26
26
27
27
#include "uvcvideo.h"
28
28
29
+ static int uvc_acquire_privileges (struct uvc_fh * handle );
30
+
29
31
static int uvc_control_add_xu_mapping (struct uvc_video_chain * chain ,
30
32
struct uvc_control_mapping * map ,
31
33
const struct uvc_xu_control_mapping * xmap )
@@ -361,9 +363,11 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
361
363
return ret ;
362
364
}
363
365
364
- static int uvc_v4l2_get_format (struct uvc_streaming * stream ,
365
- struct v4l2_format * fmt )
366
+ static int uvc_ioctl_g_fmt (struct file * file , void * fh ,
367
+ struct v4l2_format * fmt )
366
368
{
369
+ struct uvc_fh * handle = fh ;
370
+ struct uvc_streaming * stream = handle -> stream ;
367
371
const struct uvc_format * format ;
368
372
const struct uvc_frame * frame ;
369
373
int ret = 0 ;
@@ -395,14 +399,20 @@ static int uvc_v4l2_get_format(struct uvc_streaming *stream,
395
399
return ret ;
396
400
}
397
401
398
- static int uvc_v4l2_set_format (struct uvc_streaming * stream ,
399
- struct v4l2_format * fmt )
402
+ static int uvc_ioctl_s_fmt (struct file * file , void * fh ,
403
+ struct v4l2_format * fmt )
400
404
{
405
+ struct uvc_fh * handle = fh ;
406
+ struct uvc_streaming * stream = handle -> stream ;
401
407
struct uvc_streaming_control probe ;
402
408
const struct uvc_format * format ;
403
409
const struct uvc_frame * frame ;
404
410
int ret ;
405
411
412
+ ret = uvc_acquire_privileges (handle );
413
+ if (ret < 0 )
414
+ return ret ;
415
+
406
416
if (fmt -> type != stream -> type )
407
417
return - EINVAL ;
408
418
@@ -426,10 +436,12 @@ static int uvc_v4l2_set_format(struct uvc_streaming *stream,
426
436
return ret ;
427
437
}
428
438
429
- static int uvc_v4l2_get_streamparm (struct uvc_streaming * stream ,
430
- struct v4l2_streamparm * parm )
439
+ static int uvc_ioctl_g_parm (struct file * file , void * fh ,
440
+ struct v4l2_streamparm * parm )
431
441
{
432
442
u32 numerator , denominator ;
443
+ struct uvc_fh * handle = fh ;
444
+ struct uvc_streaming * stream = handle -> stream ;
433
445
434
446
if (parm -> type != stream -> type )
435
447
return - EINVAL ;
@@ -461,9 +473,11 @@ static int uvc_v4l2_get_streamparm(struct uvc_streaming *stream,
461
473
return 0 ;
462
474
}
463
475
464
- static int uvc_v4l2_set_streamparm (struct uvc_streaming * stream ,
465
- struct v4l2_streamparm * parm )
476
+ static int uvc_ioctl_s_parm (struct file * file , void * fh ,
477
+ struct v4l2_streamparm * parm )
466
478
{
479
+ struct uvc_fh * handle = fh ;
480
+ struct uvc_streaming * stream = handle -> stream ;
467
481
struct uvc_streaming_control probe ;
468
482
struct v4l2_fract timeperframe ;
469
483
const struct uvc_format * format ;
@@ -472,6 +486,10 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
472
486
unsigned int i ;
473
487
int ret ;
474
488
489
+ ret = uvc_acquire_privileges (handle );
490
+ if (ret < 0 )
491
+ return ret ;
492
+
475
493
if (parm -> type != stream -> type )
476
494
return - EINVAL ;
477
495
@@ -573,6 +591,7 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
573
591
* - VIDIOC_S_INPUT
574
592
* - VIDIOC_S_PARM
575
593
* - VIDIOC_S_FMT
594
+ * - VIDIOC_CREATE_BUFS
576
595
* - VIDIOC_REQBUFS
577
596
*/
578
597
static int uvc_acquire_privileges (struct uvc_fh * handle )
@@ -685,11 +704,13 @@ static int uvc_ioctl_querycap(struct file *file, void *fh,
685
704
return 0 ;
686
705
}
687
706
688
- static int uvc_ioctl_enum_fmt (struct uvc_streaming * stream ,
707
+ static int uvc_ioctl_enum_fmt (struct file * file , void * fh ,
689
708
struct v4l2_fmtdesc * fmt )
690
709
{
691
- const struct uvc_format * format ;
710
+ struct uvc_fh * handle = fh ;
711
+ struct uvc_streaming * stream = handle -> stream ;
692
712
enum v4l2_buf_type type = fmt -> type ;
713
+ const struct uvc_format * format ;
693
714
u32 index = fmt -> index ;
694
715
695
716
if (fmt -> type != stream -> type || fmt -> index >= stream -> nformats )
@@ -707,82 +728,8 @@ static int uvc_ioctl_enum_fmt(struct uvc_streaming *stream,
707
728
return 0 ;
708
729
}
709
730
710
- static int uvc_ioctl_enum_fmt_vid_cap (struct file * file , void * fh ,
711
- struct v4l2_fmtdesc * fmt )
712
- {
713
- struct uvc_fh * handle = fh ;
714
- struct uvc_streaming * stream = handle -> stream ;
715
-
716
- return uvc_ioctl_enum_fmt (stream , fmt );
717
- }
718
-
719
- static int uvc_ioctl_enum_fmt_vid_out (struct file * file , void * fh ,
720
- struct v4l2_fmtdesc * fmt )
721
- {
722
- struct uvc_fh * handle = fh ;
723
- struct uvc_streaming * stream = handle -> stream ;
724
-
725
- return uvc_ioctl_enum_fmt (stream , fmt );
726
- }
727
-
728
- static int uvc_ioctl_g_fmt_vid_cap (struct file * file , void * fh ,
729
- struct v4l2_format * fmt )
730
- {
731
- struct uvc_fh * handle = fh ;
732
- struct uvc_streaming * stream = handle -> stream ;
733
-
734
- return uvc_v4l2_get_format (stream , fmt );
735
- }
736
-
737
- static int uvc_ioctl_g_fmt_vid_out (struct file * file , void * fh ,
738
- struct v4l2_format * fmt )
739
- {
740
- struct uvc_fh * handle = fh ;
741
- struct uvc_streaming * stream = handle -> stream ;
742
-
743
- return uvc_v4l2_get_format (stream , fmt );
744
- }
745
-
746
- static int uvc_ioctl_s_fmt_vid_cap (struct file * file , void * fh ,
747
- struct v4l2_format * fmt )
748
- {
749
- struct uvc_fh * handle = fh ;
750
- struct uvc_streaming * stream = handle -> stream ;
751
- int ret ;
752
-
753
- ret = uvc_acquire_privileges (handle );
754
- if (ret < 0 )
755
- return ret ;
756
-
757
- return uvc_v4l2_set_format (stream , fmt );
758
- }
759
-
760
- static int uvc_ioctl_s_fmt_vid_out (struct file * file , void * fh ,
761
- struct v4l2_format * fmt )
762
- {
763
- struct uvc_fh * handle = fh ;
764
- struct uvc_streaming * stream = handle -> stream ;
765
- int ret ;
766
-
767
- ret = uvc_acquire_privileges (handle );
768
- if (ret < 0 )
769
- return ret ;
770
-
771
- return uvc_v4l2_set_format (stream , fmt );
772
- }
773
-
774
- static int uvc_ioctl_try_fmt_vid_cap (struct file * file , void * fh ,
775
- struct v4l2_format * fmt )
776
- {
777
- struct uvc_fh * handle = fh ;
778
- struct uvc_streaming * stream = handle -> stream ;
779
- struct uvc_streaming_control probe ;
780
-
781
- return uvc_v4l2_try_format (stream , fmt , & probe , NULL , NULL );
782
- }
783
-
784
- static int uvc_ioctl_try_fmt_vid_out (struct file * file , void * fh ,
785
- struct v4l2_format * fmt )
731
+ static int uvc_ioctl_try_fmt (struct file * file , void * fh ,
732
+ struct v4l2_format * fmt )
786
733
{
787
734
struct uvc_fh * handle = fh ;
788
735
struct uvc_streaming * stream = handle -> stream ;
@@ -1212,29 +1159,6 @@ static int uvc_ioctl_g_selection(struct file *file, void *fh,
1212
1159
return 0 ;
1213
1160
}
1214
1161
1215
- static int uvc_ioctl_g_parm (struct file * file , void * fh ,
1216
- struct v4l2_streamparm * parm )
1217
- {
1218
- struct uvc_fh * handle = fh ;
1219
- struct uvc_streaming * stream = handle -> stream ;
1220
-
1221
- return uvc_v4l2_get_streamparm (stream , parm );
1222
- }
1223
-
1224
- static int uvc_ioctl_s_parm (struct file * file , void * fh ,
1225
- struct v4l2_streamparm * parm )
1226
- {
1227
- struct uvc_fh * handle = fh ;
1228
- struct uvc_streaming * stream = handle -> stream ;
1229
- int ret ;
1230
-
1231
- ret = uvc_acquire_privileges (handle );
1232
- if (ret < 0 )
1233
- return ret ;
1234
-
1235
- return uvc_v4l2_set_streamparm (stream , parm );
1236
- }
1237
-
1238
1162
static int uvc_ioctl_enum_framesizes (struct file * file , void * fh ,
1239
1163
struct v4l2_frmsizeenum * fsize )
1240
1164
{
@@ -1543,15 +1467,17 @@ static unsigned long uvc_v4l2_get_unmapped_area(struct file *file,
1543
1467
#endif
1544
1468
1545
1469
const struct v4l2_ioctl_ops uvc_ioctl_ops = {
1470
+ .vidioc_g_fmt_vid_cap = uvc_ioctl_g_fmt ,
1471
+ .vidioc_g_fmt_vid_out = uvc_ioctl_g_fmt ,
1472
+ .vidioc_s_fmt_vid_cap = uvc_ioctl_s_fmt ,
1473
+ .vidioc_s_fmt_vid_out = uvc_ioctl_s_fmt ,
1474
+ .vidioc_g_parm = uvc_ioctl_g_parm ,
1475
+ .vidioc_s_parm = uvc_ioctl_s_parm ,
1546
1476
.vidioc_querycap = uvc_ioctl_querycap ,
1547
- .vidioc_enum_fmt_vid_cap = uvc_ioctl_enum_fmt_vid_cap ,
1548
- .vidioc_enum_fmt_vid_out = uvc_ioctl_enum_fmt_vid_out ,
1549
- .vidioc_g_fmt_vid_cap = uvc_ioctl_g_fmt_vid_cap ,
1550
- .vidioc_g_fmt_vid_out = uvc_ioctl_g_fmt_vid_out ,
1551
- .vidioc_s_fmt_vid_cap = uvc_ioctl_s_fmt_vid_cap ,
1552
- .vidioc_s_fmt_vid_out = uvc_ioctl_s_fmt_vid_out ,
1553
- .vidioc_try_fmt_vid_cap = uvc_ioctl_try_fmt_vid_cap ,
1554
- .vidioc_try_fmt_vid_out = uvc_ioctl_try_fmt_vid_out ,
1477
+ .vidioc_enum_fmt_vid_cap = uvc_ioctl_enum_fmt ,
1478
+ .vidioc_enum_fmt_vid_out = uvc_ioctl_enum_fmt ,
1479
+ .vidioc_try_fmt_vid_cap = uvc_ioctl_try_fmt ,
1480
+ .vidioc_try_fmt_vid_out = uvc_ioctl_try_fmt ,
1555
1481
.vidioc_reqbufs = uvc_ioctl_reqbufs ,
1556
1482
.vidioc_querybuf = uvc_ioctl_querybuf ,
1557
1483
.vidioc_qbuf = uvc_ioctl_qbuf ,
@@ -1570,8 +1496,6 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = {
1570
1496
.vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls ,
1571
1497
.vidioc_querymenu = uvc_ioctl_querymenu ,
1572
1498
.vidioc_g_selection = uvc_ioctl_g_selection ,
1573
- .vidioc_g_parm = uvc_ioctl_g_parm ,
1574
- .vidioc_s_parm = uvc_ioctl_s_parm ,
1575
1499
.vidioc_enum_framesizes = uvc_ioctl_enum_framesizes ,
1576
1500
.vidioc_enum_frameintervals = uvc_ioctl_enum_frameintervals ,
1577
1501
.vidioc_subscribe_event = uvc_ioctl_subscribe_event ,
0 commit comments