aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_conexant.c
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2011-01-21 07:27:39 -0500
committerTakashi Iwai <tiwai@suse.de>2011-01-22 11:28:28 -0500
commit02b6b5b640e773eb4d4d0685fa6c1fbc660b2834 (patch)
tree5c3362d224c914361d7c00bd9422c9b230d955d3 /sound/pci/hda/patch_conexant.c
parent233d84c46c2253d13e10b42d88c14748fbb67a98 (diff)
ALSA: HDA: Refactor some redundant code for Conexant 5066/205xx
Four very similar procedures - one for each model - now refactored into one. This isn't all duplicated code, but a step in the right direction. Signed-off-by: David Henningsson <david.henningsson@canonical.com> 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.c81
1 files changed, 23 insertions, 58 deletions
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 9bb030a469cd..7cd59b9f0e97 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -2387,79 +2387,53 @@ static void cxt5066_hp_automute(struct hda_codec *codec)
2387 cxt5066_update_speaker(codec); 2387 cxt5066_update_speaker(codec);
2388} 2388}
2389 2389
2390/* unsolicited event for jack sensing */ 2390/* Dispatch the right mic autoswitch function */
2391static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) 2391static void cxt5066_automic(struct hda_codec *codec)
2392{ 2392{
2393 struct conexant_spec *spec = codec->spec; 2393 struct conexant_spec *spec = codec->spec;
2394 snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26);
2395 switch (res >> 26) {
2396 case CONEXANT_HP_EVENT:
2397 cxt5066_hp_automute(codec);
2398 break;
2399 case CONEXANT_MIC_EVENT:
2400 /* ignore mic events in DC mode; we're always using the jack */
2401 if (!spec->dc_enable)
2402 cxt5066_olpc_automic(codec);
2403 break;
2404 }
2405}
2406 2394
2407/* unsolicited event for jack sensing */ 2395 if (spec->dell_vostro)
2408static void cxt5066_vostro_event(struct hda_codec *codec, unsigned int res)
2409{
2410 snd_printdd("CXT5066_vostro: unsol event %x (%x)\n", res, res >> 26);
2411 switch (res >> 26) {
2412 case CONEXANT_HP_EVENT:
2413 cxt5066_hp_automute(codec);
2414 break;
2415 case CONEXANT_MIC_EVENT:
2416 cxt5066_vostro_automic(codec); 2396 cxt5066_vostro_automic(codec);
2417 break; 2397 else if (spec->ideapad)
2418 }
2419}
2420
2421/* unsolicited event for jack sensing */
2422static void cxt5066_ideapad_event(struct hda_codec *codec, unsigned int res)
2423{
2424 snd_printdd("CXT5066_ideapad: unsol event %x (%x)\n", res, res >> 26);
2425 switch (res >> 26) {
2426 case CONEXANT_HP_EVENT:
2427 cxt5066_hp_automute(codec);
2428 break;
2429 case CONEXANT_MIC_EVENT:
2430 cxt5066_ideapad_automic(codec); 2398 cxt5066_ideapad_automic(codec);
2431 break; 2399 else if (spec->thinkpad)
2432 } 2400 cxt5066_thinkpad_automic(codec);
2401 else if (spec->hp_laptop)
2402 cxt5066_hp_laptop_automic(codec);
2433} 2403}
2434 2404
2435/* unsolicited event for jack sensing */ 2405/* unsolicited event for jack sensing */
2436static void cxt5066_hp_laptop_event(struct hda_codec *codec, unsigned int res) 2406static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res)
2437{ 2407{
2438 snd_printdd("CXT5066_hp_laptop: unsol event %x (%x)\n", res, res >> 26); 2408 struct conexant_spec *spec = codec->spec;
2409 snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26);
2439 switch (res >> 26) { 2410 switch (res >> 26) {
2440 case CONEXANT_HP_EVENT: 2411 case CONEXANT_HP_EVENT:
2441 cxt5066_hp_automute(codec); 2412 cxt5066_hp_automute(codec);
2442 break; 2413 break;
2443 case CONEXANT_MIC_EVENT: 2414 case CONEXANT_MIC_EVENT:
2444 cxt5066_hp_laptop_automic(codec); 2415 /* ignore mic events in DC mode; we're always using the jack */
2416 if (!spec->dc_enable)
2417 cxt5066_olpc_automic(codec);
2445 break; 2418 break;
2446 } 2419 }
2447} 2420}
2448 2421
2449/* unsolicited event for jack sensing */ 2422/* unsolicited event for jack sensing */
2450static void cxt5066_thinkpad_event(struct hda_codec *codec, unsigned int res) 2423static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res)
2451{ 2424{
2452 snd_printdd("CXT5066_thinkpad: unsol event %x (%x)\n", res, res >> 26); 2425 snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26);
2453 switch (res >> 26) { 2426 switch (res >> 26) {
2454 case CONEXANT_HP_EVENT: 2427 case CONEXANT_HP_EVENT:
2455 cxt5066_hp_automute(codec); 2428 cxt5066_hp_automute(codec);
2456 break; 2429 break;
2457 case CONEXANT_MIC_EVENT: 2430 case CONEXANT_MIC_EVENT:
2458 cxt5066_thinkpad_automic(codec); 2431 cxt5066_automic(codec);
2459 break; 2432 break;
2460 } 2433 }
2461} 2434}
2462 2435
2436
2463static const struct hda_input_mux cxt5066_analog_mic_boost = { 2437static const struct hda_input_mux cxt5066_analog_mic_boost = {
2464 .num_items = 5, 2438 .num_items = 5,
2465 .items = { 2439 .items = {
@@ -3039,20 +3013,11 @@ static struct hda_verb cxt5066_init_verbs_hp_laptop[] = {
3039/* initialize jack-sensing, too */ 3013/* initialize jack-sensing, too */
3040static int cxt5066_init(struct hda_codec *codec) 3014static int cxt5066_init(struct hda_codec *codec)
3041{ 3015{
3042 struct conexant_spec *spec = codec->spec;
3043
3044 snd_printdd("CXT5066: init\n"); 3016 snd_printdd("CXT5066: init\n");
3045 conexant_init(codec); 3017 conexant_init(codec);
3046 if (codec->patch_ops.unsol_event) { 3018 if (codec->patch_ops.unsol_event) {
3047 cxt5066_hp_automute(codec); 3019 cxt5066_hp_automute(codec);
3048 if (spec->dell_vostro) 3020 cxt5066_automic(codec);
3049 cxt5066_vostro_automic(codec);
3050 else if (spec->ideapad)
3051 cxt5066_ideapad_automic(codec);
3052 else if (spec->thinkpad)
3053 cxt5066_thinkpad_automic(codec);
3054 else if (spec->hp_laptop)
3055 cxt5066_hp_laptop_automic(codec);
3056 } 3021 }
3057 cxt5066_set_mic_boost(codec); 3022 cxt5066_set_mic_boost(codec);
3058 return 0; 3023 return 0;
@@ -3169,7 +3134,7 @@ static int patch_cxt5066(struct hda_codec *codec)
3169 break; 3134 break;
3170 case CXT5066_HP_LAPTOP: 3135 case CXT5066_HP_LAPTOP:
3171 codec->patch_ops.init = cxt5066_init; 3136 codec->patch_ops.init = cxt5066_init;
3172 codec->patch_ops.unsol_event = cxt5066_hp_laptop_event; 3137 codec->patch_ops.unsol_event = cxt5066_unsol_event;
3173 spec->init_verbs[spec->num_init_verbs] = 3138 spec->init_verbs[spec->num_init_verbs] =
3174 cxt5066_init_verbs_hp_laptop; 3139 cxt5066_init_verbs_hp_laptop;
3175 spec->num_init_verbs++; 3140 spec->num_init_verbs++;
@@ -3207,7 +3172,7 @@ static int patch_cxt5066(struct hda_codec *codec)
3207 break; 3172 break;
3208 case CXT5066_DELL_VOSTRO: 3173 case CXT5066_DELL_VOSTRO:
3209 codec->patch_ops.init = cxt5066_init; 3174 codec->patch_ops.init = cxt5066_init;
3210 codec->patch_ops.unsol_event = cxt5066_vostro_event; 3175 codec->patch_ops.unsol_event = cxt5066_unsol_event;
3211 spec->init_verbs[0] = cxt5066_init_verbs_vostro; 3176 spec->init_verbs[0] = cxt5066_init_verbs_vostro;
3212 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 3177 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
3213 spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3178 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
@@ -3224,7 +3189,7 @@ static int patch_cxt5066(struct hda_codec *codec)
3224 break; 3189 break;
3225 case CXT5066_IDEAPAD: 3190 case CXT5066_IDEAPAD:
3226 codec->patch_ops.init = cxt5066_init; 3191 codec->patch_ops.init = cxt5066_init;
3227 codec->patch_ops.unsol_event = cxt5066_ideapad_event; 3192 codec->patch_ops.unsol_event = cxt5066_unsol_event;
3228 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 3193 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
3229 spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3194 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3230 spec->init_verbs[0] = cxt5066_init_verbs_ideapad; 3195 spec->init_verbs[0] = cxt5066_init_verbs_ideapad;
@@ -3240,7 +3205,7 @@ static int patch_cxt5066(struct hda_codec *codec)
3240 break; 3205 break;
3241 case CXT5066_THINKPAD: 3206 case CXT5066_THINKPAD:
3242 codec->patch_ops.init = cxt5066_init; 3207 codec->patch_ops.init = cxt5066_init;
3243 codec->patch_ops.unsol_event = cxt5066_thinkpad_event; 3208 codec->patch_ops.unsol_event = cxt5066_unsol_event;
3244 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; 3209 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
3245 spec->mixers[spec->num_mixers++] = cxt5066_mixers; 3210 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3246 spec->init_verbs[0] = cxt5066_init_verbs_thinkpad; 3211 spec->init_verbs[0] = cxt5066_init_verbs_thinkpad;