Clemens Ladisch | 65c3ac8 | 2009-09-28 11:11:27 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * card driver for models with PCM1796 DACs (Xonar D2/D2X/HDAV1.3/ST/STX) |
| 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, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | /* |
| 20 | * Xonar D2/D2X |
| 21 | * ------------ |
| 22 | * |
| 23 | * CMI8788: |
| 24 | * |
| 25 | * SPI 0 -> 1st PCM1796 (front) |
| 26 | * SPI 1 -> 2nd PCM1796 (surround) |
| 27 | * SPI 2 -> 3rd PCM1796 (center/LFE) |
| 28 | * SPI 4 -> 4th PCM1796 (back) |
| 29 | * |
| 30 | * GPIO 2 -> M0 of CS5381 |
| 31 | * GPIO 3 -> M1 of CS5381 |
| 32 | * GPIO 5 <- external power present (D2X only) |
| 33 | * GPIO 7 -> ALT |
| 34 | * GPIO 8 -> enable output to speakers |
| 35 | */ |
| 36 | |
| 37 | /* |
| 38 | * Xonar HDAV1.3 (Deluxe) |
| 39 | * ---------------------- |
| 40 | * |
| 41 | * CMI8788: |
| 42 | * |
| 43 | * I²C <-> PCM1796 (front) |
| 44 | * |
| 45 | * GPI 0 <- external power present |
| 46 | * |
| 47 | * GPIO 0 -> enable output to speakers |
| 48 | * GPIO 2 -> M0 of CS5381 |
| 49 | * GPIO 3 -> M1 of CS5381 |
| 50 | * GPIO 8 -> route input jack to line-in (0) or mic-in (1) |
| 51 | * |
| 52 | * TXD -> HDMI controller |
| 53 | * RXD <- HDMI controller |
| 54 | * |
| 55 | * PCM1796 front: AD1,0 <- 0,0 |
| 56 | * |
| 57 | * no daughterboard |
| 58 | * ---------------- |
| 59 | * |
| 60 | * GPIO 4 <- 1 |
| 61 | * |
| 62 | * H6 daughterboard |
| 63 | * ---------------- |
| 64 | * |
| 65 | * GPIO 4 <- 0 |
| 66 | * GPIO 5 <- 0 |
| 67 | * |
| 68 | * I²C <-> PCM1796 (surround) |
| 69 | * <-> PCM1796 (center/LFE) |
| 70 | * <-> PCM1796 (back) |
| 71 | * |
| 72 | * PCM1796 surround: AD1,0 <- 0,1 |
| 73 | * PCM1796 center/LFE: AD1,0 <- 1,0 |
| 74 | * PCM1796 back: AD1,0 <- 1,1 |
| 75 | * |
| 76 | * unknown daughterboard |
| 77 | * --------------------- |
| 78 | * |
| 79 | * GPIO 4 <- 0 |
| 80 | * GPIO 5 <- 1 |
| 81 | * |
| 82 | * I²C <-> CS4362A (surround, center/LFE, back) |
| 83 | * |
| 84 | * CS4362A: AD0 <- 0 |
| 85 | */ |
| 86 | |
| 87 | /* |
| 88 | * Xonar Essence ST (Deluxe)/STX |
| 89 | * ----------------------------- |
| 90 | * |
| 91 | * CMI8788: |
| 92 | * |
| 93 | * I²C <-> PCM1792A |
| 94 | * |
| 95 | * GPI 0 <- external power present (STX only) |
| 96 | * |
| 97 | * GPIO 0 -> enable output to speakers |
| 98 | * GPIO 1 -> route HP to front panel (0) or rear jack (1) |
| 99 | * GPIO 2 -> M0 of CS5381 |
| 100 | * GPIO 3 -> M1 of CS5381 |
| 101 | * GPIO 7 -> route output to speaker jacks (0) or HP (1) |
| 102 | * GPIO 8 -> route input jack to line-in (0) or mic-in (1) |
| 103 | * |
| 104 | * PCM1792A: |
| 105 | * |
| 106 | * AD1,0 <- 0,0 |
| 107 | * |
| 108 | * H6 daughterboard |
| 109 | * ---------------- |
| 110 | * |
| 111 | * GPIO 4 <- 0 |
| 112 | * GPIO 5 <- 0 |
| 113 | */ |
| 114 | |
| 115 | #include <linux/pci.h> |
| 116 | #include <linux/delay.h> |
| 117 | #include <linux/mutex.h> |
| 118 | #include <sound/ac97_codec.h> |
| 119 | #include <sound/control.h> |
| 120 | #include <sound/core.h> |
| 121 | #include <sound/pcm.h> |
| 122 | #include <sound/pcm_params.h> |
| 123 | #include <sound/tlv.h> |
| 124 | #include "xonar.h" |
| 125 | #include "cm9780.h" |
| 126 | #include "pcm1796.h" |
| 127 | |
| 128 | |
| 129 | #define GPIO_D2X_EXT_POWER 0x0020 |
| 130 | #define GPIO_D2_ALT 0x0080 |
| 131 | #define GPIO_D2_OUTPUT_ENABLE 0x0100 |
| 132 | |
| 133 | #define GPI_EXT_POWER 0x01 |
| 134 | #define GPIO_INPUT_ROUTE 0x0100 |
| 135 | |
| 136 | #define GPIO_HDAV_OUTPUT_ENABLE 0x0001 |
| 137 | |
| 138 | #define GPIO_DB_MASK 0x0030 |
| 139 | #define GPIO_DB_H6 0x0000 |
| 140 | |
| 141 | #define GPIO_ST_OUTPUT_ENABLE 0x0001 |
| 142 | #define GPIO_ST_HP_REAR 0x0002 |
| 143 | #define GPIO_ST_HP 0x0080 |
| 144 | |
| 145 | #define I2C_DEVICE_PCM1796(i) (0x98 + ((i) << 1)) /* 10011, ii, /W=0 */ |
| 146 | |
| 147 | |
| 148 | struct xonar_pcm179x { |
| 149 | struct xonar_generic generic; |
| 150 | unsigned int dacs; |
| 151 | u8 oversampling; |
| 152 | }; |
| 153 | |
| 154 | struct xonar_hdav { |
| 155 | struct xonar_pcm179x pcm179x; |
| 156 | struct xonar_hdmi hdmi; |
| 157 | }; |
| 158 | |
| 159 | |
| 160 | static inline void pcm1796_write_spi(struct oxygen *chip, unsigned int codec, |
| 161 | u8 reg, u8 value) |
| 162 | { |
| 163 | /* maps ALSA channel pair number to SPI output */ |
| 164 | static const u8 codec_map[4] = { |
| 165 | 0, 1, 2, 4 |
| 166 | }; |
| 167 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | |
| 168 | OXYGEN_SPI_DATA_LENGTH_2 | |
| 169 | OXYGEN_SPI_CLOCK_160 | |
| 170 | (codec_map[codec] << OXYGEN_SPI_CODEC_SHIFT) | |
| 171 | OXYGEN_SPI_CEN_LATCH_CLOCK_HI, |
| 172 | (reg << 8) | value); |
| 173 | } |
| 174 | |
| 175 | static inline void pcm1796_write_i2c(struct oxygen *chip, unsigned int codec, |
| 176 | u8 reg, u8 value) |
| 177 | { |
| 178 | oxygen_write_i2c(chip, I2C_DEVICE_PCM1796(codec), reg, value); |
| 179 | } |
| 180 | |
| 181 | static void pcm1796_write(struct oxygen *chip, unsigned int codec, |
| 182 | u8 reg, u8 value) |
| 183 | { |
| 184 | if ((chip->model.function_flags & OXYGEN_FUNCTION_2WIRE_SPI_MASK) == |
| 185 | OXYGEN_FUNCTION_SPI) |
| 186 | pcm1796_write_spi(chip, codec, reg, value); |
| 187 | else |
| 188 | pcm1796_write_i2c(chip, codec, reg, value); |
| 189 | } |
| 190 | |
| 191 | static void update_pcm1796_volume(struct oxygen *chip) |
| 192 | { |
| 193 | struct xonar_pcm179x *data = chip->model_data; |
| 194 | unsigned int i; |
| 195 | |
| 196 | for (i = 0; i < data->dacs; ++i) { |
| 197 | pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]); |
| 198 | pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | static void update_pcm1796_mute(struct oxygen *chip) |
| 203 | { |
| 204 | struct xonar_pcm179x *data = chip->model_data; |
| 205 | unsigned int i; |
| 206 | u8 value; |
| 207 | |
| 208 | value = PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD; |
| 209 | if (chip->dac_mute) |
| 210 | value |= PCM1796_MUTE; |
| 211 | for (i = 0; i < data->dacs; ++i) |
| 212 | pcm1796_write(chip, i, 18, value); |
| 213 | } |
| 214 | |
| 215 | static void pcm1796_init(struct oxygen *chip) |
| 216 | { |
| 217 | struct xonar_pcm179x *data = chip->model_data; |
| 218 | unsigned int i; |
| 219 | |
| 220 | for (i = 0; i < data->dacs; ++i) { |
| 221 | pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); |
| 222 | pcm1796_write(chip, i, 20, data->oversampling); |
| 223 | pcm1796_write(chip, i, 21, 0); |
| 224 | } |
| 225 | update_pcm1796_mute(chip); /* set ATLD before ATL/ATR */ |
| 226 | update_pcm1796_volume(chip); |
| 227 | } |
| 228 | |
| 229 | static void xonar_d2_init(struct oxygen *chip) |
| 230 | { |
| 231 | struct xonar_pcm179x *data = chip->model_data; |
| 232 | |
| 233 | data->generic.anti_pop_delay = 300; |
| 234 | data->generic.output_enable_bit = GPIO_D2_OUTPUT_ENABLE; |
| 235 | data->dacs = 4; |
| 236 | data->oversampling = PCM1796_OS_64; |
| 237 | |
| 238 | pcm1796_init(chip); |
| 239 | |
| 240 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT); |
| 241 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT); |
| 242 | |
| 243 | oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC); |
| 244 | |
| 245 | xonar_init_cs53x1(chip); |
| 246 | xonar_enable_output(chip); |
| 247 | |
| 248 | snd_component_add(chip->card, "PCM1796"); |
| 249 | snd_component_add(chip->card, "CS5381"); |
| 250 | } |
| 251 | |
| 252 | static void xonar_d2x_init(struct oxygen *chip) |
| 253 | { |
| 254 | struct xonar_pcm179x *data = chip->model_data; |
| 255 | |
| 256 | data->generic.ext_power_reg = OXYGEN_GPIO_DATA; |
| 257 | data->generic.ext_power_int_reg = OXYGEN_GPIO_INTERRUPT_MASK; |
| 258 | data->generic.ext_power_bit = GPIO_D2X_EXT_POWER; |
| 259 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2X_EXT_POWER); |
| 260 | xonar_init_ext_power(chip); |
| 261 | xonar_d2_init(chip); |
| 262 | } |
| 263 | |
| 264 | static void xonar_hdav_init(struct oxygen *chip) |
| 265 | { |
| 266 | struct xonar_hdav *data = chip->model_data; |
| 267 | |
| 268 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, |
| 269 | OXYGEN_2WIRE_LENGTH_8 | |
| 270 | OXYGEN_2WIRE_INTERRUPT_MASK | |
| 271 | OXYGEN_2WIRE_SPEED_FAST); |
| 272 | |
| 273 | data->pcm179x.generic.anti_pop_delay = 100; |
| 274 | data->pcm179x.generic.output_enable_bit = GPIO_HDAV_OUTPUT_ENABLE; |
| 275 | data->pcm179x.generic.ext_power_reg = OXYGEN_GPI_DATA; |
| 276 | data->pcm179x.generic.ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; |
| 277 | data->pcm179x.generic.ext_power_bit = GPI_EXT_POWER; |
| 278 | data->pcm179x.dacs = chip->model.private_data ? 4 : 1; |
| 279 | data->pcm179x.oversampling = PCM1796_OS_64; |
| 280 | |
| 281 | pcm1796_init(chip); |
| 282 | |
| 283 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_INPUT_ROUTE); |
| 284 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_INPUT_ROUTE); |
| 285 | |
| 286 | xonar_init_cs53x1(chip); |
| 287 | xonar_init_ext_power(chip); |
| 288 | xonar_hdmi_init(chip, &data->hdmi); |
| 289 | xonar_enable_output(chip); |
| 290 | |
| 291 | snd_component_add(chip->card, "PCM1796"); |
| 292 | snd_component_add(chip->card, "CS5381"); |
| 293 | } |
| 294 | |
| 295 | static void xonar_st_init(struct oxygen *chip) |
| 296 | { |
| 297 | struct xonar_pcm179x *data = chip->model_data; |
| 298 | |
| 299 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, |
| 300 | OXYGEN_2WIRE_LENGTH_8 | |
| 301 | OXYGEN_2WIRE_INTERRUPT_MASK | |
| 302 | OXYGEN_2WIRE_SPEED_FAST); |
| 303 | |
| 304 | data->generic.anti_pop_delay = 100; |
| 305 | data->generic.output_enable_bit = GPIO_ST_OUTPUT_ENABLE; |
| 306 | data->dacs = chip->model.private_data ? 4 : 1; |
| 307 | data->oversampling = PCM1796_OS_64; |
| 308 | |
| 309 | pcm1796_init(chip); |
| 310 | |
| 311 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, |
| 312 | GPIO_INPUT_ROUTE | GPIO_ST_HP_REAR | GPIO_ST_HP); |
| 313 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, |
| 314 | GPIO_INPUT_ROUTE | GPIO_ST_HP_REAR | GPIO_ST_HP); |
| 315 | |
| 316 | xonar_init_cs53x1(chip); |
| 317 | xonar_enable_output(chip); |
| 318 | |
| 319 | snd_component_add(chip->card, "PCM1792A"); |
| 320 | snd_component_add(chip->card, "CS5381"); |
| 321 | } |
| 322 | |
| 323 | static void xonar_stx_init(struct oxygen *chip) |
| 324 | { |
| 325 | struct xonar_pcm179x *data = chip->model_data; |
| 326 | |
| 327 | data->generic.ext_power_reg = OXYGEN_GPI_DATA; |
| 328 | data->generic.ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; |
| 329 | data->generic.ext_power_bit = GPI_EXT_POWER; |
| 330 | xonar_init_ext_power(chip); |
| 331 | xonar_st_init(chip); |
| 332 | } |
| 333 | |
| 334 | static void xonar_d2_cleanup(struct oxygen *chip) |
| 335 | { |
| 336 | xonar_disable_output(chip); |
| 337 | } |
| 338 | |
| 339 | static void xonar_hdav_cleanup(struct oxygen *chip) |
| 340 | { |
| 341 | xonar_hdmi_cleanup(chip); |
| 342 | xonar_disable_output(chip); |
| 343 | msleep(2); |
| 344 | } |
| 345 | |
| 346 | static void xonar_st_cleanup(struct oxygen *chip) |
| 347 | { |
| 348 | xonar_disable_output(chip); |
| 349 | } |
| 350 | |
| 351 | static void xonar_d2_suspend(struct oxygen *chip) |
| 352 | { |
| 353 | xonar_d2_cleanup(chip); |
| 354 | } |
| 355 | |
| 356 | static void xonar_hdav_suspend(struct oxygen *chip) |
| 357 | { |
| 358 | xonar_hdav_cleanup(chip); |
| 359 | } |
| 360 | |
| 361 | static void xonar_st_suspend(struct oxygen *chip) |
| 362 | { |
| 363 | xonar_st_cleanup(chip); |
| 364 | } |
| 365 | |
| 366 | static void xonar_d2_resume(struct oxygen *chip) |
| 367 | { |
| 368 | pcm1796_init(chip); |
| 369 | xonar_enable_output(chip); |
| 370 | } |
| 371 | |
| 372 | static void xonar_hdav_resume(struct oxygen *chip) |
| 373 | { |
| 374 | struct xonar_hdav *data = chip->model_data; |
| 375 | |
| 376 | pcm1796_init(chip); |
| 377 | xonar_hdmi_resume(chip, &data->hdmi); |
| 378 | xonar_enable_output(chip); |
| 379 | } |
| 380 | |
| 381 | static void xonar_st_resume(struct oxygen *chip) |
| 382 | { |
| 383 | pcm1796_init(chip); |
| 384 | xonar_enable_output(chip); |
| 385 | } |
| 386 | |
| 387 | static void set_pcm1796_params(struct oxygen *chip, |
| 388 | struct snd_pcm_hw_params *params) |
| 389 | { |
| 390 | struct xonar_pcm179x *data = chip->model_data; |
| 391 | unsigned int i; |
| 392 | |
| 393 | data->oversampling = |
| 394 | params_rate(params) >= 96000 ? PCM1796_OS_32 : PCM1796_OS_64; |
| 395 | for (i = 0; i < data->dacs; ++i) |
| 396 | pcm1796_write(chip, i, 20, data->oversampling); |
| 397 | } |
| 398 | |
| 399 | static void set_hdav_params(struct oxygen *chip, |
| 400 | struct snd_pcm_hw_params *params) |
| 401 | { |
| 402 | struct xonar_hdav *data = chip->model_data; |
| 403 | |
| 404 | set_pcm1796_params(chip, params); |
| 405 | xonar_set_hdmi_params(chip, &data->hdmi, params); |
| 406 | } |
| 407 | |
| 408 | static const struct snd_kcontrol_new alt_switch = { |
| 409 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 410 | .name = "Analog Loopback Switch", |
| 411 | .info = snd_ctl_boolean_mono_info, |
| 412 | .get = xonar_gpio_bit_switch_get, |
| 413 | .put = xonar_gpio_bit_switch_put, |
| 414 | .private_value = GPIO_D2_ALT, |
| 415 | }; |
| 416 | |
| 417 | static int st_output_switch_info(struct snd_kcontrol *ctl, |
| 418 | struct snd_ctl_elem_info *info) |
| 419 | { |
| 420 | static const char *const names[3] = { |
| 421 | "Speakers", "Headphones", "FP Headphones" |
| 422 | }; |
| 423 | |
| 424 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 425 | info->count = 1; |
| 426 | info->value.enumerated.items = 3; |
| 427 | if (info->value.enumerated.item >= 3) |
| 428 | info->value.enumerated.item = 2; |
| 429 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); |
| 430 | return 0; |
| 431 | } |
| 432 | |
| 433 | static int st_output_switch_get(struct snd_kcontrol *ctl, |
| 434 | struct snd_ctl_elem_value *value) |
| 435 | { |
| 436 | struct oxygen *chip = ctl->private_data; |
| 437 | u16 gpio; |
| 438 | |
| 439 | gpio = oxygen_read16(chip, OXYGEN_GPIO_DATA); |
| 440 | if (!(gpio & GPIO_ST_HP)) |
| 441 | value->value.enumerated.item[0] = 0; |
| 442 | else if (gpio & GPIO_ST_HP_REAR) |
| 443 | value->value.enumerated.item[0] = 1; |
| 444 | else |
| 445 | value->value.enumerated.item[0] = 2; |
| 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | |
| 450 | static int st_output_switch_put(struct snd_kcontrol *ctl, |
| 451 | struct snd_ctl_elem_value *value) |
| 452 | { |
| 453 | struct oxygen *chip = ctl->private_data; |
| 454 | u16 gpio_old, gpio; |
| 455 | |
| 456 | mutex_lock(&chip->mutex); |
| 457 | gpio_old = oxygen_read16(chip, OXYGEN_GPIO_DATA); |
| 458 | gpio = gpio_old; |
| 459 | switch (value->value.enumerated.item[0]) { |
| 460 | case 0: |
| 461 | gpio &= ~(GPIO_ST_HP | GPIO_ST_HP_REAR); |
| 462 | break; |
| 463 | case 1: |
| 464 | gpio |= GPIO_ST_HP | GPIO_ST_HP_REAR; |
| 465 | break; |
| 466 | case 2: |
| 467 | gpio = (gpio | GPIO_ST_HP) & ~GPIO_ST_HP_REAR; |
| 468 | break; |
| 469 | } |
| 470 | oxygen_write16(chip, OXYGEN_GPIO_DATA, gpio); |
| 471 | mutex_unlock(&chip->mutex); |
| 472 | return gpio != gpio_old; |
| 473 | } |
| 474 | |
| 475 | static const struct snd_kcontrol_new st_output_switch = { |
| 476 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 477 | .name = "Analog Output", |
| 478 | .info = st_output_switch_info, |
| 479 | .get = st_output_switch_get, |
| 480 | .put = st_output_switch_put, |
| 481 | }; |
| 482 | |
| 483 | static void xonar_line_mic_ac97_switch(struct oxygen *chip, |
| 484 | unsigned int reg, unsigned int mute) |
| 485 | { |
| 486 | if (reg == AC97_LINE) { |
| 487 | spin_lock_irq(&chip->reg_lock); |
| 488 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, |
| 489 | mute ? GPIO_INPUT_ROUTE : 0, |
| 490 | GPIO_INPUT_ROUTE); |
| 491 | spin_unlock_irq(&chip->reg_lock); |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -6000, 50, 0); |
| 496 | |
| 497 | static int xonar_d2_control_filter(struct snd_kcontrol_new *template) |
| 498 | { |
| 499 | if (!strncmp(template->name, "CD Capture ", 11)) |
| 500 | /* CD in is actually connected to the video in pin */ |
| 501 | template->private_value ^= AC97_CD ^ AC97_VIDEO; |
| 502 | return 0; |
| 503 | } |
| 504 | |
| 505 | static int xonar_st_control_filter(struct snd_kcontrol_new *template) |
| 506 | { |
| 507 | if (!strncmp(template->name, "CD Capture ", 11)) |
| 508 | return 1; /* no CD input */ |
| 509 | if (!strcmp(template->name, "Stereo Upmixing")) |
| 510 | return 1; /* stereo only - we don't need upmixing */ |
| 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | static int xonar_d2_mixer_init(struct oxygen *chip) |
| 515 | { |
| 516 | return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); |
| 517 | } |
| 518 | |
| 519 | static int xonar_st_mixer_init(struct oxygen *chip) |
| 520 | { |
| 521 | return snd_ctl_add(chip->card, snd_ctl_new1(&st_output_switch, chip)); |
| 522 | } |
| 523 | |
| 524 | static const struct oxygen_model model_xonar_d2 = { |
| 525 | .longname = "Asus Virtuoso 200", |
| 526 | .chip = "AV200", |
| 527 | .init = xonar_d2_init, |
| 528 | .control_filter = xonar_d2_control_filter, |
| 529 | .mixer_init = xonar_d2_mixer_init, |
| 530 | .cleanup = xonar_d2_cleanup, |
| 531 | .suspend = xonar_d2_suspend, |
| 532 | .resume = xonar_d2_resume, |
| 533 | .set_dac_params = set_pcm1796_params, |
| 534 | .set_adc_params = xonar_set_cs53x1_params, |
| 535 | .update_dac_volume = update_pcm1796_volume, |
| 536 | .update_dac_mute = update_pcm1796_mute, |
| 537 | .dac_tlv = pcm1796_db_scale, |
| 538 | .model_data_size = sizeof(struct xonar_pcm179x), |
| 539 | .device_config = PLAYBACK_0_TO_I2S | |
| 540 | PLAYBACK_1_TO_SPDIF | |
| 541 | CAPTURE_0_FROM_I2S_2 | |
| 542 | CAPTURE_1_FROM_SPDIF | |
| 543 | MIDI_OUTPUT | |
| 544 | MIDI_INPUT, |
| 545 | .dac_channels = 8, |
| 546 | .dac_volume_min = 255 - 2*60, |
| 547 | .dac_volume_max = 255, |
| 548 | .misc_flags = OXYGEN_MISC_MIDI, |
| 549 | .function_flags = OXYGEN_FUNCTION_SPI | |
| 550 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
| 551 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 552 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 553 | }; |
| 554 | |
| 555 | static const struct oxygen_model model_xonar_hdav = { |
| 556 | .longname = "Asus Virtuoso 200", |
| 557 | .chip = "AV200", |
| 558 | .init = xonar_hdav_init, |
| 559 | .cleanup = xonar_hdav_cleanup, |
| 560 | .suspend = xonar_hdav_suspend, |
| 561 | .resume = xonar_hdav_resume, |
| 562 | .pcm_hardware_filter = xonar_hdmi_pcm_hardware_filter, |
| 563 | .set_dac_params = set_hdav_params, |
| 564 | .set_adc_params = xonar_set_cs53x1_params, |
| 565 | .update_dac_volume = update_pcm1796_volume, |
| 566 | .update_dac_mute = update_pcm1796_mute, |
| 567 | .uart_input = xonar_hdmi_uart_input, |
| 568 | .ac97_switch = xonar_line_mic_ac97_switch, |
| 569 | .dac_tlv = pcm1796_db_scale, |
| 570 | .model_data_size = sizeof(struct xonar_hdav), |
| 571 | .device_config = PLAYBACK_0_TO_I2S | |
| 572 | PLAYBACK_1_TO_SPDIF | |
| 573 | CAPTURE_0_FROM_I2S_2 | |
| 574 | CAPTURE_1_FROM_SPDIF, |
| 575 | .dac_channels = 8, |
| 576 | .dac_volume_min = 255 - 2*60, |
| 577 | .dac_volume_max = 255, |
| 578 | .misc_flags = OXYGEN_MISC_MIDI, |
| 579 | .function_flags = OXYGEN_FUNCTION_2WIRE, |
| 580 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 581 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 582 | }; |
| 583 | |
| 584 | static const struct oxygen_model model_xonar_st = { |
| 585 | .longname = "Asus Virtuoso 100", |
| 586 | .chip = "AV200", |
| 587 | .init = xonar_st_init, |
| 588 | .control_filter = xonar_st_control_filter, |
| 589 | .mixer_init = xonar_st_mixer_init, |
| 590 | .cleanup = xonar_st_cleanup, |
| 591 | .suspend = xonar_st_suspend, |
| 592 | .resume = xonar_st_resume, |
| 593 | .set_dac_params = set_pcm1796_params, |
| 594 | .set_adc_params = xonar_set_cs53x1_params, |
| 595 | .update_dac_volume = update_pcm1796_volume, |
| 596 | .update_dac_mute = update_pcm1796_mute, |
| 597 | .ac97_switch = xonar_line_mic_ac97_switch, |
| 598 | .dac_tlv = pcm1796_db_scale, |
| 599 | .model_data_size = sizeof(struct xonar_pcm179x), |
| 600 | .device_config = PLAYBACK_0_TO_I2S | |
| 601 | PLAYBACK_1_TO_SPDIF | |
| 602 | CAPTURE_0_FROM_I2S_2, |
| 603 | .dac_channels = 2, |
| 604 | .dac_volume_min = 255 - 2*60, |
| 605 | .dac_volume_max = 255, |
| 606 | .function_flags = OXYGEN_FUNCTION_2WIRE, |
| 607 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 608 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
| 609 | }; |
| 610 | |
| 611 | int __devinit get_xonar_pcm179x_model(struct oxygen *chip, |
| 612 | const struct pci_device_id *id) |
| 613 | { |
| 614 | switch (id->subdevice) { |
| 615 | case 0x8269: |
| 616 | chip->model = model_xonar_d2; |
| 617 | chip->model.shortname = "Xonar D2"; |
| 618 | break; |
| 619 | case 0x82b7: |
| 620 | chip->model = model_xonar_d2; |
| 621 | chip->model.shortname = "Xonar D2X"; |
| 622 | chip->model.init = xonar_d2x_init; |
| 623 | break; |
| 624 | case 0x8314: |
| 625 | chip->model = model_xonar_hdav; |
| 626 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DB_MASK); |
| 627 | switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DB_MASK) { |
| 628 | default: |
| 629 | chip->model.shortname = "Xonar HDAV1.3"; |
| 630 | break; |
| 631 | case GPIO_DB_H6: |
| 632 | chip->model.shortname = "Xonar HDAV1.3+H6"; |
| 633 | chip->model.private_data = 1; |
| 634 | break; |
| 635 | } |
| 636 | break; |
| 637 | case 0x835d: |
| 638 | chip->model = model_xonar_st; |
| 639 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DB_MASK); |
| 640 | switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DB_MASK) { |
| 641 | default: |
| 642 | chip->model.shortname = "Xonar ST"; |
| 643 | break; |
| 644 | case GPIO_DB_H6: |
| 645 | chip->model.shortname = "Xonar ST+H6"; |
| 646 | chip->model.dac_channels = 8; |
| 647 | chip->model.private_data = 1; |
| 648 | break; |
| 649 | } |
| 650 | break; |
| 651 | case 0x835c: |
| 652 | chip->model = model_xonar_st; |
| 653 | chip->model.shortname = "Xonar STX"; |
| 654 | chip->model.init = xonar_stx_init; |
| 655 | break; |
| 656 | default: |
| 657 | return -EINVAL; |
| 658 | } |
| 659 | return 0; |
| 660 | } |