@@ -515,6 +515,15 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
515
515
}
516
516
}
517
517
518
+ /* get a primary headphone pin if available */
519
+ static hda_nid_t alc_get_hp_pin (struct alc_spec * spec )
520
+ {
521
+ if (spec -> gen .autocfg .hp_pins [0 ])
522
+ return spec -> gen .autocfg .hp_pins [0 ];
523
+ if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
524
+ return spec -> gen .autocfg .line_out_pins [0 ];
525
+ return 0 ;
526
+ }
518
527
519
528
/*
520
529
* Realtek SSID verification
@@ -725,9 +734,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
725
734
* 15 : 1 --> enable the function "Mute internal speaker
726
735
* when the external headphone out jack is plugged"
727
736
*/
728
- if (!spec -> gen .autocfg .hp_pins [0 ] &&
729
- !(spec -> gen .autocfg .line_out_pins [0 ] &&
730
- spec -> gen .autocfg .line_out_type == AUTO_PIN_HP_OUT )) {
737
+ if (!alc_get_hp_pin (spec )) {
731
738
hda_nid_t nid ;
732
739
tmp = (ass >> 11 ) & 0x3 ; /* HP to chassis */
733
740
nid = ports [tmp ];
@@ -2959,15 +2966,10 @@ static void alc282_restore_default_value(struct hda_codec *codec)
2959
2966
static void alc282_init (struct hda_codec * codec )
2960
2967
{
2961
2968
struct alc_spec * spec = codec -> spec ;
2962
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
2969
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
2963
2970
bool hp_pin_sense ;
2964
2971
int coef78 ;
2965
2972
2966
- if (!spec -> gen .autocfg .hp_outs && spec -> gen .suppress_auto_mute ) {
2967
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
2968
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
2969
- }
2970
-
2971
2973
alc282_restore_default_value (codec );
2972
2974
2973
2975
if (!hp_pin )
@@ -3001,15 +3003,10 @@ static void alc282_init(struct hda_codec *codec)
3001
3003
static void alc282_shutup (struct hda_codec * codec )
3002
3004
{
3003
3005
struct alc_spec * spec = codec -> spec ;
3004
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
3006
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
3005
3007
bool hp_pin_sense ;
3006
3008
int coef78 ;
3007
3009
3008
- if (!spec -> gen .autocfg .hp_outs && spec -> gen .suppress_auto_mute ) {
3009
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
3010
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
3011
- }
3012
-
3013
3010
if (!hp_pin ) {
3014
3011
alc269_shutup (codec );
3015
3012
return ;
@@ -3084,14 +3081,9 @@ static void alc283_restore_default_value(struct hda_codec *codec)
3084
3081
static void alc283_init (struct hda_codec * codec )
3085
3082
{
3086
3083
struct alc_spec * spec = codec -> spec ;
3087
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
3084
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
3088
3085
bool hp_pin_sense ;
3089
3086
3090
- if (!spec -> gen .autocfg .hp_outs ) {
3091
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
3092
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
3093
- }
3094
-
3095
3087
alc283_restore_default_value (codec );
3096
3088
3097
3089
if (!hp_pin )
@@ -3125,14 +3117,9 @@ static void alc283_init(struct hda_codec *codec)
3125
3117
static void alc283_shutup (struct hda_codec * codec )
3126
3118
{
3127
3119
struct alc_spec * spec = codec -> spec ;
3128
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
3120
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
3129
3121
bool hp_pin_sense ;
3130
3122
3131
- if (!spec -> gen .autocfg .hp_outs ) {
3132
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
3133
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
3134
- }
3135
-
3136
3123
if (!hp_pin ) {
3137
3124
alc269_shutup (codec );
3138
3125
return ;
@@ -3166,14 +3153,9 @@ static void alc283_shutup(struct hda_codec *codec)
3166
3153
static void alc256_init (struct hda_codec * codec )
3167
3154
{
3168
3155
struct alc_spec * spec = codec -> spec ;
3169
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
3156
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
3170
3157
bool hp_pin_sense ;
3171
3158
3172
- if (!spec -> gen .autocfg .hp_outs && spec -> gen .suppress_auto_mute ) {
3173
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
3174
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
3175
- }
3176
-
3177
3159
if (!hp_pin )
3178
3160
return ;
3179
3161
@@ -3207,14 +3189,9 @@ static void alc256_init(struct hda_codec *codec)
3207
3189
static void alc256_shutup (struct hda_codec * codec )
3208
3190
{
3209
3191
struct alc_spec * spec = codec -> spec ;
3210
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
3192
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
3211
3193
bool hp_pin_sense ;
3212
3194
3213
- if (!spec -> gen .autocfg .hp_outs && spec -> gen .suppress_auto_mute ) {
3214
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
3215
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
3216
- }
3217
-
3218
3195
if (!hp_pin ) {
3219
3196
alc269_shutup (codec );
3220
3197
return ;
@@ -3248,14 +3225,9 @@ static void alc256_shutup(struct hda_codec *codec)
3248
3225
static void alc225_init (struct hda_codec * codec )
3249
3226
{
3250
3227
struct alc_spec * spec = codec -> spec ;
3251
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
3228
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
3252
3229
bool hp1_pin_sense , hp2_pin_sense ;
3253
3230
3254
- if (!spec -> gen .autocfg .hp_outs && spec -> gen .suppress_auto_mute ) {
3255
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
3256
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
3257
- }
3258
-
3259
3231
if (!hp_pin )
3260
3232
return ;
3261
3233
@@ -3296,14 +3268,9 @@ static void alc225_init(struct hda_codec *codec)
3296
3268
static void alc225_shutup (struct hda_codec * codec )
3297
3269
{
3298
3270
struct alc_spec * spec = codec -> spec ;
3299
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
3271
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
3300
3272
bool hp1_pin_sense , hp2_pin_sense ;
3301
3273
3302
- if (!spec -> gen .autocfg .hp_outs && spec -> gen .suppress_auto_mute ) {
3303
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
3304
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
3305
- }
3306
-
3307
3274
if (!hp_pin ) {
3308
3275
alc269_shutup (codec );
3309
3276
return ;
@@ -3345,14 +3312,9 @@ static void alc225_shutup(struct hda_codec *codec)
3345
3312
static void alc_default_init (struct hda_codec * codec )
3346
3313
{
3347
3314
struct alc_spec * spec = codec -> spec ;
3348
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
3315
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
3349
3316
bool hp_pin_sense ;
3350
3317
3351
- if (!spec -> gen .autocfg .hp_outs && spec -> gen .suppress_auto_mute ) {
3352
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
3353
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
3354
- }
3355
-
3356
3318
if (!hp_pin )
3357
3319
return ;
3358
3320
@@ -3379,14 +3341,9 @@ static void alc_default_init(struct hda_codec *codec)
3379
3341
static void alc_default_shutup (struct hda_codec * codec )
3380
3342
{
3381
3343
struct alc_spec * spec = codec -> spec ;
3382
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
3344
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
3383
3345
bool hp_pin_sense ;
3384
3346
3385
- if (!spec -> gen .autocfg .hp_outs && spec -> gen .suppress_auto_mute ) {
3386
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
3387
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
3388
- }
3389
-
3390
3347
if (!hp_pin ) {
3391
3348
alc269_shutup (codec );
3392
3349
return ;
@@ -3416,14 +3373,9 @@ static void alc_default_shutup(struct hda_codec *codec)
3416
3373
static void alc294_hp_init (struct hda_codec * codec )
3417
3374
{
3418
3375
struct alc_spec * spec = codec -> spec ;
3419
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
3376
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
3420
3377
int i , val ;
3421
3378
3422
- if (!spec -> gen .autocfg .hp_outs && spec -> gen .suppress_auto_mute ) {
3423
- if (spec -> gen .autocfg .line_out_type == AC_JACK_HP_OUT )
3424
- hp_pin = spec -> gen .autocfg .line_out_pins [0 ];
3425
- }
3426
-
3427
3379
if (!hp_pin )
3428
3380
return ;
3429
3381
@@ -4825,7 +4777,7 @@ static void alc_update_headset_mode(struct hda_codec *codec)
4825
4777
struct alc_spec * spec = codec -> spec ;
4826
4778
4827
4779
hda_nid_t mux_pin = spec -> gen .imux_pins [spec -> gen .cur_mux [0 ]];
4828
- hda_nid_t hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
4780
+ hda_nid_t hp_pin = alc_get_hp_pin ( spec ) ;
4829
4781
4830
4782
int new_headset_mode ;
4831
4783
@@ -5104,7 +5056,7 @@ static void alc_fixup_tpt470_dock(struct hda_codec *codec,
5104
5056
static void alc_shutup_dell_xps13 (struct hda_codec * codec )
5105
5057
{
5106
5058
struct alc_spec * spec = codec -> spec ;
5107
- int hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
5059
+ int hp_pin = alc_get_hp_pin ( spec ) ;
5108
5060
5109
5061
/* Prevent pop noises when headphones are plugged in */
5110
5062
snd_hda_codec_write (codec , hp_pin , 0 ,
@@ -5197,7 +5149,7 @@ static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
5197
5149
5198
5150
if (action == HDA_FIXUP_ACT_PROBE ) {
5199
5151
int mic_pin = find_ext_mic_pin (codec );
5200
- int hp_pin = spec -> gen . autocfg . hp_pins [ 0 ] ;
5152
+ int hp_pin = alc_get_hp_pin ( spec ) ;
5201
5153
5202
5154
if (snd_BUG_ON (!mic_pin || !hp_pin ))
5203
5155
return ;
0 commit comments