diff options
Diffstat (limited to 'drivers/media/video/bw-qcam.c')
-rw-r--r-- | drivers/media/video/bw-qcam.c | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c index 2520219f01ba..5b75a64b199b 100644 --- a/drivers/media/video/bw-qcam.c +++ b/drivers/media/video/bw-qcam.c | |||
@@ -607,8 +607,9 @@ static long qc_capture(struct qcam *q, char __user *buf, unsigned long len) | |||
607 | } | 607 | } |
608 | o = i * pixels_per_line + pixels_read + k; | 608 | o = i * pixels_per_line + pixels_read + k; |
609 | if (o < len) { | 609 | if (o < len) { |
610 | u8 ch = invert - buffer[k]; | ||
610 | got++; | 611 | got++; |
611 | put_user((invert - buffer[k]) << shift, buf + o); | 612 | put_user(ch << shift, buf + o); |
612 | } | 613 | } |
613 | } | 614 | } |
614 | pixels_read += bytes; | 615 | pixels_read += bytes; |
@@ -648,8 +649,8 @@ static int qcam_querycap(struct file *file, void *priv, | |||
648 | struct qcam *qcam = video_drvdata(file); | 649 | struct qcam *qcam = video_drvdata(file); |
649 | 650 | ||
650 | strlcpy(vcap->driver, qcam->v4l2_dev.name, sizeof(vcap->driver)); | 651 | strlcpy(vcap->driver, qcam->v4l2_dev.name, sizeof(vcap->driver)); |
651 | strlcpy(vcap->card, "B&W Quickcam", sizeof(vcap->card)); | 652 | strlcpy(vcap->card, "Connectix B&W Quickcam", sizeof(vcap->card)); |
652 | strlcpy(vcap->bus_info, "parport", sizeof(vcap->bus_info)); | 653 | strlcpy(vcap->bus_info, qcam->pport->name, sizeof(vcap->bus_info)); |
653 | vcap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE; | 654 | vcap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE; |
654 | vcap->capabilities = vcap->device_caps | V4L2_CAP_DEVICE_CAPS; | 655 | vcap->capabilities = vcap->device_caps | V4L2_CAP_DEVICE_CAPS; |
655 | return 0; | 656 | return 0; |
@@ -688,8 +689,8 @@ static int qcam_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f | |||
688 | pix->height = qcam->height / qcam->transfer_scale; | 689 | pix->height = qcam->height / qcam->transfer_scale; |
689 | pix->pixelformat = (qcam->bpp == 4) ? V4L2_PIX_FMT_Y4 : V4L2_PIX_FMT_Y6; | 690 | pix->pixelformat = (qcam->bpp == 4) ? V4L2_PIX_FMT_Y4 : V4L2_PIX_FMT_Y6; |
690 | pix->field = V4L2_FIELD_NONE; | 691 | pix->field = V4L2_FIELD_NONE; |
691 | pix->bytesperline = qcam->width; | 692 | pix->bytesperline = pix->width; |
692 | pix->sizeimage = qcam->width * qcam->height; | 693 | pix->sizeimage = pix->width * pix->height; |
693 | /* Just a guess */ | 694 | /* Just a guess */ |
694 | pix->colorspace = V4L2_COLORSPACE_SRGB; | 695 | pix->colorspace = V4L2_COLORSPACE_SRGB; |
695 | return 0; | 696 | return 0; |
@@ -757,7 +758,7 @@ static int qcam_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdes | |||
757 | "4-Bit Monochrome", V4L2_PIX_FMT_Y4, | 758 | "4-Bit Monochrome", V4L2_PIX_FMT_Y4, |
758 | { 0, 0, 0, 0 } | 759 | { 0, 0, 0, 0 } |
759 | }, | 760 | }, |
760 | { 0, 0, 0, | 761 | { 1, 0, 0, |
761 | "6-Bit Monochrome", V4L2_PIX_FMT_Y6, | 762 | "6-Bit Monochrome", V4L2_PIX_FMT_Y6, |
762 | { 0, 0, 0, 0 } | 763 | { 0, 0, 0, 0 } |
763 | }, | 764 | }, |
@@ -772,6 +773,25 @@ static int qcam_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdes | |||
772 | return 0; | 773 | return 0; |
773 | } | 774 | } |
774 | 775 | ||
776 | static int qcam_enum_framesizes(struct file *file, void *fh, | ||
777 | struct v4l2_frmsizeenum *fsize) | ||
778 | { | ||
779 | static const struct v4l2_frmsize_discrete sizes[] = { | ||
780 | { 80, 60 }, | ||
781 | { 160, 120 }, | ||
782 | { 320, 240 }, | ||
783 | }; | ||
784 | |||
785 | if (fsize->index > 2) | ||
786 | return -EINVAL; | ||
787 | if (fsize->pixel_format != V4L2_PIX_FMT_Y4 && | ||
788 | fsize->pixel_format != V4L2_PIX_FMT_Y6) | ||
789 | return -EINVAL; | ||
790 | fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; | ||
791 | fsize->discrete = sizes[fsize->index]; | ||
792 | return 0; | ||
793 | } | ||
794 | |||
775 | static ssize_t qcam_read(struct file *file, char __user *buf, | 795 | static ssize_t qcam_read(struct file *file, char __user *buf, |
776 | size_t count, loff_t *ppos) | 796 | size_t count, loff_t *ppos) |
777 | { | 797 | { |
@@ -795,6 +815,11 @@ static ssize_t qcam_read(struct file *file, char __user *buf, | |||
795 | return len; | 815 | return len; |
796 | } | 816 | } |
797 | 817 | ||
818 | static unsigned int qcam_poll(struct file *filp, poll_table *wait) | ||
819 | { | ||
820 | return v4l2_ctrl_poll(filp, wait) | POLLIN | POLLRDNORM; | ||
821 | } | ||
822 | |||
798 | static int qcam_s_ctrl(struct v4l2_ctrl *ctrl) | 823 | static int qcam_s_ctrl(struct v4l2_ctrl *ctrl) |
799 | { | 824 | { |
800 | struct qcam *qcam = | 825 | struct qcam *qcam = |
@@ -828,7 +853,7 @@ static const struct v4l2_file_operations qcam_fops = { | |||
828 | .owner = THIS_MODULE, | 853 | .owner = THIS_MODULE, |
829 | .open = v4l2_fh_open, | 854 | .open = v4l2_fh_open, |
830 | .release = v4l2_fh_release, | 855 | .release = v4l2_fh_release, |
831 | .poll = v4l2_ctrl_poll, | 856 | .poll = qcam_poll, |
832 | .unlocked_ioctl = video_ioctl2, | 857 | .unlocked_ioctl = video_ioctl2, |
833 | .read = qcam_read, | 858 | .read = qcam_read, |
834 | }; | 859 | }; |
@@ -839,6 +864,7 @@ static const struct v4l2_ioctl_ops qcam_ioctl_ops = { | |||
839 | .vidioc_s_input = qcam_s_input, | 864 | .vidioc_s_input = qcam_s_input, |
840 | .vidioc_enum_input = qcam_enum_input, | 865 | .vidioc_enum_input = qcam_enum_input, |
841 | .vidioc_enum_fmt_vid_cap = qcam_enum_fmt_vid_cap, | 866 | .vidioc_enum_fmt_vid_cap = qcam_enum_fmt_vid_cap, |
867 | .vidioc_enum_framesizes = qcam_enum_framesizes, | ||
842 | .vidioc_g_fmt_vid_cap = qcam_g_fmt_vid_cap, | 868 | .vidioc_g_fmt_vid_cap = qcam_g_fmt_vid_cap, |
843 | .vidioc_s_fmt_vid_cap = qcam_s_fmt_vid_cap, | 869 | .vidioc_s_fmt_vid_cap = qcam_s_fmt_vid_cap, |
844 | .vidioc_try_fmt_vid_cap = qcam_try_fmt_vid_cap, | 870 | .vidioc_try_fmt_vid_cap = qcam_try_fmt_vid_cap, |
@@ -864,9 +890,9 @@ static struct qcam *qcam_init(struct parport *port) | |||
864 | return NULL; | 890 | return NULL; |
865 | 891 | ||
866 | v4l2_dev = &qcam->v4l2_dev; | 892 | v4l2_dev = &qcam->v4l2_dev; |
867 | strlcpy(v4l2_dev->name, "bw-qcam", sizeof(v4l2_dev->name)); | 893 | snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "bw-qcam%d", num_cams); |
868 | 894 | ||
869 | if (v4l2_device_register(NULL, v4l2_dev) < 0) { | 895 | if (v4l2_device_register(port->dev, v4l2_dev) < 0) { |
870 | v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); | 896 | v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); |
871 | kfree(qcam); | 897 | kfree(qcam); |
872 | return NULL; | 898 | return NULL; |
@@ -886,7 +912,7 @@ static struct qcam *qcam_init(struct parport *port) | |||
886 | return NULL; | 912 | return NULL; |
887 | } | 913 | } |
888 | qcam->pport = port; | 914 | qcam->pport = port; |
889 | qcam->pdev = parport_register_device(port, "bw-qcam", NULL, NULL, | 915 | qcam->pdev = parport_register_device(port, v4l2_dev->name, NULL, NULL, |
890 | NULL, 0, NULL); | 916 | NULL, 0, NULL); |
891 | if (qcam->pdev == NULL) { | 917 | if (qcam->pdev == NULL) { |
892 | v4l2_err(v4l2_dev, "couldn't register for %s.\n", port->name); | 918 | v4l2_err(v4l2_dev, "couldn't register for %s.\n", port->name); |
@@ -975,6 +1001,7 @@ static int init_bwqcam(struct parport *port) | |||
975 | return -ENODEV; | 1001 | return -ENODEV; |
976 | } | 1002 | } |
977 | qc_calibrate(qcam); | 1003 | qc_calibrate(qcam); |
1004 | v4l2_ctrl_handler_setup(&qcam->hdl); | ||
978 | 1005 | ||
979 | parport_release(qcam->pdev); | 1006 | parport_release(qcam->pdev); |
980 | 1007 | ||