aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-02-21 16:11:31 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:54 -0400
commit1df795370c1392a026c63816368108187aec2ec1 (patch)
tree3cdb3df8c2faee0521f9a15355774747b3f0ccf1 /drivers
parentab373190813a2e89f9ab7338c6b106804611f2b7 (diff)
V4L/DVB (10692): usbvision: convert to v4l2_device/v4l2_subdev.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c2
-rw-r--r--drivers/media/video/usbvision/usbvision-i2c.c147
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c63
-rw-r--r--drivers/media/video/usbvision/usbvision.h8
4 files changed, 75 insertions, 145 deletions
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index 4444e7e3cdf8..eadebb91b092 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -2633,7 +2633,7 @@ int usbvision_muxsel(struct usb_usbvision *usbvision, int channel)
2633 } 2633 }
2634 route.input = mode[channel]; 2634 route.input = mode[channel];
2635 route.output = 0; 2635 route.output = 0;
2636 call_i2c_clients(usbvision, VIDIOC_INT_S_VIDEO_ROUTING,&route); 2636 call_all(usbvision, video, s_routing, &route);
2637 usbvision_set_audio(usbvision, audio[channel]); 2637 usbvision_set_audio(usbvision, audio[channel]);
2638 return 0; 2638 return 0;
2639} 2639}
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c
index 6057098282ca..dd2f8f27c73b 100644
--- a/drivers/media/video/usbvision/usbvision-i2c.c
+++ b/drivers/media/video/usbvision/usbvision-i2c.c
@@ -202,72 +202,78 @@ static struct i2c_algorithm usbvision_algo = {
202}; 202};
203 203
204 204
205/*
206 * registering functions to load algorithms at runtime
207 */
208static int usbvision_i2c_usb_add_bus(struct i2c_adapter *adap)
209{
210 PDEBUG(DBG_I2C, "I2C debugging is enabled [i2c]");
211 PDEBUG(DBG_I2C, "ALGO debugging is enabled [i2c]");
212
213 /* register new adapter to i2c module... */
214
215 adap->algo = &usbvision_algo;
216
217 adap->timeout = 100; /* default values, should */
218 adap->retries = 3; /* be replaced by defines */
219
220 i2c_add_adapter(adap);
221
222 PDEBUG(DBG_I2C,"i2c bus for %s registered", adap->name);
223
224 return 0;
225}
226
227/* ----------------------------------------------------------------------- */ 205/* ----------------------------------------------------------------------- */
228/* usbvision specific I2C functions */ 206/* usbvision specific I2C functions */
229/* ----------------------------------------------------------------------- */ 207/* ----------------------------------------------------------------------- */
230static struct i2c_adapter i2c_adap_template; 208static struct i2c_adapter i2c_adap_template;
231static struct i2c_client i2c_client_template;
232 209
233int usbvision_i2c_register(struct usb_usbvision *usbvision) 210int usbvision_i2c_register(struct usb_usbvision *usbvision)
234{ 211{
212 static unsigned short saa711x_addrs[] = {
213 0x4a >> 1, 0x48 >> 1, /* SAA7111, SAA7111A and SAA7113 */
214 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */
215 I2C_CLIENT_END };
216
235 memcpy(&usbvision->i2c_adap, &i2c_adap_template, 217 memcpy(&usbvision->i2c_adap, &i2c_adap_template,
236 sizeof(struct i2c_adapter)); 218 sizeof(struct i2c_adapter));
237 memcpy(&usbvision->i2c_client, &i2c_client_template,
238 sizeof(struct i2c_client));
239 219
240 sprintf(usbvision->i2c_adap.name + strlen(usbvision->i2c_adap.name), 220 sprintf(usbvision->i2c_adap.name + strlen(usbvision->i2c_adap.name),
241 " #%d", usbvision->vdev->num); 221 " #%d", usbvision->vdev->num);
242 PDEBUG(DBG_I2C,"Adaptername: %s", usbvision->i2c_adap.name); 222 PDEBUG(DBG_I2C,"Adaptername: %s", usbvision->i2c_adap.name);
243 usbvision->i2c_adap.dev.parent = &usbvision->dev->dev; 223 usbvision->i2c_adap.dev.parent = &usbvision->dev->dev;
244 224
245 i2c_set_adapdata(&usbvision->i2c_adap, usbvision); 225 i2c_set_adapdata(&usbvision->i2c_adap, &usbvision->v4l2_dev);
246 i2c_set_clientdata(&usbvision->i2c_client, usbvision);
247
248 usbvision->i2c_client.adapter = &usbvision->i2c_adap;
249 226
250 if (usbvision_write_reg(usbvision, USBVISION_SER_MODE, USBVISION_IIC_LRNACK) < 0) { 227 if (usbvision_write_reg(usbvision, USBVISION_SER_MODE, USBVISION_IIC_LRNACK) < 0) {
251 printk(KERN_ERR "usbvision_register: can't write reg\n"); 228 printk(KERN_ERR "usbvision_register: can't write reg\n");
252 return -EBUSY; 229 return -EBUSY;
253 } 230 }
254 231
255#ifdef CONFIG_MODULES 232 PDEBUG(DBG_I2C, "I2C debugging is enabled [i2c]");
233 PDEBUG(DBG_I2C, "ALGO debugging is enabled [i2c]");
234
235 /* register new adapter to i2c module... */
236
237 usbvision->i2c_adap.algo = &usbvision_algo;
238
239 usbvision->i2c_adap.timeout = 100; /* default values, should */
240 usbvision->i2c_adap.retries = 3; /* be replaced by defines */
241
242 i2c_add_adapter(&usbvision->i2c_adap);
243
244 PDEBUG(DBG_I2C, "i2c bus for %s registered", usbvision->i2c_adap.name);
245
256 /* Request the load of the i2c modules we need */ 246 /* Request the load of the i2c modules we need */
257 switch (usbvision_device_data[usbvision->DevModel].Codec) { 247 switch (usbvision_device_data[usbvision->DevModel].Codec) {
258 case CODEC_SAA7113: 248 case CODEC_SAA7113:
259 request_module("saa7115");
260 break;
261 case CODEC_SAA7111: 249 case CODEC_SAA7111:
262 request_module("saa7115"); 250 v4l2_i2c_new_probed_subdev(&usbvision->i2c_adap, "saa7115",
251 "saa7115_auto", saa711x_addrs);
263 break; 252 break;
264 } 253 }
265 if (usbvision_device_data[usbvision->DevModel].Tuner == 1) { 254 if (usbvision_device_data[usbvision->DevModel].Tuner == 1) {
266 request_module("tuner"); 255 struct v4l2_subdev *sd;
256 enum v4l2_i2c_tuner_type type;
257 struct tuner_setup tun_setup;
258
259 sd = v4l2_i2c_new_probed_subdev(&usbvision->i2c_adap, "tuner",
260 "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
261 /* depending on whether we found a demod or not, select
262 the tuner type. */
263 type = sd ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
264
265 sd = v4l2_i2c_new_probed_subdev(&usbvision->i2c_adap, "tuner",
266 "tuner", v4l2_i2c_tuner_addrs(type));
267
268 if (usbvision->tuner_type != -1) {
269 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
270 tun_setup.type = usbvision->tuner_type;
271 tun_setup.addr = v4l2_i2c_subdev_addr(sd);
272 call_all(usbvision, tuner, s_type_addr, &tun_setup);
273 }
267 } 274 }
268#endif
269 275
270 return usbvision_i2c_usb_add_bus(&usbvision->i2c_adap); 276 return 0;
271} 277}
272 278
273int usbvision_i2c_unregister(struct usb_usbvision *usbvision) 279int usbvision_i2c_unregister(struct usb_usbvision *usbvision)
@@ -280,67 +286,6 @@ int usbvision_i2c_unregister(struct usb_usbvision *usbvision)
280 return 0; 286 return 0;
281} 287}
282 288
283void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd,
284 void *arg)
285{
286 i2c_clients_command(&usbvision->i2c_adap, cmd, arg);
287}
288
289static int attach_inform(struct i2c_client *client)
290{
291 struct usb_usbvision *usbvision;
292
293 usbvision = (struct usb_usbvision *)i2c_get_adapdata(client->adapter);
294
295 switch (client->addr << 1) {
296 case 0x42 << 1:
297 case 0x43 << 1:
298 case 0x4a << 1:
299 case 0x4b << 1:
300 PDEBUG(DBG_I2C,"attach_inform: tda9887 detected.");
301 break;
302 case 0x42:
303 PDEBUG(DBG_I2C,"attach_inform: saa7114 detected.");
304 break;
305 case 0x4a:
306 PDEBUG(DBG_I2C,"attach_inform: saa7113 detected.");
307 break;
308 case 0x48:
309 PDEBUG(DBG_I2C,"attach_inform: saa7111 detected.");
310 break;
311 case 0xa0:
312 PDEBUG(DBG_I2C,"attach_inform: eeprom detected.");
313 break;
314
315 default:
316 {
317 struct tuner_setup tun_setup;
318
319 PDEBUG(DBG_I2C,"attach inform: detected I2C address %x", client->addr << 1);
320 usbvision->tuner_addr = client->addr;
321
322 if ((usbvision->have_tuner) && (usbvision->tuner_type != -1)) {
323 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
324 tun_setup.type = usbvision->tuner_type;
325 tun_setup.addr = usbvision->tuner_addr;
326 call_i2c_clients(usbvision, TUNER_SET_TYPE_ADDR, &tun_setup);
327 }
328 }
329 break;
330 }
331 return 0;
332}
333
334static int detach_inform(struct i2c_client *client)
335{
336 struct usb_usbvision *usbvision;
337
338 usbvision = (struct usb_usbvision *)i2c_get_adapdata(client->adapter);
339
340 PDEBUG(DBG_I2C,"usbvision[%d] detaches %s", usbvision->nr, client->name);
341 return 0;
342}
343
344static int 289static int
345usbvision_i2c_read_max4(struct usb_usbvision *usbvision, unsigned char addr, 290usbvision_i2c_read_max4(struct usb_usbvision *usbvision, unsigned char addr,
346 char *buf, short len) 291 char *buf, short len)
@@ -513,14 +458,6 @@ static int usbvision_i2c_read(struct usb_usbvision *usbvision, unsigned char add
513static struct i2c_adapter i2c_adap_template = { 458static struct i2c_adapter i2c_adap_template = {
514 .owner = THIS_MODULE, 459 .owner = THIS_MODULE,
515 .name = "usbvision", 460 .name = "usbvision",
516 .id = I2C_HW_B_BT848, /* FIXME */
517 .client_register = attach_inform,
518 .client_unregister = detach_inform,
519 .class = I2C_CLASS_TV_ANALOG,
520};
521
522static struct i2c_client i2c_client_template = {
523 .name = "usbvision internal",
524}; 461};
525 462
526/* 463/*
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 334c77d9116f..cfa184d63c65 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -212,7 +212,7 @@ static ssize_t show_hue(struct device *cd,
212 ctrl.id = V4L2_CID_HUE; 212 ctrl.id = V4L2_CID_HUE;
213 ctrl.value = 0; 213 ctrl.value = 0;
214 if(usbvision->user) 214 if(usbvision->user)
215 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 215 call_all(usbvision, core, g_ctrl, &ctrl);
216 return sprintf(buf, "%d\n", ctrl.value); 216 return sprintf(buf, "%d\n", ctrl.value);
217} 217}
218static DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); 218static DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
@@ -227,7 +227,7 @@ static ssize_t show_contrast(struct device *cd,
227 ctrl.id = V4L2_CID_CONTRAST; 227 ctrl.id = V4L2_CID_CONTRAST;
228 ctrl.value = 0; 228 ctrl.value = 0;
229 if(usbvision->user) 229 if(usbvision->user)
230 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 230 call_all(usbvision, core, g_ctrl, &ctrl);
231 return sprintf(buf, "%d\n", ctrl.value); 231 return sprintf(buf, "%d\n", ctrl.value);
232} 232}
233static DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); 233static DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
@@ -242,7 +242,7 @@ static ssize_t show_brightness(struct device *cd,
242 ctrl.id = V4L2_CID_BRIGHTNESS; 242 ctrl.id = V4L2_CID_BRIGHTNESS;
243 ctrl.value = 0; 243 ctrl.value = 0;
244 if(usbvision->user) 244 if(usbvision->user)
245 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 245 call_all(usbvision, core, g_ctrl, &ctrl);
246 return sprintf(buf, "%d\n", ctrl.value); 246 return sprintf(buf, "%d\n", ctrl.value);
247} 247}
248static DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); 248static DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
@@ -257,7 +257,7 @@ static ssize_t show_saturation(struct device *cd,
257 ctrl.id = V4L2_CID_SATURATION; 257 ctrl.id = V4L2_CID_SATURATION;
258 ctrl.value = 0; 258 ctrl.value = 0;
259 if(usbvision->user) 259 if(usbvision->user)
260 call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); 260 call_all(usbvision, core, g_ctrl, &ctrl);
261 return sprintf(buf, "%d\n", ctrl.value); 261 return sprintf(buf, "%d\n", ctrl.value);
262} 262}
263static DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); 263static DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
@@ -622,8 +622,7 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id)
622 usbvision->tvnormId=*id; 622 usbvision->tvnormId=*id;
623 623
624 mutex_lock(&usbvision->lock); 624 mutex_lock(&usbvision->lock);
625 call_i2c_clients(usbvision, VIDIOC_S_STD, 625 call_all(usbvision, tuner, s_std, usbvision->tvnormId);
626 &usbvision->tvnormId);
627 mutex_unlock(&usbvision->lock); 626 mutex_unlock(&usbvision->lock);
628 /* propagate the change to the decoder */ 627 /* propagate the change to the decoder */
629 usbvision_muxsel(usbvision, usbvision->ctl_input); 628 usbvision_muxsel(usbvision, usbvision->ctl_input);
@@ -645,7 +644,7 @@ static int vidioc_g_tuner (struct file *file, void *priv,
645 strcpy(vt->name, "Television"); 644 strcpy(vt->name, "Television");
646 } 645 }
647 /* Let clients fill in the remainder of this struct */ 646 /* Let clients fill in the remainder of this struct */
648 call_i2c_clients(usbvision,VIDIOC_G_TUNER,vt); 647 call_all(usbvision, tuner, g_tuner, vt);
649 648
650 return 0; 649 return 0;
651} 650}
@@ -659,7 +658,7 @@ static int vidioc_s_tuner (struct file *file, void *priv,
659 if (!usbvision->have_tuner || vt->index) 658 if (!usbvision->have_tuner || vt->index)
660 return -EINVAL; 659 return -EINVAL;
661 /* let clients handle this */ 660 /* let clients handle this */
662 call_i2c_clients(usbvision,VIDIOC_S_TUNER,vt); 661 call_all(usbvision, tuner, s_tuner, vt);
663 662
664 return 0; 663 return 0;
665} 664}
@@ -690,7 +689,7 @@ static int vidioc_s_frequency (struct file *file, void *priv,
690 return -EINVAL; 689 return -EINVAL;
691 690
692 usbvision->freq = freq->frequency; 691 usbvision->freq = freq->frequency;
693 call_i2c_clients(usbvision, VIDIOC_S_FREQUENCY, freq); 692 call_all(usbvision, tuner, s_frequency, freq);
694 693
695 return 0; 694 return 0;
696} 695}
@@ -728,7 +727,7 @@ static int vidioc_queryctrl (struct file *file, void *priv,
728 memset(ctrl,0,sizeof(*ctrl)); 727 memset(ctrl,0,sizeof(*ctrl));
729 ctrl->id=id; 728 ctrl->id=id;
730 729
731 call_i2c_clients(usbvision, VIDIOC_QUERYCTRL, ctrl); 730 call_all(usbvision, core, queryctrl, ctrl);
732 731
733 if (!ctrl->type) 732 if (!ctrl->type)
734 return -EINVAL; 733 return -EINVAL;
@@ -740,7 +739,7 @@ static int vidioc_g_ctrl (struct file *file, void *priv,
740 struct v4l2_control *ctrl) 739 struct v4l2_control *ctrl)
741{ 740{
742 struct usb_usbvision *usbvision = video_drvdata(file); 741 struct usb_usbvision *usbvision = video_drvdata(file);
743 call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl); 742 call_all(usbvision, core, g_ctrl, ctrl);
744 743
745 return 0; 744 return 0;
746} 745}
@@ -749,7 +748,7 @@ static int vidioc_s_ctrl (struct file *file, void *priv,
749 struct v4l2_control *ctrl) 748 struct v4l2_control *ctrl)
750{ 749{
751 struct usb_usbvision *usbvision = video_drvdata(file); 750 struct usb_usbvision *usbvision = video_drvdata(file);
752 call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl); 751 call_all(usbvision, core, s_ctrl, ctrl);
753 752
754 return 0; 753 return 0;
755} 754}
@@ -900,10 +899,9 @@ static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb)
900static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) 899static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
901{ 900{
902 struct usb_usbvision *usbvision = video_drvdata(file); 901 struct usb_usbvision *usbvision = video_drvdata(file);
903 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE;
904 902
905 usbvision->streaming = Stream_On; 903 usbvision->streaming = Stream_On;
906 call_i2c_clients(usbvision,VIDIOC_STREAMON , &b); 904 call_all(usbvision, video, s_stream, 1);
907 905
908 return 0; 906 return 0;
909} 907}
@@ -912,7 +910,6 @@ static int vidioc_streamoff(struct file *file,
912 void *priv, enum v4l2_buf_type type) 910 void *priv, enum v4l2_buf_type type)
913{ 911{
914 struct usb_usbvision *usbvision = video_drvdata(file); 912 struct usb_usbvision *usbvision = video_drvdata(file);
915 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE;
916 913
917 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 914 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
918 return -EINVAL; 915 return -EINVAL;
@@ -920,7 +917,7 @@ static int vidioc_streamoff(struct file *file,
920 if(usbvision->streaming == Stream_On) { 917 if(usbvision->streaming == Stream_On) {
921 usbvision_stream_interrupt(usbvision); 918 usbvision_stream_interrupt(usbvision);
922 /* Stop all video streamings */ 919 /* Stop all video streamings */
923 call_i2c_clients(usbvision,VIDIOC_STREAMOFF , &b); 920 call_all(usbvision, video, s_stream, 0);
924 } 921 }
925 usbvision_empty_framequeues(usbvision); 922 usbvision_empty_framequeues(usbvision);
926 923
@@ -1043,7 +1040,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf,
1043 if(usbvision->streaming != Stream_On) { 1040 if(usbvision->streaming != Stream_On) {
1044 /* no stream is running, make it running ! */ 1041 /* no stream is running, make it running ! */
1045 usbvision->streaming = Stream_On; 1042 usbvision->streaming = Stream_On;
1046 call_i2c_clients(usbvision,VIDIOC_STREAMON , NULL); 1043 call_all(usbvision, video, s_stream, 1);
1047 } 1044 }
1048 1045
1049 /* Then, enqueue as many frames as possible 1046 /* Then, enqueue as many frames as possible
@@ -1214,7 +1211,7 @@ static int usbvision_radio_open(struct file *file)
1214 1211
1215 // If so far no errors then we shall start the radio 1212 // If so far no errors then we shall start the radio
1216 usbvision->radio = 1; 1213 usbvision->radio = 1;
1217 call_i2c_clients(usbvision,AUDC_SET_RADIO,&usbvision->tuner_type); 1214 call_all(usbvision, tuner, s_radio);
1218 usbvision_set_audio(usbvision, USBVISION_AUDIO_RADIO); 1215 usbvision_set_audio(usbvision, USBVISION_AUDIO_RADIO);
1219 usbvision->user++; 1216 usbvision->user++;
1220 } 1217 }
@@ -1427,7 +1424,7 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision,
1427 } 1424 }
1428 *vdev = *vdev_template; 1425 *vdev = *vdev_template;
1429// vdev->minor = -1; 1426// vdev->minor = -1;
1430 vdev->parent = &usb_dev->dev; 1427 vdev->v4l2_dev = &usbvision->v4l2_dev;
1431 snprintf(vdev->name, sizeof(vdev->name), "%s", name); 1428 snprintf(vdev->name, sizeof(vdev->name), "%s", name);
1432 video_set_drvdata(vdev, usbvision); 1429 video_set_drvdata(vdev, usbvision);
1433 return vdev; 1430 return vdev;
@@ -1548,33 +1545,30 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev)
1548{ 1545{
1549 struct usb_usbvision *usbvision; 1546 struct usb_usbvision *usbvision;
1550 1547
1551 if ((usbvision = kzalloc(sizeof(struct usb_usbvision), GFP_KERNEL)) == 1548 usbvision = kzalloc(sizeof(struct usb_usbvision), GFP_KERNEL);
1552 NULL) { 1549 if (usbvision == NULL)
1553 goto err_exit; 1550 return NULL;
1554 }
1555 1551
1556 usbvision->dev = dev; 1552 usbvision->dev = dev;
1553 if (v4l2_device_register(&dev->dev, &usbvision->v4l2_dev))
1554 goto err_free;
1557 1555
1558 mutex_init(&usbvision->lock); /* available */ 1556 mutex_init(&usbvision->lock); /* available */
1559 1557
1560 // prepare control urb for control messages during interrupts 1558 // prepare control urb for control messages during interrupts
1561 usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); 1559 usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL);
1562 if (usbvision->ctrlUrb == NULL) { 1560 if (usbvision->ctrlUrb == NULL)
1563 goto err_exit; 1561 goto err_unreg;
1564 }
1565 init_waitqueue_head(&usbvision->ctrlUrb_wq); 1562 init_waitqueue_head(&usbvision->ctrlUrb_wq);
1566 1563
1567 usbvision_init_powerOffTimer(usbvision); 1564 usbvision_init_powerOffTimer(usbvision);
1568 1565
1569 return usbvision; 1566 return usbvision;
1570 1567
1571err_exit: 1568err_unreg:
1572 if (usbvision && usbvision->ctrlUrb) { 1569 v4l2_device_unregister(&usbvision->v4l2_dev);
1573 usb_free_urb(usbvision->ctrlUrb); 1570err_free:
1574 } 1571 kfree(usbvision);
1575 if (usbvision) {
1576 kfree(usbvision);
1577 }
1578 return NULL; 1572 return NULL;
1579} 1573}
1580 1574
@@ -1604,6 +1598,7 @@ static void usbvision_release(struct usb_usbvision *usbvision)
1604 usb_free_urb(usbvision->ctrlUrb); 1598 usb_free_urb(usbvision->ctrlUrb);
1605 } 1599 }
1606 1600
1601 v4l2_device_unregister(&usbvision->v4l2_dev);
1607 kfree(usbvision); 1602 kfree(usbvision);
1608 1603
1609 PDEBUG(DBG_PROBE, "success"); 1604 PDEBUG(DBG_PROBE, "success");
@@ -1739,8 +1734,6 @@ static int __devinit usbvision_probe(struct usb_interface *intf,
1739 usbvision->tuner_type = usbvision_device_data[model].TunerType; 1734 usbvision->tuner_type = usbvision_device_data[model].TunerType;
1740 } 1735 }
1741 1736
1742 usbvision->tuner_addr = ADDR_UNSET;
1743
1744 usbvision->DevModel = model; 1737 usbvision->DevModel = model;
1745 usbvision->remove_pending = 0; 1738 usbvision->remove_pending = 0;
1746 usbvision->iface = ifnum; 1739 usbvision->iface = ifnum;
diff --git a/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h
index 20d7ec624999..06fe43655957 100644
--- a/drivers/media/video/usbvision/usbvision.h
+++ b/drivers/media/video/usbvision/usbvision.h
@@ -35,7 +35,7 @@
35#include <linux/usb.h> 35#include <linux/usb.h>
36#include <linux/i2c.h> 36#include <linux/i2c.h>
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <media/v4l2-common.h> 38#include <media/v4l2-device.h>
39#include <media/tuner.h> 39#include <media/tuner.h>
40#include <linux/videodev2.h> 40#include <linux/videodev2.h>
41 41
@@ -357,13 +357,13 @@ extern struct usbvision_device_data_st usbvision_device_data[];
357extern struct usb_device_id usbvision_table[]; 357extern struct usb_device_id usbvision_table[];
358 358
359struct usb_usbvision { 359struct usb_usbvision {
360 struct v4l2_device v4l2_dev;
360 struct video_device *vdev; /* Video Device */ 361 struct video_device *vdev; /* Video Device */
361 struct video_device *rdev; /* Radio Device */ 362 struct video_device *rdev; /* Radio Device */
362 struct video_device *vbi; /* VBI Device */ 363 struct video_device *vbi; /* VBI Device */
363 364
364 /* i2c Declaration Section*/ 365 /* i2c Declaration Section*/
365 struct i2c_adapter i2c_adap; 366 struct i2c_adapter i2c_adap;
366 struct i2c_client i2c_client;
367 367
368 struct urb *ctrlUrb; 368 struct urb *ctrlUrb;
369 unsigned char ctrlUrbBuffer[8]; 369 unsigned char ctrlUrbBuffer[8];
@@ -374,7 +374,6 @@ struct usb_usbvision {
374 /* configuration part */ 374 /* configuration part */
375 int have_tuner; 375 int have_tuner;
376 int tuner_type; 376 int tuner_type;
377 int tuner_addr;
378 int bridgeType; // NT1003, NT1004, NT1005 377 int bridgeType; // NT1003, NT1004, NT1005
379 int radio; 378 int radio;
380 int video_inputs; // # of inputs 379 int video_inputs; // # of inputs
@@ -464,6 +463,8 @@ struct usb_usbvision {
464 int ComprBlockTypes[4]; 463 int ComprBlockTypes[4];
465}; 464};
466 465
466#define call_all(usbvision, o, f, args...) \
467 v4l2_device_call_all(&usbvision->v4l2_dev, 0, o, f, ##args)
467 468
468/* --------------------------------------------------------------- */ 469/* --------------------------------------------------------------- */
469/* defined in usbvision-i2c.c */ 470/* defined in usbvision-i2c.c */
@@ -475,7 +476,6 @@ struct usb_usbvision {
475/* ----------------------------------------------------------------------- */ 476/* ----------------------------------------------------------------------- */
476int usbvision_i2c_register(struct usb_usbvision *usbvision); 477int usbvision_i2c_register(struct usb_usbvision *usbvision);
477int usbvision_i2c_unregister(struct usb_usbvision *usbvision); 478int usbvision_i2c_unregister(struct usb_usbvision *usbvision);
478void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd,void *arg);
479 479
480/* defined in usbvision-core.c */ 480/* defined in usbvision-core.c */
481int usbvision_read_reg(struct usb_usbvision *usbvision, unsigned char reg); 481int usbvision_read_reg(struct usb_usbvision *usbvision, unsigned char reg);