diff options
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-video.c')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-video.c | 625 |
1 files changed, 279 insertions, 346 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index 011c0c386995..6083137f0bf8 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -56,7 +56,7 @@ | |||
56 | #include <linux/module.h> | 56 | #include <linux/module.h> |
57 | #include <linux/init.h> | 57 | #include <linux/init.h> |
58 | #include <linux/spinlock.h> | 58 | #include <linux/spinlock.h> |
59 | #include <asm/io.h> | 59 | #include <linux/io.h> |
60 | #include <linux/videodev2.h> | 60 | #include <linux/videodev2.h> |
61 | #include <linux/i2c.h> | 61 | #include <linux/i2c.h> |
62 | 62 | ||
@@ -70,8 +70,8 @@ | |||
70 | #include "usbvision.h" | 70 | #include "usbvision.h" |
71 | #include "usbvision-cards.h" | 71 | #include "usbvision-cards.h" |
72 | 72 | ||
73 | #define DRIVER_AUTHOR "Joerg Heckenbach <joerg@heckenbach-aw.de>,\ | 73 | #define DRIVER_AUTHOR "Joerg Heckenbach <joerg@heckenbach-aw.de>, \ |
74 | Dwaine Garden <DwaineGarden@rogers.com>" | 74 | Dwaine Garden <DwaineGarden@rogers.com>" |
75 | #define DRIVER_NAME "usbvision" | 75 | #define DRIVER_NAME "usbvision" |
76 | #define DRIVER_ALIAS "USBVision" | 76 | #define DRIVER_ALIAS "USBVision" |
77 | #define DRIVER_DESC "USBVision USB Video Device Driver for Linux" | 77 | #define DRIVER_DESC "USBVision USB Video Device Driver for Linux" |
@@ -82,9 +82,9 @@ | |||
82 | #define USBVISION_DRIVER_VERSION KERNEL_VERSION(USBVISION_DRIVER_VERSION_MAJOR,\ | 82 | #define USBVISION_DRIVER_VERSION KERNEL_VERSION(USBVISION_DRIVER_VERSION_MAJOR,\ |
83 | USBVISION_DRIVER_VERSION_MINOR,\ | 83 | USBVISION_DRIVER_VERSION_MINOR,\ |
84 | USBVISION_DRIVER_VERSION_PATCHLEVEL) | 84 | USBVISION_DRIVER_VERSION_PATCHLEVEL) |
85 | #define USBVISION_VERSION_STRING __stringify(USBVISION_DRIVER_VERSION_MAJOR)\ | 85 | #define USBVISION_VERSION_STRING __stringify(USBVISION_DRIVER_VERSION_MAJOR) \ |
86 | "." __stringify(USBVISION_DRIVER_VERSION_MINOR)\ | 86 | "." __stringify(USBVISION_DRIVER_VERSION_MINOR) \ |
87 | "." __stringify(USBVISION_DRIVER_VERSION_PATCHLEVEL) | 87 | "." __stringify(USBVISION_DRIVER_VERSION_PATCHLEVEL) |
88 | 88 | ||
89 | #define ENABLE_HEXDUMP 0 /* Enable if you need it */ | 89 | #define ENABLE_HEXDUMP 0 /* Enable if you need it */ |
90 | 90 | ||
@@ -96,16 +96,16 @@ USBVISION_DRIVER_VERSION_PATCHLEVEL) | |||
96 | __func__, __LINE__ , ## args); \ | 96 | __func__, __LINE__ , ## args); \ |
97 | } | 97 | } |
98 | #else | 98 | #else |
99 | #define PDEBUG(level, fmt, args...) do {} while(0) | 99 | #define PDEBUG(level, fmt, args...) do {} while (0) |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | #define DBG_IO 1<<1 | 102 | #define DBG_IO (1 << 1) |
103 | #define DBG_PROBE 1<<2 | 103 | #define DBG_PROBE (1 << 2) |
104 | #define DBG_MMAP 1<<3 | 104 | #define DBG_MMAP (1 << 3) |
105 | 105 | ||
106 | //String operations | 106 | /* String operations */ |
107 | #define rmspace(str) while(*str==' ') str++; | 107 | #define rmspace(str) while (*str == ' ') str++; |
108 | #define goto2next(str) while(*str!=' ') str++; while(*str==' ') str++; | 108 | #define goto2next(str) while (*str != ' ') str++; while (*str == ' ') str++; |
109 | 109 | ||
110 | 110 | ||
111 | /* sequential number of usbvision device */ | 111 | /* sequential number of usbvision device */ |
@@ -118,7 +118,7 @@ static struct usbvision_v4l2_format_st usbvision_v4l2_format[] = { | |||
118 | { 1, 4, 32, V4L2_PIX_FMT_RGB32 , "RGB32" }, | 118 | { 1, 4, 32, V4L2_PIX_FMT_RGB32 , "RGB32" }, |
119 | { 1, 2, 16, V4L2_PIX_FMT_RGB555 , "RGB555" }, | 119 | { 1, 2, 16, V4L2_PIX_FMT_RGB555 , "RGB555" }, |
120 | { 1, 2, 16, V4L2_PIX_FMT_YUYV , "YUV422" }, | 120 | { 1, 2, 16, V4L2_PIX_FMT_YUYV , "YUV422" }, |
121 | { 1, 2, 12, V4L2_PIX_FMT_YVU420 , "YUV420P" }, // 1.5 ! | 121 | { 1, 2, 12, V4L2_PIX_FMT_YVU420 , "YUV420P" }, /* 1.5 ! */ |
122 | { 1, 2, 16, V4L2_PIX_FMT_YUV422P , "YUV422P" } | 122 | { 1, 2, 16, V4L2_PIX_FMT_YUV422P , "YUV422P" } |
123 | }; | 123 | }; |
124 | 124 | ||
@@ -127,11 +127,11 @@ static void usbvision_release(struct usb_usbvision *usbvision); | |||
127 | 127 | ||
128 | /* Default initialization of device driver parameters */ | 128 | /* Default initialization of device driver parameters */ |
129 | /* Set the default format for ISOC endpoint */ | 129 | /* Set the default format for ISOC endpoint */ |
130 | static int isocMode = ISOC_MODE_COMPRESS; | 130 | static int isoc_mode = ISOC_MODE_COMPRESS; |
131 | /* Set the default Debug Mode of the device driver */ | 131 | /* Set the default Debug Mode of the device driver */ |
132 | static int video_debug; | 132 | static int video_debug; |
133 | /* Set the default device to power on at startup */ | 133 | /* Set the default device to power on at startup */ |
134 | static int PowerOnAtOpen = 1; | 134 | static int power_on_at_open = 1; |
135 | /* Sequential Number of Video Device */ | 135 | /* Sequential Number of Video Device */ |
136 | static int video_nr = -1; | 136 | static int video_nr = -1; |
137 | /* Sequential Number of Radio Device */ | 137 | /* Sequential Number of Radio Device */ |
@@ -140,20 +140,20 @@ static int radio_nr = -1; | |||
140 | /* Grab parameters for the device driver */ | 140 | /* Grab parameters for the device driver */ |
141 | 141 | ||
142 | /* Showing parameters under SYSFS */ | 142 | /* Showing parameters under SYSFS */ |
143 | module_param(isocMode, int, 0444); | 143 | module_param(isoc_mode, int, 0444); |
144 | module_param(video_debug, int, 0444); | 144 | module_param(video_debug, int, 0444); |
145 | module_param(PowerOnAtOpen, int, 0444); | 145 | module_param(power_on_at_open, int, 0444); |
146 | module_param(video_nr, int, 0444); | 146 | module_param(video_nr, int, 0444); |
147 | module_param(radio_nr, int, 0444); | 147 | module_param(radio_nr, int, 0444); |
148 | 148 | ||
149 | MODULE_PARM_DESC(isocMode, " Set the default format for ISOC endpoint. Default: 0x60 (Compression On)"); | 149 | MODULE_PARM_DESC(isoc_mode, " Set the default format for ISOC endpoint. Default: 0x60 (Compression On)"); |
150 | MODULE_PARM_DESC(video_debug, " Set the default Debug Mode of the device driver. Default: 0 (Off)"); | 150 | MODULE_PARM_DESC(video_debug, " Set the default Debug Mode of the device driver. Default: 0 (Off)"); |
151 | MODULE_PARM_DESC(PowerOnAtOpen, " Set the default device to power on when device is opened. Default: 1 (On)"); | 151 | MODULE_PARM_DESC(power_on_at_open, " Set the default device to power on when device is opened. Default: 1 (On)"); |
152 | MODULE_PARM_DESC(video_nr, "Set video device number (/dev/videoX). Default: -1 (autodetect)"); | 152 | MODULE_PARM_DESC(video_nr, "Set video device number (/dev/videoX). Default: -1 (autodetect)"); |
153 | MODULE_PARM_DESC(radio_nr, "Set radio device number (/dev/radioX). Default: -1 (autodetect)"); | 153 | MODULE_PARM_DESC(radio_nr, "Set radio device number (/dev/radioX). Default: -1 (autodetect)"); |
154 | 154 | ||
155 | 155 | ||
156 | // Misc stuff | 156 | /* Misc stuff */ |
157 | MODULE_AUTHOR(DRIVER_AUTHOR); | 157 | MODULE_AUTHOR(DRIVER_AUTHOR); |
158 | MODULE_DESCRIPTION(DRIVER_DESC); | 158 | MODULE_DESCRIPTION(DRIVER_DESC); |
159 | MODULE_LICENSE(DRIVER_LICENSE); | 159 | MODULE_LICENSE(DRIVER_LICENSE); |
@@ -192,7 +192,7 @@ static ssize_t show_model(struct device *cd, | |||
192 | container_of(cd, struct video_device, dev); | 192 | container_of(cd, struct video_device, dev); |
193 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 193 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
194 | return sprintf(buf, "%s\n", | 194 | return sprintf(buf, "%s\n", |
195 | usbvision_device_data[usbvision->DevModel].ModelString); | 195 | usbvision_device_data[usbvision->dev_model].model_string); |
196 | } | 196 | } |
197 | static DEVICE_ATTR(model, S_IRUGO, show_model, NULL); | 197 | static DEVICE_ATTR(model, S_IRUGO, show_model, NULL); |
198 | 198 | ||
@@ -205,7 +205,7 @@ static ssize_t show_hue(struct device *cd, | |||
205 | struct v4l2_control ctrl; | 205 | struct v4l2_control ctrl; |
206 | ctrl.id = V4L2_CID_HUE; | 206 | ctrl.id = V4L2_CID_HUE; |
207 | ctrl.value = 0; | 207 | ctrl.value = 0; |
208 | if(usbvision->user) | 208 | if (usbvision->user) |
209 | call_all(usbvision, core, g_ctrl, &ctrl); | 209 | call_all(usbvision, core, g_ctrl, &ctrl); |
210 | return sprintf(buf, "%d\n", ctrl.value); | 210 | return sprintf(buf, "%d\n", ctrl.value); |
211 | } | 211 | } |
@@ -220,7 +220,7 @@ static ssize_t show_contrast(struct device *cd, | |||
220 | struct v4l2_control ctrl; | 220 | struct v4l2_control ctrl; |
221 | ctrl.id = V4L2_CID_CONTRAST; | 221 | ctrl.id = V4L2_CID_CONTRAST; |
222 | ctrl.value = 0; | 222 | ctrl.value = 0; |
223 | if(usbvision->user) | 223 | if (usbvision->user) |
224 | call_all(usbvision, core, g_ctrl, &ctrl); | 224 | call_all(usbvision, core, g_ctrl, &ctrl); |
225 | return sprintf(buf, "%d\n", ctrl.value); | 225 | return sprintf(buf, "%d\n", ctrl.value); |
226 | } | 226 | } |
@@ -235,7 +235,7 @@ static ssize_t show_brightness(struct device *cd, | |||
235 | struct v4l2_control ctrl; | 235 | struct v4l2_control ctrl; |
236 | ctrl.id = V4L2_CID_BRIGHTNESS; | 236 | ctrl.id = V4L2_CID_BRIGHTNESS; |
237 | ctrl.value = 0; | 237 | ctrl.value = 0; |
238 | if(usbvision->user) | 238 | if (usbvision->user) |
239 | call_all(usbvision, core, g_ctrl, &ctrl); | 239 | call_all(usbvision, core, g_ctrl, &ctrl); |
240 | return sprintf(buf, "%d\n", ctrl.value); | 240 | return sprintf(buf, "%d\n", ctrl.value); |
241 | } | 241 | } |
@@ -250,7 +250,7 @@ static ssize_t show_saturation(struct device *cd, | |||
250 | struct v4l2_control ctrl; | 250 | struct v4l2_control ctrl; |
251 | ctrl.id = V4L2_CID_SATURATION; | 251 | ctrl.id = V4L2_CID_SATURATION; |
252 | ctrl.value = 0; | 252 | ctrl.value = 0; |
253 | if(usbvision->user) | 253 | if (usbvision->user) |
254 | call_all(usbvision, core, g_ctrl, &ctrl); | 254 | call_all(usbvision, core, g_ctrl, &ctrl); |
255 | return sprintf(buf, "%d\n", ctrl.value); | 255 | return sprintf(buf, "%d\n", ctrl.value); |
256 | } | 256 | } |
@@ -263,7 +263,7 @@ static ssize_t show_streaming(struct device *cd, | |||
263 | container_of(cd, struct video_device, dev); | 263 | container_of(cd, struct video_device, dev); |
264 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 264 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
265 | return sprintf(buf, "%s\n", | 265 | return sprintf(buf, "%s\n", |
266 | YES_NO(usbvision->streaming==Stream_On?1:0)); | 266 | YES_NO(usbvision->streaming == stream_on ? 1 : 0)); |
267 | } | 267 | } |
268 | static DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); | 268 | static DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); |
269 | 269 | ||
@@ -274,7 +274,7 @@ static ssize_t show_compression(struct device *cd, | |||
274 | container_of(cd, struct video_device, dev); | 274 | container_of(cd, struct video_device, dev); |
275 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 275 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
276 | return sprintf(buf, "%s\n", | 276 | return sprintf(buf, "%s\n", |
277 | YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS)); | 277 | YES_NO(usbvision->isoc_mode == ISOC_MODE_COMPRESS)); |
278 | } | 278 | } |
279 | static DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); | 279 | static DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); |
280 | 280 | ||
@@ -284,42 +284,43 @@ static ssize_t show_device_bridge(struct device *cd, | |||
284 | struct video_device *vdev = | 284 | struct video_device *vdev = |
285 | container_of(cd, struct video_device, dev); | 285 | container_of(cd, struct video_device, dev); |
286 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 286 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
287 | return sprintf(buf, "%d\n", usbvision->bridgeType); | 287 | return sprintf(buf, "%d\n", usbvision->bridge_type); |
288 | } | 288 | } |
289 | static DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL); | 289 | static DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL); |
290 | 290 | ||
291 | static void usbvision_create_sysfs(struct video_device *vdev) | 291 | static void usbvision_create_sysfs(struct video_device *vdev) |
292 | { | 292 | { |
293 | int res; | 293 | int res; |
294 | |||
294 | if (!vdev) | 295 | if (!vdev) |
295 | return; | 296 | return; |
296 | do { | 297 | do { |
297 | res = device_create_file(&vdev->dev, &dev_attr_version); | 298 | res = device_create_file(&vdev->dev, &dev_attr_version); |
298 | if (res<0) | 299 | if (res < 0) |
299 | break; | 300 | break; |
300 | res = device_create_file(&vdev->dev, &dev_attr_model); | 301 | res = device_create_file(&vdev->dev, &dev_attr_model); |
301 | if (res<0) | 302 | if (res < 0) |
302 | break; | 303 | break; |
303 | res = device_create_file(&vdev->dev, &dev_attr_hue); | 304 | res = device_create_file(&vdev->dev, &dev_attr_hue); |
304 | if (res<0) | 305 | if (res < 0) |
305 | break; | 306 | break; |
306 | res = device_create_file(&vdev->dev, &dev_attr_contrast); | 307 | res = device_create_file(&vdev->dev, &dev_attr_contrast); |
307 | if (res<0) | 308 | if (res < 0) |
308 | break; | 309 | break; |
309 | res = device_create_file(&vdev->dev, &dev_attr_brightness); | 310 | res = device_create_file(&vdev->dev, &dev_attr_brightness); |
310 | if (res<0) | 311 | if (res < 0) |
311 | break; | 312 | break; |
312 | res = device_create_file(&vdev->dev, &dev_attr_saturation); | 313 | res = device_create_file(&vdev->dev, &dev_attr_saturation); |
313 | if (res<0) | 314 | if (res < 0) |
314 | break; | 315 | break; |
315 | res = device_create_file(&vdev->dev, &dev_attr_streaming); | 316 | res = device_create_file(&vdev->dev, &dev_attr_streaming); |
316 | if (res<0) | 317 | if (res < 0) |
317 | break; | 318 | break; |
318 | res = device_create_file(&vdev->dev, &dev_attr_compression); | 319 | res = device_create_file(&vdev->dev, &dev_attr_compression); |
319 | if (res<0) | 320 | if (res < 0) |
320 | break; | 321 | break; |
321 | res = device_create_file(&vdev->dev, &dev_attr_bridge); | 322 | res = device_create_file(&vdev->dev, &dev_attr_bridge); |
322 | if (res>=0) | 323 | if (res >= 0) |
323 | return; | 324 | return; |
324 | } while (0); | 325 | } while (0); |
325 | 326 | ||
@@ -352,24 +353,23 @@ static void usbvision_remove_sysfs(struct video_device *vdev) | |||
352 | static int usbvision_v4l2_open(struct file *file) | 353 | static int usbvision_v4l2_open(struct file *file) |
353 | { | 354 | { |
354 | struct usb_usbvision *usbvision = video_drvdata(file); | 355 | struct usb_usbvision *usbvision = video_drvdata(file); |
355 | int errCode = 0; | 356 | int err_code = 0; |
356 | 357 | ||
357 | PDEBUG(DBG_IO, "open"); | 358 | PDEBUG(DBG_IO, "open"); |
358 | 359 | ||
359 | mutex_lock(&usbvision->lock); | 360 | usbvision_reset_power_off_timer(usbvision); |
360 | usbvision_reset_powerOffTimer(usbvision); | ||
361 | 361 | ||
362 | if (usbvision->user) | 362 | if (usbvision->user) |
363 | errCode = -EBUSY; | 363 | err_code = -EBUSY; |
364 | else { | 364 | else { |
365 | /* Allocate memory for the scratch ring buffer */ | 365 | /* Allocate memory for the scratch ring buffer */ |
366 | errCode = usbvision_scratch_alloc(usbvision); | 366 | err_code = usbvision_scratch_alloc(usbvision); |
367 | if (isocMode==ISOC_MODE_COMPRESS) { | 367 | if (isoc_mode == ISOC_MODE_COMPRESS) { |
368 | /* Allocate intermediate decompression buffers | 368 | /* Allocate intermediate decompression buffers |
369 | only if needed */ | 369 | only if needed */ |
370 | errCode = usbvision_decompress_alloc(usbvision); | 370 | err_code = usbvision_decompress_alloc(usbvision); |
371 | } | 371 | } |
372 | if (errCode) { | 372 | if (err_code) { |
373 | /* Deallocate all buffers if trouble */ | 373 | /* Deallocate all buffers if trouble */ |
374 | usbvision_scratch_free(usbvision); | 374 | usbvision_scratch_free(usbvision); |
375 | usbvision_decompress_free(usbvision); | 375 | usbvision_decompress_free(usbvision); |
@@ -377,7 +377,7 @@ static int usbvision_v4l2_open(struct file *file) | |||
377 | } | 377 | } |
378 | 378 | ||
379 | /* If so far no errors then we shall start the camera */ | 379 | /* If so far no errors then we shall start the camera */ |
380 | if (!errCode) { | 380 | if (!err_code) { |
381 | if (usbvision->power == 0) { | 381 | if (usbvision->power == 0) { |
382 | usbvision_power_on(usbvision); | 382 | usbvision_power_on(usbvision); |
383 | usbvision_i2c_register(usbvision); | 383 | usbvision_i2c_register(usbvision); |
@@ -386,21 +386,21 @@ static int usbvision_v4l2_open(struct file *file) | |||
386 | /* Send init sequence only once, it's large! */ | 386 | /* Send init sequence only once, it's large! */ |
387 | if (!usbvision->initialized) { | 387 | if (!usbvision->initialized) { |
388 | int setup_ok = 0; | 388 | int setup_ok = 0; |
389 | setup_ok = usbvision_setup(usbvision,isocMode); | 389 | setup_ok = usbvision_setup(usbvision, isoc_mode); |
390 | if (setup_ok) | 390 | if (setup_ok) |
391 | usbvision->initialized = 1; | 391 | usbvision->initialized = 1; |
392 | else | 392 | else |
393 | errCode = -EBUSY; | 393 | err_code = -EBUSY; |
394 | } | 394 | } |
395 | 395 | ||
396 | if (!errCode) { | 396 | if (!err_code) { |
397 | usbvision_begin_streaming(usbvision); | 397 | usbvision_begin_streaming(usbvision); |
398 | errCode = usbvision_init_isoc(usbvision); | 398 | err_code = usbvision_init_isoc(usbvision); |
399 | /* device must be initialized before isoc transfer */ | 399 | /* device must be initialized before isoc transfer */ |
400 | usbvision_muxsel(usbvision,0); | 400 | usbvision_muxsel(usbvision, 0); |
401 | usbvision->user++; | 401 | usbvision->user++; |
402 | } else { | 402 | } else { |
403 | if (PowerOnAtOpen) { | 403 | if (power_on_at_open) { |
404 | usbvision_i2c_unregister(usbvision); | 404 | usbvision_i2c_unregister(usbvision); |
405 | usbvision_power_off(usbvision); | 405 | usbvision_power_off(usbvision); |
406 | usbvision->initialized = 0; | 406 | usbvision->initialized = 0; |
@@ -412,8 +412,7 @@ static int usbvision_v4l2_open(struct file *file) | |||
412 | usbvision_empty_framequeues(usbvision); | 412 | usbvision_empty_framequeues(usbvision); |
413 | 413 | ||
414 | PDEBUG(DBG_IO, "success"); | 414 | PDEBUG(DBG_IO, "success"); |
415 | mutex_unlock(&usbvision->lock); | 415 | return err_code; |
416 | return errCode; | ||
417 | } | 416 | } |
418 | 417 | ||
419 | /* | 418 | /* |
@@ -429,7 +428,6 @@ static int usbvision_v4l2_close(struct file *file) | |||
429 | struct usb_usbvision *usbvision = video_drvdata(file); | 428 | struct usb_usbvision *usbvision = video_drvdata(file); |
430 | 429 | ||
431 | PDEBUG(DBG_IO, "close"); | 430 | PDEBUG(DBG_IO, "close"); |
432 | mutex_lock(&usbvision->lock); | ||
433 | 431 | ||
434 | usbvision_audio_off(usbvision); | 432 | usbvision_audio_off(usbvision); |
435 | usbvision_restart_isoc(usbvision); | 433 | usbvision_restart_isoc(usbvision); |
@@ -442,15 +440,13 @@ static int usbvision_v4l2_close(struct file *file) | |||
442 | 440 | ||
443 | usbvision->user--; | 441 | usbvision->user--; |
444 | 442 | ||
445 | if (PowerOnAtOpen) { | 443 | if (power_on_at_open) { |
446 | /* power off in a little while | 444 | /* power off in a little while |
447 | to avoid off/on every close/open short sequences */ | 445 | to avoid off/on every close/open short sequences */ |
448 | usbvision_set_powerOffTimer(usbvision); | 446 | usbvision_set_power_off_timer(usbvision); |
449 | usbvision->initialized = 0; | 447 | usbvision->initialized = 0; |
450 | } | 448 | } |
451 | 449 | ||
452 | mutex_unlock(&usbvision->lock); | ||
453 | |||
454 | if (usbvision->remove_pending) { | 450 | if (usbvision->remove_pending) { |
455 | printk(KERN_INFO "%s: Final disconnect\n", __func__); | 451 | printk(KERN_INFO "%s: Final disconnect\n", __func__); |
456 | usbvision_release(usbvision); | 452 | usbvision_release(usbvision); |
@@ -468,55 +464,55 @@ static int usbvision_v4l2_close(struct file *file) | |||
468 | * | 464 | * |
469 | */ | 465 | */ |
470 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 466 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
471 | static int vidioc_g_register (struct file *file, void *priv, | 467 | static int vidioc_g_register(struct file *file, void *priv, |
472 | struct v4l2_dbg_register *reg) | 468 | struct v4l2_dbg_register *reg) |
473 | { | 469 | { |
474 | struct usb_usbvision *usbvision = video_drvdata(file); | 470 | struct usb_usbvision *usbvision = video_drvdata(file); |
475 | int errCode; | 471 | int err_code; |
476 | 472 | ||
477 | if (!v4l2_chip_match_host(®->match)) | 473 | if (!v4l2_chip_match_host(®->match)) |
478 | return -EINVAL; | 474 | return -EINVAL; |
479 | /* NT100x has a 8-bit register space */ | 475 | /* NT100x has a 8-bit register space */ |
480 | errCode = usbvision_read_reg(usbvision, reg->reg&0xff); | 476 | err_code = usbvision_read_reg(usbvision, reg->reg&0xff); |
481 | if (errCode < 0) { | 477 | if (err_code < 0) { |
482 | dev_err(&usbvision->vdev->dev, | 478 | dev_err(&usbvision->vdev->dev, |
483 | "%s: VIDIOC_DBG_G_REGISTER failed: error %d\n", | 479 | "%s: VIDIOC_DBG_G_REGISTER failed: error %d\n", |
484 | __func__, errCode); | 480 | __func__, err_code); |
485 | return errCode; | 481 | return err_code; |
486 | } | 482 | } |
487 | reg->val = errCode; | 483 | reg->val = err_code; |
488 | reg->size = 1; | 484 | reg->size = 1; |
489 | return 0; | 485 | return 0; |
490 | } | 486 | } |
491 | 487 | ||
492 | static int vidioc_s_register (struct file *file, void *priv, | 488 | static int vidioc_s_register(struct file *file, void *priv, |
493 | struct v4l2_dbg_register *reg) | 489 | struct v4l2_dbg_register *reg) |
494 | { | 490 | { |
495 | struct usb_usbvision *usbvision = video_drvdata(file); | 491 | struct usb_usbvision *usbvision = video_drvdata(file); |
496 | int errCode; | 492 | int err_code; |
497 | 493 | ||
498 | if (!v4l2_chip_match_host(®->match)) | 494 | if (!v4l2_chip_match_host(®->match)) |
499 | return -EINVAL; | 495 | return -EINVAL; |
500 | /* NT100x has a 8-bit register space */ | 496 | /* NT100x has a 8-bit register space */ |
501 | errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); | 497 | err_code = usbvision_write_reg(usbvision, reg->reg & 0xff, reg->val); |
502 | if (errCode < 0) { | 498 | if (err_code < 0) { |
503 | dev_err(&usbvision->vdev->dev, | 499 | dev_err(&usbvision->vdev->dev, |
504 | "%s: VIDIOC_DBG_S_REGISTER failed: error %d\n", | 500 | "%s: VIDIOC_DBG_S_REGISTER failed: error %d\n", |
505 | __func__, errCode); | 501 | __func__, err_code); |
506 | return errCode; | 502 | return err_code; |
507 | } | 503 | } |
508 | return 0; | 504 | return 0; |
509 | } | 505 | } |
510 | #endif | 506 | #endif |
511 | 507 | ||
512 | static int vidioc_querycap (struct file *file, void *priv, | 508 | static int vidioc_querycap(struct file *file, void *priv, |
513 | struct v4l2_capability *vc) | 509 | struct v4l2_capability *vc) |
514 | { | 510 | { |
515 | struct usb_usbvision *usbvision = video_drvdata(file); | 511 | struct usb_usbvision *usbvision = video_drvdata(file); |
516 | 512 | ||
517 | strlcpy(vc->driver, "USBVision", sizeof(vc->driver)); | 513 | strlcpy(vc->driver, "USBVision", sizeof(vc->driver)); |
518 | strlcpy(vc->card, | 514 | strlcpy(vc->card, |
519 | usbvision_device_data[usbvision->DevModel].ModelString, | 515 | usbvision_device_data[usbvision->dev_model].model_string, |
520 | sizeof(vc->card)); | 516 | sizeof(vc->card)); |
521 | usb_make_path(usbvision->dev, vc->bus_info, sizeof(vc->bus_info)); | 517 | usb_make_path(usbvision->dev, vc->bus_info, sizeof(vc->bus_info)); |
522 | vc->version = USBVISION_DRIVER_VERSION; | 518 | vc->version = USBVISION_DRIVER_VERSION; |
@@ -528,7 +524,7 @@ static int vidioc_querycap (struct file *file, void *priv, | |||
528 | return 0; | 524 | return 0; |
529 | } | 525 | } |
530 | 526 | ||
531 | static int vidioc_enum_input (struct file *file, void *priv, | 527 | static int vidioc_enum_input(struct file *file, void *priv, |
532 | struct v4l2_input *vi) | 528 | struct v4l2_input *vi) |
533 | { | 529 | { |
534 | struct usb_usbvision *usbvision = video_drvdata(file); | 530 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -536,16 +532,16 @@ static int vidioc_enum_input (struct file *file, void *priv, | |||
536 | 532 | ||
537 | if (vi->index >= usbvision->video_inputs) | 533 | if (vi->index >= usbvision->video_inputs) |
538 | return -EINVAL; | 534 | return -EINVAL; |
539 | if (usbvision->have_tuner) { | 535 | if (usbvision->have_tuner) |
540 | chan = vi->index; | 536 | chan = vi->index; |
541 | } else { | 537 | else |
542 | chan = vi->index + 1; /*skip Television string*/ | 538 | chan = vi->index + 1; /* skip Television string*/ |
543 | } | 539 | |
544 | /* Determine the requested input characteristics | 540 | /* Determine the requested input characteristics |
545 | specific for each usbvision card model */ | 541 | specific for each usbvision card model */ |
546 | switch(chan) { | 542 | switch (chan) { |
547 | case 0: | 543 | case 0: |
548 | if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) { | 544 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) { |
549 | strcpy(vi->name, "White Video Input"); | 545 | strcpy(vi->name, "White Video Input"); |
550 | } else { | 546 | } else { |
551 | strcpy(vi->name, "Television"); | 547 | strcpy(vi->name, "Television"); |
@@ -557,20 +553,18 @@ static int vidioc_enum_input (struct file *file, void *priv, | |||
557 | break; | 553 | break; |
558 | case 1: | 554 | case 1: |
559 | vi->type = V4L2_INPUT_TYPE_CAMERA; | 555 | vi->type = V4L2_INPUT_TYPE_CAMERA; |
560 | if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) { | 556 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) |
561 | strcpy(vi->name, "Green Video Input"); | 557 | strcpy(vi->name, "Green Video Input"); |
562 | } else { | 558 | else |
563 | strcpy(vi->name, "Composite Video Input"); | 559 | strcpy(vi->name, "Composite Video Input"); |
564 | } | ||
565 | vi->std = V4L2_STD_PAL; | 560 | vi->std = V4L2_STD_PAL; |
566 | break; | 561 | break; |
567 | case 2: | 562 | case 2: |
568 | vi->type = V4L2_INPUT_TYPE_CAMERA; | 563 | vi->type = V4L2_INPUT_TYPE_CAMERA; |
569 | if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) { | 564 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) |
570 | strcpy(vi->name, "Yellow Video Input"); | 565 | strcpy(vi->name, "Yellow Video Input"); |
571 | } else { | 566 | else |
572 | strcpy(vi->name, "S-Video Input"); | 567 | strcpy(vi->name, "S-Video Input"); |
573 | } | ||
574 | vi->std = V4L2_STD_PAL; | 568 | vi->std = V4L2_STD_PAL; |
575 | break; | 569 | break; |
576 | case 3: | 570 | case 3: |
@@ -582,7 +576,7 @@ static int vidioc_enum_input (struct file *file, void *priv, | |||
582 | return 0; | 576 | return 0; |
583 | } | 577 | } |
584 | 578 | ||
585 | static int vidioc_g_input (struct file *file, void *priv, unsigned int *input) | 579 | static int vidioc_g_input(struct file *file, void *priv, unsigned int *input) |
586 | { | 580 | { |
587 | struct usb_usbvision *usbvision = video_drvdata(file); | 581 | struct usb_usbvision *usbvision = video_drvdata(file); |
588 | 582 | ||
@@ -590,46 +584,42 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *input) | |||
590 | return 0; | 584 | return 0; |
591 | } | 585 | } |
592 | 586 | ||
593 | static int vidioc_s_input (struct file *file, void *priv, unsigned int input) | 587 | static int vidioc_s_input(struct file *file, void *priv, unsigned int input) |
594 | { | 588 | { |
595 | struct usb_usbvision *usbvision = video_drvdata(file); | 589 | struct usb_usbvision *usbvision = video_drvdata(file); |
596 | 590 | ||
597 | if (input >= usbvision->video_inputs) | 591 | if (input >= usbvision->video_inputs) |
598 | return -EINVAL; | 592 | return -EINVAL; |
599 | 593 | ||
600 | mutex_lock(&usbvision->lock); | ||
601 | usbvision_muxsel(usbvision, input); | 594 | usbvision_muxsel(usbvision, input); |
602 | usbvision_set_input(usbvision); | 595 | usbvision_set_input(usbvision); |
603 | usbvision_set_output(usbvision, | 596 | usbvision_set_output(usbvision, |
604 | usbvision->curwidth, | 597 | usbvision->curwidth, |
605 | usbvision->curheight); | 598 | usbvision->curheight); |
606 | mutex_unlock(&usbvision->lock); | ||
607 | return 0; | 599 | return 0; |
608 | } | 600 | } |
609 | 601 | ||
610 | static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | 602 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *id) |
611 | { | 603 | { |
612 | struct usb_usbvision *usbvision = video_drvdata(file); | 604 | struct usb_usbvision *usbvision = video_drvdata(file); |
613 | 605 | ||
614 | usbvision->tvnormId=*id; | 606 | usbvision->tvnorm_id = *id; |
615 | 607 | ||
616 | mutex_lock(&usbvision->lock); | 608 | call_all(usbvision, core, s_std, usbvision->tvnorm_id); |
617 | call_all(usbvision, core, s_std, usbvision->tvnormId); | ||
618 | mutex_unlock(&usbvision->lock); | ||
619 | /* propagate the change to the decoder */ | 609 | /* propagate the change to the decoder */ |
620 | usbvision_muxsel(usbvision, usbvision->ctl_input); | 610 | usbvision_muxsel(usbvision, usbvision->ctl_input); |
621 | 611 | ||
622 | return 0; | 612 | return 0; |
623 | } | 613 | } |
624 | 614 | ||
625 | static int vidioc_g_tuner (struct file *file, void *priv, | 615 | static int vidioc_g_tuner(struct file *file, void *priv, |
626 | struct v4l2_tuner *vt) | 616 | struct v4l2_tuner *vt) |
627 | { | 617 | { |
628 | struct usb_usbvision *usbvision = video_drvdata(file); | 618 | struct usb_usbvision *usbvision = video_drvdata(file); |
629 | 619 | ||
630 | if (!usbvision->have_tuner || vt->index) // Only tuner 0 | 620 | if (!usbvision->have_tuner || vt->index) /* Only tuner 0 */ |
631 | return -EINVAL; | 621 | return -EINVAL; |
632 | if(usbvision->radio) { | 622 | if (usbvision->radio) { |
633 | strcpy(vt->name, "Radio"); | 623 | strcpy(vt->name, "Radio"); |
634 | vt->type = V4L2_TUNER_RADIO; | 624 | vt->type = V4L2_TUNER_RADIO; |
635 | } else { | 625 | } else { |
@@ -641,12 +631,12 @@ static int vidioc_g_tuner (struct file *file, void *priv, | |||
641 | return 0; | 631 | return 0; |
642 | } | 632 | } |
643 | 633 | ||
644 | static int vidioc_s_tuner (struct file *file, void *priv, | 634 | static int vidioc_s_tuner(struct file *file, void *priv, |
645 | struct v4l2_tuner *vt) | 635 | struct v4l2_tuner *vt) |
646 | { | 636 | { |
647 | struct usb_usbvision *usbvision = video_drvdata(file); | 637 | struct usb_usbvision *usbvision = video_drvdata(file); |
648 | 638 | ||
649 | // Only no or one tuner for now | 639 | /* Only no or one tuner for now */ |
650 | if (!usbvision->have_tuner || vt->index) | 640 | if (!usbvision->have_tuner || vt->index) |
651 | return -EINVAL; | 641 | return -EINVAL; |
652 | /* let clients handle this */ | 642 | /* let clients handle this */ |
@@ -655,28 +645,27 @@ static int vidioc_s_tuner (struct file *file, void *priv, | |||
655 | return 0; | 645 | return 0; |
656 | } | 646 | } |
657 | 647 | ||
658 | static int vidioc_g_frequency (struct file *file, void *priv, | 648 | static int vidioc_g_frequency(struct file *file, void *priv, |
659 | struct v4l2_frequency *freq) | 649 | struct v4l2_frequency *freq) |
660 | { | 650 | { |
661 | struct usb_usbvision *usbvision = video_drvdata(file); | 651 | struct usb_usbvision *usbvision = video_drvdata(file); |
662 | 652 | ||
663 | freq->tuner = 0; // Only one tuner | 653 | freq->tuner = 0; /* Only one tuner */ |
664 | if(usbvision->radio) { | 654 | if (usbvision->radio) |
665 | freq->type = V4L2_TUNER_RADIO; | 655 | freq->type = V4L2_TUNER_RADIO; |
666 | } else { | 656 | else |
667 | freq->type = V4L2_TUNER_ANALOG_TV; | 657 | freq->type = V4L2_TUNER_ANALOG_TV; |
668 | } | ||
669 | freq->frequency = usbvision->freq; | 658 | freq->frequency = usbvision->freq; |
670 | 659 | ||
671 | return 0; | 660 | return 0; |
672 | } | 661 | } |
673 | 662 | ||
674 | static int vidioc_s_frequency (struct file *file, void *priv, | 663 | static int vidioc_s_frequency(struct file *file, void *priv, |
675 | struct v4l2_frequency *freq) | 664 | struct v4l2_frequency *freq) |
676 | { | 665 | { |
677 | struct usb_usbvision *usbvision = video_drvdata(file); | 666 | struct usb_usbvision *usbvision = video_drvdata(file); |
678 | 667 | ||
679 | // Only no or one tuner for now | 668 | /* Only no or one tuner for now */ |
680 | if (!usbvision->have_tuner || freq->tuner) | 669 | if (!usbvision->have_tuner || freq->tuner) |
681 | return -EINVAL; | 670 | return -EINVAL; |
682 | 671 | ||
@@ -686,30 +675,27 @@ static int vidioc_s_frequency (struct file *file, void *priv, | |||
686 | return 0; | 675 | return 0; |
687 | } | 676 | } |
688 | 677 | ||
689 | static int vidioc_g_audio (struct file *file, void *priv, struct v4l2_audio *a) | 678 | static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a) |
690 | { | 679 | { |
691 | struct usb_usbvision *usbvision = video_drvdata(file); | 680 | struct usb_usbvision *usbvision = video_drvdata(file); |
692 | 681 | ||
693 | if(usbvision->radio) { | 682 | if (usbvision->radio) |
694 | strcpy(a->name,"Radio"); | 683 | strcpy(a->name, "Radio"); |
695 | } else { | 684 | else |
696 | strcpy(a->name, "TV"); | 685 | strcpy(a->name, "TV"); |
697 | } | ||
698 | 686 | ||
699 | return 0; | 687 | return 0; |
700 | } | 688 | } |
701 | 689 | ||
702 | static int vidioc_s_audio (struct file *file, void *fh, | 690 | static int vidioc_s_audio(struct file *file, void *fh, |
703 | struct v4l2_audio *a) | 691 | struct v4l2_audio *a) |
704 | { | 692 | { |
705 | if(a->index) { | 693 | if (a->index) |
706 | return -EINVAL; | 694 | return -EINVAL; |
707 | } | ||
708 | |||
709 | return 0; | 695 | return 0; |
710 | } | 696 | } |
711 | 697 | ||
712 | static int vidioc_queryctrl (struct file *file, void *priv, | 698 | static int vidioc_queryctrl(struct file *file, void *priv, |
713 | struct v4l2_queryctrl *ctrl) | 699 | struct v4l2_queryctrl *ctrl) |
714 | { | 700 | { |
715 | struct usb_usbvision *usbvision = video_drvdata(file); | 701 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -722,52 +708,53 @@ static int vidioc_queryctrl (struct file *file, void *priv, | |||
722 | return 0; | 708 | return 0; |
723 | } | 709 | } |
724 | 710 | ||
725 | static int vidioc_g_ctrl (struct file *file, void *priv, | 711 | static int vidioc_g_ctrl(struct file *file, void *priv, |
726 | struct v4l2_control *ctrl) | 712 | struct v4l2_control *ctrl) |
727 | { | 713 | { |
728 | struct usb_usbvision *usbvision = video_drvdata(file); | 714 | struct usb_usbvision *usbvision = video_drvdata(file); |
729 | call_all(usbvision, core, g_ctrl, ctrl); | ||
730 | 715 | ||
716 | call_all(usbvision, core, g_ctrl, ctrl); | ||
731 | return 0; | 717 | return 0; |
732 | } | 718 | } |
733 | 719 | ||
734 | static int vidioc_s_ctrl (struct file *file, void *priv, | 720 | static int vidioc_s_ctrl(struct file *file, void *priv, |
735 | struct v4l2_control *ctrl) | 721 | struct v4l2_control *ctrl) |
736 | { | 722 | { |
737 | struct usb_usbvision *usbvision = video_drvdata(file); | 723 | struct usb_usbvision *usbvision = video_drvdata(file); |
738 | call_all(usbvision, core, s_ctrl, ctrl); | ||
739 | 724 | ||
725 | call_all(usbvision, core, s_ctrl, ctrl); | ||
740 | return 0; | 726 | return 0; |
741 | } | 727 | } |
742 | 728 | ||
743 | static int vidioc_reqbufs (struct file *file, | 729 | static int vidioc_reqbufs(struct file *file, |
744 | void *priv, struct v4l2_requestbuffers *vr) | 730 | void *priv, struct v4l2_requestbuffers *vr) |
745 | { | 731 | { |
746 | struct usb_usbvision *usbvision = video_drvdata(file); | 732 | struct usb_usbvision *usbvision = video_drvdata(file); |
747 | int ret; | 733 | int ret; |
748 | 734 | ||
749 | RESTRICT_TO_RANGE(vr->count,1,USBVISION_NUMFRAMES); | 735 | RESTRICT_TO_RANGE(vr->count, 1, USBVISION_NUMFRAMES); |
750 | 736 | ||
751 | /* Check input validity: | 737 | /* Check input validity: |
752 | the user must do a VIDEO CAPTURE and MMAP method. */ | 738 | the user must do a VIDEO CAPTURE and MMAP method. */ |
753 | if (vr->memory != V4L2_MEMORY_MMAP) | 739 | if (vr->memory != V4L2_MEMORY_MMAP) |
754 | return -EINVAL; | 740 | return -EINVAL; |
755 | 741 | ||
756 | if(usbvision->streaming == Stream_On) { | 742 | if (usbvision->streaming == stream_on) { |
757 | if ((ret = usbvision_stream_interrupt(usbvision))) | 743 | ret = usbvision_stream_interrupt(usbvision); |
744 | if (ret) | ||
758 | return ret; | 745 | return ret; |
759 | } | 746 | } |
760 | 747 | ||
761 | usbvision_frames_free(usbvision); | 748 | usbvision_frames_free(usbvision); |
762 | usbvision_empty_framequeues(usbvision); | 749 | usbvision_empty_framequeues(usbvision); |
763 | vr->count = usbvision_frames_alloc(usbvision,vr->count); | 750 | vr->count = usbvision_frames_alloc(usbvision, vr->count); |
764 | 751 | ||
765 | usbvision->curFrame = NULL; | 752 | usbvision->cur_frame = NULL; |
766 | 753 | ||
767 | return 0; | 754 | return 0; |
768 | } | 755 | } |
769 | 756 | ||
770 | static int vidioc_querybuf (struct file *file, | 757 | static int vidioc_querybuf(struct file *file, |
771 | void *priv, struct v4l2_buffer *vb) | 758 | void *priv, struct v4l2_buffer *vb) |
772 | { | 759 | { |
773 | struct usb_usbvision *usbvision = video_drvdata(file); | 760 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -775,52 +762,49 @@ static int vidioc_querybuf (struct file *file, | |||
775 | 762 | ||
776 | /* FIXME : must control | 763 | /* FIXME : must control |
777 | that buffers are mapped (VIDIOC_REQBUFS has been called) */ | 764 | that buffers are mapped (VIDIOC_REQBUFS has been called) */ |
778 | if(vb->index>=usbvision->num_frames) { | 765 | if (vb->index >= usbvision->num_frames) |
779 | return -EINVAL; | 766 | return -EINVAL; |
780 | } | ||
781 | /* Updating the corresponding frame state */ | 767 | /* Updating the corresponding frame state */ |
782 | vb->flags = 0; | 768 | vb->flags = 0; |
783 | frame = &usbvision->frame[vb->index]; | 769 | frame = &usbvision->frame[vb->index]; |
784 | if(frame->grabstate >= FrameState_Ready) | 770 | if (frame->grabstate >= frame_state_ready) |
785 | vb->flags |= V4L2_BUF_FLAG_QUEUED; | 771 | vb->flags |= V4L2_BUF_FLAG_QUEUED; |
786 | if(frame->grabstate >= FrameState_Done) | 772 | if (frame->grabstate >= frame_state_done) |
787 | vb->flags |= V4L2_BUF_FLAG_DONE; | 773 | vb->flags |= V4L2_BUF_FLAG_DONE; |
788 | if(frame->grabstate == FrameState_Unused) | 774 | if (frame->grabstate == frame_state_unused) |
789 | vb->flags |= V4L2_BUF_FLAG_MAPPED; | 775 | vb->flags |= V4L2_BUF_FLAG_MAPPED; |
790 | vb->memory = V4L2_MEMORY_MMAP; | 776 | vb->memory = V4L2_MEMORY_MMAP; |
791 | 777 | ||
792 | vb->m.offset = vb->index*PAGE_ALIGN(usbvision->max_frame_size); | 778 | vb->m.offset = vb->index * PAGE_ALIGN(usbvision->max_frame_size); |
793 | 779 | ||
794 | vb->memory = V4L2_MEMORY_MMAP; | 780 | vb->memory = V4L2_MEMORY_MMAP; |
795 | vb->field = V4L2_FIELD_NONE; | 781 | vb->field = V4L2_FIELD_NONE; |
796 | vb->length = usbvision->curwidth* | 782 | vb->length = usbvision->curwidth * |
797 | usbvision->curheight* | 783 | usbvision->curheight * |
798 | usbvision->palette.bytes_per_pixel; | 784 | usbvision->palette.bytes_per_pixel; |
799 | vb->timestamp = usbvision->frame[vb->index].timestamp; | 785 | vb->timestamp = usbvision->frame[vb->index].timestamp; |
800 | vb->sequence = usbvision->frame[vb->index].sequence; | 786 | vb->sequence = usbvision->frame[vb->index].sequence; |
801 | return 0; | 787 | return 0; |
802 | } | 788 | } |
803 | 789 | ||
804 | static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | 790 | static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *vb) |
805 | { | 791 | { |
806 | struct usb_usbvision *usbvision = video_drvdata(file); | 792 | struct usb_usbvision *usbvision = video_drvdata(file); |
807 | struct usbvision_frame *frame; | 793 | struct usbvision_frame *frame; |
808 | unsigned long lock_flags; | 794 | unsigned long lock_flags; |
809 | 795 | ||
810 | /* FIXME : works only on VIDEO_CAPTURE MODE, MMAP. */ | 796 | /* FIXME : works only on VIDEO_CAPTURE MODE, MMAP. */ |
811 | if(vb->index>=usbvision->num_frames) { | 797 | if (vb->index >= usbvision->num_frames) |
812 | return -EINVAL; | 798 | return -EINVAL; |
813 | } | ||
814 | 799 | ||
815 | frame = &usbvision->frame[vb->index]; | 800 | frame = &usbvision->frame[vb->index]; |
816 | 801 | ||
817 | if (frame->grabstate != FrameState_Unused) { | 802 | if (frame->grabstate != frame_state_unused) |
818 | return -EAGAIN; | 803 | return -EAGAIN; |
819 | } | ||
820 | 804 | ||
821 | /* Mark it as ready and enqueue frame */ | 805 | /* Mark it as ready and enqueue frame */ |
822 | frame->grabstate = FrameState_Ready; | 806 | frame->grabstate = frame_state_ready; |
823 | frame->scanstate = ScanState_Scanning; | 807 | frame->scanstate = scan_state_scanning; |
824 | frame->scanlength = 0; /* Accumulated in usbvision_parse_data() */ | 808 | frame->scanlength = 0; /* Accumulated in usbvision_parse_data() */ |
825 | 809 | ||
826 | vb->flags &= ~V4L2_BUF_FLAG_DONE; | 810 | vb->flags &= ~V4L2_BUF_FLAG_DONE; |
@@ -835,7 +819,7 @@ static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | |||
835 | return 0; | 819 | return 0; |
836 | } | 820 | } |
837 | 821 | ||
838 | static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | 822 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *vb) |
839 | { | 823 | { |
840 | struct usb_usbvision *usbvision = video_drvdata(file); | 824 | struct usb_usbvision *usbvision = video_drvdata(file); |
841 | int ret; | 825 | int ret; |
@@ -843,7 +827,7 @@ static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | |||
843 | unsigned long lock_flags; | 827 | unsigned long lock_flags; |
844 | 828 | ||
845 | if (list_empty(&(usbvision->outqueue))) { | 829 | if (list_empty(&(usbvision->outqueue))) { |
846 | if (usbvision->streaming == Stream_Idle) | 830 | if (usbvision->streaming == stream_idle) |
847 | return -EINVAL; | 831 | return -EINVAL; |
848 | ret = wait_event_interruptible | 832 | ret = wait_event_interruptible |
849 | (usbvision->wait_frame, | 833 | (usbvision->wait_frame, |
@@ -858,7 +842,7 @@ static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | |||
858 | list_del(usbvision->outqueue.next); | 842 | list_del(usbvision->outqueue.next); |
859 | spin_unlock_irqrestore(&usbvision->queue_lock, lock_flags); | 843 | spin_unlock_irqrestore(&usbvision->queue_lock, lock_flags); |
860 | 844 | ||
861 | f->grabstate = FrameState_Unused; | 845 | f->grabstate = frame_state_unused; |
862 | 846 | ||
863 | vb->memory = V4L2_MEMORY_MMAP; | 847 | vb->memory = V4L2_MEMORY_MMAP; |
864 | vb->flags = V4L2_BUF_FLAG_MAPPED | | 848 | vb->flags = V4L2_BUF_FLAG_MAPPED | |
@@ -877,7 +861,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | |||
877 | { | 861 | { |
878 | struct usb_usbvision *usbvision = video_drvdata(file); | 862 | struct usb_usbvision *usbvision = video_drvdata(file); |
879 | 863 | ||
880 | usbvision->streaming = Stream_On; | 864 | usbvision->streaming = stream_on; |
881 | call_all(usbvision, video, s_stream, 1); | 865 | call_all(usbvision, video, s_stream, 1); |
882 | 866 | ||
883 | return 0; | 867 | return 0; |
@@ -891,7 +875,7 @@ static int vidioc_streamoff(struct file *file, | |||
891 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 875 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
892 | return -EINVAL; | 876 | return -EINVAL; |
893 | 877 | ||
894 | if(usbvision->streaming == Stream_On) { | 878 | if (usbvision->streaming == stream_on) { |
895 | usbvision_stream_interrupt(usbvision); | 879 | usbvision_stream_interrupt(usbvision); |
896 | /* Stop all video streamings */ | 880 | /* Stop all video streamings */ |
897 | call_all(usbvision, video, s_stream, 0); | 881 | call_all(usbvision, video, s_stream, 0); |
@@ -901,18 +885,17 @@ static int vidioc_streamoff(struct file *file, | |||
901 | return 0; | 885 | return 0; |
902 | } | 886 | } |
903 | 887 | ||
904 | static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, | 888 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, |
905 | struct v4l2_fmtdesc *vfd) | 889 | struct v4l2_fmtdesc *vfd) |
906 | { | 890 | { |
907 | if(vfd->index>=USBVISION_SUPPORTED_PALETTES-1) { | 891 | if (vfd->index >= USBVISION_SUPPORTED_PALETTES - 1) |
908 | return -EINVAL; | 892 | return -EINVAL; |
909 | } | 893 | strcpy(vfd->description, usbvision_v4l2_format[vfd->index].desc); |
910 | strcpy(vfd->description,usbvision_v4l2_format[vfd->index].desc); | ||
911 | vfd->pixelformat = usbvision_v4l2_format[vfd->index].format; | 894 | vfd->pixelformat = usbvision_v4l2_format[vfd->index].format; |
912 | return 0; | 895 | return 0; |
913 | } | 896 | } |
914 | 897 | ||
915 | static int vidioc_g_fmt_vid_cap (struct file *file, void *priv, | 898 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, |
916 | struct v4l2_format *vf) | 899 | struct v4l2_format *vf) |
917 | { | 900 | { |
918 | struct usb_usbvision *usbvision = video_drvdata(file); | 901 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -920,32 +903,31 @@ static int vidioc_g_fmt_vid_cap (struct file *file, void *priv, | |||
920 | vf->fmt.pix.height = usbvision->curheight; | 903 | vf->fmt.pix.height = usbvision->curheight; |
921 | vf->fmt.pix.pixelformat = usbvision->palette.format; | 904 | vf->fmt.pix.pixelformat = usbvision->palette.format; |
922 | vf->fmt.pix.bytesperline = | 905 | vf->fmt.pix.bytesperline = |
923 | usbvision->curwidth*usbvision->palette.bytes_per_pixel; | 906 | usbvision->curwidth * usbvision->palette.bytes_per_pixel; |
924 | vf->fmt.pix.sizeimage = vf->fmt.pix.bytesperline*usbvision->curheight; | 907 | vf->fmt.pix.sizeimage = vf->fmt.pix.bytesperline * usbvision->curheight; |
925 | vf->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 908 | vf->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
926 | vf->fmt.pix.field = V4L2_FIELD_NONE; /* Always progressive image */ | 909 | vf->fmt.pix.field = V4L2_FIELD_NONE; /* Always progressive image */ |
927 | 910 | ||
928 | return 0; | 911 | return 0; |
929 | } | 912 | } |
930 | 913 | ||
931 | static int vidioc_try_fmt_vid_cap (struct file *file, void *priv, | 914 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, |
932 | struct v4l2_format *vf) | 915 | struct v4l2_format *vf) |
933 | { | 916 | { |
934 | struct usb_usbvision *usbvision = video_drvdata(file); | 917 | struct usb_usbvision *usbvision = video_drvdata(file); |
935 | int formatIdx; | 918 | int format_idx; |
936 | 919 | ||
937 | /* Find requested format in available ones */ | 920 | /* Find requested format in available ones */ |
938 | for(formatIdx=0;formatIdx<USBVISION_SUPPORTED_PALETTES;formatIdx++) { | 921 | for (format_idx = 0; format_idx < USBVISION_SUPPORTED_PALETTES; format_idx++) { |
939 | if(vf->fmt.pix.pixelformat == | 922 | if (vf->fmt.pix.pixelformat == |
940 | usbvision_v4l2_format[formatIdx].format) { | 923 | usbvision_v4l2_format[format_idx].format) { |
941 | usbvision->palette = usbvision_v4l2_format[formatIdx]; | 924 | usbvision->palette = usbvision_v4l2_format[format_idx]; |
942 | break; | 925 | break; |
943 | } | 926 | } |
944 | } | 927 | } |
945 | /* robustness */ | 928 | /* robustness */ |
946 | if(formatIdx == USBVISION_SUPPORTED_PALETTES) { | 929 | if (format_idx == USBVISION_SUPPORTED_PALETTES) |
947 | return -EINVAL; | 930 | return -EINVAL; |
948 | } | ||
949 | RESTRICT_TO_RANGE(vf->fmt.pix.width, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH); | 931 | RESTRICT_TO_RANGE(vf->fmt.pix.width, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH); |
950 | RESTRICT_TO_RANGE(vf->fmt.pix.height, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT); | 932 | RESTRICT_TO_RANGE(vf->fmt.pix.height, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT); |
951 | 933 | ||
@@ -962,24 +944,23 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
962 | struct usb_usbvision *usbvision = video_drvdata(file); | 944 | struct usb_usbvision *usbvision = video_drvdata(file); |
963 | int ret; | 945 | int ret; |
964 | 946 | ||
965 | if( 0 != (ret=vidioc_try_fmt_vid_cap (file, priv, vf)) ) { | 947 | ret = vidioc_try_fmt_vid_cap(file, priv, vf); |
948 | if (ret) | ||
966 | return ret; | 949 | return ret; |
967 | } | ||
968 | 950 | ||
969 | /* stop io in case it is already in progress */ | 951 | /* stop io in case it is already in progress */ |
970 | if(usbvision->streaming == Stream_On) { | 952 | if (usbvision->streaming == stream_on) { |
971 | if ((ret = usbvision_stream_interrupt(usbvision))) | 953 | ret = usbvision_stream_interrupt(usbvision); |
954 | if (ret) | ||
972 | return ret; | 955 | return ret; |
973 | } | 956 | } |
974 | usbvision_frames_free(usbvision); | 957 | usbvision_frames_free(usbvision); |
975 | usbvision_empty_framequeues(usbvision); | 958 | usbvision_empty_framequeues(usbvision); |
976 | 959 | ||
977 | usbvision->curFrame = NULL; | 960 | usbvision->cur_frame = NULL; |
978 | 961 | ||
979 | /* by now we are committed to the new data... */ | 962 | /* by now we are committed to the new data... */ |
980 | mutex_lock(&usbvision->lock); | ||
981 | usbvision_set_output(usbvision, vf->fmt.pix.width, vf->fmt.pix.height); | 963 | usbvision_set_output(usbvision, vf->fmt.pix.width, vf->fmt.pix.height); |
982 | mutex_unlock(&usbvision->lock); | ||
983 | 964 | ||
984 | return 0; | 965 | return 0; |
985 | } | 966 | } |
@@ -990,8 +971,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
990 | struct usb_usbvision *usbvision = video_drvdata(file); | 971 | struct usb_usbvision *usbvision = video_drvdata(file); |
991 | int noblock = file->f_flags & O_NONBLOCK; | 972 | int noblock = file->f_flags & O_NONBLOCK; |
992 | unsigned long lock_flags; | 973 | unsigned long lock_flags; |
993 | 974 | int ret, i; | |
994 | int ret,i; | ||
995 | struct usbvision_frame *frame; | 975 | struct usbvision_frame *frame; |
996 | 976 | ||
997 | PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__, | 977 | PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__, |
@@ -1003,28 +983,28 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1003 | /* This entry point is compatible with the mmap routines | 983 | /* This entry point is compatible with the mmap routines |
1004 | so that a user can do either VIDIOC_QBUF/VIDIOC_DQBUF | 984 | so that a user can do either VIDIOC_QBUF/VIDIOC_DQBUF |
1005 | to get frames or call read on the device. */ | 985 | to get frames or call read on the device. */ |
1006 | if(!usbvision->num_frames) { | 986 | if (!usbvision->num_frames) { |
1007 | /* First, allocate some frames to work with | 987 | /* First, allocate some frames to work with |
1008 | if this has not been done with VIDIOC_REQBUF */ | 988 | if this has not been done with VIDIOC_REQBUF */ |
1009 | usbvision_frames_free(usbvision); | 989 | usbvision_frames_free(usbvision); |
1010 | usbvision_empty_framequeues(usbvision); | 990 | usbvision_empty_framequeues(usbvision); |
1011 | usbvision_frames_alloc(usbvision,USBVISION_NUMFRAMES); | 991 | usbvision_frames_alloc(usbvision, USBVISION_NUMFRAMES); |
1012 | } | 992 | } |
1013 | 993 | ||
1014 | if(usbvision->streaming != Stream_On) { | 994 | if (usbvision->streaming != stream_on) { |
1015 | /* no stream is running, make it running ! */ | 995 | /* no stream is running, make it running ! */ |
1016 | usbvision->streaming = Stream_On; | 996 | usbvision->streaming = stream_on; |
1017 | call_all(usbvision, video, s_stream, 1); | 997 | call_all(usbvision, video, s_stream, 1); |
1018 | } | 998 | } |
1019 | 999 | ||
1020 | /* Then, enqueue as many frames as possible | 1000 | /* Then, enqueue as many frames as possible |
1021 | (like a user of VIDIOC_QBUF would do) */ | 1001 | (like a user of VIDIOC_QBUF would do) */ |
1022 | for(i=0;i<usbvision->num_frames;i++) { | 1002 | for (i = 0; i < usbvision->num_frames; i++) { |
1023 | frame = &usbvision->frame[i]; | 1003 | frame = &usbvision->frame[i]; |
1024 | if(frame->grabstate == FrameState_Unused) { | 1004 | if (frame->grabstate == frame_state_unused) { |
1025 | /* Mark it as ready and enqueue frame */ | 1005 | /* Mark it as ready and enqueue frame */ |
1026 | frame->grabstate = FrameState_Ready; | 1006 | frame->grabstate = frame_state_ready; |
1027 | frame->scanstate = ScanState_Scanning; | 1007 | frame->scanstate = scan_state_scanning; |
1028 | /* Accumulated in usbvision_parse_data() */ | 1008 | /* Accumulated in usbvision_parse_data() */ |
1029 | frame->scanlength = 0; | 1009 | frame->scanlength = 0; |
1030 | 1010 | ||
@@ -1040,7 +1020,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1040 | 1020 | ||
1041 | /* Then try to steal a frame (like a VIDIOC_DQBUF would do) */ | 1021 | /* Then try to steal a frame (like a VIDIOC_DQBUF would do) */ |
1042 | if (list_empty(&(usbvision->outqueue))) { | 1022 | if (list_empty(&(usbvision->outqueue))) { |
1043 | if(noblock) | 1023 | if (noblock) |
1044 | return -EAGAIN; | 1024 | return -EAGAIN; |
1045 | 1025 | ||
1046 | ret = wait_event_interruptible | 1026 | ret = wait_event_interruptible |
@@ -1057,7 +1037,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1057 | spin_unlock_irqrestore(&usbvision->queue_lock, lock_flags); | 1037 | spin_unlock_irqrestore(&usbvision->queue_lock, lock_flags); |
1058 | 1038 | ||
1059 | /* An error returns an empty frame */ | 1039 | /* An error returns an empty frame */ |
1060 | if (frame->grabstate == FrameState_Error) { | 1040 | if (frame->grabstate == frame_state_error) { |
1061 | frame->bytes_read = 0; | 1041 | frame->bytes_read = 0; |
1062 | return 0; | 1042 | return 0; |
1063 | } | 1043 | } |
@@ -1070,9 +1050,8 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1070 | if ((count + frame->bytes_read) > (unsigned long)frame->scanlength) | 1050 | if ((count + frame->bytes_read) > (unsigned long)frame->scanlength) |
1071 | count = frame->scanlength - frame->bytes_read; | 1051 | count = frame->scanlength - frame->bytes_read; |
1072 | 1052 | ||
1073 | if (copy_to_user(buf, frame->data + frame->bytes_read, count)) { | 1053 | if (copy_to_user(buf, frame->data + frame->bytes_read, count)) |
1074 | return -EFAULT; | 1054 | return -EFAULT; |
1075 | } | ||
1076 | 1055 | ||
1077 | frame->bytes_read += count; | 1056 | frame->bytes_read += count; |
1078 | PDEBUG(DBG_IO, "%s: {copy} count used=%ld, new bytes_read=%ld", | 1057 | PDEBUG(DBG_IO, "%s: {copy} count used=%ld, new bytes_read=%ld", |
@@ -1080,12 +1059,12 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1080 | (unsigned long)count, frame->bytes_read); | 1059 | (unsigned long)count, frame->bytes_read); |
1081 | 1060 | ||
1082 | /* For now, forget the frame if it has not been read in one shot. */ | 1061 | /* For now, forget the frame if it has not been read in one shot. */ |
1083 | /* if (frame->bytes_read >= frame->scanlength) {// All data has been read */ | 1062 | /* if (frame->bytes_read >= frame->scanlength) {*/ /* All data has been read */ |
1084 | frame->bytes_read = 0; | 1063 | frame->bytes_read = 0; |
1085 | 1064 | ||
1086 | /* Mark it as available to be used again. */ | 1065 | /* Mark it as available to be used again. */ |
1087 | frame->grabstate = FrameState_Unused; | 1066 | frame->grabstate = frame_state_unused; |
1088 | /* } */ | 1067 | /* } */ |
1089 | 1068 | ||
1090 | return count; | 1069 | return count; |
1091 | } | 1070 | } |
@@ -1100,16 +1079,11 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1100 | 1079 | ||
1101 | PDEBUG(DBG_MMAP, "mmap"); | 1080 | PDEBUG(DBG_MMAP, "mmap"); |
1102 | 1081 | ||
1103 | mutex_lock(&usbvision->lock); | 1082 | if (!USBVISION_IS_OPERATIONAL(usbvision)) |
1104 | |||
1105 | if (!USBVISION_IS_OPERATIONAL(usbvision)) { | ||
1106 | mutex_unlock(&usbvision->lock); | ||
1107 | return -EFAULT; | 1083 | return -EFAULT; |
1108 | } | ||
1109 | 1084 | ||
1110 | if (!(vma->vm_flags & VM_WRITE) || | 1085 | if (!(vma->vm_flags & VM_WRITE) || |
1111 | size != PAGE_ALIGN(usbvision->max_frame_size)) { | 1086 | size != PAGE_ALIGN(usbvision->max_frame_size)) { |
1112 | mutex_unlock(&usbvision->lock); | ||
1113 | return -EINVAL; | 1087 | return -EINVAL; |
1114 | } | 1088 | } |
1115 | 1089 | ||
@@ -1121,7 +1095,6 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1121 | if (i == usbvision->num_frames) { | 1095 | if (i == usbvision->num_frames) { |
1122 | PDEBUG(DBG_MMAP, | 1096 | PDEBUG(DBG_MMAP, |
1123 | "mmap: user supplied mapping address is out of range"); | 1097 | "mmap: user supplied mapping address is out of range"); |
1124 | mutex_unlock(&usbvision->lock); | ||
1125 | return -EINVAL; | 1098 | return -EINVAL; |
1126 | } | 1099 | } |
1127 | 1100 | ||
@@ -1131,10 +1104,8 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1131 | 1104 | ||
1132 | pos = usbvision->frame[i].data; | 1105 | pos = usbvision->frame[i].data; |
1133 | while (size > 0) { | 1106 | while (size > 0) { |
1134 | |||
1135 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { | 1107 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { |
1136 | PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); | 1108 | PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); |
1137 | mutex_unlock(&usbvision->lock); | ||
1138 | return -EAGAIN; | 1109 | return -EAGAIN; |
1139 | } | 1110 | } |
1140 | start += PAGE_SIZE; | 1111 | start += PAGE_SIZE; |
@@ -1142,7 +1113,6 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1142 | size -= PAGE_SIZE; | 1113 | size -= PAGE_SIZE; |
1143 | } | 1114 | } |
1144 | 1115 | ||
1145 | mutex_unlock(&usbvision->lock); | ||
1146 | return 0; | 1116 | return 0; |
1147 | } | 1117 | } |
1148 | 1118 | ||
@@ -1154,21 +1124,18 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1154 | static int usbvision_radio_open(struct file *file) | 1124 | static int usbvision_radio_open(struct file *file) |
1155 | { | 1125 | { |
1156 | struct usb_usbvision *usbvision = video_drvdata(file); | 1126 | struct usb_usbvision *usbvision = video_drvdata(file); |
1157 | int errCode = 0; | 1127 | int err_code = 0; |
1158 | 1128 | ||
1159 | PDEBUG(DBG_IO, "%s:", __func__); | 1129 | PDEBUG(DBG_IO, "%s:", __func__); |
1160 | 1130 | ||
1161 | mutex_lock(&usbvision->lock); | ||
1162 | |||
1163 | if (usbvision->user) { | 1131 | if (usbvision->user) { |
1164 | dev_err(&usbvision->rdev->dev, | 1132 | dev_err(&usbvision->rdev->dev, |
1165 | "%s: Someone tried to open an already opened USBVision Radio!\n", | 1133 | "%s: Someone tried to open an already opened USBVision Radio!\n", |
1166 | __func__); | 1134 | __func__); |
1167 | errCode = -EBUSY; | 1135 | err_code = -EBUSY; |
1168 | } | 1136 | } else { |
1169 | else { | 1137 | if (power_on_at_open) { |
1170 | if(PowerOnAtOpen) { | 1138 | usbvision_reset_power_off_timer(usbvision); |
1171 | usbvision_reset_powerOffTimer(usbvision); | ||
1172 | if (usbvision->power == 0) { | 1139 | if (usbvision->power == 0) { |
1173 | usbvision_power_on(usbvision); | 1140 | usbvision_power_on(usbvision); |
1174 | usbvision_i2c_register(usbvision); | 1141 | usbvision_i2c_register(usbvision); |
@@ -1176,80 +1143,73 @@ static int usbvision_radio_open(struct file *file) | |||
1176 | } | 1143 | } |
1177 | 1144 | ||
1178 | /* Alternate interface 1 is is the biggest frame size */ | 1145 | /* Alternate interface 1 is is the biggest frame size */ |
1179 | errCode = usbvision_set_alternate(usbvision); | 1146 | err_code = usbvision_set_alternate(usbvision); |
1180 | if (errCode < 0) { | 1147 | if (err_code < 0) { |
1181 | usbvision->last_error = errCode; | 1148 | usbvision->last_error = err_code; |
1182 | errCode = -EBUSY; | 1149 | err_code = -EBUSY; |
1183 | goto out; | 1150 | goto out; |
1184 | } | 1151 | } |
1185 | 1152 | ||
1186 | // If so far no errors then we shall start the radio | 1153 | /* If so far no errors then we shall start the radio */ |
1187 | usbvision->radio = 1; | 1154 | usbvision->radio = 1; |
1188 | call_all(usbvision, tuner, s_radio); | 1155 | call_all(usbvision, tuner, s_radio); |
1189 | usbvision_set_audio(usbvision, USBVISION_AUDIO_RADIO); | 1156 | usbvision_set_audio(usbvision, USBVISION_AUDIO_RADIO); |
1190 | usbvision->user++; | 1157 | usbvision->user++; |
1191 | } | 1158 | } |
1192 | 1159 | ||
1193 | if (errCode) { | 1160 | if (err_code) { |
1194 | if (PowerOnAtOpen) { | 1161 | if (power_on_at_open) { |
1195 | usbvision_i2c_unregister(usbvision); | 1162 | usbvision_i2c_unregister(usbvision); |
1196 | usbvision_power_off(usbvision); | 1163 | usbvision_power_off(usbvision); |
1197 | usbvision->initialized = 0; | 1164 | usbvision->initialized = 0; |
1198 | } | 1165 | } |
1199 | } | 1166 | } |
1200 | out: | 1167 | out: |
1201 | mutex_unlock(&usbvision->lock); | 1168 | return err_code; |
1202 | return errCode; | ||
1203 | } | 1169 | } |
1204 | 1170 | ||
1205 | 1171 | ||
1206 | static int usbvision_radio_close(struct file *file) | 1172 | static int usbvision_radio_close(struct file *file) |
1207 | { | 1173 | { |
1208 | struct usb_usbvision *usbvision = video_drvdata(file); | 1174 | struct usb_usbvision *usbvision = video_drvdata(file); |
1209 | int errCode = 0; | 1175 | int err_code = 0; |
1210 | 1176 | ||
1211 | PDEBUG(DBG_IO, ""); | 1177 | PDEBUG(DBG_IO, ""); |
1212 | 1178 | ||
1213 | mutex_lock(&usbvision->lock); | ||
1214 | |||
1215 | /* Set packet size to 0 */ | 1179 | /* Set packet size to 0 */ |
1216 | usbvision->ifaceAlt=0; | 1180 | usbvision->iface_alt = 0; |
1217 | errCode = usb_set_interface(usbvision->dev, usbvision->iface, | 1181 | err_code = usb_set_interface(usbvision->dev, usbvision->iface, |
1218 | usbvision->ifaceAlt); | 1182 | usbvision->iface_alt); |
1219 | 1183 | ||
1220 | usbvision_audio_off(usbvision); | 1184 | usbvision_audio_off(usbvision); |
1221 | usbvision->radio=0; | 1185 | usbvision->radio = 0; |
1222 | usbvision->user--; | 1186 | usbvision->user--; |
1223 | 1187 | ||
1224 | if (PowerOnAtOpen) { | 1188 | if (power_on_at_open) { |
1225 | usbvision_set_powerOffTimer(usbvision); | 1189 | usbvision_set_power_off_timer(usbvision); |
1226 | usbvision->initialized = 0; | 1190 | usbvision->initialized = 0; |
1227 | } | 1191 | } |
1228 | 1192 | ||
1229 | mutex_unlock(&usbvision->lock); | ||
1230 | |||
1231 | if (usbvision->remove_pending) { | 1193 | if (usbvision->remove_pending) { |
1232 | printk(KERN_INFO "%s: Final disconnect\n", __func__); | 1194 | printk(KERN_INFO "%s: Final disconnect\n", __func__); |
1233 | usbvision_release(usbvision); | 1195 | usbvision_release(usbvision); |
1234 | } | 1196 | } |
1235 | 1197 | ||
1236 | PDEBUG(DBG_IO, "success"); | 1198 | PDEBUG(DBG_IO, "success"); |
1237 | return errCode; | 1199 | return err_code; |
1238 | } | 1200 | } |
1239 | 1201 | ||
1240 | // | 1202 | /* Video registration stuff */ |
1241 | // Video registration stuff | ||
1242 | // | ||
1243 | 1203 | ||
1244 | // Video template | 1204 | /* Video template */ |
1245 | static const struct v4l2_file_operations usbvision_fops = { | 1205 | static const struct v4l2_file_operations usbvision_fops = { |
1246 | .owner = THIS_MODULE, | 1206 | .owner = THIS_MODULE, |
1247 | .open = usbvision_v4l2_open, | 1207 | .open = usbvision_v4l2_open, |
1248 | .release = usbvision_v4l2_close, | 1208 | .release = usbvision_v4l2_close, |
1249 | .read = usbvision_v4l2_read, | 1209 | .read = usbvision_v4l2_read, |
1250 | .mmap = usbvision_v4l2_mmap, | 1210 | .mmap = usbvision_v4l2_mmap, |
1251 | .ioctl = video_ioctl2, | 1211 | .unlocked_ioctl = video_ioctl2, |
1252 | /* .poll = video_poll, */ | 1212 | /* .poll = video_poll, */ |
1253 | }; | 1213 | }; |
1254 | 1214 | ||
1255 | static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { | 1215 | static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { |
@@ -1273,9 +1233,6 @@ static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { | |||
1273 | .vidioc_s_ctrl = vidioc_s_ctrl, | 1233 | .vidioc_s_ctrl = vidioc_s_ctrl, |
1274 | .vidioc_streamon = vidioc_streamon, | 1234 | .vidioc_streamon = vidioc_streamon, |
1275 | .vidioc_streamoff = vidioc_streamoff, | 1235 | .vidioc_streamoff = vidioc_streamoff, |
1276 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
1277 | /* .vidiocgmbuf = vidiocgmbuf, */ | ||
1278 | #endif | ||
1279 | .vidioc_g_tuner = vidioc_g_tuner, | 1236 | .vidioc_g_tuner = vidioc_g_tuner, |
1280 | .vidioc_s_tuner = vidioc_s_tuner, | 1237 | .vidioc_s_tuner = vidioc_s_tuner, |
1281 | .vidioc_g_frequency = vidioc_g_frequency, | 1238 | .vidioc_g_frequency = vidioc_g_frequency, |
@@ -1288,20 +1245,20 @@ static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { | |||
1288 | 1245 | ||
1289 | static struct video_device usbvision_video_template = { | 1246 | static struct video_device usbvision_video_template = { |
1290 | .fops = &usbvision_fops, | 1247 | .fops = &usbvision_fops, |
1291 | .ioctl_ops = &usbvision_ioctl_ops, | 1248 | .ioctl_ops = &usbvision_ioctl_ops, |
1292 | .name = "usbvision-video", | 1249 | .name = "usbvision-video", |
1293 | .release = video_device_release, | 1250 | .release = video_device_release, |
1294 | .tvnorms = USBVISION_NORMS, | 1251 | .tvnorms = USBVISION_NORMS, |
1295 | .current_norm = V4L2_STD_PAL | 1252 | .current_norm = V4L2_STD_PAL |
1296 | }; | 1253 | }; |
1297 | 1254 | ||
1298 | 1255 | ||
1299 | // Radio template | 1256 | /* Radio template */ |
1300 | static const struct v4l2_file_operations usbvision_radio_fops = { | 1257 | static const struct v4l2_file_operations usbvision_radio_fops = { |
1301 | .owner = THIS_MODULE, | 1258 | .owner = THIS_MODULE, |
1302 | .open = usbvision_radio_open, | 1259 | .open = usbvision_radio_open, |
1303 | .release = usbvision_radio_close, | 1260 | .release = usbvision_radio_close, |
1304 | .ioctl = video_ioctl2, | 1261 | .unlocked_ioctl = video_ioctl2, |
1305 | }; | 1262 | }; |
1306 | 1263 | ||
1307 | static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = { | 1264 | static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = { |
@@ -1322,9 +1279,9 @@ static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = { | |||
1322 | 1279 | ||
1323 | static struct video_device usbvision_radio_template = { | 1280 | static struct video_device usbvision_radio_template = { |
1324 | .fops = &usbvision_radio_fops, | 1281 | .fops = &usbvision_radio_fops, |
1325 | .name = "usbvision-radio", | 1282 | .name = "usbvision-radio", |
1326 | .release = video_device_release, | 1283 | .release = video_device_release, |
1327 | .ioctl_ops = &usbvision_radio_ioctl_ops, | 1284 | .ioctl_ops = &usbvision_radio_ioctl_ops, |
1328 | 1285 | ||
1329 | .tvnorms = USBVISION_NORMS, | 1286 | .tvnorms = USBVISION_NORMS, |
1330 | .current_norm = V4L2_STD_PAL | 1287 | .current_norm = V4L2_STD_PAL |
@@ -1345,80 +1302,70 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision, | |||
1345 | } | 1302 | } |
1346 | 1303 | ||
1347 | vdev = video_device_alloc(); | 1304 | vdev = video_device_alloc(); |
1348 | if (NULL == vdev) { | 1305 | if (NULL == vdev) |
1349 | return NULL; | 1306 | return NULL; |
1350 | } | ||
1351 | *vdev = *vdev_template; | 1307 | *vdev = *vdev_template; |
1308 | vdev->lock = &usbvision->v4l2_lock; | ||
1352 | vdev->v4l2_dev = &usbvision->v4l2_dev; | 1309 | vdev->v4l2_dev = &usbvision->v4l2_dev; |
1353 | snprintf(vdev->name, sizeof(vdev->name), "%s", name); | 1310 | snprintf(vdev->name, sizeof(vdev->name), "%s", name); |
1354 | video_set_drvdata(vdev, usbvision); | 1311 | video_set_drvdata(vdev, usbvision); |
1355 | return vdev; | 1312 | return vdev; |
1356 | } | 1313 | } |
1357 | 1314 | ||
1358 | // unregister video4linux devices | 1315 | /* unregister video4linux devices */ |
1359 | static void usbvision_unregister_video(struct usb_usbvision *usbvision) | 1316 | static void usbvision_unregister_video(struct usb_usbvision *usbvision) |
1360 | { | 1317 | { |
1361 | // Radio Device: | 1318 | /* Radio Device: */ |
1362 | if (usbvision->rdev) { | 1319 | if (usbvision->rdev) { |
1363 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", | 1320 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", |
1364 | video_device_node_name(usbvision->rdev)); | 1321 | video_device_node_name(usbvision->rdev)); |
1365 | if (video_is_registered(usbvision->rdev)) { | 1322 | if (video_is_registered(usbvision->rdev)) |
1366 | video_unregister_device(usbvision->rdev); | 1323 | video_unregister_device(usbvision->rdev); |
1367 | } else { | 1324 | else |
1368 | video_device_release(usbvision->rdev); | 1325 | video_device_release(usbvision->rdev); |
1369 | } | ||
1370 | usbvision->rdev = NULL; | 1326 | usbvision->rdev = NULL; |
1371 | } | 1327 | } |
1372 | 1328 | ||
1373 | // Video Device: | 1329 | /* Video Device: */ |
1374 | if (usbvision->vdev) { | 1330 | if (usbvision->vdev) { |
1375 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", | 1331 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", |
1376 | video_device_node_name(usbvision->vdev)); | 1332 | video_device_node_name(usbvision->vdev)); |
1377 | if (video_is_registered(usbvision->vdev)) { | 1333 | if (video_is_registered(usbvision->vdev)) |
1378 | video_unregister_device(usbvision->vdev); | 1334 | video_unregister_device(usbvision->vdev); |
1379 | } else { | 1335 | else |
1380 | video_device_release(usbvision->vdev); | 1336 | video_device_release(usbvision->vdev); |
1381 | } | ||
1382 | usbvision->vdev = NULL; | 1337 | usbvision->vdev = NULL; |
1383 | } | 1338 | } |
1384 | } | 1339 | } |
1385 | 1340 | ||
1386 | // register video4linux devices | 1341 | /* register video4linux devices */ |
1387 | static int __devinit usbvision_register_video(struct usb_usbvision *usbvision) | 1342 | static int __devinit usbvision_register_video(struct usb_usbvision *usbvision) |
1388 | { | 1343 | { |
1389 | // Video Device: | 1344 | /* Video Device: */ |
1390 | usbvision->vdev = usbvision_vdev_init(usbvision, | 1345 | usbvision->vdev = usbvision_vdev_init(usbvision, |
1391 | &usbvision_video_template, | 1346 | &usbvision_video_template, |
1392 | "USBVision Video"); | 1347 | "USBVision Video"); |
1393 | if (usbvision->vdev == NULL) { | 1348 | if (usbvision->vdev == NULL) |
1394 | goto err_exit; | 1349 | goto err_exit; |
1395 | } | 1350 | if (video_register_device(usbvision->vdev, VFL_TYPE_GRABBER, video_nr) < 0) |
1396 | if (video_register_device(usbvision->vdev, | ||
1397 | VFL_TYPE_GRABBER, | ||
1398 | video_nr)<0) { | ||
1399 | goto err_exit; | 1351 | goto err_exit; |
1400 | } | ||
1401 | printk(KERN_INFO "USBVision[%d]: registered USBVision Video device %s [v4l2]\n", | 1352 | printk(KERN_INFO "USBVision[%d]: registered USBVision Video device %s [v4l2]\n", |
1402 | usbvision->nr, video_device_node_name(usbvision->vdev)); | 1353 | usbvision->nr, video_device_node_name(usbvision->vdev)); |
1403 | 1354 | ||
1404 | // Radio Device: | 1355 | /* Radio Device: */ |
1405 | if (usbvision_device_data[usbvision->DevModel].Radio) { | 1356 | if (usbvision_device_data[usbvision->dev_model].radio) { |
1406 | // usbvision has radio | 1357 | /* usbvision has radio */ |
1407 | usbvision->rdev = usbvision_vdev_init(usbvision, | 1358 | usbvision->rdev = usbvision_vdev_init(usbvision, |
1408 | &usbvision_radio_template, | 1359 | &usbvision_radio_template, |
1409 | "USBVision Radio"); | 1360 | "USBVision Radio"); |
1410 | if (usbvision->rdev == NULL) { | 1361 | if (usbvision->rdev == NULL) |
1411 | goto err_exit; | 1362 | goto err_exit; |
1412 | } | 1363 | if (video_register_device(usbvision->rdev, VFL_TYPE_RADIO, radio_nr) < 0) |
1413 | if (video_register_device(usbvision->rdev, | ||
1414 | VFL_TYPE_RADIO, | ||
1415 | radio_nr)<0) { | ||
1416 | goto err_exit; | 1364 | goto err_exit; |
1417 | } | ||
1418 | printk(KERN_INFO "USBVision[%d]: registered USBVision Radio device %s [v4l2]\n", | 1365 | printk(KERN_INFO "USBVision[%d]: registered USBVision Radio device %s [v4l2]\n", |
1419 | usbvision->nr, video_device_node_name(usbvision->rdev)); | 1366 | usbvision->nr, video_device_node_name(usbvision->rdev)); |
1420 | } | 1367 | } |
1421 | // all done | 1368 | /* all done */ |
1422 | return 0; | 1369 | return 0; |
1423 | 1370 | ||
1424 | err_exit: | 1371 | err_exit: |
@@ -1451,15 +1398,15 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev, | |||
1451 | if (v4l2_device_register(&intf->dev, &usbvision->v4l2_dev)) | 1398 | if (v4l2_device_register(&intf->dev, &usbvision->v4l2_dev)) |
1452 | goto err_free; | 1399 | goto err_free; |
1453 | 1400 | ||
1454 | mutex_init(&usbvision->lock); /* available */ | 1401 | mutex_init(&usbvision->v4l2_lock); |
1455 | 1402 | ||
1456 | // prepare control urb for control messages during interrupts | 1403 | /* prepare control urb for control messages during interrupts */ |
1457 | usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); | 1404 | usbvision->ctrl_urb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); |
1458 | if (usbvision->ctrlUrb == NULL) | 1405 | if (usbvision->ctrl_urb == NULL) |
1459 | goto err_unreg; | 1406 | goto err_unreg; |
1460 | init_waitqueue_head(&usbvision->ctrlUrb_wq); | 1407 | init_waitqueue_head(&usbvision->ctrl_urb_wq); |
1461 | 1408 | ||
1462 | usbvision_init_powerOffTimer(usbvision); | 1409 | usbvision_init_power_off_timer(usbvision); |
1463 | 1410 | ||
1464 | return usbvision; | 1411 | return usbvision; |
1465 | 1412 | ||
@@ -1481,20 +1428,14 @@ static void usbvision_release(struct usb_usbvision *usbvision) | |||
1481 | { | 1428 | { |
1482 | PDEBUG(DBG_PROBE, ""); | 1429 | PDEBUG(DBG_PROBE, ""); |
1483 | 1430 | ||
1484 | mutex_lock(&usbvision->lock); | 1431 | usbvision_reset_power_off_timer(usbvision); |
1485 | |||
1486 | usbvision_reset_powerOffTimer(usbvision); | ||
1487 | 1432 | ||
1488 | usbvision->initialized = 0; | 1433 | usbvision->initialized = 0; |
1489 | 1434 | ||
1490 | mutex_unlock(&usbvision->lock); | ||
1491 | |||
1492 | usbvision_remove_sysfs(usbvision->vdev); | 1435 | usbvision_remove_sysfs(usbvision->vdev); |
1493 | usbvision_unregister_video(usbvision); | 1436 | usbvision_unregister_video(usbvision); |
1494 | 1437 | ||
1495 | if (usbvision->ctrlUrb) { | 1438 | usb_free_urb(usbvision->ctrl_urb); |
1496 | usb_free_urb(usbvision->ctrlUrb); | ||
1497 | } | ||
1498 | 1439 | ||
1499 | v4l2_device_unregister(&usbvision->v4l2_dev); | 1440 | v4l2_device_unregister(&usbvision->v4l2_dev); |
1500 | kfree(usbvision); | 1441 | kfree(usbvision); |
@@ -1512,25 +1453,25 @@ static void usbvision_configure_video(struct usb_usbvision *usbvision) | |||
1512 | if (usbvision == NULL) | 1453 | if (usbvision == NULL) |
1513 | return; | 1454 | return; |
1514 | 1455 | ||
1515 | model = usbvision->DevModel; | 1456 | model = usbvision->dev_model; |
1516 | usbvision->palette = usbvision_v4l2_format[2]; // V4L2_PIX_FMT_RGB24; | 1457 | usbvision->palette = usbvision_v4l2_format[2]; /* V4L2_PIX_FMT_RGB24; */ |
1517 | 1458 | ||
1518 | if (usbvision_device_data[usbvision->DevModel].Vin_Reg2_override) { | 1459 | if (usbvision_device_data[usbvision->dev_model].vin_reg2_override) { |
1519 | usbvision->Vin_Reg2_Preset = | 1460 | usbvision->vin_reg2_preset = |
1520 | usbvision_device_data[usbvision->DevModel].Vin_Reg2; | 1461 | usbvision_device_data[usbvision->dev_model].vin_reg2; |
1521 | } else { | 1462 | } else { |
1522 | usbvision->Vin_Reg2_Preset = 0; | 1463 | usbvision->vin_reg2_preset = 0; |
1523 | } | 1464 | } |
1524 | 1465 | ||
1525 | usbvision->tvnormId = usbvision_device_data[model].VideoNorm; | 1466 | usbvision->tvnorm_id = usbvision_device_data[model].video_norm; |
1526 | 1467 | ||
1527 | usbvision->video_inputs = usbvision_device_data[model].VideoChannels; | 1468 | usbvision->video_inputs = usbvision_device_data[model].video_channels; |
1528 | usbvision->ctl_input = 0; | 1469 | usbvision->ctl_input = 0; |
1529 | 1470 | ||
1530 | /* This should be here to make i2c clients to be able to register */ | 1471 | /* This should be here to make i2c clients to be able to register */ |
1531 | /* first switch off audio */ | 1472 | /* first switch off audio */ |
1532 | usbvision_audio_off(usbvision); | 1473 | usbvision_audio_off(usbvision); |
1533 | if (!PowerOnAtOpen) { | 1474 | if (!power_on_at_open) { |
1534 | /* and then power up the noisy tuner */ | 1475 | /* and then power up the noisy tuner */ |
1535 | usbvision_power_on(usbvision); | 1476 | usbvision_power_on(usbvision); |
1536 | usbvision_i2c_register(usbvision); | 1477 | usbvision_i2c_register(usbvision); |
@@ -1553,25 +1494,24 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1553 | const struct usb_host_interface *interface; | 1494 | const struct usb_host_interface *interface; |
1554 | struct usb_usbvision *usbvision = NULL; | 1495 | struct usb_usbvision *usbvision = NULL; |
1555 | const struct usb_endpoint_descriptor *endpoint; | 1496 | const struct usb_endpoint_descriptor *endpoint; |
1556 | int model,i; | 1497 | int model, i; |
1557 | 1498 | ||
1558 | PDEBUG(DBG_PROBE, "VID=%#04x, PID=%#04x, ifnum=%u", | 1499 | PDEBUG(DBG_PROBE, "VID=%#04x, PID=%#04x, ifnum=%u", |
1559 | dev->descriptor.idVendor, | 1500 | dev->descriptor.idVendor, |
1560 | dev->descriptor.idProduct, ifnum); | 1501 | dev->descriptor.idProduct, ifnum); |
1561 | 1502 | ||
1562 | model = devid->driver_info; | 1503 | model = devid->driver_info; |
1563 | if ( (model<0) || (model>=usbvision_device_data_size) ) { | 1504 | if (model < 0 || model >= usbvision_device_data_size) { |
1564 | PDEBUG(DBG_PROBE, "model out of bounds %d",model); | 1505 | PDEBUG(DBG_PROBE, "model out of bounds %d", model); |
1565 | return -ENODEV; | 1506 | return -ENODEV; |
1566 | } | 1507 | } |
1567 | printk(KERN_INFO "%s: %s found\n", __func__, | 1508 | printk(KERN_INFO "%s: %s found\n", __func__, |
1568 | usbvision_device_data[model].ModelString); | 1509 | usbvision_device_data[model].model_string); |
1569 | 1510 | ||
1570 | if (usbvision_device_data[model].Interface >= 0) { | 1511 | if (usbvision_device_data[model].interface >= 0) |
1571 | interface = &dev->actconfig->interface[usbvision_device_data[model].Interface]->altsetting[0]; | 1512 | interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0]; |
1572 | } else { | 1513 | else |
1573 | interface = &dev->actconfig->interface[ifnum]->altsetting[0]; | 1514 | interface = &dev->actconfig->interface[ifnum]->altsetting[0]; |
1574 | } | ||
1575 | endpoint = &interface->endpoint[1].desc; | 1515 | endpoint = &interface->endpoint[1].desc; |
1576 | if (!usb_endpoint_xfer_isoc(endpoint)) { | 1516 | if (!usb_endpoint_xfer_isoc(endpoint)) { |
1577 | dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n", | 1517 | dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n", |
@@ -1592,59 +1532,52 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1592 | return -ENOMEM; | 1532 | return -ENOMEM; |
1593 | } | 1533 | } |
1594 | 1534 | ||
1595 | if (dev->descriptor.bNumConfigurations > 1) { | 1535 | if (dev->descriptor.bNumConfigurations > 1) |
1596 | usbvision->bridgeType = BRIDGE_NT1004; | 1536 | usbvision->bridge_type = BRIDGE_NT1004; |
1597 | } else if (model == DAZZLE_DVC_90_REV_1_SECAM) { | 1537 | else if (model == DAZZLE_DVC_90_REV_1_SECAM) |
1598 | usbvision->bridgeType = BRIDGE_NT1005; | 1538 | usbvision->bridge_type = BRIDGE_NT1005; |
1599 | } else { | 1539 | else |
1600 | usbvision->bridgeType = BRIDGE_NT1003; | 1540 | usbvision->bridge_type = BRIDGE_NT1003; |
1601 | } | 1541 | PDEBUG(DBG_PROBE, "bridge_type %d", usbvision->bridge_type); |
1602 | PDEBUG(DBG_PROBE, "bridgeType %d", usbvision->bridgeType); | ||
1603 | |||
1604 | mutex_lock(&usbvision->lock); | ||
1605 | 1542 | ||
1606 | /* compute alternate max packet sizes */ | 1543 | /* compute alternate max packet sizes */ |
1607 | uif = dev->actconfig->interface[0]; | 1544 | uif = dev->actconfig->interface[0]; |
1608 | 1545 | ||
1609 | usbvision->num_alt=uif->num_altsetting; | 1546 | usbvision->num_alt = uif->num_altsetting; |
1610 | PDEBUG(DBG_PROBE, "Alternate settings: %i",usbvision->num_alt); | 1547 | PDEBUG(DBG_PROBE, "Alternate settings: %i", usbvision->num_alt); |
1611 | usbvision->alt_max_pkt_size = kmalloc(32* | 1548 | usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL); |
1612 | usbvision->num_alt,GFP_KERNEL); | ||
1613 | if (usbvision->alt_max_pkt_size == NULL) { | 1549 | if (usbvision->alt_max_pkt_size == NULL) { |
1614 | dev_err(&intf->dev, "usbvision: out of memory!\n"); | 1550 | dev_err(&intf->dev, "usbvision: out of memory!\n"); |
1615 | mutex_unlock(&usbvision->lock); | ||
1616 | return -ENOMEM; | 1551 | return -ENOMEM; |
1617 | } | 1552 | } |
1618 | 1553 | ||
1619 | for (i = 0; i < usbvision->num_alt ; i++) { | 1554 | for (i = 0; i < usbvision->num_alt; i++) { |
1620 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[1].desc. | 1555 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[1].desc. |
1621 | wMaxPacketSize); | 1556 | wMaxPacketSize); |
1622 | usbvision->alt_max_pkt_size[i] = | 1557 | usbvision->alt_max_pkt_size[i] = |
1623 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 1558 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
1624 | PDEBUG(DBG_PROBE, "Alternate setting %i, max size= %i",i, | 1559 | PDEBUG(DBG_PROBE, "Alternate setting %i, max size= %i", i, |
1625 | usbvision->alt_max_pkt_size[i]); | 1560 | usbvision->alt_max_pkt_size[i]); |
1626 | } | 1561 | } |
1627 | 1562 | ||
1628 | 1563 | ||
1629 | usbvision->nr = usbvision_nr++; | 1564 | usbvision->nr = usbvision_nr++; |
1630 | 1565 | ||
1631 | usbvision->have_tuner = usbvision_device_data[model].Tuner; | 1566 | usbvision->have_tuner = usbvision_device_data[model].tuner; |
1632 | if (usbvision->have_tuner) { | 1567 | if (usbvision->have_tuner) |
1633 | usbvision->tuner_type = usbvision_device_data[model].TunerType; | 1568 | usbvision->tuner_type = usbvision_device_data[model].tuner_type; |
1634 | } | ||
1635 | 1569 | ||
1636 | usbvision->DevModel = model; | 1570 | usbvision->dev_model = model; |
1637 | usbvision->remove_pending = 0; | 1571 | usbvision->remove_pending = 0; |
1638 | usbvision->iface = ifnum; | 1572 | usbvision->iface = ifnum; |
1639 | usbvision->ifaceAlt = 0; | 1573 | usbvision->iface_alt = 0; |
1640 | usbvision->video_endp = endpoint->bEndpointAddress; | 1574 | usbvision->video_endp = endpoint->bEndpointAddress; |
1641 | usbvision->isocPacketSize = 0; | 1575 | usbvision->isoc_packet_size = 0; |
1642 | usbvision->usb_bandwidth = 0; | 1576 | usbvision->usb_bandwidth = 0; |
1643 | usbvision->user = 0; | 1577 | usbvision->user = 0; |
1644 | usbvision->streaming = Stream_Off; | 1578 | usbvision->streaming = stream_off; |
1645 | usbvision_configure_video(usbvision); | 1579 | usbvision_configure_video(usbvision); |
1646 | usbvision_register_video(usbvision); | 1580 | usbvision_register_video(usbvision); |
1647 | mutex_unlock(&usbvision->lock); | ||
1648 | 1581 | ||
1649 | usbvision_create_sysfs(usbvision->vdev); | 1582 | usbvision_create_sysfs(usbvision->vdev); |
1650 | 1583 | ||
@@ -1672,9 +1605,9 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf) | |||
1672 | return; | 1605 | return; |
1673 | } | 1606 | } |
1674 | 1607 | ||
1675 | mutex_lock(&usbvision->lock); | 1608 | mutex_lock(&usbvision->v4l2_lock); |
1676 | 1609 | ||
1677 | // At this time we ask to cancel outstanding URBs | 1610 | /* At this time we ask to cancel outstanding URBs */ |
1678 | usbvision_stop_isoc(usbvision); | 1611 | usbvision_stop_isoc(usbvision); |
1679 | 1612 | ||
1680 | v4l2_device_disconnect(&usbvision->v4l2_dev); | 1613 | v4l2_device_disconnect(&usbvision->v4l2_dev); |
@@ -1683,12 +1616,12 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf) | |||
1683 | usbvision_i2c_unregister(usbvision); | 1616 | usbvision_i2c_unregister(usbvision); |
1684 | usbvision_power_off(usbvision); | 1617 | usbvision_power_off(usbvision); |
1685 | } | 1618 | } |
1686 | usbvision->remove_pending = 1; // Now all ISO data will be ignored | 1619 | usbvision->remove_pending = 1; /* Now all ISO data will be ignored */ |
1687 | 1620 | ||
1688 | usb_put_dev(usbvision->dev); | 1621 | usb_put_dev(usbvision->dev); |
1689 | usbvision->dev = NULL; // USB device is no more | 1622 | usbvision->dev = NULL; /* USB device is no more */ |
1690 | 1623 | ||
1691 | mutex_unlock(&usbvision->lock); | 1624 | mutex_unlock(&usbvision->v4l2_lock); |
1692 | 1625 | ||
1693 | if (usbvision->user) { | 1626 | if (usbvision->user) { |
1694 | printk(KERN_INFO "%s: In use, disconnect pending\n", | 1627 | printk(KERN_INFO "%s: In use, disconnect pending\n", |
@@ -1717,7 +1650,7 @@ static struct usb_driver usbvision_driver = { | |||
1717 | */ | 1650 | */ |
1718 | static int __init usbvision_init(void) | 1651 | static int __init usbvision_init(void) |
1719 | { | 1652 | { |
1720 | int errCode; | 1653 | int err_code; |
1721 | 1654 | ||
1722 | PDEBUG(DBG_PROBE, ""); | 1655 | PDEBUG(DBG_PROBE, ""); |
1723 | 1656 | ||
@@ -1726,27 +1659,27 @@ static int __init usbvision_init(void) | |||
1726 | PDEBUG(DBG_MMAP, "MMAP debugging is enabled [video]"); | 1659 | PDEBUG(DBG_MMAP, "MMAP debugging is enabled [video]"); |
1727 | 1660 | ||
1728 | /* disable planar mode support unless compression enabled */ | 1661 | /* disable planar mode support unless compression enabled */ |
1729 | if (isocMode != ISOC_MODE_COMPRESS ) { | 1662 | if (isoc_mode != ISOC_MODE_COMPRESS) { |
1730 | // FIXME : not the right way to set supported flag | 1663 | /* FIXME : not the right way to set supported flag */ |
1731 | usbvision_v4l2_format[6].supported = 0; // V4L2_PIX_FMT_YVU420 | 1664 | usbvision_v4l2_format[6].supported = 0; /* V4L2_PIX_FMT_YVU420 */ |
1732 | usbvision_v4l2_format[7].supported = 0; // V4L2_PIX_FMT_YUV422P | 1665 | usbvision_v4l2_format[7].supported = 0; /* V4L2_PIX_FMT_YUV422P */ |
1733 | } | 1666 | } |
1734 | 1667 | ||
1735 | errCode = usb_register(&usbvision_driver); | 1668 | err_code = usb_register(&usbvision_driver); |
1736 | 1669 | ||
1737 | if (errCode == 0) { | 1670 | if (err_code == 0) { |
1738 | printk(KERN_INFO DRIVER_DESC " : " USBVISION_VERSION_STRING "\n"); | 1671 | printk(KERN_INFO DRIVER_DESC " : " USBVISION_VERSION_STRING "\n"); |
1739 | PDEBUG(DBG_PROBE, "success"); | 1672 | PDEBUG(DBG_PROBE, "success"); |
1740 | } | 1673 | } |
1741 | return errCode; | 1674 | return err_code; |
1742 | } | 1675 | } |
1743 | 1676 | ||
1744 | static void __exit usbvision_exit(void) | 1677 | static void __exit usbvision_exit(void) |
1745 | { | 1678 | { |
1746 | PDEBUG(DBG_PROBE, ""); | 1679 | PDEBUG(DBG_PROBE, ""); |
1747 | 1680 | ||
1748 | usb_deregister(&usbvision_driver); | 1681 | usb_deregister(&usbvision_driver); |
1749 | PDEBUG(DBG_PROBE, "success"); | 1682 | PDEBUG(DBG_PROBE, "success"); |
1750 | } | 1683 | } |
1751 | 1684 | ||
1752 | module_init(usbvision_init); | 1685 | module_init(usbvision_init); |