diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 05:06:29 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:17:21 -0500 |
commit | d2a6d7dc757da6b57d77bd8b460cf4faa9fd152d (patch) | |
tree | b3edf27437b4be8ee23917b852d8e93376ac62da /sound/pci/hda/patch_realtek.c | |
parent | 59de641ca37b88dd34d0e1d853800b488f642624 (diff) |
[ALSA] hda-codec - Add channel-mode helper
Modules: HDA Codec driver,HDA generic driver
Add common channel-mode helper functions for all codec patches.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 67 |
1 files changed, 16 insertions, 51 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index cffb83fdcff7..a213c19ab06c 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -109,7 +109,7 @@ struct alc_spec { | |||
109 | unsigned int cur_mux[3]; | 109 | unsigned int cur_mux[3]; |
110 | 110 | ||
111 | /* channel model */ | 111 | /* channel model */ |
112 | const struct alc_channel_mode *channel_mode; | 112 | const struct hda_channel_mode *channel_mode; |
113 | int num_channel_mode; | 113 | int num_channel_mode; |
114 | 114 | ||
115 | /* PCM information */ | 115 | /* PCM information */ |
@@ -157,63 +157,28 @@ static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon | |||
157 | /* | 157 | /* |
158 | * channel mode setting | 158 | * channel mode setting |
159 | */ | 159 | */ |
160 | struct alc_channel_mode { | ||
161 | int channels; | ||
162 | const struct hda_verb *sequence; | ||
163 | }; | ||
164 | |||
165 | static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) | 160 | static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) |
166 | { | 161 | { |
167 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 162 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
168 | struct alc_spec *spec = codec->spec; | 163 | struct alc_spec *spec = codec->spec; |
169 | int items = kcontrol->private_value ? (int)kcontrol->private_value : 2; | 164 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
170 | 165 | spec->num_channel_mode); | |
171 | snd_assert(spec->channel_mode, return -ENXIO); | ||
172 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
173 | uinfo->count = 1; | ||
174 | uinfo->value.enumerated.items = items; | ||
175 | if (uinfo->value.enumerated.item >= items) | ||
176 | uinfo->value.enumerated.item = items - 1; | ||
177 | sprintf(uinfo->value.enumerated.name, "%dch", | ||
178 | spec->channel_mode[uinfo->value.enumerated.item].channels); | ||
179 | return 0; | ||
180 | } | 166 | } |
181 | 167 | ||
182 | static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | 168 | static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
183 | { | 169 | { |
184 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 170 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
185 | struct alc_spec *spec = codec->spec; | 171 | struct alc_spec *spec = codec->spec; |
186 | int items = kcontrol->private_value ? (int)kcontrol->private_value : 2; | 172 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
187 | int i; | 173 | spec->num_channel_mode, spec->multiout.max_channels); |
188 | |||
189 | snd_assert(spec->channel_mode, return -ENXIO); | ||
190 | for (i = 0; i < items; i++) { | ||
191 | if (spec->multiout.max_channels == spec->channel_mode[i].channels) { | ||
192 | ucontrol->value.enumerated.item[0] = i; | ||
193 | break; | ||
194 | } | ||
195 | } | ||
196 | return 0; | ||
197 | } | 174 | } |
198 | 175 | ||
199 | static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) | 176 | static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) |
200 | { | 177 | { |
201 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 178 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
202 | struct alc_spec *spec = codec->spec; | 179 | struct alc_spec *spec = codec->spec; |
203 | int mode; | 180 | return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
204 | 181 | spec->num_channel_mode, &spec->multiout.max_channels); | |
205 | snd_assert(spec->channel_mode, return -ENXIO); | ||
206 | mode = ucontrol->value.enumerated.item[0] ? 1 : 0; | ||
207 | if (spec->multiout.max_channels == spec->channel_mode[mode].channels && | ||
208 | ! codec->in_resume) | ||
209 | return 0; | ||
210 | |||
211 | /* change the current channel setting */ | ||
212 | spec->multiout.max_channels = spec->channel_mode[mode].channels; | ||
213 | if (spec->channel_mode[mode].sequence) | ||
214 | snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence); | ||
215 | |||
216 | return 1; | ||
217 | } | 182 | } |
218 | 183 | ||
219 | 184 | ||
@@ -328,7 +293,7 @@ static struct hda_verb alc880_threestack_ch6_init[] = { | |||
328 | { } /* end */ | 293 | { } /* end */ |
329 | }; | 294 | }; |
330 | 295 | ||
331 | static struct alc_channel_mode alc880_threestack_modes[2] = { | 296 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
332 | { 2, alc880_threestack_ch2_init }, | 297 | { 2, alc880_threestack_ch2_init }, |
333 | { 6, alc880_threestack_ch6_init }, | 298 | { 6, alc880_threestack_ch6_init }, |
334 | }; | 299 | }; |
@@ -443,7 +408,7 @@ static struct hda_verb alc880_fivestack_ch8_init[] = { | |||
443 | { } /* end */ | 408 | { } /* end */ |
444 | }; | 409 | }; |
445 | 410 | ||
446 | static struct alc_channel_mode alc880_fivestack_modes[2] = { | 411 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
447 | { 6, alc880_fivestack_ch6_init }, | 412 | { 6, alc880_fivestack_ch6_init }, |
448 | { 8, alc880_fivestack_ch8_init }, | 413 | { 8, alc880_fivestack_ch8_init }, |
449 | }; | 414 | }; |
@@ -473,7 +438,7 @@ static struct hda_input_mux alc880_6stack_capture_source = { | |||
473 | }; | 438 | }; |
474 | 439 | ||
475 | /* fixed 8-channels */ | 440 | /* fixed 8-channels */ |
476 | static struct alc_channel_mode alc880_sixstack_modes[1] = { | 441 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
477 | { 8, NULL }, | 442 | { 8, NULL }, |
478 | }; | 443 | }; |
479 | 444 | ||
@@ -540,7 +505,7 @@ static hda_nid_t alc880_w810_dac_nids[3] = { | |||
540 | }; | 505 | }; |
541 | 506 | ||
542 | /* fixed 6 channels */ | 507 | /* fixed 6 channels */ |
543 | static struct alc_channel_mode alc880_w810_modes[1] = { | 508 | static struct hda_channel_mode alc880_w810_modes[1] = { |
544 | { 6, NULL } | 509 | { 6, NULL } |
545 | }; | 510 | }; |
546 | 511 | ||
@@ -572,7 +537,7 @@ static hda_nid_t alc880_z71v_dac_nids[1] = { | |||
572 | #define ALC880_Z71V_HP_DAC 0x03 | 537 | #define ALC880_Z71V_HP_DAC 0x03 |
573 | 538 | ||
574 | /* fixed 2 channels */ | 539 | /* fixed 2 channels */ |
575 | static struct alc_channel_mode alc880_2_jack_modes[1] = { | 540 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
576 | { 2, NULL } | 541 | { 2, NULL } |
577 | }; | 542 | }; |
578 | 543 | ||
@@ -1227,7 +1192,7 @@ static struct hda_input_mux alc880_test_capture_source = { | |||
1227 | }, | 1192 | }, |
1228 | }; | 1193 | }; |
1229 | 1194 | ||
1230 | static struct alc_channel_mode alc880_test_modes[4] = { | 1195 | static struct hda_channel_mode alc880_test_modes[4] = { |
1231 | { 2, NULL }, | 1196 | { 2, NULL }, |
1232 | { 4, NULL }, | 1197 | { 4, NULL }, |
1233 | { 6, NULL }, | 1198 | { 6, NULL }, |
@@ -1585,7 +1550,7 @@ struct alc_config_preset { | |||
1585 | unsigned int num_adc_nids; | 1550 | unsigned int num_adc_nids; |
1586 | hda_nid_t *adc_nids; | 1551 | hda_nid_t *adc_nids; |
1587 | unsigned int num_channel_mode; | 1552 | unsigned int num_channel_mode; |
1588 | const struct alc_channel_mode *channel_mode; | 1553 | const struct hda_channel_mode *channel_mode; |
1589 | const struct hda_input_mux *input_mux; | 1554 | const struct hda_input_mux *input_mux; |
1590 | }; | 1555 | }; |
1591 | 1556 | ||
@@ -2202,7 +2167,7 @@ static struct hda_input_mux alc260_fujitsu_capture_source = { | |||
2202 | * element which allows changing the channel mode, so the verb list is | 2167 | * element which allows changing the channel mode, so the verb list is |
2203 | * never used. | 2168 | * never used. |
2204 | */ | 2169 | */ |
2205 | static struct alc_channel_mode alc260_modes[1] = { | 2170 | static struct hda_channel_mode alc260_modes[1] = { |
2206 | { 2, NULL }, | 2171 | { 2, NULL }, |
2207 | }; | 2172 | }; |
2208 | 2173 | ||
@@ -2506,7 +2471,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
2506 | * driver yet). | 2471 | * driver yet). |
2507 | */ | 2472 | */ |
2508 | 2473 | ||
2509 | static struct alc_channel_mode alc882_ch_modes[1] = { | 2474 | static struct hda_channel_mode alc882_ch_modes[1] = { |
2510 | { 8, NULL } | 2475 | { 8, NULL } |
2511 | }; | 2476 | }; |
2512 | 2477 | ||