~ubuntu-branches/ubuntu/quantal/linux-lowlatency/quantal-proposed

« back to all changes in this revision

Viewing changes to drivers/media/video/bw-qcam.c

  • Committer: Package Import Robot
  • Author(s): Andy Whitcroft, Andy Whitcroft, Ubuntu: 3.5.0-3.3
  • Date: 2012-07-03 09:23:14 UTC
  • Revision ID: package-import@ubuntu.com-20120703092314-wjaqz3coxptokmtl
Tags: 3.5.0-3.3
[ Andy Whitcroft ]

* [Config] drop -pae from d-i configuration.
* rebase to Ubuntu-3.5.0-3.3

[ Ubuntu: 3.5.0-3.3 ]

* [Config] enable CONFIG_MEMTEST=y
  - LP: #1004535
* [Config] config-check: add support for a cut operation
* [Config] enforcer -- switch to cut where appropriate
* Rebase to v3.5-rc5
* [Config] Updateconfigs after rebase to v3.5-rc5
* SAUCE: ocfs2: Fix NULL pointer dereferrence in
  __ocfs2_change_file_space
  - LP: #1006012
* SAUCE: (drop after 3.5) drm/i915: ignore pipe select bit when checking
  for LVDS register initialization
  - LP: #1012800
* rebase to v3.5-rc5
  - LP: #1013183
  - LP: #1017017
  - LP: #884652

Show diffs side-by-side

added added

removed removed

Lines of Context:
607
607
                                }
608
608
                                o = i * pixels_per_line + pixels_read + k;
609
609
                                if (o < len) {
 
610
                                        u8 ch = invert - buffer[k];
610
611
                                        got++;
611
 
                                        put_user((invert - buffer[k]) << shift, buf + o);
 
612
                                        put_user(ch << shift, buf + o);
612
613
                                }
613
614
                        }
614
615
                        pixels_read += bytes;
648
649
        struct qcam *qcam = video_drvdata(file);
649
650
 
650
651
        strlcpy(vcap->driver, qcam->v4l2_dev.name, sizeof(vcap->driver));
651
 
        strlcpy(vcap->card, "B&W Quickcam", sizeof(vcap->card));
652
 
        strlcpy(vcap->bus_info, "parport", sizeof(vcap->bus_info));
 
652
        strlcpy(vcap->card, "Connectix B&W Quickcam", sizeof(vcap->card));
 
653
        strlcpy(vcap->bus_info, qcam->pport->name, sizeof(vcap->bus_info));
653
654
        vcap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE;
654
655
        vcap->capabilities = vcap->device_caps | V4L2_CAP_DEVICE_CAPS;
655
656
        return 0;
688
689
        pix->height = qcam->height / qcam->transfer_scale;
689
690
        pix->pixelformat = (qcam->bpp == 4) ? V4L2_PIX_FMT_Y4 : V4L2_PIX_FMT_Y6;
690
691
        pix->field = V4L2_FIELD_NONE;
691
 
        pix->bytesperline = qcam->width;
692
 
        pix->sizeimage = qcam->width * qcam->height;
 
692
        pix->bytesperline = pix->width;
 
693
        pix->sizeimage = pix->width * pix->height;
693
694
        /* Just a guess */
694
695
        pix->colorspace = V4L2_COLORSPACE_SRGB;
695
696
        return 0;
757
758
                  "4-Bit Monochrome", V4L2_PIX_FMT_Y4,
758
759
                  { 0, 0, 0, 0 }
759
760
                },
760
 
                { 0, 0, 0,
 
761
                { 1, 0, 0,
761
762
                  "6-Bit Monochrome", V4L2_PIX_FMT_Y6,
762
763
                  { 0, 0, 0, 0 }
763
764
                },
772
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
795
static ssize_t qcam_read(struct file *file, char __user *buf,
776
796
                size_t count, loff_t *ppos)
777
797
{
795
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
823
static int qcam_s_ctrl(struct v4l2_ctrl *ctrl)
799
824
{
800
825
        struct qcam *qcam =
828
853
        .owner          = THIS_MODULE,
829
854
        .open           = v4l2_fh_open,
830
855
        .release        = v4l2_fh_release,
831
 
        .poll           = v4l2_ctrl_poll,
 
856
        .poll           = qcam_poll,
832
857
        .unlocked_ioctl = video_ioctl2,
833
858
        .read           = qcam_read,
834
859
};
839
864
        .vidioc_s_input                     = qcam_s_input,
840
865
        .vidioc_enum_input                  = qcam_enum_input,
841
866
        .vidioc_enum_fmt_vid_cap            = qcam_enum_fmt_vid_cap,
 
867
        .vidioc_enum_framesizes             = qcam_enum_framesizes,
842
868
        .vidioc_g_fmt_vid_cap               = qcam_g_fmt_vid_cap,
843
869
        .vidioc_s_fmt_vid_cap               = qcam_s_fmt_vid_cap,
844
870
        .vidioc_try_fmt_vid_cap             = qcam_try_fmt_vid_cap,
864
890
                return NULL;
865
891
 
866
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
896
                v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
871
897
                kfree(qcam);
872
898
                return NULL;
886
912
                return NULL;
887
913
        }
888
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
916
                        NULL, 0, NULL);
891
917
        if (qcam->pdev == NULL) {
892
918
                v4l2_err(v4l2_dev, "couldn't register for %s.\n", port->name);
975
1001
                return -ENODEV;
976
1002
        }
977
1003
        qc_calibrate(qcam);
 
1004
        v4l2_ctrl_handler_setup(&qcam->hdl);
978
1005
 
979
1006
        parport_release(qcam->pdev);
980
1007