From patchwork Sun Apr 9 19:38:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9671727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1D737600CB for ; Sun, 9 Apr 2017 19:38:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09B5126E8A for ; Sun, 9 Apr 2017 19:38:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2CCF27F10; Sun, 9 Apr 2017 19:38:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B56526E8A for ; Sun, 9 Apr 2017 19:38:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752597AbdDITiq (ORCPT ); Sun, 9 Apr 2017 15:38:46 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34888 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752427AbdDITij (ORCPT ); Sun, 9 Apr 2017 15:38:39 -0400 Received: by mail-wr0-f196.google.com with SMTP id t20so26640453wra.2 for ; Sun, 09 Apr 2017 12:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dKf0y205K2PB1ZvPhRgP7s9P9kLTjSBlu6zLiKZz1eA=; b=WIkzhCvGqMx7lPtSPDR03DpCB9rZesrOU/eaI74mXvmtR9x5ars1IADoESRigG6fZj z0eMDj5FAjywZ/Hvirw5Us5lKYaTwgzNGA25qYpCdO7TLdZXI9LNLROYHUF6kbuZZbIp dxkNVoCKMGKAT+9hn6UoVVw/wDeViUapvrPD84R8jMExvNhr9jlWv/YCDo7xCHvwxJte aJA/NT3rpRL9bLBooyuf6wB7THKXqYLhgx8nmP048aZY9TQ/TtNii9jOKHkBxGWDeoOv Q1EBcvYC+j71iXuzVgIKT6KLbs87j1Uvkh4Ng0rVliwyUYxj/0xy2u+Gk0/PMHBPBkqc xKNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dKf0y205K2PB1ZvPhRgP7s9P9kLTjSBlu6zLiKZz1eA=; b=iK1Q9nLrM4h6wjteTKtwX4uAUhsMF111naT2CURLXAX9CW0lHBGCvxI9iAcmN48ehf CcTl1UXviYXsSPIlq9erGDS2/L18Wqmr1LQY/gs6FpKvLJb9T4x+TWo+y/hpNtLheIuJ 5rHJalqrvzRbO/Z9A8xcD5TkLjUselq7ds3LbFef25ej1yYnL3BGGOgowYs34YLWxown o8RydoQQre/f21+cXbQMz2n/Nt2qXphcAo+LcL2o3GZqAaskT1ZmFiBJDzm6hKDFzxsv pJ50Xoo8GDvmpJxB4Pctu6yCF5jfH6BeJSjcuYwjcT+LywRZBHZdtZj40amgstAJkvXj WBmg== X-Gm-Message-State: AN3rC/5T4beLuH8GEbdaBCKAbZR0x3k1B1jSjloR4Vp4aKVP4+DPSgR2XOPEWGPENvQQtQ== X-Received: by 10.223.171.8 with SMTP id q8mr3217245wrc.115.1491766717520; Sun, 09 Apr 2017 12:38:37 -0700 (PDT) Received: from dvbdev.wuest.de (ip-37-24-178-151.hsi14.unitymediagroup.de. [37.24.178.151]) by smtp.gmail.com with ESMTPSA id f135sm7441407wmd.7.2017.04.09.12.38.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 09 Apr 2017 12:38:36 -0700 (PDT) From: Daniel Scheller To: aospan@netup.ru, serjk@netup.ru, mchehab@kernel.org, linux-media@vger.kernel.org Cc: rjkm@metzlerbros.de Subject: [PATCH 07/19] [media] dvb-frontends/cxd2841er: make call to i2c_gate_ctrl optional Date: Sun, 9 Apr 2017 21:38:16 +0200 Message-Id: <20170409193828.18458-8-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170409193828.18458-1-d.scheller.oss@gmail.com> References: <20170409193828.18458-1-d.scheller.oss@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller Some cards/bridges wrap i2c_gate_ctrl handling with a mutex_lock(). This is e.g. done in ddbridge to protect against concurrent tuner access with regards to the dual tuner HW, where concurrent tuner reconfiguration can result in tuning fails or bad reception quality. When the tuner driver additionally tries to open the I2C gate (which e.g. the tda18212 driver does) when the demod already did this, this will lead to a deadlock. This makes the calls to i2c_gatectrl from the demod driver optional when the flag is set, leaving this to the tuner driver. For readability reasons and to not have the check duplicated multiple times, the setup is factored into cxd2841er_tuner_set(). This commit also updates the netup card driver (which seems to be the only consumer of the cxd2841er as of now). Signed-off-by: Daniel Scheller Acked-by: Abylay Ospan --- drivers/media/dvb-frontends/cxd2841er.c | 32 ++++++++++++++-------- drivers/media/dvb-frontends/cxd2841er.h | 2 ++ drivers/media/pci/netup_unidvb/netup_unidvb_core.c | 3 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index f49a09b..162a0f5 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -327,6 +327,20 @@ static u32 cxd2841er_calc_iffreq(u32 ifhz) return cxd2841er_calc_iffreq_xtal(SONY_XTAL_20500, ifhz); } +static int cxd2841er_tuner_set(struct dvb_frontend *fe) +{ + struct cxd2841er_priv *priv = fe->demodulator_priv; + + if ((priv->flags & CXD2841ER_USE_GATECTRL) && fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 1); + if (fe->ops.tuner_ops.set_params) + fe->ops.tuner_ops.set_params(fe); + if ((priv->flags & CXD2841ER_USE_GATECTRL) && fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 0); + + return 0; +} + static int cxd2841er_dvbs2_set_symbol_rate(struct cxd2841er_priv *priv, u32 symbol_rate) { @@ -3251,12 +3265,9 @@ static int cxd2841er_set_frontend_s(struct dvb_frontend *fe) dev_dbg(&priv->i2c->dev, "%s(): tune failed\n", __func__); goto done; } - if (fe->ops.i2c_gate_ctrl) - fe->ops.i2c_gate_ctrl(fe, 1); - if (fe->ops.tuner_ops.set_params) - fe->ops.tuner_ops.set_params(fe); - if (fe->ops.i2c_gate_ctrl) - fe->ops.i2c_gate_ctrl(fe, 0); + + cxd2841er_tuner_set(fe); + cxd2841er_tune_done(priv); timeout = ((3000000 + (symbol_rate - 1)) / symbol_rate) + 150; for (i = 0; i < timeout / CXD2841ER_DVBS_POLLING_INVL; i++) { @@ -3376,12 +3387,9 @@ static int cxd2841er_set_frontend_tc(struct dvb_frontend *fe) } if (ret) goto done; - if (fe->ops.i2c_gate_ctrl) - fe->ops.i2c_gate_ctrl(fe, 1); - if (fe->ops.tuner_ops.set_params) - fe->ops.tuner_ops.set_params(fe); - if (fe->ops.i2c_gate_ctrl) - fe->ops.i2c_gate_ctrl(fe, 0); + + cxd2841er_tuner_set(fe); + cxd2841er_tune_done(priv); timeout = 2500; while (timeout > 0) { diff --git a/drivers/media/dvb-frontends/cxd2841er.h b/drivers/media/dvb-frontends/cxd2841er.h index 2fb8b38..15564af 100644 --- a/drivers/media/dvb-frontends/cxd2841er.h +++ b/drivers/media/dvb-frontends/cxd2841er.h @@ -24,6 +24,8 @@ #include +#define CXD2841ER_USE_GATECTRL 1 + enum cxd2841er_xtal { SONY_XTAL_20500, /* 20.5 MHz */ SONY_XTAL_24000, /* 24 MHz */ diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c index 191bd82..5e6553f 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c @@ -122,7 +122,8 @@ static void netup_unidvb_queue_cleanup(struct netup_dma *dma); static struct cxd2841er_config demod_config = { .i2c_addr = 0xc8, - .xtal = SONY_XTAL_24000 + .xtal = SONY_XTAL_24000, + .flags = CXD2841ER_USE_GATECTRL }; static struct horus3a_config horus3a_conf = {