From patchwork Mon Nov 5 23:28:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 15354 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1TVW5y-00041X-9G for patchwork@linuxtv.org; Tue, 06 Nov 2012 00:28:42 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-4) with esmtp for id 1TVW5x-0003jG-Bc; Tue, 06 Nov 2012 00:28:42 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933270Ab2KEX2i (ORCPT ); Mon, 5 Nov 2012 18:28:38 -0500 Received: from smtp209.alice.it ([82.57.200.105]:35237 "EHLO smtp209.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933070Ab2KEX2f (ORCPT ); Mon, 5 Nov 2012 18:28:35 -0500 Received: from jcn (79.3.140.100) by smtp209.alice.it (8.6.058.01) id 509136A000D9D758; Tue, 6 Nov 2012 00:28:32 +0100 Received: from ao2 by jcn with local (Exim 4.80) (envelope-from ) id 1TVW5g-0004iD-7P; Tue, 06 Nov 2012 00:28:24 +0100 From: Antonio Ospite To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Antti Palosaari , Michael Krufky , Patrick Boettcher , Antonio Ospite Subject: [PATCH 1/5] [media] dvb-usb: add a pre_init hook to struct dvb_usb_device_properties Date: Tue, 6 Nov 2012 00:28:12 +0100 Message-Id: <1352158096-17737-2-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1352158096-17737-1-git-send-email-ospite@studenti.unina.it> References: <1352158096-17737-1-git-send-email-ospite@studenti.unina.it> X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.11.5.231827 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' Some devices need to issue a pre-initialization command sequence via i2c in order to "enable" the communication with some adapter components. This happens for instance in the vp7049 USB DVB-T stick on which the frontend cannot be detected without first sending a certain sequence of commands via i2c. Signed-off-by: Antonio Ospite --- If this approach is OK I can send a similar patch for dvb-usb-v2. Are all the dvb-usb drivers going to be ported to dvb-usb-v2 eventually? drivers/media/usb/dvb-usb/dvb-usb.h | 5 +++++ drivers/media/usb/dvb-usb/dvb-usb-init.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/media/usb/dvb-usb/dvb-usb.h b/drivers/media/usb/dvb-usb/dvb-usb.h index aab0f99..1fcea68 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb.h +++ b/drivers/media/usb/dvb-usb/dvb-usb.h @@ -233,6 +233,9 @@ enum dvb_usb_mode { * @size_of_priv: how many bytes shall be allocated for the private field * of struct dvb_usb_device. * + * @pre_init: function executed after i2c initialization but + * before the adapters get initialized + * * @power_ctrl: called to enable/disable power of the device. * @read_mac_address: called to read the MAC address of the device. * @identify_state: called to determine the state (cold or warm), when it @@ -274,6 +277,8 @@ struct dvb_usb_device_properties { int size_of_priv; + int (*pre_init) (struct dvb_usb_device *); + int num_adapters; struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; diff --git a/drivers/media/usb/dvb-usb/dvb-usb-init.c b/drivers/media/usb/dvb-usb/dvb-usb-init.c index 169196e..8ab916e 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c @@ -31,6 +31,12 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs) struct dvb_usb_adapter *adap; int ret, n, o; + if (d->props.pre_init) { + ret = d->props.pre_init(d); + if (ret < 0) + return ret; + } + for (n = 0; n < d->props.num_adapters; n++) { adap = &d->adapter[n]; adap->dev = d;