From patchwork Fri Jun 10 14:48:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmljaGFyZCBSw4PCtmpmb3Jz?= X-Patchwork-Id: 869892 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5AEn73n027210 for ; Fri, 10 Jun 2011 14:49:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756849Ab1FJOtA (ORCPT ); Fri, 10 Jun 2011 10:49:00 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:43607 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756366Ab1FJOs5 (ORCPT ); Fri, 10 Jun 2011 10:48:57 -0400 Received: by wwa36 with SMTP id 36so2861302wwa.1 for ; Fri, 10 Jun 2011 07:48:55 -0700 (PDT) Received: by 10.216.27.67 with SMTP id d45mr2239623wea.21.1307717335662; Fri, 10 Jun 2011 07:48:55 -0700 (PDT) Received: from [10.8.36.162] (194-237-7-146.customer.telia.com [194.237.7.146]) by mx.google.com with ESMTPS id t79sm1443327weq.5.2011.06.10.07.48.53 (version=SSLv3 cipher=OTHER); Fri, 10 Jun 2011 07:48:54 -0700 (PDT) Subject: [PATCH 2/2] radio-timb: Add open function which finds tuner and DSP via I2C From: Richard =?ISO-8859-1?Q?R=F6jfors?= To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Hans Verkuil Organization: Pelagicore AB Date: Fri, 10 Jun 2011 16:48:52 +0200 Message-ID: <1307717332.2420.30.camel@debian> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 10 Jun 2011 14:49:07 +0000 (UTC) This patch uses the platform data and finds a tuner and DSP. This is done when the user calls open. Not during probe, to allow shorter bootup time of the system. This piece of code was actually missing earlier, many of the functions were not useful without DSP and tuner. Signed-off-by: Richard Röjfors --- -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c index a185610..64a5e19 100644 --- a/drivers/media/radio/radio-timb.c +++ b/drivers/media/radio/radio-timb.c @@ -141,9 +141,42 @@ static const struct v4l2_ioctl_ops timbradio_ioctl_ops = { .vidioc_s_ctrl = timbradio_vidioc_s_ctrl }; +static int timbradio_fops_open(struct file *file) +{ + struct timbradio *tr = video_drvdata(file); + struct i2c_adapter *adapt; + + /* find the I2C bus */ + adapt = i2c_get_adapter(tr->pdata.i2c_adapter); + if (!adapt) { + printk(KERN_ERR DRIVER_NAME": No I2C bus\n"); + return -ENODEV; + } + + /* now find the tuner and dsp */ + if (!tr->sd_dsp) + tr->sd_dsp = v4l2_i2c_new_subdev_board(&tr->v4l2_dev, adapt, + tr->pdata.dsp, NULL); + + if (!tr->sd_tuner) + tr->sd_tuner = v4l2_i2c_new_subdev_board(&tr->v4l2_dev, adapt, + tr->pdata.tuner, NULL); + + i2c_put_adapter(adapt); + + if (!tr->sd_tuner || !tr->sd_dsp) { + printk(KERN_ERR DRIVER_NAME + ": Failed to get tuner or DSP\n"); + return -ENODEV; + } + + return 0; +} + static const struct v4l2_file_operations timbradio_fops = { .owner = THIS_MODULE, .unlocked_ioctl = video_ioctl2, + .open = timbradio_fops_open, }; static int __devinit timbradio_probe(struct platform_device *pdev)