Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
99cd47bc dfddb244

+73 -16
+2 -1
drivers/media/radio/radio-si4713.c
··· 224 224 s_frequency, vf); 225 225 } 226 226 227 - static long radio_si4713_default(struct file *file, void *p, int cmd, void *arg) 227 + static long radio_si4713_default(struct file *file, void *p, 228 + bool valid_prio, int cmd, void *arg) 228 229 { 229 230 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core, 230 231 ioctl, cmd, arg);
+2 -1
drivers/media/video/cpia2/cpia2_v4l.c
··· 395 395 * 396 396 *****************************************************************************/ 397 397 398 - static long cpia2_default(struct file *file, void *fh, int cmd, void *arg) 398 + static long cpia2_default(struct file *file, void *fh, bool valid_prio, 399 + int cmd, void *arg) 399 400 { 400 401 struct camera_data *cam = video_drvdata(file); 401 402 __u32 gpio_val;
+2 -1
drivers/media/video/cx18/cx18-ioctl.c
··· 1057 1057 return 0; 1058 1058 } 1059 1059 1060 - static long cx18_default(struct file *file, void *fh, int cmd, void *arg) 1060 + static long cx18_default(struct file *file, void *fh, bool valid_prio, 1061 + int cmd, void *arg) 1061 1062 { 1062 1063 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; 1063 1064
+1 -1
drivers/media/video/davinci/vpfe_capture.c
··· 1719 1719 1720 1720 1721 1721 static 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 1724 struct vpfe_device *vpfe_dev = video_drvdata(file); 1725 1725 int ret = 0;
+2 -1
drivers/media/video/ivtv/ivtv-ioctl.c
··· 1795 1795 return 0; 1796 1796 } 1797 1797 1798 - static long ivtv_default(struct file *file, void *fh, int cmd, void *arg) 1798 + static long ivtv_default(struct file *file, void *fh, bool valid_prio, 1799 + int cmd, void *arg) 1799 1800 { 1800 1801 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; 1801 1802
+2 -1
drivers/media/video/meye.c
··· 1547 1547 return 0; 1548 1548 } 1549 1549 1550 - static long vidioc_default(struct file *file, void *fh, int cmd, void *arg) 1550 + static long vidioc_default(struct file *file, void *fh, bool valid_prio, 1551 + int cmd, void *arg) 1551 1552 { 1552 1553 switch (cmd) { 1553 1554 case MEYEIOC_G_PARAMS:
+2 -1
drivers/media/video/mxb.c
··· 643 643 } 644 644 #endif 645 645 646 - static long vidioc_default(struct file *file, void *fh, int cmd, void *arg) 646 + static long vidioc_default(struct file *file, void *fh, bool valid_prio, 647 + int cmd, void *arg) 647 648 { 648 649 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; 649 650 struct mxb *mxb = (struct mxb *)dev->ext_priv;
+2 -1
drivers/media/video/pwc/pwc-v4l.c
··· 860 860 return 0; 861 861 } 862 862 863 - static long pwc_default(struct file *file, void *fh, int cmd, void *arg) 863 + static long pwc_default(struct file *file, void *fh, bool valid_prio, 864 + int cmd, void *arg) 864 865 { 865 866 struct pwc_device *pdev = video_drvdata(file); 866 867
+57 -7
drivers/media/video/v4l2-ioctl.c
··· 24 24 #include <media/v4l2-ctrls.h> 25 25 #include <media/v4l2-fh.h> 26 26 #include <media/v4l2-event.h> 27 + #include <media/v4l2-device.h> 27 28 #include <media/v4l2-chip-ident.h> 28 29 29 30 #define dbgarg(cmd, fmt, arg...) \ ··· 539 538 struct video_device *vfd = video_devdata(file); 540 539 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; 541 540 void *fh = file->private_data; 541 + struct v4l2_fh *vfh = NULL; 542 542 struct v4l2_format f_copy; 543 543 long ret = -EINVAL; 544 544 ··· 553 551 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { 554 552 v4l_print_ioctl(vfd->name, cmd); 555 553 printk(KERN_CONT "\n"); 554 + } 555 + 556 + if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) 557 + vfh = file->private_data; 558 + 559 + if (vfh && !ops->vidioc_s_priority) { 560 + switch (cmd) { 561 + case VIDIOC_S_CTRL: 562 + case VIDIOC_S_STD: 563 + case VIDIOC_S_INPUT: 564 + case VIDIOC_S_OUTPUT: 565 + case VIDIOC_S_TUNER: 566 + case VIDIOC_S_FREQUENCY: 567 + case VIDIOC_S_FMT: 568 + case VIDIOC_S_CROP: 569 + case VIDIOC_S_AUDIO: 570 + case VIDIOC_S_AUDOUT: 571 + case VIDIOC_S_EXT_CTRLS: 572 + case VIDIOC_S_FBUF: 573 + case VIDIOC_S_PRIORITY: 574 + case VIDIOC_S_DV_PRESET: 575 + case VIDIOC_S_DV_TIMINGS: 576 + case VIDIOC_S_JPEGCOMP: 577 + case VIDIOC_S_MODULATOR: 578 + case VIDIOC_S_PARM: 579 + case VIDIOC_S_HW_FREQ_SEEK: 580 + case VIDIOC_ENCODER_CMD: 581 + case VIDIOC_OVERLAY: 582 + case VIDIOC_REQBUFS: 583 + case VIDIOC_STREAMON: 584 + case VIDIOC_STREAMOFF: 585 + ret = v4l2_prio_check(vfd->prio, vfh->prio); 586 + if (ret) 587 + goto exit_prio; 588 + ret = -EINVAL; 589 + break; 590 + } 556 591 } 557 592 558 593 switch (cmd) { ··· 618 579 { 619 580 enum v4l2_priority *p = arg; 620 581 621 - if (!ops->vidioc_g_priority) 622 - break; 623 - ret = ops->vidioc_g_priority(file, fh, p); 582 + if (ops->vidioc_g_priority) { 583 + ret = ops->vidioc_g_priority(file, fh, p); 584 + } else if (vfh) { 585 + *p = v4l2_prio_max(&vfd->v4l2_dev->prio); 586 + ret = 0; 587 + } 624 588 if (!ret) 625 589 dbgarg(cmd, "priority is %d\n", *p); 626 590 break; ··· 632 590 { 633 591 enum v4l2_priority *p = arg; 634 592 635 - if (!ops->vidioc_s_priority) 636 - break; 593 + if (!ops->vidioc_s_priority && vfh == NULL) 594 + break; 637 595 dbgarg(cmd, "setting priority to %d\n", *p); 638 - ret = ops->vidioc_s_priority(file, fh, *p); 596 + if (ops->vidioc_s_priority) 597 + ret = ops->vidioc_s_priority(file, fh, *p); 598 + else 599 + ret = v4l2_prio_change(&vfd->v4l2_dev->prio, &vfh->prio, *p); 639 600 break; 640 601 } 641 602 ··· 2183 2138 } 2184 2139 default: 2185 2140 { 2141 + bool valid_prio = true; 2142 + 2186 2143 if (!ops->vidioc_default) 2187 2144 break; 2188 - ret = ops->vidioc_default(file, fh, cmd, arg); 2145 + if (vfh && !ops->vidioc_s_priority) 2146 + valid_prio = v4l2_prio_check(vfd->prio, vfh->prio) >= 0; 2147 + ret = ops->vidioc_default(file, fh, valid_prio, cmd, arg); 2189 2148 break; 2190 2149 } 2191 2150 } /* switch */ 2192 2151 2152 + exit_prio: 2193 2153 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { 2194 2154 if (ret < 0) { 2195 2155 v4l_print_ioctl(vfd->name, cmd);
+1 -1
include/media/v4l2-ioctl.h
··· 270 270 271 271 /* For other private ioctls */ 272 272 long (*vidioc_default) (struct file *file, void *fh, 273 - int cmd, void *arg); 273 + bool valid_prio, int cmd, void *arg); 274 274 }; 275 275 276 276