From patchwork Sun Feb 25 12:31:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10240855 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 24D18603B4 for ; Sun, 25 Feb 2018 12:32:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1791229CBE for ; Sun, 25 Feb 2018 12:32:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C55D29CE4; Sun, 25 Feb 2018 12:32:03 +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 8CC4E29CBE for ; Sun, 25 Feb 2018 12:32:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751775AbeBYMcA (ORCPT ); Sun, 25 Feb 2018 07:32:00 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:51713 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751765AbeBYMbw (ORCPT ); Sun, 25 Feb 2018 07:31:52 -0500 Received: by mail-wm0-f68.google.com with SMTP id h21so12543709wmd.1 for ; Sun, 25 Feb 2018 04:31:51 -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=Il1i9Jk4otLZzdEpp29fJPLtsokXtsRbEgwhGyt6nuQ=; b=Lb0nMkD2vfD2s3wDdMptXwIrZ7yimCeOcxW8XNdKl9x+3ZqUKjZNUtxm7rkuaWDGJl CWG+PGBJFgwBfFslxgubGACIssbrrahwg/35BCd0/RylMDreXOS6/TqiykO4OLH/QXS/ f2XyiZ/i6yLWrHYUp3msD1hPfWWR6wcqL2qqu1fT9gHCfdtau0Io4+M/IOk3RjY/J7Hb cfZqgy5n0dsdEg3jV5Q8Y/3CKhKOI9IzN51014X/vLNlL9ahKUh9XY8S2Rp55NI4LtQQ Fpgs3dnr0TapmMHHj58ZYwoKOsACDuWPZiZAMlv/vsxkomHVABkrAFDA/w+FOA3D6uXw OreA== 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=Il1i9Jk4otLZzdEpp29fJPLtsokXtsRbEgwhGyt6nuQ=; b=Jev9f36ol0VGho+Mo9dhpLRf7tEtwR/7eRlTZzvNTB8DMwk9C4eKdvqTLrBLbrjaKU bNUO3gVTffOwCyaxKgoR+G2OIx6nVyITa7M7mE1dY6daPp1l7pLgy8pKpW/+z2JoiR+H 0IMt7G6Ow1Kc5fAiRkb3knTDhzu7mPAGET50Wcb/BkE5zQkeB0HnfiHmra2MJ2vkpEmo WAlYS7B1m1L/0UQvSHCW3cRYxVvuWYxIckcV7NFIeIdwYVmNnkNOzSEstqfDVIiVytsz EoeMMKQxMGrJW4PfElLzeAT40LrmrJDycx454N7cWV7zLXNFCctHPPzHKeNt9w1c9dr9 kZJQ== X-Gm-Message-State: APf1xPCzyYsuvj8XLg77Wzmk0JM+p1t7O4yLv/s7LyhMmBCG5sqGhJlo 7V/D6Z+9NUUPkQzsADciiwPgsg== X-Google-Smtp-Source: AG47ELuiKzAodEfi6MvS5UPz8uxhGE0lnhBmCe/v+ONncOLUOu6c/qFNjD5zaPqR/7DVj+W/Zvo/FA== X-Received: by 10.28.17.141 with SMTP id 135mr5517832wmr.80.1519561909982; Sun, 25 Feb 2018 04:31:49 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Feb 2018 04:31:49 -0800 (PST) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Subject: [PATCH v2 07/12] [media] ngene: add support for DuoFlex S2 V4 addon modules Date: Sun, 25 Feb 2018 13:31:35 +0100 Message-Id: <20180225123140.19486-8-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 Add support for the STV0910/STV6111/LNBH25 based DuoFlex S2 V4 DVB-S2 addon modules by recognizing them from their XO2 type value and using the auxiliary stv0910, stv6111 and lnbh25 driver to form a complete DVB frontend. This also adds autoselection (if MEDIA_SUBDRV_AUTOSELECT) of the STV0910, STV6111 and LNBH25 demod/tuner/LNB-IC drivers to Kconfig. Signed-off-by: Daniel Scheller --- drivers/media/pci/ngene/Kconfig | 3 ++ drivers/media/pci/ngene/ngene-cards.c | 83 +++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/drivers/media/pci/ngene/Kconfig b/drivers/media/pci/ngene/Kconfig index f717567f54a5..e06d019996f3 100644 --- a/drivers/media/pci/ngene/Kconfig +++ b/drivers/media/pci/ngene/Kconfig @@ -11,6 +11,9 @@ config DVB_NGENE select DVB_STV0367 if MEDIA_SUBDRV_AUTOSELECT select DVB_CXD2841ER if MEDIA_SUBDRV_AUTOSELECT select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT + select DVB_STV0910 if MEDIA_SUBDRV_AUTOSELECT + select DVB_STV6111 if MEDIA_SUBDRV_AUTOSELECT + select DVB_LNBH25 if MEDIA_SUBDRV_AUTOSELECT select DVB_CXD2099 if MEDIA_SUBDRV_AUTOSELECT ---help--- Support for Micronas PCI express cards with nGene bridge. diff --git a/drivers/media/pci/ngene/ngene-cards.c b/drivers/media/pci/ngene/ngene-cards.c index cdc8db14c606..00b100660784 100644 --- a/drivers/media/pci/ngene/ngene-cards.c +++ b/drivers/media/pci/ngene/ngene-cards.c @@ -46,6 +46,9 @@ #include "stv0367_priv.h" #include "tda18212.h" #include "cxd2841er.h" +#include "stv0910.h" +#include "stv6111.h" +#include "lnbh25.h" /****************************************************************************/ /* I2C transfer functions used for demod/tuner probing***********************/ @@ -152,6 +155,30 @@ static int tuner_attach_stv6110(struct ngene_channel *chan) return 0; } +static int tuner_attach_stv6111(struct ngene_channel *chan) +{ + struct device *pdev = &chan->dev->pci_dev->dev; + struct i2c_adapter *i2c; + struct dvb_frontend *fe; + u8 adr = 4 + ((chan->number & 1) ? 0x63 : 0x60); + + /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */ + if (chan->number < 2) + i2c = &chan->dev->channel[0].i2c_adapter; + else + i2c = &chan->dev->channel[1].i2c_adapter; + + fe = dvb_attach(stv6111_attach, chan->fe, i2c, adr); + if (!fe) { + fe = dvb_attach(stv6111_attach, chan->fe, i2c, adr & ~4); + if (!fe) { + dev_err(pdev, "stv6111_attach() failed!\n"); + return -ENODEV; + } + } + return 0; +} + static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) { struct ngene_channel *chan = fe->sec_priv; @@ -283,6 +310,8 @@ static int tuner_attach_probe(struct ngene_channel *chan) case DEMOD_TYPE_SONY_C2T2: case DEMOD_TYPE_SONY_C2T2I: return tuner_attach_tda18212(chan, chan->demod_type); + case DEMOD_TYPE_STV0910: + return tuner_attach_stv6111(chan); } return -EINVAL; @@ -326,6 +355,54 @@ static int demod_attach_stv0900(struct ngene_channel *chan) return 0; } +static struct stv0910_cfg stv0910_p = { + .adr = 0x68, + .parallel = 1, + .rptlvl = 4, + .clk = 30000000, +}; + +static struct lnbh25_config lnbh25_cfg = { + .i2c_address = 0x0c << 1, + .data2_config = LNBH25_TEN +}; + +static int demod_attach_stv0910(struct ngene_channel *chan, + struct i2c_adapter *i2c) +{ + struct device *pdev = &chan->dev->pci_dev->dev; + struct stv0910_cfg cfg = stv0910_p; + struct lnbh25_config lnbcfg = lnbh25_cfg; + + chan->fe = dvb_attach(stv0910_attach, i2c, &cfg, (chan->number & 1)); + if (!chan->fe) { + cfg.adr = 0x6c; + chan->fe = dvb_attach(stv0910_attach, i2c, + &cfg, (chan->number & 1)); + } + if (!chan->fe) { + dev_err(pdev, "stv0910_attach() failed!\n"); + return -ENODEV; + } + + /* + * attach lnbh25 - leftshift by one as the lnbh25 driver expects 8bit + * i2c addresses + */ + lnbcfg.i2c_address = (((chan->number & 1) ? 0x0d : 0x0c) << 1); + if (!dvb_attach(lnbh25_attach, chan->fe, &lnbcfg, i2c)) { + lnbcfg.i2c_address = (((chan->number & 1) ? 0x09 : 0x08) << 1); + if (!dvb_attach(lnbh25_attach, chan->fe, &lnbcfg, i2c)) { + dev_err(pdev, "lnbh25_attach() failed!\n"); + dvb_frontend_detach(chan->fe); + chan->fe = NULL; + return -ENODEV; + } + } + + return 0; +} + static struct stv0367_config ddb_stv0367_config[] = { { .demod_address = 0x1f, @@ -586,6 +663,12 @@ static int cineS2_probe(struct ngene_channel *chan) demod_attach_cxd28xx(chan, i2c, sony_osc24); break; + case DEMOD_TYPE_STV0910: + dev_info(pdev, "%s (XO2) on channel %d\n", + xo2names[xo2_id], chan->number); + chan->demod_type = xo2_demodtype; + demod_attach_stv0910(chan, i2c); + break; default: dev_warn(pdev, "Unsupported XO2 module on channel %d\n",