diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-12-14 06:28:24 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-01-07 04:17:12 -0500 |
commit | 718bde1aa9e03fd49d69816c4facea55d69a4737 (patch) | |
tree | fb204ab2a1aec2d770397c6f8194b5e7dca3d22a | |
parent | 9db0fb182ea8a42c5bfd322b169d65728721fd71 (diff) |
[media] saa7134: convert to the control framework
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/pci/saa7134/saa7134-core.c | 9 | ||||
-rw-r--r-- | drivers/media/pci/saa7134/saa7134-empress.c | 140 | ||||
-rw-r--r-- | drivers/media/pci/saa7134/saa7134-video.c | 395 | ||||
-rw-r--r-- | drivers/media/pci/saa7134/saa7134.h | 13 | ||||
-rw-r--r-- | include/uapi/linux/v4l2-controls.h | 4 |
5 files changed, 162 insertions, 399 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c index f442405568d8..d3b4e5661c83 100644 --- a/drivers/media/pci/saa7134/saa7134-core.c +++ b/drivers/media/pci/saa7134/saa7134-core.c | |||
@@ -1009,13 +1009,13 @@ static int saa7134_initdev(struct pci_dev *pci_dev, | |||
1009 | 1009 | ||
1010 | /* load i2c helpers */ | 1010 | /* load i2c helpers */ |
1011 | if (card_is_empress(dev)) { | 1011 | if (card_is_empress(dev)) { |
1012 | struct v4l2_subdev *sd = | 1012 | dev->empress_sd = |
1013 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, | 1013 | v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap, |
1014 | "saa6752hs", | 1014 | "saa6752hs", |
1015 | saa7134_boards[dev->board].empress_addr, NULL); | 1015 | saa7134_boards[dev->board].empress_addr, NULL); |
1016 | 1016 | ||
1017 | if (sd) | 1017 | if (dev->empress_sd) |
1018 | sd->grp_id = GRP_EMPRESS; | 1018 | dev->empress_sd->grp_id = GRP_EMPRESS; |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | if (saa7134_boards[dev->board].rds_addr) { | 1021 | if (saa7134_boards[dev->board].rds_addr) { |
@@ -1047,6 +1047,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev, | |||
1047 | printk(KERN_INFO "%s: Overlay support disabled.\n", dev->name); | 1047 | printk(KERN_INFO "%s: Overlay support disabled.\n", dev->name); |
1048 | 1048 | ||
1049 | dev->video_dev = vdev_init(dev,&saa7134_video_template,"video"); | 1049 | dev->video_dev = vdev_init(dev,&saa7134_video_template,"video"); |
1050 | dev->video_dev->ctrl_handler = &dev->ctrl_handler; | ||
1050 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, | 1051 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, |
1051 | video_nr[dev->nr]); | 1052 | video_nr[dev->nr]); |
1052 | if (err < 0) { | 1053 | if (err < 0) { |
@@ -1058,6 +1059,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev, | |||
1058 | dev->name, video_device_node_name(dev->video_dev)); | 1059 | dev->name, video_device_node_name(dev->video_dev)); |
1059 | 1060 | ||
1060 | dev->vbi_dev = vdev_init(dev, &saa7134_video_template, "vbi"); | 1061 | dev->vbi_dev = vdev_init(dev, &saa7134_video_template, "vbi"); |
1062 | dev->vbi_dev->ctrl_handler = &dev->ctrl_handler; | ||
1061 | 1063 | ||
1062 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, | 1064 | err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, |
1063 | vbi_nr[dev->nr]); | 1065 | vbi_nr[dev->nr]); |
@@ -1068,6 +1070,7 @@ static int saa7134_initdev(struct pci_dev *pci_dev, | |||
1068 | 1070 | ||
1069 | if (card_has_radio(dev)) { | 1071 | if (card_has_radio(dev)) { |
1070 | dev->radio_dev = vdev_init(dev,&saa7134_radio_template,"radio"); | 1072 | dev->radio_dev = vdev_init(dev,&saa7134_radio_template,"radio"); |
1073 | dev->radio_dev->ctrl_handler = &dev->radio_ctrl_handler; | ||
1071 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, | 1074 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, |
1072 | radio_nr[dev->nr]); | 1075 | radio_nr[dev->nr]); |
1073 | if (err < 0) | 1076 | if (err < 0) |
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c index 3022eb2a7925..7c24f44c98bd 100644 --- a/drivers/media/pci/saa7134/saa7134-empress.c +++ b/drivers/media/pci/saa7134/saa7134-empress.c | |||
@@ -316,113 +316,6 @@ static int empress_streamoff(struct file *file, void *priv, | |||
316 | return videobuf_streamoff(&dev->empress_tsq); | 316 | return videobuf_streamoff(&dev->empress_tsq); |
317 | } | 317 | } |
318 | 318 | ||
319 | static int empress_s_ext_ctrls(struct file *file, void *priv, | ||
320 | struct v4l2_ext_controls *ctrls) | ||
321 | { | ||
322 | struct saa7134_dev *dev = file->private_data; | ||
323 | int err; | ||
324 | |||
325 | /* count == 0 is abused in saa6752hs.c, so that special | ||
326 | case is handled here explicitly. */ | ||
327 | if (ctrls->count == 0) | ||
328 | return 0; | ||
329 | |||
330 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
331 | return -EINVAL; | ||
332 | |||
333 | err = saa_call_empress(dev, core, s_ext_ctrls, ctrls); | ||
334 | ts_init_encoder(dev); | ||
335 | |||
336 | return err; | ||
337 | } | ||
338 | |||
339 | static int empress_g_ext_ctrls(struct file *file, void *priv, | ||
340 | struct v4l2_ext_controls *ctrls) | ||
341 | { | ||
342 | struct saa7134_dev *dev = file->private_data; | ||
343 | |||
344 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
345 | return -EINVAL; | ||
346 | return saa_call_empress(dev, core, g_ext_ctrls, ctrls); | ||
347 | } | ||
348 | |||
349 | static int empress_g_ctrl(struct file *file, void *priv, | ||
350 | struct v4l2_control *c) | ||
351 | { | ||
352 | struct saa7134_dev *dev = file->private_data; | ||
353 | |||
354 | return saa7134_g_ctrl_internal(dev, NULL, c); | ||
355 | } | ||
356 | |||
357 | static int empress_s_ctrl(struct file *file, void *priv, | ||
358 | struct v4l2_control *c) | ||
359 | { | ||
360 | struct saa7134_dev *dev = file->private_data; | ||
361 | |||
362 | return saa7134_s_ctrl_internal(dev, NULL, c); | ||
363 | } | ||
364 | |||
365 | static int empress_queryctrl(struct file *file, void *priv, | ||
366 | struct v4l2_queryctrl *c) | ||
367 | { | ||
368 | /* Must be sorted from low to high control ID! */ | ||
369 | static const u32 user_ctrls[] = { | ||
370 | V4L2_CID_USER_CLASS, | ||
371 | V4L2_CID_BRIGHTNESS, | ||
372 | V4L2_CID_CONTRAST, | ||
373 | V4L2_CID_SATURATION, | ||
374 | V4L2_CID_HUE, | ||
375 | V4L2_CID_AUDIO_VOLUME, | ||
376 | V4L2_CID_AUDIO_MUTE, | ||
377 | V4L2_CID_HFLIP, | ||
378 | 0 | ||
379 | }; | ||
380 | |||
381 | /* Must be sorted from low to high control ID! */ | ||
382 | static const u32 mpeg_ctrls[] = { | ||
383 | V4L2_CID_MPEG_CLASS, | ||
384 | V4L2_CID_MPEG_STREAM_TYPE, | ||
385 | V4L2_CID_MPEG_STREAM_PID_PMT, | ||
386 | V4L2_CID_MPEG_STREAM_PID_AUDIO, | ||
387 | V4L2_CID_MPEG_STREAM_PID_VIDEO, | ||
388 | V4L2_CID_MPEG_STREAM_PID_PCR, | ||
389 | V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ, | ||
390 | V4L2_CID_MPEG_AUDIO_ENCODING, | ||
391 | V4L2_CID_MPEG_AUDIO_L2_BITRATE, | ||
392 | V4L2_CID_MPEG_VIDEO_ENCODING, | ||
393 | V4L2_CID_MPEG_VIDEO_ASPECT, | ||
394 | V4L2_CID_MPEG_VIDEO_BITRATE_MODE, | ||
395 | V4L2_CID_MPEG_VIDEO_BITRATE, | ||
396 | V4L2_CID_MPEG_VIDEO_BITRATE_PEAK, | ||
397 | 0 | ||
398 | }; | ||
399 | static const u32 *ctrl_classes[] = { | ||
400 | user_ctrls, | ||
401 | mpeg_ctrls, | ||
402 | NULL | ||
403 | }; | ||
404 | struct saa7134_dev *dev = file->private_data; | ||
405 | |||
406 | c->id = v4l2_ctrl_next(ctrl_classes, c->id); | ||
407 | if (c->id == 0) | ||
408 | return -EINVAL; | ||
409 | if (c->id == V4L2_CID_USER_CLASS || c->id == V4L2_CID_MPEG_CLASS) | ||
410 | return v4l2_ctrl_query_fill(c, 0, 0, 0, 0); | ||
411 | if (V4L2_CTRL_ID2CLASS(c->id) != V4L2_CTRL_CLASS_MPEG) | ||
412 | return saa7134_queryctrl(file, priv, c); | ||
413 | return saa_call_empress(dev, core, queryctrl, c); | ||
414 | } | ||
415 | |||
416 | static int empress_querymenu(struct file *file, void *priv, | ||
417 | struct v4l2_querymenu *c) | ||
418 | { | ||
419 | struct saa7134_dev *dev = file->private_data; | ||
420 | |||
421 | if (V4L2_CTRL_ID2CLASS(c->id) != V4L2_CTRL_CLASS_MPEG) | ||
422 | return -EINVAL; | ||
423 | return saa_call_empress(dev, core, querymenu, c); | ||
424 | } | ||
425 | |||
426 | static int empress_s_std(struct file *file, void *priv, v4l2_std_id id) | 319 | static int empress_s_std(struct file *file, void *priv, v4l2_std_id id) |
427 | { | 320 | { |
428 | struct saa7134_dev *dev = file->private_data; | 321 | struct saa7134_dev *dev = file->private_data; |
@@ -461,15 +354,9 @@ static const struct v4l2_ioctl_ops ts_ioctl_ops = { | |||
461 | .vidioc_dqbuf = empress_dqbuf, | 354 | .vidioc_dqbuf = empress_dqbuf, |
462 | .vidioc_streamon = empress_streamon, | 355 | .vidioc_streamon = empress_streamon, |
463 | .vidioc_streamoff = empress_streamoff, | 356 | .vidioc_streamoff = empress_streamoff, |
464 | .vidioc_s_ext_ctrls = empress_s_ext_ctrls, | ||
465 | .vidioc_g_ext_ctrls = empress_g_ext_ctrls, | ||
466 | .vidioc_enum_input = empress_enum_input, | 357 | .vidioc_enum_input = empress_enum_input, |
467 | .vidioc_g_input = empress_g_input, | 358 | .vidioc_g_input = empress_g_input, |
468 | .vidioc_s_input = empress_s_input, | 359 | .vidioc_s_input = empress_s_input, |
469 | .vidioc_queryctrl = empress_queryctrl, | ||
470 | .vidioc_querymenu = empress_querymenu, | ||
471 | .vidioc_g_ctrl = empress_g_ctrl, | ||
472 | .vidioc_s_ctrl = empress_s_ctrl, | ||
473 | .vidioc_s_std = empress_s_std, | 360 | .vidioc_s_std = empress_s_std, |
474 | .vidioc_g_std = empress_g_std, | 361 | .vidioc_g_std = empress_g_std, |
475 | }; | 362 | }; |
@@ -501,9 +388,26 @@ static void empress_signal_change(struct saa7134_dev *dev) | |||
501 | schedule_work(&dev->empress_workqueue); | 388 | schedule_work(&dev->empress_workqueue); |
502 | } | 389 | } |
503 | 390 | ||
391 | static bool empress_ctrl_filter(const struct v4l2_ctrl *ctrl) | ||
392 | { | ||
393 | switch (ctrl->id) { | ||
394 | case V4L2_CID_BRIGHTNESS: | ||
395 | case V4L2_CID_HUE: | ||
396 | case V4L2_CID_CONTRAST: | ||
397 | case V4L2_CID_SATURATION: | ||
398 | case V4L2_CID_AUDIO_MUTE: | ||
399 | case V4L2_CID_AUDIO_VOLUME: | ||
400 | case V4L2_CID_PRIVATE_INVERT: | ||
401 | case V4L2_CID_PRIVATE_AUTOMUTE: | ||
402 | return true; | ||
403 | default: | ||
404 | return false; | ||
405 | } | ||
406 | } | ||
504 | 407 | ||
505 | static int empress_init(struct saa7134_dev *dev) | 408 | static int empress_init(struct saa7134_dev *dev) |
506 | { | 409 | { |
410 | struct v4l2_ctrl_handler *hdl = &dev->empress_ctrl_handler; | ||
507 | int err; | 411 | int err; |
508 | 412 | ||
509 | dprintk("%s: %s\n",dev->name,__func__); | 413 | dprintk("%s: %s\n",dev->name,__func__); |
@@ -516,6 +420,15 @@ static int empress_init(struct saa7134_dev *dev) | |||
516 | snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name), | 420 | snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name), |
517 | "%s empress (%s)", dev->name, | 421 | "%s empress (%s)", dev->name, |
518 | saa7134_boards[dev->board].name); | 422 | saa7134_boards[dev->board].name); |
423 | v4l2_ctrl_handler_init(hdl, 21); | ||
424 | v4l2_ctrl_add_handler(hdl, &dev->ctrl_handler, empress_ctrl_filter); | ||
425 | if (dev->empress_sd) | ||
426 | v4l2_ctrl_add_handler(hdl, dev->empress_sd->ctrl_handler, NULL); | ||
427 | if (hdl->error) { | ||
428 | video_device_release(dev->empress_dev); | ||
429 | return hdl->error; | ||
430 | } | ||
431 | dev->empress_dev->ctrl_handler = hdl; | ||
519 | 432 | ||
520 | INIT_WORK(&dev->empress_workqueue, empress_signal_update); | 433 | INIT_WORK(&dev->empress_workqueue, empress_signal_update); |
521 | 434 | ||
@@ -551,6 +464,7 @@ static int empress_fini(struct saa7134_dev *dev) | |||
551 | return 0; | 464 | return 0; |
552 | flush_work(&dev->empress_workqueue); | 465 | flush_work(&dev->empress_workqueue); |
553 | video_unregister_device(dev->empress_dev); | 466 | video_unregister_device(dev->empress_dev); |
467 | v4l2_ctrl_handler_free(&dev->empress_ctrl_handler); | ||
554 | dev->empress_dev = NULL; | 468 | dev->empress_dev = NULL; |
555 | return 0; | 469 | return 0; |
556 | } | 470 | } |
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index 8f73058f901e..7a52259b803d 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c | |||
@@ -369,117 +369,6 @@ static struct saa7134_tvnorm tvnorms[] = { | |||
369 | }; | 369 | }; |
370 | #define TVNORMS ARRAY_SIZE(tvnorms) | 370 | #define TVNORMS ARRAY_SIZE(tvnorms) |
371 | 371 | ||
372 | #define V4L2_CID_PRIVATE_INVERT (V4L2_CID_PRIVATE_BASE + 0) | ||
373 | #define V4L2_CID_PRIVATE_Y_ODD (V4L2_CID_PRIVATE_BASE + 1) | ||
374 | #define V4L2_CID_PRIVATE_Y_EVEN (V4L2_CID_PRIVATE_BASE + 2) | ||
375 | #define V4L2_CID_PRIVATE_AUTOMUTE (V4L2_CID_PRIVATE_BASE + 3) | ||
376 | #define V4L2_CID_PRIVATE_LASTP1 (V4L2_CID_PRIVATE_BASE + 4) | ||
377 | |||
378 | static const struct v4l2_queryctrl no_ctrl = { | ||
379 | .name = "42", | ||
380 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
381 | }; | ||
382 | static const struct v4l2_queryctrl video_ctrls[] = { | ||
383 | /* --- video --- */ | ||
384 | { | ||
385 | .id = V4L2_CID_BRIGHTNESS, | ||
386 | .name = "Brightness", | ||
387 | .minimum = 0, | ||
388 | .maximum = 255, | ||
389 | .step = 1, | ||
390 | .default_value = 128, | ||
391 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
392 | },{ | ||
393 | .id = V4L2_CID_CONTRAST, | ||
394 | .name = "Contrast", | ||
395 | .minimum = 0, | ||
396 | .maximum = 127, | ||
397 | .step = 1, | ||
398 | .default_value = 68, | ||
399 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
400 | },{ | ||
401 | .id = V4L2_CID_SATURATION, | ||
402 | .name = "Saturation", | ||
403 | .minimum = 0, | ||
404 | .maximum = 127, | ||
405 | .step = 1, | ||
406 | .default_value = 64, | ||
407 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
408 | },{ | ||
409 | .id = V4L2_CID_HUE, | ||
410 | .name = "Hue", | ||
411 | .minimum = -128, | ||
412 | .maximum = 127, | ||
413 | .step = 1, | ||
414 | .default_value = 0, | ||
415 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
416 | },{ | ||
417 | .id = V4L2_CID_HFLIP, | ||
418 | .name = "Mirror", | ||
419 | .minimum = 0, | ||
420 | .maximum = 1, | ||
421 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
422 | }, | ||
423 | /* --- audio --- */ | ||
424 | { | ||
425 | .id = V4L2_CID_AUDIO_MUTE, | ||
426 | .name = "Mute", | ||
427 | .minimum = 0, | ||
428 | .maximum = 1, | ||
429 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
430 | },{ | ||
431 | .id = V4L2_CID_AUDIO_VOLUME, | ||
432 | .name = "Volume", | ||
433 | .minimum = -15, | ||
434 | .maximum = 15, | ||
435 | .step = 1, | ||
436 | .default_value = 0, | ||
437 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
438 | }, | ||
439 | /* --- private --- */ | ||
440 | { | ||
441 | .id = V4L2_CID_PRIVATE_INVERT, | ||
442 | .name = "Invert", | ||
443 | .minimum = 0, | ||
444 | .maximum = 1, | ||
445 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
446 | },{ | ||
447 | .id = V4L2_CID_PRIVATE_Y_ODD, | ||
448 | .name = "y offset odd field", | ||
449 | .minimum = 0, | ||
450 | .maximum = 128, | ||
451 | .step = 1, | ||
452 | .default_value = 0, | ||
453 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
454 | },{ | ||
455 | .id = V4L2_CID_PRIVATE_Y_EVEN, | ||
456 | .name = "y offset even field", | ||
457 | .minimum = 0, | ||
458 | .maximum = 128, | ||
459 | .step = 1, | ||
460 | .default_value = 0, | ||
461 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
462 | },{ | ||
463 | .id = V4L2_CID_PRIVATE_AUTOMUTE, | ||
464 | .name = "automute", | ||
465 | .minimum = 0, | ||
466 | .maximum = 1, | ||
467 | .default_value = 1, | ||
468 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
469 | } | ||
470 | }; | ||
471 | static const unsigned int CTRLS = ARRAY_SIZE(video_ctrls); | ||
472 | |||
473 | static const struct v4l2_queryctrl* ctrl_by_id(unsigned int id) | ||
474 | { | ||
475 | unsigned int i; | ||
476 | |||
477 | for (i = 0; i < CTRLS; i++) | ||
478 | if (video_ctrls[i].id == id) | ||
479 | return video_ctrls+i; | ||
480 | return NULL; | ||
481 | } | ||
482 | |||
483 | static struct saa7134_format* format_by_fourcc(unsigned int fourcc) | 372 | static struct saa7134_format* format_by_fourcc(unsigned int fourcc) |
484 | { | 373 | { |
485 | unsigned int i; | 374 | unsigned int i; |
@@ -868,7 +757,7 @@ static int verify_preview(struct saa7134_dev *dev, struct v4l2_window *win, bool | |||
868 | return 0; | 757 | return 0; |
869 | } | 758 | } |
870 | 759 | ||
871 | static int start_preview(struct saa7134_dev *dev, struct saa7134_fh *fh) | 760 | static int start_preview(struct saa7134_dev *dev) |
872 | { | 761 | { |
873 | unsigned long base,control,bpl; | 762 | unsigned long base,control,bpl; |
874 | int err; | 763 | int err; |
@@ -923,7 +812,7 @@ static int start_preview(struct saa7134_dev *dev, struct saa7134_fh *fh) | |||
923 | return 0; | 812 | return 0; |
924 | } | 813 | } |
925 | 814 | ||
926 | static int stop_preview(struct saa7134_dev *dev, struct saa7134_fh *fh) | 815 | static int stop_preview(struct saa7134_dev *dev) |
927 | { | 816 | { |
928 | dev->ovenable = 0; | 817 | dev->ovenable = 0; |
929 | saa7134_set_dmabits(dev); | 818 | saa7134_set_dmabits(dev); |
@@ -1114,133 +1003,56 @@ static struct videobuf_queue_ops video_qops = { | |||
1114 | 1003 | ||
1115 | /* ------------------------------------------------------------------ */ | 1004 | /* ------------------------------------------------------------------ */ |
1116 | 1005 | ||
1117 | int saa7134_g_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c) | 1006 | static int saa7134_s_ctrl(struct v4l2_ctrl *ctrl) |
1118 | { | ||
1119 | const struct v4l2_queryctrl* ctrl; | ||
1120 | |||
1121 | ctrl = ctrl_by_id(c->id); | ||
1122 | if (NULL == ctrl) | ||
1123 | return -EINVAL; | ||
1124 | switch (c->id) { | ||
1125 | case V4L2_CID_BRIGHTNESS: | ||
1126 | c->value = dev->ctl_bright; | ||
1127 | break; | ||
1128 | case V4L2_CID_HUE: | ||
1129 | c->value = dev->ctl_hue; | ||
1130 | break; | ||
1131 | case V4L2_CID_CONTRAST: | ||
1132 | c->value = dev->ctl_contrast; | ||
1133 | break; | ||
1134 | case V4L2_CID_SATURATION: | ||
1135 | c->value = dev->ctl_saturation; | ||
1136 | break; | ||
1137 | case V4L2_CID_AUDIO_MUTE: | ||
1138 | c->value = dev->ctl_mute; | ||
1139 | break; | ||
1140 | case V4L2_CID_AUDIO_VOLUME: | ||
1141 | c->value = dev->ctl_volume; | ||
1142 | break; | ||
1143 | case V4L2_CID_PRIVATE_INVERT: | ||
1144 | c->value = dev->ctl_invert; | ||
1145 | break; | ||
1146 | case V4L2_CID_HFLIP: | ||
1147 | c->value = dev->ctl_mirror; | ||
1148 | break; | ||
1149 | case V4L2_CID_PRIVATE_Y_EVEN: | ||
1150 | c->value = dev->ctl_y_even; | ||
1151 | break; | ||
1152 | case V4L2_CID_PRIVATE_Y_ODD: | ||
1153 | c->value = dev->ctl_y_odd; | ||
1154 | break; | ||
1155 | case V4L2_CID_PRIVATE_AUTOMUTE: | ||
1156 | c->value = dev->ctl_automute; | ||
1157 | break; | ||
1158 | default: | ||
1159 | return -EINVAL; | ||
1160 | } | ||
1161 | return 0; | ||
1162 | } | ||
1163 | EXPORT_SYMBOL_GPL(saa7134_g_ctrl_internal); | ||
1164 | |||
1165 | static int saa7134_g_ctrl(struct file *file, void *priv, struct v4l2_control *c) | ||
1166 | { | 1007 | { |
1167 | struct saa7134_fh *fh = priv; | 1008 | struct saa7134_dev *dev = container_of(ctrl->handler, struct saa7134_dev, ctrl_handler); |
1168 | |||
1169 | return saa7134_g_ctrl_internal(fh->dev, fh, c); | ||
1170 | } | ||
1171 | |||
1172 | int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c) | ||
1173 | { | ||
1174 | const struct v4l2_queryctrl* ctrl; | ||
1175 | unsigned long flags; | 1009 | unsigned long flags; |
1176 | int restart_overlay = 0; | 1010 | int restart_overlay = 0; |
1177 | int err; | ||
1178 | |||
1179 | err = -EINVAL; | ||
1180 | 1011 | ||
1181 | mutex_lock(&dev->lock); | 1012 | switch (ctrl->id) { |
1182 | |||
1183 | ctrl = ctrl_by_id(c->id); | ||
1184 | if (NULL == ctrl) | ||
1185 | goto error; | ||
1186 | |||
1187 | dprintk("set_control name=%s val=%d\n",ctrl->name,c->value); | ||
1188 | switch (ctrl->type) { | ||
1189 | case V4L2_CTRL_TYPE_BOOLEAN: | ||
1190 | case V4L2_CTRL_TYPE_MENU: | ||
1191 | case V4L2_CTRL_TYPE_INTEGER: | ||
1192 | if (c->value < ctrl->minimum) | ||
1193 | c->value = ctrl->minimum; | ||
1194 | if (c->value > ctrl->maximum) | ||
1195 | c->value = ctrl->maximum; | ||
1196 | break; | ||
1197 | default: | ||
1198 | /* nothing */; | ||
1199 | } | ||
1200 | switch (c->id) { | ||
1201 | case V4L2_CID_BRIGHTNESS: | 1013 | case V4L2_CID_BRIGHTNESS: |
1202 | dev->ctl_bright = c->value; | 1014 | dev->ctl_bright = ctrl->val; |
1203 | saa_writeb(SAA7134_DEC_LUMA_BRIGHT, dev->ctl_bright); | 1015 | saa_writeb(SAA7134_DEC_LUMA_BRIGHT, ctrl->val); |
1204 | break; | 1016 | break; |
1205 | case V4L2_CID_HUE: | 1017 | case V4L2_CID_HUE: |
1206 | dev->ctl_hue = c->value; | 1018 | dev->ctl_hue = ctrl->val; |
1207 | saa_writeb(SAA7134_DEC_CHROMA_HUE, dev->ctl_hue); | 1019 | saa_writeb(SAA7134_DEC_CHROMA_HUE, ctrl->val); |
1208 | break; | 1020 | break; |
1209 | case V4L2_CID_CONTRAST: | 1021 | case V4L2_CID_CONTRAST: |
1210 | dev->ctl_contrast = c->value; | 1022 | dev->ctl_contrast = ctrl->val; |
1211 | saa_writeb(SAA7134_DEC_LUMA_CONTRAST, | 1023 | saa_writeb(SAA7134_DEC_LUMA_CONTRAST, |
1212 | dev->ctl_invert ? -dev->ctl_contrast : dev->ctl_contrast); | 1024 | dev->ctl_invert ? -dev->ctl_contrast : dev->ctl_contrast); |
1213 | break; | 1025 | break; |
1214 | case V4L2_CID_SATURATION: | 1026 | case V4L2_CID_SATURATION: |
1215 | dev->ctl_saturation = c->value; | 1027 | dev->ctl_saturation = ctrl->val; |
1216 | saa_writeb(SAA7134_DEC_CHROMA_SATURATION, | 1028 | saa_writeb(SAA7134_DEC_CHROMA_SATURATION, |
1217 | dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation); | 1029 | dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation); |
1218 | break; | 1030 | break; |
1219 | case V4L2_CID_AUDIO_MUTE: | 1031 | case V4L2_CID_AUDIO_MUTE: |
1220 | dev->ctl_mute = c->value; | 1032 | dev->ctl_mute = ctrl->val; |
1221 | saa7134_tvaudio_setmute(dev); | 1033 | saa7134_tvaudio_setmute(dev); |
1222 | break; | 1034 | break; |
1223 | case V4L2_CID_AUDIO_VOLUME: | 1035 | case V4L2_CID_AUDIO_VOLUME: |
1224 | dev->ctl_volume = c->value; | 1036 | dev->ctl_volume = ctrl->val; |
1225 | saa7134_tvaudio_setvolume(dev,dev->ctl_volume); | 1037 | saa7134_tvaudio_setvolume(dev,dev->ctl_volume); |
1226 | break; | 1038 | break; |
1227 | case V4L2_CID_PRIVATE_INVERT: | 1039 | case V4L2_CID_PRIVATE_INVERT: |
1228 | dev->ctl_invert = c->value; | 1040 | dev->ctl_invert = ctrl->val; |
1229 | saa_writeb(SAA7134_DEC_LUMA_CONTRAST, | 1041 | saa_writeb(SAA7134_DEC_LUMA_CONTRAST, |
1230 | dev->ctl_invert ? -dev->ctl_contrast : dev->ctl_contrast); | 1042 | dev->ctl_invert ? -dev->ctl_contrast : dev->ctl_contrast); |
1231 | saa_writeb(SAA7134_DEC_CHROMA_SATURATION, | 1043 | saa_writeb(SAA7134_DEC_CHROMA_SATURATION, |
1232 | dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation); | 1044 | dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation); |
1233 | break; | 1045 | break; |
1234 | case V4L2_CID_HFLIP: | 1046 | case V4L2_CID_HFLIP: |
1235 | dev->ctl_mirror = c->value; | 1047 | dev->ctl_mirror = ctrl->val; |
1236 | restart_overlay = 1; | 1048 | restart_overlay = 1; |
1237 | break; | 1049 | break; |
1238 | case V4L2_CID_PRIVATE_Y_EVEN: | 1050 | case V4L2_CID_PRIVATE_Y_EVEN: |
1239 | dev->ctl_y_even = c->value; | 1051 | dev->ctl_y_even = ctrl->val; |
1240 | restart_overlay = 1; | 1052 | restart_overlay = 1; |
1241 | break; | 1053 | break; |
1242 | case V4L2_CID_PRIVATE_Y_ODD: | 1054 | case V4L2_CID_PRIVATE_Y_ODD: |
1243 | dev->ctl_y_odd = c->value; | 1055 | dev->ctl_y_odd = ctrl->val; |
1244 | restart_overlay = 1; | 1056 | restart_overlay = 1; |
1245 | break; | 1057 | break; |
1246 | case V4L2_CID_PRIVATE_AUTOMUTE: | 1058 | case V4L2_CID_PRIVATE_AUTOMUTE: |
@@ -1250,7 +1062,7 @@ int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, str | |||
1250 | tda9887_cfg.tuner = TUNER_TDA9887; | 1062 | tda9887_cfg.tuner = TUNER_TDA9887; |
1251 | tda9887_cfg.priv = &dev->tda9887_conf; | 1063 | tda9887_cfg.priv = &dev->tda9887_conf; |
1252 | 1064 | ||
1253 | dev->ctl_automute = c->value; | 1065 | dev->ctl_automute = ctrl->val; |
1254 | if (dev->tda9887_conf) { | 1066 | if (dev->tda9887_conf) { |
1255 | if (dev->ctl_automute) | 1067 | if (dev->ctl_automute) |
1256 | dev->tda9887_conf |= TDA9887_AUTOMUTE; | 1068 | dev->tda9887_conf |= TDA9887_AUTOMUTE; |
@@ -1262,27 +1074,15 @@ int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, str | |||
1262 | break; | 1074 | break; |
1263 | } | 1075 | } |
1264 | default: | 1076 | default: |
1265 | goto error; | 1077 | return -EINVAL; |
1266 | } | 1078 | } |
1267 | if (restart_overlay && fh && res_check(fh, RESOURCE_OVERLAY)) { | 1079 | if (restart_overlay && res_locked(dev, RESOURCE_OVERLAY)) { |
1268 | spin_lock_irqsave(&dev->slock,flags); | 1080 | spin_lock_irqsave(&dev->slock, flags); |
1269 | stop_preview(dev,fh); | 1081 | stop_preview(dev); |
1270 | start_preview(dev,fh); | 1082 | start_preview(dev); |
1271 | spin_unlock_irqrestore(&dev->slock,flags); | 1083 | spin_unlock_irqrestore(&dev->slock, flags); |
1272 | } | 1084 | } |
1273 | err = 0; | 1085 | return 0; |
1274 | |||
1275 | error: | ||
1276 | mutex_unlock(&dev->lock); | ||
1277 | return err; | ||
1278 | } | ||
1279 | EXPORT_SYMBOL_GPL(saa7134_s_ctrl_internal); | ||
1280 | |||
1281 | static int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c) | ||
1282 | { | ||
1283 | struct saa7134_fh *fh = f; | ||
1284 | |||
1285 | return saa7134_s_ctrl_internal(fh->dev, fh, c); | ||
1286 | } | 1086 | } |
1287 | 1087 | ||
1288 | /* ------------------------------------------------------------------ */ | 1088 | /* ------------------------------------------------------------------ */ |
@@ -1434,7 +1234,7 @@ static int video_release(struct file *file) | |||
1434 | /* turn off overlay */ | 1234 | /* turn off overlay */ |
1435 | if (res_check(fh, RESOURCE_OVERLAY)) { | 1235 | if (res_check(fh, RESOURCE_OVERLAY)) { |
1436 | spin_lock_irqsave(&dev->slock,flags); | 1236 | spin_lock_irqsave(&dev->slock,flags); |
1437 | stop_preview(dev,fh); | 1237 | stop_preview(dev); |
1438 | spin_unlock_irqrestore(&dev->slock,flags); | 1238 | spin_unlock_irqrestore(&dev->slock,flags); |
1439 | res_free(dev,fh,RESOURCE_OVERLAY); | 1239 | res_free(dev,fh,RESOURCE_OVERLAY); |
1440 | } | 1240 | } |
@@ -1703,8 +1503,8 @@ static int saa7134_s_fmt_vid_overlay(struct file *file, void *priv, | |||
1703 | 1503 | ||
1704 | if (res_check(fh, RESOURCE_OVERLAY)) { | 1504 | if (res_check(fh, RESOURCE_OVERLAY)) { |
1705 | spin_lock_irqsave(&dev->slock, flags); | 1505 | spin_lock_irqsave(&dev->slock, flags); |
1706 | stop_preview(dev, fh); | 1506 | stop_preview(dev); |
1707 | start_preview(dev, fh); | 1507 | start_preview(dev); |
1708 | spin_unlock_irqrestore(&dev->slock, flags); | 1508 | spin_unlock_irqrestore(&dev->slock, flags); |
1709 | } | 1509 | } |
1710 | 1510 | ||
@@ -1712,21 +1512,6 @@ static int saa7134_s_fmt_vid_overlay(struct file *file, void *priv, | |||
1712 | return 0; | 1512 | return 0; |
1713 | } | 1513 | } |
1714 | 1514 | ||
1715 | int saa7134_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c) | ||
1716 | { | ||
1717 | const struct v4l2_queryctrl *ctrl; | ||
1718 | |||
1719 | if ((c->id < V4L2_CID_BASE || | ||
1720 | c->id >= V4L2_CID_LASTP1) && | ||
1721 | (c->id < V4L2_CID_PRIVATE_BASE || | ||
1722 | c->id >= V4L2_CID_PRIVATE_LASTP1)) | ||
1723 | return -EINVAL; | ||
1724 | ctrl = ctrl_by_id(c->id); | ||
1725 | *c = (NULL != ctrl) ? *ctrl : no_ctrl; | ||
1726 | return 0; | ||
1727 | } | ||
1728 | EXPORT_SYMBOL_GPL(saa7134_queryctrl); | ||
1729 | |||
1730 | static int saa7134_enum_input(struct file *file, void *priv, | 1515 | static int saa7134_enum_input(struct file *file, void *priv, |
1731 | struct v4l2_input *i) | 1516 | struct v4l2_input *i) |
1732 | { | 1517 | { |
@@ -1882,13 +1667,13 @@ int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_ | |||
1882 | mutex_lock(&dev->lock); | 1667 | mutex_lock(&dev->lock); |
1883 | if (fh && res_check(fh, RESOURCE_OVERLAY)) { | 1668 | if (fh && res_check(fh, RESOURCE_OVERLAY)) { |
1884 | spin_lock_irqsave(&dev->slock, flags); | 1669 | spin_lock_irqsave(&dev->slock, flags); |
1885 | stop_preview(dev, fh); | 1670 | stop_preview(dev); |
1886 | spin_unlock_irqrestore(&dev->slock, flags); | 1671 | spin_unlock_irqrestore(&dev->slock, flags); |
1887 | 1672 | ||
1888 | set_tvnorm(dev, &tvnorms[i]); | 1673 | set_tvnorm(dev, &tvnorms[i]); |
1889 | 1674 | ||
1890 | spin_lock_irqsave(&dev->slock, flags); | 1675 | spin_lock_irqsave(&dev->slock, flags); |
1891 | start_preview(dev, fh); | 1676 | start_preview(dev); |
1892 | spin_unlock_irqrestore(&dev->slock, flags); | 1677 | spin_unlock_irqrestore(&dev->slock, flags); |
1893 | } else | 1678 | } else |
1894 | set_tvnorm(dev, &tvnorms[i]); | 1679 | set_tvnorm(dev, &tvnorms[i]); |
@@ -2157,14 +1942,14 @@ static int saa7134_overlay(struct file *file, void *f, unsigned int on) | |||
2157 | if (!res_get(dev, fh, RESOURCE_OVERLAY)) | 1942 | if (!res_get(dev, fh, RESOURCE_OVERLAY)) |
2158 | return -EBUSY; | 1943 | return -EBUSY; |
2159 | spin_lock_irqsave(&dev->slock, flags); | 1944 | spin_lock_irqsave(&dev->slock, flags); |
2160 | start_preview(dev, fh); | 1945 | start_preview(dev); |
2161 | spin_unlock_irqrestore(&dev->slock, flags); | 1946 | spin_unlock_irqrestore(&dev->slock, flags); |
2162 | } | 1947 | } |
2163 | if (!on) { | 1948 | if (!on) { |
2164 | if (!res_check(fh, RESOURCE_OVERLAY)) | 1949 | if (!res_check(fh, RESOURCE_OVERLAY)) |
2165 | return -EINVAL; | 1950 | return -EINVAL; |
2166 | spin_lock_irqsave(&dev->slock, flags); | 1951 | spin_lock_irqsave(&dev->slock, flags); |
2167 | stop_preview(dev, fh); | 1952 | stop_preview(dev); |
2168 | spin_unlock_irqrestore(&dev->slock, flags); | 1953 | spin_unlock_irqrestore(&dev->slock, flags); |
2169 | res_free(dev, fh, RESOURCE_OVERLAY); | 1954 | res_free(dev, fh, RESOURCE_OVERLAY); |
2170 | } | 1955 | } |
@@ -2319,22 +2104,6 @@ static int radio_s_std(struct file *file, void *fh, v4l2_std_id norm) | |||
2319 | return 0; | 2104 | return 0; |
2320 | } | 2105 | } |
2321 | 2106 | ||
2322 | static int radio_queryctrl(struct file *file, void *priv, | ||
2323 | struct v4l2_queryctrl *c) | ||
2324 | { | ||
2325 | const struct v4l2_queryctrl *ctrl; | ||
2326 | |||
2327 | if (c->id < V4L2_CID_BASE || | ||
2328 | c->id >= V4L2_CID_LASTP1) | ||
2329 | return -EINVAL; | ||
2330 | if (c->id == V4L2_CID_AUDIO_MUTE) { | ||
2331 | ctrl = ctrl_by_id(c->id); | ||
2332 | *c = *ctrl; | ||
2333 | } else | ||
2334 | *c = no_ctrl; | ||
2335 | return 0; | ||
2336 | } | ||
2337 | |||
2338 | static const struct v4l2_file_operations video_fops = | 2107 | static const struct v4l2_file_operations video_fops = |
2339 | { | 2108 | { |
2340 | .owner = THIS_MODULE, | 2109 | .owner = THIS_MODULE, |
@@ -2369,9 +2138,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
2369 | .vidioc_enum_input = saa7134_enum_input, | 2138 | .vidioc_enum_input = saa7134_enum_input, |
2370 | .vidioc_g_input = saa7134_g_input, | 2139 | .vidioc_g_input = saa7134_g_input, |
2371 | .vidioc_s_input = saa7134_s_input, | 2140 | .vidioc_s_input = saa7134_s_input, |
2372 | .vidioc_queryctrl = saa7134_queryctrl, | ||
2373 | .vidioc_g_ctrl = saa7134_g_ctrl, | ||
2374 | .vidioc_s_ctrl = saa7134_s_ctrl, | ||
2375 | .vidioc_streamon = saa7134_streamon, | 2141 | .vidioc_streamon = saa7134_streamon, |
2376 | .vidioc_streamoff = saa7134_streamoff, | 2142 | .vidioc_streamoff = saa7134_streamoff, |
2377 | .vidioc_g_tuner = saa7134_g_tuner, | 2143 | .vidioc_g_tuner = saa7134_g_tuner, |
@@ -2405,10 +2171,7 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = { | |||
2405 | .vidioc_s_tuner = radio_s_tuner, | 2171 | .vidioc_s_tuner = radio_s_tuner, |
2406 | .vidioc_s_input = radio_s_input, | 2172 | .vidioc_s_input = radio_s_input, |
2407 | .vidioc_s_std = radio_s_std, | 2173 | .vidioc_s_std = radio_s_std, |
2408 | .vidioc_queryctrl = radio_queryctrl, | ||
2409 | .vidioc_g_input = radio_g_input, | 2174 | .vidioc_g_input = radio_g_input, |
2410 | .vidioc_g_ctrl = saa7134_g_ctrl, | ||
2411 | .vidioc_s_ctrl = saa7134_s_ctrl, | ||
2412 | .vidioc_g_frequency = saa7134_g_frequency, | 2175 | .vidioc_g_frequency = saa7134_g_frequency, |
2413 | .vidioc_s_frequency = saa7134_s_frequency, | 2176 | .vidioc_s_frequency = saa7134_s_frequency, |
2414 | }; | 2177 | }; |
@@ -2429,8 +2192,55 @@ struct video_device saa7134_radio_template = { | |||
2429 | .ioctl_ops = &radio_ioctl_ops, | 2192 | .ioctl_ops = &radio_ioctl_ops, |
2430 | }; | 2193 | }; |
2431 | 2194 | ||
2195 | static const struct v4l2_ctrl_ops saa7134_ctrl_ops = { | ||
2196 | .s_ctrl = saa7134_s_ctrl, | ||
2197 | }; | ||
2198 | |||
2199 | static const struct v4l2_ctrl_config saa7134_ctrl_invert = { | ||
2200 | .ops = &saa7134_ctrl_ops, | ||
2201 | .id = V4L2_CID_PRIVATE_INVERT, | ||
2202 | .name = "Invert", | ||
2203 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
2204 | .min = 0, | ||
2205 | .max = 1, | ||
2206 | .step = 1, | ||
2207 | }; | ||
2208 | |||
2209 | static const struct v4l2_ctrl_config saa7134_ctrl_y_odd = { | ||
2210 | .ops = &saa7134_ctrl_ops, | ||
2211 | .id = V4L2_CID_PRIVATE_Y_ODD, | ||
2212 | .name = "Y Offset Odd Field", | ||
2213 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
2214 | .min = 0, | ||
2215 | .max = 128, | ||
2216 | .step = 1, | ||
2217 | }; | ||
2218 | |||
2219 | static const struct v4l2_ctrl_config saa7134_ctrl_y_even = { | ||
2220 | .ops = &saa7134_ctrl_ops, | ||
2221 | .id = V4L2_CID_PRIVATE_Y_EVEN, | ||
2222 | .name = "Y Offset Even Field", | ||
2223 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
2224 | .min = 0, | ||
2225 | .max = 128, | ||
2226 | .step = 1, | ||
2227 | }; | ||
2228 | |||
2229 | static const struct v4l2_ctrl_config saa7134_ctrl_automute = { | ||
2230 | .ops = &saa7134_ctrl_ops, | ||
2231 | .id = V4L2_CID_PRIVATE_AUTOMUTE, | ||
2232 | .name = "Automute", | ||
2233 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
2234 | .min = 0, | ||
2235 | .max = 1, | ||
2236 | .step = 1, | ||
2237 | .def = 1, | ||
2238 | }; | ||
2239 | |||
2432 | int saa7134_video_init1(struct saa7134_dev *dev) | 2240 | int saa7134_video_init1(struct saa7134_dev *dev) |
2433 | { | 2241 | { |
2242 | struct v4l2_ctrl_handler *hdl = &dev->ctrl_handler; | ||
2243 | |||
2434 | /* sanitycheck insmod options */ | 2244 | /* sanitycheck insmod options */ |
2435 | if (gbuffers < 2 || gbuffers > VIDEO_MAX_FRAME) | 2245 | if (gbuffers < 2 || gbuffers > VIDEO_MAX_FRAME) |
2436 | gbuffers = 2; | 2246 | gbuffers = 2; |
@@ -2438,17 +2248,38 @@ int saa7134_video_init1(struct saa7134_dev *dev) | |||
2438 | gbufsize = gbufsize_max; | 2248 | gbufsize = gbufsize_max; |
2439 | gbufsize = (gbufsize + PAGE_SIZE - 1) & PAGE_MASK; | 2249 | gbufsize = (gbufsize + PAGE_SIZE - 1) & PAGE_MASK; |
2440 | 2250 | ||
2441 | /* put some sensible defaults into the data structures ... */ | 2251 | v4l2_ctrl_handler_init(hdl, 11); |
2442 | dev->ctl_bright = ctrl_by_id(V4L2_CID_BRIGHTNESS)->default_value; | 2252 | v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops, |
2443 | dev->ctl_contrast = ctrl_by_id(V4L2_CID_CONTRAST)->default_value; | 2253 | V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); |
2444 | dev->ctl_hue = ctrl_by_id(V4L2_CID_HUE)->default_value; | 2254 | v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops, |
2445 | dev->ctl_saturation = ctrl_by_id(V4L2_CID_SATURATION)->default_value; | 2255 | V4L2_CID_CONTRAST, 0, 127, 1, 68); |
2446 | dev->ctl_volume = ctrl_by_id(V4L2_CID_AUDIO_VOLUME)->default_value; | 2256 | v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops, |
2447 | dev->ctl_mute = 1; // ctrl_by_id(V4L2_CID_AUDIO_MUTE)->default_value; | 2257 | V4L2_CID_SATURATION, 0, 127, 1, 64); |
2448 | dev->ctl_invert = ctrl_by_id(V4L2_CID_PRIVATE_INVERT)->default_value; | 2258 | v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops, |
2449 | dev->ctl_automute = ctrl_by_id(V4L2_CID_PRIVATE_AUTOMUTE)->default_value; | 2259 | V4L2_CID_HUE, -128, 127, 1, 0); |
2450 | 2260 | v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops, | |
2451 | if (dev->tda9887_conf && dev->ctl_automute) | 2261 | V4L2_CID_HFLIP, 0, 1, 1, 0); |
2262 | v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops, | ||
2263 | V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0); | ||
2264 | v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops, | ||
2265 | V4L2_CID_AUDIO_VOLUME, -15, 15, 1, 0); | ||
2266 | v4l2_ctrl_new_custom(hdl, &saa7134_ctrl_invert, NULL); | ||
2267 | v4l2_ctrl_new_custom(hdl, &saa7134_ctrl_y_odd, NULL); | ||
2268 | v4l2_ctrl_new_custom(hdl, &saa7134_ctrl_y_even, NULL); | ||
2269 | v4l2_ctrl_new_custom(hdl, &saa7134_ctrl_automute, NULL); | ||
2270 | if (hdl->error) | ||
2271 | return hdl->error; | ||
2272 | if (card_has_radio(dev)) { | ||
2273 | hdl = &dev->radio_ctrl_handler; | ||
2274 | v4l2_ctrl_handler_init(hdl, 2); | ||
2275 | v4l2_ctrl_add_handler(hdl, &dev->ctrl_handler, | ||
2276 | v4l2_ctrl_radio_filter); | ||
2277 | if (hdl->error) | ||
2278 | return hdl->error; | ||
2279 | } | ||
2280 | dev->ctl_mute = 1; | ||
2281 | |||
2282 | if (dev->tda9887_conf && saa7134_ctrl_automute.def) | ||
2452 | dev->tda9887_conf |= TDA9887_AUTOMUTE; | 2283 | dev->tda9887_conf |= TDA9887_AUTOMUTE; |
2453 | dev->automute = 0; | 2284 | dev->automute = 0; |
2454 | 2285 | ||
@@ -2494,6 +2325,9 @@ void saa7134_video_fini(struct saa7134_dev *dev) | |||
2494 | /* free stuff */ | 2325 | /* free stuff */ |
2495 | saa7134_pgtable_free(dev->pci, &dev->pt_cap); | 2326 | saa7134_pgtable_free(dev->pci, &dev->pt_cap); |
2496 | saa7134_pgtable_free(dev->pci, &dev->pt_vbi); | 2327 | saa7134_pgtable_free(dev->pci, &dev->pt_vbi); |
2328 | v4l2_ctrl_handler_free(&dev->ctrl_handler); | ||
2329 | if (card_has_radio(dev)) | ||
2330 | v4l2_ctrl_handler_free(&dev->radio_ctrl_handler); | ||
2497 | } | 2331 | } |
2498 | 2332 | ||
2499 | int saa7134_videoport_init(struct saa7134_dev *dev) | 2333 | int saa7134_videoport_init(struct saa7134_dev *dev) |
@@ -2537,6 +2371,7 @@ int saa7134_video_init2(struct saa7134_dev *dev) | |||
2537 | /* init video hw */ | 2371 | /* init video hw */ |
2538 | set_tvnorm(dev,&tvnorms[0]); | 2372 | set_tvnorm(dev,&tvnorms[0]); |
2539 | video_mux(dev,0); | 2373 | video_mux(dev,0); |
2374 | v4l2_ctrl_handler_setup(&dev->ctrl_handler); | ||
2540 | saa7134_tvaudio_setmute(dev); | 2375 | saa7134_tvaudio_setmute(dev); |
2541 | saa7134_tvaudio_setvolume(dev,dev->ctl_volume); | 2376 | saa7134_tvaudio_setvolume(dev,dev->ctl_volume); |
2542 | return 0; | 2377 | return 0; |
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h index 96b7ccf9a384..e0e5c70fb660 100644 --- a/drivers/media/pci/saa7134/saa7134.h +++ b/drivers/media/pci/saa7134/saa7134.h | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <media/v4l2-ioctl.h> | 37 | #include <media/v4l2-ioctl.h> |
38 | #include <media/v4l2-device.h> | 38 | #include <media/v4l2-device.h> |
39 | #include <media/v4l2-fh.h> | 39 | #include <media/v4l2-fh.h> |
40 | #include <media/v4l2-ctrls.h> | ||
40 | #include <media/tuner.h> | 41 | #include <media/tuner.h> |
41 | #include <media/rc-core.h> | 42 | #include <media/rc-core.h> |
42 | #include <media/ir-kbd-i2c.h> | 43 | #include <media/ir-kbd-i2c.h> |
@@ -410,6 +411,11 @@ struct saa7134_board { | |||
410 | #define card(dev) (saa7134_boards[dev->board]) | 411 | #define card(dev) (saa7134_boards[dev->board]) |
411 | #define card_in(dev,n) (saa7134_boards[dev->board].inputs[n]) | 412 | #define card_in(dev,n) (saa7134_boards[dev->board].inputs[n]) |
412 | 413 | ||
414 | #define V4L2_CID_PRIVATE_INVERT (V4L2_CID_USER_SAA7134_BASE + 0) | ||
415 | #define V4L2_CID_PRIVATE_Y_ODD (V4L2_CID_USER_SAA7134_BASE + 1) | ||
416 | #define V4L2_CID_PRIVATE_Y_EVEN (V4L2_CID_USER_SAA7134_BASE + 2) | ||
417 | #define V4L2_CID_PRIVATE_AUTOMUTE (V4L2_CID_USER_SAA7134_BASE + 3) | ||
418 | |||
413 | /* ----------------------------------------------------------- */ | 419 | /* ----------------------------------------------------------- */ |
414 | /* device / file handle status */ | 420 | /* device / file handle status */ |
415 | 421 | ||
@@ -595,6 +601,7 @@ struct saa7134_dev { | |||
595 | /* various v4l controls */ | 601 | /* various v4l controls */ |
596 | struct saa7134_tvnorm *tvnorm; /* video */ | 602 | struct saa7134_tvnorm *tvnorm; /* video */ |
597 | struct saa7134_tvaudio *tvaudio; | 603 | struct saa7134_tvaudio *tvaudio; |
604 | struct v4l2_ctrl_handler ctrl_handler; | ||
598 | unsigned int ctl_input; | 605 | unsigned int ctl_input; |
599 | int ctl_bright; | 606 | int ctl_bright; |
600 | int ctl_contrast; | 607 | int ctl_contrast; |
@@ -622,6 +629,7 @@ struct saa7134_dev { | |||
622 | int last_carrier; | 629 | int last_carrier; |
623 | int nosignal; | 630 | int nosignal; |
624 | unsigned int insuspend; | 631 | unsigned int insuspend; |
632 | struct v4l2_ctrl_handler radio_ctrl_handler; | ||
625 | 633 | ||
626 | /* I2C keyboard data */ | 634 | /* I2C keyboard data */ |
627 | struct IR_i2c_init_data init_data; | 635 | struct IR_i2c_init_data init_data; |
@@ -634,10 +642,12 @@ struct saa7134_dev { | |||
634 | 642 | ||
635 | /* SAA7134_MPEG_EMPRESS only */ | 643 | /* SAA7134_MPEG_EMPRESS only */ |
636 | struct video_device *empress_dev; | 644 | struct video_device *empress_dev; |
645 | struct v4l2_subdev *empress_sd; | ||
637 | struct videobuf_queue empress_tsq; | 646 | struct videobuf_queue empress_tsq; |
638 | atomic_t empress_users; | 647 | atomic_t empress_users; |
639 | struct work_struct empress_workqueue; | 648 | struct work_struct empress_workqueue; |
640 | int empress_started; | 649 | int empress_started; |
650 | struct v4l2_ctrl_handler empress_ctrl_handler; | ||
641 | 651 | ||
642 | #if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB) | 652 | #if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB) |
643 | /* SAA7134_MPEG_DVB only */ | 653 | /* SAA7134_MPEG_DVB only */ |
@@ -757,9 +767,6 @@ extern unsigned int video_debug; | |||
757 | extern struct video_device saa7134_video_template; | 767 | extern struct video_device saa7134_video_template; |
758 | extern struct video_device saa7134_radio_template; | 768 | extern struct video_device saa7134_radio_template; |
759 | 769 | ||
760 | int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c); | ||
761 | int saa7134_g_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, struct v4l2_control *c); | ||
762 | int saa7134_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *c); | ||
763 | int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_std_id id); | 770 | int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_std_id id); |
764 | 771 | ||
765 | int saa7134_videoport_init(struct saa7134_dev *dev); | 772 | int saa7134_videoport_init(struct saa7134_dev *dev); |
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 1666aabbbb86..8e4d1d974eda 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h | |||
@@ -164,6 +164,10 @@ enum v4l2_colorfx { | |||
164 | * this driver */ | 164 | * this driver */ |
165 | #define V4L2_CID_USER_TI_VPE_BASE (V4L2_CID_USER_BASE + 0x1050) | 165 | #define V4L2_CID_USER_TI_VPE_BASE (V4L2_CID_USER_BASE + 0x1050) |
166 | 166 | ||
167 | /* The base for the saa7134 driver controls. | ||
168 | * We reserve 16 controls for this driver. */ | ||
169 | #define V4L2_CID_USER_SAA7134_BASE (V4L2_CID_USER_BASE + 0x1060) | ||
170 | |||
167 | /* MPEG-class control IDs */ | 171 | /* MPEG-class control IDs */ |
168 | /* The MPEG controls are applicable to all codec controls | 172 | /* The MPEG controls are applicable to all codec controls |
169 | * and the 'MPEG' part of the define is historical */ | 173 | * and the 'MPEG' part of the define is historical */ |