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