From patchwork Sat Jan 4 10:55:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 3433591 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 090559F2E9 for ; Sat, 4 Jan 2014 14:00:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F92A20134 for ; Sat, 4 Jan 2014 14:00:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BBE1F2013D for ; Sat, 4 Jan 2014 14:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754410AbaADOAF (ORCPT ); Sat, 4 Jan 2014 09:00:05 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:43706 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753799AbaADN7T (ORCPT ); Sat, 4 Jan 2014 08:59:19 -0500 Received: from [177.143.150.208] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1VzRky-00013k-V4; Sat, 04 Jan 2014 13:59:17 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1VzOtV-0003jz-Ip; Sat, 04 Jan 2014 08:55:53 -0200 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH v4 05/22] [media] em28xx: initialize analog I2C devices at the right place Date: Sat, 4 Jan 2014 08:55:34 -0200 Message-Id: <1388832951-11195-6-git-send-email-m.chehab@samsung.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1388832951-11195-1-git-send-email-m.chehab@samsung.com> References: <1388832951-11195-1-git-send-email-m.chehab@samsung.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to initialize the analog tuner, v4l2 should be registere first, or otherwise we get an oops: [ 51.783537] BUG: unable to handle kernel NULL pointer dereference at ) [ 51.784479] IP: [] __list_add+0x1b/0xc0 [ 51.784479] PGD 0 [ 51.784479] Oops: 0000 [#1] SMP [ 51.784479] Modules linked in: tvp5150 em28xx(+) tveeprom v4l2_common videode [ 51.784479] CPU: 0 PID: 946 Comm: systemd-udevd Not tainted 3.13.0-rc1+ #38 [ 51.784479] Hardware name: PCCHIPS P17G/P17G, BIOS 080012 05/14/2008 [ 51.784479] task: ffff880027482080 ti: ffff88003c9b6000 task.ti: ffff88003c90 [ 51.784479] RIP: 0010:[] [] __list_add+0 [ 51.784479] RSP: 0018:ffff88003c9b7a10 EFLAGS: 00010246 [ 51.784479] RAX: 0000000000000000 RBX: ffff880036d12428 RCX: 0000000000000000 [ 51.784479] RDX: ffff880036ce6040 RSI: 0000000000000000 RDI: ffff880036d12428 [ 51.784479] RBP: ffff88003c9b7a28 R08: 0000000000000000 R09: 0000000000000001 [ 51.784479] R10: 0000000000000001 R11: 0000000000000000 R12: ffff880036ce6040 [ 51.784479] R13: 0000000000000000 R14: ffff880036ce62c0 R15: ffffffffa045c176 [ 51.784479] FS: 00007fba89124880(0000) GS:ffff88003f400000(0000) knlGS:00000 [ 51.784479] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 51.784479] CR2: 0000000000000000 CR3: 000000003bccf000 CR4: 00000000000007f0 [ 51.784479] Stack: [ 51.784479] ffff880036d12428 ffff880036ce6038 0000000000000000 ffff88003c9b0 [ 51.784479] ffffffffa0425bbc ffff880028246800 ffff880036d12428 ffff880036ce8 [ 51.784479] ffff88003c9b7a80 ffffffffa044d733 ffff88003c9b7a90 ffff880036ce8 [ 51.784479] Call Trace: [ 51.784479] [] v4l2_device_register_subdev+0xdc/0x120 [vi] [ 51.784479] [] v4l2_i2c_new_subdev_board+0xa3/0x100 [v4l2] [ 51.784479] [] v4l2_i2c_new_subdev+0x6a/0x90 [v4l2_common] [ 51.784479] [] em28xx_usb_probe+0xd3b/0x10a0 [em28xx] [ 51.784479] [] usb_probe_interface+0x1c4/0x2f0 [ 51.784479] [] driver_probe_device+0x87/0x390 [ 51.784479] [] __driver_attach+0x93/0xa0 [ 51.784479] [] ? __device_attach+0x40/0x40 [ 51.784479] [] bus_for_each_dev+0x63/0xa0 [ 51.784479] [] driver_attach+0x1e/0x20 [ 51.784479] [] bus_add_driver+0x180/0x250 [ 51.784479] [] driver_register+0x64/0xf0 [ 51.784479] [] usb_register_driver+0x81/0x160 [ 51.784479] [] ? 0xffffffffa0466fff [ 51.784479] [] em28xx_usb_driver_init+0x1e/0x1000 [em28xx] [ 51.784479] [] do_one_initcall+0xfa/0x1b0 [ 51.784479] [] ? set_memory_nx+0x43/0x50 [ 51.784479] [] load_module+0x1bc6/0x24b0 [ 51.784479] [] ? store_uevent+0x40/0x40 [ 51.784479] [] SyS_finit_module+0x86/0xb0 [ 51.784479] [] system_call_fastpath+0x16/0x1b [ 51.784479] Code: ff ff 5b 41 5c 41 5d 41 5e 41 5f 5d c3 0f 1f 00 55 48 89 e [ 51.784479] RIP [] __list_add+0x1b/0xc0 [ 51.784479] RSP [ 51.784479] CR2: 0000000000000000 [ 52.218397] ---[ end trace 0bd601544e51b8a3 ]--- Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/em28xx/em28xx-cards.c | 64 -------------------------------- drivers/media/usb/em28xx/em28xx-video.c | 65 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 64 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 938daaabd8e0..d1c75e66554c 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -2362,24 +2362,6 @@ static struct em28xx_hash_table em28xx_i2c_hash[] = { }; /* NOTE: introduce a separate hash table for devices with 16 bit eeproms */ -/* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */ -static unsigned short saa711x_addrs[] = { - 0x4a >> 1, 0x48 >> 1, /* SAA7111, SAA7111A and SAA7113 */ - 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */ - I2C_CLIENT_END }; - -static unsigned short tvp5150_addrs[] = { - 0xb8 >> 1, - 0xba >> 1, - I2C_CLIENT_END -}; - -static unsigned short msp3400_addrs[] = { - 0x80 >> 1, - 0x88 >> 1, - I2C_CLIENT_END -}; - int em28xx_tuner_callback(void *ptr, int component, int command, int arg) { struct em28xx_i2c_bus *i2c_bus = ptr; @@ -2784,54 +2766,8 @@ static void em28xx_card_setup(struct em28xx *dev) /* Allow override tuner type by a module parameter */ if (tuner >= 0) dev->tuner_type = tuner; - - /* request some modules */ - if (dev->board.has_msp34xx) - v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], - "msp3400", 0, msp3400_addrs); - - if (dev->board.decoder == EM28XX_SAA711X) - v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], - "saa7115_auto", 0, saa711x_addrs); - - if (dev->board.decoder == EM28XX_TVP5150) - v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], - "tvp5150", 0, tvp5150_addrs); - - if (dev->board.adecoder == EM28XX_TVAUDIO) - v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], - "tvaudio", dev->board.tvaudio_addr, NULL); - - if (dev->board.tuner_type != TUNER_ABSENT) { - int has_demod = (dev->tda9887_conf & TDA9887_PRESENT); - - if (dev->board.radio.type) - v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], - "tuner", dev->board.radio_addr, NULL); - - if (has_demod) - v4l2_i2c_new_subdev(&dev->v4l2_dev, - &dev->i2c_adap[dev->def_i2c_bus], "tuner", - 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); - if (dev->tuner_addr == 0) { - enum v4l2_i2c_tuner_type type = - has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; - struct v4l2_subdev *sd; - - sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, - &dev->i2c_adap[dev->def_i2c_bus], "tuner", - 0, v4l2_i2c_tuner_addrs(type)); - - if (sd) - dev->tuner_addr = v4l2_i2c_subdev_addr(sd); - } else { - v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], - "tuner", dev->tuner_addr, NULL); - } - } } - static void request_module_async(struct work_struct *work) { struct em28xx *dev = container_of(work, diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index d615bff8ac09..56d1b46164a0 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -2051,6 +2051,24 @@ static struct video_device em28xx_radio_template = { .ioctl_ops = &radio_ioctl_ops, }; +/* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */ +static unsigned short saa711x_addrs[] = { + 0x4a >> 1, 0x48 >> 1, /* SAA7111, SAA7111A and SAA7113 */ + 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */ + I2C_CLIENT_END }; + +static unsigned short tvp5150_addrs[] = { + 0xb8 >> 1, + 0xba >> 1, + I2C_CLIENT_END +}; + +static unsigned short msp3400_addrs[] = { + 0x80 >> 1, + 0x88 >> 1, + I2C_CLIENT_END +}; + /******************************** usb interface ******************************/ static struct video_device *em28xx_vdev_init(struct em28xx *dev, @@ -2218,7 +2236,54 @@ static int em28xx_v4l2_init(struct em28xx *dev) dev->vinctl = EM28XX_VINCTRL_INTERLACED | EM28XX_VINCTRL_CCIR656_ENABLE; + /* request some modules */ + + if (dev->board.has_msp34xx) + v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], + "msp3400", 0, msp3400_addrs); + + if (dev->board.decoder == EM28XX_SAA711X) + v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], + "saa7115_auto", 0, saa711x_addrs); + + if (dev->board.decoder == EM28XX_TVP5150) + v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], + "tvp5150", 0, tvp5150_addrs); + + if (dev->board.adecoder == EM28XX_TVAUDIO) + v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], + "tvaudio", dev->board.tvaudio_addr, NULL); + /* Initialize tuner and camera */ + + if (dev->board.tuner_type != TUNER_ABSENT) { + int has_demod = (dev->tda9887_conf & TDA9887_PRESENT); + + if (dev->board.radio.type) + v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], + "tuner", dev->board.radio_addr, NULL); + + if (has_demod) + v4l2_i2c_new_subdev(&dev->v4l2_dev, + &dev->i2c_adap[dev->def_i2c_bus], "tuner", + 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); + if (dev->tuner_addr == 0) { + enum v4l2_i2c_tuner_type type = + has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; + struct v4l2_subdev *sd; + + sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, + &dev->i2c_adap[dev->def_i2c_bus], "tuner", + 0, v4l2_i2c_tuner_addrs(type)); + + if (sd) + dev->tuner_addr = v4l2_i2c_subdev_addr(sd); + } else { + v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap[dev->def_i2c_bus], + "tuner", dev->tuner_addr, NULL); + } + } + em28xx_tuner_setup(dev); em28xx_init_camera(dev);