aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c36
-rw-r--r--include/media/cx25840.h1
2 files changed, 25 insertions, 12 deletions
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 904e9a5a9065..9702a9334b4a 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -703,6 +703,10 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
703 struct cx25840_state *state = to_state(i2c_get_clientdata(client)); 703 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
704 u8 is_composite = (vid_input >= CX25840_COMPOSITE1 && 704 u8 is_composite = (vid_input >= CX25840_COMPOSITE1 &&
705 vid_input <= CX25840_COMPOSITE8); 705 vid_input <= CX25840_COMPOSITE8);
706 u8 is_component = (vid_input & CX25840_COMPONENT_ON) ==
707 CX25840_COMPONENT_ON;
708 int luma = vid_input & 0xf0;
709 int chroma = vid_input & 0xf00;
706 u8 reg; 710 u8 reg;
707 711
708 v4l_dbg(1, cx25840_debug, client, 712 v4l_dbg(1, cx25840_debug, client,
@@ -715,18 +719,14 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
715 reg = vid_input & 0xff; 719 reg = vid_input & 0xff;
716 if ((vid_input & CX25840_SVIDEO_ON) == CX25840_SVIDEO_ON) 720 if ((vid_input & CX25840_SVIDEO_ON) == CX25840_SVIDEO_ON)
717 is_composite = 0; 721 is_composite = 0;
718 else 722 else if ((vid_input & CX25840_COMPONENT_ON) == 0)
719 is_composite = 1; 723 is_composite = 1;
720 724
721 v4l_dbg(1, cx25840_debug, client, "mux cfg 0x%x comp=%d\n", 725 v4l_dbg(1, cx25840_debug, client, "mux cfg 0x%x comp=%d\n",
722 reg, is_composite); 726 reg, is_composite);
723 } else 727 } else if (is_composite) {
724 if (is_composite) {
725 reg = 0xf0 + (vid_input - CX25840_COMPOSITE1); 728 reg = 0xf0 + (vid_input - CX25840_COMPOSITE1);
726 } else { 729 } else {
727 int luma = vid_input & 0xf0;
728 int chroma = vid_input & 0xf00;
729
730 if ((vid_input & ~0xff0) || 730 if ((vid_input & ~0xff0) ||
731 luma < CX25840_SVIDEO_LUMA1 || luma > CX25840_SVIDEO_LUMA8 || 731 luma < CX25840_SVIDEO_LUMA1 || luma > CX25840_SVIDEO_LUMA8 ||
732 chroma < CX25840_SVIDEO_CHROMA4 || chroma > CX25840_SVIDEO_CHROMA8) { 732 chroma < CX25840_SVIDEO_CHROMA4 || chroma > CX25840_SVIDEO_CHROMA8) {
@@ -768,8 +768,11 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
768 768
769 cx25840_write(client, 0x103, reg); 769 cx25840_write(client, 0x103, reg);
770 770
771 /* Set INPUT_MODE to Composite (0) or S-Video (1) */ 771 /* Set INPUT_MODE to Composite, S-Video or Component */
772 cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02); 772 if (is_component)
773 cx25840_and_or(client, 0x401, ~0x6, 0x6);
774 else
775 cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02);
773 776
774 if (!is_cx2388x(state) && !is_cx231xx(state)) { 777 if (!is_cx2388x(state) && !is_cx231xx(state)) {
775 /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */ 778 /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */
@@ -780,12 +783,21 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
780 else 783 else
781 cx25840_and_or(client, 0x102, ~0x4, 0); 784 cx25840_and_or(client, 0x102, ~0x4, 0);
782 } else { 785 } else {
783 if (is_composite) 786 /* Set DUAL_MODE_ADC2 to 1 if component*/
787 cx25840_and_or(client, 0x102, ~0x4, is_component ? 0x4 : 0x0);
788 if (is_composite) {
784 /* ADC2 input select channel 2 */ 789 /* ADC2 input select channel 2 */
785 cx25840_and_or(client, 0x102, ~0x2, 0); 790 cx25840_and_or(client, 0x102, ~0x2, 0);
786 else 791 } else if (!is_component) {
787 /* ADC2 input select channel 3 */ 792 /* S-Video */
788 cx25840_and_or(client, 0x102, ~0x2, 2); 793 if (chroma >= CX25840_SVIDEO_CHROMA7) {
794 /* ADC2 input select channel 3 */
795 cx25840_and_or(client, 0x102, ~0x2, 2);
796 } else {
797 /* ADC2 input select channel 2 */
798 cx25840_and_or(client, 0x102, ~0x2, 0);
799 }
800 }
789 } 801 }
790 802
791 state->vid_input = vid_input; 803 state->vid_input = vid_input;
diff --git a/include/media/cx25840.h b/include/media/cx25840.h
index 2c3fbaa33f74..0b0cb1776796 100644
--- a/include/media/cx25840.h
+++ b/include/media/cx25840.h
@@ -84,6 +84,7 @@ enum cx25840_video_input {
84 CX25840_NONE0_CH3 = 0x80000080, 84 CX25840_NONE0_CH3 = 0x80000080,
85 CX25840_NONE1_CH3 = 0x800000c0, 85 CX25840_NONE1_CH3 = 0x800000c0,
86 CX25840_SVIDEO_ON = 0x80000100, 86 CX25840_SVIDEO_ON = 0x80000100,
87 CX25840_COMPONENT_ON = 0x80000200,
87}; 88};
88 89
89enum cx25840_audio_input { 90enum cx25840_audio_input {