diff options
author | James Courtier-Dutton <James@superbug.co.uk> | 2006-04-09 08:01:34 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-06-22 15:32:35 -0400 |
commit | 6129daaa0d2b84c0e376b6b17b3d3740c4d1d1ca (patch) | |
tree | 8a043f22709ffa613f44a4bc1d3aeed256f488cf /sound/pci/ca0106/ca0106_main.c | |
parent | 52ab3f3dc711eeccbfbcc5d4f5c5d9b9ff59650f (diff) |
[ALSA] ca0106: Add analog capture controls.
Signed-off-by: James Courtier-Dutton <James@superbug.co.uk>
Diffstat (limited to 'sound/pci/ca0106/ca0106_main.c')
-rw-r--r-- | sound/pci/ca0106/ca0106_main.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index fd8bfebfbd54..3762f58384e0 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c | |||
@@ -326,6 +326,7 @@ int snd_ca0106_spi_write(struct snd_ca0106 * emu, | |||
326 | return 0; | 326 | return 0; |
327 | } | 327 | } |
328 | 328 | ||
329 | /* The ADC does not support i2c read, so only write is implemented */ | ||
329 | int snd_ca0106_i2c_write(struct snd_ca0106 *emu, | 330 | int snd_ca0106_i2c_write(struct snd_ca0106 *emu, |
330 | u32 reg, | 331 | u32 reg, |
331 | u32 value) | 332 | u32 value) |
@@ -340,6 +341,7 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu, | |||
340 | } | 341 | } |
341 | 342 | ||
342 | tmp = reg << 25 | value << 16; | 343 | tmp = reg << 25 | value << 16; |
344 | // snd_printk("I2C-write:reg=0x%x, value=0x%x\n", reg, value); | ||
343 | /* Not sure what this I2C channel controls. */ | 345 | /* Not sure what this I2C channel controls. */ |
344 | /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */ | 346 | /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */ |
345 | 347 | ||
@@ -348,8 +350,9 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu, | |||
348 | 350 | ||
349 | for (retry = 0; retry < 10; retry++) { | 351 | for (retry = 0; retry < 10; retry++) { |
350 | /* Send the data to i2c */ | 352 | /* Send the data to i2c */ |
351 | tmp = snd_ca0106_ptr_read(emu, I2C_A, 0); | 353 | //tmp = snd_ca0106_ptr_read(emu, I2C_A, 0); |
352 | tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK); | 354 | //tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK); |
355 | tmp = 0; | ||
353 | tmp = tmp | (I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD); | 356 | tmp = tmp | (I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD); |
354 | snd_ca0106_ptr_write(emu, I2C_A, 0, tmp); | 357 | snd_ca0106_ptr_write(emu, I2C_A, 0, tmp); |
355 | 358 | ||
@@ -1200,6 +1203,22 @@ static unsigned int spi_dac_init[] = { | |||
1200 | 0x1400, | 1203 | 0x1400, |
1201 | }; | 1204 | }; |
1202 | 1205 | ||
1206 | static unsigned int i2c_adc_init[][2] = { | ||
1207 | { 0x17, 0x00 }, /* Reset */ | ||
1208 | { 0x07, 0x00 }, /* Timeout */ | ||
1209 | { 0x0b, 0x22 }, /* Interface control */ | ||
1210 | { 0x0c, 0x22 }, /* Master mode control */ | ||
1211 | { 0x0d, 0x08 }, /* Powerdown control */ | ||
1212 | { 0x0e, 0xcf }, /* Attenuation Left 0x01 = -103dB, 0xff = 24dB */ | ||
1213 | { 0x0f, 0xcf }, /* Attenuation Right 0.5dB steps */ | ||
1214 | { 0x10, 0x7b }, /* ALC Control 1 */ | ||
1215 | { 0x11, 0x00 }, /* ALC Control 2 */ | ||
1216 | { 0x12, 0x32 }, /* ALC Control 3 */ | ||
1217 | { 0x13, 0x00 }, /* Noise gate control */ | ||
1218 | { 0x14, 0xa6 }, /* Limiter control */ | ||
1219 | { 0x15, ADC_MUX_LINEIN }, /* ADC Mixer control */ | ||
1220 | }; | ||
1221 | |||
1203 | static int __devinit snd_ca0106_create(struct snd_card *card, | 1222 | static int __devinit snd_ca0106_create(struct snd_card *card, |
1204 | struct pci_dev *pci, | 1223 | struct pci_dev *pci, |
1205 | struct snd_ca0106 **rchip) | 1224 | struct snd_ca0106 **rchip) |
@@ -1361,7 +1380,12 @@ static int __devinit snd_ca0106_create(struct snd_card *card, | |||
1361 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC, Line in, TAD in, AUX in */ | 1380 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC, Line in, TAD in, AUX in */ |
1362 | chip->capture_source = 3; /* Set CAPTURE_SOURCE */ | 1381 | chip->capture_source = 3; /* Set CAPTURE_SOURCE */ |
1363 | 1382 | ||
1364 | if (chip->details->gpio_type == 1) { /* The SB0410 and SB0413 use GPIO differently. */ | 1383 | if (chip->details->gpio_type == 2) { /* The SB0410 and SB0413 use GPIO differently. */ |
1384 | /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ | ||
1385 | outl(0x0, chip->port+GPIO); | ||
1386 | //outl(0x00f0e000, chip->port+GPIO); /* Analog */ | ||
1387 | outl(0x005f5301, chip->port+GPIO); /* Analog */ | ||
1388 | } else if (chip->details->gpio_type == 1) { /* The SB0410 and SB0413 use GPIO differently. */ | ||
1365 | /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ | 1389 | /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ |
1366 | outl(0x0, chip->port+GPIO); | 1390 | outl(0x0, chip->port+GPIO); |
1367 | //outl(0x00f0e000, chip->port+GPIO); /* Analog */ | 1391 | //outl(0x00f0e000, chip->port+GPIO); /* Analog */ |
@@ -1379,7 +1403,19 @@ static int __devinit snd_ca0106_create(struct snd_card *card, | |||
1379 | outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); /* AC97 2.0, Enable outputs. */ | 1403 | outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); /* AC97 2.0, Enable outputs. */ |
1380 | 1404 | ||
1381 | if (chip->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ | 1405 | if (chip->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ |
1382 | snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ | 1406 | int size, n; |
1407 | |||
1408 | size = ARRAY_SIZE(i2c_adc_init); | ||
1409 | //snd_printk("I2C:array size=0x%x\n", size); | ||
1410 | for (n=0; n < size; n++) { | ||
1411 | snd_ca0106_i2c_write(chip, i2c_adc_init[n][0], i2c_adc_init[n][1]); | ||
1412 | } | ||
1413 | for (n=0; n < 4; n++) { | ||
1414 | chip->i2c_capture_volume[n][0]= 0xcf; | ||
1415 | chip->i2c_capture_volume[n][1]= 0xcf; | ||
1416 | } | ||
1417 | chip->i2c_capture_source=2; /* Line in */ | ||
1418 | //snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ | ||
1383 | } | 1419 | } |
1384 | if (chip->details->spi_dac == 1) { /* The SB0570 use SPI to control DAC. */ | 1420 | if (chip->details->spi_dac == 1) { /* The SB0570 use SPI to control DAC. */ |
1385 | int size, n; | 1421 | int size, n; |