aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/vino.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-02-27 07:05:10 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:10 -0400
commitcf4e9484f402c799fa25c9ffb7e9a3b620a3702d (patch)
tree5f7839009c8a66f4c1b5eaaf2c3c7365b515564d /drivers/media/video/vino.c
parentbabb7dc7776dd6ded4e1e6cb7acc34c25c0eb521 (diff)
V4L/DVB (10861): vino/indycam/saa7191: convert to i2c modules to V4L2.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/vino.c')
-rw-r--r--drivers/media/video/vino.c396
1 files changed, 113 insertions, 283 deletions
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index f9ca27a9524e..0a5cd567bfb1 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -38,7 +38,6 @@
38#include <linux/videodev2.h> 38#include <linux/videodev2.h>
39#include <media/v4l2-common.h> 39#include <media/v4l2-common.h>
40#include <media/v4l2-ioctl.h> 40#include <media/v4l2-ioctl.h>
41#include <linux/video_decoder.h>
42#include <linux/mutex.h> 41#include <linux/mutex.h>
43 42
44#include <asm/paccess.h> 43#include <asm/paccess.h>
@@ -139,10 +138,6 @@ MODULE_LICENSE("GPL");
139#define VINO_DATA_NORM_PAL 1 138#define VINO_DATA_NORM_PAL 1
140#define VINO_DATA_NORM_SECAM 2 139#define VINO_DATA_NORM_SECAM 2
141#define VINO_DATA_NORM_D1 3 140#define VINO_DATA_NORM_D1 3
142/* The following are special entries that can be used to
143 * autodetect the norm. */
144#define VINO_DATA_NORM_AUTO 0xfe
145#define VINO_DATA_NORM_AUTO_EXT 0xff
146 141
147#define VINO_DATA_NORM_COUNT 4 142#define VINO_DATA_NORM_COUNT 4
148 143
@@ -360,11 +355,11 @@ static const struct vino_input vino_inputs[] = {
360 .name = "Composite", 355 .name = "Composite",
361 .std = V4L2_STD_NTSC | V4L2_STD_PAL 356 .std = V4L2_STD_NTSC | V4L2_STD_PAL
362 | V4L2_STD_SECAM, 357 | V4L2_STD_SECAM,
363 },{ 358 }, {
364 .name = "S-Video", 359 .name = "S-Video",
365 .std = V4L2_STD_NTSC | V4L2_STD_PAL 360 .std = V4L2_STD_NTSC | V4L2_STD_PAL
366 | V4L2_STD_SECAM, 361 | V4L2_STD_SECAM,
367 },{ 362 }, {
368 .name = "D1/IndyCam", 363 .name = "D1/IndyCam",
369 .std = V4L2_STD_NTSC, 364 .std = V4L2_STD_NTSC,
370 } 365 }
@@ -376,17 +371,17 @@ static const struct vino_data_format vino_data_formats[] = {
376 .bpp = 1, 371 .bpp = 1,
377 .pixelformat = V4L2_PIX_FMT_GREY, 372 .pixelformat = V4L2_PIX_FMT_GREY,
378 .colorspace = V4L2_COLORSPACE_SMPTE170M, 373 .colorspace = V4L2_COLORSPACE_SMPTE170M,
379 },{ 374 }, {
380 .description = "8-bit dithered RGB 3-3-2", 375 .description = "8-bit dithered RGB 3-3-2",
381 .bpp = 1, 376 .bpp = 1,
382 .pixelformat = V4L2_PIX_FMT_RGB332, 377 .pixelformat = V4L2_PIX_FMT_RGB332,
383 .colorspace = V4L2_COLORSPACE_SRGB, 378 .colorspace = V4L2_COLORSPACE_SRGB,
384 },{ 379 }, {
385 .description = "32-bit RGB", 380 .description = "32-bit RGB",
386 .bpp = 4, 381 .bpp = 4,
387 .pixelformat = V4L2_PIX_FMT_RGB32, 382 .pixelformat = V4L2_PIX_FMT_RGB32,
388 .colorspace = V4L2_COLORSPACE_SRGB, 383 .colorspace = V4L2_COLORSPACE_SRGB,
389 },{ 384 }, {
390 .description = "YUV 4:2:2", 385 .description = "YUV 4:2:2",
391 .bpp = 2, 386 .bpp = 2,
392 .pixelformat = V4L2_PIX_FMT_YUYV, // XXX: swapped? 387 .pixelformat = V4L2_PIX_FMT_YUYV, // XXX: swapped?
@@ -417,7 +412,7 @@ static const struct vino_data_norm vino_data_norms[] = {
417 + VINO_NTSC_HEIGHT / 2 - 1, 412 + VINO_NTSC_HEIGHT / 2 - 1,
418 .right = VINO_NTSC_WIDTH, 413 .right = VINO_NTSC_WIDTH,
419 }, 414 },
420 },{ 415 }, {
421 .description = "PAL", 416 .description = "PAL",
422 .std = V4L2_STD_PAL, 417 .std = V4L2_STD_PAL,
423 .fps_min = 5, 418 .fps_min = 5,
@@ -439,7 +434,7 @@ static const struct vino_data_norm vino_data_norms[] = {
439 + VINO_PAL_HEIGHT / 2 - 1, 434 + VINO_PAL_HEIGHT / 2 - 1,
440 .right = VINO_PAL_WIDTH, 435 .right = VINO_PAL_WIDTH,
441 }, 436 },
442 },{ 437 }, {
443 .description = "SECAM", 438 .description = "SECAM",
444 .std = V4L2_STD_SECAM, 439 .std = V4L2_STD_SECAM,
445 .fps_min = 5, 440 .fps_min = 5,
@@ -461,7 +456,7 @@ static const struct vino_data_norm vino_data_norms[] = {
461 + VINO_PAL_HEIGHT / 2 - 1, 456 + VINO_PAL_HEIGHT / 2 - 1,
462 .right = VINO_PAL_WIDTH, 457 .right = VINO_PAL_WIDTH,
463 }, 458 },
464 },{ 459 }, {
465 .description = "NTSC/D1", 460 .description = "NTSC/D1",
466 .std = V4L2_STD_NTSC, 461 .std = V4L2_STD_NTSC,
467 .fps_min = 6, 462 .fps_min = 6,
@@ -497,9 +492,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
497 .maximum = 1, 492 .maximum = 1,
498 .step = 1, 493 .step = 1,
499 .default_value = INDYCAM_AGC_DEFAULT, 494 .default_value = INDYCAM_AGC_DEFAULT,
500 .flags = 0, 495 }, {
501 .reserved = { INDYCAM_CONTROL_AGC, 0 },
502 },{
503 .id = V4L2_CID_AUTO_WHITE_BALANCE, 496 .id = V4L2_CID_AUTO_WHITE_BALANCE,
504 .type = V4L2_CTRL_TYPE_BOOLEAN, 497 .type = V4L2_CTRL_TYPE_BOOLEAN,
505 .name = "Automatic White Balance", 498 .name = "Automatic White Balance",
@@ -507,9 +500,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
507 .maximum = 1, 500 .maximum = 1,
508 .step = 1, 501 .step = 1,
509 .default_value = INDYCAM_AWB_DEFAULT, 502 .default_value = INDYCAM_AWB_DEFAULT,
510 .flags = 0, 503 }, {
511 .reserved = { INDYCAM_CONTROL_AWB, 0 },
512 },{
513 .id = V4L2_CID_GAIN, 504 .id = V4L2_CID_GAIN,
514 .type = V4L2_CTRL_TYPE_INTEGER, 505 .type = V4L2_CTRL_TYPE_INTEGER,
515 .name = "Gain", 506 .name = "Gain",
@@ -517,29 +508,23 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
517 .maximum = INDYCAM_GAIN_MAX, 508 .maximum = INDYCAM_GAIN_MAX,
518 .step = 1, 509 .step = 1,
519 .default_value = INDYCAM_GAIN_DEFAULT, 510 .default_value = INDYCAM_GAIN_DEFAULT,
520 .flags = 0, 511 }, {
521 .reserved = { INDYCAM_CONTROL_GAIN, 0 }, 512 .id = INDYCAM_CONTROL_RED_SATURATION,
522 },{
523 .id = V4L2_CID_PRIVATE_BASE,
524 .type = V4L2_CTRL_TYPE_INTEGER, 513 .type = V4L2_CTRL_TYPE_INTEGER,
525 .name = "Red Saturation", 514 .name = "Red Saturation",
526 .minimum = INDYCAM_RED_SATURATION_MIN, 515 .minimum = INDYCAM_RED_SATURATION_MIN,
527 .maximum = INDYCAM_RED_SATURATION_MAX, 516 .maximum = INDYCAM_RED_SATURATION_MAX,
528 .step = 1, 517 .step = 1,
529 .default_value = INDYCAM_RED_SATURATION_DEFAULT, 518 .default_value = INDYCAM_RED_SATURATION_DEFAULT,
530 .flags = 0, 519 }, {
531 .reserved = { INDYCAM_CONTROL_RED_SATURATION, 0 }, 520 .id = INDYCAM_CONTROL_BLUE_SATURATION,
532 },{
533 .id = V4L2_CID_PRIVATE_BASE + 1,
534 .type = V4L2_CTRL_TYPE_INTEGER, 521 .type = V4L2_CTRL_TYPE_INTEGER,
535 .name = "Blue Saturation", 522 .name = "Blue Saturation",
536 .minimum = INDYCAM_BLUE_SATURATION_MIN, 523 .minimum = INDYCAM_BLUE_SATURATION_MIN,
537 .maximum = INDYCAM_BLUE_SATURATION_MAX, 524 .maximum = INDYCAM_BLUE_SATURATION_MAX,
538 .step = 1, 525 .step = 1,
539 .default_value = INDYCAM_BLUE_SATURATION_DEFAULT, 526 .default_value = INDYCAM_BLUE_SATURATION_DEFAULT,
540 .flags = 0, 527 }, {
541 .reserved = { INDYCAM_CONTROL_BLUE_SATURATION, 0 },
542 },{
543 .id = V4L2_CID_RED_BALANCE, 528 .id = V4L2_CID_RED_BALANCE,
544 .type = V4L2_CTRL_TYPE_INTEGER, 529 .type = V4L2_CTRL_TYPE_INTEGER,
545 .name = "Red Balance", 530 .name = "Red Balance",
@@ -547,9 +532,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
547 .maximum = INDYCAM_RED_BALANCE_MAX, 532 .maximum = INDYCAM_RED_BALANCE_MAX,
548 .step = 1, 533 .step = 1,
549 .default_value = INDYCAM_RED_BALANCE_DEFAULT, 534 .default_value = INDYCAM_RED_BALANCE_DEFAULT,
550 .flags = 0, 535 }, {
551 .reserved = { INDYCAM_CONTROL_RED_BALANCE, 0 },
552 },{
553 .id = V4L2_CID_BLUE_BALANCE, 536 .id = V4L2_CID_BLUE_BALANCE,
554 .type = V4L2_CTRL_TYPE_INTEGER, 537 .type = V4L2_CTRL_TYPE_INTEGER,
555 .name = "Blue Balance", 538 .name = "Blue Balance",
@@ -557,9 +540,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
557 .maximum = INDYCAM_BLUE_BALANCE_MAX, 540 .maximum = INDYCAM_BLUE_BALANCE_MAX,
558 .step = 1, 541 .step = 1,
559 .default_value = INDYCAM_BLUE_BALANCE_DEFAULT, 542 .default_value = INDYCAM_BLUE_BALANCE_DEFAULT,
560 .flags = 0, 543 }, {
561 .reserved = { INDYCAM_CONTROL_BLUE_BALANCE, 0 },
562 },{
563 .id = V4L2_CID_EXPOSURE, 544 .id = V4L2_CID_EXPOSURE,
564 .type = V4L2_CTRL_TYPE_INTEGER, 545 .type = V4L2_CTRL_TYPE_INTEGER,
565 .name = "Shutter Control", 546 .name = "Shutter Control",
@@ -567,9 +548,7 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
567 .maximum = INDYCAM_SHUTTER_MAX, 548 .maximum = INDYCAM_SHUTTER_MAX,
568 .step = 1, 549 .step = 1,
569 .default_value = INDYCAM_SHUTTER_DEFAULT, 550 .default_value = INDYCAM_SHUTTER_DEFAULT,
570 .flags = 0, 551 }, {
571 .reserved = { INDYCAM_CONTROL_SHUTTER, 0 },
572 },{
573 .id = V4L2_CID_GAMMA, 552 .id = V4L2_CID_GAMMA,
574 .type = V4L2_CTRL_TYPE_INTEGER, 553 .type = V4L2_CTRL_TYPE_INTEGER,
575 .name = "Gamma", 554 .name = "Gamma",
@@ -577,8 +556,6 @@ struct v4l2_queryctrl vino_indycam_v4l2_controls[] = {
577 .maximum = INDYCAM_GAMMA_MAX, 556 .maximum = INDYCAM_GAMMA_MAX,
578 .step = 1, 557 .step = 1,
579 .default_value = INDYCAM_GAMMA_DEFAULT, 558 .default_value = INDYCAM_GAMMA_DEFAULT,
580 .flags = 0,
581 .reserved = { INDYCAM_CONTROL_GAMMA, 0 },
582 } 559 }
583}; 560};
584 561
@@ -593,88 +570,70 @@ struct v4l2_queryctrl vino_saa7191_v4l2_controls[] = {
593 .maximum = SAA7191_HUE_MAX, 570 .maximum = SAA7191_HUE_MAX,
594 .step = 1, 571 .step = 1,
595 .default_value = SAA7191_HUE_DEFAULT, 572 .default_value = SAA7191_HUE_DEFAULT,
596 .flags = 0, 573 }, {
597 .reserved = { SAA7191_CONTROL_HUE, 0 }, 574 .id = SAA7191_CONTROL_BANDPASS,
598 },{
599 .id = V4L2_CID_PRIVATE_BASE,
600 .type = V4L2_CTRL_TYPE_INTEGER, 575 .type = V4L2_CTRL_TYPE_INTEGER,
601 .name = "Luminance Bandpass", 576 .name = "Luminance Bandpass",
602 .minimum = SAA7191_BANDPASS_MIN, 577 .minimum = SAA7191_BANDPASS_MIN,
603 .maximum = SAA7191_BANDPASS_MAX, 578 .maximum = SAA7191_BANDPASS_MAX,
604 .step = 1, 579 .step = 1,
605 .default_value = SAA7191_BANDPASS_DEFAULT, 580 .default_value = SAA7191_BANDPASS_DEFAULT,
606 .flags = 0, 581 }, {
607 .reserved = { SAA7191_CONTROL_BANDPASS, 0 }, 582 .id = SAA7191_CONTROL_BANDPASS_WEIGHT,
608 },{
609 .id = V4L2_CID_PRIVATE_BASE + 1,
610 .type = V4L2_CTRL_TYPE_INTEGER, 583 .type = V4L2_CTRL_TYPE_INTEGER,
611 .name = "Luminance Bandpass Weight", 584 .name = "Luminance Bandpass Weight",
612 .minimum = SAA7191_BANDPASS_WEIGHT_MIN, 585 .minimum = SAA7191_BANDPASS_WEIGHT_MIN,
613 .maximum = SAA7191_BANDPASS_WEIGHT_MAX, 586 .maximum = SAA7191_BANDPASS_WEIGHT_MAX,
614 .step = 1, 587 .step = 1,
615 .default_value = SAA7191_BANDPASS_WEIGHT_DEFAULT, 588 .default_value = SAA7191_BANDPASS_WEIGHT_DEFAULT,
616 .flags = 0, 589 }, {
617 .reserved = { SAA7191_CONTROL_BANDPASS_WEIGHT, 0 }, 590 .id = SAA7191_CONTROL_CORING,
618 },{
619 .id = V4L2_CID_PRIVATE_BASE + 2,
620 .type = V4L2_CTRL_TYPE_INTEGER, 591 .type = V4L2_CTRL_TYPE_INTEGER,
621 .name = "HF Luminance Coring", 592 .name = "HF Luminance Coring",
622 .minimum = SAA7191_CORING_MIN, 593 .minimum = SAA7191_CORING_MIN,
623 .maximum = SAA7191_CORING_MAX, 594 .maximum = SAA7191_CORING_MAX,
624 .step = 1, 595 .step = 1,
625 .default_value = SAA7191_CORING_DEFAULT, 596 .default_value = SAA7191_CORING_DEFAULT,
626 .flags = 0, 597 }, {
627 .reserved = { SAA7191_CONTROL_CORING, 0 }, 598 .id = SAA7191_CONTROL_FORCE_COLOUR,
628 },{
629 .id = V4L2_CID_PRIVATE_BASE + 3,
630 .type = V4L2_CTRL_TYPE_BOOLEAN, 599 .type = V4L2_CTRL_TYPE_BOOLEAN,
631 .name = "Force Colour", 600 .name = "Force Colour",
632 .minimum = SAA7191_FORCE_COLOUR_MIN, 601 .minimum = SAA7191_FORCE_COLOUR_MIN,
633 .maximum = SAA7191_FORCE_COLOUR_MAX, 602 .maximum = SAA7191_FORCE_COLOUR_MAX,
634 .step = 1, 603 .step = 1,
635 .default_value = SAA7191_FORCE_COLOUR_DEFAULT, 604 .default_value = SAA7191_FORCE_COLOUR_DEFAULT,
636 .flags = 0, 605 }, {
637 .reserved = { SAA7191_CONTROL_FORCE_COLOUR, 0 }, 606 .id = SAA7191_CONTROL_CHROMA_GAIN,
638 },{
639 .id = V4L2_CID_PRIVATE_BASE + 4,
640 .type = V4L2_CTRL_TYPE_INTEGER, 607 .type = V4L2_CTRL_TYPE_INTEGER,
641 .name = "Chrominance Gain Control", 608 .name = "Chrominance Gain Control",
642 .minimum = SAA7191_CHROMA_GAIN_MIN, 609 .minimum = SAA7191_CHROMA_GAIN_MIN,
643 .maximum = SAA7191_CHROMA_GAIN_MAX, 610 .maximum = SAA7191_CHROMA_GAIN_MAX,
644 .step = 1, 611 .step = 1,
645 .default_value = SAA7191_CHROMA_GAIN_DEFAULT, 612 .default_value = SAA7191_CHROMA_GAIN_DEFAULT,
646 .flags = 0, 613 }, {
647 .reserved = { SAA7191_CONTROL_CHROMA_GAIN, 0 }, 614 .id = SAA7191_CONTROL_VTRC,
648 },{
649 .id = V4L2_CID_PRIVATE_BASE + 5,
650 .type = V4L2_CTRL_TYPE_BOOLEAN, 615 .type = V4L2_CTRL_TYPE_BOOLEAN,
651 .name = "VTR Time Constant", 616 .name = "VTR Time Constant",
652 .minimum = SAA7191_VTRC_MIN, 617 .minimum = SAA7191_VTRC_MIN,
653 .maximum = SAA7191_VTRC_MAX, 618 .maximum = SAA7191_VTRC_MAX,
654 .step = 1, 619 .step = 1,
655 .default_value = SAA7191_VTRC_DEFAULT, 620 .default_value = SAA7191_VTRC_DEFAULT,
656 .flags = 0, 621 }, {
657 .reserved = { SAA7191_CONTROL_VTRC, 0 }, 622 .id = SAA7191_CONTROL_LUMA_DELAY,
658 },{
659 .id = V4L2_CID_PRIVATE_BASE + 6,
660 .type = V4L2_CTRL_TYPE_INTEGER, 623 .type = V4L2_CTRL_TYPE_INTEGER,
661 .name = "Luminance Delay Compensation", 624 .name = "Luminance Delay Compensation",
662 .minimum = SAA7191_LUMA_DELAY_MIN, 625 .minimum = SAA7191_LUMA_DELAY_MIN,
663 .maximum = SAA7191_LUMA_DELAY_MAX, 626 .maximum = SAA7191_LUMA_DELAY_MAX,
664 .step = 1, 627 .step = 1,
665 .default_value = SAA7191_LUMA_DELAY_DEFAULT, 628 .default_value = SAA7191_LUMA_DELAY_DEFAULT,
666 .flags = 0, 629 }, {
667 .reserved = { SAA7191_CONTROL_LUMA_DELAY, 0 }, 630 .id = SAA7191_CONTROL_VNR,
668 },{
669 .id = V4L2_CID_PRIVATE_BASE + 7,
670 .type = V4L2_CTRL_TYPE_INTEGER, 631 .type = V4L2_CTRL_TYPE_INTEGER,
671 .name = "Vertical Noise Reduction", 632 .name = "Vertical Noise Reduction",
672 .minimum = SAA7191_VNR_MIN, 633 .minimum = SAA7191_VNR_MIN,
673 .maximum = SAA7191_VNR_MAX, 634 .maximum = SAA7191_VNR_MAX,
674 .step = 1, 635 .step = 1,
675 .default_value = SAA7191_VNR_DEFAULT, 636 .default_value = SAA7191_VNR_DEFAULT,
676 .flags = 0,
677 .reserved = { SAA7191_CONTROL_VNR, 0 },
678 } 637 }
679}; 638};
680 639
@@ -2490,77 +2449,6 @@ static int vino_get_saa7191_input(int input)
2490 } 2449 }
2491} 2450}
2492 2451
2493static int vino_get_saa7191_norm(unsigned int data_norm)
2494{
2495 switch (data_norm) {
2496 case VINO_DATA_NORM_AUTO:
2497 return SAA7191_NORM_AUTO;
2498 case VINO_DATA_NORM_AUTO_EXT:
2499 return SAA7191_NORM_AUTO_EXT;
2500 case VINO_DATA_NORM_PAL:
2501 return SAA7191_NORM_PAL;
2502 case VINO_DATA_NORM_NTSC:
2503 return SAA7191_NORM_NTSC;
2504 case VINO_DATA_NORM_SECAM:
2505 return SAA7191_NORM_SECAM;
2506 default:
2507 printk(KERN_ERR "VINO: vino_get_saa7191_norm(): "
2508 "invalid norm!\n");
2509 return -1;
2510 }
2511}
2512
2513static int vino_get_from_saa7191_norm(int saa7191_norm)
2514{
2515 switch (saa7191_norm) {
2516 case SAA7191_NORM_PAL:
2517 return VINO_DATA_NORM_PAL;
2518 case SAA7191_NORM_NTSC:
2519 return VINO_DATA_NORM_NTSC;
2520 case SAA7191_NORM_SECAM:
2521 return VINO_DATA_NORM_SECAM;
2522 default:
2523 printk(KERN_ERR "VINO: vino_get_from_saa7191_norm(): "
2524 "invalid norm!\n");
2525 return VINO_DATA_NORM_NONE;
2526 }
2527}
2528
2529static int vino_saa7191_set_norm(unsigned int *data_norm)
2530{
2531 int saa7191_norm, new_data_norm;
2532 int err = 0;
2533
2534 saa7191_norm = vino_get_saa7191_norm(*data_norm);
2535
2536 err = i2c_decoder_command(DECODER_SAA7191_SET_NORM,
2537 &saa7191_norm);
2538 if (err)
2539 goto out;
2540
2541 if ((*data_norm == VINO_DATA_NORM_AUTO)
2542 || (*data_norm == VINO_DATA_NORM_AUTO_EXT)) {
2543 struct saa7191_status status;
2544
2545 err = i2c_decoder_command(DECODER_SAA7191_GET_STATUS,
2546 &status);
2547 if (err)
2548 goto out;
2549
2550 new_data_norm =
2551 vino_get_from_saa7191_norm(status.norm);
2552 if (new_data_norm == VINO_DATA_NORM_NONE) {
2553 err = -EINVAL;
2554 goto out;
2555 }
2556
2557 *data_norm = (unsigned int)new_data_norm;
2558 }
2559
2560out:
2561 return err;
2562}
2563
2564/* execute with input_lock locked */ 2452/* execute with input_lock locked */
2565static int vino_is_input_owner(struct vino_channel_settings *vcs) 2453static int vino_is_input_owner(struct vino_channel_settings *vcs)
2566{ 2454{
@@ -2593,15 +2481,16 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
2593 vcs->data_norm = VINO_DATA_NORM_D1; 2481 vcs->data_norm = VINO_DATA_NORM_D1;
2594 } else if (vino_drvdata->decoder.driver 2482 } else if (vino_drvdata->decoder.driver
2595 && (vino_drvdata->decoder.owner == VINO_NO_CHANNEL)) { 2483 && (vino_drvdata->decoder.owner == VINO_NO_CHANNEL)) {
2596 int input, data_norm; 2484 int input;
2597 int saa7191_input; 2485 int data_norm;
2486 v4l2_std_id norm;
2487 struct v4l2_routing route = { 0, 0 };
2598 2488
2599 i2c_use_client(vino_drvdata->decoder.driver); 2489 i2c_use_client(vino_drvdata->decoder.driver);
2600 input = VINO_INPUT_COMPOSITE; 2490 input = VINO_INPUT_COMPOSITE;
2601 2491
2602 saa7191_input = vino_get_saa7191_input(input); 2492 route.input = vino_get_saa7191_input(input);
2603 ret = i2c_decoder_command(DECODER_SET_INPUT, 2493 ret = i2c_decoder_command(VIDIOC_INT_S_VIDEO_ROUTING, &route);
2604 &saa7191_input);
2605 if (ret) { 2494 if (ret) {
2606 ret = -EINVAL; 2495 ret = -EINVAL;
2607 goto out; 2496 goto out;
@@ -2612,12 +2501,15 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
2612 /* Don't hold spinlocks while auto-detecting norm 2501 /* Don't hold spinlocks while auto-detecting norm
2613 * as it may take a while... */ 2502 * as it may take a while... */
2614 2503
2615 data_norm = VINO_DATA_NORM_AUTO_EXT; 2504 ret = i2c_decoder_command(VIDIOC_QUERYSTD, &norm);
2616 2505 if (!ret) {
2617 ret = vino_saa7191_set_norm(&data_norm); 2506 for (data_norm = 0; data_norm < 3; data_norm++) {
2618 if ((ret == -EBUSY) || (ret == -EAGAIN)) { 2507 if (vino_data_norms[data_norm].std & norm)
2619 data_norm = VINO_DATA_NORM_PAL; 2508 break;
2620 ret = vino_saa7191_set_norm(&data_norm); 2509 }
2510 if (data_norm == 3)
2511 data_norm = VINO_DATA_NORM_PAL;
2512 ret = i2c_decoder_command(VIDIOC_S_STD, &norm);
2621 } 2513 }
2622 2514
2623 spin_lock_irqsave(&vino_drvdata->input_lock, flags); 2515 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
@@ -2684,11 +2576,11 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
2684 2576
2685 if (vino_drvdata->decoder.owner == vcs->channel) { 2577 if (vino_drvdata->decoder.owner == vcs->channel) {
2686 int data_norm; 2578 int data_norm;
2687 int saa7191_input; 2579 v4l2_std_id norm;
2580 struct v4l2_routing route = { 0, 0 };
2688 2581
2689 saa7191_input = vino_get_saa7191_input(input); 2582 route.input = vino_get_saa7191_input(input);
2690 ret = i2c_decoder_command(DECODER_SET_INPUT, 2583 ret = i2c_decoder_command(VIDIOC_INT_S_VIDEO_ROUTING, &route);
2691 &saa7191_input);
2692 if (ret) { 2584 if (ret) {
2693 vino_drvdata->decoder.owner = VINO_NO_CHANNEL; 2585 vino_drvdata->decoder.owner = VINO_NO_CHANNEL;
2694 ret = -EINVAL; 2586 ret = -EINVAL;
@@ -2700,12 +2592,15 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
2700 /* Don't hold spinlocks while auto-detecting norm 2592 /* Don't hold spinlocks while auto-detecting norm
2701 * as it may take a while... */ 2593 * as it may take a while... */
2702 2594
2703 data_norm = VINO_DATA_NORM_AUTO_EXT; 2595 ret = i2c_decoder_command(VIDIOC_QUERYSTD, &norm);
2704 2596 if (!ret) {
2705 ret = vino_saa7191_set_norm(&data_norm); 2597 for (data_norm = 0; data_norm < 3; data_norm++) {
2706 if ((ret == -EBUSY) || (ret == -EAGAIN)) { 2598 if (vino_data_norms[data_norm].std & norm)
2707 data_norm = VINO_DATA_NORM_PAL; 2599 break;
2708 ret = vino_saa7191_set_norm(&data_norm); 2600 }
2601 if (data_norm == 3)
2602 data_norm = VINO_DATA_NORM_PAL;
2603 ret = i2c_decoder_command(VIDIOC_S_STD, &norm);
2709 } 2604 }
2710 2605
2711 spin_lock_irqsave(&vino_drvdata->input_lock, flags); 2606 spin_lock_irqsave(&vino_drvdata->input_lock, flags);
@@ -2733,8 +2628,7 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
2733 if (vcs2->input == VINO_INPUT_D1) { 2628 if (vcs2->input == VINO_INPUT_D1) {
2734 vino_drvdata->camera.owner = vcs2->channel; 2629 vino_drvdata->camera.owner = vcs2->channel;
2735 } else { 2630 } else {
2736 i2c_release_client(vino_drvdata-> 2631 i2c_release_client(vino_drvdata->camera.driver);
2737 camera.driver);
2738 vino_drvdata->camera.owner = VINO_NO_CHANNEL; 2632 vino_drvdata->camera.owner = VINO_NO_CHANNEL;
2739 } 2633 }
2740 } 2634 }
@@ -2829,18 +2723,16 @@ static int vino_set_data_norm(struct vino_channel_settings *vcs,
2829 switch (vcs->input) { 2723 switch (vcs->input) {
2830 case VINO_INPUT_D1: 2724 case VINO_INPUT_D1:
2831 /* only one "norm" supported */ 2725 /* only one "norm" supported */
2832 if ((data_norm != VINO_DATA_NORM_D1) 2726 if (data_norm != VINO_DATA_NORM_D1)
2833 && (data_norm != VINO_DATA_NORM_AUTO)
2834 && (data_norm != VINO_DATA_NORM_AUTO_EXT))
2835 return -EINVAL; 2727 return -EINVAL;
2836 break; 2728 break;
2837 case VINO_INPUT_COMPOSITE: 2729 case VINO_INPUT_COMPOSITE:
2838 case VINO_INPUT_SVIDEO: { 2730 case VINO_INPUT_SVIDEO: {
2731 v4l2_std_id norm;
2732
2839 if ((data_norm != VINO_DATA_NORM_PAL) 2733 if ((data_norm != VINO_DATA_NORM_PAL)
2840 && (data_norm != VINO_DATA_NORM_NTSC) 2734 && (data_norm != VINO_DATA_NORM_NTSC)
2841 && (data_norm != VINO_DATA_NORM_SECAM) 2735 && (data_norm != VINO_DATA_NORM_SECAM))
2842 && (data_norm != VINO_DATA_NORM_AUTO)
2843 && (data_norm != VINO_DATA_NORM_AUTO_EXT))
2844 return -EINVAL; 2736 return -EINVAL;
2845 2737
2846 spin_unlock_irqrestore(&vino_drvdata->input_lock, *flags); 2738 spin_unlock_irqrestore(&vino_drvdata->input_lock, *flags);
@@ -2848,7 +2740,8 @@ static int vino_set_data_norm(struct vino_channel_settings *vcs,
2848 /* Don't hold spinlocks while setting norm 2740 /* Don't hold spinlocks while setting norm
2849 * as it may take a while... */ 2741 * as it may take a while... */
2850 2742
2851 err = vino_saa7191_set_norm(&data_norm); 2743 norm = vino_data_norms[data_norm].std;
2744 err = i2c_decoder_command(VIDIOC_S_STD, &norm);
2852 2745
2853 spin_lock_irqsave(&vino_drvdata->input_lock, *flags); 2746 spin_lock_irqsave(&vino_drvdata->input_lock, *flags);
2854 2747
@@ -2998,14 +2891,8 @@ static int vino_enum_input(struct file *file, void *__fh,
2998 i->std = vino_inputs[input].std; 2891 i->std = vino_inputs[input].std;
2999 strcpy(i->name, vino_inputs[input].name); 2892 strcpy(i->name, vino_inputs[input].name);
3000 2893
3001 if ((input == VINO_INPUT_COMPOSITE) 2894 if (input == VINO_INPUT_COMPOSITE || input == VINO_INPUT_SVIDEO)
3002 || (input == VINO_INPUT_SVIDEO)) { 2895 i2c_decoder_command(VIDIOC_INT_G_INPUT_STATUS, &i->status);
3003 struct saa7191_status status;
3004 i2c_decoder_command(DECODER_SAA7191_GET_STATUS, &status);
3005 i->status |= status.signal ? 0 : V4L2_IN_ST_NO_SIGNAL;
3006 i->status |= status.color ? 0 : V4L2_IN_ST_NO_COLOR;
3007 }
3008
3009 return 0; 2896 return 0;
3010} 2897}
3011 2898
@@ -3062,19 +2949,7 @@ static int vino_querystd(struct file *file, void *__fh,
3062 break; 2949 break;
3063 case VINO_INPUT_COMPOSITE: 2950 case VINO_INPUT_COMPOSITE:
3064 case VINO_INPUT_SVIDEO: { 2951 case VINO_INPUT_SVIDEO: {
3065 struct saa7191_status status; 2952 i2c_decoder_command(VIDIOC_QUERYSTD, std);
3066
3067 i2c_decoder_command(DECODER_SAA7191_GET_STATUS, &status);
3068
3069 if (status.signal) {
3070 if (status.signal_60hz) {
3071 *std = V4L2_STD_NTSC;
3072 } else {
3073 *std = V4L2_STD_PAL | V4L2_STD_SECAM;
3074 }
3075 } else {
3076 *std = vino_inputs[vcs->input].std;
3077 }
3078 break; 2953 break;
3079 } 2954 }
3080 default: 2955 default:
@@ -3126,12 +3001,7 @@ static int vino_s_std(struct file *file, void *__fh,
3126 if (vcs->input == VINO_INPUT_D1) 3001 if (vcs->input == VINO_INPUT_D1)
3127 goto out; 3002 goto out;
3128 3003
3129 if (((*std) & V4L2_STD_PAL) 3004 if ((*std) & V4L2_STD_PAL) {
3130 && ((*std) & V4L2_STD_NTSC)
3131 && ((*std) & V4L2_STD_SECAM)) {
3132 ret = vino_set_data_norm(vcs, VINO_DATA_NORM_AUTO_EXT,
3133 &flags);
3134 } else if ((*std) & V4L2_STD_PAL) {
3135 ret = vino_set_data_norm(vcs, VINO_DATA_NORM_PAL, 3005 ret = vino_set_data_norm(vcs, VINO_DATA_NORM_PAL,
3136 &flags); 3006 &flags);
3137 } else if ((*std) & V4L2_STD_NTSC) { 3007 } else if ((*std) & V4L2_STD_NTSC) {
@@ -3797,56 +3667,38 @@ static int vino_g_ctrl(struct file *file, void *__fh,
3797 3667
3798 switch (vcs->input) { 3668 switch (vcs->input) {
3799 case VINO_INPUT_D1: { 3669 case VINO_INPUT_D1: {
3800 struct indycam_control indycam_ctrl; 3670 err = -EINVAL;
3801
3802 for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) { 3671 for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) {
3803 if (vino_indycam_v4l2_controls[i].id == 3672 if (vino_indycam_v4l2_controls[i].id == control->id) {
3804 control->id) { 3673 err = 0;
3805 goto found1; 3674 break;
3806 } 3675 }
3807 } 3676 }
3808 3677
3809 err = -EINVAL; 3678 if (err)
3810 goto out;
3811
3812found1:
3813 indycam_ctrl.type = vino_indycam_v4l2_controls[i].reserved[0];
3814
3815 err = i2c_camera_command(DECODER_INDYCAM_GET_CONTROL,
3816 &indycam_ctrl);
3817 if (err) {
3818 err = -EINVAL;
3819 goto out; 3679 goto out;
3820 }
3821 3680
3822 control->value = indycam_ctrl.value; 3681 err = i2c_camera_command(VIDIOC_G_CTRL, &control);
3682 if (err)
3683 err = -EINVAL;
3823 break; 3684 break;
3824 } 3685 }
3825 case VINO_INPUT_COMPOSITE: 3686 case VINO_INPUT_COMPOSITE:
3826 case VINO_INPUT_SVIDEO: { 3687 case VINO_INPUT_SVIDEO: {
3827 struct saa7191_control saa7191_ctrl; 3688 err = -EINVAL;
3828
3829 for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) { 3689 for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) {
3830 if (vino_saa7191_v4l2_controls[i].id == 3690 if (vino_saa7191_v4l2_controls[i].id == control->id) {
3831 control->id) { 3691 err = 0;
3832 goto found2; 3692 break;
3833 } 3693 }
3834 } 3694 }
3835 3695
3836 err = -EINVAL; 3696 if (err)
3837 goto out;
3838
3839found2:
3840 saa7191_ctrl.type = vino_saa7191_v4l2_controls[i].reserved[0];
3841
3842 err = i2c_decoder_command(DECODER_SAA7191_GET_CONTROL,
3843 &saa7191_ctrl);
3844 if (err) {
3845 err = -EINVAL;
3846 goto out; 3697 goto out;
3847 }
3848 3698
3849 control->value = saa7191_ctrl.value; 3699 err = i2c_decoder_command(VIDIOC_G_CTRL, &control);
3700 if (err)
3701 err = -EINVAL;
3850 break; 3702 break;
3851 } 3703 }
3852 default: 3704 default:
@@ -3876,65 +3728,43 @@ static int vino_s_ctrl(struct file *file, void *__fh,
3876 3728
3877 switch (vcs->input) { 3729 switch (vcs->input) {
3878 case VINO_INPUT_D1: { 3730 case VINO_INPUT_D1: {
3879 struct indycam_control indycam_ctrl; 3731 err = -EINVAL;
3880
3881 for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) { 3732 for (i = 0; i < VINO_INDYCAM_V4L2_CONTROL_COUNT; i++) {
3882 if (vino_indycam_v4l2_controls[i].id == 3733 if (vino_indycam_v4l2_controls[i].id == control->id) {
3883 control->id) { 3734 err = 0;
3884 if ((control->value >= 3735 break;
3885 vino_indycam_v4l2_controls[i].minimum)
3886 && (control->value <=
3887 vino_indycam_v4l2_controls[i].
3888 maximum)) {
3889 goto found1;
3890 } else {
3891 err = -ERANGE;
3892 goto out;
3893 }
3894 } 3736 }
3895 } 3737 }
3896 3738 if (err)
3897 err = -EINVAL; 3739 goto out;
3898 goto out; 3740 if (control->value < vino_indycam_v4l2_controls[i].minimum ||
3899 3741 control->value > vino_indycam_v4l2_controls[i].maximum) {
3900found1: 3742 err = -ERANGE;
3901 indycam_ctrl.type = vino_indycam_v4l2_controls[i].reserved[0]; 3743 goto out;
3902 indycam_ctrl.value = control->value; 3744 }
3903 3745 err = i2c_camera_command(VIDIOC_S_CTRL, &control);
3904 err = i2c_camera_command(DECODER_INDYCAM_SET_CONTROL,
3905 &indycam_ctrl);
3906 if (err) 3746 if (err)
3907 err = -EINVAL; 3747 err = -EINVAL;
3908 break; 3748 break;
3909 } 3749 }
3910 case VINO_INPUT_COMPOSITE: 3750 case VINO_INPUT_COMPOSITE:
3911 case VINO_INPUT_SVIDEO: { 3751 case VINO_INPUT_SVIDEO: {
3912 struct saa7191_control saa7191_ctrl; 3752 err = -EINVAL;
3913
3914 for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) { 3753 for (i = 0; i < VINO_SAA7191_V4L2_CONTROL_COUNT; i++) {
3915 if (vino_saa7191_v4l2_controls[i].id == 3754 if (vino_saa7191_v4l2_controls[i].id == control->id) {
3916 control->id) { 3755 err = 0;
3917 if ((control->value >= 3756 break;
3918 vino_saa7191_v4l2_controls[i].minimum)
3919 && (control->value <=
3920 vino_saa7191_v4l2_controls[i].
3921 maximum)) {
3922 goto found2;
3923 } else {
3924 err = -ERANGE;
3925 goto out;
3926 }
3927 } 3757 }
3928 } 3758 }
3929 err = -EINVAL; 3759 if (err)
3930 goto out; 3760 goto out;
3931 3761 if (control->value < vino_saa7191_v4l2_controls[i].minimum ||
3932found2: 3762 control->value > vino_saa7191_v4l2_controls[i].maximum) {
3933 saa7191_ctrl.type = vino_saa7191_v4l2_controls[i].reserved[0]; 3763 err = -ERANGE;
3934 saa7191_ctrl.value = control->value; 3764 goto out;
3765 }
3935 3766
3936 err = i2c_decoder_command(DECODER_SAA7191_SET_CONTROL, 3767 err = i2c_decoder_command(VIDIOC_S_CTRL, &control);
3937 &saa7191_ctrl);
3938 if (err) 3768 if (err)
3939 err = -EINVAL; 3769 err = -EINVAL;
3940 break; 3770 break;