From patchwork Thu Apr 5 16:47:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gianluca Gennari X-Patchwork-Id: 10591 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1SFpqO-0006Hb-T7 for patchwork@linuxtv.org; Thu, 05 Apr 2012 18:47:32 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-4) with esmtp for id 1SFpqO-0001b6-AO; Thu, 05 Apr 2012 18:47:32 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753913Ab2DEQra (ORCPT ); Thu, 5 Apr 2012 12:47:30 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:50332 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753150Ab2DEQr3 (ORCPT ); Thu, 5 Apr 2012 12:47:29 -0400 Received: by wgbdr13 with SMTP id dr13so1502771wgb.1 for ; Thu, 05 Apr 2012 09:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=MVFjL4BbQ/WdorNYqfq7Cn3o5JNPfGOBgl+DjkSktzo=; b=v0KeV6Fn+DW/c7tNYFkYi2qvhk8fzxrgdx/lfCSY9vqQldmTqn6Yc2CteEV/5Fk7kn aq562sLhxEJhKKvRnVD4vyPn5sJdYNrQpywwXatPrOxARWz2FFFz7QPQgTi9rvvdwBdc 7vilNJP1kZWEY0Y2R7cPZYq3p+OepFR2/8Yfln+aTKdpiLJPOStxn3iPHBMvgaIoeyhD d0s/cp+CAKDWLyjZbcik7WzkSdqzoMlp/zh3MP7U2D0HqvvYM3tgenN3CzzHYzekgfvL bC1LY9gxWaNKx+IkTdLPkUvxXf+L9z5LGGsolu2xtZNCVGj3oh7HDg0Q2EHDBKS5xnV0 cIcQ== Received: by 10.180.86.132 with SMTP id p4mr6452647wiz.15.1333644448135; Thu, 05 Apr 2012 09:47:28 -0700 (PDT) Received: from localhost.localdomain (93-50-34-119.ip150.fastwebnet.it. [93.50.34.119]) by mx.google.com with ESMTPS id l5sm14932848wia.11.2012.04.05.09.47.26 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Apr 2012 09:47:27 -0700 (PDT) From: Gianluca Gennari To: linux-media@vger.kernel.org, crope@iki.fi Cc: m@bues.ch, hfvogt@gmx.net, mchehab@redhat.com, Gianluca Gennari Subject: [PATCH] af9033: implement get_frontend Date: Thu, 5 Apr 2012 18:47:19 +0200 Message-Id: <1333644439-1875-1-git-send-email-gennarone@gmail.com> X-Mailer: git-send-email 1.7.0.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.4.5.163638 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' FORGED_FROM_GMAIL 0.1, MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' Implement the get_frontend function. The code is derived from the old af9033 driver by Antti Palosaari. Signed-off-by: Gianluca Gennari --- drivers/media/dvb/frontends/af9033.c | 133 ++++++++++++++++++++++++++++++++++ 1 files changed, 133 insertions(+), 0 deletions(-) diff --git a/drivers/media/dvb/frontends/af9033.c b/drivers/media/dvb/frontends/af9033.c index 5fadee7..da91155 100644 --- a/drivers/media/dvb/frontends/af9033.c +++ b/drivers/media/dvb/frontends/af9033.c @@ -26,6 +26,7 @@ struct af9033_state { struct dvb_frontend fe; struct af9033_config cfg; + u32 frequency; u32 bandwidth_hz; bool ts_mode_parallel; bool ts_mode_serial; @@ -406,6 +407,8 @@ static int af9033_set_frontend(struct dvb_frontend *fe) pr_debug("%s: frequency=%d bandwidth_hz=%d\n", __func__, c->frequency, c->bandwidth_hz); + state->frequency = c->frequency; + /* check bandwidth */ switch (c->bandwidth_hz) { case 6000000: @@ -523,6 +526,135 @@ err: return ret; } +static int af9033_get_frontend(struct dvb_frontend *fe) +{ + struct dtv_frontend_properties *p = &fe->dtv_property_cache; + struct af9033_state *state = fe->demodulator_priv; + int ret; + u8 buf[8]; + + pr_debug("%s\n", __func__); + + /* read all needed registers */ + ret = af9033_rd_regs(state, 0x80f900, buf, sizeof(buf)); + if (ret) + goto error; + + switch ((buf[0] >> 0) & 3) { + case 0: + p->transmission_mode = TRANSMISSION_MODE_2K; + break; + case 1: + p->transmission_mode = TRANSMISSION_MODE_8K; + break; + } + + switch ((buf[1] >> 0) & 3) { + case 0: + p->guard_interval = GUARD_INTERVAL_1_32; + break; + case 1: + p->guard_interval = GUARD_INTERVAL_1_16; + break; + case 2: + p->guard_interval = GUARD_INTERVAL_1_8; + break; + case 3: + p->guard_interval = GUARD_INTERVAL_1_4; + break; + } + + switch ((buf[2] >> 0) & 7) { + case 0: + p->hierarchy = HIERARCHY_NONE; + break; + case 1: + p->hierarchy = HIERARCHY_1; + break; + case 2: + p->hierarchy = HIERARCHY_2; + break; + case 3: + p->hierarchy = HIERARCHY_4; + break; + } + + switch ((buf[3] >> 0) & 3) { + case 0: + p->modulation = QPSK; + break; + case 1: + p->modulation = QAM_16; + break; + case 2: + p->modulation = QAM_64; + break; + } + + switch ((buf[4] >> 0) & 3) { + case 0: + p->bandwidth_hz = 6000000; + break; + case 1: + p->bandwidth_hz = 7000000; + break; + case 2: + p->bandwidth_hz = 8000000; + break; + } + + switch ((buf[6] >> 0) & 7) { + case 0: + p->code_rate_HP = FEC_1_2; + break; + case 1: + p->code_rate_HP = FEC_2_3; + break; + case 2: + p->code_rate_HP = FEC_3_4; + break; + case 3: + p->code_rate_HP = FEC_5_6; + break; + case 4: + p->code_rate_HP = FEC_7_8; + break; + case 5: + p->code_rate_HP = FEC_NONE; + break; + } + + switch ((buf[7] >> 0) & 7) { + case 0: + p->code_rate_LP = FEC_1_2; + break; + case 1: + p->code_rate_LP = FEC_2_3; + break; + case 2: + p->code_rate_LP = FEC_3_4; + break; + case 3: + p->code_rate_LP = FEC_5_6; + break; + case 4: + p->code_rate_LP = FEC_7_8; + break; + case 5: + p->code_rate_LP = FEC_NONE; + break; + } + + p->inversion = INVERSION_AUTO; + p->frequency = state->frequency; + +error: + if (ret) + pr_debug("%s: failed:%d\n", __func__, ret); + + return ret; +} + static int af9033_read_status(struct dvb_frontend *fe, fe_status_t *status) { struct af9033_state *state = fe->demodulator_priv; @@ -776,6 +908,7 @@ static struct dvb_frontend_ops af9033_ops = { .get_tune_settings = af9033_get_tune_settings, .set_frontend = af9033_set_frontend, + .get_frontend = af9033_get_frontend, .read_status = af9033_read_status, .read_snr = af9033_read_snr,