diff options
Diffstat (limited to 'drivers/media/video/w9966.c')
-rw-r--r-- | drivers/media/video/w9966.c | 94 |
1 files changed, 41 insertions, 53 deletions
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c index 7fd7ac567e1a..db2a6003a1c3 100644 --- a/drivers/media/video/w9966.c +++ b/drivers/media/video/w9966.c | |||
@@ -62,6 +62,9 @@ | |||
62 | #include <media/v4l2-common.h> | 62 | #include <media/v4l2-common.h> |
63 | #include <media/v4l2-ioctl.h> | 63 | #include <media/v4l2-ioctl.h> |
64 | #include <media/v4l2-device.h> | 64 | #include <media/v4l2-device.h> |
65 | #include <media/v4l2-fh.h> | ||
66 | #include <media/v4l2-ctrls.h> | ||
67 | #include <media/v4l2-event.h> | ||
65 | #include <linux/parport.h> | 68 | #include <linux/parport.h> |
66 | 69 | ||
67 | /*#define DEBUG*/ /* Undef me for production */ | 70 | /*#define DEBUG*/ /* Undef me for production */ |
@@ -104,6 +107,7 @@ | |||
104 | 107 | ||
105 | struct w9966 { | 108 | struct w9966 { |
106 | struct v4l2_device v4l2_dev; | 109 | struct v4l2_device v4l2_dev; |
110 | struct v4l2_ctrl_handler hdl; | ||
107 | unsigned char dev_state; | 111 | unsigned char dev_state; |
108 | unsigned char i2c_state; | 112 | unsigned char i2c_state; |
109 | unsigned short ppmode; | 113 | unsigned short ppmode; |
@@ -567,7 +571,8 @@ static int cam_querycap(struct file *file, void *priv, | |||
567 | strlcpy(vcap->driver, cam->v4l2_dev.name, sizeof(vcap->driver)); | 571 | strlcpy(vcap->driver, cam->v4l2_dev.name, sizeof(vcap->driver)); |
568 | strlcpy(vcap->card, W9966_DRIVERNAME, sizeof(vcap->card)); | 572 | strlcpy(vcap->card, W9966_DRIVERNAME, sizeof(vcap->card)); |
569 | strlcpy(vcap->bus_info, "parport", sizeof(vcap->bus_info)); | 573 | strlcpy(vcap->bus_info, "parport", sizeof(vcap->bus_info)); |
570 | vcap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE; | 574 | vcap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE; |
575 | vcap->capabilities = vcap->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
571 | return 0; | 576 | return 0; |
572 | } | 577 | } |
573 | 578 | ||
@@ -595,67 +600,25 @@ static int cam_s_input(struct file *file, void *fh, unsigned int inp) | |||
595 | return (inp > 0) ? -EINVAL : 0; | 600 | return (inp > 0) ? -EINVAL : 0; |
596 | } | 601 | } |
597 | 602 | ||
598 | static int cam_queryctrl(struct file *file, void *priv, | 603 | static int cam_s_ctrl(struct v4l2_ctrl *ctrl) |
599 | struct v4l2_queryctrl *qc) | ||
600 | { | 604 | { |
601 | switch (qc->id) { | 605 | struct w9966 *cam = |
602 | case V4L2_CID_BRIGHTNESS: | 606 | container_of(ctrl->handler, struct w9966, hdl); |
603 | return v4l2_ctrl_query_fill(qc, 0, 255, 1, 128); | ||
604 | case V4L2_CID_CONTRAST: | ||
605 | return v4l2_ctrl_query_fill(qc, -64, 64, 1, 64); | ||
606 | case V4L2_CID_SATURATION: | ||
607 | return v4l2_ctrl_query_fill(qc, -64, 64, 1, 64); | ||
608 | case V4L2_CID_HUE: | ||
609 | return v4l2_ctrl_query_fill(qc, -128, 127, 1, 0); | ||
610 | } | ||
611 | return -EINVAL; | ||
612 | } | ||
613 | |||
614 | static int cam_g_ctrl(struct file *file, void *priv, | ||
615 | struct v4l2_control *ctrl) | ||
616 | { | ||
617 | struct w9966 *cam = video_drvdata(file); | ||
618 | int ret = 0; | ||
619 | |||
620 | switch (ctrl->id) { | ||
621 | case V4L2_CID_BRIGHTNESS: | ||
622 | ctrl->value = cam->brightness; | ||
623 | break; | ||
624 | case V4L2_CID_CONTRAST: | ||
625 | ctrl->value = cam->contrast; | ||
626 | break; | ||
627 | case V4L2_CID_SATURATION: | ||
628 | ctrl->value = cam->color; | ||
629 | break; | ||
630 | case V4L2_CID_HUE: | ||
631 | ctrl->value = cam->hue; | ||
632 | break; | ||
633 | default: | ||
634 | ret = -EINVAL; | ||
635 | break; | ||
636 | } | ||
637 | return ret; | ||
638 | } | ||
639 | |||
640 | static int cam_s_ctrl(struct file *file, void *priv, | ||
641 | struct v4l2_control *ctrl) | ||
642 | { | ||
643 | struct w9966 *cam = video_drvdata(file); | ||
644 | int ret = 0; | 607 | int ret = 0; |
645 | 608 | ||
646 | mutex_lock(&cam->lock); | 609 | mutex_lock(&cam->lock); |
647 | switch (ctrl->id) { | 610 | switch (ctrl->id) { |
648 | case V4L2_CID_BRIGHTNESS: | 611 | case V4L2_CID_BRIGHTNESS: |
649 | cam->brightness = ctrl->value; | 612 | cam->brightness = ctrl->val; |
650 | break; | 613 | break; |
651 | case V4L2_CID_CONTRAST: | 614 | case V4L2_CID_CONTRAST: |
652 | cam->contrast = ctrl->value; | 615 | cam->contrast = ctrl->val; |
653 | break; | 616 | break; |
654 | case V4L2_CID_SATURATION: | 617 | case V4L2_CID_SATURATION: |
655 | cam->color = ctrl->value; | 618 | cam->color = ctrl->val; |
656 | break; | 619 | break; |
657 | case V4L2_CID_HUE: | 620 | case V4L2_CID_HUE: |
658 | cam->hue = ctrl->value; | 621 | cam->hue = ctrl->val; |
659 | break; | 622 | break; |
660 | default: | 623 | default: |
661 | ret = -EINVAL; | 624 | ret = -EINVAL; |
@@ -813,6 +776,9 @@ out: | |||
813 | 776 | ||
814 | static const struct v4l2_file_operations w9966_fops = { | 777 | static const struct v4l2_file_operations w9966_fops = { |
815 | .owner = THIS_MODULE, | 778 | .owner = THIS_MODULE, |
779 | .open = v4l2_fh_open, | ||
780 | .release = v4l2_fh_release, | ||
781 | .poll = v4l2_ctrl_poll, | ||
816 | .unlocked_ioctl = video_ioctl2, | 782 | .unlocked_ioctl = video_ioctl2, |
817 | .read = w9966_v4l_read, | 783 | .read = w9966_v4l_read, |
818 | }; | 784 | }; |
@@ -822,13 +788,17 @@ static const struct v4l2_ioctl_ops w9966_ioctl_ops = { | |||
822 | .vidioc_g_input = cam_g_input, | 788 | .vidioc_g_input = cam_g_input, |
823 | .vidioc_s_input = cam_s_input, | 789 | .vidioc_s_input = cam_s_input, |
824 | .vidioc_enum_input = cam_enum_input, | 790 | .vidioc_enum_input = cam_enum_input, |
825 | .vidioc_queryctrl = cam_queryctrl, | ||
826 | .vidioc_g_ctrl = cam_g_ctrl, | ||
827 | .vidioc_s_ctrl = cam_s_ctrl, | ||
828 | .vidioc_enum_fmt_vid_cap = cam_enum_fmt_vid_cap, | 791 | .vidioc_enum_fmt_vid_cap = cam_enum_fmt_vid_cap, |
829 | .vidioc_g_fmt_vid_cap = cam_g_fmt_vid_cap, | 792 | .vidioc_g_fmt_vid_cap = cam_g_fmt_vid_cap, |
830 | .vidioc_s_fmt_vid_cap = cam_s_fmt_vid_cap, | 793 | .vidioc_s_fmt_vid_cap = cam_s_fmt_vid_cap, |
831 | .vidioc_try_fmt_vid_cap = cam_try_fmt_vid_cap, | 794 | .vidioc_try_fmt_vid_cap = cam_try_fmt_vid_cap, |
795 | .vidioc_log_status = v4l2_ctrl_log_status, | ||
796 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | ||
797 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
798 | }; | ||
799 | |||
800 | static const struct v4l2_ctrl_ops cam_ctrl_ops = { | ||
801 | .s_ctrl = cam_s_ctrl, | ||
832 | }; | 802 | }; |
833 | 803 | ||
834 | 804 | ||
@@ -849,6 +819,20 @@ static int w9966_init(struct w9966 *cam, struct parport *port) | |||
849 | v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); | 819 | v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); |
850 | return -1; | 820 | return -1; |
851 | } | 821 | } |
822 | |||
823 | v4l2_ctrl_handler_init(&cam->hdl, 4); | ||
824 | v4l2_ctrl_new_std(&cam->hdl, &cam_ctrl_ops, | ||
825 | V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); | ||
826 | v4l2_ctrl_new_std(&cam->hdl, &cam_ctrl_ops, | ||
827 | V4L2_CID_CONTRAST, -64, 64, 1, 64); | ||
828 | v4l2_ctrl_new_std(&cam->hdl, &cam_ctrl_ops, | ||
829 | V4L2_CID_SATURATION, -64, 64, 1, 64); | ||
830 | v4l2_ctrl_new_std(&cam->hdl, &cam_ctrl_ops, | ||
831 | V4L2_CID_HUE, -128, 127, 1, 0); | ||
832 | if (cam->hdl.error) { | ||
833 | v4l2_err(v4l2_dev, "couldn't register controls\n"); | ||
834 | return -1; | ||
835 | } | ||
852 | cam->pport = port; | 836 | cam->pport = port; |
853 | cam->brightness = 128; | 837 | cam->brightness = 128; |
854 | cam->contrast = 64; | 838 | cam->contrast = 64; |
@@ -898,6 +882,8 @@ static int w9966_init(struct w9966 *cam, struct parport *port) | |||
898 | cam->vdev.fops = &w9966_fops; | 882 | cam->vdev.fops = &w9966_fops; |
899 | cam->vdev.ioctl_ops = &w9966_ioctl_ops; | 883 | cam->vdev.ioctl_ops = &w9966_ioctl_ops; |
900 | cam->vdev.release = video_device_release_empty; | 884 | cam->vdev.release = video_device_release_empty; |
885 | cam->vdev.ctrl_handler = &cam->hdl; | ||
886 | set_bit(V4L2_FL_USE_FH_PRIO, &cam->vdev.flags); | ||
901 | video_set_drvdata(&cam->vdev, cam); | 887 | video_set_drvdata(&cam->vdev, cam); |
902 | 888 | ||
903 | mutex_init(&cam->lock); | 889 | mutex_init(&cam->lock); |
@@ -923,6 +909,8 @@ static void w9966_term(struct w9966 *cam) | |||
923 | w9966_set_state(cam, W9966_STATE_VDEV, 0); | 909 | w9966_set_state(cam, W9966_STATE_VDEV, 0); |
924 | } | 910 | } |
925 | 911 | ||
912 | v4l2_ctrl_handler_free(&cam->hdl); | ||
913 | |||
926 | /* Terminate from IEEE1284 mode and release pdev block */ | 914 | /* Terminate from IEEE1284 mode and release pdev block */ |
927 | if (w9966_get_state(cam, W9966_STATE_PDEV, W9966_STATE_PDEV)) { | 915 | if (w9966_get_state(cam, W9966_STATE_PDEV, W9966_STATE_PDEV)) { |
928 | w9966_pdev_claim(cam); | 916 | w9966_pdev_claim(cam); |