From patchwork Fri Feb 7 06:59:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antti Palosaari X-Patchwork-Id: 3599911 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EF62F9F344 for ; Fri, 7 Feb 2014 06:59:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F61420145 for ; Fri, 7 Feb 2014 06:59:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CB2220115 for ; Fri, 7 Feb 2014 06:59:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750822AbaBGG7l (ORCPT ); Fri, 7 Feb 2014 01:59:41 -0500 Received: from mail.kapsi.fi ([217.30.184.167]:43575 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750715AbaBGG7k (ORCPT ); Fri, 7 Feb 2014 01:59:40 -0500 Received: from [82.128.187.60] (helo=localhost.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1WBfPR-0007OT-4s; Fri, 07 Feb 2014 08:59:33 +0200 From: Antti Palosaari To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Hans Verkuil , Antti Palosaari Subject: [PATCH 2/3] e4000: implement PLL lock v4l control Date: Fri, 7 Feb 2014 08:59:11 +0200 Message-Id: <1391756352-3841-2-git-send-email-crope@iki.fi> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1391756352-3841-1-git-send-email-crope@iki.fi> References: <1391756352-3841-1-git-send-email-crope@iki.fi> X-SA-Exim-Connect-IP: 82.128.187.60 X-SA-Exim-Mail-From: crope@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement PLL lock control to get PLL lock flag status from tuner synthesizer. Cc: Mauro Carvalho Chehab Cc: Hans Verkuil Signed-off-by: Antti Palosaari --- drivers/media/tuners/e4000.c | 53 ++++++++++++++++++++++++++++++++++++++- drivers/media/tuners/e4000_priv.h | 2 ++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c index 019dc62..662e19a1 100644 --- a/drivers/media/tuners/e4000.c +++ b/drivers/media/tuners/e4000.c @@ -181,6 +181,8 @@ static int e4000_init(struct dvb_frontend *fe) if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); + priv->active = true; + return 0; err: if (fe->ops.i2c_gate_ctrl) @@ -197,6 +199,8 @@ static int e4000_sleep(struct dvb_frontend *fe) dev_dbg(&priv->client->dev, "%s:\n", __func__); + priv->active = false; + if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); @@ -512,6 +516,50 @@ err: return ret; } +static int e4000_pll_lock(struct dvb_frontend *fe) +{ + struct e4000_priv *priv = fe->tuner_priv; + int ret; + u8 u8tmp; + + if (priv->active == false) + return 0; + + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 1); + + ret = e4000_rd_reg(priv, 0x07, &u8tmp); + if (ret) + goto err; + + priv->pll_lock->val = (u8tmp & 0x01); +err: + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 0); + + if (ret) + dev_dbg(&priv->client->dev, "%s: failed=%d\n", __func__, ret); + + return ret; +} + +static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl) +{ + struct e4000_priv *priv = + container_of(ctrl->handler, struct e4000_priv, hdl); + int ret; + + switch (ctrl->id) { + case V4L2_CID_PLL_LOCK: + ret = e4000_pll_lock(priv->fe); + break; + default: + ret = -EINVAL; + } + + return ret; +} + static int e4000_s_ctrl(struct v4l2_ctrl *ctrl) { struct e4000_priv *priv = @@ -550,6 +598,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl) } static const struct v4l2_ctrl_ops e4000_ctrl_ops = { + .g_volatile_ctrl = e4000_g_volatile_ctrl, .s_ctrl = e4000_s_ctrl, }; @@ -616,7 +665,7 @@ static int e4000_probe(struct i2c_client *client, goto err; /* Register controls */ - v4l2_ctrl_handler_init(&priv->hdl, 8); + v4l2_ctrl_handler_init(&priv->hdl, 9); priv->bandwidth_auto = v4l2_ctrl_new_std(&priv->hdl, &e4000_ctrl_ops, V4L2_CID_BANDWIDTH_AUTO, 0, 1, 1, 1); priv->bandwidth = v4l2_ctrl_new_std(&priv->hdl, &e4000_ctrl_ops, @@ -637,6 +686,8 @@ static int e4000_probe(struct i2c_client *client, priv->if_gain = v4l2_ctrl_new_std(&priv->hdl, &e4000_ctrl_ops, V4L2_CID_IF_GAIN, 0, 54, 1, 0); v4l2_ctrl_auto_cluster(2, &priv->if_gain_auto, 0, false); + priv->pll_lock = v4l2_ctrl_new_std(&priv->hdl, &e4000_ctrl_ops, + V4L2_CID_PLL_LOCK, 0, 1, 1, 0); if (priv->hdl.error) { ret = priv->hdl.error; dev_err(&priv->client->dev, "Could not initialize controls\n"); diff --git a/drivers/media/tuners/e4000_priv.h b/drivers/media/tuners/e4000_priv.h index 8cc27b3..d41dbcc 100644 --- a/drivers/media/tuners/e4000_priv.h +++ b/drivers/media/tuners/e4000_priv.h @@ -28,6 +28,7 @@ struct e4000_priv { struct i2c_client *client; u32 clock; struct dvb_frontend *fe; + bool active; /* Controls */ struct v4l2_ctrl_handler hdl; @@ -39,6 +40,7 @@ struct e4000_priv { struct v4l2_ctrl *mixer_gain; struct v4l2_ctrl *if_gain_auto; struct v4l2_ctrl *if_gain; + struct v4l2_ctrl *pll_lock; }; struct e4000_pll {