Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | |
| 3 | cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver |
| 4 | |
| 5 | (c) 2001 Michael Eskin, Tom Zakrajsek [Windows version] |
| 6 | (c) 2002 Yurij Sysoev <yurij@naturesoft.net> |
| 7 | (c) 2003 Gerd Knorr <kraxel@bytesex.org> |
| 8 | |
| 9 | ----------------------------------------------------------------------- |
| 10 | |
| 11 | Lot of voodoo here. Even the data sheet doesn't help to |
| 12 | understand what is going on here, the documentation for the audio |
| 13 | part of the cx2388x chip is *very* bad. |
| 14 | |
| 15 | Some of this comes from party done linux driver sources I got from |
| 16 | [undocumented]. |
| 17 | |
| 18 | Some comes from the dscaler sources, one of the dscaler driver guy works |
| 19 | for Conexant ... |
| 20 | |
| 21 | ----------------------------------------------------------------------- |
| 22 | |
| 23 | This program is free software; you can redistribute it and/or modify |
| 24 | it under the terms of the GNU General Public License as published by |
| 25 | the Free Software Foundation; either version 2 of the License, or |
| 26 | (at your option) any later version. |
| 27 | |
| 28 | This program is distributed in the hope that it will be useful, |
| 29 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 30 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 31 | GNU General Public License for more details. |
| 32 | |
| 33 | You should have received a copy of the GNU General Public License |
| 34 | along with this program; if not, write to the Free Software |
| 35 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 36 | */ |
| 37 | |
| 38 | #include <linux/module.h> |
| 39 | #include <linux/moduleparam.h> |
| 40 | #include <linux/errno.h> |
| 41 | #include <linux/kernel.h> |
| 42 | #include <linux/slab.h> |
| 43 | #include <linux/mm.h> |
| 44 | #include <linux/poll.h> |
| 45 | #include <linux/pci.h> |
| 46 | #include <linux/signal.h> |
| 47 | #include <linux/ioport.h> |
| 48 | #include <linux/sched.h> |
| 49 | #include <linux/types.h> |
| 50 | #include <linux/interrupt.h> |
| 51 | #include <linux/vmalloc.h> |
| 52 | #include <linux/init.h> |
| 53 | #include <linux/smp_lock.h> |
| 54 | #include <linux/delay.h> |
Michael Krufky | 1138ead | 2006-06-19 09:54:00 -0300 | [diff] [blame] | 55 | #include <linux/config.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | #include <linux/kthread.h> |
| 57 | |
| 58 | #include "cx88.h" |
| 59 | |
| 60 | static unsigned int audio_debug = 0; |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 61 | module_param(audio_debug, int, 0644); |
| 62 | MODULE_PARM_DESC(audio_debug, "enable debug messages [audio]"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
Panagiotis Christeas | 7d83e84 | 2006-01-15 07:01:54 -0200 | [diff] [blame] | 64 | static unsigned int always_analog = 0; |
| 65 | module_param(always_analog,int,0644); |
| 66 | MODULE_PARM_DESC(always_analog,"force analog audio out"); |
| 67 | |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #define dprintk(fmt, arg...) if (audio_debug) \ |
| 70 | printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) |
| 71 | |
| 72 | /* ----------------------------------------------------------- */ |
| 73 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 74 | static char *aud_ctl_names[64] = { |
| 75 | [EN_BTSC_FORCE_MONO] = "BTSC_FORCE_MONO", |
| 76 | [EN_BTSC_FORCE_STEREO] = "BTSC_FORCE_STEREO", |
| 77 | [EN_BTSC_FORCE_SAP] = "BTSC_FORCE_SAP", |
| 78 | [EN_BTSC_AUTO_STEREO] = "BTSC_AUTO_STEREO", |
| 79 | [EN_BTSC_AUTO_SAP] = "BTSC_AUTO_SAP", |
| 80 | [EN_A2_FORCE_MONO1] = "A2_FORCE_MONO1", |
| 81 | [EN_A2_FORCE_MONO2] = "A2_FORCE_MONO2", |
| 82 | [EN_A2_FORCE_STEREO] = "A2_FORCE_STEREO", |
| 83 | [EN_A2_AUTO_MONO2] = "A2_AUTO_MONO2", |
| 84 | [EN_A2_AUTO_STEREO] = "A2_AUTO_STEREO", |
| 85 | [EN_EIAJ_FORCE_MONO1] = "EIAJ_FORCE_MONO1", |
| 86 | [EN_EIAJ_FORCE_MONO2] = "EIAJ_FORCE_MONO2", |
| 87 | [EN_EIAJ_FORCE_STEREO] = "EIAJ_FORCE_STEREO", |
| 88 | [EN_EIAJ_AUTO_MONO2] = "EIAJ_AUTO_MONO2", |
| 89 | [EN_EIAJ_AUTO_STEREO] = "EIAJ_AUTO_STEREO", |
| 90 | [EN_NICAM_FORCE_MONO1] = "NICAM_FORCE_MONO1", |
| 91 | [EN_NICAM_FORCE_MONO2] = "NICAM_FORCE_MONO2", |
| 92 | [EN_NICAM_FORCE_STEREO] = "NICAM_FORCE_STEREO", |
| 93 | [EN_NICAM_AUTO_MONO2] = "NICAM_AUTO_MONO2", |
| 94 | [EN_NICAM_AUTO_STEREO] = "NICAM_AUTO_STEREO", |
| 95 | [EN_FMRADIO_FORCE_MONO] = "FMRADIO_FORCE_MONO", |
| 96 | [EN_FMRADIO_FORCE_STEREO] = "FMRADIO_FORCE_STEREO", |
| 97 | [EN_FMRADIO_AUTO_STEREO] = "FMRADIO_AUTO_STEREO", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | struct rlist { |
| 101 | u32 reg; |
| 102 | u32 val; |
| 103 | }; |
| 104 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 105 | static void set_audio_registers(struct cx88_core *core, const struct rlist *l) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | { |
| 107 | int i; |
| 108 | |
| 109 | for (i = 0; l[i].reg; i++) { |
| 110 | switch (l[i].reg) { |
| 111 | case AUD_PDF_DDS_CNST_BYTE2: |
| 112 | case AUD_PDF_DDS_CNST_BYTE1: |
| 113 | case AUD_PDF_DDS_CNST_BYTE0: |
| 114 | case AUD_QAM_MODE: |
| 115 | case AUD_PHACC_FREQ_8MSB: |
| 116 | case AUD_PHACC_FREQ_8LSB: |
| 117 | cx_writeb(l[i].reg, l[i].val); |
| 118 | break; |
| 119 | default: |
| 120 | cx_write(l[i].reg, l[i].val); |
| 121 | break; |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 126 | static void set_audio_start(struct cx88_core *core, u32 mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | { |
Ian Pickworth | 53a7338 | 2005-12-01 00:51:28 -0800 | [diff] [blame] | 128 | /* mute */ |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 129 | cx_write(AUD_VOL_CTL, (1 << 6)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Ian Pickworth | 53a7338 | 2005-12-01 00:51:28 -0800 | [diff] [blame] | 131 | /* start programming */ |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 132 | cx_write(AUD_INIT, mode); |
| 133 | cx_write(AUD_INIT_LD, 0x0001); |
| 134 | cx_write(AUD_SOFT_RESET, 0x0001); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 137 | static void set_audio_finish(struct cx88_core *core, u32 ctl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | { |
| 139 | u32 volume; |
| 140 | |
Ricardo Cerqueira | b63535f | 2006-06-18 00:21:49 -0300 | [diff] [blame] | 141 | #ifndef CONFIG_VIDEO_CX88_ALSA |
Mauro Carvalho Chehab | 6f502b8 | 2005-12-01 00:51:34 -0800 | [diff] [blame] | 142 | /* restart dma; This avoids buzz in NICAM and is good in others */ |
| 143 | cx88_stop_audio_dma(core); |
Mauro Carvalho Chehab | b7f355d | 2006-01-09 15:32:44 -0200 | [diff] [blame] | 144 | #endif |
Ian Pickworth | 53a7338 | 2005-12-01 00:51:28 -0800 | [diff] [blame] | 145 | cx_write(AUD_RATE_THRES_DMD, 0x000000C0); |
Ricardo Cerqueira | b63535f | 2006-06-18 00:21:49 -0300 | [diff] [blame] | 146 | #ifndef CONFIG_VIDEO_CX88_ALSA |
Mauro Carvalho Chehab | 6f502b8 | 2005-12-01 00:51:34 -0800 | [diff] [blame] | 147 | cx88_start_audio_dma(core); |
Mauro Carvalho Chehab | b7f355d | 2006-01-09 15:32:44 -0200 | [diff] [blame] | 148 | #endif |
Ian Pickworth | 53a7338 | 2005-12-01 00:51:28 -0800 | [diff] [blame] | 149 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | if (cx88_boards[core->board].blackbird) { |
Ian Pickworth | 53a7338 | 2005-12-01 00:51:28 -0800 | [diff] [blame] | 151 | /* sets sound input from external adc */ |
Michael Krufky | 7a3165a | 2006-04-13 13:06:28 -0300 | [diff] [blame] | 152 | switch (core->board) { |
| 153 | case CX88_BOARD_HAUPPAUGE_ROSLYN: |
| 154 | case CX88_BOARD_KWORLD_MCE200_DELUXE: |
Michael Krufky | 3febc04 | 2006-04-16 12:17:34 -0300 | [diff] [blame] | 155 | case CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT: |
Angelo Marconi | a312462 | 2006-05-09 18:27:48 -0300 | [diff] [blame] | 156 | case CX88_BOARD_PIXELVIEW_PLAYTV_P7000: |
Michael Krufky | 7597e8e | 2006-06-22 23:13:06 -0300 | [diff] [blame] | 157 | case CX88_BOARD_ASUS_PVR_416: |
Steven Toth | 0345c38 | 2006-01-09 15:25:17 -0200 | [diff] [blame] | 158 | cx_clear(AUD_CTL, EN_I2SIN_ENABLE); |
Michael Krufky | 7a3165a | 2006-04-13 13:06:28 -0300 | [diff] [blame] | 159 | break; |
| 160 | default: |
Steven Toth | 0345c38 | 2006-01-09 15:25:17 -0200 | [diff] [blame] | 161 | cx_set(AUD_CTL, EN_I2SIN_ENABLE); |
Michael Krufky | 7a3165a | 2006-04-13 13:06:28 -0300 | [diff] [blame] | 162 | } |
Steven Toth | 0345c38 | 2006-01-09 15:25:17 -0200 | [diff] [blame] | 163 | |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 164 | cx_write(AUD_I2SINPUTCNTL, 4); |
| 165 | cx_write(AUD_BAUDRATE, 1); |
Ian Pickworth | 53a7338 | 2005-12-01 00:51:28 -0800 | [diff] [blame] | 166 | /* 'pass-thru mode': this enables the i2s output to the mpeg encoder */ |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 167 | cx_set(AUD_CTL, EN_I2SOUT_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | cx_write(AUD_I2SOUTPUTCNTL, 1); |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 169 | cx_write(AUD_I2SCNTL, 0); |
Ian Pickworth | 53a7338 | 2005-12-01 00:51:28 -0800 | [diff] [blame] | 170 | /* cx_write(AUD_APB_IN_RATE_ADJ, 0); */ |
Panagiotis Christeas | 7d83e84 | 2006-01-15 07:01:54 -0200 | [diff] [blame] | 171 | } |
| 172 | if ((always_analog) || (!cx88_boards[core->board].blackbird)) { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 173 | ctl |= EN_DAC_ENABLE; |
| 174 | cx_write(AUD_CTL, ctl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 177 | /* finish programming */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | cx_write(AUD_SOFT_RESET, 0x0000); |
| 179 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 180 | /* unmute */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | volume = cx_sread(SHADOW_AUD_VOL_CTL); |
| 182 | cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, volume); |
| 183 | } |
| 184 | |
| 185 | /* ----------------------------------------------------------- */ |
| 186 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 187 | static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap, |
| 188 | u32 mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | { |
| 190 | static const struct rlist btsc[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 191 | {AUD_AFE_12DB_EN, 0x00000001}, |
| 192 | {AUD_OUT1_SEL, 0x00000013}, |
| 193 | {AUD_OUT1_SHIFT, 0x00000000}, |
| 194 | {AUD_POLY0_DDS_CONSTANT, 0x0012010c}, |
| 195 | {AUD_DMD_RA_DDS, 0x00c3e7aa}, |
| 196 | {AUD_DBX_IN_GAIN, 0x00004734}, |
| 197 | {AUD_DBX_WBE_GAIN, 0x00004640}, |
| 198 | {AUD_DBX_SE_GAIN, 0x00008d31}, |
| 199 | {AUD_DCOC_0_SRC, 0x0000001a}, |
| 200 | {AUD_IIR1_4_SEL, 0x00000021}, |
| 201 | {AUD_DCOC_PASS_IN, 0x00000003}, |
| 202 | {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, |
| 203 | {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, |
| 204 | {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, |
| 205 | {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, |
| 206 | {AUD_DN0_FREQ, 0x0000283b}, |
| 207 | {AUD_DN2_SRC_SEL, 0x00000008}, |
| 208 | {AUD_DN2_FREQ, 0x00003000}, |
| 209 | {AUD_DN2_AFC, 0x00000002}, |
| 210 | {AUD_DN2_SHFT, 0x00000000}, |
| 211 | {AUD_IIR2_2_SEL, 0x00000020}, |
| 212 | {AUD_IIR2_2_SHIFT, 0x00000000}, |
| 213 | {AUD_IIR2_3_SEL, 0x0000001f}, |
| 214 | {AUD_IIR2_3_SHIFT, 0x00000000}, |
| 215 | {AUD_CRDC1_SRC_SEL, 0x000003ce}, |
| 216 | {AUD_CRDC1_SHIFT, 0x00000000}, |
| 217 | {AUD_CORDIC_SHIFT_1, 0x00000007}, |
| 218 | {AUD_DCOC_1_SRC, 0x0000001b}, |
| 219 | {AUD_DCOC1_SHIFT, 0x00000000}, |
| 220 | {AUD_RDSI_SEL, 0x00000008}, |
| 221 | {AUD_RDSQ_SEL, 0x00000008}, |
| 222 | {AUD_RDSI_SHIFT, 0x00000000}, |
| 223 | {AUD_RDSQ_SHIFT, 0x00000000}, |
| 224 | {AUD_POLYPH80SCALEFAC, 0x00000003}, |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 225 | { /* end of list */ }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | }; |
| 227 | static const struct rlist btsc_sap[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 228 | {AUD_AFE_12DB_EN, 0x00000001}, |
| 229 | {AUD_DBX_IN_GAIN, 0x00007200}, |
| 230 | {AUD_DBX_WBE_GAIN, 0x00006200}, |
| 231 | {AUD_DBX_SE_GAIN, 0x00006200}, |
| 232 | {AUD_IIR1_1_SEL, 0x00000000}, |
| 233 | {AUD_IIR1_3_SEL, 0x00000001}, |
| 234 | {AUD_DN1_SRC_SEL, 0x00000007}, |
| 235 | {AUD_IIR1_4_SHIFT, 0x00000006}, |
| 236 | {AUD_IIR2_1_SHIFT, 0x00000000}, |
| 237 | {AUD_IIR2_2_SHIFT, 0x00000000}, |
| 238 | {AUD_IIR3_0_SHIFT, 0x00000000}, |
| 239 | {AUD_IIR3_1_SHIFT, 0x00000000}, |
| 240 | {AUD_IIR3_0_SEL, 0x0000000d}, |
| 241 | {AUD_IIR3_1_SEL, 0x0000000e}, |
| 242 | {AUD_DEEMPH1_SRC_SEL, 0x00000014}, |
| 243 | {AUD_DEEMPH1_SHIFT, 0x00000000}, |
| 244 | {AUD_DEEMPH1_G0, 0x00004000}, |
| 245 | {AUD_DEEMPH1_A0, 0x00000000}, |
| 246 | {AUD_DEEMPH1_B0, 0x00000000}, |
| 247 | {AUD_DEEMPH1_A1, 0x00000000}, |
| 248 | {AUD_DEEMPH1_B1, 0x00000000}, |
| 249 | {AUD_OUT0_SEL, 0x0000003f}, |
| 250 | {AUD_OUT1_SEL, 0x0000003f}, |
| 251 | {AUD_DN1_AFC, 0x00000002}, |
| 252 | {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, |
| 253 | {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, |
| 254 | {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, |
| 255 | {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, |
| 256 | {AUD_IIR1_0_SEL, 0x0000001d}, |
| 257 | {AUD_IIR1_2_SEL, 0x0000001e}, |
| 258 | {AUD_IIR2_1_SEL, 0x00000002}, |
| 259 | {AUD_IIR2_2_SEL, 0x00000004}, |
| 260 | {AUD_IIR3_2_SEL, 0x0000000f}, |
| 261 | {AUD_DCOC2_SHIFT, 0x00000001}, |
| 262 | {AUD_IIR3_2_SHIFT, 0x00000001}, |
| 263 | {AUD_DEEMPH0_SRC_SEL, 0x00000014}, |
| 264 | {AUD_CORDIC_SHIFT_1, 0x00000006}, |
| 265 | {AUD_POLY0_DDS_CONSTANT, 0x000e4db2}, |
| 266 | {AUD_DMD_RA_DDS, 0x00f696e6}, |
| 267 | {AUD_IIR2_3_SEL, 0x00000025}, |
| 268 | {AUD_IIR1_4_SEL, 0x00000021}, |
| 269 | {AUD_DN1_FREQ, 0x0000c965}, |
| 270 | {AUD_DCOC_PASS_IN, 0x00000003}, |
| 271 | {AUD_DCOC_0_SRC, 0x0000001a}, |
| 272 | {AUD_DCOC_1_SRC, 0x0000001b}, |
| 273 | {AUD_DCOC1_SHIFT, 0x00000000}, |
| 274 | {AUD_RDSI_SEL, 0x00000009}, |
| 275 | {AUD_RDSQ_SEL, 0x00000009}, |
| 276 | {AUD_RDSI_SHIFT, 0x00000000}, |
| 277 | {AUD_RDSQ_SHIFT, 0x00000000}, |
| 278 | {AUD_POLYPH80SCALEFAC, 0x00000003}, |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 279 | { /* end of list */ }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | }; |
| 281 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 282 | mode |= EN_FMRADIO_EN_RDS; |
| 283 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | if (sap) { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 285 | dprintk("%s SAP (status: unknown)\n", __FUNCTION__); |
| 286 | set_audio_start(core, SEL_SAP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | set_audio_registers(core, btsc_sap); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 288 | set_audio_finish(core, mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | } else { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 290 | dprintk("%s (status: known-good)\n", __FUNCTION__); |
| 291 | set_audio_start(core, SEL_BTSC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | set_audio_registers(core, btsc); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 293 | set_audio_finish(core, mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | } |
| 296 | |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 297 | static void set_audio_standard_NICAM(struct cx88_core *core, u32 mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | { |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 299 | static const struct rlist nicam_l[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 300 | {AUD_AFE_12DB_EN, 0x00000001}, |
| 301 | {AUD_RATE_ADJ1, 0x00000060}, |
| 302 | {AUD_RATE_ADJ2, 0x000000F9}, |
| 303 | {AUD_RATE_ADJ3, 0x000001CC}, |
| 304 | {AUD_RATE_ADJ4, 0x000002B3}, |
| 305 | {AUD_RATE_ADJ5, 0x00000726}, |
| 306 | {AUD_DEEMPHDENOM1_R, 0x0000F3D0}, |
| 307 | {AUD_DEEMPHDENOM2_R, 0x00000000}, |
| 308 | {AUD_ERRLOGPERIOD_R, 0x00000064}, |
| 309 | {AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF}, |
| 310 | {AUD_ERRINTRPTTHSHLD2_R, 0x0000001F}, |
| 311 | {AUD_ERRINTRPTTHSHLD3_R, 0x0000000F}, |
| 312 | {AUD_POLYPH80SCALEFAC, 0x00000003}, |
| 313 | {AUD_DMD_RA_DDS, 0x00C00000}, |
| 314 | {AUD_PLL_INT, 0x0000001E}, |
| 315 | {AUD_PLL_DDS, 0x00000000}, |
| 316 | {AUD_PLL_FRAC, 0x0000E542}, |
| 317 | {AUD_START_TIMER, 0x00000000}, |
| 318 | {AUD_DEEMPHNUMER1_R, 0x000353DE}, |
| 319 | {AUD_DEEMPHNUMER2_R, 0x000001B1}, |
| 320 | {AUD_PDF_DDS_CNST_BYTE2, 0x06}, |
| 321 | {AUD_PDF_DDS_CNST_BYTE1, 0x82}, |
| 322 | {AUD_PDF_DDS_CNST_BYTE0, 0x12}, |
| 323 | {AUD_QAM_MODE, 0x05}, |
| 324 | {AUD_PHACC_FREQ_8MSB, 0x34}, |
| 325 | {AUD_PHACC_FREQ_8LSB, 0x4C}, |
| 326 | {AUD_DEEMPHGAIN_R, 0x00006680}, |
| 327 | {AUD_RATE_THRES_DMD, 0x000000C0}, |
| 328 | { /* end of list */ }, |
| 329 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 331 | static const struct rlist nicam_bgdki_common[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 332 | {AUD_AFE_12DB_EN, 0x00000001}, |
| 333 | {AUD_RATE_ADJ1, 0x00000010}, |
| 334 | {AUD_RATE_ADJ2, 0x00000040}, |
| 335 | {AUD_RATE_ADJ3, 0x00000100}, |
| 336 | {AUD_RATE_ADJ4, 0x00000400}, |
| 337 | {AUD_RATE_ADJ5, 0x00001000}, |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 338 | {AUD_ERRLOGPERIOD_R, 0x00000fff}, |
| 339 | {AUD_ERRINTRPTTHSHLD1_R, 0x000003ff}, |
| 340 | {AUD_ERRINTRPTTHSHLD2_R, 0x000000ff}, |
| 341 | {AUD_ERRINTRPTTHSHLD3_R, 0x0000003f}, |
| 342 | {AUD_POLYPH80SCALEFAC, 0x00000003}, |
| 343 | {AUD_DEEMPHGAIN_R, 0x000023c2}, |
| 344 | {AUD_DEEMPHNUMER1_R, 0x0002a7bc}, |
| 345 | {AUD_DEEMPHNUMER2_R, 0x0003023e}, |
| 346 | {AUD_DEEMPHDENOM1_R, 0x0000f3d0}, |
| 347 | {AUD_DEEMPHDENOM2_R, 0x00000000}, |
Michael Krufky | d0fcdd7 | 2005-11-08 21:38:32 -0800 | [diff] [blame] | 348 | {AUD_PDF_DDS_CNST_BYTE2, 0x06}, |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 349 | {AUD_PDF_DDS_CNST_BYTE1, 0x82}, |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 350 | {AUD_QAM_MODE, 0x05}, |
| 351 | { /* end of list */ }, |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 352 | }; |
| 353 | |
| 354 | static const struct rlist nicam_i[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 355 | {AUD_PDF_DDS_CNST_BYTE0, 0x12}, |
| 356 | {AUD_PHACC_FREQ_8MSB, 0x3a}, |
| 357 | {AUD_PHACC_FREQ_8LSB, 0x93}, |
| 358 | { /* end of list */ }, |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 359 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 361 | static const struct rlist nicam_default[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 362 | {AUD_PDF_DDS_CNST_BYTE0, 0x16}, |
| 363 | {AUD_PHACC_FREQ_8MSB, 0x34}, |
| 364 | {AUD_PHACC_FREQ_8LSB, 0x4c}, |
| 365 | { /* end of list */ }, |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 366 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | |
Torsten Seeboth | 7f7e846 | 2005-11-08 21:38:51 -0800 | [diff] [blame] | 368 | set_audio_start(core,SEL_NICAM); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 369 | switch (core->tvaudio) { |
| 370 | case WW_L: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 371 | dprintk("%s SECAM-L NICAM (status: devel)\n", __FUNCTION__); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 372 | set_audio_registers(core, nicam_l); |
| 373 | break; |
| 374 | case WW_I: |
Ian Pickworth | 53a7338 | 2005-12-01 00:51:28 -0800 | [diff] [blame] | 375 | dprintk("%s PAL-I NICAM (status: known-good)\n", __FUNCTION__); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 376 | set_audio_registers(core, nicam_bgdki_common); |
| 377 | set_audio_registers(core, nicam_i); |
| 378 | break; |
| 379 | default: |
Ian Pickworth | 53a7338 | 2005-12-01 00:51:28 -0800 | [diff] [blame] | 380 | dprintk("%s PAL-BGDK NICAM (status: known-good)\n", __FUNCTION__); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 381 | set_audio_registers(core, nicam_bgdki_common); |
| 382 | set_audio_registers(core, nicam_default); |
| 383 | break; |
| 384 | }; |
| 385 | |
| 386 | mode |= EN_DMTRX_LR | EN_DMTRX_BYPASS; |
| 387 | set_audio_finish(core, mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | } |
| 389 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 390 | static void set_audio_standard_A2(struct cx88_core *core, u32 mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | { |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 392 | static const struct rlist a2_bgdk_common[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 393 | {AUD_ERRLOGPERIOD_R, 0x00000064}, |
| 394 | {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, |
| 395 | {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, |
| 396 | {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, |
| 397 | {AUD_PDF_DDS_CNST_BYTE2, 0x06}, |
| 398 | {AUD_PDF_DDS_CNST_BYTE1, 0x82}, |
| 399 | {AUD_PDF_DDS_CNST_BYTE0, 0x12}, |
| 400 | {AUD_QAM_MODE, 0x05}, |
| 401 | {AUD_PHACC_FREQ_8MSB, 0x34}, |
| 402 | {AUD_PHACC_FREQ_8LSB, 0x4c}, |
| 403 | {AUD_RATE_ADJ1, 0x00000100}, |
| 404 | {AUD_RATE_ADJ2, 0x00000200}, |
| 405 | {AUD_RATE_ADJ3, 0x00000300}, |
| 406 | {AUD_RATE_ADJ4, 0x00000400}, |
| 407 | {AUD_RATE_ADJ5, 0x00000500}, |
| 408 | {AUD_THR_FR, 0x00000000}, |
| 409 | {AAGC_HYST, 0x0000001a}, |
| 410 | {AUD_PILOT_BQD_1_K0, 0x0000755b}, |
| 411 | {AUD_PILOT_BQD_1_K1, 0x00551340}, |
| 412 | {AUD_PILOT_BQD_1_K2, 0x006d30be}, |
| 413 | {AUD_PILOT_BQD_1_K3, 0xffd394af}, |
| 414 | {AUD_PILOT_BQD_1_K4, 0x00400000}, |
| 415 | {AUD_PILOT_BQD_2_K0, 0x00040000}, |
| 416 | {AUD_PILOT_BQD_2_K1, 0x002a4841}, |
| 417 | {AUD_PILOT_BQD_2_K2, 0x00400000}, |
| 418 | {AUD_PILOT_BQD_2_K3, 0x00000000}, |
| 419 | {AUD_PILOT_BQD_2_K4, 0x00000000}, |
| 420 | {AUD_MODE_CHG_TIMER, 0x00000040}, |
| 421 | {AUD_AFE_12DB_EN, 0x00000001}, |
| 422 | {AUD_CORDIC_SHIFT_0, 0x00000007}, |
| 423 | {AUD_CORDIC_SHIFT_1, 0x00000007}, |
| 424 | {AUD_DEEMPH0_G0, 0x00000380}, |
| 425 | {AUD_DEEMPH1_G0, 0x00000380}, |
| 426 | {AUD_DCOC_0_SRC, 0x0000001a}, |
| 427 | {AUD_DCOC0_SHIFT, 0x00000000}, |
| 428 | {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, |
| 429 | {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, |
| 430 | {AUD_DCOC_PASS_IN, 0x00000003}, |
| 431 | {AUD_IIR3_0_SEL, 0x00000021}, |
| 432 | {AUD_DN2_AFC, 0x00000002}, |
| 433 | {AUD_DCOC_1_SRC, 0x0000001b}, |
| 434 | {AUD_DCOC1_SHIFT, 0x00000000}, |
| 435 | {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, |
| 436 | {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, |
| 437 | {AUD_IIR3_1_SEL, 0x00000023}, |
| 438 | {AUD_RDSI_SEL, 0x00000017}, |
| 439 | {AUD_RDSI_SHIFT, 0x00000000}, |
| 440 | {AUD_RDSQ_SEL, 0x00000017}, |
| 441 | {AUD_RDSQ_SHIFT, 0x00000000}, |
| 442 | {AUD_PLL_INT, 0x0000001e}, |
| 443 | {AUD_PLL_DDS, 0x00000000}, |
| 444 | {AUD_PLL_FRAC, 0x0000e542}, |
| 445 | {AUD_POLYPH80SCALEFAC, 0x00000001}, |
| 446 | {AUD_START_TIMER, 0x00000000}, |
| 447 | { /* end of list */ }, |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 448 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 450 | static const struct rlist a2_bg[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 451 | {AUD_DMD_RA_DDS, 0x002a4f2f}, |
| 452 | {AUD_C1_UP_THR, 0x00007000}, |
| 453 | {AUD_C1_LO_THR, 0x00005400}, |
| 454 | {AUD_C2_UP_THR, 0x00005400}, |
| 455 | {AUD_C2_LO_THR, 0x00003000}, |
| 456 | { /* end of list */ }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | }; |
| 458 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 459 | static const struct rlist a2_dk[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 460 | {AUD_DMD_RA_DDS, 0x002a4f2f}, |
| 461 | {AUD_C1_UP_THR, 0x00007000}, |
| 462 | {AUD_C1_LO_THR, 0x00005400}, |
| 463 | {AUD_C2_UP_THR, 0x00005400}, |
| 464 | {AUD_C2_LO_THR, 0x00003000}, |
| 465 | {AUD_DN0_FREQ, 0x00003a1c}, |
| 466 | {AUD_DN2_FREQ, 0x0000d2e0}, |
| 467 | { /* end of list */ }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | }; |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 469 | |
| 470 | static const struct rlist a1_i[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 471 | {AUD_ERRLOGPERIOD_R, 0x00000064}, |
| 472 | {AUD_ERRINTRPTTHSHLD1_R, 0x00000fff}, |
| 473 | {AUD_ERRINTRPTTHSHLD2_R, 0x0000001f}, |
| 474 | {AUD_ERRINTRPTTHSHLD3_R, 0x0000000f}, |
| 475 | {AUD_PDF_DDS_CNST_BYTE2, 0x06}, |
| 476 | {AUD_PDF_DDS_CNST_BYTE1, 0x82}, |
| 477 | {AUD_PDF_DDS_CNST_BYTE0, 0x12}, |
| 478 | {AUD_QAM_MODE, 0x05}, |
| 479 | {AUD_PHACC_FREQ_8MSB, 0x3a}, |
| 480 | {AUD_PHACC_FREQ_8LSB, 0x93}, |
| 481 | {AUD_DMD_RA_DDS, 0x002a4f2f}, |
| 482 | {AUD_PLL_INT, 0x0000001e}, |
| 483 | {AUD_PLL_DDS, 0x00000004}, |
| 484 | {AUD_PLL_FRAC, 0x0000e542}, |
| 485 | {AUD_RATE_ADJ1, 0x00000100}, |
| 486 | {AUD_RATE_ADJ2, 0x00000200}, |
| 487 | {AUD_RATE_ADJ3, 0x00000300}, |
| 488 | {AUD_RATE_ADJ4, 0x00000400}, |
| 489 | {AUD_RATE_ADJ5, 0x00000500}, |
| 490 | {AUD_THR_FR, 0x00000000}, |
| 491 | {AUD_PILOT_BQD_1_K0, 0x0000755b}, |
| 492 | {AUD_PILOT_BQD_1_K1, 0x00551340}, |
| 493 | {AUD_PILOT_BQD_1_K2, 0x006d30be}, |
| 494 | {AUD_PILOT_BQD_1_K3, 0xffd394af}, |
| 495 | {AUD_PILOT_BQD_1_K4, 0x00400000}, |
| 496 | {AUD_PILOT_BQD_2_K0, 0x00040000}, |
| 497 | {AUD_PILOT_BQD_2_K1, 0x002a4841}, |
| 498 | {AUD_PILOT_BQD_2_K2, 0x00400000}, |
| 499 | {AUD_PILOT_BQD_2_K3, 0x00000000}, |
| 500 | {AUD_PILOT_BQD_2_K4, 0x00000000}, |
| 501 | {AUD_MODE_CHG_TIMER, 0x00000060}, |
| 502 | {AUD_AFE_12DB_EN, 0x00000001}, |
| 503 | {AAGC_HYST, 0x0000000a}, |
| 504 | {AUD_CORDIC_SHIFT_0, 0x00000007}, |
| 505 | {AUD_CORDIC_SHIFT_1, 0x00000007}, |
| 506 | {AUD_C1_UP_THR, 0x00007000}, |
| 507 | {AUD_C1_LO_THR, 0x00005400}, |
| 508 | {AUD_C2_UP_THR, 0x00005400}, |
| 509 | {AUD_C2_LO_THR, 0x00003000}, |
| 510 | {AUD_DCOC_0_SRC, 0x0000001a}, |
| 511 | {AUD_DCOC0_SHIFT, 0x00000000}, |
| 512 | {AUD_DCOC_0_SHIFT_IN0, 0x0000000a}, |
| 513 | {AUD_DCOC_0_SHIFT_IN1, 0x00000008}, |
| 514 | {AUD_DCOC_PASS_IN, 0x00000003}, |
| 515 | {AUD_IIR3_0_SEL, 0x00000021}, |
| 516 | {AUD_DN2_AFC, 0x00000002}, |
| 517 | {AUD_DCOC_1_SRC, 0x0000001b}, |
| 518 | {AUD_DCOC1_SHIFT, 0x00000000}, |
| 519 | {AUD_DCOC_1_SHIFT_IN0, 0x0000000a}, |
| 520 | {AUD_DCOC_1_SHIFT_IN1, 0x00000008}, |
| 521 | {AUD_IIR3_1_SEL, 0x00000023}, |
| 522 | {AUD_DN0_FREQ, 0x000035a3}, |
| 523 | {AUD_DN2_FREQ, 0x000029c7}, |
| 524 | {AUD_CRDC0_SRC_SEL, 0x00000511}, |
| 525 | {AUD_IIR1_0_SEL, 0x00000001}, |
| 526 | {AUD_IIR1_1_SEL, 0x00000000}, |
| 527 | {AUD_IIR3_2_SEL, 0x00000003}, |
| 528 | {AUD_IIR3_2_SHIFT, 0x00000000}, |
| 529 | {AUD_IIR3_0_SEL, 0x00000002}, |
| 530 | {AUD_IIR2_0_SEL, 0x00000021}, |
| 531 | {AUD_IIR2_0_SHIFT, 0x00000002}, |
| 532 | {AUD_DEEMPH0_SRC_SEL, 0x0000000b}, |
| 533 | {AUD_DEEMPH1_SRC_SEL, 0x0000000b}, |
| 534 | {AUD_POLYPH80SCALEFAC, 0x00000001}, |
| 535 | {AUD_START_TIMER, 0x00000000}, |
| 536 | { /* end of list */ }, |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 537 | }; |
| 538 | |
| 539 | static const struct rlist am_l[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 540 | {AUD_ERRLOGPERIOD_R, 0x00000064}, |
| 541 | {AUD_ERRINTRPTTHSHLD1_R, 0x00000FFF}, |
| 542 | {AUD_ERRINTRPTTHSHLD2_R, 0x0000001F}, |
| 543 | {AUD_ERRINTRPTTHSHLD3_R, 0x0000000F}, |
| 544 | {AUD_PDF_DDS_CNST_BYTE2, 0x48}, |
| 545 | {AUD_PDF_DDS_CNST_BYTE1, 0x3D}, |
| 546 | {AUD_QAM_MODE, 0x00}, |
| 547 | {AUD_PDF_DDS_CNST_BYTE0, 0xf5}, |
| 548 | {AUD_PHACC_FREQ_8MSB, 0x3a}, |
| 549 | {AUD_PHACC_FREQ_8LSB, 0x4a}, |
| 550 | {AUD_DEEMPHGAIN_R, 0x00006680}, |
| 551 | {AUD_DEEMPHNUMER1_R, 0x000353DE}, |
| 552 | {AUD_DEEMPHNUMER2_R, 0x000001B1}, |
| 553 | {AUD_DEEMPHDENOM1_R, 0x0000F3D0}, |
| 554 | {AUD_DEEMPHDENOM2_R, 0x00000000}, |
| 555 | {AUD_FM_MODE_ENABLE, 0x00000007}, |
| 556 | {AUD_POLYPH80SCALEFAC, 0x00000003}, |
| 557 | {AUD_AFE_12DB_EN, 0x00000001}, |
| 558 | {AAGC_GAIN, 0x00000000}, |
| 559 | {AAGC_HYST, 0x00000018}, |
| 560 | {AAGC_DEF, 0x00000020}, |
| 561 | {AUD_DN0_FREQ, 0x00000000}, |
| 562 | {AUD_POLY0_DDS_CONSTANT, 0x000E4DB2}, |
| 563 | {AUD_DCOC_0_SRC, 0x00000021}, |
| 564 | {AUD_IIR1_0_SEL, 0x00000000}, |
| 565 | {AUD_IIR1_0_SHIFT, 0x00000007}, |
| 566 | {AUD_IIR1_1_SEL, 0x00000002}, |
| 567 | {AUD_IIR1_1_SHIFT, 0x00000000}, |
| 568 | {AUD_DCOC_1_SRC, 0x00000003}, |
| 569 | {AUD_DCOC1_SHIFT, 0x00000000}, |
| 570 | {AUD_DCOC_PASS_IN, 0x00000000}, |
| 571 | {AUD_IIR1_2_SEL, 0x00000023}, |
| 572 | {AUD_IIR1_2_SHIFT, 0x00000000}, |
| 573 | {AUD_IIR1_3_SEL, 0x00000004}, |
| 574 | {AUD_IIR1_3_SHIFT, 0x00000007}, |
| 575 | {AUD_IIR1_4_SEL, 0x00000005}, |
| 576 | {AUD_IIR1_4_SHIFT, 0x00000007}, |
| 577 | {AUD_IIR3_0_SEL, 0x00000007}, |
| 578 | {AUD_IIR3_0_SHIFT, 0x00000000}, |
| 579 | {AUD_DEEMPH0_SRC_SEL, 0x00000011}, |
| 580 | {AUD_DEEMPH0_SHIFT, 0x00000000}, |
| 581 | {AUD_DEEMPH0_G0, 0x00007000}, |
| 582 | {AUD_DEEMPH0_A0, 0x00000000}, |
| 583 | {AUD_DEEMPH0_B0, 0x00000000}, |
| 584 | {AUD_DEEMPH0_A1, 0x00000000}, |
| 585 | {AUD_DEEMPH0_B1, 0x00000000}, |
| 586 | {AUD_DEEMPH1_SRC_SEL, 0x00000011}, |
| 587 | {AUD_DEEMPH1_SHIFT, 0x00000000}, |
| 588 | {AUD_DEEMPH1_G0, 0x00007000}, |
| 589 | {AUD_DEEMPH1_A0, 0x00000000}, |
| 590 | {AUD_DEEMPH1_B0, 0x00000000}, |
| 591 | {AUD_DEEMPH1_A1, 0x00000000}, |
| 592 | {AUD_DEEMPH1_B1, 0x00000000}, |
| 593 | {AUD_OUT0_SEL, 0x0000003F}, |
| 594 | {AUD_OUT1_SEL, 0x0000003F}, |
| 595 | {AUD_DMD_RA_DDS, 0x00F5C285}, |
| 596 | {AUD_PLL_INT, 0x0000001E}, |
| 597 | {AUD_PLL_DDS, 0x00000000}, |
| 598 | {AUD_PLL_FRAC, 0x0000E542}, |
| 599 | {AUD_RATE_ADJ1, 0x00000100}, |
| 600 | {AUD_RATE_ADJ2, 0x00000200}, |
| 601 | {AUD_RATE_ADJ3, 0x00000300}, |
| 602 | {AUD_RATE_ADJ4, 0x00000400}, |
| 603 | {AUD_RATE_ADJ5, 0x00000500}, |
| 604 | {AUD_RATE_THRES_DMD, 0x000000C0}, |
| 605 | { /* end of list */ }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | }; |
| 607 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 608 | static const struct rlist a2_deemph50[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 609 | {AUD_DEEMPH0_G0, 0x00000380}, |
| 610 | {AUD_DEEMPH1_G0, 0x00000380}, |
| 611 | {AUD_DEEMPHGAIN_R, 0x000011e1}, |
| 612 | {AUD_DEEMPHNUMER1_R, 0x0002a7bc}, |
| 613 | {AUD_DEEMPHNUMER2_R, 0x0003023c}, |
| 614 | { /* end of list */ }, |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 615 | }; |
| 616 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 617 | set_audio_start(core, SEL_A2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | switch (core->tvaudio) { |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 619 | case WW_BG: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 620 | dprintk("%s PAL-BG A1/2 (status: known-good)\n", __FUNCTION__); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 621 | set_audio_registers(core, a2_bgdk_common); |
| 622 | set_audio_registers(core, a2_bg); |
| 623 | set_audio_registers(core, a2_deemph50); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | break; |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 625 | case WW_DK: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 626 | dprintk("%s PAL-DK A1/2 (status: known-good)\n", __FUNCTION__); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 627 | set_audio_registers(core, a2_bgdk_common); |
| 628 | set_audio_registers(core, a2_dk); |
| 629 | set_audio_registers(core, a2_deemph50); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | break; |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 631 | case WW_I: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 632 | dprintk("%s PAL-I A1 (status: known-good)\n", __FUNCTION__); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 633 | set_audio_registers(core, a1_i); |
| 634 | set_audio_registers(core, a2_deemph50); |
| 635 | break; |
| 636 | case WW_L: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 637 | dprintk("%s AM-L (status: devel)\n", __FUNCTION__); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 638 | set_audio_registers(core, am_l); |
| 639 | break; |
| 640 | default: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 641 | dprintk("%s Warning: wrong value\n", __FUNCTION__); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 642 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | break; |
| 644 | }; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 645 | |
| 646 | mode |= EN_FMRADIO_EN_RDS | EN_DMTRX_SUMDIFF; |
| 647 | set_audio_finish(core, mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | static void set_audio_standard_EIAJ(struct cx88_core *core) |
| 651 | { |
| 652 | static const struct rlist eiaj[] = { |
| 653 | /* TODO: eiaj register settings are not there yet ... */ |
| 654 | |
| 655 | { /* end of list */ }, |
| 656 | }; |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 657 | dprintk("%s (status: unknown)\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 659 | set_audio_start(core, SEL_EIAJ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | set_audio_registers(core, eiaj); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 661 | set_audio_finish(core, EN_EIAJ_AUTO_STEREO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | } |
| 663 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 664 | static void set_audio_standard_FM(struct cx88_core *core, |
| 665 | enum cx88_deemph_type deemph) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | { |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 667 | static const struct rlist fm_deemph_50[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 668 | {AUD_DEEMPH0_G0, 0x0C45}, |
| 669 | {AUD_DEEMPH0_A0, 0x6262}, |
| 670 | {AUD_DEEMPH0_B0, 0x1C29}, |
| 671 | {AUD_DEEMPH0_A1, 0x3FC66}, |
| 672 | {AUD_DEEMPH0_B1, 0x399A}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 674 | {AUD_DEEMPH1_G0, 0x0D80}, |
| 675 | {AUD_DEEMPH1_A0, 0x6262}, |
| 676 | {AUD_DEEMPH1_B0, 0x1C29}, |
| 677 | {AUD_DEEMPH1_A1, 0x3FC66}, |
| 678 | {AUD_DEEMPH1_B1, 0x399A}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 680 | {AUD_POLYPH80SCALEFAC, 0x0003}, |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 681 | { /* end of list */ }, |
| 682 | }; |
| 683 | static const struct rlist fm_deemph_75[] = { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 684 | {AUD_DEEMPH0_G0, 0x091B}, |
| 685 | {AUD_DEEMPH0_A0, 0x6B68}, |
| 686 | {AUD_DEEMPH0_B0, 0x11EC}, |
| 687 | {AUD_DEEMPH0_A1, 0x3FC66}, |
| 688 | {AUD_DEEMPH0_B1, 0x399A}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 690 | {AUD_DEEMPH1_G0, 0x0AA0}, |
| 691 | {AUD_DEEMPH1_A0, 0x6B68}, |
| 692 | {AUD_DEEMPH1_B0, 0x11EC}, |
| 693 | {AUD_DEEMPH1_A1, 0x3FC66}, |
| 694 | {AUD_DEEMPH1_B1, 0x399A}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 696 | {AUD_POLYPH80SCALEFAC, 0x0003}, |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 697 | { /* end of list */ }, |
| 698 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 700 | /* It is enough to leave default values? */ |
| 701 | static const struct rlist fm_no_deemph[] = { |
| 702 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 703 | {AUD_POLYPH80SCALEFAC, 0x0003}, |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 704 | { /* end of list */ }, |
| 705 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 707 | dprintk("%s (status: unknown)\n", __FUNCTION__); |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 708 | set_audio_start(core, SEL_FMRADIO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 710 | switch (deemph) { |
| 711 | case FM_NO_DEEMPH: |
| 712 | set_audio_registers(core, fm_no_deemph); |
| 713 | break; |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 714 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 715 | case FM_DEEMPH_50: |
| 716 | set_audio_registers(core, fm_deemph_50); |
| 717 | break; |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 718 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 719 | case FM_DEEMPH_75: |
| 720 | set_audio_registers(core, fm_deemph_75); |
| 721 | break; |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 722 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 724 | set_audio_finish(core, EN_FMRADIO_AUTO_STEREO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | /* ----------------------------------------------------------- */ |
| 728 | |
Adrian Bunk | dff47bf | 2006-06-24 19:25:43 -0300 | [diff] [blame] | 729 | static int cx88_detect_nicam(struct cx88_core *core) |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 730 | { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 731 | int i, j = 0; |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 732 | |
| 733 | dprintk("start nicam autodetect.\n"); |
| 734 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 735 | for (i = 0; i < 6; i++) { |
| 736 | /* if bit1=1 then nicam is detected */ |
| 737 | j += ((cx_read(AUD_NICAM_STATUS2) & 0x02) >> 1); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 738 | |
Ian Pickworth | 53a7338 | 2005-12-01 00:51:28 -0800 | [diff] [blame] | 739 | if (j == 1) { |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 740 | dprintk("nicam is detected.\n"); |
| 741 | return 1; |
| 742 | } |
| 743 | |
| 744 | /* wait a little bit for next reading status */ |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 745 | msleep(10); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | dprintk("nicam is not detected.\n"); |
| 749 | return 0; |
| 750 | } |
| 751 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | void cx88_set_tvaudio(struct cx88_core *core) |
| 753 | { |
| 754 | switch (core->tvaudio) { |
| 755 | case WW_BTSC: |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 756 | set_audio_standard_BTSC(core, 0, EN_BTSC_AUTO_STEREO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | break; |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 758 | case WW_BG: |
| 759 | case WW_DK: |
| 760 | case WW_I: |
| 761 | case WW_L: |
| 762 | /* prepare all dsp registers */ |
| 763 | set_audio_standard_A2(core, EN_A2_FORCE_MONO1); |
| 764 | |
| 765 | /* set nicam mode - otherwise |
| 766 | AUD_NICAM_STATUS2 contains wrong values */ |
Torsten Seeboth | 7f7e846 | 2005-11-08 21:38:51 -0800 | [diff] [blame] | 767 | set_audio_standard_NICAM(core, EN_NICAM_AUTO_STEREO); |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 768 | if (0 == cx88_detect_nicam(core)) { |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 769 | /* fall back to fm / am mono */ |
| 770 | set_audio_standard_A2(core, EN_A2_FORCE_MONO1); |
| 771 | core->use_nicam = 0; |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 772 | } else { |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 773 | core->use_nicam = 1; |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 774 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | break; |
| 776 | case WW_EIAJ: |
| 777 | set_audio_standard_EIAJ(core); |
| 778 | break; |
| 779 | case WW_FM: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 780 | set_audio_standard_FM(core, FM_NO_DEEMPH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 782 | case WW_NONE: |
| 783 | default: |
| 784 | printk("%s/0: unknown tv audio mode [%d]\n", |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 785 | core->name, core->tvaudio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | break; |
| 787 | } |
| 788 | return; |
| 789 | } |
| 790 | |
| 791 | void cx88_newstation(struct cx88_core *core) |
| 792 | { |
| 793 | core->audiomode_manual = UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t) |
| 797 | { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 798 | static char *m[] = { "stereo", "dual mono", "mono", "sap" }; |
| 799 | static char *p[] = { "no pilot", "pilot c1", "pilot c2", "?" }; |
| 800 | u32 reg, mode, pilot; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 802 | reg = cx_read(AUD_STATUS); |
| 803 | mode = reg & 0x03; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | pilot = (reg >> 2) & 0x03; |
| 805 | |
| 806 | if (core->astat != reg) |
| 807 | dprintk("AUD_STATUS: 0x%x [%s/%s] ctl=%s\n", |
| 808 | reg, m[mode], p[pilot], |
| 809 | aud_ctl_names[cx_read(AUD_CTL) & 63]); |
| 810 | core->astat = reg; |
| 811 | |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 812 | /* TODO |
| 813 | Reading from AUD_STATUS is not enough |
| 814 | for auto-detecting sap/dual-fm/nicam. |
| 815 | Add some code here later. |
| 816 | */ |
| 817 | |
| 818 | # if 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP | |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 820 | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | t->rxsubchans = V4L2_TUNER_SUB_MONO; |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 822 | t->audmode = V4L2_TUNER_MODE_MONO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | |
| 824 | switch (core->tvaudio) { |
| 825 | case WW_BTSC: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 826 | t->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_SAP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | t->rxsubchans = V4L2_TUNER_SUB_STEREO; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 828 | if (1 == pilot) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | /* SAP */ |
| 830 | t->rxsubchans |= V4L2_TUNER_SUB_SAP; |
| 831 | } |
| 832 | break; |
| 833 | case WW_A2_BG: |
| 834 | case WW_A2_DK: |
| 835 | case WW_A2_M: |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 836 | if (1 == pilot) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | /* stereo */ |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 838 | t->rxsubchans = |
| 839 | V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | if (0 == mode) |
| 841 | t->audmode = V4L2_TUNER_MODE_STEREO; |
| 842 | } |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 843 | if (2 == pilot) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | /* dual language -- FIXME */ |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 845 | t->rxsubchans = |
| 846 | V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | t->audmode = V4L2_TUNER_MODE_LANG1; |
| 848 | } |
| 849 | break; |
| 850 | case WW_NICAM_BGDKL: |
| 851 | if (0 == mode) { |
| 852 | t->audmode = V4L2_TUNER_MODE_STEREO; |
| 853 | t->rxsubchans |= V4L2_TUNER_SUB_STEREO; |
| 854 | } |
| 855 | break; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 856 | case WW_SYSTEM_L_AM: |
| 857 | if (0x0 == mode && !(cx_read(AUD_INIT) & 0x04)) { |
| 858 | t->audmode = V4L2_TUNER_MODE_STEREO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | t->rxsubchans |= V4L2_TUNER_SUB_STEREO; |
| 860 | } |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 861 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | default: |
| 863 | /* nothing */ |
| 864 | break; |
| 865 | } |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 866 | # endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | return; |
| 868 | } |
| 869 | |
| 870 | void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) |
| 871 | { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 872 | u32 ctl = UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | u32 mask = UNSET; |
| 874 | |
| 875 | if (manual) { |
| 876 | core->audiomode_manual = mode; |
| 877 | } else { |
| 878 | if (UNSET != core->audiomode_manual) |
| 879 | return; |
| 880 | } |
| 881 | core->audiomode_current = mode; |
| 882 | |
| 883 | switch (core->tvaudio) { |
| 884 | case WW_BTSC: |
| 885 | switch (mode) { |
| 886 | case V4L2_TUNER_MODE_MONO: |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 887 | set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_MONO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | break; |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 889 | case V4L2_TUNER_MODE_LANG1: |
| 890 | set_audio_standard_BTSC(core, 0, EN_BTSC_AUTO_STEREO); |
| 891 | break; |
| 892 | case V4L2_TUNER_MODE_LANG2: |
| 893 | set_audio_standard_BTSC(core, 1, EN_BTSC_FORCE_SAP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | break; |
| 895 | case V4L2_TUNER_MODE_STEREO: |
Hans Verkuil | 301e22d | 2006-03-18 17:15:00 -0300 | [diff] [blame] | 896 | case V4L2_TUNER_MODE_LANG1_LANG2: |
Mauro Carvalho Chehab | e52e98a | 2005-09-09 13:03:41 -0700 | [diff] [blame] | 897 | set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_STEREO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | break; |
| 899 | } |
| 900 | break; |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 901 | case WW_BG: |
| 902 | case WW_DK: |
| 903 | case WW_I: |
| 904 | case WW_L: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 905 | if (1 == core->use_nicam) { |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 906 | switch (mode) { |
| 907 | case V4L2_TUNER_MODE_MONO: |
| 908 | case V4L2_TUNER_MODE_LANG1: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 909 | set_audio_standard_NICAM(core, |
| 910 | EN_NICAM_FORCE_MONO1); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 911 | break; |
| 912 | case V4L2_TUNER_MODE_LANG2: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 913 | set_audio_standard_NICAM(core, |
| 914 | EN_NICAM_FORCE_MONO2); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 915 | break; |
| 916 | case V4L2_TUNER_MODE_STEREO: |
Hans Verkuil | 301e22d | 2006-03-18 17:15:00 -0300 | [diff] [blame] | 917 | case V4L2_TUNER_MODE_LANG1_LANG2: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 918 | set_audio_standard_NICAM(core, |
| 919 | EN_NICAM_FORCE_STEREO); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 920 | break; |
| 921 | } |
| 922 | } else { |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 923 | if ((core->tvaudio == WW_I) || (core->tvaudio == WW_L)) { |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 924 | /* fall back to fm / am mono */ |
| 925 | set_audio_standard_A2(core, EN_A2_FORCE_MONO1); |
| 926 | } else { |
| 927 | /* TODO: Add A2 autodection */ |
| 928 | switch (mode) { |
| 929 | case V4L2_TUNER_MODE_MONO: |
| 930 | case V4L2_TUNER_MODE_LANG1: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 931 | set_audio_standard_A2(core, |
| 932 | EN_A2_FORCE_MONO1); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 933 | break; |
| 934 | case V4L2_TUNER_MODE_LANG2: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 935 | set_audio_standard_A2(core, |
| 936 | EN_A2_FORCE_MONO2); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 937 | break; |
| 938 | case V4L2_TUNER_MODE_STEREO: |
Hans Verkuil | 301e22d | 2006-03-18 17:15:00 -0300 | [diff] [blame] | 939 | case V4L2_TUNER_MODE_LANG1_LANG2: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 940 | set_audio_standard_A2(core, |
| 941 | EN_A2_FORCE_STEREO); |
Torsten Seeboth | b1706b9 | 2005-11-08 21:36:27 -0800 | [diff] [blame] | 942 | break; |
| 943 | } |
| 944 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | } |
| 946 | break; |
| 947 | case WW_FM: |
| 948 | switch (mode) { |
| 949 | case V4L2_TUNER_MODE_MONO: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 950 | ctl = EN_FMRADIO_FORCE_MONO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | mask = 0x3f; |
| 952 | break; |
| 953 | case V4L2_TUNER_MODE_STEREO: |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 954 | ctl = EN_FMRADIO_AUTO_STEREO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | mask = 0x3f; |
| 956 | break; |
| 957 | } |
| 958 | break; |
| 959 | } |
| 960 | |
| 961 | if (UNSET != ctl) { |
| 962 | dprintk("cx88_set_stereo: mask 0x%x, ctl 0x%x " |
| 963 | "[status=0x%x,ctl=0x%x,vol=0x%x]\n", |
| 964 | mask, ctl, cx_read(AUD_STATUS), |
| 965 | cx_read(AUD_CTL), cx_sread(SHADOW_AUD_VOL_CTL)); |
| 966 | cx_andor(AUD_CTL, mask, ctl); |
| 967 | } |
| 968 | return; |
| 969 | } |
| 970 | |
| 971 | int cx88_audio_thread(void *data) |
| 972 | { |
| 973 | struct cx88_core *core = data; |
| 974 | struct v4l2_tuner t; |
| 975 | u32 mode = 0; |
| 976 | |
| 977 | dprintk("cx88: tvaudio thread started\n"); |
| 978 | for (;;) { |
| 979 | msleep_interruptible(1000); |
| 980 | if (kthread_should_stop()) |
| 981 | break; |
| 982 | |
| 983 | /* just monitor the audio status for now ... */ |
Nickolay V. Shmyrev | 7b3c6d6 | 2005-11-08 21:36:59 -0800 | [diff] [blame] | 984 | memset(&t, 0, sizeof(t)); |
| 985 | cx88_get_stereo(core, &t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | |
| 987 | if (UNSET != core->audiomode_manual) |
| 988 | /* manually set, don't do anything. */ |
| 989 | continue; |
| 990 | |
| 991 | /* monitor signal */ |
| 992 | if (t.rxsubchans & V4L2_TUNER_SUB_STEREO) |
| 993 | mode = V4L2_TUNER_MODE_STEREO; |
| 994 | else |
| 995 | mode = V4L2_TUNER_MODE_MONO; |
| 996 | if (mode == core->audiomode_current) |
| 997 | continue; |
| 998 | |
| 999 | /* automatically switch to best available mode */ |
| 1000 | cx88_set_stereo(core, mode, 0); |
| 1001 | } |
| 1002 | |
| 1003 | dprintk("cx88: tvaudio thread exiting\n"); |
| 1004 | return 0; |
| 1005 | } |
| 1006 | |
| 1007 | /* ----------------------------------------------------------- */ |
| 1008 | |
| 1009 | EXPORT_SYMBOL(cx88_set_tvaudio); |
| 1010 | EXPORT_SYMBOL(cx88_newstation); |
| 1011 | EXPORT_SYMBOL(cx88_set_stereo); |
| 1012 | EXPORT_SYMBOL(cx88_get_stereo); |
| 1013 | EXPORT_SYMBOL(cx88_audio_thread); |
| 1014 | |
| 1015 | /* |
| 1016 | * Local variables: |
| 1017 | * c-basic-offset: 8 |
| 1018 | * End: |
Mauro Carvalho Chehab | b45009b | 2005-06-23 22:05:03 -0700 | [diff] [blame] | 1019 | * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | */ |