diff options
author | Ladislav Michl <ladis@linux-mips.org> | 2005-09-01 11:07:34 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2005-11-07 13:05:41 -0500 |
commit | a637a114f36b94a1ad8b9867f43bac0414958420 (patch) | |
tree | 3ad9a5c60817c8d0b4e2de30672da706c44ecbfa /drivers/media/video/vino.c | |
parent | a06d61c648890ad7e86d5ea04bd6999b254db193 (diff) |
VINO driver version 0.0.5.
Second cut of the VINO / Indycam driver for the Silicon Graphics Indy,
much more feature complete and bug free.
Diffstat (limited to 'drivers/media/video/vino.c')
-rw-r--r-- | drivers/media/video/vino.c | 1170 |
1 files changed, 779 insertions, 391 deletions
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c index ed4394e854ab..71b28e9e0850 100644 --- a/drivers/media/video/vino.c +++ b/drivers/media/video/vino.c | |||
@@ -12,15 +12,11 @@ | |||
12 | 12 | ||
13 | /* | 13 | /* |
14 | * TODO: | 14 | * TODO: |
15 | * - remove "hacks" from memory allocation code and implement nopage() | 15 | * - remove "mark pages reserved-hacks" from memory allocation code |
16 | * and implement nopage() | ||
16 | * - check decimation, calculating and reporting image size when | 17 | * - check decimation, calculating and reporting image size when |
17 | * using decimation | 18 | * using decimation |
18 | * - check vino_acquire_input(), vino_set_input() and channel | 19 | * - implement read(), user mode buffers and overlay (?) |
19 | * ownership handling | ||
20 | * - report VINO error-interrupts via ioctls ? | ||
21 | * - implement picture controls (all implemented?) | ||
22 | * - use macros for boolean values (?) | ||
23 | * - implement user mode buffers and overlay (?) | ||
24 | */ | 20 | */ |
25 | 21 | ||
26 | #include <linux/init.h> | 22 | #include <linux/init.h> |
@@ -60,18 +56,16 @@ | |||
60 | * debug info. | 56 | * debug info. |
61 | * Note that the debug output also slows down the driver significantly */ | 57 | * Note that the debug output also slows down the driver significantly */ |
62 | // #define VINO_DEBUG | 58 | // #define VINO_DEBUG |
59 | // #define VINO_DEBUG_INT | ||
63 | 60 | ||
64 | #define VINO_MODULE_VERSION "0.0.3" | 61 | #define VINO_MODULE_VERSION "0.0.5" |
65 | #define VINO_VERSION_CODE KERNEL_VERSION(0, 0, 3) | 62 | #define VINO_VERSION_CODE KERNEL_VERSION(0, 0, 5) |
66 | 63 | ||
67 | MODULE_DESCRIPTION("SGI VINO Video4Linux2 driver"); | 64 | MODULE_DESCRIPTION("SGI VINO Video4Linux2 driver"); |
68 | MODULE_VERSION(VINO_MODULE_VERSION); | 65 | MODULE_VERSION(VINO_MODULE_VERSION); |
69 | MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); | 66 | MODULE_AUTHOR("Mikael Nousiainen <tmnousia@cc.hut.fi>"); |
70 | MODULE_LICENSE("GPL"); | 67 | MODULE_LICENSE("GPL"); |
71 | 68 | ||
72 | #define mem_map_reserve(p) set_bit(PG_reserved, &((p)->flags)) | ||
73 | #define mem_map_unreserve(p) clear_bit(PG_reserved, &((p)->flags)) | ||
74 | |||
75 | #ifdef VINO_DEBUG | 69 | #ifdef VINO_DEBUG |
76 | #define dprintk(x...) printk("VINO: " x); | 70 | #define dprintk(x...) printk("VINO: " x); |
77 | #else | 71 | #else |
@@ -91,15 +85,16 @@ MODULE_LICENSE("GPL"); | |||
91 | #define VINO_MIN_HEIGHT 32 | 85 | #define VINO_MIN_HEIGHT 32 |
92 | 86 | ||
93 | #define VINO_CLIPPING_START_ODD_D1 1 | 87 | #define VINO_CLIPPING_START_ODD_D1 1 |
94 | #define VINO_CLIPPING_START_ODD_PAL 1 | 88 | #define VINO_CLIPPING_START_ODD_PAL 15 |
95 | #define VINO_CLIPPING_START_ODD_NTSC 1 | 89 | #define VINO_CLIPPING_START_ODD_NTSC 12 |
96 | 90 | ||
97 | #define VINO_CLIPPING_START_EVEN_D1 2 | 91 | #define VINO_CLIPPING_START_EVEN_D1 2 |
98 | #define VINO_CLIPPING_START_EVEN_PAL 2 | 92 | #define VINO_CLIPPING_START_EVEN_PAL 15 |
99 | #define VINO_CLIPPING_START_EVEN_NTSC 2 | 93 | #define VINO_CLIPPING_START_EVEN_NTSC 12 |
100 | 94 | ||
101 | #define VINO_INPUT_CHANNEL_COUNT 3 | 95 | #define VINO_INPUT_CHANNEL_COUNT 3 |
102 | 96 | ||
97 | /* the number is the index for vino_inputs */ | ||
103 | #define VINO_INPUT_NONE -1 | 98 | #define VINO_INPUT_NONE -1 |
104 | #define VINO_INPUT_COMPOSITE 0 | 99 | #define VINO_INPUT_COMPOSITE 0 |
105 | #define VINO_INPUT_SVIDEO 1 | 100 | #define VINO_INPUT_SVIDEO 1 |
@@ -107,15 +102,13 @@ MODULE_LICENSE("GPL"); | |||
107 | 102 | ||
108 | #define VINO_PAGE_RATIO (PAGE_SIZE / VINO_PAGE_SIZE) | 103 | #define VINO_PAGE_RATIO (PAGE_SIZE / VINO_PAGE_SIZE) |
109 | 104 | ||
110 | #define VINO_FIFO_THRESHOLD_DEFAULT 512 | 105 | #define VINO_FIFO_THRESHOLD_DEFAULT 16 |
111 | 106 | ||
112 | /*#define VINO_FRAMEBUFFER_SIZE (VINO_PAL_WIDTH * VINO_PAL_HEIGHT * 4 \ | ||
113 | + 2 * PAGE_SIZE)*/ | ||
114 | #define VINO_FRAMEBUFFER_SIZE ((VINO_PAL_WIDTH \ | 107 | #define VINO_FRAMEBUFFER_SIZE ((VINO_PAL_WIDTH \ |
115 | * VINO_PAL_HEIGHT * 4 \ | 108 | * VINO_PAL_HEIGHT * 4 \ |
116 | + 3 * PAGE_SIZE) & ~(PAGE_SIZE - 1)) | 109 | + 3 * PAGE_SIZE) & ~(PAGE_SIZE - 1)) |
117 | 110 | ||
118 | #define VINO_FRAMEBUFFER_MAX_COUNT 8 | 111 | #define VINO_FRAMEBUFFER_COUNT_MAX 8 |
119 | 112 | ||
120 | #define VINO_FRAMEBUFFER_UNUSED 0 | 113 | #define VINO_FRAMEBUFFER_UNUSED 0 |
121 | #define VINO_FRAMEBUFFER_IN_USE 1 | 114 | #define VINO_FRAMEBUFFER_IN_USE 1 |
@@ -131,24 +124,27 @@ MODULE_LICENSE("GPL"); | |||
131 | #define VINO_DUMMY_DESC_COUNT 4 | 124 | #define VINO_DUMMY_DESC_COUNT 4 |
132 | #define VINO_DESC_FETCH_DELAY 5 /* microseconds */ | 125 | #define VINO_DESC_FETCH_DELAY 5 /* microseconds */ |
133 | 126 | ||
127 | #define VINO_MAX_FRAME_SKIP_COUNT 128 | ||
128 | |||
134 | /* the number is the index for vino_data_formats */ | 129 | /* the number is the index for vino_data_formats */ |
135 | #define VINO_DATA_FMT_NONE -1 | 130 | #define VINO_DATA_FMT_NONE -1 |
136 | #define VINO_DATA_FMT_GREY 0 | 131 | #define VINO_DATA_FMT_GREY 0 |
137 | #define VINO_DATA_FMT_RGB332 1 | 132 | #define VINO_DATA_FMT_RGB332 1 |
138 | #define VINO_DATA_FMT_RGB32 2 | 133 | #define VINO_DATA_FMT_RGB32 2 |
139 | #define VINO_DATA_FMT_YUV 3 | 134 | #define VINO_DATA_FMT_YUV 3 |
140 | //#define VINO_DATA_FMT_RGB24 4 | ||
141 | 135 | ||
142 | #define VINO_DATA_FMT_COUNT 4 | 136 | #define VINO_DATA_FMT_COUNT 4 |
143 | 137 | ||
138 | /* the number is the index for vino_data_norms */ | ||
144 | #define VINO_DATA_NORM_NONE -1 | 139 | #define VINO_DATA_NORM_NONE -1 |
145 | #define VINO_DATA_NORM_NTSC 0 | 140 | #define VINO_DATA_NORM_NTSC 0 |
146 | #define VINO_DATA_NORM_PAL 1 | 141 | #define VINO_DATA_NORM_PAL 1 |
147 | #define VINO_DATA_NORM_SECAM 2 | 142 | #define VINO_DATA_NORM_SECAM 2 |
148 | #define VINO_DATA_NORM_D1 3 | 143 | #define VINO_DATA_NORM_D1 3 |
149 | /* The following is a special entry that can be used to | 144 | /* The following are special entries that can be used to |
150 | * autodetect the norm. */ | 145 | * autodetect the norm. */ |
151 | #define VINO_DATA_NORM_AUTO 0xff | 146 | #define VINO_DATA_NORM_AUTO 0xfe |
147 | #define VINO_DATA_NORM_AUTO_EXT 0xff | ||
152 | 148 | ||
153 | #define VINO_DATA_NORM_COUNT 4 | 149 | #define VINO_DATA_NORM_COUNT 4 |
154 | 150 | ||
@@ -232,7 +228,7 @@ struct vino_framebuffer_fifo { | |||
232 | unsigned int head; | 228 | unsigned int head; |
233 | unsigned int tail; | 229 | unsigned int tail; |
234 | 230 | ||
235 | unsigned int data[VINO_FRAMEBUFFER_MAX_COUNT]; | 231 | unsigned int data[VINO_FRAMEBUFFER_COUNT_MAX]; |
236 | }; | 232 | }; |
237 | 233 | ||
238 | struct vino_framebuffer_queue { | 234 | struct vino_framebuffer_queue { |
@@ -246,13 +242,20 @@ struct vino_framebuffer_queue { | |||
246 | struct vino_framebuffer_fifo in; | 242 | struct vino_framebuffer_fifo in; |
247 | struct vino_framebuffer_fifo out; | 243 | struct vino_framebuffer_fifo out; |
248 | 244 | ||
249 | struct vino_framebuffer *buffer[VINO_FRAMEBUFFER_MAX_COUNT]; | 245 | struct vino_framebuffer *buffer[VINO_FRAMEBUFFER_COUNT_MAX]; |
250 | 246 | ||
251 | spinlock_t queue_lock; | 247 | spinlock_t queue_lock; |
252 | struct semaphore queue_sem; | 248 | struct semaphore queue_sem; |
253 | wait_queue_head_t frame_wait_queue; | 249 | wait_queue_head_t frame_wait_queue; |
254 | }; | 250 | }; |
255 | 251 | ||
252 | struct vino_interrupt_data { | ||
253 | struct timeval timestamp; | ||
254 | unsigned int frame_counter; | ||
255 | unsigned int skip_count; | ||
256 | unsigned int skip; | ||
257 | }; | ||
258 | |||
256 | struct vino_channel_settings { | 259 | struct vino_channel_settings { |
257 | unsigned int channel; | 260 | unsigned int channel; |
258 | 261 | ||
@@ -285,6 +288,8 @@ struct vino_channel_settings { | |||
285 | 288 | ||
286 | unsigned int users; | 289 | unsigned int users; |
287 | 290 | ||
291 | struct vino_interrupt_data int_data; | ||
292 | |||
288 | /* V4L support */ | 293 | /* V4L support */ |
289 | struct video_device *v4l_device; | 294 | struct video_device *v4l_device; |
290 | }; | 295 | }; |
@@ -315,7 +320,7 @@ struct vino_settings { | |||
315 | /* Module parameters */ | 320 | /* Module parameters */ |
316 | 321 | ||
317 | /* | 322 | /* |
318 | * Using vino_pixel_conversion the ARGB32-format pixels supplied | 323 | * Using vino_pixel_conversion the ABGR32-format pixels supplied |
319 | * by the VINO chip can be converted to more common formats | 324 | * by the VINO chip can be converted to more common formats |
320 | * like RGBA32 (or probably RGB24 in the future). This way we | 325 | * like RGBA32 (or probably RGB24 in the future). This way we |
321 | * can give out data that can be specified correctly with | 326 | * can give out data that can be specified correctly with |
@@ -329,7 +334,9 @@ struct vino_settings { | |||
329 | * Use non-zero value to enable conversion. | 334 | * Use non-zero value to enable conversion. |
330 | */ | 335 | */ |
331 | static int vino_pixel_conversion = 0; | 336 | static int vino_pixel_conversion = 0; |
337 | |||
332 | module_param_named(pixelconv, vino_pixel_conversion, int, 0); | 338 | module_param_named(pixelconv, vino_pixel_conversion, int, 0); |
339 | |||
333 | MODULE_PARM_DESC(pixelconv, | 340 | MODULE_PARM_DESC(pixelconv, |
334 | "enable pixel conversion (non-zero value enables)"); | 341 | "enable pixel conversion (non-zero value enables)"); |
335 | 342 | ||
@@ -345,15 +352,22 @@ static const char *vino_bus_name = "GIO64 bus"; | |||
345 | static const char *vino_v4l_device_name_a = "SGI VINO Channel A"; | 352 | static const char *vino_v4l_device_name_a = "SGI VINO Channel A"; |
346 | static const char *vino_v4l_device_name_b = "SGI VINO Channel B"; | 353 | static const char *vino_v4l_device_name_b = "SGI VINO Channel B"; |
347 | 354 | ||
355 | static void vino_capture_tasklet(unsigned long channel); | ||
356 | |||
357 | DECLARE_TASKLET(vino_tasklet_a, vino_capture_tasklet, VINO_CHANNEL_A); | ||
358 | DECLARE_TASKLET(vino_tasklet_b, vino_capture_tasklet, VINO_CHANNEL_B); | ||
359 | |||
348 | static const struct vino_input vino_inputs[] = { | 360 | static const struct vino_input vino_inputs[] = { |
349 | { | 361 | { |
350 | .name = "Composite", | 362 | .name = "Composite", |
351 | .std = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM, | 363 | .std = V4L2_STD_NTSC | V4L2_STD_PAL |
364 | | V4L2_STD_SECAM, | ||
352 | },{ | 365 | },{ |
353 | .name = "S-Video", | 366 | .name = "S-Video", |
354 | .std = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM, | 367 | .std = V4L2_STD_NTSC | V4L2_STD_PAL |
368 | | V4L2_STD_SECAM, | ||
355 | },{ | 369 | },{ |
356 | .name = "D1 (IndyCam)", | 370 | .name = "D1/IndyCam", |
357 | .std = V4L2_STD_NTSC, | 371 | .std = V4L2_STD_NTSC, |
358 | } | 372 | } |
359 | }; | 373 | }; |
@@ -376,15 +390,10 @@ static const struct vino_data_format vino_data_formats[] = { | |||
376 | .colorspace = V4L2_COLORSPACE_SRGB, | 390 | .colorspace = V4L2_COLORSPACE_SRGB, |
377 | },{ | 391 | },{ |
378 | .description = "YUV 4:2:2", | 392 | .description = "YUV 4:2:2", |
379 | .bpp = 4, | 393 | .bpp = 2, |
380 | .pixelformat = V4L2_PIX_FMT_YUYV, // XXX: swapped? | 394 | .pixelformat = V4L2_PIX_FMT_YUYV, // XXX: swapped? |
381 | .colorspace = V4L2_COLORSPACE_SMPTE170M, | 395 | .colorspace = V4L2_COLORSPACE_SMPTE170M, |
382 | }/*,{ | 396 | } |
383 | .description = "24-bit RGB", | ||
384 | .bpp = 3, | ||
385 | .pixelformat = V4L2_PIX_FMT_RGB24, | ||
386 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
387 | }*/ | ||
388 | }; | 397 | }; |
389 | 398 | ||
390 | static const struct vino_data_norm vino_data_norms[] = { | 399 | static const struct vino_data_norm vino_data_norms[] = { |
@@ -397,18 +406,18 @@ static const struct vino_data_norm vino_data_norms[] = { | |||
397 | .width = VINO_NTSC_WIDTH, | 406 | .width = VINO_NTSC_WIDTH, |
398 | .height = VINO_NTSC_HEIGHT, | 407 | .height = VINO_NTSC_HEIGHT, |
399 | .odd = { | 408 | .odd = { |
400 | .top = VINO_CLIPPING_START_ODD_NTSC, | 409 | .top = VINO_CLIPPING_START_ODD_NTSC, |
401 | .left = 0, | 410 | .left = 0, |
402 | .bottom = VINO_CLIPPING_START_ODD_NTSC | 411 | .bottom = VINO_CLIPPING_START_ODD_NTSC |
403 | + VINO_NTSC_HEIGHT / 2 - 1, | 412 | + VINO_NTSC_HEIGHT / 2 - 1, |
404 | .right = VINO_NTSC_WIDTH, | 413 | .right = VINO_NTSC_WIDTH, |
405 | }, | 414 | }, |
406 | .even = { | 415 | .even = { |
407 | .top = VINO_CLIPPING_START_EVEN_NTSC, | 416 | .top = VINO_CLIPPING_START_EVEN_NTSC, |
408 | .left = 0, | 417 | .left = 0, |
409 | .bottom = VINO_CLIPPING_START_EVEN_NTSC | 418 | .bottom = VINO_CLIPPING_START_EVEN_NTSC |
410 | + VINO_NTSC_HEIGHT / 2 - 1, | 419 | + VINO_NTSC_HEIGHT / 2 - 1, |
411 | .right = VINO_NTSC_WIDTH, | 420 | .right = VINO_NTSC_WIDTH, |
412 | }, | 421 | }, |
413 | },{ | 422 | },{ |
414 | .description = "PAL", | 423 | .description = "PAL", |
@@ -419,18 +428,18 @@ static const struct vino_data_norm vino_data_norms[] = { | |||
419 | .width = VINO_PAL_WIDTH, | 428 | .width = VINO_PAL_WIDTH, |
420 | .height = VINO_PAL_HEIGHT, | 429 | .height = VINO_PAL_HEIGHT, |
421 | .odd = { | 430 | .odd = { |
422 | .top = VINO_CLIPPING_START_ODD_PAL, | 431 | .top = VINO_CLIPPING_START_ODD_PAL, |
423 | .left = 0, | 432 | .left = 0, |
424 | .bottom = VINO_CLIPPING_START_ODD_PAL | 433 | .bottom = VINO_CLIPPING_START_ODD_PAL |
425 | + VINO_PAL_HEIGHT / 2 - 1, | 434 | + VINO_PAL_HEIGHT / 2 - 1, |
426 | .right = VINO_PAL_WIDTH, | 435 | .right = VINO_PAL_WIDTH, |
427 | }, | 436 | }, |
428 | .even = { | 437 | .even = { |
429 | .top = VINO_CLIPPING_START_EVEN_PAL, | 438 | .top = VINO_CLIPPING_START_EVEN_PAL, |
430 | .left = 0, | 439 | .left = 0, |
431 | .bottom = VINO_CLIPPING_START_EVEN_PAL | 440 | .bottom = VINO_CLIPPING_START_EVEN_PAL |
432 | + VINO_PAL_HEIGHT / 2 - 1, | 441 | + VINO_PAL_HEIGHT / 2 - 1, |
433 | .right = VINO_PAL_WIDTH, | 442 | .right = VINO_PAL_WIDTH, |
434 | }, | 443 | }, |
435 | },{ | 444 | },{ |
436 | .description = "SECAM", | 445 | .description = "SECAM", |
@@ -441,21 +450,21 @@ static const struct vino_data_norm vino_data_norms[] = { | |||
441 | .width = VINO_PAL_WIDTH, | 450 | .width = VINO_PAL_WIDTH, |
442 | .height = VINO_PAL_HEIGHT, | 451 | .height = VINO_PAL_HEIGHT, |
443 | .odd = { | 452 | .odd = { |
444 | .top = VINO_CLIPPING_START_ODD_PAL, | 453 | .top = VINO_CLIPPING_START_ODD_PAL, |
445 | .left = 0, | 454 | .left = 0, |
446 | .bottom = VINO_CLIPPING_START_ODD_PAL | 455 | .bottom = VINO_CLIPPING_START_ODD_PAL |
447 | + VINO_PAL_HEIGHT / 2 - 1, | 456 | + VINO_PAL_HEIGHT / 2 - 1, |
448 | .right = VINO_PAL_WIDTH, | 457 | .right = VINO_PAL_WIDTH, |
449 | }, | 458 | }, |
450 | .even = { | 459 | .even = { |
451 | .top = VINO_CLIPPING_START_EVEN_PAL, | 460 | .top = VINO_CLIPPING_START_EVEN_PAL, |
452 | .left = 0, | 461 | .left = 0, |
453 | .bottom = VINO_CLIPPING_START_EVEN_PAL | 462 | .bottom = VINO_CLIPPING_START_EVEN_PAL |
454 | + VINO_PAL_HEIGHT / 2 - 1, | 463 | + VINO_PAL_HEIGHT / 2 - 1, |
455 | .right = VINO_PAL_WIDTH, | 464 | .right = VINO_PAL_WIDTH, |
456 | }, | 465 | }, |
457 | },{ | 466 | },{ |
458 | .description = "NTSC (D1 input)", | 467 | .description = "NTSC/D1", |
459 | .std = V4L2_STD_NTSC, | 468 | .std = V4L2_STD_NTSC, |
460 | .fps_min = 6, | 469 | .fps_min = 6, |
461 | .fps_max = 30, | 470 | .fps_max = 30, |
@@ -463,18 +472,18 @@ static const struct vino_data_norm vino_data_norms[] = { | |||
463 | .width = VINO_NTSC_WIDTH, | 472 | .width = VINO_NTSC_WIDTH, |
464 | .height = VINO_NTSC_HEIGHT, | 473 | .height = VINO_NTSC_HEIGHT, |
465 | .odd = { | 474 | .odd = { |
466 | .top = VINO_CLIPPING_START_ODD_D1, | 475 | .top = VINO_CLIPPING_START_ODD_D1, |
467 | .left = 0, | 476 | .left = 0, |
468 | .bottom = VINO_CLIPPING_START_ODD_D1 | 477 | .bottom = VINO_CLIPPING_START_ODD_D1 |
469 | + VINO_NTSC_HEIGHT / 2 - 1, | 478 | + VINO_NTSC_HEIGHT / 2 - 1, |
470 | .right = VINO_NTSC_WIDTH, | 479 | .right = VINO_NTSC_WIDTH, |
471 | }, | 480 | }, |
472 | .even = { | 481 | .even = { |
473 | .top = VINO_CLIPPING_START_EVEN_D1, | 482 | .top = VINO_CLIPPING_START_EVEN_D1, |
474 | .left = 0, | 483 | .left = 0, |
475 | .bottom = VINO_CLIPPING_START_EVEN_D1 | 484 | .bottom = VINO_CLIPPING_START_EVEN_D1 |
476 | + VINO_NTSC_HEIGHT / 2 - 1, | 485 | + VINO_NTSC_HEIGHT / 2 - 1, |
477 | .right = VINO_NTSC_WIDTH, | 486 | .right = VINO_NTSC_WIDTH, |
478 | }, | 487 | }, |
479 | } | 488 | } |
480 | }; | 489 | }; |
@@ -491,7 +500,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { | |||
491 | .step = 1, | 500 | .step = 1, |
492 | .default_value = INDYCAM_AGC_DEFAULT, | 501 | .default_value = INDYCAM_AGC_DEFAULT, |
493 | .flags = 0, | 502 | .flags = 0, |
494 | .reserved = { 0, 0 }, | 503 | .reserved = { INDYCAM_CONTROL_AGC, 0 }, |
495 | },{ | 504 | },{ |
496 | .id = V4L2_CID_AUTO_WHITE_BALANCE, | 505 | .id = V4L2_CID_AUTO_WHITE_BALANCE, |
497 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 506 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
@@ -501,7 +510,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { | |||
501 | .step = 1, | 510 | .step = 1, |
502 | .default_value = INDYCAM_AWB_DEFAULT, | 511 | .default_value = INDYCAM_AWB_DEFAULT, |
503 | .flags = 0, | 512 | .flags = 0, |
504 | .reserved = { 0, 0 }, | 513 | .reserved = { INDYCAM_CONTROL_AWB, 0 }, |
505 | },{ | 514 | },{ |
506 | .id = V4L2_CID_GAIN, | 515 | .id = V4L2_CID_GAIN, |
507 | .type = V4L2_CTRL_TYPE_INTEGER, | 516 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -511,7 +520,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { | |||
511 | .step = 1, | 520 | .step = 1, |
512 | .default_value = INDYCAM_GAIN_DEFAULT, | 521 | .default_value = INDYCAM_GAIN_DEFAULT, |
513 | .flags = 0, | 522 | .flags = 0, |
514 | .reserved = { 0, 0 }, | 523 | .reserved = { INDYCAM_CONTROL_GAIN, 0 }, |
515 | },{ | 524 | },{ |
516 | .id = V4L2_CID_PRIVATE_BASE, | 525 | .id = V4L2_CID_PRIVATE_BASE, |
517 | .type = V4L2_CTRL_TYPE_INTEGER, | 526 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -521,7 +530,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { | |||
521 | .step = 1, | 530 | .step = 1, |
522 | .default_value = INDYCAM_RED_SATURATION_DEFAULT, | 531 | .default_value = INDYCAM_RED_SATURATION_DEFAULT, |
523 | .flags = 0, | 532 | .flags = 0, |
524 | .reserved = { 0, 0 }, | 533 | .reserved = { INDYCAM_CONTROL_RED_SATURATION, 0 }, |
525 | },{ | 534 | },{ |
526 | .id = V4L2_CID_PRIVATE_BASE + 1, | 535 | .id = V4L2_CID_PRIVATE_BASE + 1, |
527 | .type = V4L2_CTRL_TYPE_INTEGER, | 536 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -531,7 +540,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { | |||
531 | .step = 1, | 540 | .step = 1, |
532 | .default_value = INDYCAM_BLUE_SATURATION_DEFAULT, | 541 | .default_value = INDYCAM_BLUE_SATURATION_DEFAULT, |
533 | .flags = 0, | 542 | .flags = 0, |
534 | .reserved = { 0, 0 }, | 543 | .reserved = { INDYCAM_CONTROL_BLUE_SATURATION, 0 }, |
535 | },{ | 544 | },{ |
536 | .id = V4L2_CID_RED_BALANCE, | 545 | .id = V4L2_CID_RED_BALANCE, |
537 | .type = V4L2_CTRL_TYPE_INTEGER, | 546 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -541,7 +550,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { | |||
541 | .step = 1, | 550 | .step = 1, |
542 | .default_value = INDYCAM_RED_BALANCE_DEFAULT, | 551 | .default_value = INDYCAM_RED_BALANCE_DEFAULT, |
543 | .flags = 0, | 552 | .flags = 0, |
544 | .reserved = { 0, 0 }, | 553 | .reserved = { INDYCAM_CONTROL_RED_BALANCE, 0 }, |
545 | },{ | 554 | },{ |
546 | .id = V4L2_CID_BLUE_BALANCE, | 555 | .id = V4L2_CID_BLUE_BALANCE, |
547 | .type = V4L2_CTRL_TYPE_INTEGER, | 556 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -551,7 +560,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { | |||
551 | .step = 1, | 560 | .step = 1, |
552 | .default_value = INDYCAM_BLUE_BALANCE_DEFAULT, | 561 | .default_value = INDYCAM_BLUE_BALANCE_DEFAULT, |
553 | .flags = 0, | 562 | .flags = 0, |
554 | .reserved = { 0, 0 }, | 563 | .reserved = { INDYCAM_CONTROL_BLUE_BALANCE, 0 }, |
555 | },{ | 564 | },{ |
556 | .id = V4L2_CID_EXPOSURE, | 565 | .id = V4L2_CID_EXPOSURE, |
557 | .type = V4L2_CTRL_TYPE_INTEGER, | 566 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -561,7 +570,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { | |||
561 | .step = 1, | 570 | .step = 1, |
562 | .default_value = INDYCAM_SHUTTER_DEFAULT, | 571 | .default_value = INDYCAM_SHUTTER_DEFAULT, |
563 | .flags = 0, | 572 | .flags = 0, |
564 | .reserved = { 0, 0 }, | 573 | .reserved = { INDYCAM_CONTROL_SHUTTER, 0 }, |
565 | },{ | 574 | },{ |
566 | .id = V4L2_CID_GAMMA, | 575 | .id = V4L2_CID_GAMMA, |
567 | .type = V4L2_CTRL_TYPE_INTEGER, | 576 | .type = V4L2_CTRL_TYPE_INTEGER, |
@@ -571,11 +580,11 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = { | |||
571 | .step = 1, | 580 | .step = 1, |
572 | .default_value = INDYCAM_GAMMA_DEFAULT, | 581 | .default_value = INDYCAM_GAMMA_DEFAULT, |
573 | .flags = 0, | 582 | .flags = 0, |
574 | .reserved = { 0, 0 }, | 583 | .reserved = { INDYCAM_CONTROL_GAMMA, 0 }, |
575 | } | 584 | } |
576 | }; | 585 | }; |
577 | 586 | ||
578 | #define VINO_SAA7191_V4L2_CONTROL_COUNT 2 | 587 | #define VINO_SAA7191_V4L2_CONTROL_COUNT 9 |
579 | 588 | ||
580 | struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = { | 589 | struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = { |
581 | { | 590 | { |
@@ -587,9 +596,59 @@ struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = { | |||
587 | .step = 1, | 596 | .step = 1, |
588 | .default_value = SAA7191_HUE_DEFAULT, | 597 | .default_value = SAA7191_HUE_DEFAULT, |
589 | .flags = 0, | 598 | .flags = 0, |
590 | .reserved = { 0, 0 }, | 599 | .reserved = { SAA7191_CONTROL_HUE, 0 }, |
591 | },{ | 600 | },{ |
592 | .id = V4L2_CID_PRIVATE_BASE, | 601 | .id = V4L2_CID_PRIVATE_BASE, |
602 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
603 | .name = "Luminance Bandpass", | ||
604 | .minimum = SAA7191_BANDPASS_MIN, | ||
605 | .maximum = SAA7191_BANDPASS_MAX, | ||
606 | .step = 1, | ||
607 | .default_value = SAA7191_BANDPASS_DEFAULT, | ||
608 | .flags = 0, | ||
609 | .reserved = { SAA7191_CONTROL_BANDPASS, 0 }, | ||
610 | },{ | ||
611 | .id = V4L2_CID_PRIVATE_BASE + 1, | ||
612 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
613 | .name = "Luminance Bandpass Weight", | ||
614 | .minimum = SAA7191_BANDPASS_WEIGHT_MIN, | ||
615 | .maximum = SAA7191_BANDPASS_WEIGHT_MAX, | ||
616 | .step = 1, | ||
617 | .default_value = SAA7191_BANDPASS_WEIGHT_DEFAULT, | ||
618 | .flags = 0, | ||
619 | .reserved = { SAA7191_CONTROL_BANDPASS_WEIGHT, 0 }, | ||
620 | },{ | ||
621 | .id = V4L2_CID_PRIVATE_BASE + 2, | ||
622 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
623 | .name = "HF Luminance Coring", | ||
624 | .minimum = SAA7191_CORING_MIN, | ||
625 | .maximum = SAA7191_CORING_MAX, | ||
626 | .step = 1, | ||
627 | .default_value = SAA7191_CORING_DEFAULT, | ||
628 | .flags = 0, | ||
629 | .reserved = { SAA7191_CONTROL_CORING, 0 }, | ||
630 | },{ | ||
631 | .id = V4L2_CID_PRIVATE_BASE + 3, | ||
632 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
633 | .name = "Force Colour", | ||
634 | .minimum = SAA7191_FORCE_COLOUR_MIN, | ||
635 | .maximum = SAA7191_FORCE_COLOUR_MAX, | ||
636 | .step = 1, | ||
637 | .default_value = SAA7191_FORCE_COLOUR_DEFAULT, | ||
638 | .flags = 0, | ||
639 | .reserved = { SAA7191_CONTROL_FORCE_COLOUR, 0 }, | ||
640 | },{ | ||
641 | .id = V4L2_CID_PRIVATE_BASE + 4, | ||
642 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
643 | .name = "Chrominance Gain Control", | ||
644 | .minimum = SAA7191_CHROMA_GAIN_MIN, | ||
645 | .maximum = SAA7191_CHROMA_GAIN_MAX, | ||
646 | .step = 1, | ||
647 | .default_value = SAA7191_CHROMA_GAIN_DEFAULT, | ||
648 | .flags = 0, | ||
649 | .reserved = { SAA7191_CONTROL_CHROMA_GAIN, 0 }, | ||
650 | },{ | ||
651 | .id = V4L2_CID_PRIVATE_BASE + 5, | ||
593 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 652 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
594 | .name = "VTR Time Constant", | 653 | .name = "VTR Time Constant", |
595 | .minimum = SAA7191_VTRC_MIN, | 654 | .minimum = SAA7191_VTRC_MIN, |
@@ -597,7 +656,27 @@ struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = { | |||
597 | .step = 1, | 656 | .step = 1, |
598 | .default_value = SAA7191_VTRC_DEFAULT, | 657 | .default_value = SAA7191_VTRC_DEFAULT, |
599 | .flags = 0, | 658 | .flags = 0, |
600 | .reserved = { 0, 0 }, | 659 | .reserved = { SAA7191_CONTROL_VTRC, 0 }, |
660 | },{ | ||
661 | .id = V4L2_CID_PRIVATE_BASE + 6, | ||
662 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
663 | .name = "Luminance Delay Compensation", | ||
664 | .minimum = SAA7191_LUMA_DELAY_MIN, | ||
665 | .maximum = SAA7191_LUMA_DELAY_MAX, | ||
666 | .step = 1, | ||
667 | .default_value = SAA7191_LUMA_DELAY_DEFAULT, | ||
668 | .flags = 0, | ||
669 | .reserved = { SAA7191_CONTROL_LUMA_DELAY, 0 }, | ||
670 | },{ | ||
671 | .id = V4L2_CID_PRIVATE_BASE + 7, | ||
672 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
673 | .name = "Vertical Noise Reduction", | ||
674 | .minimum = SAA7191_VNR_MIN, | ||
675 | .maximum = SAA7191_VNR_MAX, | ||
676 | .step = 1, | ||
677 | .default_value = SAA7191_VNR_DEFAULT, | ||
678 | .flags = 0, | ||
679 | .reserved = { SAA7191_CONTROL_VNR, 0 }, | ||
601 | } | 680 | } |
602 | }; | 681 | }; |
603 | 682 | ||
@@ -639,9 +718,10 @@ static struct i2c_algo_sgi_data i2c_sgi_vino_data = | |||
639 | */ | 718 | */ |
640 | static int i2c_vino_client_reg(struct i2c_client *client) | 719 | static int i2c_vino_client_reg(struct i2c_client *client) |
641 | { | 720 | { |
721 | unsigned long flags; | ||
642 | int ret = 0; | 722 | int ret = 0; |
643 | 723 | ||
644 | spin_lock(&vino_drvdata->input_lock); | 724 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
645 | switch (client->driver->id) { | 725 | switch (client->driver->id) { |
646 | case I2C_DRIVERID_SAA7191: | 726 | case I2C_DRIVERID_SAA7191: |
647 | if (vino_drvdata->decoder.driver) | 727 | if (vino_drvdata->decoder.driver) |
@@ -658,16 +738,17 @@ static int i2c_vino_client_reg(struct i2c_client *client) | |||
658 | default: | 738 | default: |
659 | ret = -ENODEV; | 739 | ret = -ENODEV; |
660 | } | 740 | } |
661 | spin_unlock(&vino_drvdata->input_lock); | 741 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
662 | 742 | ||
663 | return ret; | 743 | return ret; |
664 | } | 744 | } |
665 | 745 | ||
666 | static int i2c_vino_client_unreg(struct i2c_client *client) | 746 | static int i2c_vino_client_unreg(struct i2c_client *client) |
667 | { | 747 | { |
748 | unsigned long flags; | ||
668 | int ret = 0; | 749 | int ret = 0; |
669 | 750 | ||
670 | spin_lock(&vino_drvdata->input_lock); | 751 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
671 | if (client == vino_drvdata->decoder.driver) { | 752 | if (client == vino_drvdata->decoder.driver) { |
672 | if (vino_drvdata->decoder.owner != VINO_NO_CHANNEL) | 753 | if (vino_drvdata->decoder.owner != VINO_NO_CHANNEL) |
673 | ret = -EBUSY; | 754 | ret = -EBUSY; |
@@ -679,7 +760,7 @@ static int i2c_vino_client_unreg(struct i2c_client *client) | |||
679 | else | 760 | else |
680 | vino_drvdata->camera.driver = NULL; | 761 | vino_drvdata->camera.driver = NULL; |
681 | } | 762 | } |
682 | spin_unlock(&vino_drvdata->input_lock); | 763 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
683 | 764 | ||
684 | return ret; | 765 | return ret; |
685 | } | 766 | } |
@@ -727,7 +808,7 @@ static void vino_free_buffer_with_count(struct vino_framebuffer *fb, | |||
727 | dprintk("vino_free_buffer_with_count(): count = %d\n", count); | 808 | dprintk("vino_free_buffer_with_count(): count = %d\n", count); |
728 | 809 | ||
729 | for (i = 0; i < count; i++) { | 810 | for (i = 0; i < count; i++) { |
730 | mem_map_unreserve(virt_to_page(fb->desc_table.virtual[i])); | 811 | ClearPageReserved(virt_to_page(fb->desc_table.virtual[i])); |
731 | dma_unmap_single(NULL, | 812 | dma_unmap_single(NULL, |
732 | fb->desc_table.dma_cpu[VINO_PAGE_RATIO * i], | 813 | fb->desc_table.dma_cpu[VINO_PAGE_RATIO * i], |
733 | PAGE_SIZE, DMA_FROM_DEVICE); | 814 | PAGE_SIZE, DMA_FROM_DEVICE); |
@@ -805,7 +886,7 @@ static int vino_allocate_buffer(struct vino_framebuffer *fb, | |||
805 | dma_data_addr + VINO_PAGE_SIZE * j; | 886 | dma_data_addr + VINO_PAGE_SIZE * j; |
806 | } | 887 | } |
807 | 888 | ||
808 | mem_map_reserve(virt_to_page(fb->desc_table.virtual[i])); | 889 | SetPageReserved(virt_to_page(fb->desc_table.virtual[i])); |
809 | } | 890 | } |
810 | 891 | ||
811 | /* page_count needs to be set anyway, because the descriptor table has | 892 | /* page_count needs to be set anyway, because the descriptor table has |
@@ -892,7 +973,7 @@ static int vino_prepare_user_buffer(struct vino_framebuffer *fb, | |||
892 | dma_data_addr + VINO_PAGE_SIZE * j; | 973 | dma_data_addr + VINO_PAGE_SIZE * j; |
893 | } | 974 | } |
894 | 975 | ||
895 | mem_map_reserve(virt_to_page(fb->desc_table.virtual[i])); | 976 | SetPageReserved(virt_to_page(fb->desc_table.virtual[i])); |
896 | } | 977 | } |
897 | 978 | ||
898 | /* page_count needs to be set anyway, because the descriptor table has | 979 | /* page_count needs to be set anyway, because the descriptor table has |
@@ -933,7 +1014,7 @@ static void vino_sync_buffer(struct vino_framebuffer *fb) | |||
933 | 1014 | ||
934 | /* Framebuffer fifo functions (need to be locked externally) */ | 1015 | /* Framebuffer fifo functions (need to be locked externally) */ |
935 | 1016 | ||
936 | static void vino_fifo_init(struct vino_framebuffer_fifo *f, | 1017 | static inline void vino_fifo_init(struct vino_framebuffer_fifo *f, |
937 | unsigned int length) | 1018 | unsigned int length) |
938 | { | 1019 | { |
939 | f->length = 0; | 1020 | f->length = 0; |
@@ -941,16 +1022,18 @@ static void vino_fifo_init(struct vino_framebuffer_fifo *f, | |||
941 | f->head = 0; | 1022 | f->head = 0; |
942 | f->tail = 0; | 1023 | f->tail = 0; |
943 | 1024 | ||
944 | if (length > VINO_FRAMEBUFFER_MAX_COUNT) | 1025 | if (length > VINO_FRAMEBUFFER_COUNT_MAX) |
945 | length = VINO_FRAMEBUFFER_MAX_COUNT; | 1026 | length = VINO_FRAMEBUFFER_COUNT_MAX; |
946 | 1027 | ||
947 | f->length = length; | 1028 | f->length = length; |
948 | } | 1029 | } |
949 | 1030 | ||
950 | /* returns true/false */ | 1031 | /* returns true/false */ |
951 | static int vino_fifo_has_id(struct vino_framebuffer_fifo *f, unsigned int id) | 1032 | static inline int vino_fifo_has_id(struct vino_framebuffer_fifo *f, |
1033 | unsigned int id) | ||
952 | { | 1034 | { |
953 | unsigned int i; | 1035 | unsigned int i; |
1036 | |||
954 | for (i = f->head; i == (f->tail - 1); i = (i + 1) % f->length) { | 1037 | for (i = f->head; i == (f->tail - 1); i = (i + 1) % f->length) { |
955 | if (f->data[i] == id) | 1038 | if (f->data[i] == id) |
956 | return 1; | 1039 | return 1; |
@@ -959,13 +1042,15 @@ static int vino_fifo_has_id(struct vino_framebuffer_fifo *f, unsigned int id) | |||
959 | return 0; | 1042 | return 0; |
960 | } | 1043 | } |
961 | 1044 | ||
1045 | #if 0 | ||
962 | /* returns true/false */ | 1046 | /* returns true/false */ |
963 | static int vino_fifo_full(struct vino_framebuffer_fifo *f) | 1047 | static inline int vino_fifo_full(struct vino_framebuffer_fifo *f) |
964 | { | 1048 | { |
965 | return (f->used == f->length); | 1049 | return (f->used == f->length); |
966 | } | 1050 | } |
1051 | #endif | ||
967 | 1052 | ||
968 | static unsigned int vino_fifo_get_used(struct vino_framebuffer_fifo *f) | 1053 | static inline unsigned int vino_fifo_get_used(struct vino_framebuffer_fifo *f) |
969 | { | 1054 | { |
970 | return f->used; | 1055 | return f->used; |
971 | } | 1056 | } |
@@ -1076,8 +1161,8 @@ static int vino_queue_init(struct vino_framebuffer_queue *q, | |||
1076 | 1161 | ||
1077 | down(&q->queue_sem); | 1162 | down(&q->queue_sem); |
1078 | 1163 | ||
1079 | if (*length > VINO_FRAMEBUFFER_MAX_COUNT) | 1164 | if (*length > VINO_FRAMEBUFFER_COUNT_MAX) |
1080 | *length = VINO_FRAMEBUFFER_MAX_COUNT; | 1165 | *length = VINO_FRAMEBUFFER_COUNT_MAX; |
1081 | 1166 | ||
1082 | q->length = 0; | 1167 | q->length = 0; |
1083 | 1168 | ||
@@ -1313,6 +1398,7 @@ out: | |||
1313 | return ret; | 1398 | return ret; |
1314 | } | 1399 | } |
1315 | 1400 | ||
1401 | #if 0 | ||
1316 | static int vino_queue_get_total(struct vino_framebuffer_queue *q, | 1402 | static int vino_queue_get_total(struct vino_framebuffer_queue *q, |
1317 | unsigned int *total) | 1403 | unsigned int *total) |
1318 | { | 1404 | { |
@@ -1338,6 +1424,7 @@ out: | |||
1338 | 1424 | ||
1339 | return ret; | 1425 | return ret; |
1340 | } | 1426 | } |
1427 | #endif | ||
1341 | 1428 | ||
1342 | static struct vino_framebuffer *vino_queue_peek(struct | 1429 | static struct vino_framebuffer *vino_queue_peek(struct |
1343 | vino_framebuffer_queue *q, | 1430 | vino_framebuffer_queue *q, |
@@ -1471,12 +1558,14 @@ static void vino_update_line_size(struct vino_channel_settings *vcs) | |||
1471 | 1558 | ||
1472 | dprintk("update_line_size(): before: w = %d, d = %d, " | 1559 | dprintk("update_line_size(): before: w = %d, d = %d, " |
1473 | "line_size = %d\n", w, d, vcs->line_size); | 1560 | "line_size = %d\n", w, d, vcs->line_size); |
1561 | |||
1474 | /* line size must be multiple of 8 bytes */ | 1562 | /* line size must be multiple of 8 bytes */ |
1475 | lsize = (bpp * (w / d)) & ~7; | 1563 | lsize = (bpp * (w / d)) & ~7; |
1476 | w = (lsize / bpp) * d; | 1564 | w = (lsize / bpp) * d; |
1477 | 1565 | ||
1478 | vcs->clipping.right = vcs->clipping.left + w; | 1566 | vcs->clipping.right = vcs->clipping.left + w; |
1479 | vcs->line_size = lsize; | 1567 | vcs->line_size = lsize; |
1568 | |||
1480 | dprintk("update_line_size(): after: w = %d, d = %d, " | 1569 | dprintk("update_line_size(): after: w = %d, d = %d, " |
1481 | "line_size = %d\n", w, d, vcs->line_size); | 1570 | "line_size = %d\n", w, d, vcs->line_size); |
1482 | } | 1571 | } |
@@ -1532,7 +1621,7 @@ static void vino_set_clipping(struct vino_channel_settings *vcs, | |||
1532 | } | 1621 | } |
1533 | 1622 | ||
1534 | /* execute with input_lock locked */ | 1623 | /* execute with input_lock locked */ |
1535 | static void vino_set_default_clipping(struct vino_channel_settings *vcs) | 1624 | static inline void vino_set_default_clipping(struct vino_channel_settings *vcs) |
1536 | { | 1625 | { |
1537 | vino_set_clipping(vcs, 0, 0, vino_data_norms[vcs->data_norm].width, | 1626 | vino_set_clipping(vcs, 0, 0, vino_data_norms[vcs->data_norm].width, |
1538 | vino_data_norms[vcs->data_norm].height); | 1627 | vino_data_norms[vcs->data_norm].height); |
@@ -1556,8 +1645,7 @@ static void vino_set_scaling(struct vino_channel_settings *vcs, | |||
1556 | 1645 | ||
1557 | if (d < 1) { | 1646 | if (d < 1) { |
1558 | d = 1; | 1647 | d = 1; |
1559 | } | 1648 | } else if (d > 8) { |
1560 | if (d > 8) { | ||
1561 | d = 8; | 1649 | d = 8; |
1562 | } | 1650 | } |
1563 | 1651 | ||
@@ -1570,7 +1658,7 @@ static void vino_set_scaling(struct vino_channel_settings *vcs, | |||
1570 | } | 1658 | } |
1571 | 1659 | ||
1572 | /* execute with input_lock locked */ | 1660 | /* execute with input_lock locked */ |
1573 | static void vino_reset_scaling(struct vino_channel_settings *vcs) | 1661 | static inline void vino_set_default_scaling(struct vino_channel_settings *vcs) |
1574 | { | 1662 | { |
1575 | vino_set_scaling(vcs, vcs->clipping.right - vcs->clipping.left, | 1663 | vino_set_scaling(vcs, vcs->clipping.right - vcs->clipping.left, |
1576 | vcs->clipping.bottom - vcs->clipping.top); | 1664 | vcs->clipping.bottom - vcs->clipping.top); |
@@ -1649,7 +1737,8 @@ static void vino_set_framerate(struct vino_channel_settings *vcs, | |||
1649 | } | 1737 | } |
1650 | 1738 | ||
1651 | /* execute with input_lock locked */ | 1739 | /* execute with input_lock locked */ |
1652 | static void vino_set_default_framerate(struct vino_channel_settings *vcs) | 1740 | static inline void vino_set_default_framerate(struct |
1741 | vino_channel_settings *vcs) | ||
1653 | { | 1742 | { |
1654 | vino_set_framerate(vcs, vino_data_norms[vcs->data_norm].fps_max); | 1743 | vino_set_framerate(vcs, vino_data_norms[vcs->data_norm].fps_max); |
1655 | } | 1744 | } |
@@ -1687,6 +1776,9 @@ static int vino_dma_setup(struct vino_channel_settings *vcs, | |||
1687 | * should be more than enough time */ | 1776 | * should be more than enough time */ |
1688 | udelay(VINO_DESC_FETCH_DELAY); | 1777 | udelay(VINO_DESC_FETCH_DELAY); |
1689 | 1778 | ||
1779 | dprintk("vino_dma_setup(): start desc = %08x, next 4 desc = %08x\n", | ||
1780 | ch->start_desc_tbl, ch->next_4_desc); | ||
1781 | |||
1690 | /* set the alpha register */ | 1782 | /* set the alpha register */ |
1691 | ch->alpha = vcs->alpha; | 1783 | ch->alpha = vcs->alpha; |
1692 | 1784 | ||
@@ -1700,9 +1792,6 @@ static int vino_dma_setup(struct vino_channel_settings *vcs, | |||
1700 | VINO_CLIP_EVEN(norm->even.top + | 1792 | VINO_CLIP_EVEN(norm->even.top + |
1701 | vcs->clipping.bottom / 2 - 1) | | 1793 | vcs->clipping.bottom / 2 - 1) | |
1702 | VINO_CLIP_X(vcs->clipping.right); | 1794 | VINO_CLIP_X(vcs->clipping.right); |
1703 | /* FIXME: end-of-field bug workaround | ||
1704 | VINO_CLIP_X(VINO_PAL_WIDTH); | ||
1705 | */ | ||
1706 | 1795 | ||
1707 | /* set the size of actual content in the buffer (DECIMATION !) */ | 1796 | /* set the size of actual content in the buffer (DECIMATION !) */ |
1708 | fb->data_size = ((vcs->clipping.right - vcs->clipping.left) / | 1797 | fb->data_size = ((vcs->clipping.right - vcs->clipping.left) / |
@@ -1802,7 +1891,7 @@ static int vino_dma_setup(struct vino_channel_settings *vcs, | |||
1802 | } | 1891 | } |
1803 | 1892 | ||
1804 | /* (execute only with vino_lock locked) */ | 1893 | /* (execute only with vino_lock locked) */ |
1805 | static void vino_dma_start(struct vino_channel_settings *vcs) | 1894 | static inline void vino_dma_start(struct vino_channel_settings *vcs) |
1806 | { | 1895 | { |
1807 | u32 ctrl = vino->control; | 1896 | u32 ctrl = vino->control; |
1808 | 1897 | ||
@@ -1813,12 +1902,14 @@ static void vino_dma_start(struct vino_channel_settings *vcs) | |||
1813 | } | 1902 | } |
1814 | 1903 | ||
1815 | /* (execute only with vino_lock locked) */ | 1904 | /* (execute only with vino_lock locked) */ |
1816 | static void vino_dma_stop(struct vino_channel_settings *vcs) | 1905 | static inline void vino_dma_stop(struct vino_channel_settings *vcs) |
1817 | { | 1906 | { |
1818 | u32 ctrl = vino->control; | 1907 | u32 ctrl = vino->control; |
1819 | 1908 | ||
1820 | ctrl &= (vcs->channel == VINO_CHANNEL_A) ? | 1909 | ctrl &= (vcs->channel == VINO_CHANNEL_A) ? |
1821 | ~VINO_CTRL_A_DMA_ENBL : ~VINO_CTRL_B_DMA_ENBL; | 1910 | ~VINO_CTRL_A_DMA_ENBL : ~VINO_CTRL_B_DMA_ENBL; |
1911 | ctrl &= (vcs->channel == VINO_CHANNEL_A) ? | ||
1912 | ~VINO_CTRL_A_INT : ~VINO_CTRL_B_INT; | ||
1822 | vino->control = ctrl; | 1913 | vino->control = ctrl; |
1823 | dprintk("vino_dma_stop():\n"); | 1914 | dprintk("vino_dma_stop():\n"); |
1824 | } | 1915 | } |
@@ -1902,7 +1993,7 @@ static int vino_capture_next(struct vino_channel_settings *vcs, int start) | |||
1902 | struct vino_framebuffer *fb; | 1993 | struct vino_framebuffer *fb; |
1903 | unsigned int incoming, id; | 1994 | unsigned int incoming, id; |
1904 | int err = 0; | 1995 | int err = 0; |
1905 | unsigned long flags, flags2; | 1996 | unsigned long flags; |
1906 | 1997 | ||
1907 | dprintk("vino_capture_next():\n"); | 1998 | dprintk("vino_capture_next():\n"); |
1908 | 1999 | ||
@@ -1943,10 +2034,6 @@ static int vino_capture_next(struct vino_channel_settings *vcs, int start) | |||
1943 | goto out; | 2034 | goto out; |
1944 | } | 2035 | } |
1945 | 2036 | ||
1946 | spin_lock_irqsave(&fb->state_lock, flags2); | ||
1947 | fb->state = VINO_FRAMEBUFFER_UNUSED; | ||
1948 | spin_unlock_irqrestore(&fb->state_lock, flags2); | ||
1949 | |||
1950 | if (start) { | 2037 | if (start) { |
1951 | vcs->capturing = 1; | 2038 | vcs->capturing = 1; |
1952 | } | 2039 | } |
@@ -1964,7 +2051,7 @@ out: | |||
1964 | return err; | 2051 | return err; |
1965 | } | 2052 | } |
1966 | 2053 | ||
1967 | static int vino_is_capturing(struct vino_channel_settings *vcs) | 2054 | static inline int vino_is_capturing(struct vino_channel_settings *vcs) |
1968 | { | 2055 | { |
1969 | int ret; | 2056 | int ret; |
1970 | unsigned long flags; | 2057 | unsigned long flags; |
@@ -2076,6 +2163,7 @@ static void vino_capture_stop(struct vino_channel_settings *vcs) | |||
2076 | dprintk("vino_capture_stop():\n"); | 2163 | dprintk("vino_capture_stop():\n"); |
2077 | 2164 | ||
2078 | spin_lock_irqsave(&vcs->capture_lock, flags); | 2165 | spin_lock_irqsave(&vcs->capture_lock, flags); |
2166 | |||
2079 | /* unset capturing to stop queue processing */ | 2167 | /* unset capturing to stop queue processing */ |
2080 | vcs->capturing = 0; | 2168 | vcs->capturing = 0; |
2081 | 2169 | ||
@@ -2121,6 +2209,7 @@ out: | |||
2121 | spin_unlock_irqrestore(&vcs->capture_lock, flags); | 2209 | spin_unlock_irqrestore(&vcs->capture_lock, flags); |
2122 | } | 2210 | } |
2123 | 2211 | ||
2212 | #if 0 | ||
2124 | static int vino_capture_failed(struct vino_channel_settings *vcs) | 2213 | static int vino_capture_failed(struct vino_channel_settings *vcs) |
2125 | { | 2214 | { |
2126 | struct vino_framebuffer *fb; | 2215 | struct vino_framebuffer *fb; |
@@ -2165,9 +2254,31 @@ static int vino_capture_failed(struct vino_channel_settings *vcs) | |||
2165 | 2254 | ||
2166 | return 0; | 2255 | return 0; |
2167 | } | 2256 | } |
2257 | #endif | ||
2258 | |||
2259 | static void vino_skip_frame(struct vino_channel_settings *vcs) | ||
2260 | { | ||
2261 | struct vino_framebuffer *fb; | ||
2262 | unsigned long flags; | ||
2263 | unsigned int id; | ||
2264 | |||
2265 | spin_lock_irqsave(&vcs->capture_lock, flags); | ||
2266 | fb = vino_queue_peek(&vcs->fb_queue, &id); | ||
2267 | if (!fb) { | ||
2268 | spin_unlock_irqrestore(&vcs->capture_lock, flags); | ||
2269 | dprintk("vino_skip_frame(): vino_queue_peek() failed!\n"); | ||
2270 | return; | ||
2271 | } | ||
2272 | spin_unlock_irqrestore(&vcs->capture_lock, flags); | ||
2273 | |||
2274 | spin_lock_irqsave(&fb->state_lock, flags); | ||
2275 | fb->state = VINO_FRAMEBUFFER_UNUSED; | ||
2276 | spin_unlock_irqrestore(&fb->state_lock, flags); | ||
2277 | |||
2278 | vino_capture_next(vcs, 0); | ||
2279 | } | ||
2168 | 2280 | ||
2169 | static void vino_frame_done(struct vino_channel_settings *vcs, | 2281 | static void vino_frame_done(struct vino_channel_settings *vcs) |
2170 | unsigned int fc) | ||
2171 | { | 2282 | { |
2172 | struct vino_framebuffer *fb; | 2283 | struct vino_framebuffer *fb; |
2173 | unsigned long flags; | 2284 | unsigned long flags; |
@@ -2181,8 +2292,9 @@ static void vino_frame_done(struct vino_channel_settings *vcs, | |||
2181 | } | 2292 | } |
2182 | spin_unlock_irqrestore(&vcs->capture_lock, flags); | 2293 | spin_unlock_irqrestore(&vcs->capture_lock, flags); |
2183 | 2294 | ||
2184 | fb->frame_counter = fc; | 2295 | fb->frame_counter = vcs->int_data.frame_counter; |
2185 | do_gettimeofday(&fb->timestamp); | 2296 | memcpy(&fb->timestamp, &vcs->int_data.timestamp, |
2297 | sizeof(struct timeval)); | ||
2186 | 2298 | ||
2187 | spin_lock_irqsave(&fb->state_lock, flags); | 2299 | spin_lock_irqsave(&fb->state_lock, flags); |
2188 | if (fb->state == VINO_FRAMEBUFFER_IN_USE) | 2300 | if (fb->state == VINO_FRAMEBUFFER_IN_USE) |
@@ -2194,72 +2306,175 @@ static void vino_frame_done(struct vino_channel_settings *vcs, | |||
2194 | vino_capture_next(vcs, 0); | 2306 | vino_capture_next(vcs, 0); |
2195 | } | 2307 | } |
2196 | 2308 | ||
2309 | static void vino_capture_tasklet(unsigned long channel) { | ||
2310 | struct vino_channel_settings *vcs; | ||
2311 | |||
2312 | vcs = (channel == VINO_CHANNEL_A) | ||
2313 | ? &vino_drvdata->a : &vino_drvdata->b; | ||
2314 | |||
2315 | if (vcs->int_data.skip) | ||
2316 | vcs->int_data.skip_count++; | ||
2317 | |||
2318 | if (vcs->int_data.skip && (vcs->int_data.skip_count | ||
2319 | <= VINO_MAX_FRAME_SKIP_COUNT)) { | ||
2320 | vino_skip_frame(vcs); | ||
2321 | } else { | ||
2322 | vcs->int_data.skip_count = 0; | ||
2323 | vino_frame_done(vcs); | ||
2324 | } | ||
2325 | } | ||
2326 | |||
2197 | static irqreturn_t vino_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 2327 | static irqreturn_t vino_interrupt(int irq, void *dev_id, struct pt_regs *regs) |
2198 | { | 2328 | { |
2199 | u32 intr; | 2329 | u32 ctrl, intr; |
2200 | unsigned int fc_a, fc_b; | 2330 | unsigned int fc_a, fc_b; |
2201 | int done_a = 0; | 2331 | int handled_a = 0, skip_a = 0, done_a = 0; |
2202 | int done_b = 0; | 2332 | int handled_b = 0, skip_b = 0, done_b = 0; |
2333 | |||
2334 | #ifdef VINO_DEBUG_INT | ||
2335 | int loop = 0; | ||
2336 | unsigned int line_count = vino->a.line_count, | ||
2337 | page_index = vino->a.page_index, | ||
2338 | field_counter = vino->a.field_counter, | ||
2339 | start_desc_tbl = vino->a.start_desc_tbl, | ||
2340 | next_4_desc = vino->a.next_4_desc; | ||
2341 | unsigned int line_count_2, | ||
2342 | page_index_2, | ||
2343 | field_counter_2, | ||
2344 | start_desc_tbl_2, | ||
2345 | next_4_desc_2; | ||
2346 | #endif | ||
2203 | 2347 | ||
2204 | spin_lock(&vino_drvdata->vino_lock); | 2348 | spin_lock(&vino_drvdata->vino_lock); |
2205 | 2349 | ||
2206 | intr = vino->intr_status; | 2350 | while ((intr = vino->intr_status)) { |
2207 | fc_a = vino->a.field_counter / 2; | 2351 | fc_a = vino->a.field_counter >> 1; |
2208 | fc_b = vino->b.field_counter / 2; | 2352 | fc_b = vino->b.field_counter >> 1; |
2209 | 2353 | ||
2210 | // TODO: handle error-interrupts in some special way ? | 2354 | /* handle error-interrupts in some special way ? |
2211 | 2355 | * --> skips frames */ | |
2212 | if (intr & VINO_INTSTAT_A) { | 2356 | if (intr & VINO_INTSTAT_A) { |
2213 | if (intr & VINO_INTSTAT_A_EOF) { | 2357 | if (intr & VINO_INTSTAT_A_EOF) { |
2214 | vino_drvdata->a.field++; | 2358 | vino_drvdata->a.field++; |
2215 | if (vino_drvdata->a.field > 1) { | 2359 | if (vino_drvdata->a.field > 1) { |
2360 | vino_dma_stop(&vino_drvdata->a); | ||
2361 | vino_clear_interrupt(&vino_drvdata->a); | ||
2362 | vino_drvdata->a.field = 0; | ||
2363 | done_a = 1; | ||
2364 | } else { | ||
2365 | if (vino->a.page_index | ||
2366 | != vino_drvdata->a.line_size) { | ||
2367 | vino->a.line_count = 0; | ||
2368 | vino->a.page_index = | ||
2369 | vino_drvdata-> | ||
2370 | a.line_size; | ||
2371 | vino->a.next_4_desc = | ||
2372 | vino->a.start_desc_tbl; | ||
2373 | } | ||
2374 | } | ||
2375 | dprintk("channel A end-of-field " | ||
2376 | "interrupt: %04x\n", intr); | ||
2377 | } else { | ||
2216 | vino_dma_stop(&vino_drvdata->a); | 2378 | vino_dma_stop(&vino_drvdata->a); |
2217 | vino_clear_interrupt(&vino_drvdata->a); | 2379 | vino_clear_interrupt(&vino_drvdata->a); |
2218 | vino_drvdata->a.field = 0; | 2380 | vino_drvdata->a.field = 0; |
2219 | done_a = 1; | 2381 | skip_a = 1; |
2382 | dprintk("channel A error interrupt: %04x\n", | ||
2383 | intr); | ||
2220 | } | 2384 | } |
2221 | dprintk("intr: channel A end-of-field interrupt: " | 2385 | |
2222 | "%04x\n", intr); | 2386 | #ifdef VINO_DEBUG_INT |
2223 | } else { | 2387 | line_count_2 = vino->a.line_count; |
2224 | vino_dma_stop(&vino_drvdata->a); | 2388 | page_index_2 = vino->a.page_index; |
2225 | vino_clear_interrupt(&vino_drvdata->a); | 2389 | field_counter_2 = vino->a.field_counter; |
2226 | done_a = 1; | 2390 | start_desc_tbl_2 = vino->a.start_desc_tbl; |
2227 | dprintk("channel A error interrupt: %04x\n", intr); | 2391 | next_4_desc_2 = vino->a.next_4_desc; |
2392 | |||
2393 | printk("intr = %04x, loop = %d, field = %d\n", | ||
2394 | intr, loop, vino_drvdata->a.field); | ||
2395 | printk("1- line count = %04d, page index = %04d, " | ||
2396 | "start = %08x, next = %08x\n" | ||
2397 | " fieldc = %d, framec = %d\n", | ||
2398 | line_count, page_index, start_desc_tbl, | ||
2399 | next_4_desc, field_counter, fc_a); | ||
2400 | printk("12-line count = %04d, page index = %04d, " | ||
2401 | " start = %08x, next = %08x\n", | ||
2402 | line_count_2, page_index_2, start_desc_tbl_2, | ||
2403 | next_4_desc_2); | ||
2404 | |||
2405 | if (done_a) | ||
2406 | printk("\n"); | ||
2407 | #endif | ||
2228 | } | 2408 | } |
2229 | } | 2409 | |
2230 | if (intr & VINO_INTSTAT_B) { | 2410 | if (intr & VINO_INTSTAT_B) { |
2231 | if (intr & VINO_INTSTAT_B_EOF) { | 2411 | if (intr & VINO_INTSTAT_B_EOF) { |
2232 | vino_drvdata->b.field++; | 2412 | vino_drvdata->b.field++; |
2233 | if (vino_drvdata->b.field > 1) { | 2413 | if (vino_drvdata->b.field > 1) { |
2414 | vino_dma_stop(&vino_drvdata->b); | ||
2415 | vino_clear_interrupt(&vino_drvdata->b); | ||
2416 | vino_drvdata->b.field = 0; | ||
2417 | done_b = 1; | ||
2418 | } | ||
2419 | dprintk("channel B end-of-field " | ||
2420 | "interrupt: %04x\n", intr); | ||
2421 | } else { | ||
2234 | vino_dma_stop(&vino_drvdata->b); | 2422 | vino_dma_stop(&vino_drvdata->b); |
2235 | vino_clear_interrupt(&vino_drvdata->b); | 2423 | vino_clear_interrupt(&vino_drvdata->b); |
2236 | vino_drvdata->b.field = 0; | 2424 | vino_drvdata->b.field = 0; |
2237 | done_b = 1; | 2425 | skip_b = 1; |
2426 | dprintk("channel B error interrupt: %04x\n", | ||
2427 | intr); | ||
2238 | } | 2428 | } |
2239 | dprintk("intr: channel B end-of-field interrupt: " | ||
2240 | "%04x\n", intr); | ||
2241 | } else { | ||
2242 | vino_dma_stop(&vino_drvdata->b); | ||
2243 | vino_clear_interrupt(&vino_drvdata->b); | ||
2244 | done_b = 1; | ||
2245 | dprintk("channel B error interrupt: %04x\n", intr); | ||
2246 | } | 2429 | } |
2247 | } | ||
2248 | 2430 | ||
2249 | /* always remember to clear interrupt status */ | 2431 | /* Always remember to clear interrupt status. |
2250 | vino->intr_status = ~intr; | 2432 | * Disable VINO interrupts while we do this. */ |
2433 | ctrl = vino->control; | ||
2434 | vino->control = ctrl & ~(VINO_CTRL_A_INT | VINO_CTRL_B_INT); | ||
2435 | vino->intr_status = ~intr; | ||
2436 | vino->control = ctrl; | ||
2251 | 2437 | ||
2252 | spin_unlock(&vino_drvdata->vino_lock); | 2438 | spin_unlock(&vino_drvdata->vino_lock); |
2253 | 2439 | ||
2254 | if (done_a) { | 2440 | if ((!handled_a) && (done_a || skip_a)) { |
2255 | vino_frame_done(&vino_drvdata->a, fc_a); | 2441 | if (!skip_a) { |
2256 | dprintk("channel A frame done, interrupt: %d\n", intr); | 2442 | do_gettimeofday(&vino_drvdata-> |
2257 | } | 2443 | a.int_data.timestamp); |
2258 | if (done_b) { | 2444 | vino_drvdata->a.int_data.frame_counter = fc_a; |
2259 | vino_frame_done(&vino_drvdata->b, fc_b); | 2445 | } |
2260 | dprintk("channel B frame done, interrupt: %d\n", intr); | 2446 | vino_drvdata->a.int_data.skip = skip_a; |
2447 | |||
2448 | dprintk("channel A %s, interrupt: %d\n", | ||
2449 | skip_a ? "skipping frame" : "frame done", | ||
2450 | intr); | ||
2451 | tasklet_hi_schedule(&vino_tasklet_a); | ||
2452 | handled_a = 1; | ||
2453 | } | ||
2454 | |||
2455 | if ((!handled_b) && (done_b || skip_b)) { | ||
2456 | if (!skip_b) { | ||
2457 | do_gettimeofday(&vino_drvdata-> | ||
2458 | b.int_data.timestamp); | ||
2459 | vino_drvdata->b.int_data.frame_counter = fc_b; | ||
2460 | } | ||
2461 | vino_drvdata->b.int_data.skip = skip_b; | ||
2462 | |||
2463 | dprintk("channel B %s, interrupt: %d\n", | ||
2464 | skip_b ? "skipping frame" : "frame done", | ||
2465 | intr); | ||
2466 | tasklet_hi_schedule(&vino_tasklet_b); | ||
2467 | handled_b = 1; | ||
2468 | } | ||
2469 | |||
2470 | #ifdef VINO_DEBUG_INT | ||
2471 | loop++; | ||
2472 | #endif | ||
2473 | spin_lock(&vino_drvdata->vino_lock); | ||
2261 | } | 2474 | } |
2262 | 2475 | ||
2476 | spin_unlock(&vino_drvdata->vino_lock); | ||
2477 | |||
2263 | return IRQ_HANDLED; | 2478 | return IRQ_HANDLED; |
2264 | } | 2479 | } |
2265 | 2480 | ||
@@ -2279,11 +2494,13 @@ static int vino_get_saa7191_input(int input) | |||
2279 | } | 2494 | } |
2280 | } | 2495 | } |
2281 | 2496 | ||
2282 | static int vino_get_saa7191_norm(int norm) | 2497 | static int vino_get_saa7191_norm(unsigned int data_norm) |
2283 | { | 2498 | { |
2284 | switch (norm) { | 2499 | switch (data_norm) { |
2285 | case VINO_DATA_NORM_AUTO: | 2500 | case VINO_DATA_NORM_AUTO: |
2286 | return SAA7191_NORM_AUTO; | 2501 | return SAA7191_NORM_AUTO; |
2502 | case VINO_DATA_NORM_AUTO_EXT: | ||
2503 | return SAA7191_NORM_AUTO_EXT; | ||
2287 | case VINO_DATA_NORM_PAL: | 2504 | case VINO_DATA_NORM_PAL: |
2288 | return SAA7191_NORM_PAL; | 2505 | return SAA7191_NORM_PAL; |
2289 | case VINO_DATA_NORM_NTSC: | 2506 | case VINO_DATA_NORM_NTSC: |
@@ -2297,6 +2514,57 @@ static int vino_get_saa7191_norm(int norm) | |||
2297 | } | 2514 | } |
2298 | } | 2515 | } |
2299 | 2516 | ||
2517 | static int vino_get_from_saa7191_norm(int saa7191_norm) | ||
2518 | { | ||
2519 | switch (saa7191_norm) { | ||
2520 | case SAA7191_NORM_PAL: | ||
2521 | return VINO_DATA_NORM_PAL; | ||
2522 | case SAA7191_NORM_NTSC: | ||
2523 | return VINO_DATA_NORM_NTSC; | ||
2524 | case SAA7191_NORM_SECAM: | ||
2525 | return VINO_DATA_NORM_SECAM; | ||
2526 | default: | ||
2527 | printk(KERN_ERR "VINO: vino_get_from_saa7191_norm(): " | ||
2528 | "invalid norm!\n"); | ||
2529 | return VINO_DATA_NORM_NONE; | ||
2530 | } | ||
2531 | } | ||
2532 | |||
2533 | static int vino_saa7191_set_norm(unsigned int *data_norm) | ||
2534 | { | ||
2535 | int saa7191_norm, new_data_norm; | ||
2536 | int err = 0; | ||
2537 | |||
2538 | saa7191_norm = vino_get_saa7191_norm(*data_norm); | ||
2539 | |||
2540 | err = i2c_decoder_command(DECODER_SAA7191_SET_NORM, | ||
2541 | &saa7191_norm); | ||
2542 | if (err) | ||
2543 | goto out; | ||
2544 | |||
2545 | if ((*data_norm == VINO_DATA_NORM_AUTO) | ||
2546 | || (*data_norm == VINO_DATA_NORM_AUTO_EXT)) { | ||
2547 | struct saa7191_status status; | ||
2548 | |||
2549 | err = i2c_decoder_command(DECODER_SAA7191_GET_STATUS, | ||
2550 | &status); | ||
2551 | if (err) | ||
2552 | goto out; | ||
2553 | |||
2554 | new_data_norm = | ||
2555 | vino_get_from_saa7191_norm(status.norm); | ||
2556 | if (new_data_norm == VINO_DATA_NORM_NONE) { | ||
2557 | err = -EINVAL; | ||
2558 | goto out; | ||
2559 | } | ||
2560 | |||
2561 | *data_norm = (unsigned int)new_data_norm; | ||
2562 | } | ||
2563 | |||
2564 | out: | ||
2565 | return err; | ||
2566 | } | ||
2567 | |||
2300 | /* execute with input_lock locked */ | 2568 | /* execute with input_lock locked */ |
2301 | static int vino_is_input_owner(struct vino_channel_settings *vcs) | 2569 | static int vino_is_input_owner(struct vino_channel_settings *vcs) |
2302 | { | 2570 | { |
@@ -2313,11 +2581,12 @@ static int vino_is_input_owner(struct vino_channel_settings *vcs) | |||
2313 | 2581 | ||
2314 | static int vino_acquire_input(struct vino_channel_settings *vcs) | 2582 | static int vino_acquire_input(struct vino_channel_settings *vcs) |
2315 | { | 2583 | { |
2584 | unsigned long flags; | ||
2316 | int ret = 0; | 2585 | int ret = 0; |
2317 | 2586 | ||
2318 | dprintk("vino_acquire_input():\n"); | 2587 | dprintk("vino_acquire_input():\n"); |
2319 | 2588 | ||
2320 | spin_lock(&vino_drvdata->input_lock); | 2589 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
2321 | 2590 | ||
2322 | /* First try D1 and then SAA7191 */ | 2591 | /* First try D1 and then SAA7191 */ |
2323 | if (vino_drvdata->camera.driver | 2592 | if (vino_drvdata->camera.driver |
@@ -2332,23 +2601,48 @@ static int vino_acquire_input(struct vino_channel_settings *vcs) | |||
2332 | vcs->data_norm = VINO_DATA_NORM_D1; | 2601 | vcs->data_norm = VINO_DATA_NORM_D1; |
2333 | } else if (vino_drvdata->decoder.driver | 2602 | } else if (vino_drvdata->decoder.driver |
2334 | && (vino_drvdata->decoder.owner == VINO_NO_CHANNEL)) { | 2603 | && (vino_drvdata->decoder.owner == VINO_NO_CHANNEL)) { |
2604 | int input, data_norm; | ||
2335 | int saa7191_input; | 2605 | int saa7191_input; |
2336 | int saa7191_norm; | ||
2337 | 2606 | ||
2338 | if (i2c_use_client(vino_drvdata->decoder.driver)) { | 2607 | if (i2c_use_client(vino_drvdata->decoder.driver)) { |
2339 | ret = -ENODEV; | 2608 | ret = -ENODEV; |
2340 | goto out; | 2609 | goto out; |
2341 | } | 2610 | } |
2342 | 2611 | ||
2343 | vino_drvdata->decoder.owner = vcs->channel; | 2612 | input = VINO_INPUT_COMPOSITE; |
2344 | vcs->input = VINO_INPUT_COMPOSITE; | 2613 | |
2345 | vcs->data_norm = VINO_DATA_NORM_PAL; | 2614 | saa7191_input = vino_get_saa7191_input(input); |
2615 | ret = i2c_decoder_command(DECODER_SET_INPUT, | ||
2616 | &saa7191_input); | ||
2617 | if (ret) { | ||
2618 | ret = -EINVAL; | ||
2619 | goto out; | ||
2620 | } | ||
2621 | |||
2622 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
2346 | 2623 | ||
2347 | saa7191_input = vino_get_saa7191_input(vcs->input); | 2624 | /* Don't hold spinlocks while auto-detecting norm |
2348 | i2c_decoder_command(DECODER_SET_INPUT, &saa7191_input); | 2625 | * as it may take a while... */ |
2349 | 2626 | ||
2350 | saa7191_norm = vino_get_saa7191_norm(vcs->data_norm); | 2627 | data_norm = VINO_DATA_NORM_AUTO_EXT; |
2351 | i2c_decoder_command(DECODER_SAA7191_SET_NORM, &saa7191_norm); | 2628 | |
2629 | ret = vino_saa7191_set_norm(&data_norm); | ||
2630 | if ((ret == -EBUSY) || (ret == -EAGAIN)) { | ||
2631 | data_norm = VINO_DATA_NORM_PAL; | ||
2632 | ret = vino_saa7191_set_norm(&data_norm); | ||
2633 | } | ||
2634 | |||
2635 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | ||
2636 | |||
2637 | if (ret) { | ||
2638 | ret = -EINVAL; | ||
2639 | goto out; | ||
2640 | } | ||
2641 | |||
2642 | vino_drvdata->decoder.owner = vcs->channel; | ||
2643 | |||
2644 | vcs->input = input; | ||
2645 | vcs->data_norm = data_norm; | ||
2352 | } else { | 2646 | } else { |
2353 | vcs->input = (vcs->channel == VINO_CHANNEL_A) ? | 2647 | vcs->input = (vcs->channel == VINO_CHANNEL_A) ? |
2354 | vino_drvdata->b.input : vino_drvdata->a.input; | 2648 | vino_drvdata->b.input : vino_drvdata->a.input; |
@@ -2361,15 +2655,14 @@ static int vino_acquire_input(struct vino_channel_settings *vcs) | |||
2361 | goto out; | 2655 | goto out; |
2362 | } | 2656 | } |
2363 | 2657 | ||
2364 | if (vino_is_input_owner(vcs)) { | 2658 | vino_set_default_clipping(vcs); |
2365 | vino_set_default_clipping(vcs); | 2659 | vino_set_default_scaling(vcs); |
2366 | vino_set_default_framerate(vcs); | 2660 | vino_set_default_framerate(vcs); |
2367 | } | ||
2368 | 2661 | ||
2369 | dprintk("vino_acquire_input(): %s\n", vino_inputs[vcs->input].name); | 2662 | dprintk("vino_acquire_input(): %s\n", vino_inputs[vcs->input].name); |
2370 | 2663 | ||
2371 | out: | 2664 | out: |
2372 | spin_unlock(&vino_drvdata->input_lock); | 2665 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
2373 | 2666 | ||
2374 | return ret; | 2667 | return ret; |
2375 | } | 2668 | } |
@@ -2378,16 +2671,17 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input) | |||
2378 | { | 2671 | { |
2379 | struct vino_channel_settings *vcs2 = (vcs->channel == VINO_CHANNEL_A) ? | 2672 | struct vino_channel_settings *vcs2 = (vcs->channel == VINO_CHANNEL_A) ? |
2380 | &vino_drvdata->b : &vino_drvdata->a; | 2673 | &vino_drvdata->b : &vino_drvdata->a; |
2674 | unsigned long flags; | ||
2381 | int ret = 0; | 2675 | int ret = 0; |
2382 | 2676 | ||
2383 | dprintk("vino_set_input():\n"); | 2677 | dprintk("vino_set_input():\n"); |
2384 | 2678 | ||
2385 | spin_lock(&vino_drvdata->input_lock); | 2679 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
2386 | 2680 | ||
2387 | if (vcs->input == input) | 2681 | if (vcs->input == input) |
2388 | goto out; | 2682 | goto out; |
2389 | 2683 | ||
2390 | switch(input) { | 2684 | switch (input) { |
2391 | case VINO_INPUT_COMPOSITE: | 2685 | case VINO_INPUT_COMPOSITE: |
2392 | case VINO_INPUT_SVIDEO: | 2686 | case VINO_INPUT_SVIDEO: |
2393 | if (!vino_drvdata->decoder.driver) { | 2687 | if (!vino_drvdata->decoder.driver) { |
@@ -2404,19 +2698,43 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input) | |||
2404 | } | 2698 | } |
2405 | 2699 | ||
2406 | if (vino_drvdata->decoder.owner == vcs->channel) { | 2700 | if (vino_drvdata->decoder.owner == vcs->channel) { |
2701 | int data_norm; | ||
2407 | int saa7191_input; | 2702 | int saa7191_input; |
2408 | int saa7191_norm; | ||
2409 | 2703 | ||
2410 | vcs->input = input; | 2704 | saa7191_input = vino_get_saa7191_input(input); |
2411 | vcs->data_norm = VINO_DATA_NORM_PAL; | 2705 | ret = i2c_decoder_command(DECODER_SET_INPUT, |
2706 | &saa7191_input); | ||
2707 | if (ret) { | ||
2708 | vino_drvdata->decoder.owner = VINO_NO_CHANNEL; | ||
2709 | ret = -EINVAL; | ||
2710 | goto out; | ||
2711 | } | ||
2712 | |||
2713 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
2714 | |||
2715 | /* Don't hold spinlocks while auto-detecting norm | ||
2716 | * as it may take a while... */ | ||
2717 | |||
2718 | data_norm = VINO_DATA_NORM_AUTO_EXT; | ||
2719 | |||
2720 | ret = vino_saa7191_set_norm(&data_norm); | ||
2721 | if ((ret == -EBUSY) || (ret == -EAGAIN)) { | ||
2722 | data_norm = VINO_DATA_NORM_PAL; | ||
2723 | ret = vino_saa7191_set_norm(&data_norm); | ||
2724 | } | ||
2412 | 2725 | ||
2413 | saa7191_input = vino_get_saa7191_input(vcs->input); | 2726 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
2414 | i2c_decoder_command(DECODER_SET_INPUT, &saa7191_input); | 2727 | |
2415 | saa7191_norm = vino_get_saa7191_norm(vcs->data_norm); | 2728 | if (ret) { |
2416 | i2c_decoder_command(DECODER_SAA7191_SET_NORM, | 2729 | vino_drvdata->decoder.owner = VINO_NO_CHANNEL; |
2417 | &saa7191_norm); | 2730 | ret = -EINVAL; |
2731 | goto out; | ||
2732 | } | ||
2733 | |||
2734 | vcs->input = input; | ||
2735 | vcs->data_norm = data_norm; | ||
2418 | } else { | 2736 | } else { |
2419 | if (vcs2->input != input) { | 2737 | if (input != vcs2->input) { |
2420 | ret = -EBUSY; | 2738 | ret = -EBUSY; |
2421 | goto out; | 2739 | goto out; |
2422 | } | 2740 | } |
@@ -2471,12 +2789,13 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input) | |||
2471 | } | 2789 | } |
2472 | 2790 | ||
2473 | vino_set_default_clipping(vcs); | 2791 | vino_set_default_clipping(vcs); |
2792 | vino_set_default_scaling(vcs); | ||
2474 | vino_set_default_framerate(vcs); | 2793 | vino_set_default_framerate(vcs); |
2475 | 2794 | ||
2476 | dprintk("vino_set_input(): %s\n", vino_inputs[vcs->input].name); | 2795 | dprintk("vino_set_input(): %s\n", vino_inputs[vcs->input].name); |
2477 | 2796 | ||
2478 | out: | 2797 | out: |
2479 | spin_unlock(&vino_drvdata->input_lock); | 2798 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
2480 | 2799 | ||
2481 | return ret; | 2800 | return ret; |
2482 | } | 2801 | } |
@@ -2485,10 +2804,11 @@ static void vino_release_input(struct vino_channel_settings *vcs) | |||
2485 | { | 2804 | { |
2486 | struct vino_channel_settings *vcs2 = (vcs->channel == VINO_CHANNEL_A) ? | 2805 | struct vino_channel_settings *vcs2 = (vcs->channel == VINO_CHANNEL_A) ? |
2487 | &vino_drvdata->b : &vino_drvdata->a; | 2806 | &vino_drvdata->b : &vino_drvdata->a; |
2807 | unsigned long flags; | ||
2488 | 2808 | ||
2489 | dprintk("vino_release_input():\n"); | 2809 | dprintk("vino_release_input():\n"); |
2490 | 2810 | ||
2491 | spin_lock(&vino_drvdata->input_lock); | 2811 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
2492 | 2812 | ||
2493 | /* Release ownership of the channel | 2813 | /* Release ownership of the channel |
2494 | * and if the other channel takes input from | 2814 | * and if the other channel takes input from |
@@ -2511,34 +2831,61 @@ static void vino_release_input(struct vino_channel_settings *vcs) | |||
2511 | } | 2831 | } |
2512 | vcs->input = VINO_INPUT_NONE; | 2832 | vcs->input = VINO_INPUT_NONE; |
2513 | 2833 | ||
2514 | spin_unlock(&vino_drvdata->input_lock); | 2834 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
2515 | } | 2835 | } |
2516 | 2836 | ||
2517 | /* execute with input_lock locked */ | 2837 | /* execute with input_lock locked */ |
2518 | static int vino_set_data_norm(struct vino_channel_settings *vcs, | 2838 | static int vino_set_data_norm(struct vino_channel_settings *vcs, |
2519 | unsigned int data_norm) | 2839 | unsigned int data_norm, |
2840 | unsigned long *flags) | ||
2520 | { | 2841 | { |
2521 | int saa7191_norm; | 2842 | int err = 0; |
2843 | |||
2844 | if (data_norm == vcs->data_norm) | ||
2845 | return 0; | ||
2522 | 2846 | ||
2523 | switch (vcs->input) { | 2847 | switch (vcs->input) { |
2524 | case VINO_INPUT_D1: | 2848 | case VINO_INPUT_D1: |
2525 | /* only one "norm" supported */ | 2849 | /* only one "norm" supported */ |
2526 | if (data_norm != VINO_DATA_NORM_D1) | 2850 | if ((data_norm != VINO_DATA_NORM_D1) |
2851 | && (data_norm != VINO_DATA_NORM_AUTO) | ||
2852 | && (data_norm != VINO_DATA_NORM_AUTO_EXT)) | ||
2527 | return -EINVAL; | 2853 | return -EINVAL; |
2528 | break; | 2854 | break; |
2529 | case VINO_INPUT_COMPOSITE: | 2855 | case VINO_INPUT_COMPOSITE: |
2530 | case VINO_INPUT_SVIDEO: | 2856 | case VINO_INPUT_SVIDEO: { |
2857 | if ((data_norm != VINO_DATA_NORM_PAL) | ||
2858 | && (data_norm != VINO_DATA_NORM_NTSC) | ||
2859 | && (data_norm != VINO_DATA_NORM_SECAM) | ||
2860 | && (data_norm != VINO_DATA_NORM_AUTO) | ||
2861 | && (data_norm != VINO_DATA_NORM_AUTO_EXT)) | ||
2862 | return -EINVAL; | ||
2531 | 2863 | ||
2532 | saa7191_norm = vino_get_saa7191_norm(data_norm); | 2864 | spin_unlock_irqrestore(&vino_drvdata->input_lock, *flags); |
2865 | |||
2866 | /* Don't hold spinlocks while setting norm | ||
2867 | * as it may take a while... */ | ||
2868 | |||
2869 | err = vino_saa7191_set_norm(&data_norm); | ||
2870 | |||
2871 | spin_lock_irqsave(&vino_drvdata->input_lock, *flags); | ||
2872 | |||
2873 | if (err) | ||
2874 | goto out; | ||
2533 | 2875 | ||
2534 | i2c_decoder_command(DECODER_SAA7191_SET_NORM, &saa7191_norm); | ||
2535 | vcs->data_norm = data_norm; | 2876 | vcs->data_norm = data_norm; |
2877 | |||
2878 | vino_set_default_clipping(vcs); | ||
2879 | vino_set_default_scaling(vcs); | ||
2880 | vino_set_default_framerate(vcs); | ||
2536 | break; | 2881 | break; |
2882 | } | ||
2537 | default: | 2883 | default: |
2538 | return -EINVAL; | 2884 | return -EINVAL; |
2539 | } | 2885 | } |
2540 | 2886 | ||
2541 | return 0; | 2887 | out: |
2888 | return err; | ||
2542 | } | 2889 | } |
2543 | 2890 | ||
2544 | /* V4L2 helper functions */ | 2891 | /* V4L2 helper functions */ |
@@ -2558,8 +2905,9 @@ static int vino_find_data_format(__u32 pixelformat) | |||
2558 | static int vino_enum_data_norm(struct vino_channel_settings *vcs, __u32 index) | 2905 | static int vino_enum_data_norm(struct vino_channel_settings *vcs, __u32 index) |
2559 | { | 2906 | { |
2560 | int data_norm = VINO_DATA_NORM_NONE; | 2907 | int data_norm = VINO_DATA_NORM_NONE; |
2908 | unsigned long flags; | ||
2561 | 2909 | ||
2562 | spin_lock(&vino_drvdata->input_lock); | 2910 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
2563 | switch(vcs->input) { | 2911 | switch(vcs->input) { |
2564 | case VINO_INPUT_COMPOSITE: | 2912 | case VINO_INPUT_COMPOSITE: |
2565 | case VINO_INPUT_SVIDEO: | 2913 | case VINO_INPUT_SVIDEO: |
@@ -2577,7 +2925,7 @@ static int vino_enum_data_norm(struct vino_channel_settings *vcs, __u32 index) | |||
2577 | } | 2925 | } |
2578 | break; | 2926 | break; |
2579 | } | 2927 | } |
2580 | spin_unlock(&vino_drvdata->input_lock); | 2928 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
2581 | 2929 | ||
2582 | return data_norm; | 2930 | return data_norm; |
2583 | } | 2931 | } |
@@ -2585,8 +2933,9 @@ static int vino_enum_data_norm(struct vino_channel_settings *vcs, __u32 index) | |||
2585 | static int vino_enum_input(struct vino_channel_settings *vcs, __u32 index) | 2933 | static int vino_enum_input(struct vino_channel_settings *vcs, __u32 index) |
2586 | { | 2934 | { |
2587 | int input = VINO_INPUT_NONE; | 2935 | int input = VINO_INPUT_NONE; |
2936 | unsigned long flags; | ||
2588 | 2937 | ||
2589 | spin_lock(&vino_drvdata->input_lock); | 2938 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
2590 | if (vino_drvdata->decoder.driver && vino_drvdata->camera.driver) { | 2939 | if (vino_drvdata->decoder.driver && vino_drvdata->camera.driver) { |
2591 | switch (index) { | 2940 | switch (index) { |
2592 | case 0: | 2941 | case 0: |
@@ -2615,7 +2964,7 @@ static int vino_enum_input(struct vino_channel_settings *vcs, __u32 index) | |||
2615 | break; | 2964 | break; |
2616 | } | 2965 | } |
2617 | } | 2966 | } |
2618 | spin_unlock(&vino_drvdata->input_lock); | 2967 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
2619 | 2968 | ||
2620 | return input; | 2969 | return input; |
2621 | } | 2970 | } |
@@ -2704,15 +3053,16 @@ static int vino_v4l2_enuminput(struct vino_channel_settings *vcs, | |||
2704 | } | 3053 | } |
2705 | 3054 | ||
2706 | static int vino_v4l2_g_input(struct vino_channel_settings *vcs, | 3055 | static int vino_v4l2_g_input(struct vino_channel_settings *vcs, |
2707 | struct v4l2_input *i) | 3056 | unsigned int *i) |
2708 | { | 3057 | { |
2709 | __u32 index; | 3058 | __u32 index; |
2710 | int input; | 3059 | int input; |
3060 | unsigned long flags; | ||
2711 | 3061 | ||
2712 | spin_lock(&vino_drvdata->input_lock); | 3062 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
2713 | input = vcs->input; | 3063 | input = vcs->input; |
2714 | index = vino_find_input_index(vcs); | 3064 | index = vino_find_input_index(vcs); |
2715 | spin_unlock(&vino_drvdata->input_lock); | 3065 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
2716 | 3066 | ||
2717 | dprintk("input = %d\n", input); | 3067 | dprintk("input = %d\n", input); |
2718 | 3068 | ||
@@ -2720,23 +3070,18 @@ static int vino_v4l2_g_input(struct vino_channel_settings *vcs, | |||
2720 | return -EINVAL; | 3070 | return -EINVAL; |
2721 | } | 3071 | } |
2722 | 3072 | ||
2723 | memset(i, 0, sizeof(struct v4l2_input)); | 3073 | *i = index; |
2724 | |||
2725 | i->index = index; | ||
2726 | i->type = V4L2_INPUT_TYPE_CAMERA; | ||
2727 | i->std = vino_inputs[input].std; | ||
2728 | strcpy(i->name, vino_inputs[input].name); | ||
2729 | 3074 | ||
2730 | return 0; | 3075 | return 0; |
2731 | } | 3076 | } |
2732 | 3077 | ||
2733 | static int vino_v4l2_s_input(struct vino_channel_settings *vcs, | 3078 | static int vino_v4l2_s_input(struct vino_channel_settings *vcs, |
2734 | struct v4l2_input *i) | 3079 | unsigned int *i) |
2735 | { | 3080 | { |
2736 | int input; | 3081 | int input; |
2737 | dprintk("requested input = %d\n", i->index); | 3082 | dprintk("requested input = %d\n", *i); |
2738 | 3083 | ||
2739 | input = vino_enum_input(vcs, i->index); | 3084 | input = vino_enum_input(vcs, *i); |
2740 | if (input == VINO_INPUT_NONE) | 3085 | if (input == VINO_INPUT_NONE) |
2741 | return -EINVAL; | 3086 | return -EINVAL; |
2742 | 3087 | ||
@@ -2747,7 +3092,9 @@ static int vino_v4l2_enumstd(struct vino_channel_settings *vcs, | |||
2747 | struct v4l2_standard *s) | 3092 | struct v4l2_standard *s) |
2748 | { | 3093 | { |
2749 | int index = s->index; | 3094 | int index = s->index; |
2750 | int data_norm = vino_enum_data_norm(vcs, index); | 3095 | int data_norm; |
3096 | |||
3097 | data_norm = vino_enum_data_norm(vcs, index); | ||
2751 | dprintk("standard index = %d\n", index); | 3098 | dprintk("standard index = %d\n", index); |
2752 | 3099 | ||
2753 | if (data_norm == VINO_DATA_NORM_NONE) | 3100 | if (data_norm == VINO_DATA_NORM_NONE) |
@@ -2771,13 +3118,55 @@ static int vino_v4l2_enumstd(struct vino_channel_settings *vcs, | |||
2771 | return 0; | 3118 | return 0; |
2772 | } | 3119 | } |
2773 | 3120 | ||
3121 | static int vino_v4l2_querystd(struct vino_channel_settings *vcs, | ||
3122 | v4l2_std_id *std) | ||
3123 | { | ||
3124 | unsigned long flags; | ||
3125 | int err = 0; | ||
3126 | |||
3127 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | ||
3128 | |||
3129 | switch (vcs->input) { | ||
3130 | case VINO_INPUT_D1: | ||
3131 | *std = vino_inputs[vcs->input].std; | ||
3132 | break; | ||
3133 | case VINO_INPUT_COMPOSITE: | ||
3134 | case VINO_INPUT_SVIDEO: { | ||
3135 | struct saa7191_status status; | ||
3136 | |||
3137 | i2c_decoder_command(DECODER_SAA7191_GET_STATUS, &status); | ||
3138 | |||
3139 | if (status.signal) { | ||
3140 | if (status.signal_60hz) { | ||
3141 | *std = V4L2_STD_NTSC; | ||
3142 | } else { | ||
3143 | *std = V4L2_STD_PAL | V4L2_STD_SECAM; | ||
3144 | } | ||
3145 | } else { | ||
3146 | *std = vino_inputs[vcs->input].std; | ||
3147 | } | ||
3148 | break; | ||
3149 | } | ||
3150 | default: | ||
3151 | err = -EINVAL; | ||
3152 | } | ||
3153 | |||
3154 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
3155 | |||
3156 | return err; | ||
3157 | } | ||
3158 | |||
2774 | static int vino_v4l2_g_std(struct vino_channel_settings *vcs, | 3159 | static int vino_v4l2_g_std(struct vino_channel_settings *vcs, |
2775 | v4l2_std_id *std) | 3160 | v4l2_std_id *std) |
2776 | { | 3161 | { |
2777 | spin_lock(&vino_drvdata->input_lock); | 3162 | unsigned long flags; |
2778 | dprintk("current standard = %d\n", vcs->data_norm); | 3163 | |
3164 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | ||
3165 | |||
2779 | *std = vino_data_norms[vcs->data_norm].std; | 3166 | *std = vino_data_norms[vcs->data_norm].std; |
2780 | spin_unlock(&vino_drvdata->input_lock); | 3167 | dprintk("current standard = %d\n", vcs->data_norm); |
3168 | |||
3169 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
2781 | 3170 | ||
2782 | return 0; | 3171 | return 0; |
2783 | } | 3172 | } |
@@ -2785,13 +3174,18 @@ static int vino_v4l2_g_std(struct vino_channel_settings *vcs, | |||
2785 | static int vino_v4l2_s_std(struct vino_channel_settings *vcs, | 3174 | static int vino_v4l2_s_std(struct vino_channel_settings *vcs, |
2786 | v4l2_std_id *std) | 3175 | v4l2_std_id *std) |
2787 | { | 3176 | { |
3177 | unsigned long flags; | ||
2788 | int ret = 0; | 3178 | int ret = 0; |
2789 | 3179 | ||
2790 | spin_lock(&vino_drvdata->input_lock); | 3180 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3181 | |||
3182 | if (!vino_is_input_owner(vcs)) { | ||
3183 | ret = -EBUSY; | ||
3184 | goto out; | ||
3185 | } | ||
2791 | 3186 | ||
2792 | /* check if the standard is valid for the current input */ | 3187 | /* check if the standard is valid for the current input */ |
2793 | if (vino_is_input_owner(vcs) | 3188 | if ((*std) & vino_inputs[vcs->input].std) { |
2794 | && (vino_inputs[vcs->input].std & (*std))) { | ||
2795 | dprintk("standard accepted\n"); | 3189 | dprintk("standard accepted\n"); |
2796 | 3190 | ||
2797 | /* change the video norm for SAA7191 | 3191 | /* change the video norm for SAA7191 |
@@ -2800,24 +3194,33 @@ static int vino_v4l2_s_std(struct vino_channel_settings *vcs, | |||
2800 | if (vcs->input == VINO_INPUT_D1) | 3194 | if (vcs->input == VINO_INPUT_D1) |
2801 | goto out; | 3195 | goto out; |
2802 | 3196 | ||
2803 | if ((*std) & V4L2_STD_PAL) { | 3197 | if (((*std) & V4L2_STD_PAL) |
2804 | vino_set_data_norm(vcs, VINO_DATA_NORM_PAL); | 3198 | && ((*std) & V4L2_STD_NTSC) |
2805 | vcs->data_norm = VINO_DATA_NORM_PAL; | 3199 | && ((*std) & V4L2_STD_SECAM)) { |
3200 | ret = vino_set_data_norm(vcs, VINO_DATA_NORM_AUTO_EXT, | ||
3201 | &flags); | ||
3202 | } else if ((*std) & V4L2_STD_PAL) { | ||
3203 | ret = vino_set_data_norm(vcs, VINO_DATA_NORM_PAL, | ||
3204 | &flags); | ||
2806 | } else if ((*std) & V4L2_STD_NTSC) { | 3205 | } else if ((*std) & V4L2_STD_NTSC) { |
2807 | vino_set_data_norm(vcs, VINO_DATA_NORM_NTSC); | 3206 | ret = vino_set_data_norm(vcs, VINO_DATA_NORM_NTSC, |
2808 | vcs->data_norm = VINO_DATA_NORM_NTSC; | 3207 | &flags); |
2809 | } else if ((*std) & V4L2_STD_SECAM) { | 3208 | } else if ((*std) & V4L2_STD_SECAM) { |
2810 | vino_set_data_norm(vcs, VINO_DATA_NORM_SECAM); | 3209 | ret = vino_set_data_norm(vcs, VINO_DATA_NORM_SECAM, |
2811 | vcs->data_norm = VINO_DATA_NORM_SECAM; | 3210 | &flags); |
2812 | } else { | 3211 | } else { |
2813 | ret = -EINVAL; | 3212 | ret = -EINVAL; |
2814 | } | 3213 | } |
3214 | |||
3215 | if (ret) { | ||
3216 | ret = -EINVAL; | ||
3217 | } | ||
2815 | } else { | 3218 | } else { |
2816 | ret = -EINVAL; | 3219 | ret = -EINVAL; |
2817 | } | 3220 | } |
2818 | 3221 | ||
2819 | out: | 3222 | out: |
2820 | spin_unlock(&vino_drvdata->input_lock); | 3223 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
2821 | 3224 | ||
2822 | return ret; | 3225 | return ret; |
2823 | } | 3226 | } |
@@ -2855,6 +3258,7 @@ static int vino_v4l2_try_fmt(struct vino_channel_settings *vcs, | |||
2855 | struct v4l2_format *f) | 3258 | struct v4l2_format *f) |
2856 | { | 3259 | { |
2857 | struct vino_channel_settings tempvcs; | 3260 | struct vino_channel_settings tempvcs; |
3261 | unsigned long flags; | ||
2858 | 3262 | ||
2859 | switch (f->type) { | 3263 | switch (f->type) { |
2860 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { | 3264 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { |
@@ -2863,13 +3267,13 @@ static int vino_v4l2_try_fmt(struct vino_channel_settings *vcs, | |||
2863 | dprintk("requested: w = %d, h = %d\n", | 3267 | dprintk("requested: w = %d, h = %d\n", |
2864 | pf->width, pf->height); | 3268 | pf->width, pf->height); |
2865 | 3269 | ||
2866 | spin_lock(&vino_drvdata->input_lock); | 3270 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
2867 | memcpy(&tempvcs, vcs, sizeof(struct vino_channel_settings)); | 3271 | memcpy(&tempvcs, vcs, sizeof(struct vino_channel_settings)); |
2868 | spin_unlock(&vino_drvdata->input_lock); | 3272 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
2869 | 3273 | ||
2870 | tempvcs.data_format = vino_find_data_format(pf->pixelformat); | 3274 | tempvcs.data_format = vino_find_data_format(pf->pixelformat); |
2871 | if (tempvcs.data_format == VINO_DATA_FMT_NONE) { | 3275 | if (tempvcs.data_format == VINO_DATA_FMT_NONE) { |
2872 | tempvcs.data_format = VINO_DATA_FMT_RGB32; | 3276 | tempvcs.data_format = VINO_DATA_FMT_GREY; |
2873 | pf->pixelformat = | 3277 | pf->pixelformat = |
2874 | vino_data_formats[tempvcs.data_format]. | 3278 | vino_data_formats[tempvcs.data_format]. |
2875 | pixelformat; | 3279 | pixelformat; |
@@ -2908,10 +3312,13 @@ static int vino_v4l2_try_fmt(struct vino_channel_settings *vcs, | |||
2908 | static int vino_v4l2_g_fmt(struct vino_channel_settings *vcs, | 3312 | static int vino_v4l2_g_fmt(struct vino_channel_settings *vcs, |
2909 | struct v4l2_format *f) | 3313 | struct v4l2_format *f) |
2910 | { | 3314 | { |
3315 | unsigned long flags; | ||
3316 | |||
2911 | switch (f->type) { | 3317 | switch (f->type) { |
2912 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { | 3318 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { |
2913 | struct v4l2_pix_format *pf = &f->fmt.pix; | 3319 | struct v4l2_pix_format *pf = &f->fmt.pix; |
2914 | spin_lock(&vino_drvdata->input_lock); | 3320 | |
3321 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); | ||
2915 | 3322 | ||
2916 | pf->width = (vcs->clipping.right - vcs->clipping.left) / | 3323 | pf->width = (vcs->clipping.right - vcs->clipping.left) / |
2917 | vcs->decimation; | 3324 | vcs->decimation; |
@@ -2930,7 +3337,7 @@ static int vino_v4l2_g_fmt(struct vino_channel_settings *vcs, | |||
2930 | 3337 | ||
2931 | pf->priv = 0; | 3338 | pf->priv = 0; |
2932 | 3339 | ||
2933 | spin_unlock(&vino_drvdata->input_lock); | 3340 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
2934 | break; | 3341 | break; |
2935 | } | 3342 | } |
2936 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 3343 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
@@ -2945,20 +3352,18 @@ static int vino_v4l2_s_fmt(struct vino_channel_settings *vcs, | |||
2945 | struct v4l2_format *f) | 3352 | struct v4l2_format *f) |
2946 | { | 3353 | { |
2947 | int data_format; | 3354 | int data_format; |
3355 | unsigned long flags; | ||
2948 | 3356 | ||
2949 | switch (f->type) { | 3357 | switch (f->type) { |
2950 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { | 3358 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { |
2951 | struct v4l2_pix_format *pf = &f->fmt.pix; | 3359 | struct v4l2_pix_format *pf = &f->fmt.pix; |
2952 | spin_lock(&vino_drvdata->input_lock); | ||
2953 | 3360 | ||
2954 | if (!vino_is_input_owner(vcs)) { | 3361 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
2955 | spin_unlock(&vino_drvdata->input_lock); | ||
2956 | return -EINVAL; | ||
2957 | } | ||
2958 | 3362 | ||
2959 | data_format = vino_find_data_format(pf->pixelformat); | 3363 | data_format = vino_find_data_format(pf->pixelformat); |
3364 | |||
2960 | if (data_format == VINO_DATA_FMT_NONE) { | 3365 | if (data_format == VINO_DATA_FMT_NONE) { |
2961 | vcs->data_format = VINO_DATA_FMT_RGB32; | 3366 | vcs->data_format = VINO_DATA_FMT_GREY; |
2962 | pf->pixelformat = | 3367 | pf->pixelformat = |
2963 | vino_data_formats[vcs->data_format]. | 3368 | vino_data_formats[vcs->data_format]. |
2964 | pixelformat; | 3369 | pixelformat; |
@@ -2985,7 +3390,7 @@ static int vino_v4l2_s_fmt(struct vino_channel_settings *vcs, | |||
2985 | 3390 | ||
2986 | pf->priv = 0; | 3391 | pf->priv = 0; |
2987 | 3392 | ||
2988 | spin_unlock(&vino_drvdata->input_lock); | 3393 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
2989 | break; | 3394 | break; |
2990 | } | 3395 | } |
2991 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 3396 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
@@ -3000,12 +3405,15 @@ static int vino_v4l2_cropcap(struct vino_channel_settings *vcs, | |||
3000 | struct v4l2_cropcap *ccap) | 3405 | struct v4l2_cropcap *ccap) |
3001 | { | 3406 | { |
3002 | const struct vino_data_norm *norm; | 3407 | const struct vino_data_norm *norm; |
3408 | unsigned long flags; | ||
3003 | 3409 | ||
3004 | switch (ccap->type) { | 3410 | switch (ccap->type) { |
3005 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 3411 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
3006 | spin_lock(&vino_drvdata->input_lock); | 3412 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3413 | |||
3007 | norm = &vino_data_norms[vcs->data_norm]; | 3414 | norm = &vino_data_norms[vcs->data_norm]; |
3008 | spin_unlock(&vino_drvdata->input_lock); | 3415 | |
3416 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
3009 | 3417 | ||
3010 | ccap->bounds.left = 0; | 3418 | ccap->bounds.left = 0; |
3011 | ccap->bounds.top = 0; | 3419 | ccap->bounds.top = 0; |
@@ -3028,16 +3436,18 @@ static int vino_v4l2_cropcap(struct vino_channel_settings *vcs, | |||
3028 | static int vino_v4l2_g_crop(struct vino_channel_settings *vcs, | 3436 | static int vino_v4l2_g_crop(struct vino_channel_settings *vcs, |
3029 | struct v4l2_crop *c) | 3437 | struct v4l2_crop *c) |
3030 | { | 3438 | { |
3439 | unsigned long flags; | ||
3440 | |||
3031 | switch (c->type) { | 3441 | switch (c->type) { |
3032 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 3442 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
3033 | spin_lock(&vino_drvdata->input_lock); | 3443 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3034 | 3444 | ||
3035 | c->c.left = vcs->clipping.left; | 3445 | c->c.left = vcs->clipping.left; |
3036 | c->c.top = vcs->clipping.top; | 3446 | c->c.top = vcs->clipping.top; |
3037 | c->c.width = vcs->clipping.right - vcs->clipping.left; | 3447 | c->c.width = vcs->clipping.right - vcs->clipping.left; |
3038 | c->c.height = vcs->clipping.bottom - vcs->clipping.top; | 3448 | c->c.height = vcs->clipping.bottom - vcs->clipping.top; |
3039 | 3449 | ||
3040 | spin_unlock(&vino_drvdata->input_lock); | 3450 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
3041 | break; | 3451 | break; |
3042 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 3452 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
3043 | default: | 3453 | default: |
@@ -3050,18 +3460,16 @@ static int vino_v4l2_g_crop(struct vino_channel_settings *vcs, | |||
3050 | static int vino_v4l2_s_crop(struct vino_channel_settings *vcs, | 3460 | static int vino_v4l2_s_crop(struct vino_channel_settings *vcs, |
3051 | struct v4l2_crop *c) | 3461 | struct v4l2_crop *c) |
3052 | { | 3462 | { |
3463 | unsigned long flags; | ||
3464 | |||
3053 | switch (c->type) { | 3465 | switch (c->type) { |
3054 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 3466 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
3055 | spin_lock(&vino_drvdata->input_lock); | 3467 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3056 | 3468 | ||
3057 | if (!vino_is_input_owner(vcs)) { | ||
3058 | spin_unlock(&vino_drvdata->input_lock); | ||
3059 | return -EINVAL; | ||
3060 | } | ||
3061 | vino_set_clipping(vcs, c->c.left, c->c.top, | 3469 | vino_set_clipping(vcs, c->c.left, c->c.top, |
3062 | c->c.width, c->c.height); | 3470 | c->c.width, c->c.height); |
3063 | 3471 | ||
3064 | spin_unlock(&vino_drvdata->input_lock); | 3472 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
3065 | break; | 3473 | break; |
3066 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 3474 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
3067 | default: | 3475 | default: |
@@ -3074,6 +3482,8 @@ static int vino_v4l2_s_crop(struct vino_channel_settings *vcs, | |||
3074 | static int vino_v4l2_g_parm(struct vino_channel_settings *vcs, | 3482 | static int vino_v4l2_g_parm(struct vino_channel_settings *vcs, |
3075 | struct v4l2_streamparm *sp) | 3483 | struct v4l2_streamparm *sp) |
3076 | { | 3484 | { |
3485 | unsigned long flags; | ||
3486 | |||
3077 | switch (sp->type) { | 3487 | switch (sp->type) { |
3078 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { | 3488 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { |
3079 | struct v4l2_captureparm *cp = &sp->parm.capture; | 3489 | struct v4l2_captureparm *cp = &sp->parm.capture; |
@@ -3082,9 +3492,11 @@ static int vino_v4l2_g_parm(struct vino_channel_settings *vcs, | |||
3082 | cp->capability = V4L2_CAP_TIMEPERFRAME; | 3492 | cp->capability = V4L2_CAP_TIMEPERFRAME; |
3083 | cp->timeperframe.numerator = 1; | 3493 | cp->timeperframe.numerator = 1; |
3084 | 3494 | ||
3085 | spin_lock(&vino_drvdata->input_lock); | 3495 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3496 | |||
3086 | cp->timeperframe.denominator = vcs->fps; | 3497 | cp->timeperframe.denominator = vcs->fps; |
3087 | spin_unlock(&vino_drvdata->input_lock); | 3498 | |
3499 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
3088 | 3500 | ||
3089 | // TODO: cp->readbuffers = xxx; | 3501 | // TODO: cp->readbuffers = xxx; |
3090 | break; | 3502 | break; |
@@ -3100,15 +3512,13 @@ static int vino_v4l2_g_parm(struct vino_channel_settings *vcs, | |||
3100 | static int vino_v4l2_s_parm(struct vino_channel_settings *vcs, | 3512 | static int vino_v4l2_s_parm(struct vino_channel_settings *vcs, |
3101 | struct v4l2_streamparm *sp) | 3513 | struct v4l2_streamparm *sp) |
3102 | { | 3514 | { |
3515 | unsigned long flags; | ||
3516 | |||
3103 | switch (sp->type) { | 3517 | switch (sp->type) { |
3104 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { | 3518 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: { |
3105 | struct v4l2_captureparm *cp = &sp->parm.capture; | 3519 | struct v4l2_captureparm *cp = &sp->parm.capture; |
3106 | 3520 | ||
3107 | spin_lock(&vino_drvdata->input_lock); | 3521 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3108 | if (!vino_is_input_owner(vcs)) { | ||
3109 | spin_unlock(&vino_drvdata->input_lock); | ||
3110 | return -EINVAL; | ||
3111 | } | ||
3112 | 3522 | ||
3113 | if ((cp->timeperframe.numerator == 0) || | 3523 | if ((cp->timeperframe.numerator == 0) || |
3114 | (cp->timeperframe.denominator == 0)) { | 3524 | (cp->timeperframe.denominator == 0)) { |
@@ -3118,7 +3528,8 @@ static int vino_v4l2_s_parm(struct vino_channel_settings *vcs, | |||
3118 | vino_set_framerate(vcs, cp->timeperframe.denominator / | 3528 | vino_set_framerate(vcs, cp->timeperframe.denominator / |
3119 | cp->timeperframe.numerator); | 3529 | cp->timeperframe.numerator); |
3120 | } | 3530 | } |
3121 | spin_unlock(&vino_drvdata->input_lock); | 3531 | |
3532 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
3122 | 3533 | ||
3123 | // TODO: set buffers according to cp->readbuffers | 3534 | // TODO: set buffers according to cp->readbuffers |
3124 | break; | 3535 | break; |
@@ -3145,21 +3556,23 @@ static int vino_v4l2_reqbufs(struct vino_channel_settings *vcs, | |||
3145 | return -EINVAL; | 3556 | return -EINVAL; |
3146 | } | 3557 | } |
3147 | 3558 | ||
3148 | if (vino_is_capturing(vcs)) { | ||
3149 | dprintk("busy, capturing\n"); | ||
3150 | return -EBUSY; | ||
3151 | } | ||
3152 | |||
3153 | dprintk("count = %d\n", rb->count); | 3559 | dprintk("count = %d\n", rb->count); |
3154 | if (rb->count > 0) { | 3560 | if (rb->count > 0) { |
3561 | if (vino_is_capturing(vcs)) { | ||
3562 | dprintk("busy, capturing\n"); | ||
3563 | return -EBUSY; | ||
3564 | } | ||
3565 | |||
3155 | if (vino_queue_has_mapped_buffers(&vcs->fb_queue)) { | 3566 | if (vino_queue_has_mapped_buffers(&vcs->fb_queue)) { |
3156 | dprintk("busy, buffers still mapped\n"); | 3567 | dprintk("busy, buffers still mapped\n"); |
3157 | return -EBUSY; | 3568 | return -EBUSY; |
3158 | } else { | 3569 | } else { |
3570 | vcs->streaming = 0; | ||
3159 | vino_queue_free(&vcs->fb_queue); | 3571 | vino_queue_free(&vcs->fb_queue); |
3160 | vino_queue_init(&vcs->fb_queue, &rb->count); | 3572 | vino_queue_init(&vcs->fb_queue, &rb->count); |
3161 | } | 3573 | } |
3162 | } else { | 3574 | } else { |
3575 | vcs->streaming = 0; | ||
3163 | vino_capture_stop(vcs); | 3576 | vino_capture_stop(vcs); |
3164 | vino_queue_free(&vcs->fb_queue); | 3577 | vino_queue_free(&vcs->fb_queue); |
3165 | } | 3578 | } |
@@ -3302,12 +3715,12 @@ static int vino_v4l2_dqbuf(struct vino_channel_settings *vcs, | |||
3302 | err = vino_queue_get_incoming(&vcs->fb_queue, &incoming); | 3715 | err = vino_queue_get_incoming(&vcs->fb_queue, &incoming); |
3303 | if (err) { | 3716 | if (err) { |
3304 | dprintk("vino_queue_get_incoming() failed\n"); | 3717 | dprintk("vino_queue_get_incoming() failed\n"); |
3305 | return -EIO; | 3718 | return -EINVAL; |
3306 | } | 3719 | } |
3307 | err = vino_queue_get_outgoing(&vcs->fb_queue, &outgoing); | 3720 | err = vino_queue_get_outgoing(&vcs->fb_queue, &outgoing); |
3308 | if (err) { | 3721 | if (err) { |
3309 | dprintk("vino_queue_get_outgoing() failed\n"); | 3722 | dprintk("vino_queue_get_outgoing() failed\n"); |
3310 | return -EIO; | 3723 | return -EINVAL; |
3311 | } | 3724 | } |
3312 | 3725 | ||
3313 | dprintk("incoming = %d, outgoing = %d\n", incoming, outgoing); | 3726 | dprintk("incoming = %d, outgoing = %d\n", incoming, outgoing); |
@@ -3327,8 +3740,10 @@ static int vino_v4l2_dqbuf(struct vino_channel_settings *vcs, | |||
3327 | if (err) { | 3740 | if (err) { |
3328 | err = vino_wait_for_frame(vcs); | 3741 | err = vino_wait_for_frame(vcs); |
3329 | if (err) { | 3742 | if (err) { |
3330 | /* interrupted */ | 3743 | /* interrupted or |
3331 | vino_capture_failed(vcs); | 3744 | * no frames captured because |
3745 | * of frame skipping */ | ||
3746 | // vino_capture_failed(vcs); | ||
3332 | return -EIO; | 3747 | return -EIO; |
3333 | } | 3748 | } |
3334 | } | 3749 | } |
@@ -3341,10 +3756,12 @@ static int vino_v4l2_dqbuf(struct vino_channel_settings *vcs, | |||
3341 | } | 3756 | } |
3342 | 3757 | ||
3343 | err = vino_check_buffer(vcs, fb); | 3758 | err = vino_check_buffer(vcs, fb); |
3759 | |||
3760 | vino_v4l2_get_buffer_status(vcs, fb, b); | ||
3761 | |||
3344 | if (err) | 3762 | if (err) |
3345 | return -EIO; | 3763 | return -EIO; |
3346 | 3764 | ||
3347 | vino_v4l2_get_buffer_status(vcs, fb, b); | ||
3348 | break; | 3765 | break; |
3349 | } | 3766 | } |
3350 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 3767 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
@@ -3401,8 +3818,8 @@ static int vino_v4l2_streamoff(struct vino_channel_settings *vcs) | |||
3401 | if (!vcs->streaming) | 3818 | if (!vcs->streaming) |
3402 | return 0; | 3819 | return 0; |
3403 | 3820 | ||
3404 | vino_capture_stop(vcs); | ||
3405 | vcs->streaming = 0; | 3821 | vcs->streaming = 0; |
3822 | vino_capture_stop(vcs); | ||
3406 | 3823 | ||
3407 | return 0; | 3824 | return 0; |
3408 | } | 3825 | } |
@@ -3410,10 +3827,11 @@ static int vino_v4l2_streamoff(struct vino_channel_settings *vcs) | |||
3410 | static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs, | 3827 | static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs, |
3411 | struct v4l2_queryctrl *queryctrl) | 3828 | struct v4l2_queryctrl *queryctrl) |
3412 | { | 3829 | { |
3830 | unsigned long flags; | ||
3413 | int i; | 3831 | int i; |
3414 | int err = 0; | 3832 | int err = 0; |
3415 | 3833 | ||
3416 | spin_lock(&vino_drvdata->input_lock); | 3834 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3417 | 3835 | ||
3418 | switch (vcs->input) { | 3836 | switch (vcs->input) { |
3419 | case VINO_INPUT_D1: | 3837 | case VINO_INPUT_D1: |
@@ -3423,6 +3841,7 @@ static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs, | |||
3423 | memcpy(queryctrl, | 3841 | memcpy(queryctrl, |
3424 | &vino_indycam_v4l2_controls[i], | 3842 | &vino_indycam_v4l2_controls[i], |
3425 | sizeof(struct v4l2_queryctrl)); | 3843 | sizeof(struct v4l2_queryctrl)); |
3844 | queryctrl->reserved[0] = 0; | ||
3426 | goto found; | 3845 | goto found; |
3427 | } | 3846 | } |
3428 | } | 3847 | } |
@@ -3437,6 +3856,7 @@ static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs, | |||
3437 | memcpy(queryctrl, | 3856 | memcpy(queryctrl, |
3438 | &vino_saa7191_v4l2_controls[i], | 3857 | &vino_saa7191_v4l2_controls[i], |
3439 | sizeof(struct v4l2_queryctrl)); | 3858 | sizeof(struct v4l2_queryctrl)); |
3859 | queryctrl->reserved[0] = 0; | ||
3440 | goto found; | 3860 | goto found; |
3441 | } | 3861 | } |
3442 | } | 3862 | } |
@@ -3448,7 +3868,7 @@ static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs, | |||
3448 | } | 3868 | } |
3449 | 3869 | ||
3450 | found: | 3870 | found: |
3451 | spin_unlock(&vino_drvdata->input_lock); | 3871 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
3452 | 3872 | ||
3453 | return err; | 3873 | return err; |
3454 | } | 3874 | } |
@@ -3456,70 +3876,72 @@ static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs, | |||
3456 | static int vino_v4l2_g_ctrl(struct vino_channel_settings *vcs, | 3876 | static int vino_v4l2_g_ctrl(struct vino_channel_settings *vcs, |
3457 | struct v4l2_control *control) | 3877 | struct v4l2_control *control) |
3458 | { | 3878 | { |
3459 | struct indycam_control indycam_ctrl; | 3879 | unsigned long flags; |
3460 | struct saa7191_control saa7191_ctrl; | 3880 | int i; |
3461 | int err = 0; | 3881 | int err = 0; |
3462 | 3882 | ||
3463 | spin_lock(&vino_drvdata->input_lock); | 3883 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3464 | 3884 | ||
3465 | switch (vcs->input) { | 3885 | switch (vcs->input) { |
3466 | case VINO_INPUT_D1: | 3886 | case VINO_INPUT_D1: { |
3467 | i2c_camera_command(DECODER_INDYCAM_GET_CONTROLS, | 3887 | struct indycam_control indycam_ctrl; |
3468 | &indycam_ctrl); | ||
3469 | 3888 | ||
3470 | switch(control->id) { | 3889 | for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) { |
3471 | case V4L2_CID_AUTOGAIN: | 3890 | if (vino_indycam_v4l2_controls[i].id == |
3472 | control->value = indycam_ctrl.agc; | 3891 | control->id) { |
3473 | break; | 3892 | goto found1; |
3474 | case V4L2_CID_AUTO_WHITE_BALANCE: | 3893 | } |
3475 | control->value = indycam_ctrl.awb; | 3894 | } |
3476 | break; | 3895 | |
3477 | case V4L2_CID_GAIN: | 3896 | err = -EINVAL; |
3478 | control->value = indycam_ctrl.gain; | 3897 | goto out; |
3479 | break; | 3898 | |
3480 | case V4L2_CID_PRIVATE_BASE: | 3899 | found1: |
3481 | control->value = indycam_ctrl.red_saturation; | 3900 | indycam_ctrl.type = vino_indycam_v4l2_controls[i].reserved[0]; |
3482 | break; | 3901 | |
3483 | case V4L2_CID_PRIVATE_BASE + 1: | 3902 | err = i2c_camera_command(DECODER_INDYCAM_GET_CONTROL, |
3484 | control->value = indycam_ctrl.blue_saturation; | 3903 | &indycam_ctrl); |
3485 | break; | 3904 | if (err) { |
3486 | case V4L2_CID_RED_BALANCE: | ||
3487 | control->value = indycam_ctrl.red_balance; | ||
3488 | break; | ||
3489 | case V4L2_CID_BLUE_BALANCE: | ||
3490 | control->value = indycam_ctrl.blue_balance; | ||
3491 | break; | ||
3492 | case V4L2_CID_EXPOSURE: | ||
3493 | control->value = indycam_ctrl.shutter; | ||
3494 | break; | ||
3495 | case V4L2_CID_GAMMA: | ||
3496 | control->value = indycam_ctrl.gamma; | ||
3497 | break; | ||
3498 | default: | ||
3499 | err = -EINVAL; | 3905 | err = -EINVAL; |
3906 | goto out; | ||
3500 | } | 3907 | } |
3908 | |||
3909 | control->value = indycam_ctrl.value; | ||
3501 | break; | 3910 | break; |
3911 | } | ||
3502 | case VINO_INPUT_COMPOSITE: | 3912 | case VINO_INPUT_COMPOSITE: |
3503 | case VINO_INPUT_SVIDEO: | 3913 | case VINO_INPUT_SVIDEO: { |
3504 | i2c_decoder_command(DECODER_SAA7191_GET_CONTROLS, | 3914 | struct saa7191_control saa7191_ctrl; |
3505 | &saa7191_ctrl); | ||
3506 | 3915 | ||
3507 | switch(control->id) { | 3916 | for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) { |
3508 | case V4L2_CID_HUE: | 3917 | if (vino_saa7191_v4l2_controls[i].id == |
3509 | control->value = saa7191_ctrl.hue; | 3918 | control->id) { |
3510 | break; | 3919 | goto found2; |
3511 | case V4L2_CID_PRIVATE_BASE: | 3920 | } |
3512 | control->value = saa7191_ctrl.vtrc; | 3921 | } |
3513 | break; | 3922 | |
3514 | default: | 3923 | err = -EINVAL; |
3924 | goto out; | ||
3925 | |||
3926 | found2: | ||
3927 | saa7191_ctrl.type = vino_saa7191_v4l2_controls[i].reserved[0]; | ||
3928 | |||
3929 | err = i2c_decoder_command(DECODER_SAA7191_GET_CONTROL, | ||
3930 | &saa7191_ctrl); | ||
3931 | if (err) { | ||
3515 | err = -EINVAL; | 3932 | err = -EINVAL; |
3933 | goto out; | ||
3516 | } | 3934 | } |
3935 | |||
3936 | control->value = saa7191_ctrl.value; | ||
3517 | break; | 3937 | break; |
3938 | } | ||
3518 | default: | 3939 | default: |
3519 | err = -EINVAL; | 3940 | err = -EINVAL; |
3520 | } | 3941 | } |
3521 | 3942 | ||
3522 | spin_unlock(&vino_drvdata->input_lock); | 3943 | out: |
3944 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); | ||
3523 | 3945 | ||
3524 | return err; | 3946 | return err; |
3525 | } | 3947 | } |
@@ -3527,15 +3949,21 @@ static int vino_v4l2_g_ctrl(struct vino_channel_settings *vcs, | |||
3527 | static int vino_v4l2_s_ctrl(struct vino_channel_settings *vcs, | 3949 | static int vino_v4l2_s_ctrl(struct vino_channel_settings *vcs, |
3528 | struct v4l2_control *control) | 3950 | struct v4l2_control *control) |
3529 | { | 3951 | { |
3530 | struct indycam_control indycam_ctrl; | 3952 | unsigned long flags; |
3531 | struct saa7191_control saa7191_ctrl; | ||
3532 | int i; | 3953 | int i; |
3533 | int err = 0; | 3954 | int err = 0; |
3534 | 3955 | ||
3535 | spin_lock(&vino_drvdata->input_lock); | 3956 | spin_lock_irqsave(&vino_drvdata->input_lock, flags); |
3957 | |||
3958 | if (!vino_is_input_owner(vcs)) { | ||
3959 | err = -EBUSY; | ||
3960 | goto out; | ||
3961 | } | ||
3536 | 3962 | ||
3537 | switch (vcs->input) { | 3963 | switch (vcs->input) { |
3538 | case VINO_INPUT_D1: | 3964 | case VINO_INPUT_D1: { |
3965 | struct indycam_control indycam_ctrl; | ||
3966 | |||
3539 | for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) { | 3967 | for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) { |
3540 | if (vino_indycam_v4l2_controls[i].id == | 3968 | if (vino_indycam_v4l2_controls[i].id == |
3541 | control->id) { | 3969 | control->id) { |
@@ -3544,65 +3972,31 @@ static int vino_v4l2_s_ctrl(struct vino_channel_settings *vcs, | |||
3544 | && (control->value <= | 3972 | && (control->value <= |
3545 | vino_indycam_v4l2_controls[i]. | 3973 | vino_indycam_v4l2_controls[i]. |
3546 | maximum)) { | 3974 | maximum)) { |
3547 | goto ok1; | 3975 | goto found1; |
3548 | } else { | 3976 | } else { |
3549 | err = -ERANGE; | 3977 | err = -ERANGE; |
3550 | goto error; | 3978 | goto out; |
3551 | } | 3979 | } |
3552 | } | 3980 | } |
3553 | } | 3981 | } |
3982 | |||
3554 | err = -EINVAL; | 3983 | err = -EINVAL; |
3555 | goto error; | 3984 | goto out; |
3556 | 3985 | ||
3557 | ok1: | 3986 | found1: |
3558 | indycam_ctrl.agc = INDYCAM_VALUE_UNCHANGED; | 3987 | indycam_ctrl.type = vino_indycam_v4l2_controls[i].reserved[0]; |
3559 | indycam_ctrl.awb = INDYCAM_VALUE_UNCHANGED; | 3988 | indycam_ctrl.value = control->value; |
3560 | indycam_ctrl.shutter = INDYCAM_VALUE_UNCHANGED; | ||
3561 | indycam_ctrl.gain = INDYCAM_VALUE_UNCHANGED; | ||
3562 | indycam_ctrl.red_balance = INDYCAM_VALUE_UNCHANGED; | ||
3563 | indycam_ctrl.blue_balance = INDYCAM_VALUE_UNCHANGED; | ||
3564 | indycam_ctrl.red_saturation = INDYCAM_VALUE_UNCHANGED; | ||
3565 | indycam_ctrl.blue_saturation = INDYCAM_VALUE_UNCHANGED; | ||
3566 | indycam_ctrl.gamma = INDYCAM_VALUE_UNCHANGED; | ||
3567 | |||
3568 | switch(control->id) { | ||
3569 | case V4L2_CID_AUTOGAIN: | ||
3570 | indycam_ctrl.agc = control->value; | ||
3571 | break; | ||
3572 | case V4L2_CID_AUTO_WHITE_BALANCE: | ||
3573 | indycam_ctrl.awb = control->value; | ||
3574 | break; | ||
3575 | case V4L2_CID_GAIN: | ||
3576 | indycam_ctrl.gain = control->value; | ||
3577 | break; | ||
3578 | case V4L2_CID_PRIVATE_BASE: | ||
3579 | indycam_ctrl.red_saturation = control->value; | ||
3580 | break; | ||
3581 | case V4L2_CID_PRIVATE_BASE + 1: | ||
3582 | indycam_ctrl.blue_saturation = control->value; | ||
3583 | break; | ||
3584 | case V4L2_CID_RED_BALANCE: | ||
3585 | indycam_ctrl.red_balance = control->value; | ||
3586 | break; | ||
3587 | case V4L2_CID_BLUE_BALANCE: | ||
3588 | indycam_ctrl.blue_balance = control->value; | ||
3589 | break; | ||
3590 | case V4L2_CID_EXPOSURE: | ||
3591 | indycam_ctrl.shutter = control->value; | ||
3592 | break; | ||
3593 | case V4L2_CID_GAMMA: | ||
3594 | indycam_ctrl.gamma = control->value; | ||
3595 | break; | ||
3596 | default: | ||
3597 | err = -EINVAL; | ||
3598 | } | ||
3599 | 3989 | ||
3600 | if (!err) | 3990 | err = i2c_camera_command(DECODER_INDYCAM_SET_CONTROL, |
3601 | i2c_camera_command(DECODER_INDYCAM_SET_CONTROLS, | 3991 | &indycam_ctrl); |
3602 | &indycam_ctrl); | 3992 | if (err) |
3993 | err = -EINVAL; | ||
3603 | break; | 3994 | break; |
3995 | } | ||
3604 | case VINO_INPUT_COMPOSITE: | 3996 | case VINO_INPUT_COMPOSITE: |
3605 | case VINO_INPUT_SVIDEO: | 3997 | case VINO_INPUT_SVIDEO: { |
3998 | struct saa7191_control saa7191_ctrl; | ||
3999 | |||
3606 | for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) { | 4000 | for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) { |
3607 | if (vino_saa7191_v4l2_controls[i].id == | 4001 | if (vino_saa7191_v4l2_controls[i].id == |
3608 | control->id) { | 4002 | control->id) { |
@@ -3611,41 +4005,32 @@ ok1: | |||
3611 | && (control->value <= | 4005 | && (control->value <= |
3612 | vino_saa7191_v4l2_controls[i]. | 4006 | vino_saa7191_v4l2_controls[i]. |
3613 | maximum)) { | 4007 | maximum)) { |
3614 | goto ok2; | 4008 | goto found2; |
3615 | } else { | 4009 | } else { |
3616 | err = -ERANGE; | 4010 | err = -ERANGE; |
3617 | goto error; | 4011 | goto out; |
3618 | } | 4012 | } |
3619 | } | 4013 | } |
3620 | } | 4014 | } |
3621 | err = -EINVAL; | 4015 | err = -EINVAL; |
3622 | goto error; | 4016 | goto out; |
3623 | |||
3624 | ok2: | ||
3625 | saa7191_ctrl.hue = SAA7191_VALUE_UNCHANGED; | ||
3626 | saa7191_ctrl.vtrc = SAA7191_VALUE_UNCHANGED; | ||
3627 | 4017 | ||
3628 | switch(control->id) { | 4018 | found2: |
3629 | case V4L2_CID_HUE: | 4019 | saa7191_ctrl.type = vino_saa7191_v4l2_controls[i].reserved[0]; |
3630 | saa7191_ctrl.hue = control->value; | 4020 | saa7191_ctrl.value = control->value; |
3631 | break; | ||
3632 | case V4L2_CID_PRIVATE_BASE: | ||
3633 | saa7191_ctrl.vtrc = control->value; | ||
3634 | break; | ||
3635 | default: | ||
3636 | err = -EINVAL; | ||
3637 | } | ||
3638 | 4021 | ||
3639 | if (!err) | 4022 | err = i2c_decoder_command(DECODER_SAA7191_SET_CONTROL, |
3640 | i2c_decoder_command(DECODER_SAA7191_SET_CONTROLS, | 4023 | &saa7191_ctrl); |
3641 | &saa7191_ctrl); | 4024 | if (err) |
4025 | err = -EINVAL; | ||
3642 | break; | 4026 | break; |
4027 | } | ||
3643 | default: | 4028 | default: |
3644 | err = -EINVAL; | 4029 | err = -EINVAL; |
3645 | } | 4030 | } |
3646 | 4031 | ||
3647 | error: | 4032 | out: |
3648 | spin_unlock(&vino_drvdata->input_lock); | 4033 | spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); |
3649 | 4034 | ||
3650 | return err; | 4035 | return err; |
3651 | } | 4036 | } |
@@ -3865,9 +4250,9 @@ static unsigned int vino_poll(struct file *file, poll_table *pt) | |||
3865 | over: | 4250 | over: |
3866 | dprintk("poll(): data %savailable\n", | 4251 | dprintk("poll(): data %savailable\n", |
3867 | (outgoing > 0) ? "" : "not "); | 4252 | (outgoing > 0) ? "" : "not "); |
3868 | if (outgoing > 0) { | 4253 | |
4254 | if (outgoing > 0) | ||
3869 | ret = POLLIN | POLLRDNORM; | 4255 | ret = POLLIN | POLLRDNORM; |
3870 | } | ||
3871 | 4256 | ||
3872 | error: | 4257 | error: |
3873 | 4258 | ||
@@ -3880,6 +4265,7 @@ static int vino_do_ioctl(struct inode *inode, struct file *file, | |||
3880 | struct video_device *dev = video_devdata(file); | 4265 | struct video_device *dev = video_devdata(file); |
3881 | struct vino_channel_settings *vcs = video_get_drvdata(dev); | 4266 | struct vino_channel_settings *vcs = video_get_drvdata(dev); |
3882 | 4267 | ||
4268 | #ifdef VINO_DEBUG | ||
3883 | switch (_IOC_TYPE(cmd)) { | 4269 | switch (_IOC_TYPE(cmd)) { |
3884 | case 'v': | 4270 | case 'v': |
3885 | dprintk("ioctl(): V4L1 unsupported (0x%08x)\n", cmd); | 4271 | dprintk("ioctl(): V4L1 unsupported (0x%08x)\n", cmd); |
@@ -3891,9 +4277,9 @@ static int vino_do_ioctl(struct inode *inode, struct file *file, | |||
3891 | default: | 4277 | default: |
3892 | dprintk("ioctl(): unsupported command 0x%08x\n", cmd); | 4278 | dprintk("ioctl(): unsupported command 0x%08x\n", cmd); |
3893 | } | 4279 | } |
4280 | #endif | ||
3894 | 4281 | ||
3895 | switch (cmd) { | 4282 | switch (cmd) { |
3896 | /* TODO: V4L1 interface (use compatibility layer?) */ | ||
3897 | /* V4L2 interface */ | 4283 | /* V4L2 interface */ |
3898 | case VIDIOC_QUERYCAP: { | 4284 | case VIDIOC_QUERYCAP: { |
3899 | vino_v4l2_querycap(arg); | 4285 | vino_v4l2_querycap(arg); |
@@ -3911,6 +4297,9 @@ static int vino_do_ioctl(struct inode *inode, struct file *file, | |||
3911 | case VIDIOC_ENUMSTD: { | 4297 | case VIDIOC_ENUMSTD: { |
3912 | return vino_v4l2_enumstd(vcs, arg); | 4298 | return vino_v4l2_enumstd(vcs, arg); |
3913 | } | 4299 | } |
4300 | case VIDIOC_QUERYSTD: { | ||
4301 | return vino_v4l2_querystd(vcs, arg); | ||
4302 | } | ||
3914 | case VIDIOC_G_STD: { | 4303 | case VIDIOC_G_STD: { |
3915 | return vino_v4l2_g_std(vcs, arg); | 4304 | return vino_v4l2_g_std(vcs, arg); |
3916 | } | 4305 | } |
@@ -4100,8 +4489,7 @@ static int vino_probe(void) | |||
4100 | return -ENODEV; | 4489 | return -ENODEV; |
4101 | } | 4490 | } |
4102 | 4491 | ||
4103 | printk(KERN_INFO "VINO with chip ID %ld, revision %ld found\n", | 4492 | printk(KERN_INFO "VINO revision %ld found\n", VINO_REV_NUM(rev_id)); |
4104 | VINO_ID_VALUE(rev_id), VINO_REV_NUM(rev_id)); | ||
4105 | 4493 | ||
4106 | return 0; | 4494 | return 0; |
4107 | } | 4495 | } |