From patchwork Mon Aug 4 04:29:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antti Palosaari X-Patchwork-Id: 25146 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1XE9uH-0001Wr-Rv; Mon, 04 Aug 2014 06:29:57 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-8) with esmtp id 1XE9uF-0004Ug-lZ; Mon, 04 Aug 2014 06:29:57 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751495AbaHDE3u (ORCPT + 1 other); Mon, 4 Aug 2014 00:29:50 -0400 Received: from mail.kapsi.fi ([217.30.184.167]:44878 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750925AbaHDE3s (ORCPT ); Mon, 4 Aug 2014 00:29:48 -0400 Received: from 85-23-164-198.bb.dnainternet.fi ([85.23.164.198] helo=localhost.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1XE9u7-0006kL-NH; Mon, 04 Aug 2014 07:29:47 +0300 From: Antti Palosaari To: linux-media@vger.kernel.org Cc: Antti Palosaari Subject: [PATCH 2/9] ddbridge: I2C client for tda18212 Date: Mon, 4 Aug 2014 07:29:24 +0300 Message-Id: <1407126571-21629-2-git-send-email-crope@iki.fi> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1407126571-21629-1-git-send-email-crope@iki.fi> References: <1407126571-21629-1-git-send-email-crope@iki.fi> X-SA-Exim-Connect-IP: 85.23.164.198 X-SA-Exim-Mail-From: crope@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2014.8.4.42118 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __DATE_TZ_RU 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' Used tda18212 tuner is implemented as a I2C driver. Implement I2C client to ddbridge and use it for tda18212. Signed-off-by: Antti Palosaari --- drivers/media/pci/ddbridge/ddbridge-core.c | 70 +++++++++++++++++------------- drivers/media/pci/ddbridge/ddbridge.h | 1 + 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index c66b1b3..ccd6a57 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -834,45 +834,47 @@ static int tuner_attach_tda18271(struct ddb_input *input) return 0; } -static struct tda18212_config tda18212_config_60 = { - .i2c_address = 0x60, - .if_dvbt_6 = 3550, - .if_dvbt_7 = 3700, - .if_dvbt_8 = 4150, - .if_dvbt2_6 = 3250, - .if_dvbt2_7 = 4000, - .if_dvbt2_8 = 4000, - .if_dvbc = 5000, -}; - -static struct tda18212_config tda18212_config_63 = { - .i2c_address = 0x63, - .if_dvbt_6 = 3550, - .if_dvbt_7 = 3700, - .if_dvbt_8 = 4150, - .if_dvbt2_6 = 3250, - .if_dvbt2_7 = 4000, - .if_dvbt2_8 = 4000, - .if_dvbc = 5000, -}; - static int tuner_attach_tda18212(struct ddb_input *input) { - struct i2c_adapter *i2c = &input->port->i2c->adap; + struct i2c_adapter *adapter = &input->port->i2c->adap; struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; - struct dvb_frontend *fe; - struct tda18212_config *config; + struct i2c_client *client; + struct tda18212_config config = { + .fe = dvb->fe, + .if_dvbt_6 = 3550, + .if_dvbt_7 = 3700, + .if_dvbt_8 = 4150, + .if_dvbt2_6 = 3250, + .if_dvbt2_7 = 4000, + .if_dvbt2_8 = 4000, + .if_dvbc = 5000, + }; + struct i2c_board_info board_info = { + .type = "tda18212", + .platform_data = &config, + }; if (input->nr & 1) - config = &tda18212_config_63; + board_info.addr = 0x63; else - config = &tda18212_config_60; + board_info.addr = 0x60; - fe = dvb_attach(tda18212_attach, dvb->fe, i2c, config); - if (!fe) { - pr_err("No TDA18212 found!\n"); - return -ENODEV; + request_module(board_info.type); + + client = i2c_new_device(adapter, &board_info); + if (client == NULL || client->dev.driver == NULL) + goto err; + + if (!try_module_get(client->dev.driver->owner)) { + i2c_unregister_device(client); + goto err; } + + dvb->i2c_client[0] = client; + + return 0; +err: + dev_notice(input->port->dev->dev, "TDA18212 tuner not found. Device is not fully operational.\n"); return 0; } @@ -1059,9 +1061,15 @@ static void dvb_input_detach(struct ddb_input *input) { struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; struct dvb_demux *dvbdemux = &dvb->demux; + struct i2c_client *client; switch (dvb->attached) { case 0x31: + client = dvb->i2c_client[0]; + if (client) { + module_put(client->dev.driver->owner); + i2c_unregister_device(client); + } if (dvb->fe2) dvb_unregister_frontend(dvb->fe2); if (dvb->fe) diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h index 601cf24..2f98ac6 100644 --- a/drivers/media/pci/ddbridge/ddbridge.h +++ b/drivers/media/pci/ddbridge/ddbridge.h @@ -181,6 +181,7 @@ struct ddb_dvb { struct dvb_adapter *adap; int adap_registered; struct dvb_device *dev; + struct i2c_client *i2c_client[1]; struct dvb_frontend *fe; struct dvb_frontend *fe2; struct dmxdev dmxdev;