diff options
Diffstat (limited to 'drivers/media/video/cx18')
-rw-r--r-- | drivers/media/video/cx18/Kconfig | 4 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-av-core.c | 154 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-av-core.h | 16 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-cards.c | 88 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-cards.h | 50 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-controls.c | 6 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-driver.c | 26 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-driver.h | 9 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-dvb.c | 17 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-fileops.c | 13 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-gpio.c | 57 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-gpio.h | 1 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-i2c.c | 2 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-ioctl.c | 12 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-irq.c | 12 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-mailbox.c | 8 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-streams.c | 37 |
17 files changed, 313 insertions, 199 deletions
diff --git a/drivers/media/video/cx18/Kconfig b/drivers/media/video/cx18/Kconfig index 5f942690570c..9aefdc5ea79a 100644 --- a/drivers/media/video/cx18/Kconfig +++ b/drivers/media/video/cx18/Kconfig | |||
@@ -10,8 +10,8 @@ config VIDEO_CX18 | |||
10 | select VIDEO_TVEEPROM | 10 | select VIDEO_TVEEPROM |
11 | select VIDEO_CX2341X | 11 | select VIDEO_CX2341X |
12 | select VIDEO_CS5345 | 12 | select VIDEO_CS5345 |
13 | select DVB_S5H1409 | 13 | select DVB_S5H1409 if !DVB_FE_CUSTOMISE |
14 | select MEDIA_TUNER_MXL5005S | 14 | select MEDIA_TUNER_MXL5005S if !DVB_FE_CUSTOMISE |
15 | ---help--- | 15 | ---help--- |
16 | This is a video4linux driver for Conexant cx23418 based | 16 | This is a video4linux driver for Conexant cx23418 based |
17 | PCI combo video recorder devices. | 17 | PCI combo video recorder devices. |
diff --git a/drivers/media/video/cx18/cx18-av-core.c b/drivers/media/video/cx18/cx18-av-core.c index 66864904c99b..faca43eb940f 100644 --- a/drivers/media/video/cx18/cx18-av-core.c +++ b/drivers/media/video/cx18/cx18-av-core.c | |||
@@ -69,6 +69,58 @@ int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 and_mask, | |||
69 | or_value); | 69 | or_value); |
70 | } | 70 | } |
71 | 71 | ||
72 | int cx18_av_write_no_acfg(struct cx18 *cx, u16 addr, u8 value, int no_acfg_mask) | ||
73 | { | ||
74 | int retval; | ||
75 | u32 saved_reg[8] = {0}; | ||
76 | |||
77 | if (no_acfg_mask & CXADEC_NO_ACFG_AFE) { | ||
78 | saved_reg[0] = cx18_av_read4(cx, CXADEC_CHIP_CTRL); | ||
79 | saved_reg[1] = cx18_av_read4(cx, CXADEC_AFE_CTRL); | ||
80 | } | ||
81 | |||
82 | if (no_acfg_mask & CXADEC_NO_ACFG_PLL) { | ||
83 | saved_reg[2] = cx18_av_read4(cx, CXADEC_PLL_CTRL1); | ||
84 | saved_reg[3] = cx18_av_read4(cx, CXADEC_VID_PLL_FRAC); | ||
85 | } | ||
86 | |||
87 | if (no_acfg_mask & CXADEC_NO_ACFG_VID) { | ||
88 | saved_reg[4] = cx18_av_read4(cx, CXADEC_HORIZ_TIM_CTRL); | ||
89 | saved_reg[5] = cx18_av_read4(cx, CXADEC_VERT_TIM_CTRL); | ||
90 | saved_reg[6] = cx18_av_read4(cx, CXADEC_SRC_COMB_CFG); | ||
91 | saved_reg[7] = cx18_av_read4(cx, CXADEC_CHROMA_VBIOFF_CFG); | ||
92 | } | ||
93 | |||
94 | retval = cx18_av_write(cx, addr, value); | ||
95 | |||
96 | if (no_acfg_mask & CXADEC_NO_ACFG_AFE) { | ||
97 | cx18_av_write4(cx, CXADEC_CHIP_CTRL, saved_reg[0]); | ||
98 | cx18_av_write4(cx, CXADEC_AFE_CTRL, saved_reg[1]); | ||
99 | } | ||
100 | |||
101 | if (no_acfg_mask & CXADEC_NO_ACFG_PLL) { | ||
102 | cx18_av_write4(cx, CXADEC_PLL_CTRL1, saved_reg[2]); | ||
103 | cx18_av_write4(cx, CXADEC_VID_PLL_FRAC, saved_reg[3]); | ||
104 | } | ||
105 | |||
106 | if (no_acfg_mask & CXADEC_NO_ACFG_VID) { | ||
107 | cx18_av_write4(cx, CXADEC_HORIZ_TIM_CTRL, saved_reg[4]); | ||
108 | cx18_av_write4(cx, CXADEC_VERT_TIM_CTRL, saved_reg[5]); | ||
109 | cx18_av_write4(cx, CXADEC_SRC_COMB_CFG, saved_reg[6]); | ||
110 | cx18_av_write4(cx, CXADEC_CHROMA_VBIOFF_CFG, saved_reg[7]); | ||
111 | } | ||
112 | |||
113 | return retval; | ||
114 | } | ||
115 | |||
116 | int cx18_av_and_or_no_acfg(struct cx18 *cx, u16 addr, unsigned and_mask, | ||
117 | u8 or_value, int no_acfg_mask) | ||
118 | { | ||
119 | return cx18_av_write_no_acfg(cx, addr, | ||
120 | (cx18_av_read(cx, addr) & and_mask) | | ||
121 | or_value, no_acfg_mask); | ||
122 | } | ||
123 | |||
72 | /* ----------------------------------------------------------------------- */ | 124 | /* ----------------------------------------------------------------------- */ |
73 | 125 | ||
74 | static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, | 126 | static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, |
@@ -170,26 +222,30 @@ static void input_change(struct cx18 *cx) | |||
170 | 222 | ||
171 | /* Follow step 8c and 8d of section 3.16 in the cx18_av datasheet */ | 223 | /* Follow step 8c and 8d of section 3.16 in the cx18_av datasheet */ |
172 | if (std & V4L2_STD_SECAM) | 224 | if (std & V4L2_STD_SECAM) |
173 | cx18_av_write(cx, 0x402, 0); | 225 | cx18_av_write_no_acfg(cx, 0x402, 0, CXADEC_NO_ACFG_ALL); |
174 | else { | 226 | else { |
175 | cx18_av_write(cx, 0x402, 0x04); | 227 | cx18_av_write_no_acfg(cx, 0x402, 0x04, CXADEC_NO_ACFG_ALL); |
176 | cx18_av_write(cx, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11); | 228 | cx18_av_write(cx, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11); |
177 | } | 229 | } |
178 | cx18_av_and_or(cx, 0x401, ~0x60, 0); | 230 | cx18_av_and_or_no_acfg(cx, 0x401, ~0x60, 0, |
179 | cx18_av_and_or(cx, 0x401, ~0x60, 0x60); | 231 | CXADEC_NO_ACFG_PLL | CXADEC_NO_ACFG_VID); |
232 | cx18_av_and_or_no_acfg(cx, 0x401, ~0x60, 0x60, | ||
233 | CXADEC_NO_ACFG_PLL | CXADEC_NO_ACFG_VID); | ||
180 | 234 | ||
181 | if (std & V4L2_STD_525_60) { | 235 | if (std & V4L2_STD_525_60) { |
182 | if (std == V4L2_STD_NTSC_M_JP) { | 236 | if (std == V4L2_STD_NTSC_M_JP) { |
183 | /* Japan uses EIAJ audio standard */ | 237 | /* Japan uses EIAJ audio standard */ |
184 | cx18_av_write(cx, 0x808, 0xf7); | 238 | cx18_av_write(cx, 0x808, 0xf7); |
239 | cx18_av_write(cx, 0x80b, 0x02); | ||
185 | } else if (std == V4L2_STD_NTSC_M_KR) { | 240 | } else if (std == V4L2_STD_NTSC_M_KR) { |
186 | /* South Korea uses A2 audio standard */ | 241 | /* South Korea uses A2 audio standard */ |
187 | cx18_av_write(cx, 0x808, 0xf8); | 242 | cx18_av_write(cx, 0x808, 0xf8); |
243 | cx18_av_write(cx, 0x80b, 0x03); | ||
188 | } else { | 244 | } else { |
189 | /* Others use the BTSC audio standard */ | 245 | /* Others use the BTSC audio standard */ |
190 | cx18_av_write(cx, 0x808, 0xf6); | 246 | cx18_av_write(cx, 0x808, 0xf6); |
247 | cx18_av_write(cx, 0x80b, 0x01); | ||
191 | } | 248 | } |
192 | cx18_av_write(cx, 0x80b, 0x00); | ||
193 | } else if (std & V4L2_STD_PAL) { | 249 | } else if (std & V4L2_STD_PAL) { |
194 | /* Follow tuner change procedure for PAL */ | 250 | /* Follow tuner change procedure for PAL */ |
195 | cx18_av_write(cx, 0x808, 0xff); | 251 | cx18_av_write(cx, 0x808, 0xff); |
@@ -226,7 +282,7 @@ static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, | |||
226 | 282 | ||
227 | if ((vid_input & ~0xff0) || | 283 | if ((vid_input & ~0xff0) || |
228 | luma < CX18_AV_SVIDEO_LUMA1 || | 284 | luma < CX18_AV_SVIDEO_LUMA1 || |
229 | luma > CX18_AV_SVIDEO_LUMA4 || | 285 | luma > CX18_AV_SVIDEO_LUMA8 || |
230 | chroma < CX18_AV_SVIDEO_CHROMA4 || | 286 | chroma < CX18_AV_SVIDEO_CHROMA4 || |
231 | chroma > CX18_AV_SVIDEO_CHROMA8) { | 287 | chroma > CX18_AV_SVIDEO_CHROMA8) { |
232 | CX18_ERR("0x%04x is not a valid video input!\n", | 288 | CX18_ERR("0x%04x is not a valid video input!\n", |
@@ -260,7 +316,8 @@ static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, | |||
260 | 316 | ||
261 | cx18_av_write(cx, 0x103, reg); | 317 | cx18_av_write(cx, 0x103, reg); |
262 | /* Set INPUT_MODE to Composite (0) or S-Video (1) */ | 318 | /* Set INPUT_MODE to Composite (0) or S-Video (1) */ |
263 | cx18_av_and_or(cx, 0x401, ~0x6, is_composite ? 0 : 0x02); | 319 | cx18_av_and_or_no_acfg(cx, 0x401, ~0x6, is_composite ? 0 : 0x02, |
320 | CXADEC_NO_ACFG_PLL | CXADEC_NO_ACFG_VID); | ||
264 | /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */ | 321 | /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */ |
265 | cx18_av_and_or(cx, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0); | 322 | cx18_av_and_or(cx, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0); |
266 | /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */ | 323 | /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */ |
@@ -316,12 +373,12 @@ static int set_v4lstd(struct cx18 *cx) | |||
316 | This happens for example with the Yuan MPC622. */ | 373 | This happens for example with the Yuan MPC622. */ |
317 | if (fmt >= 4 && fmt < 8) { | 374 | if (fmt >= 4 && fmt < 8) { |
318 | /* Set format to NTSC-M */ | 375 | /* Set format to NTSC-M */ |
319 | cx18_av_and_or(cx, 0x400, ~0xf, 1); | 376 | cx18_av_and_or_no_acfg(cx, 0x400, ~0xf, 1, CXADEC_NO_ACFG_AFE); |
320 | /* Turn off LCOMB */ | 377 | /* Turn off LCOMB */ |
321 | cx18_av_and_or(cx, 0x47b, ~6, 0); | 378 | cx18_av_and_or(cx, 0x47b, ~6, 0); |
322 | } | 379 | } |
323 | cx18_av_and_or(cx, 0x400, ~0xf, fmt); | 380 | cx18_av_and_or_no_acfg(cx, 0x400, ~0xf, fmt, CXADEC_NO_ACFG_AFE); |
324 | cx18_av_and_or(cx, 0x403, ~0x3, pal_m); | 381 | cx18_av_and_or_no_acfg(cx, 0x403, ~0x3, pal_m, CXADEC_NO_ACFG_ALL); |
325 | cx18_av_vbi_setup(cx); | 382 | cx18_av_vbi_setup(cx); |
326 | input_change(cx); | 383 | input_change(cx); |
327 | return 0; | 384 | return 0; |
@@ -741,8 +798,8 @@ static void log_audio_status(struct cx18 *cx) | |||
741 | { | 798 | { |
742 | struct cx18_av_state *state = &cx->av_state; | 799 | struct cx18_av_state *state = &cx->av_state; |
743 | u8 download_ctl = cx18_av_read(cx, 0x803); | 800 | u8 download_ctl = cx18_av_read(cx, 0x803); |
744 | u8 mod_det_stat0 = cx18_av_read(cx, 0x805); | 801 | u8 mod_det_stat0 = cx18_av_read(cx, 0x804); |
745 | u8 mod_det_stat1 = cx18_av_read(cx, 0x804); | 802 | u8 mod_det_stat1 = cx18_av_read(cx, 0x805); |
746 | u8 audio_config = cx18_av_read(cx, 0x808); | 803 | u8 audio_config = cx18_av_read(cx, 0x808); |
747 | u8 pref_mode = cx18_av_read(cx, 0x809); | 804 | u8 pref_mode = cx18_av_read(cx, 0x809); |
748 | u8 afc0 = cx18_av_read(cx, 0x80b); | 805 | u8 afc0 = cx18_av_read(cx, 0x80b); |
@@ -760,12 +817,12 @@ static void log_audio_status(struct cx18 *cx) | |||
760 | case 0x12: p = "dual with SAP"; break; | 817 | case 0x12: p = "dual with SAP"; break; |
761 | case 0x14: p = "tri with SAP"; break; | 818 | case 0x14: p = "tri with SAP"; break; |
762 | case 0xfe: p = "forced mode"; break; | 819 | case 0xfe: p = "forced mode"; break; |
763 | default: p = "not defined"; | 820 | default: p = "not defined"; break; |
764 | } | 821 | } |
765 | CX18_INFO("Detected audio mode: %s\n", p); | 822 | CX18_INFO("Detected audio mode: %s\n", p); |
766 | 823 | ||
767 | switch (mod_det_stat1) { | 824 | switch (mod_det_stat1) { |
768 | case 0x00: p = "BTSC"; break; | 825 | case 0x00: p = "not defined"; break; |
769 | case 0x01: p = "EIAJ"; break; | 826 | case 0x01: p = "EIAJ"; break; |
770 | case 0x02: p = "A2-M"; break; | 827 | case 0x02: p = "A2-M"; break; |
771 | case 0x03: p = "A2-BG"; break; | 828 | case 0x03: p = "A2-BG"; break; |
@@ -779,8 +836,13 @@ static void log_audio_status(struct cx18 *cx) | |||
779 | case 0x0b: p = "NICAM-I"; break; | 836 | case 0x0b: p = "NICAM-I"; break; |
780 | case 0x0c: p = "NICAM-L"; break; | 837 | case 0x0c: p = "NICAM-L"; break; |
781 | case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break; | 838 | case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break; |
839 | case 0x0e: p = "IF FM Radio"; break; | ||
840 | case 0x0f: p = "BTSC"; break; | ||
841 | case 0x10: p = "detected chrominance"; break; | ||
842 | case 0xfd: p = "unknown audio standard"; break; | ||
843 | case 0xfe: p = "forced audio standard"; break; | ||
782 | case 0xff: p = "no detected audio standard"; break; | 844 | case 0xff: p = "no detected audio standard"; break; |
783 | default: p = "not defined"; | 845 | default: p = "not defined"; break; |
784 | } | 846 | } |
785 | CX18_INFO("Detected audio standard: %s\n", p); | 847 | CX18_INFO("Detected audio standard: %s\n", p); |
786 | CX18_INFO("Audio muted: %s\n", | 848 | CX18_INFO("Audio muted: %s\n", |
@@ -789,22 +851,23 @@ static void log_audio_status(struct cx18 *cx) | |||
789 | (download_ctl & 0x10) ? "running" : "stopped"); | 851 | (download_ctl & 0x10) ? "running" : "stopped"); |
790 | 852 | ||
791 | switch (audio_config >> 4) { | 853 | switch (audio_config >> 4) { |
792 | case 0x00: p = "BTSC"; break; | 854 | case 0x00: p = "undefined"; break; |
793 | case 0x01: p = "EIAJ"; break; | 855 | case 0x01: p = "BTSC"; break; |
794 | case 0x02: p = "A2-M"; break; | 856 | case 0x02: p = "EIAJ"; break; |
795 | case 0x03: p = "A2-BG"; break; | 857 | case 0x03: p = "A2-M"; break; |
796 | case 0x04: p = "A2-DK1"; break; | 858 | case 0x04: p = "A2-BG"; break; |
797 | case 0x05: p = "A2-DK2"; break; | 859 | case 0x05: p = "A2-DK1"; break; |
798 | case 0x06: p = "A2-DK3"; break; | 860 | case 0x06: p = "A2-DK2"; break; |
799 | case 0x07: p = "A1 (6.0 MHz FM Mono)"; break; | 861 | case 0x07: p = "A2-DK3"; break; |
800 | case 0x08: p = "AM-L"; break; | 862 | case 0x08: p = "A1 (6.0 MHz FM Mono)"; break; |
801 | case 0x09: p = "NICAM-BG"; break; | 863 | case 0x09: p = "AM-L"; break; |
802 | case 0x0a: p = "NICAM-DK"; break; | 864 | case 0x0a: p = "NICAM-BG"; break; |
803 | case 0x0b: p = "NICAM-I"; break; | 865 | case 0x0b: p = "NICAM-DK"; break; |
804 | case 0x0c: p = "NICAM-L"; break; | 866 | case 0x0c: p = "NICAM-I"; break; |
805 | case 0x0d: p = "FM radio"; break; | 867 | case 0x0d: p = "NICAM-L"; break; |
868 | case 0x0e: p = "FM radio"; break; | ||
806 | case 0x0f: p = "automatic detection"; break; | 869 | case 0x0f: p = "automatic detection"; break; |
807 | default: p = "undefined"; | 870 | default: p = "undefined"; break; |
808 | } | 871 | } |
809 | CX18_INFO("Configured audio standard: %s\n", p); | 872 | CX18_INFO("Configured audio standard: %s\n", p); |
810 | 873 | ||
@@ -815,12 +878,9 @@ static void log_audio_status(struct cx18 *cx) | |||
815 | case 0x02: p = "MONO3 (STEREO forced MONO)"; break; | 878 | case 0x02: p = "MONO3 (STEREO forced MONO)"; break; |
816 | case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break; | 879 | case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break; |
817 | case 0x04: p = "STEREO"; break; | 880 | case 0x04: p = "STEREO"; break; |
818 | case 0x05: p = "DUAL1 (AB)"; break; | 881 | case 0x05: p = "DUAL1 (AC)"; break; |
819 | case 0x06: p = "DUAL2 (AC) (FM)"; break; | 882 | case 0x06: p = "DUAL2 (BC)"; break; |
820 | case 0x07: p = "DUAL3 (BC) (FM)"; break; | 883 | case 0x07: p = "DUAL3 (AB)"; break; |
821 | case 0x08: p = "DUAL4 (AC) (AM)"; break; | ||
822 | case 0x09: p = "DUAL5 (BC) (AM)"; break; | ||
823 | case 0x0a: p = "SAP"; break; | ||
824 | default: p = "undefined"; | 884 | default: p = "undefined"; |
825 | } | 885 | } |
826 | CX18_INFO("Configured audio mode: %s\n", p); | 886 | CX18_INFO("Configured audio mode: %s\n", p); |
@@ -835,9 +895,11 @@ static void log_audio_status(struct cx18 *cx) | |||
835 | case 0x06: p = "BTSC"; break; | 895 | case 0x06: p = "BTSC"; break; |
836 | case 0x07: p = "EIAJ"; break; | 896 | case 0x07: p = "EIAJ"; break; |
837 | case 0x08: p = "A2-M"; break; | 897 | case 0x08: p = "A2-M"; break; |
838 | case 0x09: p = "FM Radio"; break; | 898 | case 0x09: p = "FM Radio (4.5 MHz)"; break; |
899 | case 0x0a: p = "FM Radio (5.5 MHz)"; break; | ||
900 | case 0x0b: p = "S-Video"; break; | ||
839 | case 0x0f: p = "automatic standard and mode detection"; break; | 901 | case 0x0f: p = "automatic standard and mode detection"; break; |
840 | default: p = "undefined"; | 902 | default: p = "undefined"; break; |
841 | } | 903 | } |
842 | CX18_INFO("Configured audio system: %s\n", p); | 904 | CX18_INFO("Configured audio system: %s\n", p); |
843 | } | 905 | } |
@@ -857,22 +919,24 @@ static void log_audio_status(struct cx18 *cx) | |||
857 | case 5: p = "language AC"; break; | 919 | case 5: p = "language AC"; break; |
858 | case 6: p = "language BC"; break; | 920 | case 6: p = "language BC"; break; |
859 | case 7: p = "language AB"; break; | 921 | case 7: p = "language AB"; break; |
860 | default: p = "undefined"; | 922 | default: p = "undefined"; break; |
861 | } | 923 | } |
862 | CX18_INFO("Preferred audio mode: %s\n", p); | 924 | CX18_INFO("Preferred audio mode: %s\n", p); |
863 | 925 | ||
864 | if ((audio_config & 0xf) == 0xf) { | 926 | if ((audio_config & 0xf) == 0xf) { |
865 | switch ((afc0 >> 2) & 0x1) { | 927 | switch ((afc0 >> 3) & 0x1) { |
866 | case 0: p = "system DK"; break; | 928 | case 0: p = "system DK"; break; |
867 | case 1: p = "system L"; break; | 929 | case 1: p = "system L"; break; |
868 | } | 930 | } |
869 | CX18_INFO("Selected 65 MHz format: %s\n", p); | 931 | CX18_INFO("Selected 65 MHz format: %s\n", p); |
870 | 932 | ||
871 | switch (afc0 & 0x3) { | 933 | switch (afc0 & 0x7) { |
872 | case 0: p = "BTSC"; break; | 934 | case 0: p = "Chroma"; break; |
873 | case 1: p = "EIAJ"; break; | 935 | case 1: p = "BTSC"; break; |
874 | case 2: p = "A2-M"; break; | 936 | case 2: p = "EIAJ"; break; |
875 | default: p = "undefined"; | 937 | case 3: p = "A2-M"; break; |
938 | case 4: p = "autodetect"; break; | ||
939 | default: p = "undefined"; break; | ||
876 | } | 940 | } |
877 | CX18_INFO("Selected 45 MHz format: %s\n", p); | 941 | CX18_INFO("Selected 45 MHz format: %s\n", p); |
878 | } | 942 | } |
diff --git a/drivers/media/video/cx18/cx18-av-core.h b/drivers/media/video/cx18/cx18-av-core.h index 786901d72e9a..c172823ce1d8 100644 --- a/drivers/media/video/cx18/cx18-av-core.h +++ b/drivers/media/video/cx18/cx18-av-core.h | |||
@@ -37,12 +37,16 @@ enum cx18_av_video_input { | |||
37 | CX18_AV_COMPOSITE7, | 37 | CX18_AV_COMPOSITE7, |
38 | CX18_AV_COMPOSITE8, | 38 | CX18_AV_COMPOSITE8, |
39 | 39 | ||
40 | /* S-Video inputs consist of one luma input (In1-In4) ORed with one | 40 | /* S-Video inputs consist of one luma input (In1-In8) ORed with one |
41 | chroma input (In5-In8) */ | 41 | chroma input (In5-In8) */ |
42 | CX18_AV_SVIDEO_LUMA1 = 0x10, | 42 | CX18_AV_SVIDEO_LUMA1 = 0x10, |
43 | CX18_AV_SVIDEO_LUMA2 = 0x20, | 43 | CX18_AV_SVIDEO_LUMA2 = 0x20, |
44 | CX18_AV_SVIDEO_LUMA3 = 0x30, | 44 | CX18_AV_SVIDEO_LUMA3 = 0x30, |
45 | CX18_AV_SVIDEO_LUMA4 = 0x40, | 45 | CX18_AV_SVIDEO_LUMA4 = 0x40, |
46 | CX18_AV_SVIDEO_LUMA5 = 0x50, | ||
47 | CX18_AV_SVIDEO_LUMA6 = 0x60, | ||
48 | CX18_AV_SVIDEO_LUMA7 = 0x70, | ||
49 | CX18_AV_SVIDEO_LUMA8 = 0x80, | ||
46 | CX18_AV_SVIDEO_CHROMA4 = 0x400, | 50 | CX18_AV_SVIDEO_CHROMA4 = 0x400, |
47 | CX18_AV_SVIDEO_CHROMA5 = 0x500, | 51 | CX18_AV_SVIDEO_CHROMA5 = 0x500, |
48 | CX18_AV_SVIDEO_CHROMA6 = 0x600, | 52 | CX18_AV_SVIDEO_CHROMA6 = 0x600, |
@@ -291,14 +295,24 @@ struct cx18_av_state { | |||
291 | #define CXADEC_SELECT_AUDIO_STANDARD_FM 0xF9 /* FM radio */ | 295 | #define CXADEC_SELECT_AUDIO_STANDARD_FM 0xF9 /* FM radio */ |
292 | #define CXADEC_SELECT_AUDIO_STANDARD_AUTO 0xFF /* Auto detect */ | 296 | #define CXADEC_SELECT_AUDIO_STANDARD_AUTO 0xFF /* Auto detect */ |
293 | 297 | ||
298 | /* Flags on what to preserve on write to 0x400-0x403 with cx18_av_.*_no_acfg()*/ | ||
299 | #define CXADEC_NO_ACFG_AFE 0x01 /* Preserve 0x100-0x107 */ | ||
300 | #define CXADEC_NO_ACFG_PLL 0x02 /* Preserve 0x108-0x10f */ | ||
301 | #define CXADEC_NO_ACFG_VID 0x04 /* Preserve 0x470-0x47f */ | ||
302 | #define CXADEC_NO_ACFG_ALL 0x07 | ||
303 | |||
294 | /* ----------------------------------------------------------------------- */ | 304 | /* ----------------------------------------------------------------------- */ |
295 | /* cx18_av-core.c */ | 305 | /* cx18_av-core.c */ |
296 | int cx18_av_write(struct cx18 *cx, u16 addr, u8 value); | 306 | int cx18_av_write(struct cx18 *cx, u16 addr, u8 value); |
297 | int cx18_av_write4(struct cx18 *cx, u16 addr, u32 value); | 307 | int cx18_av_write4(struct cx18 *cx, u16 addr, u32 value); |
308 | int cx18_av_write_no_acfg(struct cx18 *cx, u16 addr, u8 value, | ||
309 | int no_acfg_mask); | ||
298 | u8 cx18_av_read(struct cx18 *cx, u16 addr); | 310 | u8 cx18_av_read(struct cx18 *cx, u16 addr); |
299 | u32 cx18_av_read4(struct cx18 *cx, u16 addr); | 311 | u32 cx18_av_read4(struct cx18 *cx, u16 addr); |
300 | int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned mask, u8 value); | 312 | int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned mask, u8 value); |
301 | int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 mask, u32 value); | 313 | int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 mask, u32 value); |
314 | int cx18_av_and_or_no_acfg(struct cx18 *cx, u16 addr, unsigned mask, u8 value, | ||
315 | int no_acfg_mask); | ||
302 | int cx18_av_cmd(struct cx18 *cx, unsigned int cmd, void *arg); | 316 | int cx18_av_cmd(struct cx18 *cx, unsigned int cmd, void *arg); |
303 | 317 | ||
304 | /* ----------------------------------------------------------------------- */ | 318 | /* ----------------------------------------------------------------------- */ |
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c index 553adbf2cd44..c26e0ef5b075 100644 --- a/drivers/media/video/cx18/cx18-cards.c +++ b/drivers/media/video/cx18/cx18-cards.c | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include "cx18-driver.h" | 24 | #include "cx18-driver.h" |
25 | #include "cx18-cards.h" | 25 | #include "cx18-cards.h" |
26 | #include "cx18-av-core.h" | ||
26 | #include "cx18-i2c.h" | 27 | #include "cx18-i2c.h" |
27 | #include <media/cs5345.h> | 28 | #include <media/cs5345.h> |
28 | 29 | ||
@@ -54,22 +55,22 @@ static const struct cx18_card cx18_card_hvr1600_esmt = { | |||
54 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | | 55 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | |
55 | CX18_HW_CS5345 | CX18_HW_DVB, | 56 | CX18_HW_CS5345 | CX18_HW_DVB, |
56 | .video_inputs = { | 57 | .video_inputs = { |
57 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, | 58 | { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 }, |
58 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, | 59 | { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 }, |
59 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, | 60 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 }, |
60 | { CX18_CARD_INPUT_SVIDEO2, 2, CX23418_SVIDEO2 }, | 61 | { CX18_CARD_INPUT_SVIDEO2, 2, CX18_AV_SVIDEO2 }, |
61 | { CX18_CARD_INPUT_COMPOSITE2, 2, CX23418_COMPOSITE4 }, | 62 | { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 }, |
62 | }, | 63 | }, |
63 | .audio_inputs = { | 64 | .audio_inputs = { |
64 | { CX18_CARD_INPUT_AUD_TUNER, | 65 | { CX18_CARD_INPUT_AUD_TUNER, |
65 | CX23418_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 }, | 66 | CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 }, |
66 | { CX18_CARD_INPUT_LINE_IN1, | 67 | { CX18_CARD_INPUT_LINE_IN1, |
67 | CX23418_AUDIO_SERIAL, CS5345_IN_2 }, | 68 | CX18_AV_AUDIO_SERIAL, CS5345_IN_2 }, |
68 | { CX18_CARD_INPUT_LINE_IN2, | 69 | { CX18_CARD_INPUT_LINE_IN2, |
69 | CX23418_AUDIO_SERIAL, CS5345_IN_2 }, | 70 | CX18_AV_AUDIO_SERIAL, CS5345_IN_3 }, |
70 | }, | 71 | }, |
71 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, | 72 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, |
72 | CX23418_AUDIO_SERIAL, 0 }, | 73 | CX18_AV_AUDIO_SERIAL, CS5345_IN_4 }, |
73 | .ddr = { | 74 | .ddr = { |
74 | /* ESMT M13S128324A-5B memory */ | 75 | /* ESMT M13S128324A-5B memory */ |
75 | .chip_config = 0x003, | 76 | .chip_config = 0x003, |
@@ -81,6 +82,11 @@ static const struct cx18_card cx18_card_hvr1600_esmt = { | |||
81 | }, | 82 | }, |
82 | .gpio_init.initial_value = 0x3001, | 83 | .gpio_init.initial_value = 0x3001, |
83 | .gpio_init.direction = 0x3001, | 84 | .gpio_init.direction = 0x3001, |
85 | .gpio_i2c_slave_reset = { | ||
86 | .active_lo_mask = 0x3001, | ||
87 | .msecs_asserted = 10, | ||
88 | .msecs_recovery = 40, | ||
89 | }, | ||
84 | .i2c = &cx18_i2c_std, | 90 | .i2c = &cx18_i2c_std, |
85 | }; | 91 | }; |
86 | 92 | ||
@@ -94,22 +100,22 @@ static const struct cx18_card cx18_card_hvr1600_samsung = { | |||
94 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | | 100 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | |
95 | CX18_HW_CS5345 | CX18_HW_DVB, | 101 | CX18_HW_CS5345 | CX18_HW_DVB, |
96 | .video_inputs = { | 102 | .video_inputs = { |
97 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, | 103 | { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 }, |
98 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, | 104 | { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 }, |
99 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, | 105 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 }, |
100 | { CX18_CARD_INPUT_SVIDEO2, 2, CX23418_SVIDEO2 }, | 106 | { CX18_CARD_INPUT_SVIDEO2, 2, CX18_AV_SVIDEO2 }, |
101 | { CX18_CARD_INPUT_COMPOSITE2, 2, CX23418_COMPOSITE4 }, | 107 | { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 }, |
102 | }, | 108 | }, |
103 | .audio_inputs = { | 109 | .audio_inputs = { |
104 | { CX18_CARD_INPUT_AUD_TUNER, | 110 | { CX18_CARD_INPUT_AUD_TUNER, |
105 | CX23418_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 }, | 111 | CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 }, |
106 | { CX18_CARD_INPUT_LINE_IN1, | 112 | { CX18_CARD_INPUT_LINE_IN1, |
107 | CX23418_AUDIO_SERIAL, CS5345_IN_2 }, | 113 | CX18_AV_AUDIO_SERIAL, CS5345_IN_2 }, |
108 | { CX18_CARD_INPUT_LINE_IN2, | 114 | { CX18_CARD_INPUT_LINE_IN2, |
109 | CX23418_AUDIO_SERIAL, CS5345_IN_2 }, | 115 | CX18_AV_AUDIO_SERIAL, CS5345_IN_3 }, |
110 | }, | 116 | }, |
111 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, | 117 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, |
112 | CX23418_AUDIO_SERIAL, 0 }, | 118 | CX18_AV_AUDIO_SERIAL, CS5345_IN_4 }, |
113 | .ddr = { | 119 | .ddr = { |
114 | /* Samsung K4D263238G-VC33 memory */ | 120 | /* Samsung K4D263238G-VC33 memory */ |
115 | .chip_config = 0x003, | 121 | .chip_config = 0x003, |
@@ -121,12 +127,17 @@ static const struct cx18_card cx18_card_hvr1600_samsung = { | |||
121 | }, | 127 | }, |
122 | .gpio_init.initial_value = 0x3001, | 128 | .gpio_init.initial_value = 0x3001, |
123 | .gpio_init.direction = 0x3001, | 129 | .gpio_init.direction = 0x3001, |
130 | .gpio_i2c_slave_reset = { | ||
131 | .active_lo_mask = 0x3001, | ||
132 | .msecs_asserted = 10, | ||
133 | .msecs_recovery = 40, | ||
134 | }, | ||
124 | .i2c = &cx18_i2c_std, | 135 | .i2c = &cx18_i2c_std, |
125 | }; | 136 | }; |
126 | 137 | ||
127 | /* ------------------------------------------------------------------------- */ | 138 | /* ------------------------------------------------------------------------- */ |
128 | 139 | ||
129 | /* Compro VideoMate H900: not working at the moment! */ | 140 | /* Compro VideoMate H900: note that this card is analog only! */ |
130 | 141 | ||
131 | static const struct cx18_card_pci_info cx18_pci_h900[] = { | 142 | static const struct cx18_card_pci_info cx18_pci_h900[] = { |
132 | { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 }, | 143 | { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 }, |
@@ -136,24 +147,24 @@ static const struct cx18_card_pci_info cx18_pci_h900[] = { | |||
136 | static const struct cx18_card cx18_card_h900 = { | 147 | static const struct cx18_card cx18_card_h900 = { |
137 | .type = CX18_CARD_COMPRO_H900, | 148 | .type = CX18_CARD_COMPRO_H900, |
138 | .name = "Compro VideoMate H900", | 149 | .name = "Compro VideoMate H900", |
139 | .comment = "DVB & VBI are not yet supported\n", | 150 | .comment = "VBI is not yet supported\n", |
140 | .v4l2_capabilities = CX18_CAP_ENCODER, | 151 | .v4l2_capabilities = CX18_CAP_ENCODER, |
141 | .hw_audio_ctrl = CX18_HW_CX23418, | 152 | .hw_audio_ctrl = CX18_HW_CX23418, |
142 | .hw_all = CX18_HW_TUNER, | 153 | .hw_all = CX18_HW_TUNER, |
143 | .video_inputs = { | 154 | .video_inputs = { |
144 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE2 }, | 155 | { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 }, |
145 | { CX18_CARD_INPUT_SVIDEO1, 1, | 156 | { CX18_CARD_INPUT_SVIDEO1, 1, |
146 | CX23418_SVIDEO_LUMA3 | CX23418_SVIDEO_CHROMA4 }, | 157 | CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 }, |
147 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE1 }, | 158 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 }, |
148 | }, | 159 | }, |
149 | .audio_inputs = { | 160 | .audio_inputs = { |
150 | { CX18_CARD_INPUT_AUD_TUNER, | 161 | { CX18_CARD_INPUT_AUD_TUNER, |
151 | CX23418_AUDIO8, 0 }, | 162 | CX18_AV_AUDIO8, 0 }, |
152 | { CX18_CARD_INPUT_LINE_IN1, | 163 | { CX18_CARD_INPUT_LINE_IN1, |
153 | CX23418_AUDIO_SERIAL, 0 }, | 164 | CX18_AV_AUDIO_SERIAL, 0 }, |
154 | }, | 165 | }, |
155 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, | 166 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, |
156 | CX23418_AUDIO_SERIAL, 0 }, | 167 | CX18_AV_AUDIO_SERIAL, 0 }, |
157 | .tuners = { | 168 | .tuners = { |
158 | { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, | 169 | { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, |
159 | }, | 170 | }, |
@@ -183,23 +194,26 @@ static const struct cx18_card_pci_info cx18_pci_mpc718[] = { | |||
183 | static const struct cx18_card cx18_card_mpc718 = { | 194 | static const struct cx18_card cx18_card_mpc718 = { |
184 | .type = CX18_CARD_YUAN_MPC718, | 195 | .type = CX18_CARD_YUAN_MPC718, |
185 | .name = "Yuan MPC718", | 196 | .name = "Yuan MPC718", |
186 | .comment = "Not yet supported!\n", | 197 | .comment = "Some Composite and S-Video inputs are currently working.\n", |
187 | .v4l2_capabilities = 0, | 198 | .v4l2_capabilities = CX18_CAP_ENCODER, |
188 | .hw_audio_ctrl = CX18_HW_CX23418, | 199 | .hw_audio_ctrl = CX18_HW_CX23418, |
189 | .hw_all = CX18_HW_TUNER, | 200 | .hw_all = CX18_HW_TUNER, |
190 | .video_inputs = { | 201 | .video_inputs = { |
191 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, | 202 | { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 }, |
192 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, | 203 | { CX18_CARD_INPUT_SVIDEO1, 1, |
193 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, | 204 | CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 }, |
205 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 }, | ||
206 | { CX18_CARD_INPUT_SVIDEO2, 2, | ||
207 | CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 }, | ||
208 | { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 }, | ||
209 | { CX18_CARD_INPUT_COMPOSITE3, 2, CX18_AV_COMPOSITE3 }, | ||
194 | }, | 210 | }, |
195 | .audio_inputs = { | 211 | .audio_inputs = { |
196 | { CX18_CARD_INPUT_AUD_TUNER, | 212 | { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 }, |
197 | CX23418_AUDIO8, 0 }, | 213 | { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL, 0 }, |
198 | { CX18_CARD_INPUT_LINE_IN1, | 214 | { CX18_CARD_INPUT_LINE_IN2, CX18_AV_AUDIO_SERIAL, 0 }, |
199 | CX23418_AUDIO_SERIAL, 0 }, | ||
200 | }, | 215 | }, |
201 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, | 216 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL, 0 }, |
202 | CX23418_AUDIO_SERIAL, 0 }, | ||
203 | .tuners = { | 217 | .tuners = { |
204 | /* XC3028 tuner */ | 218 | /* XC3028 tuner */ |
205 | { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, | 219 | { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, |
diff --git a/drivers/media/video/cx18/cx18-cards.h b/drivers/media/video/cx18/cx18-cards.h index bccb67f0db16..dc2dd945d4c3 100644 --- a/drivers/media/video/cx18/cx18-cards.h +++ b/drivers/media/video/cx18/cx18-cards.h | |||
@@ -36,36 +36,6 @@ | |||
36 | #define CX18_CARD_INPUT_COMPOSITE2 5 | 36 | #define CX18_CARD_INPUT_COMPOSITE2 5 |
37 | #define CX18_CARD_INPUT_COMPOSITE3 6 | 37 | #define CX18_CARD_INPUT_COMPOSITE3 6 |
38 | 38 | ||
39 | enum cx34180_video_input { | ||
40 | /* Composite video inputs In1-In8 */ | ||
41 | CX23418_COMPOSITE1 = 1, | ||
42 | CX23418_COMPOSITE2, | ||
43 | CX23418_COMPOSITE3, | ||
44 | CX23418_COMPOSITE4, | ||
45 | CX23418_COMPOSITE5, | ||
46 | CX23418_COMPOSITE6, | ||
47 | CX23418_COMPOSITE7, | ||
48 | CX23418_COMPOSITE8, | ||
49 | |||
50 | /* S-Video inputs consist of one luma input (In1-In4) ORed with one | ||
51 | chroma input (In5-In8) */ | ||
52 | CX23418_SVIDEO_LUMA1 = 0x10, | ||
53 | CX23418_SVIDEO_LUMA2 = 0x20, | ||
54 | CX23418_SVIDEO_LUMA3 = 0x30, | ||
55 | CX23418_SVIDEO_LUMA4 = 0x40, | ||
56 | CX23418_SVIDEO_CHROMA4 = 0x400, | ||
57 | CX23418_SVIDEO_CHROMA5 = 0x500, | ||
58 | CX23418_SVIDEO_CHROMA6 = 0x600, | ||
59 | CX23418_SVIDEO_CHROMA7 = 0x700, | ||
60 | CX23418_SVIDEO_CHROMA8 = 0x800, | ||
61 | |||
62 | /* S-Video aliases for common luma/chroma combinations */ | ||
63 | CX23418_SVIDEO1 = 0x510, | ||
64 | CX23418_SVIDEO2 = 0x620, | ||
65 | CX23418_SVIDEO3 = 0x730, | ||
66 | CX23418_SVIDEO4 = 0x840, | ||
67 | }; | ||
68 | |||
69 | /* audio inputs */ | 39 | /* audio inputs */ |
70 | #define CX18_CARD_INPUT_AUD_TUNER 1 | 40 | #define CX18_CARD_INPUT_AUD_TUNER 1 |
71 | #define CX18_CARD_INPUT_LINE_IN1 2 | 41 | #define CX18_CARD_INPUT_LINE_IN1 2 |
@@ -75,16 +45,6 @@ enum cx34180_video_input { | |||
75 | #define CX18_CARD_MAX_AUDIO_INPUTS 3 | 45 | #define CX18_CARD_MAX_AUDIO_INPUTS 3 |
76 | #define CX18_CARD_MAX_TUNERS 2 | 46 | #define CX18_CARD_MAX_TUNERS 2 |
77 | 47 | ||
78 | enum cx23418_audio_input { | ||
79 | /* Audio inputs: serial or In4-In8 */ | ||
80 | CX23418_AUDIO_SERIAL, | ||
81 | CX23418_AUDIO4 = 4, | ||
82 | CX23418_AUDIO5, | ||
83 | CX23418_AUDIO6, | ||
84 | CX23418_AUDIO7, | ||
85 | CX23418_AUDIO8, | ||
86 | }; | ||
87 | |||
88 | /* V4L2 capability aliases */ | 48 | /* V4L2 capability aliases */ |
89 | #define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \ | 49 | #define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \ |
90 | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE) | 50 | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE) |
@@ -118,6 +78,13 @@ struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */ | |||
118 | u32 initial_value; | 78 | u32 initial_value; |
119 | }; | 79 | }; |
120 | 80 | ||
81 | struct cx18_gpio_i2c_slave_reset { | ||
82 | u32 active_lo_mask; /* GPIO outputs that reset i2c chips when low */ | ||
83 | u32 active_hi_mask; /* GPIO outputs that reset i2c chips when high */ | ||
84 | int msecs_asserted; /* time period reset must remain asserted */ | ||
85 | int msecs_recovery; /* time after deassert for chips to be ready */ | ||
86 | }; | ||
87 | |||
121 | struct cx18_card_tuner { | 88 | struct cx18_card_tuner { |
122 | v4l2_std_id std; /* standard for which the tuner is suitable */ | 89 | v4l2_std_id std; /* standard for which the tuner is suitable */ |
123 | int tuner; /* tuner ID (from tuner.h) */ | 90 | int tuner; /* tuner ID (from tuner.h) */ |
@@ -154,7 +121,8 @@ struct cx18_card { | |||
154 | 121 | ||
155 | /* GPIO card-specific settings */ | 122 | /* GPIO card-specific settings */ |
156 | u8 xceive_pin; /* XCeive tuner GPIO reset pin */ | 123 | u8 xceive_pin; /* XCeive tuner GPIO reset pin */ |
157 | struct cx18_gpio_init gpio_init; | 124 | struct cx18_gpio_init gpio_init; |
125 | struct cx18_gpio_i2c_slave_reset gpio_i2c_slave_reset; | ||
158 | 126 | ||
159 | struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; | 127 | struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; |
160 | struct cx18_card_tuner_i2c *i2c; | 128 | struct cx18_card_tuner_i2c *i2c; |
diff --git a/drivers/media/video/cx18/cx18-controls.c b/drivers/media/video/cx18/cx18-controls.c index 2bdac5ebbb0d..87cf41021665 100644 --- a/drivers/media/video/cx18/cx18-controls.c +++ b/drivers/media/video/cx18/cx18-controls.c | |||
@@ -159,7 +159,7 @@ static int cx18_setup_vbi_fmt(struct cx18 *cx, enum v4l2_mpeg_stream_vbi_fmt fmt | |||
159 | { | 159 | { |
160 | if (!(cx->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE)) | 160 | if (!(cx->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE)) |
161 | return -EINVAL; | 161 | return -EINVAL; |
162 | if (atomic_read(&cx->capturing) > 0) | 162 | if (atomic_read(&cx->ana_capturing) > 0) |
163 | return -EBUSY; | 163 | return -EBUSY; |
164 | 164 | ||
165 | /* First try to allocate sliced VBI buffers if needed. */ | 165 | /* First try to allocate sliced VBI buffers if needed. */ |
@@ -235,7 +235,7 @@ int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg) | |||
235 | CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n"); | 235 | CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n"); |
236 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) { | 236 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) { |
237 | struct cx2341x_mpeg_params p = cx->params; | 237 | struct cx2341x_mpeg_params p = cx->params; |
238 | int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->capturing), arg, cmd); | 238 | int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->ana_capturing), arg, cmd); |
239 | 239 | ||
240 | if (err) | 240 | if (err) |
241 | return err; | 241 | return err; |
@@ -295,7 +295,7 @@ int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg) | |||
295 | CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n"); | 295 | CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n"); |
296 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) | 296 | if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) |
297 | return cx2341x_ext_ctrls(&cx->params, | 297 | return cx2341x_ext_ctrls(&cx->params, |
298 | atomic_read(&cx->capturing), arg, cmd); | 298 | atomic_read(&cx->ana_capturing), arg, cmd); |
299 | return -EINVAL; | 299 | return -EINVAL; |
300 | } | 300 | } |
301 | 301 | ||
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c index 0dd4e0529970..2b810bb2a4c7 100644 --- a/drivers/media/video/cx18/cx18-driver.c +++ b/drivers/media/video/cx18/cx18-driver.c | |||
@@ -670,7 +670,7 @@ static int __devinit cx18_probe(struct pci_dev *dev, | |||
670 | cx18_init_power(cx, 1); | 670 | cx18_init_power(cx, 1); |
671 | cx18_init_memory(cx); | 671 | cx18_init_memory(cx); |
672 | 672 | ||
673 | cx->scb = (struct cx18_scb *)(cx->enc_mem + SCB_OFFSET); | 673 | cx->scb = (struct cx18_scb __iomem *)(cx->enc_mem + SCB_OFFSET); |
674 | cx18_init_scb(cx); | 674 | cx18_init_scb(cx); |
675 | 675 | ||
676 | cx18_gpio_init(cx); | 676 | cx18_gpio_init(cx); |
@@ -751,17 +751,6 @@ static int __devinit cx18_probe(struct pci_dev *dev, | |||
751 | if (cx->options.radio > 0) | 751 | if (cx->options.radio > 0) |
752 | cx->v4l2_cap |= V4L2_CAP_RADIO; | 752 | cx->v4l2_cap |= V4L2_CAP_RADIO; |
753 | 753 | ||
754 | retval = cx18_streams_setup(cx); | ||
755 | if (retval) { | ||
756 | CX18_ERR("Error %d setting up streams\n", retval); | ||
757 | goto free_irq; | ||
758 | } | ||
759 | retval = cx18_streams_register(cx); | ||
760 | if (retval) { | ||
761 | CX18_ERR("Error %d registering devices\n", retval); | ||
762 | goto free_streams; | ||
763 | } | ||
764 | |||
765 | if (cx->options.tuner > -1) { | 754 | if (cx->options.tuner > -1) { |
766 | struct tuner_setup setup; | 755 | struct tuner_setup setup; |
767 | 756 | ||
@@ -788,7 +777,16 @@ static int __devinit cx18_probe(struct pci_dev *dev, | |||
788 | are not. */ | 777 | are not. */ |
789 | cx->tuner_std = cx->std; | 778 | cx->tuner_std = cx->std; |
790 | 779 | ||
791 | cx18_init_on_first_open(cx); | 780 | retval = cx18_streams_setup(cx); |
781 | if (retval) { | ||
782 | CX18_ERR("Error %d setting up streams\n", retval); | ||
783 | goto free_irq; | ||
784 | } | ||
785 | retval = cx18_streams_register(cx); | ||
786 | if (retval) { | ||
787 | CX18_ERR("Error %d registering devices\n", retval); | ||
788 | goto free_streams; | ||
789 | } | ||
792 | 790 | ||
793 | CX18_INFO("Initialized card #%d: %s\n", cx->num, cx->card_name); | 791 | CX18_INFO("Initialized card #%d: %s\n", cx->num, cx->card_name); |
794 | 792 | ||
@@ -889,7 +887,7 @@ static void cx18_remove(struct pci_dev *pci_dev) | |||
889 | 887 | ||
890 | /* Stop all captures */ | 888 | /* Stop all captures */ |
891 | CX18_DEBUG_INFO("Stopping all streams\n"); | 889 | CX18_DEBUG_INFO("Stopping all streams\n"); |
892 | if (atomic_read(&cx->capturing) > 0) | 890 | if (atomic_read(&cx->tot_capturing) > 0) |
893 | cx18_stop_all_captures(cx); | 891 | cx18_stop_all_captures(cx); |
894 | 892 | ||
895 | /* Interrupts */ | 893 | /* Interrupts */ |
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h index a2a6c58d12fe..de14ab59a206 100644 --- a/drivers/media/video/cx18/cx18-driver.h +++ b/drivers/media/video/cx18/cx18-driver.h | |||
@@ -358,7 +358,7 @@ struct cx18 { | |||
358 | u32 v4l2_cap; /* V4L2 capabilities of card */ | 358 | u32 v4l2_cap; /* V4L2 capabilities of card */ |
359 | u32 hw_flags; /* Hardware description of the board */ | 359 | u32 hw_flags; /* Hardware description of the board */ |
360 | unsigned mdl_offset; | 360 | unsigned mdl_offset; |
361 | struct cx18_scb *scb; /* pointer to SCB */ | 361 | struct cx18_scb __iomem *scb; /* pointer to SCB */ |
362 | 362 | ||
363 | struct cx18_av_state av_state; | 363 | struct cx18_av_state av_state; |
364 | 364 | ||
@@ -380,7 +380,8 @@ struct cx18 { | |||
380 | int stream_buf_size[CX18_MAX_STREAMS]; /* Stream buffer size */ | 380 | int stream_buf_size[CX18_MAX_STREAMS]; /* Stream buffer size */ |
381 | struct cx18_stream streams[CX18_MAX_STREAMS]; /* Stream data */ | 381 | struct cx18_stream streams[CX18_MAX_STREAMS]; /* Stream data */ |
382 | unsigned long i_flags; /* global cx18 flags */ | 382 | unsigned long i_flags; /* global cx18 flags */ |
383 | atomic_t capturing; /* count number of active capture streams */ | 383 | atomic_t ana_capturing; /* count number of active analog capture streams */ |
384 | atomic_t tot_capturing; /* total count number of active capture streams */ | ||
384 | spinlock_t lock; /* lock access to this struct */ | 385 | spinlock_t lock; /* lock access to this struct */ |
385 | int search_pack_header; | 386 | int search_pack_header; |
386 | 387 | ||
@@ -423,6 +424,10 @@ struct cx18 { | |||
423 | struct mutex i2c_bus_lock[2]; | 424 | struct mutex i2c_bus_lock[2]; |
424 | struct i2c_client *i2c_clients[I2C_CLIENTS_MAX]; | 425 | struct i2c_client *i2c_clients[I2C_CLIENTS_MAX]; |
425 | 426 | ||
427 | /* gpio */ | ||
428 | u32 gpio_dir; | ||
429 | u32 gpio_val; | ||
430 | |||
426 | /* v4l2 and User settings */ | 431 | /* v4l2 and User settings */ |
427 | 432 | ||
428 | /* codec settings */ | 433 | /* codec settings */ |
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c index c9744173f969..cae38985b131 100644 --- a/drivers/media/video/cx18/cx18-dvb.c +++ b/drivers/media/video/cx18/cx18-dvb.c | |||
@@ -69,11 +69,21 @@ static int cx18_dvb_start_feed(struct dvb_demux_feed *feed) | |||
69 | struct dvb_demux *demux = feed->demux; | 69 | struct dvb_demux *demux = feed->demux; |
70 | struct cx18_stream *stream = (struct cx18_stream *) demux->priv; | 70 | struct cx18_stream *stream = (struct cx18_stream *) demux->priv; |
71 | struct cx18 *cx = stream->cx; | 71 | struct cx18 *cx = stream->cx; |
72 | int ret = -EINVAL; | 72 | int ret; |
73 | u32 v; | 73 | u32 v; |
74 | 74 | ||
75 | CX18_DEBUG_INFO("Start feed: pid = 0x%x index = %d\n", | 75 | CX18_DEBUG_INFO("Start feed: pid = 0x%x index = %d\n", |
76 | feed->pid, feed->index); | 76 | feed->pid, feed->index); |
77 | |||
78 | mutex_lock(&cx->serialize_lock); | ||
79 | ret = cx18_init_on_first_open(cx); | ||
80 | mutex_unlock(&cx->serialize_lock); | ||
81 | if (ret) { | ||
82 | CX18_ERR("Failed to initialize firmware starting DVB feed\n"); | ||
83 | return ret; | ||
84 | } | ||
85 | ret = -EINVAL; | ||
86 | |||
77 | switch (cx->card->type) { | 87 | switch (cx->card->type) { |
78 | case CX18_CARD_HVR_1600_ESMT: | 88 | case CX18_CARD_HVR_1600_ESMT: |
79 | case CX18_CARD_HVR_1600_SAMSUNG: | 89 | case CX18_CARD_HVR_1600_SAMSUNG: |
@@ -101,6 +111,11 @@ static int cx18_dvb_start_feed(struct dvb_demux_feed *feed) | |||
101 | if (stream->dvb.feeding++ == 0) { | 111 | if (stream->dvb.feeding++ == 0) { |
102 | CX18_DEBUG_INFO("Starting Transport DMA\n"); | 112 | CX18_DEBUG_INFO("Starting Transport DMA\n"); |
103 | ret = cx18_start_v4l2_encode_stream(stream); | 113 | ret = cx18_start_v4l2_encode_stream(stream); |
114 | if (ret < 0) { | ||
115 | CX18_DEBUG_INFO( | ||
116 | "Failed to start Transport DMA\n"); | ||
117 | stream->dvb.feeding--; | ||
118 | } | ||
104 | } else | 119 | } else |
105 | ret = 0; | 120 | ret = 0; |
106 | mutex_unlock(&stream->dvb.feedlock); | 121 | mutex_unlock(&stream->dvb.feedlock); |
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c index 0b3141db174b..1e537fe04a23 100644 --- a/drivers/media/video/cx18/cx18-fileops.c +++ b/drivers/media/video/cx18/cx18-fileops.c | |||
@@ -318,7 +318,7 @@ static ssize_t cx18_read(struct cx18_stream *s, char __user *ubuf, | |||
318 | size_t tot_written = 0; | 318 | size_t tot_written = 0; |
319 | int single_frame = 0; | 319 | int single_frame = 0; |
320 | 320 | ||
321 | if (atomic_read(&cx->capturing) == 0 && s->id == -1) { | 321 | if (atomic_read(&cx->ana_capturing) == 0 && s->id == -1) { |
322 | /* shouldn't happen */ | 322 | /* shouldn't happen */ |
323 | CX18_DEBUG_WARN("Stream %s not initialized before read\n", | 323 | CX18_DEBUG_WARN("Stream %s not initialized before read\n", |
324 | s->name); | 324 | s->name); |
@@ -361,7 +361,8 @@ static ssize_t cx18_read(struct cx18_stream *s, char __user *ubuf, | |||
361 | cx18_enqueue(s, buf, &s->q_free); | 361 | cx18_enqueue(s, buf, &s->q_free); |
362 | cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, | 362 | cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, |
363 | s->handle, | 363 | s->handle, |
364 | (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, | 364 | (void __iomem *)&cx->scb->cpu_mdl[buf->id] - |
365 | cx->enc_mem, | ||
365 | 1, buf->id, s->buf_size); | 366 | 1, buf->id, s->buf_size); |
366 | } else | 367 | } else |
367 | cx18_enqueue(s, buf, &s->q_io); | 368 | cx18_enqueue(s, buf, &s->q_io); |
@@ -581,7 +582,7 @@ int cx18_v4l2_close(struct inode *inode, struct file *filp) | |||
581 | cx18_call_i2c_clients(cx, VIDIOC_S_STD, &cx->std); | 582 | cx18_call_i2c_clients(cx, VIDIOC_S_STD, &cx->std); |
582 | /* Select correct audio input (i.e. TV tuner or Line in) */ | 583 | /* Select correct audio input (i.e. TV tuner or Line in) */ |
583 | cx18_audio_set_io(cx); | 584 | cx18_audio_set_io(cx); |
584 | if (atomic_read(&cx->capturing) > 0) { | 585 | if (atomic_read(&cx->ana_capturing) > 0) { |
585 | /* Undo video mute */ | 586 | /* Undo video mute */ |
586 | cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle, | 587 | cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle, |
587 | cx->params.video_mute | | 588 | cx->params.video_mute | |
@@ -627,7 +628,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) | |||
627 | } | 628 | } |
628 | 629 | ||
629 | if (!test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { | 630 | if (!test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { |
630 | if (atomic_read(&cx->capturing) > 0) { | 631 | if (atomic_read(&cx->ana_capturing) > 0) { |
631 | /* switching to radio while capture is | 632 | /* switching to radio while capture is |
632 | in progress is not polite */ | 633 | in progress is not polite */ |
633 | cx18_release_stream(s); | 634 | cx18_release_stream(s); |
@@ -694,7 +695,7 @@ int cx18_v4l2_open(struct inode *inode, struct file *filp) | |||
694 | 695 | ||
695 | void cx18_mute(struct cx18 *cx) | 696 | void cx18_mute(struct cx18 *cx) |
696 | { | 697 | { |
697 | if (atomic_read(&cx->capturing)) | 698 | if (atomic_read(&cx->ana_capturing)) |
698 | cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, | 699 | cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, |
699 | cx18_find_handle(cx), 1); | 700 | cx18_find_handle(cx), 1); |
700 | CX18_DEBUG_INFO("Mute\n"); | 701 | CX18_DEBUG_INFO("Mute\n"); |
@@ -702,7 +703,7 @@ void cx18_mute(struct cx18 *cx) | |||
702 | 703 | ||
703 | void cx18_unmute(struct cx18 *cx) | 704 | void cx18_unmute(struct cx18 *cx) |
704 | { | 705 | { |
705 | if (atomic_read(&cx->capturing)) { | 706 | if (atomic_read(&cx->ana_capturing)) { |
706 | cx18_msleep_timeout(100, 0); | 707 | cx18_msleep_timeout(100, 0); |
707 | cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2, | 708 | cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2, |
708 | cx18_find_handle(cx), 12); | 709 | cx18_find_handle(cx), 12); |
diff --git a/drivers/media/video/cx18/cx18-gpio.c b/drivers/media/video/cx18/cx18-gpio.c index bb8bc86086d0..b302833f6f9d 100644 --- a/drivers/media/video/cx18/cx18-gpio.c +++ b/drivers/media/video/cx18/cx18-gpio.c | |||
@@ -35,9 +35,6 @@ | |||
35 | #define CX18_REG_GPIO_OUT2 0xc78104 | 35 | #define CX18_REG_GPIO_OUT2 0xc78104 |
36 | #define CX18_REG_GPIO_DIR2 0xc7810c | 36 | #define CX18_REG_GPIO_DIR2 0xc7810c |
37 | 37 | ||
38 | static u32 gpio_dir; | ||
39 | static u32 gpio_val; | ||
40 | |||
41 | /* | 38 | /* |
42 | * HVR-1600 GPIO pins, courtesy of Hauppauge: | 39 | * HVR-1600 GPIO pins, courtesy of Hauppauge: |
43 | * | 40 | * |
@@ -49,24 +46,53 @@ static u32 gpio_val; | |||
49 | 46 | ||
50 | static void gpio_write(struct cx18 *cx) | 47 | static void gpio_write(struct cx18 *cx) |
51 | { | 48 | { |
52 | write_reg((gpio_dir & 0xffff) << 16, CX18_REG_GPIO_DIR1); | 49 | u32 dir = cx->gpio_dir; |
53 | write_reg(((gpio_dir & 0xffff) << 16) | (gpio_val & 0xffff), | 50 | u32 val = cx->gpio_val; |
51 | |||
52 | write_reg((dir & 0xffff) << 16, CX18_REG_GPIO_DIR1); | ||
53 | write_reg(((dir & 0xffff) << 16) | (val & 0xffff), | ||
54 | CX18_REG_GPIO_OUT1); | 54 | CX18_REG_GPIO_OUT1); |
55 | write_reg(gpio_dir & 0xffff0000, CX18_REG_GPIO_DIR2); | 55 | write_reg(dir & 0xffff0000, CX18_REG_GPIO_DIR2); |
56 | write_reg((gpio_dir & 0xffff0000) | ((gpio_val & 0xffff0000) >> 16), | 56 | write_reg_sync((dir & 0xffff0000) | ((val & 0xffff0000) >> 16), |
57 | CX18_REG_GPIO_OUT2); | 57 | CX18_REG_GPIO_OUT2); |
58 | } | 58 | } |
59 | 59 | ||
60 | void cx18_gpio_init(struct cx18 *cx) | 60 | void cx18_reset_i2c_slaves_gpio(struct cx18 *cx) |
61 | { | 61 | { |
62 | gpio_dir = cx->card->gpio_init.direction; | 62 | const struct cx18_gpio_i2c_slave_reset *p; |
63 | gpio_val = cx->card->gpio_init.initial_value; | 63 | |
64 | p = &cx->card->gpio_i2c_slave_reset; | ||
64 | 65 | ||
65 | if (gpio_dir == 0) | 66 | if ((p->active_lo_mask | p->active_hi_mask) == 0) |
66 | return; | 67 | return; |
67 | 68 | ||
68 | gpio_dir |= 1 << cx->card->xceive_pin; | 69 | /* Assuming that the masks are a subset of the bits in gpio_dir */ |
69 | gpio_val |= 1 << cx->card->xceive_pin; | 70 | |
71 | /* Assert */ | ||
72 | cx->gpio_val = | ||
73 | (cx->gpio_val | p->active_hi_mask) & ~(p->active_lo_mask); | ||
74 | gpio_write(cx); | ||
75 | schedule_timeout_uninterruptible(msecs_to_jiffies(p->msecs_asserted)); | ||
76 | |||
77 | /* Deassert */ | ||
78 | cx->gpio_val = | ||
79 | (cx->gpio_val | p->active_lo_mask) & ~(p->active_hi_mask); | ||
80 | gpio_write(cx); | ||
81 | schedule_timeout_uninterruptible(msecs_to_jiffies(p->msecs_recovery)); | ||
82 | } | ||
83 | |||
84 | void cx18_gpio_init(struct cx18 *cx) | ||
85 | { | ||
86 | cx->gpio_dir = cx->card->gpio_init.direction; | ||
87 | cx->gpio_val = cx->card->gpio_init.initial_value; | ||
88 | |||
89 | if (cx->card->tuners[0].tuner == TUNER_XC2028) { | ||
90 | cx->gpio_dir |= 1 << cx->card->xceive_pin; | ||
91 | cx->gpio_val |= 1 << cx->card->xceive_pin; | ||
92 | } | ||
93 | |||
94 | if (cx->gpio_dir == 0) | ||
95 | return; | ||
70 | 96 | ||
71 | CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n", | 97 | CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n", |
72 | read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_DIR2), | 98 | read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_DIR2), |
@@ -86,13 +112,12 @@ int cx18_reset_tuner_gpio(void *dev, int cmd, int value) | |||
86 | return 0; | 112 | return 0; |
87 | CX18_DEBUG_INFO("Resetting tuner\n"); | 113 | CX18_DEBUG_INFO("Resetting tuner\n"); |
88 | 114 | ||
89 | gpio_dir |= 1 << cx->card->xceive_pin; | 115 | cx->gpio_val &= ~(1 << cx->card->xceive_pin); |
90 | gpio_val &= ~(1 << cx->card->xceive_pin); | ||
91 | 116 | ||
92 | gpio_write(cx); | 117 | gpio_write(cx); |
93 | schedule_timeout_interruptible(msecs_to_jiffies(1)); | 118 | schedule_timeout_interruptible(msecs_to_jiffies(1)); |
94 | 119 | ||
95 | gpio_val |= 1 << cx->card->xceive_pin; | 120 | cx->gpio_val |= 1 << cx->card->xceive_pin; |
96 | gpio_write(cx); | 121 | gpio_write(cx); |
97 | schedule_timeout_interruptible(msecs_to_jiffies(1)); | 122 | schedule_timeout_interruptible(msecs_to_jiffies(1)); |
98 | return 0; | 123 | return 0; |
diff --git a/drivers/media/video/cx18/cx18-gpio.h b/drivers/media/video/cx18/cx18-gpio.h index 41bac8856b50..525c328f748a 100644 --- a/drivers/media/video/cx18/cx18-gpio.h +++ b/drivers/media/video/cx18/cx18-gpio.h | |||
@@ -21,4 +21,5 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | void cx18_gpio_init(struct cx18 *cx); | 23 | void cx18_gpio_init(struct cx18 *cx); |
24 | void cx18_reset_i2c_slaves_gpio(struct cx18 *cx); | ||
24 | int cx18_reset_tuner_gpio(void *dev, int cmd, int value); | 25 | int cx18_reset_tuner_gpio(void *dev, int cmd, int value); |
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c index 1d6c51a75313..680bc4e35b79 100644 --- a/drivers/media/video/cx18/cx18-i2c.c +++ b/drivers/media/video/cx18/cx18-i2c.c | |||
@@ -405,6 +405,8 @@ int init_cx18_i2c(struct cx18 *cx) | |||
405 | cx18_setscl(&cx->i2c_algo_cb_data[1], 1); | 405 | cx18_setscl(&cx->i2c_algo_cb_data[1], 1); |
406 | cx18_setsda(&cx->i2c_algo_cb_data[1], 1); | 406 | cx18_setsda(&cx->i2c_algo_cb_data[1], 1); |
407 | 407 | ||
408 | cx18_reset_i2c_slaves_gpio(cx); | ||
409 | |||
408 | return i2c_bit_add_bus(&cx->i2c_adap[0]) || | 410 | return i2c_bit_add_bus(&cx->i2c_adap[0]) || |
409 | i2c_bit_add_bus(&cx->i2c_adap[1]); | 411 | i2c_bit_add_bus(&cx->i2c_adap[1]); |
410 | } | 412 | } |
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c index dbdcb86ec5aa..4151f1e5493f 100644 --- a/drivers/media/video/cx18/cx18-ioctl.c +++ b/drivers/media/video/cx18/cx18-ioctl.c | |||
@@ -247,7 +247,7 @@ static int cx18_try_or_set_fmt(struct cx18 *cx, int streamtype, | |||
247 | 247 | ||
248 | if (!set_fmt || (cx->params.width == w && cx->params.height == h)) | 248 | if (!set_fmt || (cx->params.width == w && cx->params.height == h)) |
249 | return 0; | 249 | return 0; |
250 | if (atomic_read(&cx->capturing) > 0) | 250 | if (atomic_read(&cx->ana_capturing) > 0) |
251 | return -EBUSY; | 251 | return -EBUSY; |
252 | 252 | ||
253 | cx->params.width = w; | 253 | cx->params.width = w; |
@@ -264,7 +264,7 @@ static int cx18_try_or_set_fmt(struct cx18 *cx, int streamtype, | |||
264 | if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | 264 | if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) { |
265 | if (set_fmt && streamtype == CX18_ENC_STREAM_TYPE_VBI && | 265 | if (set_fmt && streamtype == CX18_ENC_STREAM_TYPE_VBI && |
266 | cx->vbi.sliced_in->service_set && | 266 | cx->vbi.sliced_in->service_set && |
267 | atomic_read(&cx->capturing) > 0) | 267 | atomic_read(&cx->ana_capturing) > 0) |
268 | return -EBUSY; | 268 | return -EBUSY; |
269 | if (set_fmt) { | 269 | if (set_fmt) { |
270 | cx->vbi.sliced_in->service_set = 0; | 270 | cx->vbi.sliced_in->service_set = 0; |
@@ -293,7 +293,7 @@ static int cx18_try_or_set_fmt(struct cx18 *cx, int streamtype, | |||
293 | return 0; | 293 | return 0; |
294 | if (set == 0) | 294 | if (set == 0) |
295 | return -EINVAL; | 295 | return -EINVAL; |
296 | if (atomic_read(&cx->capturing) > 0 && cx->vbi.sliced_in->service_set == 0) | 296 | if (atomic_read(&cx->ana_capturing) > 0 && cx->vbi.sliced_in->service_set == 0) |
297 | return -EBUSY; | 297 | return -EBUSY; |
298 | cx18_av_cmd(cx, VIDIOC_S_FMT, fmt); | 298 | cx18_av_cmd(cx, VIDIOC_S_FMT, fmt); |
299 | memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in)); | 299 | memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in)); |
@@ -581,7 +581,7 @@ int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, void *arg | |||
581 | break; | 581 | break; |
582 | 582 | ||
583 | if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) || | 583 | if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) || |
584 | atomic_read(&cx->capturing) > 0) { | 584 | atomic_read(&cx->ana_capturing) > 0) { |
585 | /* Switching standard would turn off the radio or mess | 585 | /* Switching standard would turn off the radio or mess |
586 | with already running streams, prevent that by | 586 | with already running streams, prevent that by |
587 | returning EBUSY. */ | 587 | returning EBUSY. */ |
@@ -677,7 +677,7 @@ int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, void *arg | |||
677 | enc->flags = 0; | 677 | enc->flags = 0; |
678 | if (try) | 678 | if (try) |
679 | return 0; | 679 | return 0; |
680 | if (!atomic_read(&cx->capturing)) | 680 | if (!atomic_read(&cx->ana_capturing)) |
681 | return -EPERM; | 681 | return -EPERM; |
682 | if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) | 682 | if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) |
683 | return 0; | 683 | return 0; |
@@ -689,7 +689,7 @@ int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, void *arg | |||
689 | enc->flags = 0; | 689 | enc->flags = 0; |
690 | if (try) | 690 | if (try) |
691 | return 0; | 691 | return 0; |
692 | if (!atomic_read(&cx->capturing)) | 692 | if (!atomic_read(&cx->ana_capturing)) |
693 | return -EPERM; | 693 | return -EPERM; |
694 | if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) | 694 | if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) |
695 | return 0; | 695 | return 0; |
diff --git a/drivers/media/video/cx18/cx18-irq.c b/drivers/media/video/cx18/cx18-irq.c index 6e14f8bda559..25114a5cbd57 100644 --- a/drivers/media/video/cx18/cx18-irq.c +++ b/drivers/media/video/cx18/cx18-irq.c | |||
@@ -75,7 +75,7 @@ static void epu_dma_done(struct cx18 *cx, struct cx18_mailbox *mb) | |||
75 | 75 | ||
76 | cx18_buf_sync_for_device(s, buf); | 76 | cx18_buf_sync_for_device(s, buf); |
77 | cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, | 77 | cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, |
78 | (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, | 78 | (void __iomem *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, |
79 | 1, buf->id, s->buf_size); | 79 | 1, buf->id, s->buf_size); |
80 | } else | 80 | } else |
81 | set_bit(CX18_F_B_NEED_BUF_SWAP, &buf->b_flags); | 81 | set_bit(CX18_F_B_NEED_BUF_SWAP, &buf->b_flags); |
@@ -161,13 +161,15 @@ irqreturn_t cx18_irq_handler(int irq, void *dev_id) | |||
161 | */ | 161 | */ |
162 | 162 | ||
163 | if (sw2) { | 163 | if (sw2) { |
164 | if (sw2 & (cx->scb->cpu2hpu_irq_ack | cx->scb->cpu2epu_irq_ack)) | 164 | if (sw2 & (readl(&cx->scb->cpu2hpu_irq_ack) | |
165 | readl(&cx->scb->cpu2epu_irq_ack))) | ||
165 | wake_up(&cx->mb_cpu_waitq); | 166 | wake_up(&cx->mb_cpu_waitq); |
166 | if (sw2 & (cx->scb->apu2hpu_irq_ack | cx->scb->apu2epu_irq_ack)) | 167 | if (sw2 & (readl(&cx->scb->apu2hpu_irq_ack) | |
168 | readl(&cx->scb->apu2epu_irq_ack))) | ||
167 | wake_up(&cx->mb_apu_waitq); | 169 | wake_up(&cx->mb_apu_waitq); |
168 | if (sw2 & cx->scb->epu2hpu_irq_ack) | 170 | if (sw2 & readl(&cx->scb->epu2hpu_irq_ack)) |
169 | wake_up(&cx->mb_epu_waitq); | 171 | wake_up(&cx->mb_epu_waitq); |
170 | if (sw2 & cx->scb->hpu2epu_irq_ack) | 172 | if (sw2 & readl(&cx->scb->hpu2epu_irq_ack)) |
171 | wake_up(&cx->mb_hpu_waitq); | 173 | wake_up(&cx->mb_hpu_waitq); |
172 | } | 174 | } |
173 | 175 | ||
diff --git a/drivers/media/video/cx18/cx18-mailbox.c b/drivers/media/video/cx18/cx18-mailbox.c index 0c5f328bca54..2a5ccef9185b 100644 --- a/drivers/media/video/cx18/cx18-mailbox.c +++ b/drivers/media/video/cx18/cx18-mailbox.c | |||
@@ -94,10 +94,10 @@ static const struct cx18_api_info *find_api_info(u32 cmd) | |||
94 | return NULL; | 94 | return NULL; |
95 | } | 95 | } |
96 | 96 | ||
97 | static struct cx18_mailbox *cx18_mb_is_complete(struct cx18 *cx, int rpu, | 97 | static struct cx18_mailbox __iomem *cx18_mb_is_complete(struct cx18 *cx, int rpu, |
98 | u32 *state, u32 *irq, u32 *req) | 98 | u32 *state, u32 *irq, u32 *req) |
99 | { | 99 | { |
100 | struct cx18_mailbox *mb = NULL; | 100 | struct cx18_mailbox __iomem *mb = NULL; |
101 | int wait_count = 0; | 101 | int wait_count = 0; |
102 | u32 ack; | 102 | u32 ack; |
103 | 103 | ||
@@ -142,7 +142,7 @@ static struct cx18_mailbox *cx18_mb_is_complete(struct cx18 *cx, int rpu, | |||
142 | long cx18_mb_ack(struct cx18 *cx, const struct cx18_mailbox *mb) | 142 | long cx18_mb_ack(struct cx18 *cx, const struct cx18_mailbox *mb) |
143 | { | 143 | { |
144 | const struct cx18_api_info *info = find_api_info(mb->cmd); | 144 | const struct cx18_api_info *info = find_api_info(mb->cmd); |
145 | struct cx18_mailbox *ack_mb; | 145 | struct cx18_mailbox __iomem *ack_mb; |
146 | u32 ack_irq; | 146 | u32 ack_irq; |
147 | u8 rpu = CPU; | 147 | u8 rpu = CPU; |
148 | 148 | ||
@@ -182,7 +182,7 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[]) | |||
182 | { | 182 | { |
183 | const struct cx18_api_info *info = find_api_info(cmd); | 183 | const struct cx18_api_info *info = find_api_info(cmd); |
184 | u32 state = 0, irq = 0, req, oldreq, err; | 184 | u32 state = 0, irq = 0, req, oldreq, err; |
185 | struct cx18_mailbox *mb; | 185 | struct cx18_mailbox __iomem *mb; |
186 | wait_queue_head_t *waitq; | 186 | wait_queue_head_t *waitq; |
187 | int timeout = 100; | 187 | int timeout = 100; |
188 | int cnt = 0; | 188 | int cnt = 0; |
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c index 4ca9d847f1b1..1b921a336092 100644 --- a/drivers/media/video/cx18/cx18-streams.c +++ b/drivers/media/video/cx18/cx18-streams.c | |||
@@ -36,12 +36,13 @@ | |||
36 | #define CX18_DSP0_INTERRUPT_MASK 0xd0004C | 36 | #define CX18_DSP0_INTERRUPT_MASK 0xd0004C |
37 | 37 | ||
38 | static struct file_operations cx18_v4l2_enc_fops = { | 38 | static struct file_operations cx18_v4l2_enc_fops = { |
39 | .owner = THIS_MODULE, | 39 | .owner = THIS_MODULE, |
40 | .read = cx18_v4l2_read, | 40 | .read = cx18_v4l2_read, |
41 | .open = cx18_v4l2_open, | 41 | .open = cx18_v4l2_open, |
42 | .ioctl = cx18_v4l2_ioctl, | 42 | .ioctl = cx18_v4l2_ioctl, |
43 | .release = cx18_v4l2_close, | 43 | .compat_ioctl = v4l_compat_ioctl32, |
44 | .poll = cx18_v4l2_enc_poll, | 44 | .release = cx18_v4l2_close, |
45 | .poll = cx18_v4l2_enc_poll, | ||
45 | }; | 46 | }; |
46 | 47 | ||
47 | /* offset from 0 to register ts v4l2 minors on */ | 48 | /* offset from 0 to register ts v4l2 minors on */ |
@@ -443,7 +444,7 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s) | |||
443 | s->handle = data[0]; | 444 | s->handle = data[0]; |
444 | cx18_vapi(cx, CX18_CPU_SET_CHANNEL_TYPE, 2, s->handle, captype); | 445 | cx18_vapi(cx, CX18_CPU_SET_CHANNEL_TYPE, 2, s->handle, captype); |
445 | 446 | ||
446 | if (atomic_read(&cx->capturing) == 0 && !ts) { | 447 | if (atomic_read(&cx->ana_capturing) == 0 && !ts) { |
447 | /* Stuff from Windows, we don't know what it is */ | 448 | /* Stuff from Windows, we don't know what it is */ |
448 | cx18_vapi(cx, CX18_CPU_SET_VER_CROP_LINE, 2, s->handle, 0); | 449 | cx18_vapi(cx, CX18_CPU_SET_VER_CROP_LINE, 2, s->handle, 0); |
449 | cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 3, 1); | 450 | cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 3, 1); |
@@ -466,14 +467,14 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s) | |||
466 | cx2341x_update(cx, cx18_api_func, NULL, &cx->params); | 467 | cx2341x_update(cx, cx18_api_func, NULL, &cx->params); |
467 | } | 468 | } |
468 | 469 | ||
469 | if (atomic_read(&cx->capturing) == 0) { | 470 | if (atomic_read(&cx->tot_capturing) == 0) { |
470 | clear_bit(CX18_F_I_EOS, &cx->i_flags); | 471 | clear_bit(CX18_F_I_EOS, &cx->i_flags); |
471 | write_reg(7, CX18_DSP0_INTERRUPT_MASK); | 472 | write_reg(7, CX18_DSP0_INTERRUPT_MASK); |
472 | } | 473 | } |
473 | 474 | ||
474 | cx18_vapi(cx, CX18_CPU_DE_SET_MDL_ACK, 3, s->handle, | 475 | cx18_vapi(cx, CX18_CPU_DE_SET_MDL_ACK, 3, s->handle, |
475 | (void *)&cx->scb->cpu_mdl_ack[s->type][0] - cx->enc_mem, | 476 | (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][0] - cx->enc_mem, |
476 | (void *)&cx->scb->cpu_mdl_ack[s->type][1] - cx->enc_mem); | 477 | (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][1] - cx->enc_mem); |
477 | 478 | ||
478 | list_for_each(p, &s->q_free.list) { | 479 | list_for_each(p, &s->q_free.list) { |
479 | struct cx18_buffer *buf = list_entry(p, struct cx18_buffer, list); | 480 | struct cx18_buffer *buf = list_entry(p, struct cx18_buffer, list); |
@@ -481,8 +482,8 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s) | |||
481 | writel(buf->dma_handle, &cx->scb->cpu_mdl[buf->id].paddr); | 482 | writel(buf->dma_handle, &cx->scb->cpu_mdl[buf->id].paddr); |
482 | writel(s->buf_size, &cx->scb->cpu_mdl[buf->id].length); | 483 | writel(s->buf_size, &cx->scb->cpu_mdl[buf->id].length); |
483 | cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, | 484 | cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, |
484 | (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, 1, | 485 | (void __iomem *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, |
485 | buf->id, s->buf_size); | 486 | 1, buf->id, s->buf_size); |
486 | } | 487 | } |
487 | /* begin_capture */ | 488 | /* begin_capture */ |
488 | if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) { | 489 | if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) { |
@@ -492,7 +493,9 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s) | |||
492 | } | 493 | } |
493 | 494 | ||
494 | /* you're live! sit back and await interrupts :) */ | 495 | /* you're live! sit back and await interrupts :) */ |
495 | atomic_inc(&cx->capturing); | 496 | if (!ts) |
497 | atomic_inc(&cx->ana_capturing); | ||
498 | atomic_inc(&cx->tot_capturing); | ||
496 | return 0; | 499 | return 0; |
497 | } | 500 | } |
498 | 501 | ||
@@ -523,7 +526,7 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end) | |||
523 | 526 | ||
524 | CX18_DEBUG_INFO("Stop Capture\n"); | 527 | CX18_DEBUG_INFO("Stop Capture\n"); |
525 | 528 | ||
526 | if (atomic_read(&cx->capturing) == 0) | 529 | if (atomic_read(&cx->tot_capturing) == 0) |
527 | return 0; | 530 | return 0; |
528 | 531 | ||
529 | if (s->type == CX18_ENC_STREAM_TYPE_MPG) | 532 | if (s->type == CX18_ENC_STREAM_TYPE_MPG) |
@@ -537,7 +540,9 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end) | |||
537 | CX18_INFO("ignoring gop_end: not (yet?) supported by the firmware\n"); | 540 | CX18_INFO("ignoring gop_end: not (yet?) supported by the firmware\n"); |
538 | } | 541 | } |
539 | 542 | ||
540 | atomic_dec(&cx->capturing); | 543 | if (s->type != CX18_ENC_STREAM_TYPE_TS) |
544 | atomic_dec(&cx->ana_capturing); | ||
545 | atomic_dec(&cx->tot_capturing); | ||
541 | 546 | ||
542 | /* Clear capture and no-read bits */ | 547 | /* Clear capture and no-read bits */ |
543 | clear_bit(CX18_F_S_STREAMING, &s->s_flags); | 548 | clear_bit(CX18_F_S_STREAMING, &s->s_flags); |
@@ -545,7 +550,7 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end) | |||
545 | cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); | 550 | cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); |
546 | s->handle = 0xffffffff; | 551 | s->handle = 0xffffffff; |
547 | 552 | ||
548 | if (atomic_read(&cx->capturing) > 0) | 553 | if (atomic_read(&cx->tot_capturing) > 0) |
549 | return 0; | 554 | return 0; |
550 | 555 | ||
551 | write_reg(5, CX18_DSP0_INTERRUPT_MASK); | 556 | write_reg(5, CX18_DSP0_INTERRUPT_MASK); |