From patchwork Tue Jul 11 21:06:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 9835479 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 918D860363 for ; Tue, 11 Jul 2017 21:06:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80BAB2844C for ; Tue, 11 Jul 2017 21:06:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7322328515; Tue, 11 Jul 2017 21:06:12 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 140A62844C for ; Tue, 11 Jul 2017 21:06:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932870AbdGKVGK (ORCPT ); Tue, 11 Jul 2017 17:06:10 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:35311 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932536AbdGKVGK (ORCPT ); Tue, 11 Jul 2017 17:06:10 -0400 Received: by mail-wr0-f196.google.com with SMTP id z45so1066929wrb.2 for ; Tue, 11 Jul 2017 14:06:09 -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; bh=IzGFYDM8uZOAOF/LsNvXwn9mXh4ndvFo7E7QWEq41i8=; b=YFiJ1QLTq1DhCGniUSuxhuIX4SjtbLmV6GXsKeqoLoL/HxIlgjUuxHTskFX8tAj1Jg BWZDNJPe6a9zVtQr/EL/AD6oAU3SUekdw4nzr3diLGKqH9KhTyrG02coiH+KPLdvIDZX utr1p5vTAr0DgC2plC6po3BQF7g3vqup3sEAEacnjBlm/yTkMjfTMSfmnUQohMybfkRZ KEsef/5osktvuD2WgI+34xS/rD78yT7ooGgaxuIC+O7h1fw+F7zwc6yjov02V311Cplt OPrDvWwD0iNQb+7fAlft3zC4xkfg/OnYdCihD0+AsjglexHV2DzDkbIALCiOhJNzOp3w Gf+A== 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; bh=IzGFYDM8uZOAOF/LsNvXwn9mXh4ndvFo7E7QWEq41i8=; b=p+u2QKq4cBUgsbacx/Wo9CL7hdLtINcrzqSDylIjlHeWChL17DnP9AegdFtH5Ta8PA ndTUSDfia5EKaU0Prdt/AEWq+ykQ14DFdDpus82qfg5CVJp28ipI+oTMwNJooaM+Hbqi k+CTLA9i8NUJafaWxZaIOQrD3UJGbLPVxks/SXnoPvkaulRaxQjfOyEV/UGnm4eesUdj VA7gKBb80qOtIrOfvw4zUoXi5cUDS7czUVQW6SsFPPVyBWM6d1ssQ3nBdsgWHELHeRAa P/BUC0utB2vRnK1BemjnoCBY5Tc0Tr18hUM7DpG4RDaEq6DjQ+Cj+dxTaX+RNwL6+uHB +bfg== X-Gm-Message-State: AIVw113NI86GyZsx423OxL4ZZh3w1DYjwrgd54bSG86bGhC30ikH3Ipd 5lWqX1zMIQE43/Oy X-Received: by 10.28.232.29 with SMTP id f29mr139571wmh.55.1499807168369; Tue, 11 Jul 2017 14:06:08 -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 142sm346211wmi.1.2017.07.11.14.06.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Jul 2017 14:06:07 -0700 (PDT) From: Daniel Scheller To: linux-media@vger.kernel.org, aospan@netup.ru, serjk@netup.ru Cc: mchehab@kernel.org, mchehab@s-opensource.com Subject: [PATCH] [media] dvb-frontends/cxd2841er: do sleep on delivery system change Date: Tue, 11 Jul 2017 23:06:05 +0200 Message-Id: <20170711210605.408-1-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.13.0 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 Discovered using w_scan when scanning DVB-T/T2: When w_scan goes from -T to -T2, it does so without stopping the frontend using .sleep. Due to this, the demod operation mode isn't re-setup, but as it still is in STATE_ACTIVE_TC, PLP and T2 Profile are set up, but only retune_active() is called, leaving the demod in T mode, thus not operable on any T2 frequency. Fix this by putting the demod to sleep if priv->system isn't equal to p->delsys. To properly accomplish this, sleep_tc() is split into sleep_tc() and shutdown_tc(), where sleep_tc() will only perform the sleep operation, while shutdown_tc() additionally performs the full demod shutdown (to keep the behaviour when the .sleep FE_OP is called). Signed-off-by: Daniel Scheller Acked-by: Abylay Ospan --- drivers/media/dvb-frontends/cxd2841er.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index 12bff778c97f..f663f5c4a7a8 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -487,6 +487,8 @@ static int cxd2841er_sleep_tc_to_shutdown(struct cxd2841er_priv *priv); static int cxd2841er_shutdown_to_sleep_tc(struct cxd2841er_priv *priv); +static int cxd2841er_sleep_tc(struct dvb_frontend *fe); + static int cxd2841er_retune_active(struct cxd2841er_priv *priv, struct dtv_frontend_properties *p) { @@ -3378,6 +3380,14 @@ static int cxd2841er_set_frontend_tc(struct dvb_frontend *fe) if (priv->flags & CXD2841ER_EARLY_TUNE) cxd2841er_tuner_set(fe); + /* deconfigure/put demod to sleep on delsys switch if active */ + if (priv->state == STATE_ACTIVE_TC && + priv->system != p->delivery_system) { + dev_dbg(&priv->i2c->dev, "%s(): old_delsys=%d, new_delsys=%d -> sleep\n", + __func__, priv->system, p->delivery_system); + cxd2841er_sleep_tc(fe); + } + if (p->delivery_system == SYS_DVBT) { priv->system = SYS_DVBT; switch (priv->state) { @@ -3594,6 +3604,7 @@ static int cxd2841er_sleep_tc(struct dvb_frontend *fe) struct cxd2841er_priv *priv = fe->demodulator_priv; dev_dbg(&priv->i2c->dev, "%s()\n", __func__); + if (priv->state == STATE_ACTIVE_TC) { switch (priv->system) { case SYS_DVBT: @@ -3619,7 +3630,17 @@ static int cxd2841er_sleep_tc(struct dvb_frontend *fe) __func__, priv->state); return -EINVAL; } - cxd2841er_sleep_tc_to_shutdown(priv); + return 0; +} + +static int cxd2841er_shutdown_tc(struct dvb_frontend *fe) +{ + struct cxd2841er_priv *priv = fe->demodulator_priv; + + dev_dbg(&priv->i2c->dev, "%s()\n", __func__); + + if (!cxd2841er_sleep_tc(fe)) + cxd2841er_sleep_tc_to_shutdown(priv); return 0; } @@ -3968,7 +3989,7 @@ static struct dvb_frontend_ops cxd2841er_t_c_ops = { .symbol_rate_max = 11700000 }, .init = cxd2841er_init_tc, - .sleep = cxd2841er_sleep_tc, + .sleep = cxd2841er_shutdown_tc, .release = cxd2841er_release, .set_frontend = cxd2841er_set_frontend_tc, .get_frontend = cxd2841er_get_frontend,