aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2011-03-11 17:00:56 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-22 15:37:59 -0400
commit99cd47bc733436da282016e629eef6baa0f6047c (patch)
tree7f210a24e38d65a1a44a2405c7fa59af9460a062 /drivers/media
parentdfddb2441f39e8c0254504516be35b854addf6fa (diff)
[media] v4l2-ioctl: add priority handling support
Drivers that use v4l2_fh can now use the core framework support of g/s_priority. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/radio/radio-si4713.c3
-rw-r--r--drivers/media/video/cpia2/cpia2_v4l.c3
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c3
-rw-r--r--drivers/media/video/davinci/vpfe_capture.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c3
-rw-r--r--drivers/media/video/meye.c3
-rw-r--r--drivers/media/video/mxb.c3
-rw-r--r--drivers/media/video/pwc/pwc-v4l.c3
-rw-r--r--drivers/media/video/v4l2-ioctl.c64
9 files changed, 72 insertions, 15 deletions
diff --git a/drivers/media/radio/radio-si4713.c b/drivers/media/radio/radio-si4713.c
index 726d367ad8d..444b4cf7e65 100644
--- a/drivers/media/radio/radio-si4713.c
+++ b/drivers/media/radio/radio-si4713.c
@@ -224,7 +224,8 @@ static int radio_si4713_s_frequency(struct file *file, void *p,
224 s_frequency, vf); 224 s_frequency, vf);
225} 225}
226 226
227static long radio_si4713_default(struct file *file, void *p, int cmd, void *arg) 227static long radio_si4713_default(struct file *file, void *p,
228 bool valid_prio, int cmd, void *arg)
228{ 229{
229 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core, 230 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
230 ioctl, cmd, arg); 231 ioctl, cmd, arg);
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index 363fe098b74..5111bbcefad 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -395,7 +395,8 @@ static int sync(struct camera_data *cam, int frame_nr)
395 * 395 *
396 *****************************************************************************/ 396 *****************************************************************************/
397 397
398static long cpia2_default(struct file *file, void *fh, int cmd, void *arg) 398static long cpia2_default(struct file *file, void *fh, bool valid_prio,
399 int cmd, void *arg)
399{ 400{
400 struct camera_data *cam = video_drvdata(file); 401 struct camera_data *cam = video_drvdata(file);
401 __u32 gpio_val; 402 __u32 gpio_val;
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index 36b018c943e..08ed75de191 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -1057,7 +1057,8 @@ static int cx18_log_status(struct file *file, void *fh)
1057 return 0; 1057 return 0;
1058} 1058}
1059 1059
1060static long cx18_default(struct file *file, void *fh, int cmd, void *arg) 1060static long cx18_default(struct file *file, void *fh, bool valid_prio,
1061 int cmd, void *arg)
1061{ 1062{
1062 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; 1063 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
1063 1064
diff --git a/drivers/media/video/davinci/vpfe_capture.c b/drivers/media/video/davinci/vpfe_capture.c
index 353eadaa823..71e961e53a5 100644
--- a/drivers/media/video/davinci/vpfe_capture.c
+++ b/drivers/media/video/davinci/vpfe_capture.c
@@ -1719,7 +1719,7 @@ unlock_out:
1719 1719
1720 1720
1721static long vpfe_param_handler(struct file *file, void *priv, 1721static long vpfe_param_handler(struct file *file, void *priv,
1722 int cmd, void *param) 1722 bool valid_prio, int cmd, void *param)
1723{ 1723{
1724 struct vpfe_device *vpfe_dev = video_drvdata(file); 1724 struct vpfe_device *vpfe_dev = video_drvdata(file);
1725 int ret = 0; 1725 int ret = 0;
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index b686da5e432..d34a326c0ef 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -1795,7 +1795,8 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1795 return 0; 1795 return 0;
1796} 1796}
1797 1797
1798static long ivtv_default(struct file *file, void *fh, int cmd, void *arg) 1798static long ivtv_default(struct file *file, void *fh, bool valid_prio,
1799 int cmd, void *arg)
1799{ 1800{
1800 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; 1801 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
1801 1802
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 48d2c2419c1..b09a3c80a15 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -1547,7 +1547,8 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
1547 return 0; 1547 return 0;
1548} 1548}
1549 1549
1550static long vidioc_default(struct file *file, void *fh, int cmd, void *arg) 1550static long vidioc_default(struct file *file, void *fh, bool valid_prio,
1551 int cmd, void *arg)
1551{ 1552{
1552 switch (cmd) { 1553 switch (cmd) {
1553 case MEYEIOC_G_PARAMS: 1554 case MEYEIOC_G_PARAMS:
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index e8846a09b02..0b385002350 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -643,7 +643,8 @@ static int vidioc_s_register(struct file *file, void *fh, struct v4l2_dbg_regist
643} 643}
644#endif 644#endif
645 645
646static long vidioc_default(struct file *file, void *fh, int cmd, void *arg) 646static long vidioc_default(struct file *file, void *fh, bool valid_prio,
647 int cmd, void *arg)
647{ 648{
648 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; 649 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
649 struct mxb *mxb = (struct mxb *)dev->ext_priv; 650 struct mxb *mxb = (struct mxb *)dev->ext_priv;
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c
index 68a5313a52d..aa87e462a95 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -860,7 +860,8 @@ static int pwc_enum_frameintervals(struct file *file, void *fh,
860 return 0; 860 return 0;
861} 861}
862 862
863static long pwc_default(struct file *file, void *fh, int cmd, void *arg) 863static long pwc_default(struct file *file, void *fh, bool valid_prio,
864 int cmd, void *arg)
864{ 865{
865 struct pwc_device *pdev = video_drvdata(file); 866 struct pwc_device *pdev = video_drvdata(file);
866 867
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index db6ec386834..3e6b6fa5771 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -24,6 +24,7 @@
24#include <media/v4l2-ctrls.h> 24#include <media/v4l2-ctrls.h>
25#include <media/v4l2-fh.h> 25#include <media/v4l2-fh.h>
26#include <media/v4l2-event.h> 26#include <media/v4l2-event.h>
27#include <media/v4l2-device.h>
27#include <media/v4l2-chip-ident.h> 28#include <media/v4l2-chip-ident.h>
28 29
29#define dbgarg(cmd, fmt, arg...) \ 30#define dbgarg(cmd, fmt, arg...) \
@@ -538,6 +539,7 @@ static long __video_do_ioctl(struct file *file,
538 struct video_device *vfd = video_devdata(file); 539 struct video_device *vfd = video_devdata(file);
539 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; 540 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
540 void *fh = file->private_data; 541 void *fh = file->private_data;
542 struct v4l2_fh *vfh = NULL;
541 struct v4l2_format f_copy; 543 struct v4l2_format f_copy;
542 long ret = -EINVAL; 544 long ret = -EINVAL;
543 545
@@ -553,6 +555,43 @@ static long __video_do_ioctl(struct file *file,
553 printk(KERN_CONT "\n"); 555 printk(KERN_CONT "\n");
554 } 556 }
555 557
558 if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags))
559 vfh = file->private_data;
560
561 if (vfh && !ops->vidioc_s_priority) {
562 switch (cmd) {
563 case VIDIOC_S_CTRL:
564 case VIDIOC_S_STD:
565 case VIDIOC_S_INPUT:
566 case VIDIOC_S_OUTPUT:
567 case VIDIOC_S_TUNER:
568 case VIDIOC_S_FREQUENCY:
569 case VIDIOC_S_FMT:
570 case VIDIOC_S_CROP:
571 case VIDIOC_S_AUDIO:
572 case VIDIOC_S_AUDOUT:
573 case VIDIOC_S_EXT_CTRLS:
574 case VIDIOC_S_FBUF:
575 case VIDIOC_S_PRIORITY:
576 case VIDIOC_S_DV_PRESET:
577 case VIDIOC_S_DV_TIMINGS:
578 case VIDIOC_S_JPEGCOMP:
579 case VIDIOC_S_MODULATOR:
580 case VIDIOC_S_PARM:
581 case VIDIOC_S_HW_FREQ_SEEK:
582 case VIDIOC_ENCODER_CMD:
583 case VIDIOC_OVERLAY:
584 case VIDIOC_REQBUFS:
585 case VIDIOC_STREAMON:
586 case VIDIOC_STREAMOFF:
587 ret = v4l2_prio_check(vfd->prio, vfh->prio);
588 if (ret)
589 goto exit_prio;
590 ret = -EINVAL;
591 break;
592 }
593 }
594
556 switch (cmd) { 595 switch (cmd) {
557 596
558 /* --- capabilities ------------------------------------------ */ 597 /* --- capabilities ------------------------------------------ */
@@ -579,9 +618,12 @@ static long __video_do_ioctl(struct file *file,
579 { 618 {
580 enum v4l2_priority *p = arg; 619 enum v4l2_priority *p = arg;
581 620
582 if (!ops->vidioc_g_priority) 621 if (ops->vidioc_g_priority) {
583 break; 622 ret = ops->vidioc_g_priority(file, fh, p);
584 ret = ops->vidioc_g_priority(file, fh, p); 623 } else if (vfh) {
624 *p = v4l2_prio_max(&vfd->v4l2_dev->prio);
625 ret = 0;
626 }
585 if (!ret) 627 if (!ret)
586 dbgarg(cmd, "priority is %d\n", *p); 628 dbgarg(cmd, "priority is %d\n", *p);
587 break; 629 break;
@@ -590,10 +632,13 @@ static long __video_do_ioctl(struct file *file,
590 { 632 {
591 enum v4l2_priority *p = arg; 633 enum v4l2_priority *p = arg;
592 634
593 if (!ops->vidioc_s_priority) 635 if (!ops->vidioc_s_priority && vfh == NULL)
594 break; 636 break;
595 dbgarg(cmd, "setting priority to %d\n", *p); 637 dbgarg(cmd, "setting priority to %d\n", *p);
596 ret = ops->vidioc_s_priority(file, fh, *p); 638 if (ops->vidioc_s_priority)
639 ret = ops->vidioc_s_priority(file, fh, *p);
640 else
641 ret = v4l2_prio_change(&vfd->v4l2_dev->prio, &vfh->prio, *p);
597 break; 642 break;
598 } 643 }
599 644
@@ -2138,13 +2183,18 @@ static long __video_do_ioctl(struct file *file,
2138 } 2183 }
2139 default: 2184 default:
2140 { 2185 {
2186 bool valid_prio = true;
2187
2141 if (!ops->vidioc_default) 2188 if (!ops->vidioc_default)
2142 break; 2189 break;
2143 ret = ops->vidioc_default(file, fh, cmd, arg); 2190 if (vfh && !ops->vidioc_s_priority)
2191 valid_prio = v4l2_prio_check(vfd->prio, vfh->prio) >= 0;
2192 ret = ops->vidioc_default(file, fh, valid_prio, cmd, arg);
2144 break; 2193 break;
2145 } 2194 }
2146 } /* switch */ 2195 } /* switch */
2147 2196
2197exit_prio:
2148 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { 2198 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) {
2149 if (ret < 0) { 2199 if (ret < 0) {
2150 v4l_print_ioctl(vfd->name, cmd); 2200 v4l_print_ioctl(vfd->name, cmd);