diff mbox

[1/1] radio-timb: Add tuner and DSP to the I2C bus

Message ID 1290765259.18798.11.camel@debian (mailing list archive)
State Changes Requested
Headers show

Commit Message

Richard Röjfors Nov. 26, 2010, 9:54 a.m. UTC
None
diff mbox

Patch

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)