diff options
Diffstat (limited to 'drivers/media/common/saa7146_fops.c')
-rw-r--r-- | drivers/media/common/saa7146_fops.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c index 09ec964dec5c..b614612be7b4 100644 --- a/drivers/media/common/saa7146_fops.c +++ b/drivers/media/common/saa7146_fops.c | |||
@@ -253,7 +253,10 @@ static int fops_open(struct inode *inode, struct file *file) | |||
253 | 253 | ||
254 | if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | 254 | if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { |
255 | DEB_S(("initializing vbi...\n")); | 255 | DEB_S(("initializing vbi...\n")); |
256 | result = saa7146_vbi_uops.open(dev,file); | 256 | if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) |
257 | result = saa7146_vbi_uops.open(dev,file); | ||
258 | if (dev->ext_vv_data->vbi_fops.open) | ||
259 | dev->ext_vv_data->vbi_fops.open(inode, file); | ||
257 | } else { | 260 | } else { |
258 | DEB_S(("initializing video...\n")); | 261 | DEB_S(("initializing video...\n")); |
259 | result = saa7146_video_uops.open(dev,file); | 262 | result = saa7146_video_uops.open(dev,file); |
@@ -289,7 +292,10 @@ static int fops_release(struct inode *inode, struct file *file) | |||
289 | return -ERESTARTSYS; | 292 | return -ERESTARTSYS; |
290 | 293 | ||
291 | if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | 294 | if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { |
292 | saa7146_vbi_uops.release(dev,file); | 295 | if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) |
296 | saa7146_vbi_uops.release(dev,file); | ||
297 | if (dev->ext_vv_data->vbi_fops.release) | ||
298 | dev->ext_vv_data->vbi_fops.release(inode, file); | ||
293 | } else { | 299 | } else { |
294 | saa7146_video_uops.release(dev,file); | 300 | saa7146_video_uops.release(dev,file); |
295 | } | 301 | } |
@@ -332,6 +338,7 @@ static int fops_mmap(struct file *file, struct vm_area_struct * vma) | |||
332 | BUG(); | 338 | BUG(); |
333 | return 0; | 339 | return 0; |
334 | } | 340 | } |
341 | |||
335 | return videobuf_mmap_mapper(q,vma); | 342 | return videobuf_mmap_mapper(q,vma); |
336 | } | 343 | } |
337 | 344 | ||
@@ -381,7 +388,10 @@ static ssize_t fops_read(struct file *file, char __user *data, size_t count, lof | |||
381 | } | 388 | } |
382 | case V4L2_BUF_TYPE_VBI_CAPTURE: { | 389 | case V4L2_BUF_TYPE_VBI_CAPTURE: { |
383 | // DEB_EE(("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%lu\n", file, data, (unsigned long)count)); | 390 | // DEB_EE(("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%lu\n", file, data, (unsigned long)count)); |
384 | return saa7146_vbi_uops.read(file,data,count,ppos); | 391 | if (fh->dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) |
392 | return saa7146_vbi_uops.read(file,data,count,ppos); | ||
393 | else | ||
394 | return -EINVAL; | ||
385 | } | 395 | } |
386 | break; | 396 | break; |
387 | default: | 397 | default: |
@@ -390,12 +400,31 @@ static ssize_t fops_read(struct file *file, char __user *data, size_t count, lof | |||
390 | } | 400 | } |
391 | } | 401 | } |
392 | 402 | ||
403 | static ssize_t fops_write(struct file *file, const char __user *data, size_t count, loff_t *ppos) | ||
404 | { | ||
405 | struct saa7146_fh *fh = file->private_data; | ||
406 | |||
407 | switch (fh->type) { | ||
408 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
409 | return -EINVAL; | ||
410 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
411 | if (fh->dev->ext_vv_data->vbi_fops.write) | ||
412 | return fh->dev->ext_vv_data->vbi_fops.write(file, data, count, ppos); | ||
413 | else | ||
414 | return -EINVAL; | ||
415 | default: | ||
416 | BUG(); | ||
417 | return -EINVAL; | ||
418 | } | ||
419 | } | ||
420 | |||
393 | static struct file_operations video_fops = | 421 | static struct file_operations video_fops = |
394 | { | 422 | { |
395 | .owner = THIS_MODULE, | 423 | .owner = THIS_MODULE, |
396 | .open = fops_open, | 424 | .open = fops_open, |
397 | .release = fops_release, | 425 | .release = fops_release, |
398 | .read = fops_read, | 426 | .read = fops_read, |
427 | .write = fops_write, | ||
399 | .poll = fops_poll, | 428 | .poll = fops_poll, |
400 | .mmap = fops_mmap, | 429 | .mmap = fops_mmap, |
401 | .ioctl = fops_ioctl, | 430 | .ioctl = fops_ioctl, |
@@ -467,7 +496,8 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) | |||
467 | memset(vv->d_clipping.cpu_addr, 0x0, SAA7146_CLIPPING_MEM); | 496 | memset(vv->d_clipping.cpu_addr, 0x0, SAA7146_CLIPPING_MEM); |
468 | 497 | ||
469 | saa7146_video_uops.init(dev,vv); | 498 | saa7146_video_uops.init(dev,vv); |
470 | saa7146_vbi_uops.init(dev,vv); | 499 | if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) |
500 | saa7146_vbi_uops.init(dev,vv); | ||
471 | 501 | ||
472 | dev->vv_data = vv; | 502 | dev->vv_data = vv; |
473 | dev->vv_callback = &vv_callback; | 503 | dev->vv_callback = &vv_callback; |