/*
* IF easycap_usb_disconnect() HAS ALREADY FREED POINTER peasycap BEFORE THE
* ATTEMPT TO ACQUIRE THE SEMAPHORE, isdongle() WILL HAVE FAILED. BAIL OUT.
-*/
-/*---------------------------------------------------------------------------*/
- return -ERESTARTSYS;
-}
+ */
/*---------------------------------------------------------------------------*/
-switch (cmd) {
-case VIDIOC_QUERYCAP: {
- struct v4l2_capability v4l2_capability;
- char version[16], *p1, *p2;
- int i, rc, k[3];
- long lng;
-
- JOM(8, "VIDIOC_QUERYCAP\n");
-
- if (16 <= strlen(EASYCAP_DRIVER_VERSION)) {
- SAM("ERROR: bad driver version string\n");
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EINVAL;
+ return -ERESTARTSYS;
}
- strcpy(&version[0], EASYCAP_DRIVER_VERSION);
- for (i = 0; i < 3; i++)
- k[i] = 0;
- p2 = &version[0]; i = 0;
- while (*p2) {
- p1 = p2;
- while (*p2 && ('.' != *p2))
- p2++;
- if (*p2)
- *p2++ = 0;
- if (3 > i) {
- rc = (int) strict_strtol(p1, 10, &lng);
- if (0 != rc) {
- SAM("ERROR: %i=strict_strtol(%s,.,,)\n", \
- rc, p1);
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EINVAL;
+/*---------------------------------------------------------------------------*/
+ switch (cmd) {
+ case VIDIOC_QUERYCAP: {
+ struct v4l2_capability v4l2_capability;
+ char version[16], *p1, *p2;
+ int i, rc, k[3];
+ long lng;
+
+ JOM(8, "VIDIOC_QUERYCAP\n");
+
+ if (16 <= strlen(EASYCAP_DRIVER_VERSION)) {
+ SAM("ERROR: bad driver version string\n");
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EINVAL;
+ }
+ strcpy(&version[0], EASYCAP_DRIVER_VERSION);
+ for (i = 0; i < 3; i++)
+ k[i] = 0;
+ p2 = &version[0];
+ i = 0;
+ while (*p2) {
+ p1 = p2;
+ while (*p2 && ('.' != *p2))
+ p2++;
+ if (*p2)
+ *p2++ = 0;
+ if (3 > i) {
+ rc = (int) strict_strtol(p1, 10, &lng);
+ if (rc) {
+ SAM("ERROR: %i=strict_strtol(%s,.,,)\n",
+ rc, p1);
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EINVAL;
+ }
+ k[i] = (int)lng;
}
- k[i] = (int)lng;
+ i++;
}
- i++;
- }
- memset(&v4l2_capability, 0, sizeof(struct v4l2_capability));
- strlcpy(&v4l2_capability.driver[0], "easycap", \
- sizeof(v4l2_capability.driver));
+ memset(&v4l2_capability, 0, sizeof(struct v4l2_capability));
+ strlcpy(&v4l2_capability.driver[0],
+ "easycap", sizeof(v4l2_capability.driver));
- v4l2_capability.capabilities = \
- V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | \
- V4L2_CAP_AUDIO | V4L2_CAP_READWRITE;
+ v4l2_capability.capabilities = V4L2_CAP_VIDEO_CAPTURE |
+ V4L2_CAP_STREAMING |
+ V4L2_CAP_AUDIO |
+ V4L2_CAP_READWRITE;
- v4l2_capability.version = KERNEL_VERSION(k[0], k[1], k[2]);
- JOM(8, "v4l2_capability.version=(%i,%i,%i)\n", k[0], k[1], k[2]);
+ v4l2_capability.version = KERNEL_VERSION(k[0], k[1], k[2]);
+ JOM(8, "v4l2_capability.version=(%i,%i,%i)\n", k[0], k[1], k[2]);
- strlcpy(&v4l2_capability.card[0], "EasyCAP DC60", \
- sizeof(v4l2_capability.card));
+ strlcpy(&v4l2_capability.card[0],
+ "EasyCAP DC60", sizeof(v4l2_capability.card));
- if (usb_make_path(peasycap->pusb_device, &v4l2_capability.bus_info[0],\
+ if (usb_make_path(peasycap->pusb_device,
+ &v4l2_capability.bus_info[0],
sizeof(v4l2_capability.bus_info)) < 0) {
- strlcpy(&v4l2_capability.bus_info[0], "EasyCAP bus_info", \
- sizeof(v4l2_capability.bus_info));
- JOM(8, "%s=v4l2_capability.bus_info\n", \
- &v4l2_capability.bus_info[0]);
- }
- if (0 != copy_to_user((void __user *)arg, &v4l2_capability, \
- sizeof(struct v4l2_capability))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
+
+ strlcpy(&v4l2_capability.bus_info[0], "EasyCAP bus_info",
+ sizeof(v4l2_capability.bus_info));
+ JOM(8, "%s=v4l2_capability.bus_info\n",
+ &v4l2_capability.bus_info[0]);
+ }
+ if (copy_to_user((void __user *)arg, &v4l2_capability,
+ sizeof(struct v4l2_capability))) {
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
+ break;
}
- break;
-}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_ENUMINPUT: {
- struct v4l2_input v4l2_input;
- __u32 index;
+ case VIDIOC_ENUMINPUT: {
+ struct v4l2_input v4l2_input;
+ u32 index;
- JOM(8, "VIDIOC_ENUMINPUT\n");
+ JOM(8, "VIDIOC_ENUMINPUT\n");
- if (0 != copy_from_user(&v4l2_input, (void __user *)arg, \
+ if (copy_from_user(&v4l2_input, (void __user *)arg,
sizeof(struct v4l2_input))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
- index = v4l2_input.index;
- memset(&v4l2_input, 0, sizeof(struct v4l2_input));
-
- switch (index) {
- case 0: {
- v4l2_input.index = index;
- strcpy(&v4l2_input.name[0], "CVBS0");
- v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
- v4l2_input.audioset = 0x01;
- v4l2_input.tuner = 0;
- v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \
- V4L2_STD_NTSC ;
- v4l2_input.status = 0;
- JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
- break;
- }
- case 1: {
- v4l2_input.index = index;
- strcpy(&v4l2_input.name[0], "CVBS1");
- v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
- v4l2_input.audioset = 0x01;
- v4l2_input.tuner = 0;
- v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \
- V4L2_STD_NTSC ;
- v4l2_input.status = 0;
- JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
- break;
- }
- case 2: {
- v4l2_input.index = index;
- strcpy(&v4l2_input.name[0], "CVBS2");
- v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
- v4l2_input.audioset = 0x01;
- v4l2_input.tuner = 0;
- v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \
- V4L2_STD_NTSC ;
- v4l2_input.status = 0;
- JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
- break;
- }
- case 3: {
- v4l2_input.index = index;
- strcpy(&v4l2_input.name[0], "CVBS3");
- v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
- v4l2_input.audioset = 0x01;
- v4l2_input.tuner = 0;
- v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \
- V4L2_STD_NTSC ;
- v4l2_input.status = 0;
- JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
- break;
- }
- case 4: {
- v4l2_input.index = index;
- strcpy(&v4l2_input.name[0], "CVBS4");
- v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
- v4l2_input.audioset = 0x01;
- v4l2_input.tuner = 0;
- v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \
- V4L2_STD_NTSC ;
- v4l2_input.status = 0;
- JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
- break;
- }
- case 5: {
- v4l2_input.index = index;
- strcpy(&v4l2_input.name[0], "S-VIDEO");
- v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
- v4l2_input.audioset = 0x01;
- v4l2_input.tuner = 0;
- v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \
- V4L2_STD_NTSC ;
- v4l2_input.status = 0;
- JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
- break;
- }
- default: {
- JOM(8, "%i=index: exhausts inputs\n", index);
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EINVAL;
- }
- }
+ index = v4l2_input.index;
+ memset(&v4l2_input, 0, sizeof(struct v4l2_input));
- if (0 != copy_to_user((void __user *)arg, &v4l2_input, \
- sizeof(struct v4l2_input))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
+ switch (index) {
+ case 0: {
+ v4l2_input.index = index;
+ strcpy(&v4l2_input.name[0], "CVBS0");
+ v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
+ v4l2_input.audioset = 0x01;
+ v4l2_input.tuner = 0;
+ v4l2_input.std = V4L2_STD_PAL |
+ V4L2_STD_SECAM |
+ V4L2_STD_NTSC ;
+ v4l2_input.status = 0;
+ JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
+ break;
+ }
+ case 1: {
+ v4l2_input.index = index;
+ strcpy(&v4l2_input.name[0], "CVBS1");
+ v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
+ v4l2_input.audioset = 0x01;
+ v4l2_input.tuner = 0;
+ v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
+ V4L2_STD_NTSC;
+ v4l2_input.status = 0;
+ JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
+ break;
+ }
+ case 2: {
+ v4l2_input.index = index;
+ strcpy(&v4l2_input.name[0], "CVBS2");
+ v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
+ v4l2_input.audioset = 0x01;
+ v4l2_input.tuner = 0;
+ v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
+ V4L2_STD_NTSC ;
+ v4l2_input.status = 0;
+ JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
+ break;
+ }
+ case 3: {
+ v4l2_input.index = index;
+ strcpy(&v4l2_input.name[0], "CVBS3");
+ v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
+ v4l2_input.audioset = 0x01;
+ v4l2_input.tuner = 0;
+ v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
+ V4L2_STD_NTSC ;
+ v4l2_input.status = 0;
+ JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
+ break;
+ }
+ case 4: {
+ v4l2_input.index = index;
+ strcpy(&v4l2_input.name[0], "CVBS4");
+ v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
+ v4l2_input.audioset = 0x01;
+ v4l2_input.tuner = 0;
+ v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
+ V4L2_STD_NTSC ;
+ v4l2_input.status = 0;
+ JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
+ break;
+ }
+ case 5: {
+ v4l2_input.index = index;
+ strcpy(&v4l2_input.name[0], "S-VIDEO");
+ v4l2_input.type = V4L2_INPUT_TYPE_CAMERA;
+ v4l2_input.audioset = 0x01;
+ v4l2_input.tuner = 0;
+ v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM |
+ V4L2_STD_NTSC ;
+ v4l2_input.status = 0;
+ JOM(8, "%i=index: %s\n", index, &v4l2_input.name[0]);
+ break;
+ }
+ default: {
+ JOM(8, "%i=index: exhausts inputs\n", index);
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EINVAL;
+ }
+ }
+
+ if (copy_to_user((void __user *)arg, &v4l2_input,
+ sizeof(struct v4l2_input))) {
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
+ break;
}
- break;
-}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_G_INPUT: {
- __u32 index;
-
- JOM(8, "VIDIOC_G_INPUT\n");
- index = (__u32)peasycap->input;
- JOM(8, "user is told: %i\n", index);
- if (0 != copy_to_user((void __user *)arg, &index, sizeof(__u32))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
+ case VIDIOC_G_INPUT: {
+ u32 index;
+
+ JOM(8, "VIDIOC_G_INPUT\n");
+ index = (u32)peasycap->input;
+ JOM(8, "user is told: %i\n", index);
+ if (copy_to_user((void __user *)arg, &index, sizeof(u32))) {
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
+ break;
}
- break;
-}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_S_INPUT:
+ case VIDIOC_S_INPUT:
{
- __u32 index;
- int rc;
+ u32 index;
+ int rc;
- JOM(8, "VIDIOC_S_INPUT\n");
+ JOM(8, "VIDIOC_S_INPUT\n");
- if (0 != copy_from_user(&index, (void __user *)arg, sizeof(__u32))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
+ if (0 != copy_from_user(&index, (void __user *)arg, sizeof(u32))) {
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
- JOM(8, "user requests input %i\n", index);
+ JOM(8, "user requests input %i\n", index);
- if ((int)index == peasycap->input) {
- SAM("requested input already in effect\n");
- break;
- }
+ if ((int)index == peasycap->input) {
+ SAM("requested input already in effect\n");
+ break;
+ }
- if ((0 > index) || (INPUT_MANY <= index)) {
- JOM(8, "ERROR: bad requested input: %i\n", index);
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EINVAL;
- }
+ if ((0 > index) || (INPUT_MANY <= index)) {
+ JOM(8, "ERROR: bad requested input: %i\n", index);
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EINVAL;
+ }
- rc = newinput(peasycap, (int)index);
- if (0 == rc) {
- JOM(8, "newinput(.,%i) OK\n", (int)index);
- } else {
- SAM("ERROR: newinput(.,%i) returned %i\n", (int)index, rc);
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
+ rc = newinput(peasycap, (int)index);
+ if (0 == rc) {
+ JOM(8, "newinput(.,%i) OK\n", (int)index);
+ } else {
+ SAM("ERROR: newinput(.,%i) returned %i\n", (int)index, rc);
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
+ break;
}
- break;
-}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_ENUMAUDIO: {
- JOM(8, "VIDIOC_ENUMAUDIO\n");
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EINVAL;
-}
+ case VIDIOC_ENUMAUDIO: {
+ JOM(8, "VIDIOC_ENUMAUDIO\n");
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EINVAL;
+ }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_ENUMAUDOUT: {
- struct v4l2_audioout v4l2_audioout;
+ case VIDIOC_ENUMAUDOUT: {
+ struct v4l2_audioout v4l2_audioout;
- JOM(8, "VIDIOC_ENUMAUDOUT\n");
+ JOM(8, "VIDIOC_ENUMAUDOUT\n");
- if (0 != copy_from_user(&v4l2_audioout, (void __user *)arg, \
+ if (copy_from_user(&v4l2_audioout, (void __user *)arg,
sizeof(struct v4l2_audioout))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
- if (0 != v4l2_audioout.index) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EINVAL;
- }
- memset(&v4l2_audioout, 0, sizeof(struct v4l2_audioout));
- v4l2_audioout.index = 0;
- strcpy(&v4l2_audioout.name[0], "Soundtrack");
+ if (0 != v4l2_audioout.index) {
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EINVAL;
+ }
+ memset(&v4l2_audioout, 0, sizeof(struct v4l2_audioout));
+ v4l2_audioout.index = 0;
+ strcpy(&v4l2_audioout.name[0], "Soundtrack");
- if (0 != copy_to_user((void __user *)arg, &v4l2_audioout, \
- sizeof(struct v4l2_audioout))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
+ if (copy_to_user((void __user *)arg, &v4l2_audioout,
+ sizeof(struct v4l2_audioout))) {
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
+ break;
}
- break;
-}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_QUERYCTRL: {
- int i1;
- struct v4l2_queryctrl v4l2_queryctrl;
+ case VIDIOC_QUERYCTRL: {
+ int i1;
+ struct v4l2_queryctrl v4l2_queryctrl;
- JOM(8, "VIDIOC_QUERYCTRL\n");
+ JOM(8, "VIDIOC_QUERYCTRL\n");
- if (0 != copy_from_user(&v4l2_queryctrl, (void __user *)arg, \
- sizeof(struct v4l2_queryctrl))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
+ if (0 != copy_from_user(&v4l2_queryctrl, (void __user *)arg,
+ sizeof(struct v4l2_queryctrl))) {
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
- i1 = 0;
- while (0xFFFFFFFF != easycap_control[i1].id) {
- if (easycap_control[i1].id == v4l2_queryctrl.id) {
- JOM(8, "VIDIOC_QUERYCTRL %s=easycap_control[%i]" \
- ".name\n", &easycap_control[i1].name[0], i1);
- memcpy(&v4l2_queryctrl, &easycap_control[i1], \
- sizeof(struct v4l2_queryctrl));
- break;
+ i1 = 0;
+ while (0xFFFFFFFF != easycap_control[i1].id) {
+ if (easycap_control[i1].id == v4l2_queryctrl.id) {
+ JOM(8, "VIDIOC_QUERYCTRL %s=easycap_control[%i]"
+ ".name\n", &easycap_control[i1].name[0], i1);
+ memcpy(&v4l2_queryctrl, &easycap_control[i1],
+ sizeof(struct v4l2_queryctrl));
+ break;
+ }
+ i1++;
}
- i1++;
+ if (0xFFFFFFFF == easycap_control[i1].id) {
+ JOM(8, "%i=index: exhausts controls\n", i1);
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EINVAL;
+ }
+ if (copy_to_user((void __user *)arg, &v4l2_queryctrl,
+ sizeof(struct v4l2_queryctrl))) {
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
+ break;
}
- if (0xFFFFFFFF == easycap_control[i1].id) {
- JOM(8, "%i=index: exhausts controls\n", i1);
- mutex_unlock(&easycap_dongle[kd].mutex_video);
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+ case VIDIOC_QUERYMENU: {
+ JOM(8, "VIDIOC_QUERYMENU unsupported\n");
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
- if (0 != copy_to_user((void __user *)arg, &v4l2_queryctrl, \
- sizeof(struct v4l2_queryctrl))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
- break;
-}
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_QUERYMENU: {
- JOM(8, "VIDIOC_QUERYMENU unsupported\n");
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EINVAL;
-}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_G_CTRL: {
- struct v4l2_control *pv4l2_control;
-
- JOM(8, "VIDIOC_G_CTRL\n");
- pv4l2_control = kzalloc(sizeof(struct v4l2_control), GFP_KERNEL);
- if (!pv4l2_control) {
- SAM("ERROR: out of memory\n");
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -ENOMEM;
- }
- if (0 != copy_from_user(pv4l2_control, (void __user *)arg, \
- sizeof(struct v4l2_control))) {
- kfree(pv4l2_control);
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
+ case VIDIOC_G_CTRL: {
+ struct v4l2_control *pv4l2_control;
+
+ JOM(8, "VIDIOC_G_CTRL\n");
+ pv4l2_control = kzalloc(sizeof(struct v4l2_control), GFP_KERNEL);
+ if (!pv4l2_control) {
+ SAM("ERROR: out of memory\n");
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -ENOMEM;
+ }
+ if (0 != copy_from_user(pv4l2_control, (void __user *)arg,
+ sizeof(struct v4l2_control))) {
+ kfree(pv4l2_control);
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
- switch (pv4l2_control->id) {
- case V4L2_CID_BRIGHTNESS: {
- pv4l2_control->value = peasycap->brightness;
- JOM(8, "user enquires brightness: %i\n", pv4l2_control->value);
- break;
- }
- case V4L2_CID_CONTRAST: {
- pv4l2_control->value = peasycap->contrast;
- JOM(8, "user enquires contrast: %i\n", pv4l2_control->value);
- break;
- }
- case V4L2_CID_SATURATION: {
- pv4l2_control->value = peasycap->saturation;
- JOM(8, "user enquires saturation: %i\n", pv4l2_control->value);
- break;
- }
- case V4L2_CID_HUE: {
- pv4l2_control->value = peasycap->hue;
- JOM(8, "user enquires hue: %i\n", pv4l2_control->value);
- break;
- }
- case V4L2_CID_AUDIO_VOLUME: {
- pv4l2_control->value = peasycap->volume;
- JOM(8, "user enquires volume: %i\n", pv4l2_control->value);
- break;
- }
- case V4L2_CID_AUDIO_MUTE: {
- if (1 == peasycap->mute)
- pv4l2_control->value = true;
- else
- pv4l2_control->value = false;
- JOM(8, "user enquires mute: %i\n", pv4l2_control->value);
- break;
- }
- default: {
- SAM("ERROR: unknown V4L2 control: 0x%08X=id\n", \
- pv4l2_control->id);
- kfree(pv4l2_control);
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EINVAL;
- }
- }
- if (0 != copy_to_user((void __user *)arg, pv4l2_control, \
- sizeof(struct v4l2_control))) {
+ switch (pv4l2_control->id) {
+ case V4L2_CID_BRIGHTNESS: {
+ pv4l2_control->value = peasycap->brightness;
+ JOM(8, "user enquires brightness: %i\n", pv4l2_control->value);
+ break;
+ }
+ case V4L2_CID_CONTRAST: {
+ pv4l2_control->value = peasycap->contrast;
+ JOM(8, "user enquires contrast: %i\n", pv4l2_control->value);
+ break;
+ }
+ case V4L2_CID_SATURATION: {
+ pv4l2_control->value = peasycap->saturation;
+ JOM(8, "user enquires saturation: %i\n", pv4l2_control->value);
+ break;
+ }
+ case V4L2_CID_HUE: {
+ pv4l2_control->value = peasycap->hue;
+ JOM(8, "user enquires hue: %i\n", pv4l2_control->value);
+ break;
+ }
+ case V4L2_CID_AUDIO_VOLUME: {
+ pv4l2_control->value = peasycap->volume;
+ JOM(8, "user enquires volume: %i\n", pv4l2_control->value);
+ break;
+ }
+ case V4L2_CID_AUDIO_MUTE: {
+ if (1 == peasycap->mute)
+ pv4l2_control->value = true;
+ else
+ pv4l2_control->value = false;
+ JOM(8, "user enquires mute: %i\n", pv4l2_control->value);
+ break;
+ }
+ default: {
+ SAM("ERROR: unknown V4L2 control: 0x%08X=id\n",
+ pv4l2_control->id);
+ kfree(pv4l2_control);
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EINVAL;
+ }
+ }
+ if (copy_to_user((void __user *)arg, pv4l2_control,
+ sizeof(struct v4l2_control))) {
+ kfree(pv4l2_control);
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
kfree(pv4l2_control);
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
- kfree(pv4l2_control);
- break;
-}
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_S_CTRL:
- {
- struct v4l2_control v4l2_control;
-
- JOM(8, "VIDIOC_S_CTRL\n");
-
- if (0 != copy_from_user(&v4l2_control, (void __user *)arg, \
- sizeof(struct v4l2_control))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
-
- switch (v4l2_control.id) {
- case V4L2_CID_BRIGHTNESS: {
- JOM(8, "user requests brightness %i\n", v4l2_control.value);
- if (0 != adjust_brightness(peasycap, v4l2_control.value))
- ;
- break;
- }
- case V4L2_CID_CONTRAST: {
- JOM(8, "user requests contrast %i\n", v4l2_control.value);
- if (0 != adjust_contrast(peasycap, v4l2_control.value))
- ;
- break;
- }
- case V4L2_CID_SATURATION: {
- JOM(8, "user requests saturation %i\n", v4l2_control.value);
- if (0 != adjust_saturation(peasycap, v4l2_control.value))
- ;
- break;
- }
- case V4L2_CID_HUE: {
- JOM(8, "user requests hue %i\n", v4l2_control.value);
- if (0 != adjust_hue(peasycap, v4l2_control.value))
- ;
- break;
- }
- case V4L2_CID_AUDIO_VOLUME: {
- JOM(8, "user requests volume %i\n", v4l2_control.value);
- if (0 != adjust_volume(peasycap, v4l2_control.value))
- ;
- break;
- }
- case V4L2_CID_AUDIO_MUTE: {
- int mute;
-
- JOM(8, "user requests mute %i\n", v4l2_control.value);
- if (true == v4l2_control.value)
- mute = 1;
- else
- mute = 0;
-
- if (0 != adjust_mute(peasycap, mute))
- SAM("WARNING: failed to adjust mute to %i\n", mute);
break;
}
- default: {
- SAM("ERROR: unknown V4L2 control: 0x%08X=id\n", \
- v4l2_control.id);
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EINVAL;
- }
- }
- break;
-}
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_S_EXT_CTRLS: {
- JOM(8, "VIDIOC_S_EXT_CTRLS unsupported\n");
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EINVAL;
-}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- case VIDIOC_S_CTRL:
- {
-case VIDIOC_ENUM_FMT: {
- __u32 index;
- struct v4l2_fmtdesc v4l2_fmtdesc;
++ case VIDIOC_S_CTRL: {
+ struct v4l2_control v4l2_control;
- JOM(8, "VIDIOC_ENUM_FMT\n");
+ JOM(8, "VIDIOC_S_CTRL\n");
- if (0 != copy_from_user(&v4l2_fmtdesc, (void __user *)arg, \
- sizeof(struct v4l2_fmtdesc))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
+ if (0 != copy_from_user(&v4l2_control, (void __user *)arg,
+ sizeof(struct v4l2_control))) {
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
- index = v4l2_fmtdesc.index;
- memset(&v4l2_fmtdesc, 0, sizeof(struct v4l2_fmtdesc));
+ switch (v4l2_control.id) {
+ case V4L2_CID_BRIGHTNESS: {
+ JOM(8, "user requests brightness %i\n", v4l2_control.value);
+ if (0 != adjust_brightness(peasycap, v4l2_control.value))
+ ;
+ break;
+ }
+ case V4L2_CID_CONTRAST: {
+ JOM(8, "user requests contrast %i\n", v4l2_control.value);
+ if (0 != adjust_contrast(peasycap, v4l2_control.value))
+ ;
+ break;
+ }
+ case V4L2_CID_SATURATION: {
+ JOM(8, "user requests saturation %i\n", v4l2_control.value);
+ if (0 != adjust_saturation(peasycap, v4l2_control.value))
+ ;
+ break;
+ }
+ case V4L2_CID_HUE: {
+ JOM(8, "user requests hue %i\n", v4l2_control.value);
+ if (0 != adjust_hue(peasycap, v4l2_control.value))
+ ;
+ break;
+ }
+ case V4L2_CID_AUDIO_VOLUME: {
+ JOM(8, "user requests volume %i\n", v4l2_control.value);
+ if (0 != adjust_volume(peasycap, v4l2_control.value))
+ ;
+ break;
+ }
+ case V4L2_CID_AUDIO_MUTE: {
+ int mute;
- v4l2_fmtdesc.index = index;
- v4l2_fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ JOM(8, "user requests mute %i\n", v4l2_control.value);
+ if (v4l2_control.value)
+ mute = 1;
+ else
+ mute = 0;
- switch (index) {
- case 0: {
- v4l2_fmtdesc.flags = 0;
- strcpy(&v4l2_fmtdesc.description[0], "uyvy");
- v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_UYVY;
- JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
- break;
- }
- case 1: {
- v4l2_fmtdesc.flags = 0;
- strcpy(&v4l2_fmtdesc.description[0], "yuy2");
- v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_YUYV;
- JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
- break;
- }
- case 2: {
- v4l2_fmtdesc.flags = 0;
- strcpy(&v4l2_fmtdesc.description[0], "rgb24");
- v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_RGB24;
- JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
- break;
- }
- case 3: {
- v4l2_fmtdesc.flags = 0;
- strcpy(&v4l2_fmtdesc.description[0], "rgb32");
- v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_RGB32;
- JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
- break;
- }
- case 4: {
- v4l2_fmtdesc.flags = 0;
- strcpy(&v4l2_fmtdesc.description[0], "bgr24");
- v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_BGR24;
- JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
- break;
- }
- case 5: {
- v4l2_fmtdesc.flags = 0;
- strcpy(&v4l2_fmtdesc.description[0], "bgr32");
- v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_BGR32;
- JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
+ if (0 != adjust_mute(peasycap, mute))
+ SAM("WARNING: failed to adjust mute to %i\n", mute);
+ break;
+ }
+ default: {
+ SAM("ERROR: unknown V4L2 control: 0x%08X=id\n",
+ v4l2_control.id);
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EINVAL;
+ }
+ }
break;
}
- default: {
- JOM(8, "%i=index: exhausts formats\n", index);
- mutex_unlock(&easycap_dongle[kd].mutex_video);
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+ case VIDIOC_S_EXT_CTRLS: {
+ JOM(8, "VIDIOC_S_EXT_CTRLS unsupported\n");
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
return -EINVAL;
}
- }
- if (0 != copy_to_user((void __user *)arg, &v4l2_fmtdesc, \
- sizeof(struct v4l2_fmtdesc))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
- break;
-}
-/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-/*
- * THE RESPONSE TO VIDIOC_ENUM_FRAMESIZES MUST BE CONDITIONED ON THE
- * THE CURRENT STANDARD, BECAUSE THAT IS WHAT gstreamer EXPECTS. BEWARE.
-*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-case VIDIOC_ENUM_FRAMESIZES: {
- __u32 index;
- struct v4l2_frmsizeenum v4l2_frmsizeenum;
+ case VIDIOC_ENUM_FMT: {
+ u32 index;
+ struct v4l2_fmtdesc v4l2_fmtdesc;
- JOM(8, "VIDIOC_ENUM_FRAMESIZES\n");
+ JOM(8, "VIDIOC_ENUM_FMT\n");
- if (0 != copy_from_user(&v4l2_frmsizeenum, (void __user *)arg, \
- sizeof(struct v4l2_frmsizeenum))) {
- mutex_unlock(&easycap_dongle[kd].mutex_video);
- return -EFAULT;
- }
+ if (0 != copy_from_user(&v4l2_fmtdesc, (void __user *)arg,
+ sizeof(struct v4l2_fmtdesc))) {
+ mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
+ return -EFAULT;
+ }
- index = v4l2_frmsizeenum.index;
+ index = v4l2_fmtdesc.index;
+ memset(&v4l2_fmtdesc, 0, sizeof(struct v4l2_fmtdesc));
- v4l2_frmsizeenum.type = (__u32) V4L2_FRMSIZE_TYPE_DISCRETE;
+ v4l2_fmtdesc.index = index;
+ v4l2_fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (true == peasycap->ntsc) {
switch (index) {
case 0: {
- v4l2_frmsizeenum.discrete.width = 640;
- v4l2_frmsizeenum.discrete.height = 480;
- JOM(8, "%i=index: %ix%i\n", index, \
- (int)(v4l2_frmsizeenum.\
- discrete.width), \
- (int)(v4l2_frmsizeenum.\
- discrete.height));
+ v4l2_fmtdesc.flags = 0;
+ strcpy(&v4l2_fmtdesc.description[0], "uyvy");
+ v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_UYVY;
+ JOM(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]);
break;
}
case 1: {