diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-03-10 10:35:35 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-03-10 10:35:35 -0400 |
commit | df481e41b963b7fc3d7e3543a0c7bb140a682146 (patch) | |
tree | 767dcab589573a3d4c77df49b858990f73dd79a4 /sound/pci/hda/patch_conexant.c | |
parent | 5b3a7440cbabdda07cfb3dcf4a07e0115a3dff9a (diff) |
ALSA: hda - Clean up Cxt5047 parser
Clean up Conexant 5047 pareser code:
- Split mixer elements to separate arrays to reduce the duplicated
entires
- Fix mixer element names to the standard ones
- Remove unneeded cxt5047_hp2_unsol_event; the normal unsol_event
handler works fine.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_conexant.c')
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 89 |
1 files changed, 19 insertions, 70 deletions
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 71822140294d..d60ccb5bb127 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -1218,20 +1218,6 @@ static void cxt5047_hp_automute(struct hda_codec *codec) | |||
1218 | HDA_AMP_MUTE, bits); | 1218 | HDA_AMP_MUTE, bits); |
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | /* mute internal speaker if HP is plugged */ | ||
1222 | static void cxt5047_hp2_automute(struct hda_codec *codec) | ||
1223 | { | ||
1224 | struct conexant_spec *spec = codec->spec; | ||
1225 | unsigned int bits; | ||
1226 | |||
1227 | spec->hp_present = snd_hda_codec_read(codec, 0x13, 0, | ||
1228 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1229 | |||
1230 | bits = spec->hp_present ? HDA_AMP_MUTE : 0; | ||
1231 | snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0, | ||
1232 | HDA_AMP_MUTE, bits); | ||
1233 | } | ||
1234 | |||
1235 | /* toggle input of built-in and mic jack appropriately */ | 1221 | /* toggle input of built-in and mic jack appropriately */ |
1236 | static void cxt5047_hp_automic(struct hda_codec *codec) | 1222 | static void cxt5047_hp_automic(struct hda_codec *codec) |
1237 | { | 1223 | { |
@@ -1269,47 +1255,14 @@ static void cxt5047_hp_unsol_event(struct hda_codec *codec, | |||
1269 | } | 1255 | } |
1270 | } | 1256 | } |
1271 | 1257 | ||
1272 | /* unsolicited event for HP jack sensing - non-EAPD systems */ | 1258 | static struct snd_kcontrol_new cxt5047_base_mixers[] = { |
1273 | static void cxt5047_hp2_unsol_event(struct hda_codec *codec, | 1259 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT), |
1274 | unsigned int res) | 1260 | HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT), |
1275 | { | 1261 | HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT), |
1276 | res >>= 26; | ||
1277 | switch (res) { | ||
1278 | case CONEXANT_HP_EVENT: | ||
1279 | cxt5047_hp2_automute(codec); | ||
1280 | break; | ||
1281 | case CONEXANT_MIC_EVENT: | ||
1282 | cxt5047_hp_automic(codec); | ||
1283 | break; | ||
1284 | } | ||
1285 | } | ||
1286 | |||
1287 | static struct snd_kcontrol_new cxt5047_mixers[] = { | ||
1288 | HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), | ||
1289 | HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT), | ||
1290 | HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT), | ||
1291 | HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT), | ||
1292 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), | 1262 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), |
1293 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), | 1263 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), |
1294 | HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), | 1264 | HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), |
1295 | HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), | 1265 | HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), |
1296 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT), | ||
1297 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT), | ||
1298 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), | ||
1299 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT), | ||
1300 | |||
1301 | {} | ||
1302 | }; | ||
1303 | |||
1304 | static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = { | ||
1305 | HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), | ||
1306 | HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT), | ||
1307 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), | ||
1308 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), | ||
1309 | HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), | ||
1310 | HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), | ||
1311 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), | ||
1312 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT), | ||
1313 | { | 1266 | { |
1314 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1267 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
1315 | .name = "Master Playback Switch", | 1268 | .name = "Master Playback Switch", |
@@ -1322,22 +1275,14 @@ static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = { | |||
1322 | {} | 1275 | {} |
1323 | }; | 1276 | }; |
1324 | 1277 | ||
1325 | static struct snd_kcontrol_new cxt5047_hp_mixers[] = { | 1278 | static struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = { |
1326 | HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), | 1279 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT), |
1327 | HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT), | 1280 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
1328 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), | 1281 | {} |
1329 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), | 1282 | }; |
1330 | HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), | 1283 | |
1331 | HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), | 1284 | static struct snd_kcontrol_new cxt5047_hp_only_mixers[] = { |
1332 | HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), | 1285 | HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), |
1333 | { | ||
1334 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1335 | .name = "Master Playback Switch", | ||
1336 | .info = cxt_eapd_info, | ||
1337 | .get = cxt_eapd_get, | ||
1338 | .put = cxt5047_hp_master_sw_put, | ||
1339 | .private_value = 0x13, | ||
1340 | }, | ||
1341 | { } /* end */ | 1286 | { } /* end */ |
1342 | }; | 1287 | }; |
1343 | 1288 | ||
@@ -1559,7 +1504,7 @@ static int patch_cxt5047(struct hda_codec *codec) | |||
1559 | spec->adc_nids = cxt5047_adc_nids; | 1504 | spec->adc_nids = cxt5047_adc_nids; |
1560 | spec->capsrc_nids = cxt5047_capsrc_nids; | 1505 | spec->capsrc_nids = cxt5047_capsrc_nids; |
1561 | spec->num_mixers = 1; | 1506 | spec->num_mixers = 1; |
1562 | spec->mixers[0] = cxt5047_mixers; | 1507 | spec->mixers[0] = cxt5047_base_mixers; |
1563 | spec->num_init_verbs = 1; | 1508 | spec->num_init_verbs = 1; |
1564 | spec->init_verbs[0] = cxt5047_init_verbs; | 1509 | spec->init_verbs[0] = cxt5047_init_verbs; |
1565 | spec->spdif_route = 0; | 1510 | spec->spdif_route = 0; |
@@ -1573,18 +1518,22 @@ static int patch_cxt5047(struct hda_codec *codec) | |||
1573 | cxt5047_cfg_tbl); | 1518 | cxt5047_cfg_tbl); |
1574 | switch (board_config) { | 1519 | switch (board_config) { |
1575 | case CXT5047_LAPTOP: | 1520 | case CXT5047_LAPTOP: |
1576 | codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event; | 1521 | spec->num_mixers = 2; |
1522 | spec->mixers[1] = cxt5047_hp_spk_mixers; | ||
1523 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; | ||
1577 | break; | 1524 | break; |
1578 | case CXT5047_LAPTOP_HP: | 1525 | case CXT5047_LAPTOP_HP: |
1579 | spec->mixers[0] = cxt5047_hp_mixers; | 1526 | spec->num_mixers = 2; |
1527 | spec->mixers[1] = cxt5047_hp_only_mixers; | ||
1580 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; | 1528 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
1581 | codec->patch_ops.init = cxt5047_hp_init; | 1529 | codec->patch_ops.init = cxt5047_hp_init; |
1582 | break; | 1530 | break; |
1583 | case CXT5047_LAPTOP_EAPD: | 1531 | case CXT5047_LAPTOP_EAPD: |
1584 | spec->input_mux = &cxt5047_toshiba_capture_source; | 1532 | spec->input_mux = &cxt5047_toshiba_capture_source; |
1533 | spec->num_mixers = 2; | ||
1534 | spec->mixers[1] = cxt5047_hp_spk_mixers; | ||
1585 | spec->num_init_verbs = 2; | 1535 | spec->num_init_verbs = 2; |
1586 | spec->init_verbs[1] = cxt5047_toshiba_init_verbs; | 1536 | spec->init_verbs[1] = cxt5047_toshiba_init_verbs; |
1587 | spec->mixers[0] = cxt5047_toshiba_mixers; | ||
1588 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; | 1537 | codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; |
1589 | break; | 1538 | break; |
1590 | #ifdef CONFIG_SND_DEBUG | 1539 | #ifdef CONFIG_SND_DEBUG |