From patchwork Mon Feb 12 21:45:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Love X-Patchwork-Id: 10214539 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 8FD0360236 for ; Mon, 12 Feb 2018 21:45:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79F8E28D51 for ; Mon, 12 Feb 2018 21:45:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E92428D55; Mon, 12 Feb 2018 21:45:53 +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, 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 E780928D3F for ; Mon, 12 Feb 2018 21:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932444AbeBLVpv (ORCPT ); Mon, 12 Feb 2018 16:45:51 -0500 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:54635 "EHLO homiemail-a117.g.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932204AbeBLVpv (ORCPT ); Mon, 12 Feb 2018 16:45:51 -0500 Received: from homiemail-a117.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a117.g.dreamhost.com (Postfix) with ESMTP id 3A2B960001A04; Mon, 12 Feb 2018 13:45:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=nextdimension.cc; h=from :to:cc:subject:date:message-id:in-reply-to:references; s= nextdimension.cc; bh=ryjPg30bzymnaYWwgj0pHCtigpU=; b=QAFokVz/uv+ Jd/rnONOnLWm8IkMqrgDnxElr4jWDyj+p8zUPtJ5LS3uFX13alnOd2tE6IuWkZ/I W1UQqZ085P7M8maSkTNRhNUoVFhg/RUdN+IHZH5LiVfpYlNzz2A0I4LPU2w8Jl0h F407ppYDVZNh4Df2YYbnxtnBJeOdmeBI= Received: from localhost.localdomain (66-90-189-166.dyn.grandenetworks.net [66.90.189.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: brad@nextdimension.ws) by homiemail-a117.g.dreamhost.com (Postfix) with ESMTPSA id EE19F60001201; Mon, 12 Feb 2018 13:45:50 -0800 (PST) From: Brad Love To: linux-media@vger.kernel.org Cc: Brad Love Subject: [PATCH v2 7/7] cx231xx: Add second i2c demod to Hauppauge 975 Date: Mon, 12 Feb 2018 15:45:19 -0600 Message-Id: <1518471919-29885-1-git-send-email-brad@nextdimension.cc> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515773982-6411-8-git-send-email-brad@nextdimension.cc> References: <1515773982-6411-8-git-send-email-brad@nextdimension.cc> 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 Hauppauge HVR-975 is a hybrid, dual frontend, single tuner USB device. It contains lgdt3306a and si2168 frontends and one si2157 tuner. The lgdt3306a frontend is currently enabled. This creates the second demodulator and attaches it to the tuner. Enables lgdt3306a|si2168 + si2157 Signed-off-by: Brad Love --- Changes since v1: - memcpy tuner ops to frontend[1] instead of dvb attach - remove a couple redundant dev-> spots - moved failure messages one block up where probe would fail drivers/media/usb/cx231xx/cx231xx-cards.c | 1 + drivers/media/usb/cx231xx/cx231xx-dvb.c | 52 +++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 8582568..00e88a8f 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -979,6 +979,7 @@ struct cx231xx_board cx231xx_boards[] = { .demod_i2c_master = I2C_1_MUX_3, .has_dvb = 1, .demod_addr = 0x59, /* 0xb2 >> 1 */ + .demod_addr2 = 0x64, /* 0xc8 >> 1 */ .norm = V4L2_STD_ALL, .input = {{ diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c index ac3ad77..f1ffb57 100644 --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c @@ -1173,14 +1173,17 @@ static int dvb_init(struct cx231xx *dev) { struct i2c_client *client; struct i2c_adapter *adapter; + struct i2c_adapter *adapter2; struct i2c_board_info info = {}; struct si2157_config si2157_config = {}; struct lgdt3306a_config lgdt3306a_config = {}; + struct si2168_config si2168_config = {}; - /* attach demodulator chip */ + /* attach first demodulator chip */ lgdt3306a_config = hauppauge_955q_lgdt3306a_config; lgdt3306a_config.fe = &dev->dvb->frontend[0]; lgdt3306a_config.i2c_adapter = &adapter; + lgdt3306a_config.deny_i2c_rptr = 0; strlcpy(info.type, "lgdt3306a", sizeof(info.type)); info.addr = dev->board.demod_addr; @@ -1202,10 +1205,43 @@ static int dvb_init(struct cx231xx *dev) } dvb->i2c_client_demod[0] = client; - dev->dvb->frontend[0]->ops.i2c_gate_ctrl = NULL; + + /* attach second demodulator chip */ + si2168_config.ts_mode = SI2168_TS_SERIAL; + si2168_config.fe = &dev->dvb->frontend[1]; + si2168_config.i2c_adapter = &adapter2; + si2168_config.ts_clock_inv = true; + + memset(&info, 0, sizeof(struct i2c_board_info)); + strlcpy(info.type, "si2168", sizeof(info.type)); + info.addr = dev->board.demod_addr2; + info.platform_data = &si2168_config; + + request_module(info.type); + client = i2c_new_device(adapter, &info); + if (client == NULL || client->dev.driver == NULL) { + dev_err(dev->dev, + "Failed to attach %s frontend.\n", info.type); + module_put(dvb->i2c_client_demod[0]->dev.driver->owner); + i2c_unregister_device(dvb->i2c_client_demod[0]); + result = -ENODEV; + goto out_free; + } + + if (!try_module_get(client->dev.driver->owner)) { + i2c_unregister_device(client); + module_put(dvb->i2c_client_demod[0]->dev.driver->owner); + i2c_unregister_device(dvb->i2c_client_demod[0]); + result = -ENODEV; + goto out_free; + } + + dvb->i2c_client_demod[1] = client; + dvb->frontend[1]->id = 1; /* define general-purpose callback pointer */ dvb->frontend[0]->callback = cx231xx_tuner_callback; + dvb->frontend[1]->callback = cx231xx_tuner_callback; /* attach tuner */ si2157_config.fe = dev->dvb->frontend[0]; @@ -1225,6 +1261,8 @@ static int dvb_init(struct cx231xx *dev) if (client == NULL || client->dev.driver == NULL) { dev_err(dev->dev, "Failed to obtain %s tuner.\n", info.type); + module_put(dvb->i2c_client_demod[1]->dev.driver->owner); + i2c_unregister_device(dvb->i2c_client_demod[1]); module_put(dvb->i2c_client_demod[0]->dev.driver->owner); i2c_unregister_device(dvb->i2c_client_demod[0]); result = -ENODEV; @@ -1233,6 +1271,8 @@ static int dvb_init(struct cx231xx *dev) if (!try_module_get(client->dev.driver->owner)) { i2c_unregister_device(client); + module_put(dvb->i2c_client_demod[1]->dev.driver->owner); + i2c_unregister_device(dvb->i2c_client_demod[1]); module_put(dvb->i2c_client_demod[0]->dev.driver->owner); i2c_unregister_device(dvb->i2c_client_demod[0]); result = -ENODEV; @@ -1240,7 +1280,13 @@ static int dvb_init(struct cx231xx *dev) } dev->cx231xx_reset_analog_tuner = NULL; - dev->dvb->i2c_client_tuner = client; + dvb->i2c_client_tuner = client; + + dvb->frontend[1]->tuner_priv = dvb->frontend[0]->tuner_priv; + + memcpy(&dvb->frontend[1]->ops.tuner_ops, + &dvb->frontend[0]->ops.tuner_ops, + sizeof(struct dvb_tuner_ops)); break; } default: