diff options
Diffstat (limited to 'drivers/media/common/saa7146_fops.c')
-rw-r--r-- | drivers/media/common/saa7146_fops.c | 60 |
1 files changed, 10 insertions, 50 deletions
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index 620f655fa9c5..7364b9642d00 100644 --- a/drivers/media/common/saa7146_fops.c +++ b/drivers/media/common/saa7146_fops.c | |||
@@ -1,7 +1,5 @@ | |||
1 | #include <media/saa7146_vv.h> | 1 | #include <media/saa7146_vv.h> |
2 | 2 | ||
3 | #define BOARD_CAN_DO_VBI(dev) (dev->revision != 0 && dev->vv_data->vbi_minor != -1) | ||
4 | |||
5 | /****************************************************************************/ | 3 | /****************************************************************************/ |
6 | /* resource management functions, shamelessly stolen from saa7134 driver */ | 4 | /* resource management functions, shamelessly stolen from saa7134 driver */ |
7 | 5 | ||
@@ -194,43 +192,24 @@ void saa7146_buffer_timeout(unsigned long data) | |||
194 | 192 | ||
195 | static int fops_open(struct file *file) | 193 | static int fops_open(struct file *file) |
196 | { | 194 | { |
197 | unsigned int minor = video_devdata(file)->minor; | 195 | struct video_device *vdev = video_devdata(file); |
198 | struct saa7146_dev *h = NULL, *dev = NULL; | 196 | struct saa7146_dev *dev = video_drvdata(file); |
199 | struct list_head *list; | ||
200 | struct saa7146_fh *fh = NULL; | 197 | struct saa7146_fh *fh = NULL; |
201 | int result = 0; | 198 | int result = 0; |
202 | 199 | ||
203 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 200 | enum v4l2_buf_type type; |
204 | 201 | ||
205 | DEB_EE(("file:%p, minor:%d\n", file, minor)); | 202 | DEB_EE(("file:%p, dev:%s\n", file, video_device_node_name(vdev))); |
206 | 203 | ||
207 | if (mutex_lock_interruptible(&saa7146_devices_lock)) | 204 | if (mutex_lock_interruptible(&saa7146_devices_lock)) |
208 | return -ERESTARTSYS; | 205 | return -ERESTARTSYS; |
209 | 206 | ||
210 | list_for_each(list,&saa7146_devices) { | ||
211 | h = list_entry(list, struct saa7146_dev, item); | ||
212 | if( NULL == h->vv_data ) { | ||
213 | DEB_D(("device %p has not registered video devices.\n",h)); | ||
214 | continue; | ||
215 | } | ||
216 | DEB_D(("trying: %p @ major %d,%d\n",h,h->vv_data->video_minor,h->vv_data->vbi_minor)); | ||
217 | |||
218 | if (h->vv_data->video_minor == minor) { | ||
219 | dev = h; | ||
220 | } | ||
221 | if (h->vv_data->vbi_minor == minor) { | ||
222 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
223 | dev = h; | ||
224 | } | ||
225 | } | ||
226 | if (NULL == dev) { | ||
227 | DEB_S(("no such video device.\n")); | ||
228 | result = -ENODEV; | ||
229 | goto out; | ||
230 | } | ||
231 | |||
232 | DEB_D(("using: %p\n",dev)); | 207 | DEB_D(("using: %p\n",dev)); |
233 | 208 | ||
209 | type = vdev->vfl_type == VFL_TYPE_GRABBER | ||
210 | ? V4L2_BUF_TYPE_VIDEO_CAPTURE | ||
211 | : V4L2_BUF_TYPE_VBI_CAPTURE; | ||
212 | |||
234 | /* check if an extension is registered */ | 213 | /* check if an extension is registered */ |
235 | if( NULL == dev->ext ) { | 214 | if( NULL == dev->ext ) { |
236 | DEB_S(("no extension registered for this device.\n")); | 215 | DEB_S(("no extension registered for this device.\n")); |
@@ -474,9 +453,6 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) | |||
474 | configuration data) */ | 453 | configuration data) */ |
475 | dev->ext_vv_data = ext_vv; | 454 | dev->ext_vv_data = ext_vv; |
476 | 455 | ||
477 | vv->video_minor = -1; | ||
478 | vv->vbi_minor = -1; | ||
479 | |||
480 | vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle); | 456 | vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle); |
481 | if( NULL == vv->d_clipping.cpu_addr ) { | 457 | if( NULL == vv->d_clipping.cpu_addr ) { |
482 | ERR(("out of memory. aborting.\n")); | 458 | ERR(("out of memory. aborting.\n")); |
@@ -515,7 +491,6 @@ EXPORT_SYMBOL_GPL(saa7146_vv_release); | |||
515 | int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev, | 491 | int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev, |
516 | char *name, int type) | 492 | char *name, int type) |
517 | { | 493 | { |
518 | struct saa7146_vv *vv = dev->vv_data; | ||
519 | struct video_device *vfd; | 494 | struct video_device *vfd; |
520 | int err; | 495 | int err; |
521 | int i; | 496 | int i; |
@@ -543,15 +518,8 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev, | |||
543 | return err; | 518 | return err; |
544 | } | 519 | } |
545 | 520 | ||
546 | if( VFL_TYPE_GRABBER == type ) { | 521 | INFO(("%s: registered device %s [v4l2]\n", |
547 | vv->video_minor = vfd->minor; | 522 | dev->name, video_device_node_name(vfd))); |
548 | INFO(("%s: registered device video%d [v4l2]\n", | ||
549 | dev->name, vfd->num)); | ||
550 | } else { | ||
551 | vv->vbi_minor = vfd->minor; | ||
552 | INFO(("%s: registered device vbi%d [v4l2]\n", | ||
553 | dev->name, vfd->num)); | ||
554 | } | ||
555 | 523 | ||
556 | *vid = vfd; | 524 | *vid = vfd; |
557 | return 0; | 525 | return 0; |
@@ -560,16 +528,8 @@ EXPORT_SYMBOL_GPL(saa7146_register_device); | |||
560 | 528 | ||
561 | int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev) | 529 | int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev) |
562 | { | 530 | { |
563 | struct saa7146_vv *vv = dev->vv_data; | ||
564 | |||
565 | DEB_EE(("dev:%p\n",dev)); | 531 | DEB_EE(("dev:%p\n",dev)); |
566 | 532 | ||
567 | if ((*vid)->vfl_type == VFL_TYPE_GRABBER) { | ||
568 | vv->video_minor = -1; | ||
569 | } else { | ||
570 | vv->vbi_minor = -1; | ||
571 | } | ||
572 | |||
573 | video_unregister_device(*vid); | 533 | video_unregister_device(*vid); |
574 | *vid = NULL; | 534 | *vid = NULL; |
575 | 535 | ||