aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-01-17 03:05:09 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:30:03 -0500
commit05855ba3f405d02c4530072527d2b1c72e3b38a9 (patch)
treea3a53083e0e773d606f56922f927f719568026d9 /sound/pci
parentb8c5b53e1f104a9f877f947cdb86d5c7208d6c9a (diff)
[ALSA] oxygen: make the I2S format configurable
Add proper register bit symbols for the I2S format field, and allow card models to configure the I2S format to be used for the DACs and ADCs. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/oxygen/oxygen.c4
-rw-r--r--sound/pci/oxygen/oxygen.h2
-rw-r--r--sound/pci/oxygen/oxygen_pcm.c46
-rw-r--r--sound/pci/oxygen/oxygen_regs.h16
-rw-r--r--sound/pci/oxygen/virtuoso.c6
5 files changed, 44 insertions, 30 deletions
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index f8e3fd39749d..e618cde7f9e4 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -285,6 +285,8 @@ static const struct oxygen_model model_generic = {
285 OXYGEN_CHANNEL_MULTICH | 285 OXYGEN_CHANNEL_MULTICH |
286 OXYGEN_CHANNEL_AC97, 286 OXYGEN_CHANNEL_AC97,
287 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5, 287 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5,
288 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
289 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
288}; 290};
289static const struct oxygen_model model_meridian = { 291static const struct oxygen_model model_meridian = {
290 .shortname = "C-Media CMI8788", 292 .shortname = "C-Media CMI8788",
@@ -304,6 +306,8 @@ static const struct oxygen_model model_meridian = {
304 OXYGEN_CHANNEL_MULTICH | 306 OXYGEN_CHANNEL_MULTICH |
305 OXYGEN_CHANNEL_AC97, 307 OXYGEN_CHANNEL_AC97,
306 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5, 308 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5,
309 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
310 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
307}; 311};
308 312
309static int __devinit generic_oxygen_probe(struct pci_dev *pci, 313static int __devinit generic_oxygen_probe(struct pci_dev *pci,
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index 602105ce2947..98cccc6ce9dc 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -86,6 +86,8 @@ struct oxygen_model {
86 void (*update_dac_mute)(struct oxygen *chip); 86 void (*update_dac_mute)(struct oxygen *chip);
87 u8 used_channels; 87 u8 used_channels;
88 u8 function_flags; 88 u8 function_flags;
89 u16 dac_i2s_format;
90 u16 adc_i2s_format;
89}; 91};
90 92
91/* oxygen_lib.c */ 93/* oxygen_lib.c */
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c
index 5515c757ec4b..f24659af53d3 100644
--- a/sound/pci/oxygen/oxygen_pcm.c
+++ b/sound/pci/oxygen/oxygen_pcm.c
@@ -313,12 +313,12 @@ static unsigned int oxygen_i2s_magic2(struct snd_pcm_hw_params *hw_params)
313 return params_rate(hw_params) <= 96000 ? 0x10 : 0x00; 313 return params_rate(hw_params) <= 96000 ? 0x10 : 0x00;
314} 314}
315 315
316static unsigned int oxygen_i2s_format(struct snd_pcm_hw_params *hw_params) 316static unsigned int oxygen_i2s_bits(struct snd_pcm_hw_params *hw_params)
317{ 317{
318 if (params_format(hw_params) == SNDRV_PCM_FORMAT_S32_LE) 318 if (params_format(hw_params) == SNDRV_PCM_FORMAT_S32_LE)
319 return OXYGEN_I2S_FORMAT_24; 319 return OXYGEN_I2S_BITS_24;
320 else 320 else
321 return OXYGEN_I2S_FORMAT_16; 321 return OXYGEN_I2S_BITS_16;
322} 322}
323 323
324static unsigned int oxygen_play_channels(struct snd_pcm_hw_params *hw_params) 324static unsigned int oxygen_play_channels(struct snd_pcm_hw_params *hw_params)
@@ -386,13 +386,15 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream,
386 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, 386 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
387 oxygen_format(hw_params) << OXYGEN_REC_FORMAT_A_SHIFT, 387 oxygen_format(hw_params) << OXYGEN_REC_FORMAT_A_SHIFT,
388 OXYGEN_REC_FORMAT_A_MASK); 388 OXYGEN_REC_FORMAT_A_MASK);
389 oxygen_write8_masked(chip, OXYGEN_I2S_A_FORMAT, 389 oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT,
390 oxygen_rate(hw_params) | 390 oxygen_rate(hw_params) |
391 oxygen_i2s_magic2(hw_params) | 391 oxygen_i2s_magic2(hw_params) |
392 oxygen_i2s_format(hw_params), 392 chip->model->adc_i2s_format |
393 OXYGEN_I2S_RATE_MASK | 393 oxygen_i2s_bits(hw_params),
394 OXYGEN_I2S_MAGIC2_MASK | 394 OXYGEN_I2S_RATE_MASK |
395 OXYGEN_I2S_FORMAT_MASK); 395 OXYGEN_I2S_FORMAT_MASK |
396 OXYGEN_I2S_MAGIC2_MASK |
397 OXYGEN_I2S_BITS_MASK);
396 oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x08); 398 oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x08);
397 spin_unlock_irq(&chip->reg_lock); 399 spin_unlock_irq(&chip->reg_lock);
398 400
@@ -416,13 +418,15 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream,
416 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, 418 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
417 oxygen_format(hw_params) << OXYGEN_REC_FORMAT_B_SHIFT, 419 oxygen_format(hw_params) << OXYGEN_REC_FORMAT_B_SHIFT,
418 OXYGEN_REC_FORMAT_B_MASK); 420 OXYGEN_REC_FORMAT_B_MASK);
419 oxygen_write8_masked(chip, OXYGEN_I2S_B_FORMAT, 421 oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT,
420 oxygen_rate(hw_params) | 422 oxygen_rate(hw_params) |
421 oxygen_i2s_magic2(hw_params) | 423 oxygen_i2s_magic2(hw_params) |
422 oxygen_i2s_format(hw_params), 424 chip->model->adc_i2s_format |
423 OXYGEN_I2S_RATE_MASK | 425 oxygen_i2s_bits(hw_params),
424 OXYGEN_I2S_MAGIC2_MASK | 426 OXYGEN_I2S_RATE_MASK |
425 OXYGEN_I2S_FORMAT_MASK); 427 OXYGEN_I2S_FORMAT_MASK |
428 OXYGEN_I2S_MAGIC2_MASK |
429 OXYGEN_I2S_BITS_MASK);
426 oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x10); 430 oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x10);
427 spin_unlock_irq(&chip->reg_lock); 431 spin_unlock_irq(&chip->reg_lock);
428 432
@@ -493,8 +497,12 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream,
493 oxygen_format(hw_params) << OXYGEN_MULTICH_FORMAT_SHIFT, 497 oxygen_format(hw_params) << OXYGEN_MULTICH_FORMAT_SHIFT,
494 OXYGEN_MULTICH_FORMAT_MASK); 498 OXYGEN_MULTICH_FORMAT_MASK);
495 oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, 499 oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT,
496 oxygen_rate(hw_params) | oxygen_i2s_format(hw_params), 500 oxygen_rate(hw_params) |
497 OXYGEN_I2S_RATE_MASK | OXYGEN_I2S_FORMAT_MASK); 501 chip->model->dac_i2s_format |
502 oxygen_i2s_bits(hw_params),
503 OXYGEN_I2S_RATE_MASK |
504 OXYGEN_I2S_FORMAT_MASK |
505 OXYGEN_I2S_BITS_MASK);
498 oxygen_clear_bits16(chip, OXYGEN_PLAY_ROUTING, 0x001f); 506 oxygen_clear_bits16(chip, OXYGEN_PLAY_ROUTING, 0x001f);
499 oxygen_update_dac_routing(chip); 507 oxygen_update_dac_routing(chip);
500 oxygen_update_spdif_source(chip); 508 oxygen_update_spdif_source(chip);
diff --git a/sound/pci/oxygen/oxygen_regs.h b/sound/pci/oxygen/oxygen_regs.h
index 7a4726d2b2cf..b3491f73c598 100644
--- a/sound/pci/oxygen/oxygen_regs.h
+++ b/sound/pci/oxygen/oxygen_regs.h
@@ -105,18 +105,20 @@
105#define OXYGEN_RATE_96000 0x0005 105#define OXYGEN_RATE_96000 0x0005
106#define OXYGEN_RATE_176400 0x0006 106#define OXYGEN_RATE_176400 0x0006
107#define OXYGEN_RATE_192000 0x0007 107#define OXYGEN_RATE_192000 0x0007
108#define OXYGEN_I2S_MAGIC1_MASK 0x0008 108#define OXYGEN_I2S_FORMAT_MASK 0x0008
109#define OXYGEN_I2S_FORMAT_I2S 0x0000
110#define OXYGEN_I2S_FORMAT_LJUST 0x0008
109#define OXYGEN_I2S_MAGIC2_MASK 0x0030 111#define OXYGEN_I2S_MAGIC2_MASK 0x0030
110#define OXYGEN_I2S_FORMAT_MASK 0x00c0 112#define OXYGEN_I2S_BITS_MASK 0x00c0
111#define OXYGEN_I2S_FORMAT_16 0x0000 113#define OXYGEN_I2S_BITS_16 0x0000
112#define OXYGEN_I2S_FORMAT_20 0x0040 114#define OXYGEN_I2S_BITS_20 0x0040
113#define OXYGEN_I2S_FORMAT_24 0x0080 115#define OXYGEN_I2S_BITS_24 0x0080
114#define OXYGEN_I2S_FORMAT_32 0x00c0 116#define OXYGEN_I2S_BITS_32 0x00c0
115 117
116#define OXYGEN_I2S_A_FORMAT 0x62 118#define OXYGEN_I2S_A_FORMAT 0x62
117#define OXYGEN_I2S_B_FORMAT 0x64 119#define OXYGEN_I2S_B_FORMAT 0x64
118#define OXYGEN_I2S_C_FORMAT 0x66 120#define OXYGEN_I2S_C_FORMAT 0x66
119/* OXYGEN_I2S_RATE_* and OXYGEN_I2S_FORMAT_* */ 121/* like OXYGEN_I2S_MULTICH_FORMAT */
120 122
121#define OXYGEN_SPDIF_CONTROL 0x70 123#define OXYGEN_SPDIF_CONTROL 0x70
122#define OXYGEN_SPDIF_OUT_ENABLE 0x00000002 124#define OXYGEN_SPDIF_OUT_ENABLE 0x00000002
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index bea34f10d447..83c2c43e7b85 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -102,10 +102,6 @@ static void xonar_init(struct oxygen *chip)
102 102
103 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 0x8c); 103 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 0x8c);
104 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, 0x00, 0x8c); 104 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, 0x00, 0x8c);
105#if 0
106 oxygen_clear_bits16(chip, OXYGEN_I2S_MULTICH_FORMAT,
107 OXYGEN_I2S_MAGIC1_MASK);
108#endif
109 oxygen_ac97_set_bits(chip, 0, 0x62, 0x0080); 105 oxygen_ac97_set_bits(chip, 0, 0x62, 0x0080);
110 msleep(300); 106 msleep(300);
111 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 0x100); 107 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 0x100);
@@ -253,6 +249,8 @@ static const struct oxygen_model model_xonar = {
253 OXYGEN_CHANNEL_SPDIF | 249 OXYGEN_CHANNEL_SPDIF |
254 OXYGEN_CHANNEL_MULTICH, 250 OXYGEN_CHANNEL_MULTICH,
255 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5, 251 .function_flags = OXYGEN_FUNCTION_ENABLE_SPI_4_5,
252 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
253 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
256}; 254};
257 255
258static int __devinit xonar_probe(struct pci_dev *pci, 256static int __devinit xonar_probe(struct pci_dev *pci,