diff options
author | Palash Bandyopadhyay <palash.bandyopadhyay@conexant.com> | 2010-07-06 17:12:25 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-20 23:17:10 -0400 |
commit | 64fbf44455260684fa5bfdd3121af3d0ef0b48dd (patch) | |
tree | 3e823c84d187b8de0731cd0b703b341abd92350e /drivers/media/video/cx231xx/cx231xx-avcore.c | |
parent | 47b75ec14653f12f9fd6fd76bfd5891ba35e1e79 (diff) |
[media] cx231xx: Added support for Carraera, Shelby, RDx_253S and VIDEO_GRABBER
Added support for new cx231xx boards - Carraera, Shelby, RDx_253S and
VIDEO_GRABBER.
[mchehab@redhat.com: Fix a merge conflict with BKL removal patches]
Signed-off-by: Palash Bandyopadhyay <palash.bandyopadhyay@conexant.com>
Signed-off-by: Devin Heitmueller <dheitmueller@hauppauge.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx231xx/cx231xx-avcore.c')
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-avcore.c | 631 |
1 files changed, 605 insertions, 26 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-avcore.c b/drivers/media/video/cx231xx/cx231xx-avcore.c index c2174413ab29..3e467ce1b06f 100644 --- a/drivers/media/video/cx231xx/cx231xx-avcore.c +++ b/drivers/media/video/cx231xx/cx231xx-avcore.c | |||
@@ -31,13 +31,16 @@ | |||
31 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
32 | #include <linux/mm.h> | 32 | #include <linux/mm.h> |
33 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
34 | #include <media/tuner.h> | ||
34 | 35 | ||
35 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
36 | #include <media/v4l2-ioctl.h> | 37 | #include <media/v4l2-ioctl.h> |
37 | #include <media/v4l2-chip-ident.h> | 38 | #include <media/v4l2-chip-ident.h> |
38 | 39 | ||
39 | #include "cx231xx.h" | 40 | #include "cx231xx.h" |
41 | #include "cx231xx-dif.h" | ||
40 | 42 | ||
43 | #define TUNER_MODE_FM_RADIO 0 | ||
41 | /****************************************************************************** | 44 | /****************************************************************************** |
42 | -: BLOCK ARRANGEMENT :- | 45 | -: BLOCK ARRANGEMENT :- |
43 | I2S block ----------------------| | 46 | I2S block ----------------------| |
@@ -50,6 +53,57 @@ | |||
50 | [Video] | 53 | [Video] |
51 | 54 | ||
52 | *******************************************************************************/ | 55 | *******************************************************************************/ |
56 | /****************************************************************************** | ||
57 | * VERVE REGISTER * | ||
58 | * * | ||
59 | ******************************************************************************/ | ||
60 | static int verve_write_byte(struct cx231xx *dev, u8 saddr, u8 data) | ||
61 | { | ||
62 | return cx231xx_write_i2c_data(dev, VERVE_I2C_ADDRESS, | ||
63 | saddr, 1, data, 1); | ||
64 | } | ||
65 | |||
66 | static int verve_read_byte(struct cx231xx *dev, u8 saddr, u8 *data) | ||
67 | { | ||
68 | int status; | ||
69 | u32 temp = 0; | ||
70 | |||
71 | status = cx231xx_read_i2c_data(dev, VERVE_I2C_ADDRESS, | ||
72 | saddr, 1, &temp, 1); | ||
73 | *data = (u8) temp; | ||
74 | return status; | ||
75 | } | ||
76 | void initGPIO(struct cx231xx *dev) | ||
77 | { | ||
78 | u32 _gpio_direction = 0; | ||
79 | u32 value = 0; | ||
80 | u8 val = 0; | ||
81 | |||
82 | _gpio_direction = _gpio_direction & 0xFC0003FF; | ||
83 | _gpio_direction = _gpio_direction | 0x03FDFC00; | ||
84 | cx231xx_send_gpio_cmd(dev, _gpio_direction, (u8 *)&value, 4, 0, 0); | ||
85 | |||
86 | verve_read_byte(dev, 0x07, &val); | ||
87 | cx231xx_info(" verve_read_byte address0x07=0x%x\n", val); | ||
88 | verve_write_byte(dev, 0x07, 0xF4); | ||
89 | verve_read_byte(dev, 0x07, &val); | ||
90 | cx231xx_info(" verve_read_byte address0x07=0x%x\n", val); | ||
91 | |||
92 | cx231xx_capture_start(dev, 1, 2); | ||
93 | |||
94 | cx231xx_mode_register(dev, EP_MODE_SET, 0x0500FE00); | ||
95 | cx231xx_mode_register(dev, GBULK_BIT_EN, 0xFFFDFFFF); | ||
96 | |||
97 | } | ||
98 | void uninitGPIO(struct cx231xx *dev) | ||
99 | { | ||
100 | u8 value[4] = { 0, 0, 0, 0 }; | ||
101 | |||
102 | cx231xx_capture_start(dev, 0, 2); | ||
103 | verve_write_byte(dev, 0x07, 0x14); | ||
104 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
105 | 0x68, value, 4); | ||
106 | } | ||
53 | 107 | ||
54 | /****************************************************************************** | 108 | /****************************************************************************** |
55 | * A F E - B L O C K C O N T R O L functions * | 109 | * A F E - B L O C K C O N T R O L functions * |
@@ -258,7 +312,7 @@ int cx231xx_afe_set_mode(struct cx231xx *dev, enum AFE_MODE mode) | |||
258 | 312 | ||
259 | switch (mode) { | 313 | switch (mode) { |
260 | case AFE_MODE_LOW_IF: | 314 | case AFE_MODE_LOW_IF: |
261 | /* SetupAFEforLowIF(); */ | 315 | cx231xx_Setup_AFE_for_LowIF(dev); |
262 | break; | 316 | break; |
263 | case AFE_MODE_BASEBAND: | 317 | case AFE_MODE_BASEBAND: |
264 | status = cx231xx_afe_setup_AFE_for_baseband(dev); | 318 | status = cx231xx_afe_setup_AFE_for_baseband(dev); |
@@ -291,8 +345,13 @@ int cx231xx_afe_update_power_control(struct cx231xx *dev, | |||
291 | int status = 0; | 345 | int status = 0; |
292 | 346 | ||
293 | switch (dev->model) { | 347 | switch (dev->model) { |
348 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
294 | case CX231XX_BOARD_CNXT_RDE_250: | 349 | case CX231XX_BOARD_CNXT_RDE_250: |
350 | case CX231XX_BOARD_CNXT_SHELBY: | ||
295 | case CX231XX_BOARD_CNXT_RDU_250: | 351 | case CX231XX_BOARD_CNXT_RDU_250: |
352 | case CX231XX_BOARD_CNXT_RDE_253S: | ||
353 | case CX231XX_BOARD_CNXT_RDU_253S: | ||
354 | case CX231XX_BOARD_CNXT_VIDEO_GRABBER: | ||
296 | if (avmode == POLARIS_AVMODE_ANALOGT_TV) { | 355 | if (avmode == POLARIS_AVMODE_ANALOGT_TV) { |
297 | while (afe_power_status != (FLD_PWRDN_TUNING_BIAS | | 356 | while (afe_power_status != (FLD_PWRDN_TUNING_BIAS | |
298 | FLD_PWRDN_ENABLE_PLL)) { | 357 | FLD_PWRDN_ENABLE_PLL)) { |
@@ -483,6 +542,17 @@ static int vid_blk_read_word(struct cx231xx *dev, u16 saddr, u32 *data) | |||
483 | return cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, | 542 | return cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, |
484 | saddr, 2, data, 4); | 543 | saddr, 2, data, 4); |
485 | } | 544 | } |
545 | int cx231xx_check_fw(struct cx231xx *dev) | ||
546 | { | ||
547 | u8 temp = 0; | ||
548 | int status = 0; | ||
549 | status = vid_blk_read_byte(dev, DL_CTL_ADDRESS_LOW, &temp); | ||
550 | if (status < 0) | ||
551 | return status; | ||
552 | else | ||
553 | return temp; | ||
554 | |||
555 | } | ||
486 | 556 | ||
487 | int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input) | 557 | int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input) |
488 | { | 558 | { |
@@ -521,9 +591,15 @@ int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input) | |||
521 | return status; | 591 | return status; |
522 | } | 592 | } |
523 | } | 593 | } |
524 | status = cx231xx_set_decoder_video_input(dev, | 594 | if (dev->tuner_type == TUNER_NXP_TDA18271) |
595 | status = cx231xx_set_decoder_video_input(dev, | ||
596 | CX231XX_VMUX_TELEVISION, | ||
597 | INPUT(input)->vmux); | ||
598 | else | ||
599 | status = cx231xx_set_decoder_video_input(dev, | ||
525 | CX231XX_VMUX_COMPOSITE1, | 600 | CX231XX_VMUX_COMPOSITE1, |
526 | INPUT(input)->vmux); | 601 | INPUT(input)->vmux); |
602 | |||
527 | break; | 603 | break; |
528 | default: | 604 | default: |
529 | cx231xx_errdev("%s: set_power_mode : Unknown Input %d !\n", | 605 | cx231xx_errdev("%s: set_power_mode : Unknown Input %d !\n", |
@@ -681,7 +757,9 @@ int cx231xx_set_decoder_video_input(struct cx231xx *dev, | |||
681 | case CX231XX_VMUX_CABLE: | 757 | case CX231XX_VMUX_CABLE: |
682 | default: | 758 | default: |
683 | switch (dev->model) { | 759 | switch (dev->model) { |
760 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
684 | case CX231XX_BOARD_CNXT_RDE_250: | 761 | case CX231XX_BOARD_CNXT_RDE_250: |
762 | case CX231XX_BOARD_CNXT_SHELBY: | ||
685 | case CX231XX_BOARD_CNXT_RDU_250: | 763 | case CX231XX_BOARD_CNXT_RDU_250: |
686 | /* Disable the use of DIF */ | 764 | /* Disable the use of DIF */ |
687 | 765 | ||
@@ -816,9 +894,21 @@ int cx231xx_set_decoder_video_input(struct cx231xx *dev, | |||
816 | /* Set VGA_SEL (for audio control) (bit 7-8) */ | 894 | /* Set VGA_SEL (for audio control) (bit 7-8) */ |
817 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | 895 | status = vid_blk_read_word(dev, AFE_CTRL, &value); |
818 | 896 | ||
897 | /*Set Func mode:01-DIF 10-baseband 11-YUV*/ | ||
898 | value &= (~(FLD_FUNC_MODE)); | ||
899 | value |= 0x800000; | ||
900 | |||
819 | value |= FLD_VGA_SEL_CH3 | FLD_VGA_SEL_CH2; | 901 | value |= FLD_VGA_SEL_CH3 | FLD_VGA_SEL_CH2; |
820 | 902 | ||
821 | status = vid_blk_write_word(dev, AFE_CTRL, value); | 903 | status = vid_blk_write_word(dev, AFE_CTRL, value); |
904 | |||
905 | if (dev->tuner_type == TUNER_NXP_TDA18271) { | ||
906 | status = vid_blk_read_word(dev, PIN_CTRL, | ||
907 | &value); | ||
908 | status = vid_blk_write_word(dev, PIN_CTRL, | ||
909 | (value & 0xFFFFFFEF)); | ||
910 | } | ||
911 | |||
822 | break; | 912 | break; |
823 | 913 | ||
824 | } | 914 | } |
@@ -840,6 +930,39 @@ int cx231xx_set_decoder_video_input(struct cx231xx *dev, | |||
840 | return status; | 930 | return status; |
841 | } | 931 | } |
842 | 932 | ||
933 | void cx231xx_enable656(struct cx231xx *dev) | ||
934 | { | ||
935 | u8 temp = 0; | ||
936 | int status; | ||
937 | /*enable TS1 data[0:7] as output to export 656*/ | ||
938 | |||
939 | status = vid_blk_write_byte(dev, TS1_PIN_CTL0, 0xFF); | ||
940 | |||
941 | /*enable TS1 clock as output to export 656*/ | ||
942 | |||
943 | status = vid_blk_read_byte(dev, TS1_PIN_CTL1, &temp); | ||
944 | temp = temp|0x04; | ||
945 | |||
946 | status = vid_blk_write_byte(dev, TS1_PIN_CTL1, temp); | ||
947 | |||
948 | } | ||
949 | EXPORT_SYMBOL_GPL(cx231xx_enable656); | ||
950 | |||
951 | void cx231xx_disable656(struct cx231xx *dev) | ||
952 | { | ||
953 | u8 temp = 0; | ||
954 | int status; | ||
955 | |||
956 | |||
957 | status = vid_blk_write_byte(dev, TS1_PIN_CTL0, 0x00); | ||
958 | |||
959 | status = vid_blk_read_byte(dev, TS1_PIN_CTL1, &temp); | ||
960 | temp = temp&0xFB; | ||
961 | |||
962 | status = vid_blk_write_byte(dev, TS1_PIN_CTL1, temp); | ||
963 | } | ||
964 | EXPORT_SYMBOL_GPL(cx231xx_disable656); | ||
965 | |||
843 | /* | 966 | /* |
844 | * Handle any video-mode specific overrides that are different | 967 | * Handle any video-mode specific overrides that are different |
845 | * on a per video standards basis after touching the MODE_CTRL | 968 | * on a per video standards basis after touching the MODE_CTRL |
@@ -873,7 +996,7 @@ int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev) | |||
873 | VID_BLK_I2C_ADDRESS, | 996 | VID_BLK_I2C_ADDRESS, |
874 | VERT_TIM_CTRL, | 997 | VERT_TIM_CTRL, |
875 | FLD_V656BLANK_CNT, | 998 | FLD_V656BLANK_CNT, |
876 | 0x1E000000); | 999 | 0x1C000000); |
877 | 1000 | ||
878 | status = cx231xx_read_modify_write_i2c_dword(dev, | 1001 | status = cx231xx_read_modify_write_i2c_dword(dev, |
879 | VID_BLK_I2C_ADDRESS, | 1002 | VID_BLK_I2C_ADDRESS, |
@@ -881,12 +1004,20 @@ int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev) | |||
881 | FLD_HBLANK_CNT, | 1004 | FLD_HBLANK_CNT, |
882 | cx231xx_set_field | 1005 | cx231xx_set_field |
883 | (FLD_HBLANK_CNT, 0x79)); | 1006 | (FLD_HBLANK_CNT, 0x79)); |
1007 | |||
884 | } else if (dev->norm & V4L2_STD_SECAM) { | 1008 | } else if (dev->norm & V4L2_STD_SECAM) { |
885 | cx231xx_info("do_mode_ctrl_overrides SECAM\n"); | 1009 | cx231xx_info("do_mode_ctrl_overrides SECAM\n"); |
886 | status = cx231xx_read_modify_write_i2c_dword(dev, | 1010 | status = cx231xx_read_modify_write_i2c_dword(dev, |
887 | VID_BLK_I2C_ADDRESS, | 1011 | VID_BLK_I2C_ADDRESS, |
888 | VERT_TIM_CTRL, | 1012 | VERT_TIM_CTRL, |
889 | FLD_VBLANK_CNT, 0x24); | 1013 | FLD_VBLANK_CNT, 0x24); |
1014 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1015 | VID_BLK_I2C_ADDRESS, | ||
1016 | VERT_TIM_CTRL, | ||
1017 | FLD_V656BLANK_CNT, | ||
1018 | cx231xx_set_field | ||
1019 | (FLD_V656BLANK_CNT, | ||
1020 | 0x28)); | ||
890 | /* Adjust the active video horizontal start point */ | 1021 | /* Adjust the active video horizontal start point */ |
891 | status = cx231xx_read_modify_write_i2c_dword(dev, | 1022 | status = cx231xx_read_modify_write_i2c_dword(dev, |
892 | VID_BLK_I2C_ADDRESS, | 1023 | VID_BLK_I2C_ADDRESS, |
@@ -900,6 +1031,13 @@ int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev) | |||
900 | VID_BLK_I2C_ADDRESS, | 1031 | VID_BLK_I2C_ADDRESS, |
901 | VERT_TIM_CTRL, | 1032 | VERT_TIM_CTRL, |
902 | FLD_VBLANK_CNT, 0x24); | 1033 | FLD_VBLANK_CNT, 0x24); |
1034 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1035 | VID_BLK_I2C_ADDRESS, | ||
1036 | VERT_TIM_CTRL, | ||
1037 | FLD_V656BLANK_CNT, | ||
1038 | cx231xx_set_field | ||
1039 | (FLD_V656BLANK_CNT, | ||
1040 | 0x28)); | ||
903 | /* Adjust the active video horizontal start point */ | 1041 | /* Adjust the active video horizontal start point */ |
904 | status = cx231xx_read_modify_write_i2c_dword(dev, | 1042 | status = cx231xx_read_modify_write_i2c_dword(dev, |
905 | VID_BLK_I2C_ADDRESS, | 1043 | VID_BLK_I2C_ADDRESS, |
@@ -907,11 +1045,28 @@ int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev) | |||
907 | FLD_HBLANK_CNT, | 1045 | FLD_HBLANK_CNT, |
908 | cx231xx_set_field | 1046 | cx231xx_set_field |
909 | (FLD_HBLANK_CNT, 0x85)); | 1047 | (FLD_HBLANK_CNT, 0x85)); |
1048 | |||
910 | } | 1049 | } |
911 | 1050 | ||
912 | return status; | 1051 | return status; |
913 | } | 1052 | } |
914 | 1053 | ||
1054 | int cx231xx_unmute_audio(struct cx231xx *dev) | ||
1055 | { | ||
1056 | return vid_blk_write_byte(dev, PATH1_VOL_CTL, 0x24); | ||
1057 | } | ||
1058 | EXPORT_SYMBOL_GPL(cx231xx_unmute_audio); | ||
1059 | |||
1060 | int stopAudioFirmware(struct cx231xx *dev) | ||
1061 | { | ||
1062 | return vid_blk_write_byte(dev, DL_CTL_CONTROL, 0x03); | ||
1063 | } | ||
1064 | |||
1065 | int restartAudioFirmware(struct cx231xx *dev) | ||
1066 | { | ||
1067 | return vid_blk_write_byte(dev, DL_CTL_CONTROL, 0x13); | ||
1068 | } | ||
1069 | |||
915 | int cx231xx_set_audio_input(struct cx231xx *dev, u8 input) | 1070 | int cx231xx_set_audio_input(struct cx231xx *dev, u8 input) |
916 | { | 1071 | { |
917 | int status = 0; | 1072 | int status = 0; |
@@ -970,6 +1125,7 @@ int cx231xx_set_audio_decoder_input(struct cx231xx *dev, | |||
970 | 1125 | ||
971 | /* unmute all, AC97 in, independence mode | 1126 | /* unmute all, AC97 in, independence mode |
972 | adr 08d0, data 0x00063073 */ | 1127 | adr 08d0, data 0x00063073 */ |
1128 | status = vid_blk_write_word(dev, DL_CTL, 0x3000001); | ||
973 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x00063073); | 1129 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x00063073); |
974 | 1130 | ||
975 | /* set AVC maximum threshold, adr 08d4, dat ffff0024 */ | 1131 | /* set AVC maximum threshold, adr 08d4, dat ffff0024 */ |
@@ -985,7 +1141,7 @@ int cx231xx_set_audio_decoder_input(struct cx231xx *dev, | |||
985 | 1141 | ||
986 | case AUDIO_INPUT_TUNER_TV: | 1142 | case AUDIO_INPUT_TUNER_TV: |
987 | default: | 1143 | default: |
988 | 1144 | status = stopAudioFirmware(dev); | |
989 | /* Setup SRC sources and clocks */ | 1145 | /* Setup SRC sources and clocks */ |
990 | status = vid_blk_write_word(dev, BAND_OUT_SEL, | 1146 | status = vid_blk_write_word(dev, BAND_OUT_SEL, |
991 | cx231xx_set_field(FLD_SRC6_IN_SEL, 0x00) | | 1147 | cx231xx_set_field(FLD_SRC6_IN_SEL, 0x00) | |
@@ -1013,17 +1169,30 @@ int cx231xx_set_audio_decoder_input(struct cx231xx *dev, | |||
1013 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x1F063870); | 1169 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x1F063870); |
1014 | 1170 | ||
1015 | /* setAudioStandard(_audio_standard); */ | 1171 | /* setAudioStandard(_audio_standard); */ |
1016 | |||
1017 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x00063870); | 1172 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x00063870); |
1173 | |||
1174 | status = restartAudioFirmware(dev); | ||
1175 | |||
1018 | switch (dev->model) { | 1176 | switch (dev->model) { |
1177 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
1019 | case CX231XX_BOARD_CNXT_RDE_250: | 1178 | case CX231XX_BOARD_CNXT_RDE_250: |
1179 | case CX231XX_BOARD_CNXT_SHELBY: | ||
1020 | case CX231XX_BOARD_CNXT_RDU_250: | 1180 | case CX231XX_BOARD_CNXT_RDU_250: |
1181 | case CX231XX_BOARD_CNXT_VIDEO_GRABBER: | ||
1021 | status = cx231xx_read_modify_write_i2c_dword(dev, | 1182 | status = cx231xx_read_modify_write_i2c_dword(dev, |
1022 | VID_BLK_I2C_ADDRESS, | 1183 | VID_BLK_I2C_ADDRESS, |
1023 | CHIP_CTRL, | 1184 | CHIP_CTRL, |
1024 | FLD_SIF_EN, | 1185 | FLD_SIF_EN, |
1025 | cx231xx_set_field(FLD_SIF_EN, 1)); | 1186 | cx231xx_set_field(FLD_SIF_EN, 1)); |
1026 | break; | 1187 | break; |
1188 | case CX231XX_BOARD_CNXT_RDE_253S: | ||
1189 | case CX231XX_BOARD_CNXT_RDU_253S: | ||
1190 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1191 | VID_BLK_I2C_ADDRESS, | ||
1192 | CHIP_CTRL, | ||
1193 | FLD_SIF_EN, | ||
1194 | cx231xx_set_field(FLD_SIF_EN, 0)); | ||
1195 | break; | ||
1027 | default: | 1196 | default: |
1028 | break; | 1197 | break; |
1029 | } | 1198 | } |
@@ -1058,7 +1227,9 @@ int cx231xx_resolution_set(struct cx231xx *dev) | |||
1058 | return status; | 1227 | return status; |
1059 | 1228 | ||
1060 | /* set vertical scale */ | 1229 | /* set vertical scale */ |
1061 | return vid_blk_write_word(dev, VSCALE_CTRL, dev->vscale); | 1230 | status = vid_blk_write_word(dev, VSCALE_CTRL, dev->vscale); |
1231 | |||
1232 | return status; | ||
1062 | } | 1233 | } |
1063 | 1234 | ||
1064 | /****************************************************************************** | 1235 | /****************************************************************************** |
@@ -1123,6 +1294,346 @@ int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex) | |||
1123 | return status; | 1294 | return status; |
1124 | 1295 | ||
1125 | } | 1296 | } |
1297 | EXPORT_SYMBOL_GPL(cx231xx_enable_i2c_for_tuner); | ||
1298 | void update_HH_register_after_set_DIF(struct cx231xx *dev) | ||
1299 | { | ||
1300 | /* | ||
1301 | u8 status = 0; | ||
1302 | u32 value = 0; | ||
1303 | |||
1304 | vid_blk_write_word(dev, PIN_CTRL, 0xA0FFF82F); | ||
1305 | vid_blk_write_word(dev, DIF_MISC_CTRL, 0x0A203F11); | ||
1306 | vid_blk_write_word(dev, DIF_SRC_PHASE_INC, 0x1BEFBF06); | ||
1307 | |||
1308 | status = vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); | ||
1309 | vid_blk_write_word(dev, AFE_CTRL_C2HH_SRC_CTRL, 0x4485D390); | ||
1310 | status = vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); | ||
1311 | */ | ||
1312 | } | ||
1313 | |||
1314 | void cx231xx_dump_HH_reg(struct cx231xx *dev) | ||
1315 | { | ||
1316 | u8 status = 0; | ||
1317 | u32 value = 0; | ||
1318 | u16 i = 0; | ||
1319 | |||
1320 | value = 0x45005390; | ||
1321 | status = vid_blk_write_word(dev, 0x104, value); | ||
1322 | |||
1323 | for (i = 0x100; i < 0x140; i++) { | ||
1324 | status = vid_blk_read_word(dev, i, &value); | ||
1325 | cx231xx_info("reg0x%x=0x%x\n", i, value); | ||
1326 | i = i+3; | ||
1327 | } | ||
1328 | |||
1329 | for (i = 0x300; i < 0x400; i++) { | ||
1330 | status = vid_blk_read_word(dev, i, &value); | ||
1331 | cx231xx_info("reg0x%x=0x%x\n", i, value); | ||
1332 | i = i+3; | ||
1333 | } | ||
1334 | |||
1335 | for (i = 0x400; i < 0x440; i++) { | ||
1336 | status = vid_blk_read_word(dev, i, &value); | ||
1337 | cx231xx_info("reg0x%x=0x%x\n", i, value); | ||
1338 | i = i+3; | ||
1339 | } | ||
1340 | |||
1341 | status = vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); | ||
1342 | cx231xx_info("AFE_CTRL_C2HH_SRC_CTRL=0x%x\n", value); | ||
1343 | vid_blk_write_word(dev, AFE_CTRL_C2HH_SRC_CTRL, 0x4485D390); | ||
1344 | status = vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); | ||
1345 | cx231xx_info("AFE_CTRL_C2HH_SRC_CTRL=0x%x\n", value); | ||
1346 | |||
1347 | } | ||
1348 | void cx231xx_dump_SC_reg(struct cx231xx *dev) | ||
1349 | { | ||
1350 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1351 | int status = 0; | ||
1352 | cx231xx_info("cx231xx_dump_SC_reg %s!\n", __TIME__); | ||
1353 | |||
1354 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT, | ||
1355 | value, 4); | ||
1356 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", BOARD_CFG_STAT, value[0], | ||
1357 | value[1], value[2], value[3]); | ||
1358 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS_MODE_REG, | ||
1359 | value, 4); | ||
1360 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS_MODE_REG, value[0], | ||
1361 | value[1], value[2], value[3]); | ||
1362 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS1_CFG_REG, | ||
1363 | value, 4); | ||
1364 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS1_CFG_REG, value[0], | ||
1365 | value[1], value[2], value[3]); | ||
1366 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS1_LENGTH_REG, | ||
1367 | value, 4); | ||
1368 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS1_LENGTH_REG, value[0], | ||
1369 | value[1], value[2], value[3]); | ||
1370 | |||
1371 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS2_CFG_REG, | ||
1372 | value, 4); | ||
1373 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS2_CFG_REG, value[0], | ||
1374 | value[1], value[2], value[3]); | ||
1375 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS2_LENGTH_REG, | ||
1376 | value, 4); | ||
1377 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS2_LENGTH_REG, value[0], | ||
1378 | value[1], value[2], value[3]); | ||
1379 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, | ||
1380 | value, 4); | ||
1381 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", EP_MODE_SET, value[0], | ||
1382 | value[1], value[2], value[3]); | ||
1383 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN1, | ||
1384 | value, 4); | ||
1385 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN1, value[0], | ||
1386 | value[1], value[2], value[3]); | ||
1387 | |||
1388 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN2, | ||
1389 | value, 4); | ||
1390 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN2, value[0], | ||
1391 | value[1], value[2], value[3]); | ||
1392 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN3, | ||
1393 | value, 4); | ||
1394 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN3, value[0], | ||
1395 | value[1], value[2], value[3]); | ||
1396 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK0, | ||
1397 | value, 4); | ||
1398 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK0, value[0], | ||
1399 | value[1], value[2], value[3]); | ||
1400 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK1, | ||
1401 | value, 4); | ||
1402 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK1, value[0], | ||
1403 | value[1], value[2], value[3]); | ||
1404 | |||
1405 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK2, | ||
1406 | value, 4); | ||
1407 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK2, value[0], | ||
1408 | value[1], value[2], value[3]); | ||
1409 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_GAIN, | ||
1410 | value, 4); | ||
1411 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_GAIN, value[0], | ||
1412 | value[1], value[2], value[3]); | ||
1413 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_CAR_REG, | ||
1414 | value, 4); | ||
1415 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_CAR_REG, value[0], | ||
1416 | value[1], value[2], value[3]); | ||
1417 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_OT_CFG1, | ||
1418 | value, 4); | ||
1419 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_OT_CFG1, value[0], | ||
1420 | value[1], value[2], value[3]); | ||
1421 | |||
1422 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_OT_CFG2, | ||
1423 | value, 4); | ||
1424 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_OT_CFG2, value[0], | ||
1425 | value[1], value[2], value[3]); | ||
1426 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, | ||
1427 | value, 4); | ||
1428 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", PWR_CTL_EN, value[0], | ||
1429 | value[1], value[2], value[3]); | ||
1430 | |||
1431 | |||
1432 | } | ||
1433 | |||
1434 | void cx231xx_Setup_AFE_for_LowIF(struct cx231xx *dev) | ||
1435 | |||
1436 | { | ||
1437 | u8 status = 0; | ||
1438 | u8 value = 0; | ||
1439 | |||
1440 | |||
1441 | |||
1442 | status = afe_read_byte(dev, ADC_STATUS2_CH3, &value); | ||
1443 | value = (value & 0xFE)|0x01; | ||
1444 | status = afe_write_byte(dev, ADC_STATUS2_CH3, value); | ||
1445 | |||
1446 | status = afe_read_byte(dev, ADC_STATUS2_CH3, &value); | ||
1447 | value = (value & 0xFE)|0x00; | ||
1448 | status = afe_write_byte(dev, ADC_STATUS2_CH3, value); | ||
1449 | |||
1450 | |||
1451 | /* | ||
1452 | config colibri to lo-if mode | ||
1453 | |||
1454 | FIXME: ntf_mode = 2'b00 by default. But set 0x1 would reduce | ||
1455 | the diff IF input by half, | ||
1456 | |||
1457 | for low-if agc defect | ||
1458 | */ | ||
1459 | |||
1460 | status = afe_read_byte(dev, ADC_NTF_PRECLMP_EN_CH3, &value); | ||
1461 | value = (value & 0xFC)|0x00; | ||
1462 | status = afe_write_byte(dev, ADC_NTF_PRECLMP_EN_CH3, value); | ||
1463 | |||
1464 | status = afe_read_byte(dev, ADC_INPUT_CH3, &value); | ||
1465 | value = (value & 0xF9)|0x02; | ||
1466 | status = afe_write_byte(dev, ADC_INPUT_CH3, value); | ||
1467 | |||
1468 | status = afe_read_byte(dev, ADC_FB_FRCRST_CH3, &value); | ||
1469 | value = (value & 0xFB)|0x04; | ||
1470 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH3, value); | ||
1471 | |||
1472 | status = afe_read_byte(dev, ADC_DCSERVO_DEM_CH3, &value); | ||
1473 | value = (value & 0xFC)|0x03; | ||
1474 | status = afe_write_byte(dev, ADC_DCSERVO_DEM_CH3, value); | ||
1475 | |||
1476 | status = afe_read_byte(dev, ADC_CTRL_DAC1_CH3, &value); | ||
1477 | value = (value & 0xFB)|0x04; | ||
1478 | status = afe_write_byte(dev, ADC_CTRL_DAC1_CH3, value); | ||
1479 | |||
1480 | status = afe_read_byte(dev, ADC_CTRL_DAC23_CH3, &value); | ||
1481 | value = (value & 0xF8)|0x06; | ||
1482 | status = afe_write_byte(dev, ADC_CTRL_DAC23_CH3, value); | ||
1483 | |||
1484 | status = afe_read_byte(dev, ADC_CTRL_DAC23_CH3, &value); | ||
1485 | value = (value & 0x8F)|0x40; | ||
1486 | status = afe_write_byte(dev, ADC_CTRL_DAC23_CH3, value); | ||
1487 | |||
1488 | status = afe_read_byte(dev, ADC_PWRDN_CLAMP_CH3, &value); | ||
1489 | value = (value & 0xDF)|0x20; | ||
1490 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, value); | ||
1491 | } | ||
1492 | |||
1493 | void cx231xx_set_Colibri_For_LowIF(struct cx231xx *dev, u32 if_freq, | ||
1494 | u8 spectral_invert, u32 mode) | ||
1495 | { | ||
1496 | |||
1497 | u32 colibri_carrier_offset = 0; | ||
1498 | u8 status = 0; | ||
1499 | u32 func_mode = 0; | ||
1500 | u32 standard = 0; | ||
1501 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1502 | |||
1503 | switch (dev->model) { | ||
1504 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
1505 | case CX231XX_BOARD_CNXT_RDE_250: | ||
1506 | case CX231XX_BOARD_CNXT_SHELBY: | ||
1507 | case CX231XX_BOARD_CNXT_RDU_250: | ||
1508 | case CX231XX_BOARD_CNXT_VIDEO_GRABBER: | ||
1509 | func_mode = 0x03; | ||
1510 | break; | ||
1511 | case CX231XX_BOARD_CNXT_RDE_253S: | ||
1512 | case CX231XX_BOARD_CNXT_RDU_253S: | ||
1513 | func_mode = 0x01; | ||
1514 | break; | ||
1515 | |||
1516 | default: | ||
1517 | func_mode = 0x01; | ||
1518 | } | ||
1519 | |||
1520 | cx231xx_info("Enter cx231xx_set_Colibri_For_LowIF()\n"); | ||
1521 | value[0] = (u8) 0x6F; | ||
1522 | value[1] = (u8) 0x6F; | ||
1523 | value[2] = (u8) 0x6F; | ||
1524 | value[3] = (u8) 0x6F; | ||
1525 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1526 | PWR_CTL_EN, value, 4); | ||
1527 | if (1) { | ||
1528 | |||
1529 | /*Set colibri for low IF*/ | ||
1530 | status = cx231xx_afe_set_mode(dev, AFE_MODE_LOW_IF); | ||
1531 | |||
1532 | |||
1533 | /* Set C2HH for low IF operation.*/ | ||
1534 | standard = dev->norm; | ||
1535 | status = cx231xx_dif_configure_C2HH_for_low_IF(dev, dev->active_mode, | ||
1536 | func_mode, standard); | ||
1537 | |||
1538 | |||
1539 | /* Get colibri offsets.*/ | ||
1540 | colibri_carrier_offset = cx231xx_Get_Colibri_CarrierOffset(mode, | ||
1541 | standard); | ||
1542 | |||
1543 | cx231xx_info("colibri_carrier_offset=%d, standard=0x%x\n", | ||
1544 | colibri_carrier_offset, standard); | ||
1545 | |||
1546 | /* Set the band Pass filter for DIF*/ | ||
1547 | cx231xx_set_DIF_bandpass(dev, (if_freq+colibri_carrier_offset) | ||
1548 | , spectral_invert, mode); | ||
1549 | } | ||
1550 | } | ||
1551 | |||
1552 | u32 cx231xx_Get_Colibri_CarrierOffset(u32 mode, u32 standerd) | ||
1553 | { | ||
1554 | u32 colibri_carrier_offset = 0; | ||
1555 | |||
1556 | |||
1557 | if (mode == TUNER_MODE_FM_RADIO) { | ||
1558 | colibri_carrier_offset = 1100000; | ||
1559 | } else if (standerd & (V4L2_STD_NTSC | V4L2_STD_NTSC_M_JP)) { | ||
1560 | colibri_carrier_offset = 4832000; /*4.83MHz */ | ||
1561 | } else if (standerd & (V4L2_STD_PAL_B | V4L2_STD_PAL_G)) { | ||
1562 | colibri_carrier_offset = 2700000; /*2.70MHz */ | ||
1563 | } else if (standerd & (V4L2_STD_PAL_D | V4L2_STD_PAL_I | ||
1564 | | V4L2_STD_SECAM)) { | ||
1565 | colibri_carrier_offset = 2100000; /*2.10MHz */ | ||
1566 | } | ||
1567 | |||
1568 | |||
1569 | return colibri_carrier_offset; | ||
1570 | } | ||
1571 | |||
1572 | void cx231xx_set_DIF_bandpass(struct cx231xx *dev, u32 if_freq, | ||
1573 | u8 spectral_invert, u32 mode) | ||
1574 | { | ||
1575 | |||
1576 | unsigned long pll_freq_word; | ||
1577 | int status = 0; | ||
1578 | u32 dif_misc_ctrl_value = 0; | ||
1579 | u64 pll_freq_u64 = 0; | ||
1580 | u32 i = 0; | ||
1581 | |||
1582 | |||
1583 | cx231xx_info("if_freq=%d;spectral_invert=0x%x;mode=0x%x\n", | ||
1584 | if_freq, spectral_invert, mode); | ||
1585 | |||
1586 | |||
1587 | if (mode == TUNER_MODE_FM_RADIO) { | ||
1588 | pll_freq_word = 0x905A1CAC; | ||
1589 | status = vid_blk_write_word(dev, DIF_PLL_FREQ_WORD, pll_freq_word); | ||
1590 | |||
1591 | } else /*KSPROPERTY_TUNER_MODE_TV*/{ | ||
1592 | /* Calculate the PLL frequency word based on the adjusted if_freq*/ | ||
1593 | pll_freq_word = if_freq; | ||
1594 | pll_freq_u64 = (u64)pll_freq_word << 28L; | ||
1595 | do_div(pll_freq_u64, 50000000); | ||
1596 | pll_freq_word = (u32)pll_freq_u64; | ||
1597 | /*pll_freq_word = 0x3463497;*/ | ||
1598 | status = vid_blk_write_word(dev, DIF_PLL_FREQ_WORD, pll_freq_word); | ||
1599 | |||
1600 | if (spectral_invert) { | ||
1601 | if_freq -= 400000; | ||
1602 | /* Enable Spectral Invert*/ | ||
1603 | status = vid_blk_read_word(dev, DIF_MISC_CTRL, | ||
1604 | &dif_misc_ctrl_value); | ||
1605 | dif_misc_ctrl_value = dif_misc_ctrl_value | 0x00200000; | ||
1606 | status = vid_blk_write_word(dev, DIF_MISC_CTRL, | ||
1607 | dif_misc_ctrl_value); | ||
1608 | } else { | ||
1609 | if_freq += 400000; | ||
1610 | /* Disable Spectral Invert*/ | ||
1611 | status = vid_blk_read_word(dev, DIF_MISC_CTRL, | ||
1612 | &dif_misc_ctrl_value); | ||
1613 | dif_misc_ctrl_value = dif_misc_ctrl_value & 0xFFDFFFFF; | ||
1614 | status = vid_blk_write_word(dev, DIF_MISC_CTRL, | ||
1615 | dif_misc_ctrl_value); | ||
1616 | } | ||
1617 | |||
1618 | if_freq = (if_freq/100000)*100000; | ||
1619 | |||
1620 | if (if_freq < 3000000) | ||
1621 | if_freq = 3000000; | ||
1622 | |||
1623 | if (if_freq > 16000000) | ||
1624 | if_freq = 16000000; | ||
1625 | } | ||
1626 | |||
1627 | cx231xx_info("Enter IF=%d\n", | ||
1628 | sizeof(Dif_set_array)/sizeof(struct dif_settings)); | ||
1629 | for (i = 0; i < sizeof(Dif_set_array)/sizeof(struct dif_settings); i++) { | ||
1630 | if (Dif_set_array[i].if_freq == if_freq) { | ||
1631 | status = vid_blk_write_word(dev, | ||
1632 | Dif_set_array[i].register_address, Dif_set_array[i].value); | ||
1633 | } | ||
1634 | } | ||
1635 | |||
1636 | } | ||
1126 | 1637 | ||
1127 | /****************************************************************************** | 1638 | /****************************************************************************** |
1128 | * D I F - B L O C K C O N T R O L functions * | 1639 | * D I F - B L O C K C O N T R O L functions * |
@@ -1132,6 +1643,7 @@ int cx231xx_dif_configure_C2HH_for_low_IF(struct cx231xx *dev, u32 mode, | |||
1132 | { | 1643 | { |
1133 | int status = 0; | 1644 | int status = 0; |
1134 | 1645 | ||
1646 | |||
1135 | if (mode == V4L2_TUNER_RADIO) { | 1647 | if (mode == V4L2_TUNER_RADIO) { |
1136 | /* C2HH */ | 1648 | /* C2HH */ |
1137 | /* lo if big signal */ | 1649 | /* lo if big signal */ |
@@ -1174,6 +1686,7 @@ int cx231xx_dif_configure_C2HH_for_low_IF(struct cx231xx *dev, u32 mode, | |||
1174 | VID_BLK_I2C_ADDRESS, 32, | 1686 | VID_BLK_I2C_ADDRESS, 32, |
1175 | AUD_IO_CTRL, 0, 31, 0x00000003); | 1687 | AUD_IO_CTRL, 0, 31, 0x00000003); |
1176 | } else if ((standard == V4L2_STD_PAL_I) | | 1688 | } else if ((standard == V4L2_STD_PAL_I) | |
1689 | (standard & V4L2_STD_PAL_D) | | ||
1177 | (standard & V4L2_STD_SECAM)) { | 1690 | (standard & V4L2_STD_SECAM)) { |
1178 | /* C2HH setup */ | 1691 | /* C2HH setup */ |
1179 | /* lo if big signal */ | 1692 | /* lo if big signal */ |
@@ -1232,10 +1745,17 @@ int cx231xx_dif_set_standard(struct cx231xx *dev, u32 standard) | |||
1232 | dev->norm = standard; | 1745 | dev->norm = standard; |
1233 | 1746 | ||
1234 | switch (dev->model) { | 1747 | switch (dev->model) { |
1748 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
1235 | case CX231XX_BOARD_CNXT_RDE_250: | 1749 | case CX231XX_BOARD_CNXT_RDE_250: |
1750 | case CX231XX_BOARD_CNXT_SHELBY: | ||
1236 | case CX231XX_BOARD_CNXT_RDU_250: | 1751 | case CX231XX_BOARD_CNXT_RDU_250: |
1752 | case CX231XX_BOARD_CNXT_VIDEO_GRABBER: | ||
1237 | func_mode = 0x03; | 1753 | func_mode = 0x03; |
1238 | break; | 1754 | break; |
1755 | case CX231XX_BOARD_CNXT_RDE_253S: | ||
1756 | case CX231XX_BOARD_CNXT_RDU_253S: | ||
1757 | func_mode = 0x01; | ||
1758 | break; | ||
1239 | default: | 1759 | default: |
1240 | func_mode = 0x01; | 1760 | func_mode = 0x01; |
1241 | } | 1761 | } |
@@ -1617,17 +2137,27 @@ int cx231xx_tuner_post_channel_change(struct cx231xx *dev) | |||
1617 | { | 2137 | { |
1618 | int status = 0; | 2138 | int status = 0; |
1619 | u32 dwval; | 2139 | u32 dwval; |
1620 | 2140 | cx231xx_info("cx231xx_tuner_post_channel_change dev->tuner_type =0%d\n", | |
2141 | dev->tuner_type); | ||
1621 | /* Set the RF and IF k_agc values to 4 for PAL/NTSC and 8 for | 2142 | /* Set the RF and IF k_agc values to 4 for PAL/NTSC and 8 for |
1622 | * SECAM L/B/D standards */ | 2143 | * SECAM L/B/D standards */ |
1623 | status = vid_blk_read_word(dev, DIF_AGC_IF_REF, &dwval); | 2144 | status = vid_blk_read_word(dev, DIF_AGC_IF_REF, &dwval); |
1624 | dwval &= ~(FLD_DIF_K_AGC_RF | FLD_DIF_K_AGC_IF); | 2145 | dwval &= ~(FLD_DIF_K_AGC_RF | FLD_DIF_K_AGC_IF); |
1625 | 2146 | ||
1626 | if (dev->norm & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_B | | 2147 | if (dev->norm & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_B | |
1627 | V4L2_STD_SECAM_D)) | 2148 | V4L2_STD_SECAM_D)) { |
1628 | dwval |= 0x88000000; | 2149 | if (dev->tuner_type == TUNER_NXP_TDA18271) { |
1629 | else | 2150 | dwval &= ~FLD_DIF_IF_REF; |
1630 | dwval |= 0x44000000; | 2151 | dwval |= 0x88000300; |
2152 | } else | ||
2153 | dwval |= 0x88000000; | ||
2154 | } else { | ||
2155 | if (dev->tuner_type == TUNER_NXP_TDA18271) { | ||
2156 | dwval &= ~FLD_DIF_IF_REF; | ||
2157 | dwval |= 0xCC000300; | ||
2158 | } else | ||
2159 | dwval |= 0x44000000; | ||
2160 | } | ||
1631 | 2161 | ||
1632 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, dwval); | 2162 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, dwval); |
1633 | 2163 | ||
@@ -1714,8 +2244,6 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
1714 | return 0; | 2244 | return 0; |
1715 | } | 2245 | } |
1716 | 2246 | ||
1717 | cx231xx_info(" setPowerMode::mode = %d\n", mode); | ||
1718 | |||
1719 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, | 2247 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, |
1720 | 4); | 2248 | 4); |
1721 | if (status < 0) | 2249 | if (status < 0) |
@@ -1761,7 +2289,7 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
1761 | 2289 | ||
1762 | case POLARIS_AVMODE_ANALOGT_TV: | 2290 | case POLARIS_AVMODE_ANALOGT_TV: |
1763 | 2291 | ||
1764 | tmp &= (~PWR_DEMOD_EN); | 2292 | tmp |= PWR_DEMOD_EN; |
1765 | tmp |= (I2C_DEMOD_EN); | 2293 | tmp |= (I2C_DEMOD_EN); |
1766 | value[0] = (u8) tmp; | 2294 | value[0] = (u8) tmp; |
1767 | value[1] = (u8) (tmp >> 8); | 2295 | value[1] = (u8) (tmp >> 8); |
@@ -1814,14 +2342,27 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
1814 | msleep(PWR_SLEEP_INTERVAL); | 2342 | msleep(PWR_SLEEP_INTERVAL); |
1815 | } | 2343 | } |
1816 | 2344 | ||
1817 | if ((dev->model == CX231XX_BOARD_CNXT_RDE_250) || | 2345 | if ((dev->model == CX231XX_BOARD_CNXT_CARRAERA) || |
2346 | (dev->model == CX231XX_BOARD_CNXT_RDE_250) || | ||
2347 | (dev->model == CX231XX_BOARD_CNXT_SHELBY) || | ||
1818 | (dev->model == CX231XX_BOARD_CNXT_RDU_250)) { | 2348 | (dev->model == CX231XX_BOARD_CNXT_RDU_250)) { |
1819 | /* tuner path to channel 1 from port 3 */ | 2349 | /* tuner path to channel 1 from port 3 */ |
1820 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | 2350 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); |
1821 | 2351 | ||
2352 | /* reset the Tuner */ | ||
2353 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | ||
2354 | |||
2355 | if (dev->cx231xx_reset_analog_tuner) | ||
2356 | dev->cx231xx_reset_analog_tuner(dev); | ||
2357 | } else if ((dev->model == CX231XX_BOARD_CNXT_RDE_253S) || | ||
2358 | (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER) || | ||
2359 | (dev->model == CX231XX_BOARD_CNXT_RDU_253S)) { | ||
2360 | /* tuner path to channel 1 from port 3 */ | ||
2361 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | ||
1822 | if (dev->cx231xx_reset_analog_tuner) | 2362 | if (dev->cx231xx_reset_analog_tuner) |
1823 | dev->cx231xx_reset_analog_tuner(dev); | 2363 | dev->cx231xx_reset_analog_tuner(dev); |
1824 | } | 2364 | } |
2365 | |||
1825 | break; | 2366 | break; |
1826 | 2367 | ||
1827 | case POLARIS_AVMODE_DIGITAL: | 2368 | case POLARIS_AVMODE_DIGITAL: |
@@ -1876,14 +2417,27 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
1876 | msleep(PWR_SLEEP_INTERVAL); | 2417 | msleep(PWR_SLEEP_INTERVAL); |
1877 | } | 2418 | } |
1878 | 2419 | ||
1879 | if ((dev->model == CX231XX_BOARD_CNXT_RDE_250) || | 2420 | if ((dev->model == CX231XX_BOARD_CNXT_CARRAERA) || |
2421 | (dev->model == CX231XX_BOARD_CNXT_RDE_250) || | ||
2422 | (dev->model == CX231XX_BOARD_CNXT_SHELBY) || | ||
1880 | (dev->model == CX231XX_BOARD_CNXT_RDU_250)) { | 2423 | (dev->model == CX231XX_BOARD_CNXT_RDU_250)) { |
1881 | /* tuner path to channel 1 from port 3 */ | 2424 | /* tuner path to channel 1 from port 3 */ |
1882 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | 2425 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); |
1883 | 2426 | ||
2427 | /* reset the Tuner */ | ||
2428 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | ||
2429 | |||
2430 | if (dev->cx231xx_reset_analog_tuner) | ||
2431 | dev->cx231xx_reset_analog_tuner(dev); | ||
2432 | } else if ((dev->model == CX231XX_BOARD_CNXT_RDE_253S) || | ||
2433 | (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER) || | ||
2434 | (dev->model == CX231XX_BOARD_CNXT_RDU_253S)) { | ||
2435 | /* tuner path to channel 1 from port 3 */ | ||
2436 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | ||
1884 | if (dev->cx231xx_reset_analog_tuner) | 2437 | if (dev->cx231xx_reset_analog_tuner) |
1885 | dev->cx231xx_reset_analog_tuner(dev); | 2438 | dev->cx231xx_reset_analog_tuner(dev); |
1886 | } | 2439 | } |
2440 | |||
1887 | break; | 2441 | break; |
1888 | 2442 | ||
1889 | default: | 2443 | default: |
@@ -1913,9 +2467,6 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
1913 | 2467 | ||
1914 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, | 2468 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, |
1915 | 4); | 2469 | 4); |
1916 | cx231xx_info(" The data of PWR_CTL_EN register 0x74" | ||
1917 | "=0x%0x,0x%0x,0x%0x,0x%0x\n", | ||
1918 | value[0], value[1], value[2], value[3]); | ||
1919 | 2470 | ||
1920 | return status; | 2471 | return status; |
1921 | } | 2472 | } |
@@ -2000,6 +2551,8 @@ int cx231xx_stop_stream(struct cx231xx *dev, u32 ep_mask) | |||
2000 | int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type) | 2551 | int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type) |
2001 | { | 2552 | { |
2002 | int status = 0; | 2553 | int status = 0; |
2554 | u32 value = 0; | ||
2555 | u8 val[4] = { 0, 0, 0, 0 }; | ||
2003 | 2556 | ||
2004 | if (dev->udev->speed == USB_SPEED_HIGH) { | 2557 | if (dev->udev->speed == USB_SPEED_HIGH) { |
2005 | switch (media_type) { | 2558 | switch (media_type) { |
@@ -2026,10 +2579,36 @@ int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type) | |||
2026 | break; | 2579 | break; |
2027 | 2580 | ||
2028 | case 4: /* ts1 */ | 2581 | case 4: /* ts1 */ |
2029 | cx231xx_info("%s: set ts1 registers\n", __func__); | 2582 | cx231xx_info("%s: set ts1 registers", __func__); |
2583 | |||
2584 | if (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER) { | ||
2585 | cx231xx_info(" MPEG\n"); | ||
2586 | value &= 0xFFFFFFFC; | ||
2587 | value |= 0x3; | ||
2588 | |||
2589 | status = cx231xx_mode_register(dev, TS_MODE_REG, value); | ||
2590 | |||
2591 | val[0] = 0x04; | ||
2592 | val[1] = 0xA3; | ||
2593 | val[2] = 0x3B; | ||
2594 | val[3] = 0x00; | ||
2595 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2596 | TS1_CFG_REG, val, 4); | ||
2597 | |||
2598 | val[0] = 0x00; | ||
2599 | val[1] = 0x08; | ||
2600 | val[2] = 0x00; | ||
2601 | val[3] = 0x08; | ||
2602 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2603 | TS1_LENGTH_REG, val, 4); | ||
2604 | |||
2605 | } else { | ||
2606 | cx231xx_info(" BDA\n"); | ||
2030 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x101); | 2607 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x101); |
2031 | status = cx231xx_mode_register(dev, TS1_CFG_REG, 0x400); | 2608 | status = cx231xx_mode_register(dev, TS1_CFG_REG, 0x010); |
2609 | } | ||
2032 | break; | 2610 | break; |
2611 | |||
2033 | case 6: /* ts1 parallel mode */ | 2612 | case 6: /* ts1 parallel mode */ |
2034 | cx231xx_info("%s: set ts1 parrallel mode registers\n", | 2613 | cx231xx_info("%s: set ts1 parrallel mode registers\n", |
2035 | __func__); | 2614 | __func__); |
@@ -2128,7 +2707,7 @@ EXPORT_SYMBOL_GPL(cx231xx_capture_start); | |||
2128 | /***************************************************************************** | 2707 | /***************************************************************************** |
2129 | * G P I O B I T control functions * | 2708 | * G P I O B I T control functions * |
2130 | ******************************************************************************/ | 2709 | ******************************************************************************/ |
2131 | int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val) | 2710 | int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val) |
2132 | { | 2711 | { |
2133 | int status = 0; | 2712 | int status = 0; |
2134 | 2713 | ||
@@ -2137,7 +2716,7 @@ int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val) | |||
2137 | return status; | 2716 | return status; |
2138 | } | 2717 | } |
2139 | 2718 | ||
2140 | int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val) | 2719 | int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val) |
2141 | { | 2720 | { |
2142 | int status = 0; | 2721 | int status = 0; |
2143 | 2722 | ||
@@ -2344,7 +2923,7 @@ int cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data) | |||
2344 | return status; | 2923 | return status; |
2345 | } | 2924 | } |
2346 | 2925 | ||
2347 | int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 * buf) | 2926 | int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 *buf) |
2348 | { | 2927 | { |
2349 | u8 value = 0; | 2928 | u8 value = 0; |
2350 | int status = 0; | 2929 | int status = 0; |
@@ -2494,7 +3073,7 @@ int cx231xx_gpio_i2c_write_nak(struct cx231xx *dev) | |||
2494 | /* cx231xx_gpio_i2c_read | 3073 | /* cx231xx_gpio_i2c_read |
2495 | * Function to read data from gpio based I2C interface | 3074 | * Function to read data from gpio based I2C interface |
2496 | */ | 3075 | */ |
2497 | int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 * buf, u8 len) | 3076 | int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 *buf, u8 len) |
2498 | { | 3077 | { |
2499 | int status = 0; | 3078 | int status = 0; |
2500 | int i = 0; | 3079 | int i = 0; |
@@ -2538,7 +3117,7 @@ int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 * buf, u8 len) | |||
2538 | /* cx231xx_gpio_i2c_write | 3117 | /* cx231xx_gpio_i2c_write |
2539 | * Function to write data to gpio based I2C interface | 3118 | * Function to write data to gpio based I2C interface |
2540 | */ | 3119 | */ |
2541 | int cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 * buf, u8 len) | 3120 | int cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 *buf, u8 len) |
2542 | { | 3121 | { |
2543 | int status = 0; | 3122 | int status = 0; |
2544 | int i = 0; | 3123 | int i = 0; |