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 | df91bc2 | 2008-08-29 13:08:34 +0200 | [diff] [blame^] | 31 | #include <linux/delay.h> |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 32 | #include <linux/mutex.h> |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 33 | #include <linux/pci.h> |
Clemens Ladisch | 902b05c | 2008-02-22 18:40:56 +0100 | [diff] [blame] | 34 | #include <sound/ac97_codec.h> |
Clemens Ladisch | ccc80fb | 2008-01-16 08:32:08 +0100 | [diff] [blame] | 35 | #include <sound/control.h> |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 36 | #include <sound/core.h> |
| 37 | #include <sound/initval.h> |
| 38 | #include <sound/pcm.h> |
| 39 | #include <sound/pcm_params.h> |
| 40 | #include <sound/tlv.h> |
| 41 | #include "oxygen.h" |
Clemens Ladisch | c626026 | 2008-01-25 08:41:52 +0100 | [diff] [blame] | 42 | #include "ak4396.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"); |
Clemens Ladisch | d023dc0 | 2008-05-13 09:18:27 +0200 | [diff] [blame] | 47 | MODULE_LICENSE("GPL v2"); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 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 | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 82 | struct generic_data { |
| 83 | u8 ak4396_ctl2; |
Clemens Ladisch | e58aee9 | 2008-05-13 09:20:51 +0200 | [diff] [blame] | 84 | u16 saved_wm8785_registers[2]; |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 85 | }; |
| 86 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 87 | static void ak4396_write(struct oxygen *chip, unsigned int codec, |
| 88 | u8 reg, u8 value) |
| 89 | { |
| 90 | /* maps ALSA channel pair number to SPI output */ |
| 91 | static const u8 codec_spi_map[4] = { |
Clemens Ladisch | 7113e95 | 2008-01-14 08:55:03 +0100 | [diff] [blame] | 92 | 0, 1, 2, 4 |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 93 | }; |
Clemens Ladisch | c2353a0 | 2008-01-18 09:17:53 +0100 | [diff] [blame] | 94 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 95 | OXYGEN_SPI_DATA_LENGTH_2 | |
Clemens Ladisch | 2ea8598 | 2008-01-30 08:38:30 +0100 | [diff] [blame] | 96 | OXYGEN_SPI_CLOCK_160 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 97 | (codec_spi_map[codec] << OXYGEN_SPI_CODEC_SHIFT) | |
Clemens Ladisch | c2353a0 | 2008-01-18 09:17:53 +0100 | [diff] [blame] | 98 | OXYGEN_SPI_CEN_LATCH_CLOCK_HI, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 99 | AK4396_WRITE | (reg << 8) | value); |
| 100 | } |
| 101 | |
| 102 | static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value) |
| 103 | { |
Clemens Ladisch | e58aee9 | 2008-05-13 09:20:51 +0200 | [diff] [blame] | 104 | struct generic_data *data = chip->model_data; |
| 105 | |
Clemens Ladisch | c2353a0 | 2008-01-18 09:17:53 +0100 | [diff] [blame] | 106 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 107 | OXYGEN_SPI_DATA_LENGTH_2 | |
Clemens Ladisch | 2ea8598 | 2008-01-30 08:38:30 +0100 | [diff] [blame] | 108 | OXYGEN_SPI_CLOCK_160 | |
Clemens Ladisch | c2353a0 | 2008-01-18 09:17:53 +0100 | [diff] [blame] | 109 | (3 << OXYGEN_SPI_CODEC_SHIFT) | |
| 110 | OXYGEN_SPI_CEN_LATCH_CLOCK_LO, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 111 | (reg << 9) | value); |
Clemens Ladisch | e58aee9 | 2008-05-13 09:20:51 +0200 | [diff] [blame] | 112 | if (reg < ARRAY_SIZE(data->saved_wm8785_registers)) |
| 113 | data->saved_wm8785_registers[reg] = value; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 114 | } |
| 115 | |
Clemens Ladisch | bbbfb55 | 2008-05-13 09:21:48 +0200 | [diff] [blame] | 116 | static void update_ak4396_volume(struct oxygen *chip) |
| 117 | { |
| 118 | unsigned int i; |
| 119 | |
| 120 | for (i = 0; i < 4; ++i) { |
| 121 | ak4396_write(chip, i, |
| 122 | AK4396_LCH_ATT, chip->dac_volume[i * 2]); |
| 123 | ak4396_write(chip, i, |
| 124 | AK4396_RCH_ATT, chip->dac_volume[i * 2 + 1]); |
| 125 | } |
| 126 | } |
| 127 | |
Clemens Ladisch | 75146fc | 2008-05-13 09:22:43 +0200 | [diff] [blame] | 128 | static void ak4396_registers_init(struct oxygen *chip) |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 129 | { |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 130 | struct generic_data *data = chip->model_data; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 131 | unsigned int i; |
| 132 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 133 | for (i = 0; i < 4; ++i) { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 134 | ak4396_write(chip, i, |
| 135 | AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); |
| 136 | ak4396_write(chip, i, |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 137 | AK4396_CONTROL_2, data->ak4396_ctl2); |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 138 | ak4396_write(chip, i, |
| 139 | AK4396_CONTROL_3, AK4396_PCM); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 140 | } |
Clemens Ladisch | bbbfb55 | 2008-05-13 09:21:48 +0200 | [diff] [blame] | 141 | update_ak4396_volume(chip); |
Clemens Ladisch | 75146fc | 2008-05-13 09:22:43 +0200 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | static void ak4396_init(struct oxygen *chip) |
| 145 | { |
| 146 | struct generic_data *data = chip->model_data; |
| 147 | |
| 148 | data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL; |
| 149 | ak4396_registers_init(chip); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 150 | snd_component_add(chip->card, "AK4396"); |
| 151 | } |
| 152 | |
| 153 | static void ak5385_init(struct oxygen *chip) |
| 154 | { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 155 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_AK5385_DFS_MASK); |
| 156 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_AK5385_DFS_MASK); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 157 | snd_component_add(chip->card, "AK5385"); |
| 158 | } |
| 159 | |
Clemens Ladisch | 75146fc | 2008-05-13 09:22:43 +0200 | [diff] [blame] | 160 | static void wm8785_registers_init(struct oxygen *chip) |
| 161 | { |
| 162 | struct generic_data *data = chip->model_data; |
| 163 | |
| 164 | wm8785_write(chip, WM8785_R7, 0); |
| 165 | wm8785_write(chip, WM8785_R0, data->saved_wm8785_registers[0]); |
| 166 | wm8785_write(chip, WM8785_R1, data->saved_wm8785_registers[1]); |
| 167 | } |
| 168 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 169 | static void wm8785_init(struct oxygen *chip) |
| 170 | { |
Clemens Ladisch | e58aee9 | 2008-05-13 09:20:51 +0200 | [diff] [blame] | 171 | struct generic_data *data = chip->model_data; |
| 172 | |
| 173 | data->saved_wm8785_registers[0] = WM8785_MCR_SLAVE | |
| 174 | WM8785_OSR_SINGLE | WM8785_FORMAT_LJUST; |
| 175 | data->saved_wm8785_registers[1] = WM8785_WL_24; |
Clemens Ladisch | 75146fc | 2008-05-13 09:22:43 +0200 | [diff] [blame] | 176 | wm8785_registers_init(chip); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 177 | snd_component_add(chip->card, "WM8785"); |
| 178 | } |
| 179 | |
| 180 | static void generic_init(struct oxygen *chip) |
| 181 | { |
| 182 | ak4396_init(chip); |
| 183 | wm8785_init(chip); |
| 184 | } |
| 185 | |
| 186 | static void meridian_init(struct oxygen *chip) |
| 187 | { |
| 188 | ak4396_init(chip); |
| 189 | ak5385_init(chip); |
| 190 | } |
| 191 | |
| 192 | static void generic_cleanup(struct oxygen *chip) |
| 193 | { |
| 194 | } |
| 195 | |
Clemens Ladisch | 4a4bc53 | 2008-05-13 09:24:39 +0200 | [diff] [blame] | 196 | static void generic_resume(struct oxygen *chip) |
| 197 | { |
| 198 | ak4396_registers_init(chip); |
| 199 | wm8785_registers_init(chip); |
| 200 | } |
| 201 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 202 | static void set_ak4396_params(struct oxygen *chip, |
| 203 | struct snd_pcm_hw_params *params) |
| 204 | { |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 205 | struct generic_data *data = chip->model_data; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 206 | unsigned int i; |
| 207 | u8 value; |
| 208 | |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 209 | value = data->ak4396_ctl2 & ~AK4396_DFS_MASK; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 210 | if (params_rate(params) <= 54000) |
| 211 | value |= AK4396_DFS_NORMAL; |
Clemens Ladisch | 236c492 | 2008-01-28 08:32:58 +0100 | [diff] [blame] | 212 | else if (params_rate(params) <= 108000) |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 213 | value |= AK4396_DFS_DOUBLE; |
| 214 | else |
| 215 | value |= AK4396_DFS_QUAD; |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 216 | data->ak4396_ctl2 = value; |
Clemens Ladisch | df91bc2 | 2008-08-29 13:08:34 +0200 | [diff] [blame^] | 217 | |
| 218 | msleep(1); /* wait for the new MCLK to become stable */ |
| 219 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 220 | for (i = 0; i < 4; ++i) { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 221 | ak4396_write(chip, i, |
| 222 | AK4396_CONTROL_1, AK4396_DIF_24_MSB); |
| 223 | ak4396_write(chip, i, |
| 224 | AK4396_CONTROL_2, value); |
| 225 | ak4396_write(chip, i, |
| 226 | AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 227 | } |
| 228 | } |
| 229 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 230 | static void update_ak4396_mute(struct oxygen *chip) |
| 231 | { |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 232 | struct generic_data *data = chip->model_data; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 233 | unsigned int i; |
| 234 | u8 value; |
| 235 | |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 236 | value = data->ak4396_ctl2 & ~AK4396_SMUTE; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 237 | if (chip->dac_mute) |
| 238 | value |= AK4396_SMUTE; |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 239 | data->ak4396_ctl2 = value; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 240 | for (i = 0; i < 4; ++i) |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 241 | ak4396_write(chip, i, AK4396_CONTROL_2, value); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | static void set_wm8785_params(struct oxygen *chip, |
| 245 | struct snd_pcm_hw_params *params) |
| 246 | { |
| 247 | unsigned int value; |
| 248 | |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 249 | wm8785_write(chip, WM8785_R7, 0); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 250 | |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 251 | value = WM8785_MCR_SLAVE | WM8785_FORMAT_LJUST; |
Clemens Ladisch | 71e22a4 | 2008-01-21 08:50:51 +0100 | [diff] [blame] | 252 | if (params_rate(params) <= 48000) |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 253 | value |= WM8785_OSR_SINGLE; |
Clemens Ladisch | 71e22a4 | 2008-01-21 08:50:51 +0100 | [diff] [blame] | 254 | else if (params_rate(params) <= 96000) |
| 255 | value |= WM8785_OSR_DOUBLE; |
| 256 | else |
| 257 | value |= WM8785_OSR_QUAD; |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 258 | wm8785_write(chip, WM8785_R0, value); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 259 | |
| 260 | if (snd_pcm_format_width(params_format(params)) <= 16) |
| 261 | value = WM8785_WL_16; |
| 262 | else |
| 263 | value = WM8785_WL_24; |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 264 | wm8785_write(chip, WM8785_R1, value); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | static void set_ak5385_params(struct oxygen *chip, |
| 268 | struct snd_pcm_hw_params *params) |
| 269 | { |
| 270 | unsigned int value; |
| 271 | |
| 272 | if (params_rate(params) <= 54000) |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 273 | value = GPIO_AK5385_DFS_NORMAL; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 274 | else if (params_rate(params) <= 108000) |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 275 | value = GPIO_AK5385_DFS_DOUBLE; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 276 | else |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 277 | value = GPIO_AK5385_DFS_QUAD; |
| 278 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, |
| 279 | value, GPIO_AK5385_DFS_MASK); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); |
| 283 | |
| 284 | static const struct oxygen_model model_generic = { |
| 285 | .shortname = "C-Media CMI8788", |
| 286 | .longname = "C-Media Oxygen HD Audio", |
| 287 | .chip = "CMI8788", |
| 288 | .owner = THIS_MODULE, |
| 289 | .init = generic_init, |
| 290 | .cleanup = generic_cleanup, |
Clemens Ladisch | 4a4bc53 | 2008-05-13 09:24:39 +0200 | [diff] [blame] | 291 | .resume = generic_resume, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 292 | .set_dac_params = set_ak4396_params, |
| 293 | .set_adc_params = set_wm8785_params, |
| 294 | .update_dac_volume = update_ak4396_volume, |
| 295 | .update_dac_mute = update_ak4396_mute, |
Clemens Ladisch | 4972a17 | 2008-04-16 09:15:45 +0200 | [diff] [blame] | 296 | .dac_tlv = ak4396_db_scale, |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 297 | .model_data_size = sizeof(struct generic_data), |
Clemens Ladisch | f009ad9 | 2008-03-19 08:19:41 +0100 | [diff] [blame] | 298 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | |
| 299 | PLAYBACK_1_TO_SPDIF | |
| 300 | PLAYBACK_2_TO_AC97_1 | |
| 301 | CAPTURE_0_FROM_I2S_1 | |
| 302 | CAPTURE_1_FROM_SPDIF | |
| 303 | CAPTURE_2_FROM_AC97_1, |
Clemens Ladisch | 976cd62 | 2008-01-25 08:37:49 +0100 | [diff] [blame] | 304 | .dac_channels = 8, |
Clemens Ladisch | 193e813 | 2008-04-16 09:13:36 +0200 | [diff] [blame] | 305 | .dac_volume_min = 0, |
| 306 | .dac_volume_max = 255, |
Clemens Ladisch | 87eedd2 | 2008-03-19 08:20:13 +0100 | [diff] [blame] | 307 | .function_flags = OXYGEN_FUNCTION_SPI | |
| 308 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
Clemens Ladisch | 05855ba | 2008-01-17 09:05:09 +0100 | [diff] [blame] | 309 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 310 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 311 | }; |
| 312 | static const struct oxygen_model model_meridian = { |
| 313 | .shortname = "C-Media CMI8788", |
| 314 | .longname = "C-Media Oxygen HD Audio", |
| 315 | .chip = "CMI8788", |
| 316 | .owner = THIS_MODULE, |
| 317 | .init = meridian_init, |
| 318 | .cleanup = generic_cleanup, |
Clemens Ladisch | 4a4bc53 | 2008-05-13 09:24:39 +0200 | [diff] [blame] | 319 | .resume = ak4396_registers_init, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 320 | .set_dac_params = set_ak4396_params, |
| 321 | .set_adc_params = set_ak5385_params, |
| 322 | .update_dac_volume = update_ak4396_volume, |
| 323 | .update_dac_mute = update_ak4396_mute, |
Clemens Ladisch | 4972a17 | 2008-04-16 09:15:45 +0200 | [diff] [blame] | 324 | .dac_tlv = ak4396_db_scale, |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 325 | .model_data_size = sizeof(struct generic_data), |
Clemens Ladisch | f009ad9 | 2008-03-19 08:19:41 +0100 | [diff] [blame] | 326 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | |
| 327 | PLAYBACK_1_TO_SPDIF | |
| 328 | PLAYBACK_2_TO_AC97_1 | |
| 329 | CAPTURE_0_FROM_I2S_2 | |
| 330 | CAPTURE_1_FROM_SPDIF | |
| 331 | CAPTURE_2_FROM_AC97_1, |
Clemens Ladisch | 976cd62 | 2008-01-25 08:37:49 +0100 | [diff] [blame] | 332 | .dac_channels = 8, |
Clemens Ladisch | 193e813 | 2008-04-16 09:13:36 +0200 | [diff] [blame] | 333 | .dac_volume_min = 0, |
| 334 | .dac_volume_max = 255, |
Clemens Ladisch | db12b8e | 2008-03-19 08:20:59 +0100 | [diff] [blame] | 335 | .misc_flags = OXYGEN_MISC_MIDI, |
Clemens Ladisch | 87eedd2 | 2008-03-19 08:20:13 +0100 | [diff] [blame] | 336 | .function_flags = OXYGEN_FUNCTION_SPI | |
| 337 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
Clemens Ladisch | 05855ba | 2008-01-17 09:05:09 +0100 | [diff] [blame] | 338 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 339 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 340 | }; |
| 341 | |
| 342 | static int __devinit generic_oxygen_probe(struct pci_dev *pci, |
| 343 | const struct pci_device_id *pci_id) |
| 344 | { |
| 345 | static int dev; |
Clemens Ladisch | cd93dc8 | 2008-01-24 08:43:39 +0100 | [diff] [blame] | 346 | int is_meridian; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 347 | int err; |
| 348 | |
| 349 | if (dev >= SNDRV_CARDS) |
| 350 | return -ENODEV; |
| 351 | if (!enable[dev]) { |
| 352 | ++dev; |
| 353 | return -ENOENT; |
| 354 | } |
Clemens Ladisch | cd93dc8 | 2008-01-24 08:43:39 +0100 | [diff] [blame] | 355 | is_meridian = pci_id->driver_data; |
Clemens Ladisch | db12b8e | 2008-03-19 08:20:59 +0100 | [diff] [blame] | 356 | err = oxygen_pci_probe(pci, index[dev], id[dev], |
Clemens Ladisch | cd93dc8 | 2008-01-24 08:43:39 +0100 | [diff] [blame] | 357 | is_meridian ? &model_meridian : &model_generic); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 358 | if (err >= 0) |
| 359 | ++dev; |
| 360 | return err; |
| 361 | } |
| 362 | |
| 363 | static struct pci_driver oxygen_driver = { |
| 364 | .name = "CMI8788", |
| 365 | .id_table = oxygen_ids, |
| 366 | .probe = generic_oxygen_probe, |
| 367 | .remove = __devexit_p(oxygen_pci_remove), |
Clemens Ladisch | 4a4bc53 | 2008-05-13 09:24:39 +0200 | [diff] [blame] | 368 | #ifdef CONFIG_PM |
| 369 | .suspend = oxygen_pci_suspend, |
| 370 | .resume = oxygen_pci_resume, |
| 371 | #endif |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 372 | }; |
| 373 | |
| 374 | static int __init alsa_card_oxygen_init(void) |
| 375 | { |
| 376 | return pci_register_driver(&oxygen_driver); |
| 377 | } |
| 378 | |
| 379 | static void __exit alsa_card_oxygen_exit(void) |
| 380 | { |
| 381 | pci_unregister_driver(&oxygen_driver); |
| 382 | } |
| 383 | |
| 384 | module_init(alsa_card_oxygen_init) |
| 385 | module_exit(alsa_card_oxygen_exit) |