aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/usbvision/usbvision-video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-video.c')
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c113
1 files changed, 48 insertions, 65 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index cd6c41d67899..b977116a0dd9 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -53,7 +53,6 @@
53#include <linux/mm.h> 53#include <linux/mm.h>
54#include <linux/utsname.h> 54#include <linux/utsname.h>
55#include <linux/highmem.h> 55#include <linux/highmem.h>
56#include <linux/videodev.h>
57#include <linux/vmalloc.h> 56#include <linux/vmalloc.h>
58#include <linux/module.h> 57#include <linux/module.h>
59#include <linux/init.h> 58#include <linux/init.h>
@@ -65,8 +64,8 @@
65 64
66#include <media/saa7115.h> 65#include <media/saa7115.h>
67#include <media/v4l2-common.h> 66#include <media/v4l2-common.h>
67#include <media/v4l2-ioctl.h>
68#include <media/tuner.h> 68#include <media/tuner.h>
69#include <media/audiochip.h>
70 69
71#include <linux/workqueue.h> 70#include <linux/workqueue.h>
72 71
@@ -184,7 +183,7 @@ MODULE_ALIAS(DRIVER_ALIAS);
184static inline struct usb_usbvision *cd_to_usbvision(struct device *cd) 183static inline struct usb_usbvision *cd_to_usbvision(struct device *cd)
185{ 184{
186 struct video_device *vdev = 185 struct video_device *vdev =
187 container_of(cd, struct video_device, class_dev); 186 container_of(cd, struct video_device, dev);
188 return video_get_drvdata(vdev); 187 return video_get_drvdata(vdev);
189} 188}
190 189
@@ -199,7 +198,7 @@ static ssize_t show_model(struct device *cd,
199 struct device_attribute *attr, char *buf) 198 struct device_attribute *attr, char *buf)
200{ 199{
201 struct video_device *vdev = 200 struct video_device *vdev =
202 container_of(cd, struct video_device, class_dev); 201 container_of(cd, struct video_device, dev);
203 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 202 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
204 return sprintf(buf, "%s\n", 203 return sprintf(buf, "%s\n",
205 usbvision_device_data[usbvision->DevModel].ModelString); 204 usbvision_device_data[usbvision->DevModel].ModelString);
@@ -210,7 +209,7 @@ static ssize_t show_hue(struct device *cd,
210 struct device_attribute *attr, char *buf) 209 struct device_attribute *attr, char *buf)
211{ 210{
212 struct video_device *vdev = 211 struct video_device *vdev =
213 container_of(cd, struct video_device, class_dev); 212 container_of(cd, struct video_device, dev);
214 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 213 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
215 struct v4l2_control ctrl; 214 struct v4l2_control ctrl;
216 ctrl.id = V4L2_CID_HUE; 215 ctrl.id = V4L2_CID_HUE;
@@ -225,7 +224,7 @@ static ssize_t show_contrast(struct device *cd,
225 struct device_attribute *attr, char *buf) 224 struct device_attribute *attr, char *buf)
226{ 225{
227 struct video_device *vdev = 226 struct video_device *vdev =
228 container_of(cd, struct video_device, class_dev); 227 container_of(cd, struct video_device, dev);
229 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 228 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
230 struct v4l2_control ctrl; 229 struct v4l2_control ctrl;
231 ctrl.id = V4L2_CID_CONTRAST; 230 ctrl.id = V4L2_CID_CONTRAST;
@@ -240,7 +239,7 @@ static ssize_t show_brightness(struct device *cd,
240 struct device_attribute *attr, char *buf) 239 struct device_attribute *attr, char *buf)
241{ 240{
242 struct video_device *vdev = 241 struct video_device *vdev =
243 container_of(cd, struct video_device, class_dev); 242 container_of(cd, struct video_device, dev);
244 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 243 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
245 struct v4l2_control ctrl; 244 struct v4l2_control ctrl;
246 ctrl.id = V4L2_CID_BRIGHTNESS; 245 ctrl.id = V4L2_CID_BRIGHTNESS;
@@ -255,7 +254,7 @@ static ssize_t show_saturation(struct device *cd,
255 struct device_attribute *attr, char *buf) 254 struct device_attribute *attr, char *buf)
256{ 255{
257 struct video_device *vdev = 256 struct video_device *vdev =
258 container_of(cd, struct video_device, class_dev); 257 container_of(cd, struct video_device, dev);
259 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 258 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
260 struct v4l2_control ctrl; 259 struct v4l2_control ctrl;
261 ctrl.id = V4L2_CID_SATURATION; 260 ctrl.id = V4L2_CID_SATURATION;
@@ -270,7 +269,7 @@ static ssize_t show_streaming(struct device *cd,
270 struct device_attribute *attr, char *buf) 269 struct device_attribute *attr, char *buf)
271{ 270{
272 struct video_device *vdev = 271 struct video_device *vdev =
273 container_of(cd, struct video_device, class_dev); 272 container_of(cd, struct video_device, dev);
274 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 273 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
275 return sprintf(buf, "%s\n", 274 return sprintf(buf, "%s\n",
276 YES_NO(usbvision->streaming==Stream_On?1:0)); 275 YES_NO(usbvision->streaming==Stream_On?1:0));
@@ -281,7 +280,7 @@ static ssize_t show_compression(struct device *cd,
281 struct device_attribute *attr, char *buf) 280 struct device_attribute *attr, char *buf)
282{ 281{
283 struct video_device *vdev = 282 struct video_device *vdev =
284 container_of(cd, struct video_device, class_dev); 283 container_of(cd, struct video_device, dev);
285 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 284 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
286 return sprintf(buf, "%s\n", 285 return sprintf(buf, "%s\n",
287 YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS)); 286 YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS));
@@ -292,7 +291,7 @@ static ssize_t show_device_bridge(struct device *cd,
292 struct device_attribute *attr, char *buf) 291 struct device_attribute *attr, char *buf)
293{ 292{
294 struct video_device *vdev = 293 struct video_device *vdev =
295 container_of(cd, struct video_device, class_dev); 294 container_of(cd, struct video_device, dev);
296 struct usb_usbvision *usbvision = video_get_drvdata(vdev); 295 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
297 return sprintf(buf, "%d\n", usbvision->bridgeType); 296 return sprintf(buf, "%d\n", usbvision->bridgeType);
298} 297}
@@ -304,40 +303,31 @@ static void usbvision_create_sysfs(struct video_device *vdev)
304 if (!vdev) 303 if (!vdev)
305 return; 304 return;
306 do { 305 do {
307 res = device_create_file(&vdev->class_dev, 306 res = device_create_file(&vdev->dev, &dev_attr_version);
308 &dev_attr_version);
309 if (res<0) 307 if (res<0)
310 break; 308 break;
311 res = device_create_file(&vdev->class_dev, 309 res = device_create_file(&vdev->dev, &dev_attr_model);
312 &dev_attr_model);
313 if (res<0) 310 if (res<0)
314 break; 311 break;
315 res = device_create_file(&vdev->class_dev, 312 res = device_create_file(&vdev->dev, &dev_attr_hue);
316 &dev_attr_hue);
317 if (res<0) 313 if (res<0)
318 break; 314 break;
319 res = device_create_file(&vdev->class_dev, 315 res = device_create_file(&vdev->dev, &dev_attr_contrast);
320 &dev_attr_contrast);
321 if (res<0) 316 if (res<0)
322 break; 317 break;
323 res = device_create_file(&vdev->class_dev, 318 res = device_create_file(&vdev->dev, &dev_attr_brightness);
324 &dev_attr_brightness);
325 if (res<0) 319 if (res<0)
326 break; 320 break;
327 res = device_create_file(&vdev->class_dev, 321 res = device_create_file(&vdev->dev, &dev_attr_saturation);
328 &dev_attr_saturation);
329 if (res<0) 322 if (res<0)
330 break; 323 break;
331 res = device_create_file(&vdev->class_dev, 324 res = device_create_file(&vdev->dev, &dev_attr_streaming);
332 &dev_attr_streaming);
333 if (res<0) 325 if (res<0)
334 break; 326 break;
335 res = device_create_file(&vdev->class_dev, 327 res = device_create_file(&vdev->dev, &dev_attr_compression);
336 &dev_attr_compression);
337 if (res<0) 328 if (res<0)
338 break; 329 break;
339 res = device_create_file(&vdev->class_dev, 330 res = device_create_file(&vdev->dev, &dev_attr_bridge);
340 &dev_attr_bridge);
341 if (res>=0) 331 if (res>=0)
342 return; 332 return;
343 } while (0); 333 } while (0);
@@ -348,24 +338,15 @@ static void usbvision_create_sysfs(struct video_device *vdev)
348static void usbvision_remove_sysfs(struct video_device *vdev) 338static void usbvision_remove_sysfs(struct video_device *vdev)
349{ 339{
350 if (vdev) { 340 if (vdev) {
351 device_remove_file(&vdev->class_dev, 341 device_remove_file(&vdev->dev, &dev_attr_version);
352 &dev_attr_version); 342 device_remove_file(&vdev->dev, &dev_attr_model);
353 device_remove_file(&vdev->class_dev, 343 device_remove_file(&vdev->dev, &dev_attr_hue);
354 &dev_attr_model); 344 device_remove_file(&vdev->dev, &dev_attr_contrast);
355 device_remove_file(&vdev->class_dev, 345 device_remove_file(&vdev->dev, &dev_attr_brightness);
356 &dev_attr_hue); 346 device_remove_file(&vdev->dev, &dev_attr_saturation);
357 device_remove_file(&vdev->class_dev, 347 device_remove_file(&vdev->dev, &dev_attr_streaming);
358 &dev_attr_contrast); 348 device_remove_file(&vdev->dev, &dev_attr_compression);
359 device_remove_file(&vdev->class_dev, 349 device_remove_file(&vdev->dev, &dev_attr_bridge);
360 &dev_attr_brightness);
361 device_remove_file(&vdev->class_dev,
362 &dev_attr_saturation);
363 device_remove_file(&vdev->class_dev,
364 &dev_attr_streaming);
365 device_remove_file(&vdev->class_dev,
366 &dev_attr_compression);
367 device_remove_file(&vdev->class_dev,
368 &dev_attr_bridge);
369 } 350 }
370} 351}
371 352
@@ -1388,13 +1369,8 @@ static const struct file_operations usbvision_fops = {
1388/* .poll = video_poll, */ 1369/* .poll = video_poll, */
1389 .compat_ioctl = v4l_compat_ioctl32, 1370 .compat_ioctl = v4l_compat_ioctl32,
1390}; 1371};
1391static struct video_device usbvision_video_template = { 1372
1392 .owner = THIS_MODULE, 1373static const struct v4l2_ioctl_ops usbvision_ioctl_ops = {
1393 .type = VID_TYPE_TUNER | VID_TYPE_CAPTURE,
1394 .fops = &usbvision_fops,
1395 .name = "usbvision-video",
1396 .release = video_device_release,
1397 .minor = -1,
1398 .vidioc_querycap = vidioc_querycap, 1374 .vidioc_querycap = vidioc_querycap,
1399 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, 1375 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1400 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1376 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
@@ -1426,6 +1402,14 @@ static struct video_device usbvision_video_template = {
1426 .vidioc_g_register = vidioc_g_register, 1402 .vidioc_g_register = vidioc_g_register,
1427 .vidioc_s_register = vidioc_s_register, 1403 .vidioc_s_register = vidioc_s_register,
1428#endif 1404#endif
1405};
1406
1407static struct video_device usbvision_video_template = {
1408 .fops = &usbvision_fops,
1409 .ioctl_ops = &usbvision_ioctl_ops,
1410 .name = "usbvision-video",
1411 .release = video_device_release,
1412 .minor = -1,
1429 .tvnorms = USBVISION_NORMS, 1413 .tvnorms = USBVISION_NORMS,
1430 .current_norm = V4L2_STD_PAL 1414 .current_norm = V4L2_STD_PAL
1431}; 1415};
@@ -1441,14 +1425,7 @@ static const struct file_operations usbvision_radio_fops = {
1441 .compat_ioctl = v4l_compat_ioctl32, 1425 .compat_ioctl = v4l_compat_ioctl32,
1442}; 1426};
1443 1427
1444static struct video_device usbvision_radio_template= 1428static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = {
1445{
1446 .owner = THIS_MODULE,
1447 .type = VID_TYPE_TUNER,
1448 .fops = &usbvision_radio_fops,
1449 .name = "usbvision-radio",
1450 .release = video_device_release,
1451 .minor = -1,
1452 .vidioc_querycap = vidioc_querycap, 1429 .vidioc_querycap = vidioc_querycap,
1453 .vidioc_enum_input = vidioc_enum_input, 1430 .vidioc_enum_input = vidioc_enum_input,
1454 .vidioc_g_input = vidioc_g_input, 1431 .vidioc_g_input = vidioc_g_input,
@@ -1462,6 +1439,14 @@ static struct video_device usbvision_radio_template=
1462 .vidioc_s_tuner = vidioc_s_tuner, 1439 .vidioc_s_tuner = vidioc_s_tuner,
1463 .vidioc_g_frequency = vidioc_g_frequency, 1440 .vidioc_g_frequency = vidioc_g_frequency,
1464 .vidioc_s_frequency = vidioc_s_frequency, 1441 .vidioc_s_frequency = vidioc_s_frequency,
1442};
1443
1444static struct video_device usbvision_radio_template = {
1445 .fops = &usbvision_radio_fops,
1446 .name = "usbvision-radio",
1447 .release = video_device_release,
1448 .minor = -1,
1449 .ioctl_ops = &usbvision_radio_ioctl_ops,
1465 1450
1466 .tvnorms = USBVISION_NORMS, 1451 .tvnorms = USBVISION_NORMS,
1467 .current_norm = V4L2_STD_PAL 1452 .current_norm = V4L2_STD_PAL
@@ -1479,8 +1464,6 @@ static const struct file_operations usbvision_vbi_fops = {
1479 1464
1480static struct video_device usbvision_vbi_template= 1465static struct video_device usbvision_vbi_template=
1481{ 1466{
1482 .owner = THIS_MODULE,
1483 .type = VID_TYPE_TUNER,
1484 .fops = &usbvision_vbi_fops, 1467 .fops = &usbvision_vbi_fops,
1485 .release = video_device_release, 1468 .release = video_device_release,
1486 .name = "usbvision-vbi", 1469 .name = "usbvision-vbi",
@@ -1506,7 +1489,7 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision,
1506 } 1489 }
1507 *vdev = *vdev_template; 1490 *vdev = *vdev_template;
1508// vdev->minor = -1; 1491// vdev->minor = -1;
1509 vdev->dev = &usb_dev->dev; 1492 vdev->parent = &usb_dev->dev;
1510 snprintf(vdev->name, sizeof(vdev->name), "%s", name); 1493 snprintf(vdev->name, sizeof(vdev->name), "%s", name);
1511 video_set_drvdata(vdev, usbvision); 1494 video_set_drvdata(vdev, usbvision);
1512 return vdev; 1495 return vdev;