aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-04-16 03:15:45 -0400
committerTakashi Iwai <tiwai@suse.de>2008-04-24 06:00:37 -0400
commit4972a177fed34036498aee555335f84a70219bc1 (patch)
tree343c9beb57407db5111d88de2c9c97498bc91777 /sound
parente983532e446ac7fabe829d9e3aeff8e26b0a277d (diff)
[ALSA] oxygen: generalize DAC volume TLV handling
Add a pointer for DAC volume TLV data to the model structure so that the model driver do not need to manually assign it in their control filter. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/oxygen/hifier.c7
-rw-r--r--sound/pci/oxygen/oxygen.c13
-rw-r--r--sound/pci/oxygen/oxygen.h1
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c5
-rw-r--r--sound/pci/oxygen/virtuoso.c15
5 files changed, 15 insertions, 26 deletions
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c
index dec9073d6ed1..090dd4354a28 100644
--- a/sound/pci/oxygen/hifier.c
+++ b/sound/pci/oxygen/hifier.c
@@ -127,12 +127,8 @@ static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
127 127
128static int hifier_control_filter(struct snd_kcontrol_new *template) 128static int hifier_control_filter(struct snd_kcontrol_new *template)
129{ 129{
130 if (!strcmp(template->name, "Master Playback Volume")) { 130 if (!strcmp(template->name, "Stereo Upmixing"))
131 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
132 template->tlv.p = ak4396_db_scale;
133 } else if (!strcmp(template->name, "Stereo Upmixing")) {
134 return 1; /* stereo only - we don't need upmixing */ 131 return 1; /* stereo only - we don't need upmixing */
135 }
136 return 0; 132 return 0;
137} 133}
138 134
@@ -148,6 +144,7 @@ static const struct oxygen_model model_hifier = {
148 .set_adc_params = set_cs5340_params, 144 .set_adc_params = set_cs5340_params,
149 .update_dac_volume = update_ak4396_volume, 145 .update_dac_volume = update_ak4396_volume,
150 .update_dac_mute = update_ak4396_mute, 146 .update_dac_mute = update_ak4396_mute,
147 .dac_tlv = ak4396_db_scale,
151 .model_data_size = sizeof(struct hifier_data), 148 .model_data_size = sizeof(struct hifier_data),
152 .pcm_dev_cfg = PLAYBACK_0_TO_I2S | 149 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
153 PLAYBACK_1_TO_SPDIF | 150 PLAYBACK_1_TO_SPDIF |
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index 636315612c32..63f185c1ed1e 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -249,27 +249,18 @@ static void set_ak5385_params(struct oxygen *chip,
249 249
250static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); 250static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);
251 251
252static int ak4396_control_filter(struct snd_kcontrol_new *template)
253{
254 if (!strcmp(template->name, "Master Playback Volume")) {
255 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
256 template->tlv.p = ak4396_db_scale;
257 }
258 return 0;
259}
260
261static const struct oxygen_model model_generic = { 252static const struct oxygen_model model_generic = {
262 .shortname = "C-Media CMI8788", 253 .shortname = "C-Media CMI8788",
263 .longname = "C-Media Oxygen HD Audio", 254 .longname = "C-Media Oxygen HD Audio",
264 .chip = "CMI8788", 255 .chip = "CMI8788",
265 .owner = THIS_MODULE, 256 .owner = THIS_MODULE,
266 .init = generic_init, 257 .init = generic_init,
267 .control_filter = ak4396_control_filter,
268 .cleanup = generic_cleanup, 258 .cleanup = generic_cleanup,
269 .set_dac_params = set_ak4396_params, 259 .set_dac_params = set_ak4396_params,
270 .set_adc_params = set_wm8785_params, 260 .set_adc_params = set_wm8785_params,
271 .update_dac_volume = update_ak4396_volume, 261 .update_dac_volume = update_ak4396_volume,
272 .update_dac_mute = update_ak4396_mute, 262 .update_dac_mute = update_ak4396_mute,
263 .dac_tlv = ak4396_db_scale,
273 .model_data_size = sizeof(struct generic_data), 264 .model_data_size = sizeof(struct generic_data),
274 .pcm_dev_cfg = PLAYBACK_0_TO_I2S | 265 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
275 PLAYBACK_1_TO_SPDIF | 266 PLAYBACK_1_TO_SPDIF |
@@ -291,12 +282,12 @@ static const struct oxygen_model model_meridian = {
291 .chip = "CMI8788", 282 .chip = "CMI8788",
292 .owner = THIS_MODULE, 283 .owner = THIS_MODULE,
293 .init = meridian_init, 284 .init = meridian_init,
294 .control_filter = ak4396_control_filter,
295 .cleanup = generic_cleanup, 285 .cleanup = generic_cleanup,
296 .set_dac_params = set_ak4396_params, 286 .set_dac_params = set_ak4396_params,
297 .set_adc_params = set_ak5385_params, 287 .set_adc_params = set_ak5385_params,
298 .update_dac_volume = update_ak4396_volume, 288 .update_dac_volume = update_ak4396_volume,
299 .update_dac_mute = update_ak4396_mute, 289 .update_dac_mute = update_ak4396_mute,
290 .dac_tlv = ak4396_db_scale,
300 .model_data_size = sizeof(struct generic_data), 291 .model_data_size = sizeof(struct generic_data),
301 .pcm_dev_cfg = PLAYBACK_0_TO_I2S | 292 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
302 PLAYBACK_1_TO_SPDIF | 293 PLAYBACK_1_TO_SPDIF |
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index 36f2f81fefc5..a71c6e059260 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -100,6 +100,7 @@ struct oxygen_model {
100 void (*gpio_changed)(struct oxygen *chip); 100 void (*gpio_changed)(struct oxygen *chip);
101 void (*ac97_switch)(struct oxygen *chip, 101 void (*ac97_switch)(struct oxygen *chip,
102 unsigned int reg, unsigned int mute); 102 unsigned int reg, unsigned int mute);
103 const unsigned int *dac_tlv;
103 size_t model_data_size; 104 size_t model_data_size;
104 unsigned int pcm_dev_cfg; 105 unsigned int pcm_dev_cfg;
105 u8 dac_channels; 106 u8 dac_channels;
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index 056581ecd915..cc0cddadd589 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -941,6 +941,11 @@ static int add_controls(struct oxygen *chip,
941 return err; 941 return err;
942 if (err == 1) 942 if (err == 1)
943 continue; 943 continue;
944 if (!strcmp(template.name, "Master Playback Volume") &&
945 chip->model->dac_tlv) {
946 template.tlv.p = chip->model->dac_tlv;
947 template.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
948 }
944 ctl = snd_ctl_new1(&template, chip); 949 ctl = snd_ctl_new1(&template, chip);
945 if (!ctl) 950 if (!ctl)
946 return -ENOMEM; 951 return -ENOMEM;
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index fe4e289840b4..7f84fa5deca2 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -502,24 +502,16 @@ static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -12700, 100, 0);
502 502
503static int xonar_d2_control_filter(struct snd_kcontrol_new *template) 503static int xonar_d2_control_filter(struct snd_kcontrol_new *template)
504{ 504{
505 if (!strcmp(template->name, "Master Playback Volume")) { 505 if (!strncmp(template->name, "CD Capture ", 11))
506 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
507 template->tlv.p = pcm1796_db_scale;
508 } else if (!strncmp(template->name, "CD Capture ", 11)) {
509 /* CD in is actually connected to the video in pin */ 506 /* CD in is actually connected to the video in pin */
510 template->private_value ^= AC97_CD ^ AC97_VIDEO; 507 template->private_value ^= AC97_CD ^ AC97_VIDEO;
511 }
512 return 0; 508 return 0;
513} 509}
514 510
515static int xonar_dx_control_filter(struct snd_kcontrol_new *template) 511static int xonar_dx_control_filter(struct snd_kcontrol_new *template)
516{ 512{
517 if (!strcmp(template->name, "Master Playback Volume")) { 513 if (!strncmp(template->name, "CD Capture ", 11))
518 template->access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
519 template->tlv.p = cs4362a_db_scale;
520 } else if (!strncmp(template->name, "CD Capture ", 11)) {
521 return 1; /* no CD input */ 514 return 1; /* no CD input */
522 }
523 return 0; 515 return 0;
524} 516}
525 517
@@ -547,6 +539,7 @@ static const struct oxygen_model xonar_models[] = {
547 .set_adc_params = set_cs53x1_params, 539 .set_adc_params = set_cs53x1_params,
548 .update_dac_volume = update_pcm1796_volume, 540 .update_dac_volume = update_pcm1796_volume,
549 .update_dac_mute = update_pcm1796_mute, 541 .update_dac_mute = update_pcm1796_mute,
542 .dac_tlv = pcm1796_db_scale,
550 .model_data_size = sizeof(struct xonar_data), 543 .model_data_size = sizeof(struct xonar_data),
551 .pcm_dev_cfg = PLAYBACK_0_TO_I2S | 544 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
552 PLAYBACK_1_TO_SPDIF | 545 PLAYBACK_1_TO_SPDIF |
@@ -575,6 +568,7 @@ static const struct oxygen_model xonar_models[] = {
575 .update_dac_volume = update_pcm1796_volume, 568 .update_dac_volume = update_pcm1796_volume,
576 .update_dac_mute = update_pcm1796_mute, 569 .update_dac_mute = update_pcm1796_mute,
577 .gpio_changed = xonar_gpio_changed, 570 .gpio_changed = xonar_gpio_changed,
571 .dac_tlv = pcm1796_db_scale,
578 .model_data_size = sizeof(struct xonar_data), 572 .model_data_size = sizeof(struct xonar_data),
579 .pcm_dev_cfg = PLAYBACK_0_TO_I2S | 573 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
580 PLAYBACK_1_TO_SPDIF | 574 PLAYBACK_1_TO_SPDIF |
@@ -604,6 +598,7 @@ static const struct oxygen_model xonar_models[] = {
604 .update_dac_mute = update_cs43xx_mute, 598 .update_dac_mute = update_cs43xx_mute,
605 .gpio_changed = xonar_gpio_changed, 599 .gpio_changed = xonar_gpio_changed,
606 .ac97_switch = xonar_dx_ac97_switch, 600 .ac97_switch = xonar_dx_ac97_switch,
601 .dac_tlv = cs4362a_db_scale,
607 .model_data_size = sizeof(struct xonar_data), 602 .model_data_size = sizeof(struct xonar_data),
608 .pcm_dev_cfg = PLAYBACK_0_TO_I2S | 603 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
609 PLAYBACK_1_TO_SPDIF | 604 PLAYBACK_1_TO_SPDIF |