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 | f5b2368 | 2008-03-19 08:14:01 +0100 | [diff] [blame] | 42 | #include "wm8785.h" |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 43 | |
| 44 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); |
| 45 | MODULE_DESCRIPTION("C-Media CMI8788 driver"); |
Clemens Ladisch | d023dc0 | 2008-05-13 09:18:27 +0200 | [diff] [blame] | 46 | MODULE_LICENSE("GPL v2"); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 47 | MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8788}}"); |
| 48 | |
| 49 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
| 50 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
| 51 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; |
| 52 | |
| 53 | module_param_array(index, int, NULL, 0444); |
| 54 | MODULE_PARM_DESC(index, "card index"); |
| 55 | module_param_array(id, charp, NULL, 0444); |
| 56 | MODULE_PARM_DESC(id, "ID string"); |
| 57 | module_param_array(enable, bool, NULL, 0444); |
| 58 | MODULE_PARM_DESC(enable, "enable card"); |
| 59 | |
| 60 | static struct pci_device_id oxygen_ids[] __devinitdata = { |
| 61 | { OXYGEN_PCI_SUBID(0x10b0, 0x0216) }, |
| 62 | { OXYGEN_PCI_SUBID(0x10b0, 0x0218) }, |
| 63 | { OXYGEN_PCI_SUBID(0x10b0, 0x0219) }, |
| 64 | { OXYGEN_PCI_SUBID(0x13f6, 0x0001) }, |
| 65 | { OXYGEN_PCI_SUBID(0x13f6, 0x0010) }, |
| 66 | { OXYGEN_PCI_SUBID(0x13f6, 0x8788) }, |
| 67 | { OXYGEN_PCI_SUBID(0x147a, 0xa017) }, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 68 | { OXYGEN_PCI_SUBID(0x1a58, 0x0910) }, |
| 69 | { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = 1 }, |
| 70 | { OXYGEN_PCI_SUBID(0x7284, 0x9761) }, |
| 71 | { } |
| 72 | }; |
| 73 | MODULE_DEVICE_TABLE(pci, oxygen_ids); |
| 74 | |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 75 | |
| 76 | #define GPIO_AK5385_DFS_MASK 0x0003 |
| 77 | #define GPIO_AK5385_DFS_NORMAL 0x0000 |
| 78 | #define GPIO_AK5385_DFS_DOUBLE 0x0001 |
| 79 | #define GPIO_AK5385_DFS_QUAD 0x0002 |
| 80 | |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 81 | struct generic_data { |
| 82 | u8 ak4396_ctl2; |
Clemens Ladisch | e58aee9 | 2008-05-13 09:20:51 +0200 | [diff] [blame^] | 83 | u16 saved_wm8785_registers[2]; |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 84 | }; |
| 85 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 86 | static void ak4396_write(struct oxygen *chip, unsigned int codec, |
| 87 | u8 reg, u8 value) |
| 88 | { |
| 89 | /* maps ALSA channel pair number to SPI output */ |
| 90 | static const u8 codec_spi_map[4] = { |
Clemens Ladisch | 7113e95 | 2008-01-14 08:55:03 +0100 | [diff] [blame] | 91 | 0, 1, 2, 4 |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 92 | }; |
Clemens Ladisch | c2353a0 | 2008-01-18 09:17:53 +0100 | [diff] [blame] | 93 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 94 | OXYGEN_SPI_DATA_LENGTH_2 | |
Clemens Ladisch | 2ea8598 | 2008-01-30 08:38:30 +0100 | [diff] [blame] | 95 | OXYGEN_SPI_CLOCK_160 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 96 | (codec_spi_map[codec] << OXYGEN_SPI_CODEC_SHIFT) | |
Clemens Ladisch | c2353a0 | 2008-01-18 09:17:53 +0100 | [diff] [blame] | 97 | OXYGEN_SPI_CEN_LATCH_CLOCK_HI, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 98 | AK4396_WRITE | (reg << 8) | value); |
| 99 | } |
| 100 | |
| 101 | static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value) |
| 102 | { |
Clemens Ladisch | e58aee9 | 2008-05-13 09:20:51 +0200 | [diff] [blame^] | 103 | struct generic_data *data = chip->model_data; |
| 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); |
Clemens Ladisch | e58aee9 | 2008-05-13 09:20:51 +0200 | [diff] [blame^] | 111 | if (reg < ARRAY_SIZE(data->saved_wm8785_registers)) |
| 112 | data->saved_wm8785_registers[reg] = value; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | static void ak4396_init(struct oxygen *chip) |
| 116 | { |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 117 | struct generic_data *data = chip->model_data; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 118 | unsigned int i; |
| 119 | |
Clemens Ladisch | e983532 | 2008-04-16 09:14:30 +0200 | [diff] [blame] | 120 | data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 121 | for (i = 0; i < 4; ++i) { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 122 | ak4396_write(chip, i, |
| 123 | AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); |
| 124 | ak4396_write(chip, i, |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 125 | AK4396_CONTROL_2, data->ak4396_ctl2); |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 126 | ak4396_write(chip, i, |
| 127 | AK4396_CONTROL_3, AK4396_PCM); |
Clemens Ladisch | e983532 | 2008-04-16 09:14:30 +0200 | [diff] [blame] | 128 | ak4396_write(chip, i, AK4396_LCH_ATT, 0); |
| 129 | ak4396_write(chip, i, AK4396_RCH_ATT, 0); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 130 | } |
| 131 | snd_component_add(chip->card, "AK4396"); |
| 132 | } |
| 133 | |
| 134 | static void ak5385_init(struct oxygen *chip) |
| 135 | { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 136 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_AK5385_DFS_MASK); |
| 137 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_AK5385_DFS_MASK); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 138 | snd_component_add(chip->card, "AK5385"); |
| 139 | } |
| 140 | |
| 141 | static void wm8785_init(struct oxygen *chip) |
| 142 | { |
Clemens Ladisch | e58aee9 | 2008-05-13 09:20:51 +0200 | [diff] [blame^] | 143 | struct generic_data *data = chip->model_data; |
| 144 | |
| 145 | data->saved_wm8785_registers[0] = WM8785_MCR_SLAVE | |
| 146 | WM8785_OSR_SINGLE | WM8785_FORMAT_LJUST; |
| 147 | data->saved_wm8785_registers[1] = WM8785_WL_24; |
| 148 | |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 149 | wm8785_write(chip, WM8785_R7, 0); |
Clemens Ladisch | e58aee9 | 2008-05-13 09:20:51 +0200 | [diff] [blame^] | 150 | wm8785_write(chip, WM8785_R0, data->saved_wm8785_registers[0]); |
| 151 | wm8785_write(chip, WM8785_R1, data->saved_wm8785_registers[1]); |
| 152 | |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 153 | snd_component_add(chip->card, "WM8785"); |
| 154 | } |
| 155 | |
| 156 | static void generic_init(struct oxygen *chip) |
| 157 | { |
| 158 | ak4396_init(chip); |
| 159 | wm8785_init(chip); |
| 160 | } |
| 161 | |
| 162 | static void meridian_init(struct oxygen *chip) |
| 163 | { |
| 164 | ak4396_init(chip); |
| 165 | ak5385_init(chip); |
| 166 | } |
| 167 | |
| 168 | static void generic_cleanup(struct oxygen *chip) |
| 169 | { |
| 170 | } |
| 171 | |
| 172 | static void set_ak4396_params(struct oxygen *chip, |
| 173 | struct snd_pcm_hw_params *params) |
| 174 | { |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 175 | struct generic_data *data = chip->model_data; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 176 | unsigned int i; |
| 177 | u8 value; |
| 178 | |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 179 | value = data->ak4396_ctl2 & ~AK4396_DFS_MASK; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 180 | if (params_rate(params) <= 54000) |
| 181 | value |= AK4396_DFS_NORMAL; |
Clemens Ladisch | 236c492 | 2008-01-28 08:32:58 +0100 | [diff] [blame] | 182 | else if (params_rate(params) <= 108000) |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 183 | value |= AK4396_DFS_DOUBLE; |
| 184 | else |
| 185 | value |= AK4396_DFS_QUAD; |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 186 | data->ak4396_ctl2 = value; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 187 | for (i = 0; i < 4; ++i) { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 188 | ak4396_write(chip, i, |
| 189 | AK4396_CONTROL_1, AK4396_DIF_24_MSB); |
| 190 | ak4396_write(chip, i, |
| 191 | AK4396_CONTROL_2, value); |
| 192 | ak4396_write(chip, i, |
| 193 | AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | |
| 197 | static void update_ak4396_volume(struct oxygen *chip) |
| 198 | { |
| 199 | unsigned int i; |
| 200 | |
| 201 | for (i = 0; i < 4; ++i) { |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 202 | ak4396_write(chip, i, |
| 203 | AK4396_LCH_ATT, chip->dac_volume[i * 2]); |
| 204 | ak4396_write(chip, i, |
| 205 | AK4396_RCH_ATT, chip->dac_volume[i * 2 + 1]); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | |
| 209 | static void update_ak4396_mute(struct oxygen *chip) |
| 210 | { |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 211 | struct generic_data *data = chip->model_data; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 212 | unsigned int i; |
| 213 | u8 value; |
| 214 | |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 215 | value = data->ak4396_ctl2 & ~AK4396_SMUTE; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 216 | if (chip->dac_mute) |
| 217 | value |= AK4396_SMUTE; |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 218 | data->ak4396_ctl2 = value; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 219 | for (i = 0; i < 4; ++i) |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 220 | ak4396_write(chip, i, AK4396_CONTROL_2, value); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | static void set_wm8785_params(struct oxygen *chip, |
| 224 | struct snd_pcm_hw_params *params) |
| 225 | { |
| 226 | unsigned int value; |
| 227 | |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 228 | wm8785_write(chip, WM8785_R7, 0); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 229 | |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 230 | value = WM8785_MCR_SLAVE | WM8785_FORMAT_LJUST; |
Clemens Ladisch | 71e22a4 | 2008-01-21 08:50:51 +0100 | [diff] [blame] | 231 | if (params_rate(params) <= 48000) |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 232 | value |= WM8785_OSR_SINGLE; |
Clemens Ladisch | 71e22a4 | 2008-01-21 08:50:51 +0100 | [diff] [blame] | 233 | else if (params_rate(params) <= 96000) |
| 234 | value |= WM8785_OSR_DOUBLE; |
| 235 | else |
| 236 | value |= WM8785_OSR_QUAD; |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 237 | wm8785_write(chip, WM8785_R0, value); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 238 | |
| 239 | if (snd_pcm_format_width(params_format(params)) <= 16) |
| 240 | value = WM8785_WL_16; |
| 241 | else |
| 242 | value = WM8785_WL_24; |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 243 | wm8785_write(chip, WM8785_R1, value); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | static void set_ak5385_params(struct oxygen *chip, |
| 247 | struct snd_pcm_hw_params *params) |
| 248 | { |
| 249 | unsigned int value; |
| 250 | |
| 251 | if (params_rate(params) <= 54000) |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 252 | value = GPIO_AK5385_DFS_NORMAL; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 253 | else if (params_rate(params) <= 108000) |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 254 | value = GPIO_AK5385_DFS_DOUBLE; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 255 | else |
Clemens Ladisch | 878ac3e | 2008-01-21 08:50:19 +0100 | [diff] [blame] | 256 | value = GPIO_AK5385_DFS_QUAD; |
| 257 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, |
| 258 | value, GPIO_AK5385_DFS_MASK); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); |
| 262 | |
| 263 | static const struct oxygen_model model_generic = { |
| 264 | .shortname = "C-Media CMI8788", |
| 265 | .longname = "C-Media Oxygen HD Audio", |
| 266 | .chip = "CMI8788", |
| 267 | .owner = THIS_MODULE, |
| 268 | .init = generic_init, |
| 269 | .cleanup = generic_cleanup, |
| 270 | .set_dac_params = set_ak4396_params, |
| 271 | .set_adc_params = set_wm8785_params, |
| 272 | .update_dac_volume = update_ak4396_volume, |
| 273 | .update_dac_mute = update_ak4396_mute, |
Clemens Ladisch | 4972a17 | 2008-04-16 09:15:45 +0200 | [diff] [blame] | 274 | .dac_tlv = ak4396_db_scale, |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 275 | .model_data_size = sizeof(struct generic_data), |
Clemens Ladisch | f009ad9 | 2008-03-19 08:19:41 +0100 | [diff] [blame] | 276 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | |
| 277 | PLAYBACK_1_TO_SPDIF | |
| 278 | PLAYBACK_2_TO_AC97_1 | |
| 279 | CAPTURE_0_FROM_I2S_1 | |
| 280 | CAPTURE_1_FROM_SPDIF | |
| 281 | CAPTURE_2_FROM_AC97_1, |
Clemens Ladisch | 976cd62 | 2008-01-25 08:37:49 +0100 | [diff] [blame] | 282 | .dac_channels = 8, |
Clemens Ladisch | 193e813 | 2008-04-16 09:13:36 +0200 | [diff] [blame] | 283 | .dac_volume_min = 0, |
| 284 | .dac_volume_max = 255, |
Clemens Ladisch | 87eedd2 | 2008-03-19 08:20:13 +0100 | [diff] [blame] | 285 | .function_flags = OXYGEN_FUNCTION_SPI | |
| 286 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
Clemens Ladisch | 05855ba | 2008-01-17 09:05:09 +0100 | [diff] [blame] | 287 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 288 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 289 | }; |
| 290 | static const struct oxygen_model model_meridian = { |
| 291 | .shortname = "C-Media CMI8788", |
| 292 | .longname = "C-Media Oxygen HD Audio", |
| 293 | .chip = "CMI8788", |
| 294 | .owner = THIS_MODULE, |
| 295 | .init = meridian_init, |
| 296 | .cleanup = generic_cleanup, |
| 297 | .set_dac_params = set_ak4396_params, |
| 298 | .set_adc_params = set_ak5385_params, |
| 299 | .update_dac_volume = update_ak4396_volume, |
| 300 | .update_dac_mute = update_ak4396_mute, |
Clemens Ladisch | 4972a17 | 2008-04-16 09:15:45 +0200 | [diff] [blame] | 301 | .dac_tlv = ak4396_db_scale, |
Clemens Ladisch | 7ef37cd | 2008-01-21 08:51:55 +0100 | [diff] [blame] | 302 | .model_data_size = sizeof(struct generic_data), |
Clemens Ladisch | f009ad9 | 2008-03-19 08:19:41 +0100 | [diff] [blame] | 303 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | |
| 304 | PLAYBACK_1_TO_SPDIF | |
| 305 | PLAYBACK_2_TO_AC97_1 | |
| 306 | CAPTURE_0_FROM_I2S_2 | |
| 307 | CAPTURE_1_FROM_SPDIF | |
| 308 | CAPTURE_2_FROM_AC97_1, |
Clemens Ladisch | 976cd62 | 2008-01-25 08:37:49 +0100 | [diff] [blame] | 309 | .dac_channels = 8, |
Clemens Ladisch | 193e813 | 2008-04-16 09:13:36 +0200 | [diff] [blame] | 310 | .dac_volume_min = 0, |
| 311 | .dac_volume_max = 255, |
Clemens Ladisch | db12b8e | 2008-03-19 08:20:59 +0100 | [diff] [blame] | 312 | .misc_flags = OXYGEN_MISC_MIDI, |
Clemens Ladisch | 87eedd2 | 2008-03-19 08:20:13 +0100 | [diff] [blame] | 313 | .function_flags = OXYGEN_FUNCTION_SPI | |
| 314 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
Clemens Ladisch | 05855ba | 2008-01-17 09:05:09 +0100 | [diff] [blame] | 315 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 316 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 317 | }; |
| 318 | |
| 319 | static int __devinit generic_oxygen_probe(struct pci_dev *pci, |
| 320 | const struct pci_device_id *pci_id) |
| 321 | { |
| 322 | static int dev; |
Clemens Ladisch | cd93dc8 | 2008-01-24 08:43:39 +0100 | [diff] [blame] | 323 | int is_meridian; |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 324 | int err; |
| 325 | |
| 326 | if (dev >= SNDRV_CARDS) |
| 327 | return -ENODEV; |
| 328 | if (!enable[dev]) { |
| 329 | ++dev; |
| 330 | return -ENOENT; |
| 331 | } |
Clemens Ladisch | cd93dc8 | 2008-01-24 08:43:39 +0100 | [diff] [blame] | 332 | is_meridian = pci_id->driver_data; |
Clemens Ladisch | db12b8e | 2008-03-19 08:20:59 +0100 | [diff] [blame] | 333 | err = oxygen_pci_probe(pci, index[dev], id[dev], |
Clemens Ladisch | cd93dc8 | 2008-01-24 08:43:39 +0100 | [diff] [blame] | 334 | is_meridian ? &model_meridian : &model_generic); |
Clemens Ladisch | d0ce994 | 2007-12-23 19:50:57 +0100 | [diff] [blame] | 335 | if (err >= 0) |
| 336 | ++dev; |
| 337 | return err; |
| 338 | } |
| 339 | |
| 340 | static struct pci_driver oxygen_driver = { |
| 341 | .name = "CMI8788", |
| 342 | .id_table = oxygen_ids, |
| 343 | .probe = generic_oxygen_probe, |
| 344 | .remove = __devexit_p(oxygen_pci_remove), |
| 345 | }; |
| 346 | |
| 347 | static int __init alsa_card_oxygen_init(void) |
| 348 | { |
| 349 | return pci_register_driver(&oxygen_driver); |
| 350 | } |
| 351 | |
| 352 | static void __exit alsa_card_oxygen_exit(void) |
| 353 | { |
| 354 | pci_unregister_driver(&oxygen_driver); |
| 355 | } |
| 356 | |
| 357 | module_init(alsa_card_oxygen_init) |
| 358 | module_exit(alsa_card_oxygen_exit) |