Commit ed00b41d authored by Dwaine Garden's avatar Dwaine Garden Committed by Mauro Carvalho Chehab

V4L/DVB (4979): Fixes compilation when CONFIG_V4L1_COMPAT is not selected

- SYSFS: Replaced all to_video_device(cd), video_device_create_file,
  video_device_remove_file and add the proper checks at create_file
- Converted old norm values to V4L2 ones.
- Robustness on sysfs hue/contrast/saturation queries.
  Additional check in order to return 0 if the driver is not opened.
- Whitespace cleanups in usbvision-cards.c

This patch merges two fixes by Thierry MERLE and Mauro Chehab, and adds
additional checks.

Signed-off-by: Dwaine Garden<DwaineGarden@rogers.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 5ef35be4
......@@ -86,7 +86,7 @@ struct usbvision_device_data_st usbvision_device_data[] = {
{0x2304, 0x0300, -1, CODEC_SAA7113, 2, V4L2_STD_NTSC, 1, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Pinnacle Studio Linx Video input cable (NTSC)"},
{0x2304, 0x0301, -1, CODEC_SAA7113, 2, V4L2_STD_PAL, 1, 0, 1, 0, 0, -1, -1, 0, 3, 7, "Pinnacle Studio Linx Video input cable (PAL)"},
{0x2304, 0x0419, -1, CODEC_SAA7113, 3, V4L2_STD_PAL, 1, 1, 1, 1, TUNER_TEMIC_4009FR5_PAL, -1, -1, 0, 3, 7, "Pinnacle PCTV Bungee USB (PAL) FM"},
{0x2400, 0x4200, -1, CODEC_SAA7111, 3, VIDEO_MODE_NTSC, 1, 0, 1, 1, TUNER_PHILIPS_NTSC_M, -1, -1, -1, -1, -1, "Hauppauge WinTv-USB"},
{0x2400, 0x4200, -1, CODEC_SAA7111, 3, V4L2_STD_NTSC, 1, 0, 1, 1, TUNER_PHILIPS_NTSC_M, -1, -1, -1, -1, -1, "Hauppauge WinTv-USB"},
{} /* Terminating entry */
};
......@@ -148,7 +148,6 @@ struct usb_device_id usbvision_table [] = {
{ USB_DEVICE(0x2304, 0x0300) }, /* Pinnacle Studio Linx Video input cable (NTSC) */
{ USB_DEVICE(0x2304, 0x0301) }, /* Pinnacle Studio Linx Video input cable (PAL) */
{ USB_DEVICE(0x2304, 0x0419) }, /* Pinnacle PCTV Bungee USB (PAL) FM */
{ USB_DEVICE(0x2400, 0x4200) }, /* Hauppauge WinTv-USB2 Model 42012 */
{ } /* Terminating entry */
......
......@@ -204,7 +204,7 @@ MODULE_ALIAS(DRIVER_ALIAS);
static inline struct usb_usbvision *cd_to_usbvision(struct class_device *cd)
{
struct video_device *vdev = to_video_device(cd);
struct video_device *vdev = container_of(cd, struct video_device, class_dev);
return video_get_drvdata(vdev);
}
......@@ -214,81 +214,85 @@ static ssize_t show_version(struct class_device *cd, char *buf)
}
static CLASS_DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
static ssize_t show_model(struct class_device *class_dev, char *buf)
static ssize_t show_model(struct class_device *cd, char *buf)
{
struct video_device *vdev = to_video_device(class_dev);
struct video_device *vdev = container_of(cd, struct video_device, class_dev);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
return sprintf(buf, "%s\n", usbvision_device_data[usbvision->DevModel].ModelString);
}
static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
static ssize_t show_hue(struct class_device *class_dev, char *buf)
static ssize_t show_hue(struct class_device *cd, char *buf)
{
struct video_device *vdev = to_video_device(class_dev);
struct video_device *vdev = container_of(cd, struct video_device, class_dev);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
struct v4l2_control ctrl;
ctrl.id = V4L2_CID_HUE;
ctrl.value = 0;
if(usbvision->user)
call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
return sprintf(buf, "%d\n", ctrl.value >> 8);
}
static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
static ssize_t show_contrast(struct class_device *class_dev, char *buf)
static ssize_t show_contrast(struct class_device *cd, char *buf)
{
struct video_device *vdev = to_video_device(class_dev);
struct video_device *vdev = container_of(cd, struct video_device, class_dev);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
struct v4l2_control ctrl;
ctrl.id = V4L2_CID_CONTRAST;
ctrl.value = 0;
if(usbvision->user)
call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
return sprintf(buf, "%d\n", ctrl.value >> 8);
}
static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
static ssize_t show_brightness(struct class_device *class_dev, char *buf)
static ssize_t show_brightness(struct class_device *cd, char *buf)
{
struct video_device *vdev = to_video_device(class_dev);
struct video_device *vdev = container_of(cd, struct video_device, class_dev);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
struct v4l2_control ctrl;
ctrl.id = V4L2_CID_BRIGHTNESS;
ctrl.value = 0;
if(usbvision->user)
call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
return sprintf(buf, "%d\n", ctrl.value >> 8);
}
static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
static ssize_t show_saturation(struct class_device *class_dev, char *buf)
static ssize_t show_saturation(struct class_device *cd, char *buf)
{
struct video_device *vdev = to_video_device(class_dev);
struct video_device *vdev = container_of(cd, struct video_device, class_dev);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
struct v4l2_control ctrl;
ctrl.id = V4L2_CID_SATURATION;
ctrl.value = 0;
if(usbvision->user)
call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
return sprintf(buf, "%d\n", ctrl.value >> 8);
}
static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
static ssize_t show_streaming(struct class_device *class_dev, char *buf)
static ssize_t show_streaming(struct class_device *cd, char *buf)
{
struct video_device *vdev = to_video_device(class_dev);
struct video_device *vdev = container_of(cd, struct video_device, class_dev);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
return sprintf(buf, "%s\n", YES_NO(usbvision->streaming==Stream_On?1:0));
}
static CLASS_DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL);
static ssize_t show_compression(struct class_device *class_dev, char *buf)
static ssize_t show_compression(struct class_device *cd, char *buf)
{
struct video_device *vdev = to_video_device(class_dev);
struct video_device *vdev = container_of(cd, struct video_device, class_dev);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
return sprintf(buf, "%s\n", YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS));
}
static CLASS_DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL);
static ssize_t show_device_bridge(struct class_device *class_dev, char *buf)
static ssize_t show_device_bridge(struct class_device *cd, char *buf)
{
struct video_device *vdev = to_video_device(class_dev);
struct video_device *vdev = container_of(cd, struct video_device, class_dev);
struct usb_usbvision *usbvision = video_get_drvdata(vdev);
return sprintf(buf, "%d\n", usbvision->bridgeType);
}
......@@ -297,31 +301,71 @@ static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL);
static void usbvision_create_sysfs(struct video_device *vdev)
{
int res;
if (vdev) {
res=video_device_create_file(vdev, &class_device_attr_version);
res=video_device_create_file(vdev, &class_device_attr_model);
res=video_device_create_file(vdev, &class_device_attr_hue);
res=video_device_create_file(vdev, &class_device_attr_contrast);
res=video_device_create_file(vdev, &class_device_attr_brightness);
res=video_device_create_file(vdev, &class_device_attr_saturation);
res=video_device_create_file(vdev, &class_device_attr_streaming);
res=video_device_create_file(vdev, &class_device_attr_compression);
res=video_device_create_file(vdev, &class_device_attr_bridge);
}
if (!vdev)
return;
do {
res=class_device_create_file(&vdev->class_dev,
&class_device_attr_version);
if (res<0)
break;
res=class_device_create_file(&vdev->class_dev,
&class_device_attr_model);
if (res<0)
break;
res=class_device_create_file(&vdev->class_dev,
&class_device_attr_hue);
if (res<0)
break;
res=class_device_create_file(&vdev->class_dev,
&class_device_attr_contrast);
if (res<0)
break;
res=class_device_create_file(&vdev->class_dev,
&class_device_attr_brightness);
if (res<0)
break;
res=class_device_create_file(&vdev->class_dev,
&class_device_attr_saturation);
if (res<0)
break;
res=class_device_create_file(&vdev->class_dev,
&class_device_attr_streaming);
if (res<0)
break;
res=class_device_create_file(&vdev->class_dev,
&class_device_attr_compression);
if (res<0)
break;
res=class_device_create_file(&vdev->class_dev,
&class_device_attr_bridge);
if (res>=0)
return;
} while (0);
err("%s error: %d\n", __FUNCTION__, res);
}
static void usbvision_remove_sysfs(struct video_device *vdev)
{
if (vdev) {
video_device_remove_file(vdev, &class_device_attr_version);
video_device_remove_file(vdev, &class_device_attr_model);
video_device_remove_file(vdev, &class_device_attr_hue);
video_device_remove_file(vdev, &class_device_attr_contrast);
video_device_remove_file(vdev, &class_device_attr_brightness);
video_device_remove_file(vdev, &class_device_attr_saturation);
video_device_remove_file(vdev, &class_device_attr_streaming);
video_device_remove_file(vdev, &class_device_attr_compression);
video_device_remove_file(vdev, &class_device_attr_bridge);
class_device_remove_file(&vdev->class_dev,
&class_device_attr_version);
class_device_remove_file(&vdev->class_dev,
&class_device_attr_model);
class_device_remove_file(&vdev->class_dev,
&class_device_attr_hue);
class_device_remove_file(&vdev->class_dev,
&class_device_attr_contrast);
class_device_remove_file(&vdev->class_dev,
&class_device_attr_brightness);
class_device_remove_file(&vdev->class_dev,
&class_device_attr_saturation);
class_device_remove_file(&vdev->class_dev,
&class_device_attr_streaming);
class_device_remove_file(&vdev->class_dev,
&class_device_attr_compression);
class_device_remove_file(&vdev->class_dev,
&class_device_attr_bridge);
}
}
......@@ -1933,22 +1977,22 @@ static void customdevice_process(void)
{
case 'P':
PDEBUG(DBG_PROBE, "VideoNorm=PAL");
usbvision_device_data[0].VideoNorm=VIDEO_MODE_PAL;
usbvision_device_data[0].VideoNorm=V4L2_STD_PAL;
break;
case 'S':
PDEBUG(DBG_PROBE, "VideoNorm=SECAM");
usbvision_device_data[0].VideoNorm=VIDEO_MODE_SECAM;
usbvision_device_data[0].VideoNorm=V4L2_STD_SECAM;
break;
case 'N':
PDEBUG(DBG_PROBE, "VideoNorm=NTSC");
usbvision_device_data[0].VideoNorm=VIDEO_MODE_NTSC;
usbvision_device_data[0].VideoNorm=V4L2_STD_NTSC;
break;
default:
PDEBUG(DBG_PROBE, "VideoNorm=PAL (by default)");
usbvision_device_data[0].VideoNorm=VIDEO_MODE_PAL;
usbvision_device_data[0].VideoNorm=V4L2_STD_PAL;
break;
}
goto2next(parse);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment