Re: [linux-usb-devel] [PATCH] USB: add zr364xx V4L2 driver
Oliver Neukum <[email protected]>
| Newsgroups | gmane.comp.video.video4linux,gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
> +/* devices supported by this driver */
> +static struct usb_device_id device_table[] = {
> + {USB_DEVICE( -1, -1)}, /* add your custom entry here ... */
> + {USB_DEVICE(0x08ca, 0x0109)},
> + {USB_DEVICE(0x041e, 0x4024)},
This ...
> +/* devices supported by this driver */
> +static struct {
> + int vendor;
> + int product;
> + int method; /* which init method this camera uses */
> + const char *name;
> +} devices[] = {
> + { -1, -1, 0, "Custom camera" }, /* ... and here ! */
> + { 0x08ca, 0x0109, 0, "Aiptek PocketDV 3300 or Maxell Maxcam PRO DV3" },
> + { 0x041e, 0x4024, 0, "Creative PC-CAM 880" },
> + { 0x0d64, 0x0108, 0, "Aiptek Fidelity 3200 or Praktica DCZ 1.3 S or "
... and this tables should be merged, using .driver_info for method and the name
read from the camera.
> + /* swap to good indian if camera needs it */
> + if (cam->method == 0)
> + for (i = 0; i < BUFFER_SIZE; i += 2) {
> + swap = cam->buffer[i];
> + cam->buffer[i] = cam->buffer[i + 1];
> + cam->buffer[i + 1] = swap;
> + }
please use the macros
> + cam->vdev = video_device_alloc();
> + if (cam->vdev == NULL) {
> + info("cam->vdev: out of memory !");
> + return -ENODEV;
> + }
memory leak in error case
> + memcpy(cam->vdev, &zoran_template, sizeof(zoran_template));
> + video_set_drvdata(cam->vdev, cam);
> +
> + cam->udev = udev;
> +
> + if ((cam->buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL)) == NULL) {
> + info("cam->buffer: out of memory !");
> + return -ENODEV;
> + }
memory leak in error case
> + switch (mode) {
> + case 1:
> + info("160x120 mode selected");
> + cam->width = 160;
> + cam->height = 120;
> + break;
> + case 2:
> + info("640x480 mode selected");
> + cam->width = 640;
> + cam->height = 480;
> + break;
> + default:
> + info("320x240 mode selected");
> + cam->width = 320;
> + cam->height = 240;
> + break;
> + }
> +
> + m1d1[0] = mode;
> + m2[2].value = 0xf000 + mode;
> + m3[1].value = 0xf000 + mode;
> + header2[437] = cam->height / 256;
> + header2[438] = cam->height % 256;
Please use the endianness macros
> + header2[439] = cam->width / 256;
> + header2[440] = cam->width % 256;
> +
> + cam->nb = 0;
> + cam->brightness = 64;
> +
> + if (video_register_device(cam->vdev, VFL_TYPE_GRABBER, -1) == -1) {
> + info("video_register_device failed");
> + return -ENODEV;
> + }
> +
> + usb_set_intfdata(intf, cam);
> + mutex_init(&cam->lock);
Do this before you register the device. Otherwise you have a race condition.
Regards
Oliver
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list