29 #include <linux/errno.h>
32 #include <linux/module.h>
33 #include <linux/poll.h>
40 #define PWC_CID_CUSTOM(ctrl) ((V4L2_CID_USER_BASE | 0xf000) + custom_ ## ctrl)
46 .g_volatile_ctrl = pwc_g_volatile_ctrl,
56 "Indoor (Incandescant Lighting) Mode",
57 "Outdoor (Sunlight) Mode",
58 "Indoor (Fluorescent Lighting) Mode",
76 .name =
"Auto contour",
103 .ops = &pwc_ctrl_ops,
112 .ops = &pwc_ctrl_ops,
115 .name =
"Dynamic Noise Reduction",
122 .ops = &pwc_ctrl_ops,
125 .name =
"Save User Settings",
129 .ops = &pwc_ctrl_ops,
132 .name =
"Restore User Settings",
136 .ops = &pwc_ctrl_ops,
139 .name =
"Restore Factory Settings",
143 .ops = &pwc_ctrl_ops,
146 .name =
"Auto White Balance Speed",
153 .ops = &pwc_ctrl_ops,
156 .name =
"Auto White Balance Delay",
186 if (pdev->
type >= 675) {
187 if (pdev->
type < 730)
193 if (r || def < -100 || def > 100)
209 cfg = pwc_auto_white_balance_cfg;
235 if (r || (def != 0 && def != 0xff))
253 if (r || (def != 0 && def != 0xff))
296 if (r || (def != 0 && def != 0xff))
304 if (r || (def != 0 && def != 0xff))
306 cfg = pwc_autocontour_cfg;
315 cfg = pwc_contour_cfg;
324 if (r || (def != 0 && def != 0xff))
326 cfg = pwc_backlight_cfg;
334 if (r || (def != 0 && def != 0xff))
336 cfg = pwc_flicker_cfg;
346 cfg = pwc_noise_reduction_cfg;
357 &pwc_restore_factory_cfg,
365 if (r || def < 1 || def > 32)
367 cfg = pwc_awb_speed_cfg;
375 cfg = pwc_awb_delay_cfg;
405 f->
fmt.
pix.pixelformat = pixfmt;
410 "width=%d, height=%d, bytesperline=%d, sizeimage=%d, pixelformat=%c%c%c%c\n",
415 (f->
fmt.
pix.pixelformat)&255,
416 (f->
fmt.
pix.pixelformat>>8)&255,
417 (f->
fmt.
pix.pixelformat>>16)&255,
418 (f->
fmt.
pix.pixelformat>>24)&255);
427 PWC_DEBUG_IOCTL(
"Bad video type must be V4L2_BUF_TYPE_VIDEO_CAPTURE\n");
431 switch (f->
fmt.
pix.pixelformat) {
453 pwc_vidioc_fill_fmt(f,
465 struct pwc_device *pdev = video_drvdata(file);
468 ret = pwc_vidioc_try_fmt(pdev, f);
475 pixelformat = f->
fmt.
pix.pixelformat;
481 (pixelformat>>8)&255,
482 (pixelformat>>16)&255,
483 (pixelformat>>24)&255);
486 pixelformat, 30, &compression, 0);
496 struct pwc_device *pdev = video_drvdata(file);
507 static int pwc_enum_input(
struct file *file,
void *fh,
struct v4l2_input *
i)
517 static int pwc_g_input(
struct file *file,
void *fh,
unsigned int *i)
523 static int pwc_s_input(
struct file *file,
void *fh,
unsigned int i)
600 static int pwc_set_awb(
struct pwc_device *pdev)
645 static int pwc_set_autogain(
struct pwc_device *pdev)
663 if (pdev->
gain->is_new) {
674 static int pwc_set_exposure_auto(
struct pwc_device *pdev)
704 static int pwc_set_autogain_expo(
struct pwc_device *pdev)
724 if (pdev->
gain->is_new) {
742 static int pwc_set_motor(
struct pwc_device *pdev)
779 static int pwc_s_ctrl(
struct v4l2_ctrl *ctrl)
803 ret = pwc_set_awb(pdev);
807 ret = pwc_set_autogain(pdev);
809 ret = pwc_set_autogain_expo(pdev);
815 ret = pwc_set_exposure_auto(pdev);
822 ctrl->
val ? 0 : 0xff);
830 if (ret == 0 && pdev->
contour->is_new) {
839 ctrl->
val ? 0 : 0xff);
844 ctrl->
val ? 0 : 0xff);
872 ret = pwc_set_motor(pdev);
884 static int pwc_enum_fmt_vid_cap(
struct file *file,
void *fh,
struct v4l2_fmtdesc *f)
886 struct pwc_device *pdev = video_drvdata(file);
906 static int pwc_g_fmt_vid_cap(
struct file *file,
void *fh,
struct v4l2_format *f)
908 struct pwc_device *pdev = video_drvdata(file);
919 static int pwc_try_fmt_vid_cap(
struct file *file,
void *fh,
struct v4l2_format *f)
921 struct pwc_device *pdev = video_drvdata(file);
923 return pwc_vidioc_try_fmt(pdev, f);
926 static int pwc_enum_framesizes(
struct file *file,
void *fh,
929 struct pwc_device *pdev = video_drvdata(file);
937 for (i = 0; i <
PSZ_MAX; i++) {
951 static int pwc_enum_frameintervals(
struct file *file,
void *fh,
954 struct pwc_device *pdev = video_drvdata(file);
958 for (i = 0; i <
PSZ_MAX; i++) {
981 static int pwc_g_parm(
struct file *file,
void *fh,
984 struct pwc_device *pdev = video_drvdata(file);
989 memset(parm, 0,
sizeof(*parm));
1000 static int pwc_s_parm(
struct file *file,
void *fh,
1003 struct pwc_device *pdev = video_drvdata(file);
1004 int compression = 0;
1013 if (parm->
parm.
capture.timeperframe.numerator == 0 ||
1017 fps = parm->
parm.
capture.timeperframe.denominator /
1024 fps, &compression, 0);
1026 pwc_g_parm(file, fh, parm);
1032 .vidioc_querycap = pwc_querycap,
1033 .vidioc_enum_input = pwc_enum_input,
1034 .vidioc_g_input = pwc_g_input,
1035 .vidioc_s_input = pwc_s_input,
1036 .vidioc_enum_fmt_vid_cap = pwc_enum_fmt_vid_cap,
1037 .vidioc_g_fmt_vid_cap = pwc_g_fmt_vid_cap,
1038 .vidioc_s_fmt_vid_cap = pwc_s_fmt_vid_cap,
1039 .vidioc_try_fmt_vid_cap = pwc_try_fmt_vid_cap,
1047 .vidioc_enum_framesizes = pwc_enum_framesizes,
1048 .vidioc_enum_frameintervals = pwc_enum_frameintervals,
1049 .vidioc_g_parm = pwc_g_parm,
1050 .vidioc_s_parm = pwc_s_parm,