aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-04-16 03:13:36 -0400
committerTakashi Iwai <tiwai@suse.de>2008-04-24 06:00:36 -0400
commit193e813814775b1b1574515fc6f11e61b29a54f7 (patch)
tree4c910d3dd308aa13ddf10d8836dad3171f21ab4b /sound/pci/oxygen
parent0c0e6daf14183fb1cd0dea054ecf81165abbdc83 (diff)
[ALSA] oxygen: generalize handling of DAC volume limits
Add fields for the DAC volume limits to the module structure so that model drivers do not need to install their own control info handlers. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/oxygen')
-rw-r--r--sound/pci/oxygen/hifier.c2
-rw-r--r--sound/pci/oxygen/oxygen.c4
-rw-r--r--sound/pci/oxygen/oxygen.h2
-rw-r--r--sound/pci/oxygen/oxygen_lib.c2
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c4
-rw-r--r--sound/pci/oxygen/virtuoso.c31
6 files changed, 17 insertions, 28 deletions
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c
index b67888f6745b..bf39c72a130c 100644
--- a/sound/pci/oxygen/hifier.c
+++ b/sound/pci/oxygen/hifier.c
@@ -153,6 +153,8 @@ static const struct oxygen_model model_hifier = {
153 PLAYBACK_1_TO_SPDIF | 153 PLAYBACK_1_TO_SPDIF |
154 CAPTURE_0_FROM_I2S_1, 154 CAPTURE_0_FROM_I2S_1,
155 .dac_channels = 2, 155 .dac_channels = 2,
156 .dac_volume_min = 0,
157 .dac_volume_max = 255,
156 .function_flags = OXYGEN_FUNCTION_SPI, 158 .function_flags = OXYGEN_FUNCTION_SPI,
157 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 159 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
158 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 160 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index b3b7771b54c0..718169792c3b 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -278,6 +278,8 @@ static const struct oxygen_model model_generic = {
278 CAPTURE_1_FROM_SPDIF | 278 CAPTURE_1_FROM_SPDIF |
279 CAPTURE_2_FROM_AC97_1, 279 CAPTURE_2_FROM_AC97_1,
280 .dac_channels = 8, 280 .dac_channels = 8,
281 .dac_volume_min = 0,
282 .dac_volume_max = 255,
281 .function_flags = OXYGEN_FUNCTION_SPI | 283 .function_flags = OXYGEN_FUNCTION_SPI |
282 OXYGEN_FUNCTION_ENABLE_SPI_4_5, 284 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
283 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 285 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
@@ -303,6 +305,8 @@ static const struct oxygen_model model_meridian = {
303 CAPTURE_1_FROM_SPDIF | 305 CAPTURE_1_FROM_SPDIF |
304 CAPTURE_2_FROM_AC97_1, 306 CAPTURE_2_FROM_AC97_1,
305 .dac_channels = 8, 307 .dac_channels = 8,
308 .dac_volume_min = 0,
309 .dac_volume_max = 255,
306 .misc_flags = OXYGEN_MISC_MIDI, 310 .misc_flags = OXYGEN_MISC_MIDI,
307 .function_flags = OXYGEN_FUNCTION_SPI | 311 .function_flags = OXYGEN_FUNCTION_SPI |
308 OXYGEN_FUNCTION_ENABLE_SPI_4_5, 312 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index 7efbf54bc4ec..36f2f81fefc5 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -103,6 +103,8 @@ struct oxygen_model {
103 size_t model_data_size; 103 size_t model_data_size;
104 unsigned int pcm_dev_cfg; 104 unsigned int pcm_dev_cfg;
105 u8 dac_channels; 105 u8 dac_channels;
106 u8 dac_volume_min;
107 u8 dac_volume_max;
106 u8 misc_flags; 108 u8 misc_flags;
107 u8 function_flags; 109 u8 function_flags;
108 u16 dac_i2s_format; 110 u16 dac_i2s_format;
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 39e4b7a51740..b7aa9fcb6b81 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -221,7 +221,7 @@ static void oxygen_init(struct oxygen *chip)
221 221
222 chip->dac_routing = 1; 222 chip->dac_routing = 1;
223 for (i = 0; i < 8; ++i) 223 for (i = 0; i < 8; ++i)
224 chip->dac_volume[i] = 0xff; 224 chip->dac_volume[i] = chip->model->dac_volume_max;
225 chip->spdif_playback_enable = 1; 225 chip->spdif_playback_enable = 1;
226 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL | 226 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL |
227 (IEC958_AES1_CON_PCM_CODER << OXYGEN_SPDIF_CATEGORY_SHIFT); 227 (IEC958_AES1_CON_PCM_CODER << OXYGEN_SPDIF_CATEGORY_SHIFT);
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index 2cb914498a19..056581ecd915 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -32,8 +32,8 @@ static int dac_volume_info(struct snd_kcontrol *ctl,
32 32
33 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 33 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
34 info->count = chip->model->dac_channels; 34 info->count = chip->model->dac_channels;
35 info->value.integer.min = 0; 35 info->value.integer.min = chip->model->dac_volume_min;
36 info->value.integer.max = 0xff; 36 info->value.integer.max = chip->model->dac_volume_max;
37 return 0; 37 return 0;
38} 38}
39 39
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 6f5c2531abd0..37f53a8c5888 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -219,10 +219,7 @@ static void xonar_d2x_init(struct oxygen *chip)
219static void xonar_dx_init(struct oxygen *chip) 219static void xonar_dx_init(struct oxygen *chip)
220{ 220{
221 struct xonar_data *data = chip->model_data; 221 struct xonar_data *data = chip->model_data;
222 unsigned int i;
223 222
224 for (i = 0; i < 8; ++i)
225 chip->dac_volume[i] = 127;
226 data->anti_pop_delay = 800; 223 data->anti_pop_delay = 800;
227 data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE; 224 data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE;
228 data->ext_power_reg = OXYGEN_GPI_DATA; 225 data->ext_power_reg = OXYGEN_GPI_DATA;
@@ -414,26 +411,6 @@ static void xonar_gpio_changed(struct oxygen *chip)
414 } 411 }
415} 412}
416 413
417static int pcm1796_volume_info(struct snd_kcontrol *ctl,
418 struct snd_ctl_elem_info *info)
419{
420 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
421 info->count = 8;
422 info->value.integer.min = 0x0f;
423 info->value.integer.max = 0xff;
424 return 0;
425}
426
427static int cs4362a_volume_info(struct snd_kcontrol *ctl,
428 struct snd_ctl_elem_info *info)
429{
430 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
431 info->count = 8;
432 info->value.integer.min = 0;
433 info->value.integer.max = 127;
434 return 0;
435}
436
437static int alt_switch_get(struct snd_kcontrol *ctl, 414static int alt_switch_get(struct snd_kcontrol *ctl,
438 struct snd_ctl_elem_value *value) 415 struct snd_ctl_elem_value *value)
439{ 416{
@@ -526,7 +503,6 @@ static int xonar_d2_control_filter(struct snd_kcontrol_new *template)
526{ 503{
527 if (!strcmp(template->name, "Master Playback Volume")) { 504 if (!strcmp(template->name, "Master Playback Volume")) {
528 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; 505 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
529 template->info = pcm1796_volume_info;
530 template->tlv.p = pcm1796_db_scale; 506 template->tlv.p = pcm1796_db_scale;
531 } else if (!strncmp(template->name, "CD Capture ", 11)) { 507 } else if (!strncmp(template->name, "CD Capture ", 11)) {
532 /* CD in is actually connected to the video in pin */ 508 /* CD in is actually connected to the video in pin */
@@ -539,7 +515,6 @@ static int xonar_dx_control_filter(struct snd_kcontrol_new *template)
539{ 515{
540 if (!strcmp(template->name, "Master Playback Volume")) { 516 if (!strcmp(template->name, "Master Playback Volume")) {
541 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; 517 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
542 template->info = cs4362a_volume_info;
543 template->tlv.p = cs4362a_db_scale; 518 template->tlv.p = cs4362a_db_scale;
544 } else if (!strncmp(template->name, "CD Capture ", 11)) { 519 } else if (!strncmp(template->name, "CD Capture ", 11)) {
545 return 1; /* no CD input */ 520 return 1; /* no CD input */
@@ -577,6 +552,8 @@ static const struct oxygen_model xonar_models[] = {
577 CAPTURE_0_FROM_I2S_2 | 552 CAPTURE_0_FROM_I2S_2 |
578 CAPTURE_1_FROM_SPDIF, 553 CAPTURE_1_FROM_SPDIF,
579 .dac_channels = 8, 554 .dac_channels = 8,
555 .dac_volume_min = 0x0f,
556 .dac_volume_max = 0xff,
580 .misc_flags = OXYGEN_MISC_MIDI, 557 .misc_flags = OXYGEN_MISC_MIDI,
581 .function_flags = OXYGEN_FUNCTION_SPI | 558 .function_flags = OXYGEN_FUNCTION_SPI |
582 OXYGEN_FUNCTION_ENABLE_SPI_4_5, 559 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
@@ -603,6 +580,8 @@ static const struct oxygen_model xonar_models[] = {
603 CAPTURE_0_FROM_I2S_2 | 580 CAPTURE_0_FROM_I2S_2 |
604 CAPTURE_1_FROM_SPDIF, 581 CAPTURE_1_FROM_SPDIF,
605 .dac_channels = 8, 582 .dac_channels = 8,
583 .dac_volume_min = 0x0f,
584 .dac_volume_max = 0xff,
606 .misc_flags = OXYGEN_MISC_MIDI, 585 .misc_flags = OXYGEN_MISC_MIDI,
607 .function_flags = OXYGEN_FUNCTION_SPI | 586 .function_flags = OXYGEN_FUNCTION_SPI |
608 OXYGEN_FUNCTION_ENABLE_SPI_4_5, 587 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
@@ -629,6 +608,8 @@ static const struct oxygen_model xonar_models[] = {
629 PLAYBACK_1_TO_SPDIF | 608 PLAYBACK_1_TO_SPDIF |
630 CAPTURE_0_FROM_I2S_2, 609 CAPTURE_0_FROM_I2S_2,
631 .dac_channels = 8, 610 .dac_channels = 8,
611 .dac_volume_min = 0,
612 .dac_volume_max = 127,
632 .function_flags = OXYGEN_FUNCTION_2WIRE, 613 .function_flags = OXYGEN_FUNCTION_2WIRE,
633 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 614 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
634 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 615 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,