From patchwork Sun Feb 25 12:31:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10240851 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 759CB603B4 for ; Sun, 25 Feb 2018 12:31:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6898829CBE for ; Sun, 25 Feb 2018 12:31:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D63829CE4; Sun, 25 Feb 2018 12:31:59 +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 DA07D29CBE for ; Sun, 25 Feb 2018 12:31:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751798AbeBYMb5 (ORCPT ); Sun, 25 Feb 2018 07:31:57 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:54643 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751771AbeBYMbu (ORCPT ); Sun, 25 Feb 2018 07:31:50 -0500 Received: by mail-wm0-f67.google.com with SMTP id z81so12517639wmb.4 for ; Sun, 25 Feb 2018 04:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=qOUPVp+YL0BHKGUsf2bwwI/SQ0hLRgyEhJ7UvzZRu80=; b=ft2tPGcRm/7wbkbrU6uYFcohJbRZk+8v6apLE9JHNEclWcPpfoPZ7AJFIPI3wS71/W kxwmMJVNNw965E8dJTepv9Wn8EdV6G+9ee8B2fuo9Bc7g0XVLLMB/7MYnpBVA1Z7xqDS p/BTCWa90LzISYxzJcb264ecV5FPrzLnKk4n+D4pDnCjh1OzNMJlE1NYBab39Gs5nJuo YYghGvOuWtfLXGn7eTZwmzpJInJL/yHSWiwbyILCgxSzz4z454UUmBUByrheCu8LtSQS 6A8C0OvLQqObIW73K4y1YNAr20nbBatl0dEachgzibG6poeeFrh8qQzBvohadeBjfF3a SvmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=qOUPVp+YL0BHKGUsf2bwwI/SQ0hLRgyEhJ7UvzZRu80=; b=BI/XoCro62oRnOtB+DWrheQx9jaY6fYGitM/XHGv3GOijx8o8+xN/4LGPtY67a1xpv QCdCQ8mRlZ/x32C7bdufsBHz+XIG/JEVAKcY8dQLx9ky3pt9FaESbU91IqJxqnAyYjjD iKS4vD5c1bwPj06hRY5xuNeN08xJupoHTLvwDdvqdEFotFs1nHNCrfT4PqCJe0SRTkwC VmxYON5qSvShiFyrErTPZGfBgowkx0LEsOKTx2kKLiz3H2hnXaOymXbJfPOKuVs+fhSC KdCHdAMWbr7/AYbdcQ/l2RNIJCm7usCIKggM056mFQBtXfvCab8bqisjCGLumcbv0Rbx QT4Q== X-Gm-Message-State: APf1xPCprcc34i0Zfoer0n/J2LOtWk8ywHUENbImv9/gU9gyvkT+307B IAwBMvAcbwcu9bhLp3HXImLC8A== X-Google-Smtp-Source: AG47ELvcJqCvVbsfQg9+/IXs0+K7r5LhIQHM3QD9P+Y+0DPKmOIOcwC7/wF70ImRlM19L6w9cZgLAw== X-Received: by 10.28.173.130 with SMTP id w124mr5512114wme.18.1519561908900; Sun, 25 Feb 2018 04:31:48 -0800 (PST) Received: from dvbdev.wuest.de (ip-84-118-193-200.unity-media.net. [84.118.193.200]) by smtp.gmail.com with ESMTPSA id y34sm15304779wry.19.2018.02.25.04.31.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Feb 2018 04:31:48 -0800 (PST) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Subject: [PATCH v2 06/12] [media] ngene: add support for Sony CXD28xx-based DuoFlex modules Date: Sun, 25 Feb 2018 13:31:34 +0100 Message-Id: <20180225123140.19486-7-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180225123140.19486-1-d.scheller.oss@gmail.com> References: <20180225123140.19486-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 Recognize (probe) and support (attach) all Sony CXD28xx based DuoFlex addon modules/cards, namely the DuoFlex CT2 (CXD2837), ISDB-T (CXD2838), C2T2 (CXD2843) and C2T2I (CXD2854). Since all these modules are equipped with a MachXO2 interface, that support is required for the hardware to work. This functionality utilises the auxiliary cxd2841er and tda18212 drivers. This also adds autoselection (if MEDIA_SUBDRV_AUTOSELECT) of the CXD2841ER demod driver to Kconfig. The __maybe_unused annotation can now be removed from the xo2names array. Signed-off-by: Daniel Scheller --- drivers/media/pci/ngene/Kconfig | 1 + drivers/media/pci/ngene/ngene-cards.c | 63 ++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/drivers/media/pci/ngene/Kconfig b/drivers/media/pci/ngene/Kconfig index c3254f9dc8ad..f717567f54a5 100644 --- a/drivers/media/pci/ngene/Kconfig +++ b/drivers/media/pci/ngene/Kconfig @@ -9,6 +9,7 @@ config DVB_NGENE select DVB_TDA18271C2DD if MEDIA_SUBDRV_AUTOSELECT select MEDIA_TUNER_MT2131 if MEDIA_SUBDRV_AUTOSELECT select DVB_STV0367 if MEDIA_SUBDRV_AUTOSELECT + select DVB_CXD2841ER if MEDIA_SUBDRV_AUTOSELECT select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT select DVB_CXD2099 if MEDIA_SUBDRV_AUTOSELECT ---help--- diff --git a/drivers/media/pci/ngene/ngene-cards.c b/drivers/media/pci/ngene/ngene-cards.c index 05b8e56999ec..cdc8db14c606 100644 --- a/drivers/media/pci/ngene/ngene-cards.c +++ b/drivers/media/pci/ngene/ngene-cards.c @@ -45,6 +45,7 @@ #include "stv0367.h" #include "stv0367_priv.h" #include "tda18212.h" +#include "cxd2841er.h" /****************************************************************************/ /* I2C transfer functions used for demod/tuner probing***********************/ @@ -277,6 +278,10 @@ static int tuner_attach_probe(struct ngene_channel *chan) case DEMOD_TYPE_DRXK: return tuner_attach_tda18271(chan); case DEMOD_TYPE_STV0367: + case DEMOD_TYPE_SONY_CT2: + case DEMOD_TYPE_SONY_ISDBT: + case DEMOD_TYPE_SONY_C2T2: + case DEMOD_TYPE_SONY_C2T2I: return tuner_attach_tda18212(chan, chan->demod_type); } @@ -358,6 +363,34 @@ static int demod_attach_stv0367(struct ngene_channel *chan, return 0; } +static int demod_attach_cxd28xx(struct ngene_channel *chan, + struct i2c_adapter *i2c, int osc24) +{ + struct device *pdev = &chan->dev->pci_dev->dev; + struct cxd2841er_config cfg; + + /* the cxd2841er driver expects 8bit/shifted I2C addresses */ + cfg.i2c_addr = ((chan->number & 1) ? 0x6d : 0x6c) << 1; + + cfg.xtal = osc24 ? SONY_XTAL_24000 : SONY_XTAL_20500; + cfg.flags = CXD2841ER_AUTO_IFHZ | CXD2841ER_EARLY_TUNE | + CXD2841ER_NO_WAIT_LOCK | CXD2841ER_NO_AGCNEG | + CXD2841ER_TSBITS | CXD2841ER_TS_SERIAL; + + /* attach frontend */ + chan->fe = dvb_attach(cxd2841er_attach_t_c, &cfg, i2c); + + if (!chan->fe) { + dev_err(pdev, "CXD28XX attach failed!\n"); + return -ENODEV; + } + + chan->fe->sec_priv = chan; + chan->gate_ctrl = chan->fe->ops.i2c_gate_ctrl; + chan->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl; + return 0; +} + static void cineS2_tuner_i2c_lock(struct dvb_frontend *fe, int lock) { struct ngene_channel *chan = fe->analog_demod_priv; @@ -426,7 +459,7 @@ static int demod_attach_drxk(struct ngene_channel *chan, /* XO2 related lists and functions ******************************************/ /****************************************************************************/ -static char __maybe_unused *xo2names[] = { +static char *xo2names[] = { "DUAL DVB-S2", "DUAL DVB-C/T/T2", "DUAL DVB-ISDBT", @@ -513,7 +546,8 @@ static int cineS2_probe(struct ngene_channel *chan) struct i2c_adapter *i2c; struct stv090x_config *fe_conf; u8 buf[3]; - u8 xo2_type, xo2_id; + u8 xo2_type, xo2_id, xo2_demodtype; + u8 sony_osc24 = 0; struct i2c_msg i2c_msg = { .flags = 0, .buf = buf }; int rc; @@ -537,9 +571,28 @@ static int cineS2_probe(struct ngene_channel *chan) else init_xo2(chan, i2c); - /* TODO: implement support for XO2 module types */ - dev_warn(pdev, "XO2 not supported\n"); - return -ENODEV; + xo2_demodtype = DEMOD_TYPE_XO2 + xo2_id; + + switch (xo2_demodtype) { + case DEMOD_TYPE_SONY_CT2: + case DEMOD_TYPE_SONY_ISDBT: + case DEMOD_TYPE_SONY_C2T2: + case DEMOD_TYPE_SONY_C2T2I: + dev_info(pdev, "%s (XO2) on channel %d\n", + xo2names[xo2_id], chan->number); + chan->demod_type = xo2_demodtype; + if (xo2_demodtype == DEMOD_TYPE_SONY_C2T2I) + sony_osc24 = 1; + + demod_attach_cxd28xx(chan, i2c, sony_osc24); + break; + default: + dev_warn(pdev, + "Unsupported XO2 module on channel %d\n", + chan->number); + return -ENODEV; + } + break; case NGENE_XO2_TYPE_CI: dev_info(pdev, "DuoFlex CI modules not supported\n"); return -ENODEV;