Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 1 | /* |
| 2 | * C-Media CMI8788 driver for C-Media's reference design and for the X-Meridian |
| 3 | * |
| 4 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> |
| 5 | * |
| 6 | * |
| 7 | * This driver is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License, version 2. |
| 9 | * |
| 10 | * This driver is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this driver; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * SPI 0 -> 1st AK4396 (front) |
Clemens Ladisch | 7113e95 | 2008-01-14 08:55:03 +0100 | [diff] [blame] | 22 | * SPI 1 -> 2nd AK4396 (surround) |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 23 | * SPI 2 -> 3rd AK4396 (center/LFE) |
| 24 | * SPI 3 -> WM8785 |
Clemens Ladisch | 7113e95 | 2008-01-14 08:55:03 +0100 | [diff] [blame] | 25 | * SPI 4 -> 4th AK4396 (back) |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 26 | * |
| 27 | * GPIO 0 -> DFS0 of AK5385 |
| 28 | * GPIO 1 -> DFS1 of AK5385 |
| 29 | */ |
| 30 | |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 31 | #include <linux/mutex.h> |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 32 | #include <linux/pci.h> |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 33 | #include <sound/ac97_codec.h> |
Clemens Ladisch | ccc80fb | 2008-01-16 08:32:08 +0100 | [diff] [blame] | 34 | #include <sound/control.h> |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 35 | #include <sound/core.h> |
| 36 | #include <sound/initval.h> |
| 37 | #include <sound/pcm.h> |
| 38 | #include <sound/pcm_params.h> |
| 39 | #include <sound/tlv.h> |
| 40 | #include "oxygen.h" |
Clemens Ladisch | c626026 | 2008-01-25 08:41:52 +0100 | [diff] [blame] | 41 | #include "ak4396.h" |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 42 | #include "cm9780.h" |
Clemens Ladisch | f5b2368 | 2008-03-19 08:14:01 +0100 | [diff] [blame^] | 43 | #include "wm8785.h" |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 44 | |
| 45 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); |
| 46 | MODULE_DESCRIPTION("C-Media CMI8788 driver"); |
| 47 | MODULE_LICENSE("GPL"); |
| 48 | MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8788}}"); |
| 49 | |
| 50 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
| 51 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
| 52 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; |
| 53 | |
| 54 | module_param_array(index, int, NULL, 0444); |
| 55 | MODULE_PARM_DESC(index, "card index"); |
| 56 | module_param_array(id, charp, NULL, 0444); |
| 57 | MODULE_PARM_DESC(id, "ID string"); |
| 58 | module_param_array(enable, bool, NULL, 0444); |
| 59 | MODULE_PARM_DESC(enable, "enable card"); |
| 60 | |
| 61 | static struct pci_device_id oxygen_ids[] __devinitdata = { |
| 62 | { OXYGEN_PCI_SUBID(0x10b0, 0x0216) }, |
| 63 | { OXYGEN_PCI_SUBID(0x10b0, 0x0218) }, |
| 64 | { OXYGEN_PCI_SUBID(0x10b0, 0x0219) }, |
| 65 | { OXYGEN_PCI_SUBID(0x13f6, 0x0001) }, |
| 66 | { OXYGEN_PCI_SUBID(0x13f6, 0x0010) }, |
| 67 | { OXYGEN_PCI_SUBID(0x13f6, 0x8788) }, |
| 68 | { OXYGEN_PCI_SUBID(0x147a, 0xa017) }, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 69 | { OXYGEN_PCI_SUBID(0x1a58, 0x0910) }, |
| 70 | { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = 1 }, |
| 71 | { OXYGEN_PCI_SUBID(0x7284, 0x9761) }, |
| 72 | { } |
| 73 | }; |
| 74 | MODULE_DEVICE_TABLE(pci, oxygen_ids); |
| 75 | |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 76 | |
| 77 | #define GPIO_AK5385_DFS_MASK 0x0003 |
| 78 | #define GPIO_AK5385_DFS_NORMAL 0x0000 |
| 79 | #define GPIO_AK5385_DFS_DOUBLE 0x0001 |
| 80 | #define GPIO_AK5385_DFS_QUAD 0x0002 |
| 81 | |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 82 | #define GPIO_LINE_MUTE CM9780_GPO0 |
| 83 | |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 84 | struct generic_data { |
| 85 | u8 ak4396_ctl2; |
| 86 | }; |
| 87 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 88 | static void ak4396_write(struct oxygen *chip, unsigned int codec, |
| 89 | u8 reg, u8 value) |
| 90 | { |
| 91 | /* maps ALSA channel pair number to SPI output */ |
| 92 | static const u8 codec_spi_map[4] = { |
Clemens Ladisch | 7113e95 | 2008-01-14 08:55:03 +0100 | [diff] [blame] | 93 | 0, 1, 2, 4 |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 94 | }; |
Clemens Ladisch | c2353a0 | 2008-01-18 09:17:53 +0100 | [diff] [blame] | 95 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 96 | OXYGEN_SPI_DATA_LENGTH_2 | |
Clemens Ladisch | 2ea8598 | 2008-01-30 08:38:30 +0100 | [diff] [blame] | 97 | OXYGEN_SPI_CLOCK_160 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 98 | (codec_spi_map[codec] << OXYGEN_SPI_CODEC_SHIFT) | |
Clemens Ladisch | c2353a0 | 2008-01-18 09:17:53 +0100 | [diff] [blame] | 99 | OXYGEN_SPI_CEN_LATCH_CLOCK_HI, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 100 | AK4396_WRITE | (reg << 8) | value); |
| 101 | } |
| 102 | |
| 103 | static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value) |
| 104 | { |
Clemens Ladisch | c2353a0 | 2008-01-18 09:17:53 +0100 | [diff] [blame] | 105 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 106 | OXYGEN_SPI_DATA_LENGTH_2 | |
Clemens Ladisch | 2ea8598 | 2008-01-30 08:38:30 +0100 | [diff] [blame] | 107 | OXYGEN_SPI_CLOCK_160 | |
Clemens Ladisch | c2353a0 | 2008-01-18 09:17:53 +0100 | [diff] [blame] | 108 | (3 << OXYGEN_SPI_CODEC_SHIFT) | |
| 109 | OXYGEN_SPI_CEN_LATCH_CLOCK_LO, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 110 | (reg << 9) | value); |
| 111 | } |
| 112 | |
| 113 | static void ak4396_init(struct oxygen *chip) |
| 114 | { |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 115 | struct generic_data *data = chip->model_data; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 116 | unsigned int i; |
| 117 | |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 118 | data->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 119 | for (i = 0; i < 4; ++i) { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 120 | ak4396_write(chip, i, |
| 121 | AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); |
| 122 | ak4396_write(chip, i, |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 123 | AK4396_CONTROL_2, data->ak4396_ctl2); |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 124 | ak4396_write(chip, i, |
| 125 | AK4396_CONTROL_3, AK4396_PCM); |
| 126 | ak4396_write(chip, i, AK4396_LCH_ATT, 0xff); |
| 127 | ak4396_write(chip, i, AK4396_RCH_ATT, 0xff); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 128 | } |
| 129 | snd_component_add(chip->card, "AK4396"); |
| 130 | } |
| 131 | |
| 132 | static void ak5385_init(struct oxygen *chip) |
| 133 | { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 134 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_AK5385_DFS_MASK); |
| 135 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_AK5385_DFS_MASK); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 136 | snd_component_add(chip->card, "AK5385"); |
| 137 | } |
| 138 | |
| 139 | static void wm8785_init(struct oxygen *chip) |
| 140 | { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 141 | wm8785_write(chip, WM8785_R7, 0); |
| 142 | wm8785_write(chip, WM8785_R0, WM8785_MCR_SLAVE | |
| 143 | WM8785_OSR_SINGLE | WM8785_FORMAT_LJUST); |
| 144 | wm8785_write(chip, WM8785_R1, WM8785_WL_24); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 145 | snd_component_add(chip->card, "WM8785"); |
| 146 | } |
| 147 | |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 148 | static void cmi9780_init(struct oxygen *chip) |
| 149 | { |
| 150 | oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS, GPIO_LINE_MUTE); |
| 151 | } |
| 152 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 153 | static void generic_init(struct oxygen *chip) |
| 154 | { |
| 155 | ak4396_init(chip); |
| 156 | wm8785_init(chip); |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 157 | cmi9780_init(chip); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | static void meridian_init(struct oxygen *chip) |
| 161 | { |
| 162 | ak4396_init(chip); |
| 163 | ak5385_init(chip); |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 164 | cmi9780_init(chip); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | static void generic_cleanup(struct oxygen *chip) |
| 168 | { |
| 169 | } |
| 170 | |
| 171 | static void set_ak4396_params(struct oxygen *chip, |
| 172 | struct snd_pcm_hw_params *params) |
| 173 | { |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 174 | struct generic_data *data = chip->model_data; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 175 | unsigned int i; |
| 176 | u8 value; |
| 177 | |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 178 | value = data->ak4396_ctl2 & ~AK4396_DFS_MASK; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 179 | if (params_rate(params) <= 54000) |
| 180 | value |= AK4396_DFS_NORMAL; |
Clemens Ladisch | 236c492 | 2008-01-28 08:32:58 +0100 | [diff] [blame] | 181 | else if (params_rate(params) <= 108000) |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 182 | value |= AK4396_DFS_DOUBLE; |
| 183 | else |
| 184 | value |= AK4396_DFS_QUAD; |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 185 | data->ak4396_ctl2 = value; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 186 | for (i = 0; i < 4; ++i) { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 187 | ak4396_write(chip, i, |
| 188 | AK4396_CONTROL_1, AK4396_DIF_24_MSB); |
| 189 | ak4396_write(chip, i, |
| 190 | AK4396_CONTROL_2, value); |
| 191 | ak4396_write(chip, i, |
| 192 | AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | |
| 196 | static void update_ak4396_volume(struct oxygen *chip) |
| 197 | { |
| 198 | unsigned int i; |
| 199 | |
| 200 | for (i = 0; i < 4; ++i) { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 201 | ak4396_write(chip, i, |
| 202 | AK4396_LCH_ATT, chip->dac_volume[i * 2]); |
| 203 | ak4396_write(chip, i, |
| 204 | AK4396_RCH_ATT, chip->dac_volume[i * 2 + 1]); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
| 208 | static void update_ak4396_mute(struct oxygen *chip) |
| 209 | { |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 210 | struct generic_data *data = chip->model_data; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 211 | unsigned int i; |
| 212 | u8 value; |
| 213 | |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 214 | value = data->ak4396_ctl2 & ~AK4396_SMUTE; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 215 | if (chip->dac_mute) |
| 216 | value |= AK4396_SMUTE; |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 217 | data->ak4396_ctl2 = value; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 218 | for (i = 0; i < 4; ++i) |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 219 | ak4396_write(chip, i, AK4396_CONTROL_2, value); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | static void set_wm8785_params(struct oxygen *chip, |
| 223 | struct snd_pcm_hw_params *params) |
| 224 | { |
| 225 | unsigned int value; |
| 226 | |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 227 | wm8785_write(chip, WM8785_R7, 0); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 228 | |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 229 | value = WM8785_MCR_SLAVE | WM8785_FORMAT_LJUST; |
Clemens Ladisch | 71e22a4 | 2008-01-21 08:50:51 +0100 | [diff] [blame] | 230 | if (params_rate(params) <= 48000) |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 231 | value |= WM8785_OSR_SINGLE; |
Clemens Ladisch | 71e22a4 | 2008-01-21 08:50:51 +0100 | [diff] [blame] | 232 | else if (params_rate(params) <= 96000) |
| 233 | value |= WM8785_OSR_DOUBLE; |
| 234 | else |
| 235 | value |= WM8785_OSR_QUAD; |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 236 | wm8785_write(chip, WM8785_R0, value); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 237 | |
| 238 | if (snd_pcm_format_width(params_format(params)) <= 16) |
| 239 | value = WM8785_WL_16; |
| 240 | else |
| 241 | value = WM8785_WL_24; |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 242 | wm8785_write(chip, WM8785_R1, value); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | static void set_ak5385_params(struct oxygen *chip, |
| 246 | struct snd_pcm_hw_params *params) |
| 247 | { |
| 248 | unsigned int value; |
| 249 | |
| 250 | if (params_rate(params) <= 54000) |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 251 | value = GPIO_AK5385_DFS_NORMAL; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 252 | else if (params_rate(params) <= 108000) |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 253 | value = GPIO_AK5385_DFS_DOUBLE; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 254 | else |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 255 | value = GPIO_AK5385_DFS_QUAD; |
| 256 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, |
| 257 | value, GPIO_AK5385_DFS_MASK); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 258 | } |
| 259 | |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 260 | static void cmi9780_switch_hook(struct oxygen *chip, unsigned int codec, |
| 261 | unsigned int reg, int mute) |
| 262 | { |
| 263 | if (codec != 0) |
| 264 | return; |
| 265 | switch (reg) { |
| 266 | case AC97_LINE: |
| 267 | oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS, |
| 268 | mute ? GPIO_LINE_MUTE : 0, |
| 269 | GPIO_LINE_MUTE); |
| 270 | break; |
| 271 | case AC97_MIC: |
| 272 | case AC97_CD: |
| 273 | case AC97_AUX: |
| 274 | if (!mute) |
| 275 | oxygen_ac97_set_bits(chip, 0, CM9780_GPIO_STATUS, |
| 276 | GPIO_LINE_MUTE); |
| 277 | break; |
| 278 | } |
| 279 | } |
| 280 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 281 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); |
| 282 | |
Clemens Ladisch | ccc80fb | 2008-01-16 08:32:08 +0100 | [diff] [blame] | 283 | static int ak4396_control_filter(struct snd_kcontrol_new *template) |
| 284 | { |
| 285 | if (!strcmp(template->name, "Master Playback Volume")) { |
| 286 | template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; |
| 287 | template->tlv.p = ak4396_db_scale; |
| 288 | } |
| 289 | return 0; |
| 290 | } |
| 291 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 292 | static const struct oxygen_model model_generic = { |
| 293 | .shortname = "C-Media CMI8788", |
| 294 | .longname = "C-Media Oxygen HD Audio", |
| 295 | .chip = "CMI8788", |
| 296 | .owner = THIS_MODULE, |
| 297 | .init = generic_init, |
Clemens Ladisch | ccc80fb | 2008-01-16 08:32:08 +0100 | [diff] [blame] | 298 | .control_filter = ak4396_control_filter, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 299 | .cleanup = generic_cleanup, |
| 300 | .set_dac_params = set_ak4396_params, |
| 301 | .set_adc_params = set_wm8785_params, |
| 302 | .update_dac_volume = update_ak4396_volume, |
| 303 | .update_dac_mute = update_ak4396_mute, |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 304 | .ac97_switch_hook = cmi9780_switch_hook, |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 305 | .model_data_size = sizeof(struct generic_data), |
Clemens Ladisch | 976cd62 | 2008-01-25 08:37:49 +0100 | [diff] [blame] | 306 | .dac_channels = 8, |
Clemens Ladisch | e85e092 | 2008-01-16 08:30:38 +0100 | [diff] [blame] | 307 | .used_channels = OXYGEN_CHANNEL_A | |
| 308 | OXYGEN_CHANNEL_C | |
| 309 | OXYGEN_CHANNEL_SPDIF | |
| 310 | OXYGEN_CHANNEL_MULTICH | |
| 311 | OXYGEN_CHANNEL_AC97, |
Clemens Ladisch | 84aa6b7 | 2008-01-16 08:28:54 +0100 | [diff] [blame] | 312 | .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
Clemens Ladisch | 05855ba | 2008-01-17 09:05:09 +0100 | [diff] [blame] | 313 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 314 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 315 | }; |
| 316 | static const struct oxygen_model model_meridian = { |
| 317 | .shortname = "C-Media CMI8788", |
| 318 | .longname = "C-Media Oxygen HD Audio", |
| 319 | .chip = "CMI8788", |
| 320 | .owner = THIS_MODULE, |
| 321 | .init = meridian_init, |
Clemens Ladisch | ccc80fb | 2008-01-16 08:32:08 +0100 | [diff] [blame] | 322 | .control_filter = ak4396_control_filter, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 323 | .cleanup = generic_cleanup, |
| 324 | .set_dac_params = set_ak4396_params, |
| 325 | .set_adc_params = set_ak5385_params, |
| 326 | .update_dac_volume = update_ak4396_volume, |
| 327 | .update_dac_mute = update_ak4396_mute, |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 328 | .ac97_switch_hook = cmi9780_switch_hook, |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 329 | .model_data_size = sizeof(struct generic_data), |
Clemens Ladisch | 976cd62 | 2008-01-25 08:37:49 +0100 | [diff] [blame] | 330 | .dac_channels = 8, |
Clemens Ladisch | e85e092 | 2008-01-16 08:30:38 +0100 | [diff] [blame] | 331 | .used_channels = OXYGEN_CHANNEL_B | |
| 332 | OXYGEN_CHANNEL_C | |
| 333 | OXYGEN_CHANNEL_SPDIF | |
| 334 | OXYGEN_CHANNEL_MULTICH | |
| 335 | OXYGEN_CHANNEL_AC97, |
Clemens Ladisch | 84aa6b7 | 2008-01-16 08:28:54 +0100 | [diff] [blame] | 336 | .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
Clemens Ladisch | 05855ba | 2008-01-17 09:05:09 +0100 | [diff] [blame] | 337 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 338 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 339 | }; |
| 340 | |
| 341 | static int __devinit generic_oxygen_probe(struct pci_dev *pci, |
| 342 | const struct pci_device_id *pci_id) |
| 343 | { |
| 344 | static int dev; |
Clemens Ladisch | cd93dc8 | 2008-01-24 08:43:39 +0100 | [diff] [blame] | 345 | int is_meridian; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 346 | int err; |
| 347 | |
| 348 | if (dev >= SNDRV_CARDS) |
| 349 | return -ENODEV; |
| 350 | if (!enable[dev]) { |
| 351 | ++dev; |
| 352 | return -ENOENT; |
| 353 | } |
Clemens Ladisch | cd93dc8 | 2008-01-24 08:43:39 +0100 | [diff] [blame] | 354 | is_meridian = pci_id->driver_data; |
| 355 | err = oxygen_pci_probe(pci, index[dev], id[dev], is_meridian, |
| 356 | is_meridian ? &model_meridian : &model_generic); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 357 | if (err >= 0) |
| 358 | ++dev; |
| 359 | return err; |
| 360 | } |
| 361 | |
| 362 | static struct pci_driver oxygen_driver = { |
| 363 | .name = "CMI8788", |
| 364 | .id_table = oxygen_ids, |
| 365 | .probe = generic_oxygen_probe, |
| 366 | .remove = __devexit_p(oxygen_pci_remove), |
| 367 | }; |
| 368 | |
| 369 | static int __init alsa_card_oxygen_init(void) |
| 370 | { |
| 371 | return pci_register_driver(&oxygen_driver); |
| 372 | } |
| 373 | |
| 374 | static void __exit alsa_card_oxygen_exit(void) |
| 375 | { |
| 376 | pci_unregister_driver(&oxygen_driver); |
| 377 | } |
| 378 | |
| 379 | module_init(alsa_card_oxygen_init) |
| 380 | module_exit(alsa_card_oxygen_exit) |