From patchwork Fri Nov 26 09:54:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmljaGFyZCBSw4PCtmpmb3Jz?= X-Patchwork-Id: 358012 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAQ9sMP1012054 for ; Fri, 26 Nov 2010 09:54:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754061Ab0KZJyV (ORCPT ); Fri, 26 Nov 2010 04:54:21 -0500 Received: from smtp-gw11.han.skanova.net ([81.236.55.20]:36854 "EHLO smtp-gw11.han.skanova.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753759Ab0KZJyU (ORCPT ); Fri, 26 Nov 2010 04:54:20 -0500 Received: from [10.8.36.162] (194.237.7.146) by smtp-gw11.han.skanova.net (8.5.124.10) id 4C7CB7ED02E31DF9; Fri, 26 Nov 2010 10:54:19 +0100 Subject: [PATCH 1/1] radio-timb: Add tuner and DSP to the I2C bus From: Richard =?ISO-8859-1?Q?R=F6jfors?= To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab Date: Fri, 26 Nov 2010 10:54:19 +0100 Message-ID: <1290765259.18798.11.camel@debian> Mime-Version: 1.0 X-Mailer: Evolution 2.30.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.3 (demeter1.kernel.org [140.211.167.41]); Fri, 26 Nov 2010 09:54:25 +0000 (UTC) diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c index a185610..2b7abe2 100644 --- a/drivers/media/radio/radio-timb.c +++ b/drivers/media/radio/radio-timb.c @@ -141,9 +141,50 @@ 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; + int err = 0; + + mutex_lock(&tr->lock); + + /* find the I2C bus */ + adapt = i2c_get_adapter(tr->pdata.i2c_adapter); + if (!adapt) { + printk(KERN_ERR DRIVER_NAME": No I2C bus\n"); + err = -ENODEV; + goto out; + } + + /* 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.module_name, tr->pdata.dsp.info, NULL); + + if (!tr->sd_tuner) + tr->sd_tuner = v4l2_i2c_new_subdev_board(&tr->v4l2_dev, adapt, + tr->pdata.tuner.module_name, tr->pdata.tuner.info, + NULL); + + i2c_put_adapter(adapt); + + if (!tr->sd_tuner || !tr->sd_dsp) { + printk(KERN_ERR DRIVER_NAME + ": Failed to get tuner or DSP\n"); + err = -ENODEV; + goto out; + } + +out: + mutex_unlock(&tr->lock); + return err; +} + 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)