~ubuntu-branches/ubuntu/trusty/linux-linaro-omap/trusty

« back to all changes in this revision

Viewing changes to sound/pci/hda/patch_realtek.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-57i0gl3v99b3lkfg
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
299
299
 
300
300
struct alc_fixup;
301
301
 
 
302
struct alc_multi_io {
 
303
        hda_nid_t pin;          /* multi-io widget pin NID */
 
304
        hda_nid_t dac;          /* DAC to be connected */
 
305
        unsigned int ctl_in;    /* cached input-pin control value */
 
306
};
 
307
 
 
308
enum {
 
309
        ALC_AUTOMUTE_PIN,       /* change the pin control */
 
310
        ALC_AUTOMUTE_AMP,       /* mute/unmute the pin AMP */
 
311
        ALC_AUTOMUTE_MIXER,     /* mute/unmute mixer widget AMP */
 
312
};
 
313
 
302
314
struct alc_spec {
303
315
        /* codec parameterization */
304
 
        struct snd_kcontrol_new *mixers[5];     /* mixer arrays */
 
316
        const struct snd_kcontrol_new *mixers[5];       /* mixer arrays */
305
317
        unsigned int num_mixers;
306
 
        struct snd_kcontrol_new *cap_mixer;     /* capture mixer */
 
318
        const struct snd_kcontrol_new *cap_mixer;       /* capture mixer */
307
319
        unsigned int beep_amp;  /* beep amp value, set via set_beep_amp() */
308
320
 
309
321
        const struct hda_verb *init_verbs[10];  /* initialization verbs
313
325
        unsigned int num_init_verbs;
314
326
 
315
327
        char stream_name_analog[32];    /* analog PCM stream */
316
 
        struct hda_pcm_stream *stream_analog_playback;
317
 
        struct hda_pcm_stream *stream_analog_capture;
318
 
        struct hda_pcm_stream *stream_analog_alt_playback;
319
 
        struct hda_pcm_stream *stream_analog_alt_capture;
 
328
        const struct hda_pcm_stream *stream_analog_playback;
 
329
        const struct hda_pcm_stream *stream_analog_capture;
 
330
        const struct hda_pcm_stream *stream_analog_alt_playback;
 
331
        const struct hda_pcm_stream *stream_analog_alt_capture;
320
332
 
321
333
        char stream_name_digital[32];   /* digital PCM stream */
322
 
        struct hda_pcm_stream *stream_digital_playback;
323
 
        struct hda_pcm_stream *stream_digital_capture;
 
334
        const struct hda_pcm_stream *stream_digital_playback;
 
335
        const struct hda_pcm_stream *stream_digital_capture;
324
336
 
325
337
        /* playback */
326
338
        struct hda_multi_out multiout;  /* playback set-up
333
345
 
334
346
        /* capture */
335
347
        unsigned int num_adc_nids;
336
 
        hda_nid_t *adc_nids;
337
 
        hda_nid_t *capsrc_nids;
 
348
        const hda_nid_t *adc_nids;
 
349
        const hda_nid_t *capsrc_nids;
338
350
        hda_nid_t dig_in_nid;           /* digital-in NID; optional */
339
351
 
340
352
        /* capture setup for dynamic dual-adc switch */
348
360
        const struct hda_input_mux *input_mux;
349
361
        unsigned int cur_mux[3];
350
362
        struct alc_mic_route ext_mic;
 
363
        struct alc_mic_route dock_mic;
351
364
        struct alc_mic_route int_mic;
352
365
 
353
366
        /* channel model */
375
388
#ifdef CONFIG_SND_HDA_POWER_SAVE
376
389
        void (*power_hook)(struct hda_codec *codec);
377
390
#endif
 
391
        void (*shutup)(struct hda_codec *codec);
378
392
 
379
393
        /* for pin sensing */
380
 
        unsigned int sense_updated: 1;
381
394
        unsigned int jack_present: 1;
382
 
        unsigned int master_sw: 1;
 
395
        unsigned int line_jack_present:1;
 
396
        unsigned int master_mute:1;
383
397
        unsigned int auto_mic:1;
 
398
        unsigned int automute:1;        /* HP automute enabled */
 
399
        unsigned int detect_line:1;     /* Line-out detection enabled */
 
400
        unsigned int automute_lines:1;  /* automute line-out as well */
 
401
        unsigned int automute_hp_lo:1;  /* both HP and LO available */
384
402
 
385
403
        /* other flags */
386
404
        unsigned int no_analog :1; /* digital I/O only */
387
405
        unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
388
406
        unsigned int single_input_src:1;
 
407
 
 
408
        /* auto-mute control */
 
409
        int automute_mode;
 
410
        hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS];
 
411
 
389
412
        int init_amp;
390
413
        int codec_variant;      /* flag for other variants */
391
414
 
403
426
        int fixup_id;
404
427
        const struct alc_fixup *fixup_list;
405
428
        const char *fixup_name;
 
429
 
 
430
        /* multi-io */
 
431
        int multi_ios;
 
432
        struct alc_multi_io multi_io[4];
406
433
};
407
434
 
408
435
/*
409
436
 * configuration template - to be copied to the spec instance
410
437
 */
411
438
struct alc_config_preset {
412
 
        struct snd_kcontrol_new *mixers[5]; /* should be identical size
 
439
        const struct snd_kcontrol_new *mixers[5]; /* should be identical size
413
440
                                             * with spec
414
441
                                             */
415
 
        struct snd_kcontrol_new *cap_mixer; /* capture mixer */
 
442
        const struct snd_kcontrol_new *cap_mixer; /* capture mixer */
416
443
        const struct hda_verb *init_verbs[5];
417
444
        unsigned int num_dacs;
418
 
        hda_nid_t *dac_nids;
 
445
        const hda_nid_t *dac_nids;
419
446
        hda_nid_t dig_out_nid;          /* optional */
420
447
        hda_nid_t hp_nid;               /* optional */
421
 
        hda_nid_t *slave_dig_outs;
 
448
        const hda_nid_t *slave_dig_outs;
422
449
        unsigned int num_adc_nids;
423
 
        hda_nid_t *adc_nids;
424
 
        hda_nid_t *capsrc_nids;
 
450
        const hda_nid_t *adc_nids;
 
451
        const hda_nid_t *capsrc_nids;
425
452
        hda_nid_t dig_in_nid;
426
453
        unsigned int num_channel_mode;
427
454
        const struct hda_channel_mode *channel_mode;
433
460
        void (*setup)(struct hda_codec *);
434
461
        void (*init_hook)(struct hda_codec *);
435
462
#ifdef CONFIG_SND_HDA_POWER_SAVE
436
 
        struct hda_amp_list *loopbacks;
 
463
        const struct hda_amp_list *loopbacks;
437
464
        void (*power_hook)(struct hda_codec *codec);
438
465
#endif
439
466
};
560
587
 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
561
588
 * March 2006.
562
589
 */
563
 
static char *alc_pin_mode_names[] = {
 
590
static const char * const alc_pin_mode_names[] = {
564
591
        "Mic 50pc bias", "Mic 80pc bias",
565
592
        "Line in", "Line out", "Headphone out",
566
593
};
567
 
static unsigned char alc_pin_mode_values[] = {
 
594
static const unsigned char alc_pin_mode_values[] = {
568
595
        PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
569
596
};
570
597
/* The control can present all 5 options, or it can limit the options based
583
610
/* Info about the pin modes supported by the different pin direction modes.
584
611
 * For each direction the minimum and maximum values are given.
585
612
 */
586
 
static signed char alc_pin_mode_dir_info[5][2] = {
 
613
static const signed char alc_pin_mode_dir_info[5][2] = {
587
614
        { 0, 2 },    /* ALC_PIN_DIR_IN */
588
615
        { 3, 4 },    /* ALC_PIN_DIR_OUT */
589
616
        { 0, 4 },    /* ALC_PIN_DIR_INOUT */
900
927
 
901
928
/*
902
929
 */
903
 
static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
 
930
static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
904
931
{
905
932
        if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
906
933
                return;
971
998
}
972
999
 
973
1000
/* Enable GPIO mask and set output */
974
 
static struct hda_verb alc_gpio1_init_verbs[] = {
 
1001
static const struct hda_verb alc_gpio1_init_verbs[] = {
975
1002
        {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
976
1003
        {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
977
1004
        {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
978
1005
        { }
979
1006
};
980
1007
 
981
 
static struct hda_verb alc_gpio2_init_verbs[] = {
 
1008
static const struct hda_verb alc_gpio2_init_verbs[] = {
982
1009
        {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
983
1010
        {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
984
1011
        {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
985
1012
        { }
986
1013
};
987
1014
 
988
 
static struct hda_verb alc_gpio3_init_verbs[] = {
 
1015
static const struct hda_verb alc_gpio3_init_verbs[] = {
989
1016
        {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
990
1017
        {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
991
1018
        {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
1031
1058
        int err;
1032
1059
        unsigned int hp_nid = spec->autocfg.hp_pins[0];
1033
1060
        unsigned int mic_nid = spec->ext_mic.pin;
 
1061
        unsigned int dock_nid = spec->dock_mic.pin;
1034
1062
 
1035
1063
        if (hp_nid) {
1036
1064
                err = snd_hda_input_jack_add(codec, hp_nid,
1047
1075
                        return err;
1048
1076
                snd_hda_input_jack_report(codec, mic_nid);
1049
1077
        }
 
1078
        if (dock_nid) {
 
1079
                err = snd_hda_input_jack_add(codec, dock_nid,
 
1080
                                             SND_JACK_MICROPHONE, NULL);
 
1081
                if (err < 0)
 
1082
                        return err;
 
1083
                snd_hda_input_jack_report(codec, dock_nid);
 
1084
        }
1050
1085
#endif /* CONFIG_SND_HDA_INPUT_JACK */
1051
1086
        return 0;
1052
1087
}
1053
1088
 
1054
 
static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
 
1089
static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
1055
1090
{
1056
 
        struct alc_spec *spec = codec->spec;
1057
 
        unsigned int mute;
1058
 
        hda_nid_t nid;
1059
 
        int i;
 
1091
        int i, present = 0;
1060
1092
 
1061
 
        spec->jack_present = 0;
1062
 
        for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1063
 
                nid = spec->autocfg.hp_pins[i];
 
1093
        for (i = 0; i < num_pins; i++) {
 
1094
                hda_nid_t nid = pins[i];
1064
1095
                if (!nid)
1065
1096
                        break;
1066
1097
                snd_hda_input_jack_report(codec, nid);
1067
 
                spec->jack_present |= snd_hda_jack_detect(codec, nid);
 
1098
                present |= snd_hda_jack_detect(codec, nid);
1068
1099
        }
1069
 
 
1070
 
        mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1071
 
        /* Toggle internal speakers muting */
1072
 
        for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1073
 
                nid = spec->autocfg.speaker_pins[i];
 
1100
        return present;
 
1101
}
 
1102
 
 
1103
static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
 
1104
                        bool mute, bool hp_out)
 
1105
{
 
1106
        struct alc_spec *spec = codec->spec;
 
1107
        unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0;
 
1108
        unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT);
 
1109
        int i;
 
1110
 
 
1111
        for (i = 0; i < num_pins; i++) {
 
1112
                hda_nid_t nid = pins[i];
1074
1113
                if (!nid)
1075
1114
                        break;
1076
 
                if (pinctl) {
 
1115
                switch (spec->automute_mode) {
 
1116
                case ALC_AUTOMUTE_PIN:
1077
1117
                        snd_hda_codec_write(codec, nid, 0,
1078
 
                                    AC_VERB_SET_PIN_WIDGET_CONTROL,
1079
 
                                    spec->jack_present ? 0 : PIN_OUT);
1080
 
                } else {
 
1118
                                            AC_VERB_SET_PIN_WIDGET_CONTROL,
 
1119
                                            pin_bits);
 
1120
                        break;
 
1121
                case ALC_AUTOMUTE_AMP:
1081
1122
                        snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1082
 
                                         HDA_AMP_MUTE, mute);
 
1123
                                                 HDA_AMP_MUTE, mute_bits);
 
1124
                        break;
 
1125
                case ALC_AUTOMUTE_MIXER:
 
1126
                        nid = spec->automute_mixer_nid[i];
 
1127
                        if (!nid)
 
1128
                                break;
 
1129
                        snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
 
1130
                                                 HDA_AMP_MUTE, mute_bits);
 
1131
                        snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1,
 
1132
                                                 HDA_AMP_MUTE, mute_bits);
 
1133
                        break;
1083
1134
                }
1084
1135
        }
1085
1136
}
1086
1137
 
1087
 
static void alc_automute_pin(struct hda_codec *codec)
1088
 
{
1089
 
        alc_automute_speaker(codec, 1);
 
1138
/* Toggle internal speakers muting */
 
1139
static void update_speakers(struct hda_codec *codec)
 
1140
{
 
1141
        struct alc_spec *spec = codec->spec;
 
1142
        int on;
 
1143
 
 
1144
        /* Control HP pins/amps depending on master_mute state;
 
1145
         * in general, HP pins/amps control should be enabled in all cases,
 
1146
         * but currently set only for master_mute, just to be safe
 
1147
         */
 
1148
        do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
 
1149
                    spec->autocfg.hp_pins, spec->master_mute, true);
 
1150
 
 
1151
        if (!spec->automute)
 
1152
                on = 0;
 
1153
        else
 
1154
                on = spec->jack_present | spec->line_jack_present;
 
1155
        on |= spec->master_mute;
 
1156
        do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins),
 
1157
                    spec->autocfg.speaker_pins, on, false);
 
1158
 
 
1159
        /* toggle line-out mutes if needed, too */
 
1160
        /* if LO is a copy of either HP or Speaker, don't need to handle it */
 
1161
        if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] ||
 
1162
            spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0])
 
1163
                return;
 
1164
        if (!spec->automute_lines || !spec->automute)
 
1165
                on = 0;
 
1166
        else
 
1167
                on = spec->jack_present;
 
1168
        on |= spec->master_mute;
 
1169
        do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
 
1170
                    spec->autocfg.line_out_pins, on, false);
 
1171
}
 
1172
 
 
1173
static void alc_hp_automute(struct hda_codec *codec)
 
1174
{
 
1175
        struct alc_spec *spec = codec->spec;
 
1176
 
 
1177
        if (!spec->automute)
 
1178
                return;
 
1179
        spec->jack_present =
 
1180
                detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
 
1181
                             spec->autocfg.hp_pins);
 
1182
        update_speakers(codec);
 
1183
}
 
1184
 
 
1185
static void alc_line_automute(struct hda_codec *codec)
 
1186
{
 
1187
        struct alc_spec *spec = codec->spec;
 
1188
 
 
1189
        if (!spec->automute || !spec->detect_line)
 
1190
                return;
 
1191
        spec->line_jack_present =
 
1192
                detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
 
1193
                             spec->autocfg.line_out_pins);
 
1194
        update_speakers(codec);
1090
1195
}
1091
1196
 
1092
1197
static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1128
1233
static void alc_mic_automute(struct hda_codec *codec)
1129
1234
{
1130
1235
        struct alc_spec *spec = codec->spec;
1131
 
        struct alc_mic_route *dead, *alive;
 
1236
        struct alc_mic_route *dead1, *dead2, *alive;
1132
1237
        unsigned int present, type;
1133
1238
        hda_nid_t cap_nid;
1134
1239
 
1146
1251
 
1147
1252
        cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1148
1253
 
 
1254
        alive = &spec->int_mic;
 
1255
        dead1 = &spec->ext_mic;
 
1256
        dead2 = &spec->dock_mic;
 
1257
 
1149
1258
        present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1150
1259
        if (present) {
1151
1260
                alive = &spec->ext_mic;
1152
 
                dead = &spec->int_mic;
1153
 
        } else {
1154
 
                alive = &spec->int_mic;
1155
 
                dead = &spec->ext_mic;
 
1261
                dead1 = &spec->int_mic;
 
1262
                dead2 = &spec->dock_mic;
 
1263
        }
 
1264
        if (!present && spec->dock_mic.pin > 0) {
 
1265
                present = snd_hda_jack_detect(codec, spec->dock_mic.pin);
 
1266
                if (present) {
 
1267
                        alive = &spec->dock_mic;
 
1268
                        dead1 = &spec->int_mic;
 
1269
                        dead2 = &spec->ext_mic;
 
1270
                }
 
1271
                snd_hda_input_jack_report(codec, spec->dock_mic.pin);
1156
1272
        }
1157
1273
 
1158
1274
        type = get_wcaps_type(get_wcaps(codec, cap_nid));
1161
1277
                snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1162
1278
                                         alive->mux_idx,
1163
1279
                                         HDA_AMP_MUTE, 0);
1164
 
                snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1165
 
                                         dead->mux_idx,
1166
 
                                         HDA_AMP_MUTE, HDA_AMP_MUTE);
 
1280
                if (dead1->pin > 0)
 
1281
                        snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
 
1282
                                                 dead1->mux_idx,
 
1283
                                                 HDA_AMP_MUTE, HDA_AMP_MUTE);
 
1284
                if (dead2->pin > 0)
 
1285
                        snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
 
1286
                                                 dead2->mux_idx,
 
1287
                                                 HDA_AMP_MUTE, HDA_AMP_MUTE);
1167
1288
        } else {
1168
1289
                /* MUX style (e.g. ALC880) */
1169
1290
                snd_hda_codec_write_cache(codec, cap_nid, 0,
1184
1305
                res >>= 26;
1185
1306
        switch (res) {
1186
1307
        case ALC880_HP_EVENT:
1187
 
                alc_automute_pin(codec);
 
1308
                alc_hp_automute(codec);
 
1309
                break;
 
1310
        case ALC880_FRONT_EVENT:
 
1311
                alc_line_automute(codec);
1188
1312
                break;
1189
1313
        case ALC880_MIC_EVENT:
1190
1314
                alc_mic_automute(codec);
1194
1318
 
1195
1319
static void alc_inithook(struct hda_codec *codec)
1196
1320
{
1197
 
        alc_automute_pin(codec);
 
1321
        alc_hp_automute(codec);
 
1322
        alc_line_automute(codec);
1198
1323
        alc_mic_automute(codec);
1199
1324
}
1200
1325
 
1236
1361
                                    on ? 2 : 0);
1237
1362
}
1238
1363
 
 
1364
/* turn on/off EAPD controls of the codec */
 
1365
static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
 
1366
{
 
1367
        /* We currently only handle front, HP */
 
1368
        switch (codec->vendor_id) {
 
1369
        case 0x10ec0260:
 
1370
                set_eapd(codec, 0x0f, on);
 
1371
                set_eapd(codec, 0x10, on);
 
1372
                break;
 
1373
        case 0x10ec0262:
 
1374
        case 0x10ec0267:
 
1375
        case 0x10ec0268:
 
1376
        case 0x10ec0269:
 
1377
        case 0x10ec0270:
 
1378
        case 0x10ec0272:
 
1379
        case 0x10ec0660:
 
1380
        case 0x10ec0662:
 
1381
        case 0x10ec0663:
 
1382
        case 0x10ec0665:
 
1383
        case 0x10ec0862:
 
1384
        case 0x10ec0889:
 
1385
        case 0x10ec0892:
 
1386
                set_eapd(codec, 0x14, on);
 
1387
                set_eapd(codec, 0x15, on);
 
1388
                break;
 
1389
        }
 
1390
}
 
1391
 
 
1392
/* generic shutup callback;
 
1393
 * just turning off EPAD and a little pause for avoiding pop-noise
 
1394
 */
 
1395
static void alc_eapd_shutup(struct hda_codec *codec)
 
1396
{
 
1397
        alc_auto_setup_eapd(codec, false);
 
1398
        msleep(200);
 
1399
}
 
1400
 
1239
1401
static void alc_auto_init_amp(struct hda_codec *codec, int type)
1240
1402
{
1241
1403
        unsigned int tmp;
1251
1413
                snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1252
1414
                break;
1253
1415
        case ALC_INIT_DEFAULT:
1254
 
                switch (codec->vendor_id) {
1255
 
                case 0x10ec0260:
1256
 
                        set_eapd(codec, 0x0f, 1);
1257
 
                        set_eapd(codec, 0x10, 1);
1258
 
                        break;
1259
 
                case 0x10ec0262:
1260
 
                case 0x10ec0267:
1261
 
                case 0x10ec0268:
1262
 
                case 0x10ec0269:
1263
 
                case 0x10ec0270:
1264
 
                case 0x10ec0272:
1265
 
                case 0x10ec0660:
1266
 
                case 0x10ec0662:
1267
 
                case 0x10ec0663:
1268
 
                case 0x10ec0665:
1269
 
                case 0x10ec0862:
1270
 
                case 0x10ec0889:
1271
 
                        set_eapd(codec, 0x14, 1);
1272
 
                        set_eapd(codec, 0x15, 1);
1273
 
                        break;
1274
 
                }
 
1416
                alc_auto_setup_eapd(codec, true);
1275
1417
                switch (codec->vendor_id) {
1276
1418
                case 0x10ec0260:
1277
1419
                        snd_hda_codec_write(codec, 0x1a, 0,
1315
1457
        }
1316
1458
}
1317
1459
 
 
1460
static int alc_automute_mode_info(struct snd_kcontrol *kcontrol,
 
1461
                                  struct snd_ctl_elem_info *uinfo)
 
1462
{
 
1463
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
 
1464
        struct alc_spec *spec = codec->spec;
 
1465
        static const char * const texts2[] = {
 
1466
                "Disabled", "Enabled"
 
1467
        };
 
1468
        static const char * const texts3[] = {
 
1469
                "Disabled", "Speaker Only", "Line-Out+Speaker"
 
1470
        };
 
1471
        const char * const *texts;
 
1472
 
 
1473
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
 
1474
        uinfo->count = 1;
 
1475
        if (spec->automute_hp_lo) {
 
1476
                uinfo->value.enumerated.items = 3;
 
1477
                texts = texts3;
 
1478
        } else {
 
1479
                uinfo->value.enumerated.items = 2;
 
1480
                texts = texts2;
 
1481
        }
 
1482
        if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
 
1483
                uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
 
1484
        strcpy(uinfo->value.enumerated.name,
 
1485
               texts[uinfo->value.enumerated.item]);
 
1486
        return 0;
 
1487
}
 
1488
 
 
1489
static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
 
1490
                                 struct snd_ctl_elem_value *ucontrol)
 
1491
{
 
1492
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
 
1493
        struct alc_spec *spec = codec->spec;
 
1494
        unsigned int val;
 
1495
        if (!spec->automute)
 
1496
                val = 0;
 
1497
        else if (!spec->automute_lines)
 
1498
                val = 1;
 
1499
        else
 
1500
                val = 2;
 
1501
        ucontrol->value.enumerated.item[0] = val;
 
1502
        return 0;
 
1503
}
 
1504
 
 
1505
static int alc_automute_mode_put(struct snd_kcontrol *kcontrol,
 
1506
                                 struct snd_ctl_elem_value *ucontrol)
 
1507
{
 
1508
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
 
1509
        struct alc_spec *spec = codec->spec;
 
1510
 
 
1511
        switch (ucontrol->value.enumerated.item[0]) {
 
1512
        case 0:
 
1513
                if (!spec->automute)
 
1514
                        return 0;
 
1515
                spec->automute = 0;
 
1516
                break;
 
1517
        case 1:
 
1518
                if (spec->automute && !spec->automute_lines)
 
1519
                        return 0;
 
1520
                spec->automute = 1;
 
1521
                spec->automute_lines = 0;
 
1522
                break;
 
1523
        case 2:
 
1524
                if (!spec->automute_hp_lo)
 
1525
                        return -EINVAL;
 
1526
                if (spec->automute && spec->automute_lines)
 
1527
                        return 0;
 
1528
                spec->automute = 1;
 
1529
                spec->automute_lines = 1;
 
1530
                break;
 
1531
        default:
 
1532
                return -EINVAL;
 
1533
        }
 
1534
        update_speakers(codec);
 
1535
        return 1;
 
1536
}
 
1537
 
 
1538
static const struct snd_kcontrol_new alc_automute_mode_enum = {
 
1539
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 
1540
        .name = "Auto-Mute Mode",
 
1541
        .info = alc_automute_mode_info,
 
1542
        .get = alc_automute_mode_get,
 
1543
        .put = alc_automute_mode_put,
 
1544
};
 
1545
 
 
1546
static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec);
 
1547
 
 
1548
static int alc_add_automute_mode_enum(struct hda_codec *codec)
 
1549
{
 
1550
        struct alc_spec *spec = codec->spec;
 
1551
        struct snd_kcontrol_new *knew;
 
1552
 
 
1553
        knew = alc_kcontrol_new(spec);
 
1554
        if (!knew)
 
1555
                return -ENOMEM;
 
1556
        *knew = alc_automute_mode_enum;
 
1557
        knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL);
 
1558
        if (!knew->name)
 
1559
                return -ENOMEM;
 
1560
        return 0;
 
1561
}
 
1562
 
1318
1563
static void alc_init_auto_hp(struct hda_codec *codec)
1319
1564
{
1320
1565
        struct alc_spec *spec = codec->spec;
1321
1566
        struct auto_pin_cfg *cfg = &spec->autocfg;
 
1567
        int present = 0;
1322
1568
        int i;
1323
1569
 
1324
 
        if (!cfg->hp_pins[0]) {
1325
 
                if (cfg->line_out_type != AUTO_PIN_HP_OUT)
1326
 
                        return;
1327
 
        }
 
1570
        if (cfg->hp_pins[0])
 
1571
                present++;
 
1572
        if (cfg->line_out_pins[0])
 
1573
                present++;
 
1574
        if (cfg->speaker_pins[0])
 
1575
                present++;
 
1576
        if (present < 2) /* need two different output types */
 
1577
                return;
 
1578
        if (present == 3)
 
1579
                spec->automute_hp_lo = 1; /* both HP and LO automute */
1328
1580
 
1329
 
        if (!cfg->speaker_pins[0]) {
1330
 
                if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1331
 
                        return;
 
1581
        if (!cfg->speaker_pins[0] &&
 
1582
            cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
1332
1583
                memcpy(cfg->speaker_pins, cfg->line_out_pins,
1333
1584
                       sizeof(cfg->speaker_pins));
1334
1585
                cfg->speaker_outs = cfg->line_outs;
1335
1586
        }
1336
1587
 
1337
 
        if (!cfg->hp_pins[0]) {
 
1588
        if (!cfg->hp_pins[0] &&
 
1589
            cfg->line_out_type == AUTO_PIN_HP_OUT) {
1338
1590
                memcpy(cfg->hp_pins, cfg->line_out_pins,
1339
1591
                       sizeof(cfg->hp_pins));
1340
1592
                cfg->hp_outs = cfg->line_outs;
1341
1593
        }
1342
1594
 
1343
1595
        for (i = 0; i < cfg->hp_outs; i++) {
 
1596
                hda_nid_t nid = cfg->hp_pins[i];
 
1597
                if (!is_jack_detectable(codec, nid))
 
1598
                        continue;
1344
1599
                snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1345
 
                            cfg->hp_pins[i]);
1346
 
                snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
 
1600
                            nid);
 
1601
                snd_hda_codec_write_cache(codec, nid, 0,
1347
1602
                                  AC_VERB_SET_UNSOLICITED_ENABLE,
1348
1603
                                  AC_USRSP_EN | ALC880_HP_EVENT);
1349
 
        }
1350
 
        spec->unsol_event = alc_sku_unsol_event;
 
1604
                spec->automute = 1;
 
1605
                spec->automute_mode = ALC_AUTOMUTE_PIN;
 
1606
        }
 
1607
        if (spec->automute && cfg->line_out_pins[0] &&
 
1608
            cfg->speaker_pins[0] &&
 
1609
            cfg->line_out_pins[0] != cfg->hp_pins[0] &&
 
1610
            cfg->line_out_pins[0] != cfg->speaker_pins[0]) {
 
1611
                for (i = 0; i < cfg->line_outs; i++) {
 
1612
                        hda_nid_t nid = cfg->line_out_pins[i];
 
1613
                        if (!is_jack_detectable(codec, nid))
 
1614
                                continue;
 
1615
                        snd_printdd("realtek: Enable Line-Out auto-muting "
 
1616
                                    "on NID 0x%x\n", nid);
 
1617
                        snd_hda_codec_write_cache(codec, nid, 0,
 
1618
                                        AC_VERB_SET_UNSOLICITED_ENABLE,
 
1619
                                        AC_USRSP_EN | ALC880_FRONT_EVENT);
 
1620
                        spec->detect_line = 1;
 
1621
                }
 
1622
                spec->automute_lines = spec->detect_line;
 
1623
        }
 
1624
 
 
1625
        if (spec->automute) {
 
1626
                /* create a control for automute mode */
 
1627
                alc_add_automute_mode_enum(codec);
 
1628
                spec->unsol_event = alc_sku_unsol_event;
 
1629
        }
1351
1630
}
1352
1631
 
1353
1632
static void alc_init_auto_mic(struct hda_codec *codec)
1354
1633
{
1355
1634
        struct alc_spec *spec = codec->spec;
1356
1635
        struct auto_pin_cfg *cfg = &spec->autocfg;
1357
 
        hda_nid_t fixed, ext;
 
1636
        hda_nid_t fixed, ext, dock;
1358
1637
        int i;
1359
1638
 
1360
 
        /* there must be only two mic inputs exclusively */
1361
 
        for (i = 0; i < cfg->num_inputs; i++)
1362
 
                if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
1363
 
                        return;
1364
 
 
1365
 
        fixed = ext = 0;
 
1639
        fixed = ext = dock = 0;
1366
1640
        for (i = 0; i < cfg->num_inputs; i++) {
1367
1641
                hda_nid_t nid = cfg->inputs[i].pin;
1368
1642
                unsigned int defcfg;
1371
1645
                case INPUT_PIN_ATTR_INT:
1372
1646
                        if (fixed)
1373
1647
                                return; /* already occupied */
 
1648
                        if (cfg->inputs[i].type != AUTO_PIN_MIC)
 
1649
                                return; /* invalid type */
1374
1650
                        fixed = nid;
1375
1651
                        break;
1376
1652
                case INPUT_PIN_ATTR_UNUSED:
1377
1653
                        return; /* invalid entry */
 
1654
                case INPUT_PIN_ATTR_DOCK:
 
1655
                        if (dock)
 
1656
                                return; /* already occupied */
 
1657
                        if (cfg->inputs[i].type > AUTO_PIN_LINE_IN)
 
1658
                                return; /* invalid type */
 
1659
                        dock = nid;
 
1660
                        break;
1378
1661
                default:
1379
1662
                        if (ext)
1380
1663
                                return; /* already occupied */
 
1664
                        if (cfg->inputs[i].type != AUTO_PIN_MIC)
 
1665
                                return; /* invalid type */
1381
1666
                        ext = nid;
1382
1667
                        break;
1383
1668
                }
1384
1669
        }
 
1670
        if (!ext && dock) {
 
1671
                ext = dock;
 
1672
                dock = 0;
 
1673
        }
1385
1674
        if (!ext || !fixed)
1386
1675
                return;
1387
 
        if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1388
 
                return; /* no unsol support */
1389
 
        snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1390
 
                    ext, fixed);
 
1676
        if (!is_jack_detectable(codec, ext))
 
1677
                return; /* no unsol support */
 
1678
        if (dock && !is_jack_detectable(codec, dock))
 
1679
                return; /* no unsol support */
 
1680
        snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
 
1681
                    ext, fixed, dock);
1391
1682
        spec->ext_mic.pin = ext;
 
1683
        spec->dock_mic.pin = dock;
1392
1684
        spec->int_mic.pin = fixed;
1393
1685
        spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
 
1686
        spec->dock_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1394
1687
        spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1395
1688
        spec->auto_mic = 1;
1396
1689
        snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1583
1876
                                return 1;
1584
1877
                spec->autocfg.hp_pins[0] = nid;
1585
1878
        }
1586
 
 
1587
 
        alc_init_auto_hp(codec);
1588
 
        alc_init_auto_mic(codec);
1589
1879
        return 1;
1590
1880
}
1591
1881
 
1598
1888
                snd_printd("realtek: "
1599
1889
                           "Enable default setup for auto mode as fallback\n");
1600
1890
                spec->init_amp = ALC_INIT_DEFAULT;
1601
 
                alc_init_auto_hp(codec);
1602
 
                alc_init_auto_mic(codec);
1603
1891
        }
 
1892
 
 
1893
        alc_init_auto_hp(codec);
 
1894
        alc_init_auto_mic(codec);
1604
1895
}
1605
1896
 
1606
1897
/*
1842
2133
/*
1843
2134
 * 2ch mode
1844
2135
 */
1845
 
static struct hda_verb alc888_4ST_ch2_intel_init[] = {
 
2136
static const struct hda_verb alc888_4ST_ch2_intel_init[] = {
1846
2137
/* Mic-in jack as mic in */
1847
2138
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1848
2139
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1857
2148
/*
1858
2149
 * 4ch mode
1859
2150
 */
1860
 
static struct hda_verb alc888_4ST_ch4_intel_init[] = {
 
2151
static const struct hda_verb alc888_4ST_ch4_intel_init[] = {
1861
2152
/* Mic-in jack as mic in */
1862
2153
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1863
2154
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1872
2163
/*
1873
2164
 * 6ch mode
1874
2165
 */
1875
 
static struct hda_verb alc888_4ST_ch6_intel_init[] = {
 
2166
static const struct hda_verb alc888_4ST_ch6_intel_init[] = {
1876
2167
/* Mic-in jack as CLFE */
1877
2168
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1878
2169
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1887
2178
/*
1888
2179
 * 8ch mode
1889
2180
 */
1890
 
static struct hda_verb alc888_4ST_ch8_intel_init[] = {
 
2181
static const struct hda_verb alc888_4ST_ch8_intel_init[] = {
1891
2182
/* Mic-in jack as CLFE */
1892
2183
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1893
2184
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1899
2190
        { } /* end */
1900
2191
};
1901
2192
 
1902
 
static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
 
2193
static const struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1903
2194
        { 2, alc888_4ST_ch2_intel_init },
1904
2195
        { 4, alc888_4ST_ch4_intel_init },
1905
2196
        { 6, alc888_4ST_ch6_intel_init },
1910
2201
 * ALC888 Fujitsu Siemens Amillo xa3530
1911
2202
 */
1912
2203
 
1913
 
static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
 
2204
static const struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1914
2205
/* Front Mic: set to PIN_IN (empty by default) */
1915
2206
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1916
2207
/* Connect Internal HP to Front */
1943
2234
        {}
1944
2235
};
1945
2236
 
1946
 
static void alc_automute_amp(struct hda_codec *codec)
1947
 
{
1948
 
        alc_automute_speaker(codec, 0);
1949
 
}
1950
 
 
1951
 
static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1952
 
                                         unsigned int res)
1953
 
{
1954
 
        if (codec->vendor_id == 0x10ec0880)
1955
 
                res >>= 28;
1956
 
        else
1957
 
                res >>= 26;
1958
 
        if (res == ALC880_HP_EVENT)
1959
 
                alc_automute_amp(codec);
1960
 
}
1961
 
 
1962
2237
static void alc889_automute_setup(struct hda_codec *codec)
1963
2238
{
1964
2239
        struct alc_spec *spec = codec->spec;
1969
2244
        spec->autocfg.speaker_pins[2] = 0x17;
1970
2245
        spec->autocfg.speaker_pins[3] = 0x19;
1971
2246
        spec->autocfg.speaker_pins[4] = 0x1a;
 
2247
        spec->automute = 1;
 
2248
        spec->automute_mode = ALC_AUTOMUTE_AMP;
1972
2249
}
1973
2250
 
1974
2251
static void alc889_intel_init_hook(struct hda_codec *codec)
1975
2252
{
1976
2253
        alc889_coef_init(codec);
1977
 
        alc_automute_amp(codec);
 
2254
        alc_hp_automute(codec);
1978
2255
}
1979
2256
 
1980
2257
static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1985
2262
        spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1986
2263
        spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1987
2264
        spec->autocfg.speaker_pins[1] = 0x15; /* bass */
 
2265
        spec->automute = 1;
 
2266
        spec->automute_mode = ALC_AUTOMUTE_AMP;
1988
2267
}
1989
2268
 
1990
2269
/*
1991
2270
 * ALC888 Acer Aspire 4930G model
1992
2271
 */
1993
2272
 
1994
 
static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
 
2273
static const struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1995
2274
/* Front Mic: set to PIN_IN (empty by default) */
1996
2275
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1997
2276
/* Unselect Front Mic by default in input mixer 3 */
2014
2293
 * ALC888 Acer Aspire 6530G model
2015
2294
 */
2016
2295
 
2017
 
static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
 
2296
static const struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
2018
2297
/* Route to built-in subwoofer as well as speakers */
2019
2298
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2020
2299
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2044
2323
 *ALC888 Acer Aspire 7730G model
2045
2324
 */
2046
2325
 
2047
 
static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
 
2326
static const struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2048
2327
/* Bias voltage on for external mic port */
2049
2328
        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2050
2329
/* Front Mic: set to PIN_IN (empty by default) */
2074
2353
 * ALC889 Acer Aspire 8930G model
2075
2354
 */
2076
2355
 
2077
 
static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
 
2356
static const struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
2078
2357
/* Front Mic: set to PIN_IN (empty by default) */
2079
2358
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2080
2359
/* Unselect Front Mic by default in input mixer 3 */
2120
2399
        { }
2121
2400
};
2122
2401
 
2123
 
static struct hda_input_mux alc888_2_capture_sources[2] = {
 
2402
static const struct hda_input_mux alc888_2_capture_sources[2] = {
2124
2403
        /* Front mic only available on one ADC */
2125
2404
        {
2126
2405
                .num_items = 4,
2141
2420
        }
2142
2421
};
2143
2422
 
2144
 
static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
 
2423
static const struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2145
2424
        /* Interal mic only available on one ADC */
2146
2425
        {
2147
2426
                .num_items = 5,
2164
2443
        }
2165
2444
};
2166
2445
 
2167
 
static struct hda_input_mux alc889_capture_sources[3] = {
 
2446
static const struct hda_input_mux alc889_capture_sources[3] = {
2168
2447
        /* Digital mic only available on first "ADC" */
2169
2448
        {
2170
2449
                .num_items = 5,
2196
2475
        }
2197
2476
};
2198
2477
 
2199
 
static struct snd_kcontrol_new alc888_base_mixer[] = {
 
2478
static const struct snd_kcontrol_new alc888_base_mixer[] = {
2200
2479
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2201
2480
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2202
2481
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2218
2497
        { } /* end */
2219
2498
};
2220
2499
 
2221
 
static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
 
2500
static const struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2222
2501
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2223
2502
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2224
2503
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2240
2519
        { } /* end */
2241
2520
};
2242
2521
 
2243
 
static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
 
2522
static const struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2244
2523
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2245
2524
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2246
2525
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2267
2546
        spec->autocfg.speaker_pins[0] = 0x14;
2268
2547
        spec->autocfg.speaker_pins[1] = 0x16;
2269
2548
        spec->autocfg.speaker_pins[2] = 0x17;
 
2549
        spec->automute = 1;
 
2550
        spec->automute_mode = ALC_AUTOMUTE_AMP;
2270
2551
}
2271
2552
 
2272
2553
static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
2277
2558
        spec->autocfg.speaker_pins[0] = 0x14;
2278
2559
        spec->autocfg.speaker_pins[1] = 0x16;
2279
2560
        spec->autocfg.speaker_pins[2] = 0x17;
 
2561
        spec->automute = 1;
 
2562
        spec->automute_mode = ALC_AUTOMUTE_AMP;
2280
2563
}
2281
2564
 
2282
2565
static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2287
2570
        spec->autocfg.speaker_pins[0] = 0x14;
2288
2571
        spec->autocfg.speaker_pins[1] = 0x16;
2289
2572
        spec->autocfg.speaker_pins[2] = 0x17;
 
2573
        spec->automute = 1;
 
2574
        spec->automute_mode = ALC_AUTOMUTE_AMP;
2290
2575
}
2291
2576
 
2292
2577
static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
2297
2582
        spec->autocfg.speaker_pins[0] = 0x14;
2298
2583
        spec->autocfg.speaker_pins[1] = 0x16;
2299
2584
        spec->autocfg.speaker_pins[2] = 0x1b;
 
2585
        spec->automute = 1;
 
2586
        spec->automute_mode = ALC_AUTOMUTE_AMP;
2300
2587
}
2301
2588
 
2302
2589
/*
2307
2594
 *                 F-Mic = 0x1b, HP = 0x19
2308
2595
 */
2309
2596
 
2310
 
static hda_nid_t alc880_dac_nids[4] = {
 
2597
static const hda_nid_t alc880_dac_nids[4] = {
2311
2598
        /* front, rear, clfe, rear_surr */
2312
2599
        0x02, 0x05, 0x04, 0x03
2313
2600
};
2314
2601
 
2315
 
static hda_nid_t alc880_adc_nids[3] = {
 
2602
static const hda_nid_t alc880_adc_nids[3] = {
2316
2603
        /* ADC0-2 */
2317
2604
        0x07, 0x08, 0x09,
2318
2605
};
2321
2608
 * but it shows zero connection in the real implementation on some devices.
2322
2609
 * Note: this is a 915GAV bug, fixed on 915GLV
2323
2610
 */
2324
 
static hda_nid_t alc880_adc_nids_alt[2] = {
 
2611
static const hda_nid_t alc880_adc_nids_alt[2] = {
2325
2612
        /* ADC1-2 */
2326
2613
        0x08, 0x09,
2327
2614
};
2329
2616
#define ALC880_DIGOUT_NID       0x06
2330
2617
#define ALC880_DIGIN_NID        0x0a
2331
2618
 
2332
 
static struct hda_input_mux alc880_capture_source = {
 
2619
static const struct hda_input_mux alc880_capture_source = {
2333
2620
        .num_items = 4,
2334
2621
        .items = {
2335
2622
                { "Mic", 0x0 },
2341
2628
 
2342
2629
/* channel source setting (2/6 channel selection for 3-stack) */
2343
2630
/* 2ch mode */
2344
 
static struct hda_verb alc880_threestack_ch2_init[] = {
 
2631
static const struct hda_verb alc880_threestack_ch2_init[] = {
2345
2632
        /* set line-in to input, mute it */
2346
2633
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2347
2634
        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2352
2639
};
2353
2640
 
2354
2641
/* 6ch mode */
2355
 
static struct hda_verb alc880_threestack_ch6_init[] = {
 
2642
static const struct hda_verb alc880_threestack_ch6_init[] = {
2356
2643
        /* set line-in to output, unmute it */
2357
2644
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2358
2645
        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2362
2649
        { } /* end */
2363
2650
};
2364
2651
 
2365
 
static struct hda_channel_mode alc880_threestack_modes[2] = {
 
2652
static const struct hda_channel_mode alc880_threestack_modes[2] = {
2366
2653
        { 2, alc880_threestack_ch2_init },
2367
2654
        { 6, alc880_threestack_ch6_init },
2368
2655
};
2369
2656
 
2370
 
static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
 
2657
static const struct snd_kcontrol_new alc880_three_stack_mixer[] = {
2371
2658
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2372
2659
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2373
2660
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2431
2718
 
2432
2719
static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2433
2720
                                 struct snd_ctl_elem_value *ucontrol,
2434
 
                                 getput_call_t func)
 
2721
                                 getput_call_t func, bool check_adc_switch)
2435
2722
{
2436
2723
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2437
2724
        struct alc_spec *spec = codec->spec;
2438
 
        unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2439
 
        int err;
 
2725
        int i, err = 0;
2440
2726
 
2441
2727
        mutex_lock(&codec->control_mutex);
2442
 
        kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2443
 
                                                      3, 0, HDA_INPUT);
2444
 
        err = func(kcontrol, ucontrol);
 
2728
        if (check_adc_switch && spec->dual_adc_switch) {
 
2729
                for (i = 0; i < spec->num_adc_nids; i++) {
 
2730
                        kcontrol->private_value =
 
2731
                                HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
 
2732
                                                    3, 0, HDA_INPUT);
 
2733
                        err = func(kcontrol, ucontrol);
 
2734
                        if (err < 0)
 
2735
                                goto error;
 
2736
                }
 
2737
        } else {
 
2738
                i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
 
2739
                kcontrol->private_value =
 
2740
                        HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
 
2741
                                            3, 0, HDA_INPUT);
 
2742
                err = func(kcontrol, ucontrol);
 
2743
        }
 
2744
 error:
2445
2745
        mutex_unlock(&codec->control_mutex);
2446
2746
        return err;
2447
2747
}
2450
2750
                           struct snd_ctl_elem_value *ucontrol)
2451
2751
{
2452
2752
        return alc_cap_getput_caller(kcontrol, ucontrol,
2453
 
                                     snd_hda_mixer_amp_volume_get);
 
2753
                                     snd_hda_mixer_amp_volume_get, false);
2454
2754
}
2455
2755
 
2456
2756
static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2457
2757
                           struct snd_ctl_elem_value *ucontrol)
2458
2758
{
2459
2759
        return alc_cap_getput_caller(kcontrol, ucontrol,
2460
 
                                     snd_hda_mixer_amp_volume_put);
 
2760
                                     snd_hda_mixer_amp_volume_put, true);
2461
2761
}
2462
2762
 
2463
2763
/* capture mixer elements */
2467
2767
                          struct snd_ctl_elem_value *ucontrol)
2468
2768
{
2469
2769
        return alc_cap_getput_caller(kcontrol, ucontrol,
2470
 
                                     snd_hda_mixer_amp_switch_get);
 
2770
                                     snd_hda_mixer_amp_switch_get, false);
2471
2771
}
2472
2772
 
2473
2773
static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2474
2774
                          struct snd_ctl_elem_value *ucontrol)
2475
2775
{
2476
2776
        return alc_cap_getput_caller(kcontrol, ucontrol,
2477
 
                                     snd_hda_mixer_amp_switch_put);
 
2777
                                     snd_hda_mixer_amp_switch_put, true);
2478
2778
}
2479
2779
 
2480
2780
#define _DEFINE_CAPMIX(num) \
2512
2812
        }
2513
2813
 
2514
2814
#define DEFINE_CAPMIX(num) \
2515
 
static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
 
2815
static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2516
2816
        _DEFINE_CAPMIX(num),                                  \
2517
2817
        _DEFINE_CAPSRC(num),                                  \
2518
2818
        { } /* end */                                         \
2519
2819
}
2520
2820
 
2521
2821
#define DEFINE_CAPMIX_NOSRC(num) \
2522
 
static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
 
2822
static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2523
2823
        _DEFINE_CAPMIX(num),                                        \
2524
2824
        { } /* end */                                               \
2525
2825
}
2542
2842
 */
2543
2843
 
2544
2844
/* additional mixers to alc880_three_stack_mixer */
2545
 
static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
 
2845
static const struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2546
2846
        HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2547
2847
        HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2548
2848
        { } /* end */
2550
2850
 
2551
2851
/* channel source setting (6/8 channel selection for 5-stack) */
2552
2852
/* 6ch mode */
2553
 
static struct hda_verb alc880_fivestack_ch6_init[] = {
 
2853
static const struct hda_verb alc880_fivestack_ch6_init[] = {
2554
2854
        /* set line-in to input, mute it */
2555
2855
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2556
2856
        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2558
2858
};
2559
2859
 
2560
2860
/* 8ch mode */
2561
 
static struct hda_verb alc880_fivestack_ch8_init[] = {
 
2861
static const struct hda_verb alc880_fivestack_ch8_init[] = {
2562
2862
        /* set line-in to output, unmute it */
2563
2863
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2564
2864
        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2565
2865
        { } /* end */
2566
2866
};
2567
2867
 
2568
 
static struct hda_channel_mode alc880_fivestack_modes[2] = {
 
2868
static const struct hda_channel_mode alc880_fivestack_modes[2] = {
2569
2869
        { 6, alc880_fivestack_ch6_init },
2570
2870
        { 8, alc880_fivestack_ch8_init },
2571
2871
};
2580
2880
 *   Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2581
2881
 */
2582
2882
 
2583
 
static hda_nid_t alc880_6st_dac_nids[4] = {
 
2883
static const hda_nid_t alc880_6st_dac_nids[4] = {
2584
2884
        /* front, rear, clfe, rear_surr */
2585
2885
        0x02, 0x03, 0x04, 0x05
2586
2886
};
2587
2887
 
2588
 
static struct hda_input_mux alc880_6stack_capture_source = {
 
2888
static const struct hda_input_mux alc880_6stack_capture_source = {
2589
2889
        .num_items = 4,
2590
2890
        .items = {
2591
2891
                { "Mic", 0x0 },
2596
2896
};
2597
2897
 
2598
2898
/* fixed 8-channels */
2599
 
static struct hda_channel_mode alc880_sixstack_modes[1] = {
 
2899
static const struct hda_channel_mode alc880_sixstack_modes[1] = {
2600
2900
        { 8, NULL },
2601
2901
};
2602
2902
 
2603
 
static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
 
2903
static const struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2604
2904
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2605
2905
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2606
2906
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2655
2955
 * haven't setup any initialization verbs for these yet...
2656
2956
 */
2657
2957
 
2658
 
static hda_nid_t alc880_w810_dac_nids[3] = {
 
2958
static const hda_nid_t alc880_w810_dac_nids[3] = {
2659
2959
        /* front, rear/surround, clfe */
2660
2960
        0x02, 0x03, 0x04
2661
2961
};
2662
2962
 
2663
2963
/* fixed 6 channels */
2664
 
static struct hda_channel_mode alc880_w810_modes[1] = {
 
2964
static const struct hda_channel_mode alc880_w810_modes[1] = {
2665
2965
        { 6, NULL }
2666
2966
};
2667
2967
 
2668
2968
/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2669
 
static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
 
2969
static const struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2670
2970
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2671
2971
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2672
2972
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2688
2988
 *                 Line = 0x1a
2689
2989
 */
2690
2990
 
2691
 
static hda_nid_t alc880_z71v_dac_nids[1] = {
 
2991
static const hda_nid_t alc880_z71v_dac_nids[1] = {
2692
2992
        0x02
2693
2993
};
2694
2994
#define ALC880_Z71V_HP_DAC      0x03
2695
2995
 
2696
2996
/* fixed 2 channels */
2697
 
static struct hda_channel_mode alc880_2_jack_modes[1] = {
 
2997
static const struct hda_channel_mode alc880_2_jack_modes[1] = {
2698
2998
        { 2, NULL }
2699
2999
};
2700
3000
 
2701
 
static struct snd_kcontrol_new alc880_z71v_mixer[] = {
 
3001
static const struct snd_kcontrol_new alc880_z71v_mixer[] = {
2702
3002
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2703
3003
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2704
3004
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2718
3018
 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2719
3019
 */
2720
3020
 
2721
 
static hda_nid_t alc880_f1734_dac_nids[1] = {
 
3021
static const hda_nid_t alc880_f1734_dac_nids[1] = {
2722
3022
        0x03
2723
3023
};
2724
3024
#define ALC880_F1734_HP_DAC     0x02
2725
3025
 
2726
 
static struct snd_kcontrol_new alc880_f1734_mixer[] = {
 
3026
static const struct snd_kcontrol_new alc880_f1734_mixer[] = {
2727
3027
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2728
3028
        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2729
3029
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2735
3035
        { } /* end */
2736
3036
};
2737
3037
 
2738
 
static struct hda_input_mux alc880_f1734_capture_source = {
 
3038
static const struct hda_input_mux alc880_f1734_capture_source = {
2739
3039
        .num_items = 2,
2740
3040
        .items = {
2741
3041
                { "Mic", 0x1 },
2755
3055
#define alc880_asus_dac_nids    alc880_w810_dac_nids    /* identical with w810 */
2756
3056
#define alc880_asus_modes       alc880_threestack_modes /* 2/6 channel mode */
2757
3057
 
2758
 
static struct snd_kcontrol_new alc880_asus_mixer[] = {
 
3058
static const struct snd_kcontrol_new alc880_asus_mixer[] = {
2759
3059
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2760
3060
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2761
3061
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2789
3089
 */
2790
3090
 
2791
3091
/* additional mixers to alc880_asus_mixer */
2792
 
static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
 
3092
static const struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2793
3093
        HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2794
3094
        HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2795
3095
        { } /* end */
2796
3096
};
2797
3097
 
2798
3098
/* TCL S700 */
2799
 
static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
 
3099
static const struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2800
3100
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2801
3101
        HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2802
3102
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2810
3110
};
2811
3111
 
2812
3112
/* Uniwill */
2813
 
static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
 
3113
static const struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2814
3114
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2815
3115
        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2816
3116
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2837
3137
        { } /* end */
2838
3138
};
2839
3139
 
2840
 
static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
 
3140
static const struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2841
3141
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2842
3142
        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2843
3143
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2851
3151
        { } /* end */
2852
3152
};
2853
3153
 
2854
 
static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
 
3154
static const struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2855
3155
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2856
3156
        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2857
3157
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2878
3178
        "Speaker Playback Volume",
2879
3179
        "Mono Playback Volume",
2880
3180
        "Line-Out Playback Volume",
2881
 
        "PCM Playback Volume",
2882
3181
        NULL,
2883
3182
};
2884
3183
 
2893
3192
        "Mono Playback Switch",
2894
3193
        "IEC958 Playback Switch",
2895
3194
        "Line-Out Playback Switch",
2896
 
        "PCM Playback Switch",
2897
3195
        NULL,
2898
3196
};
2899
3197
 
2914
3212
 
2915
3213
#ifdef CONFIG_SND_HDA_INPUT_BEEP
2916
3214
/* additional beep mixers; the actual parameters are overwritten at build */
2917
 
static struct snd_kcontrol_new alc_beep_mixer[] = {
 
3215
static const struct snd_kcontrol_new alc_beep_mixer[] = {
2918
3216
        HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2919
3217
        HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
2920
3218
        { } /* end */
2925
3223
{
2926
3224
        struct alc_spec *spec = codec->spec;
2927
3225
        struct snd_kcontrol *kctl = NULL;
2928
 
        struct snd_kcontrol_new *knew;
 
3226
        const struct snd_kcontrol_new *knew;
2929
3227
        int i, j, err;
2930
3228
        unsigned int u;
2931
3229
        hda_nid_t nid;
2962
3260
#ifdef CONFIG_SND_HDA_INPUT_BEEP
2963
3261
        /* create beep controls if needed */
2964
3262
        if (spec->beep_amp) {
2965
 
                struct snd_kcontrol_new *knew;
 
3263
                const struct snd_kcontrol_new *knew;
2966
3264
                for (knew = alc_beep_mixer; knew->name; knew++) {
2967
3265
                        struct snd_kcontrol *kctl;
2968
3266
                        kctl = snd_ctl_new1(knew, codec);
3001
3299
                if (!kctl)
3002
3300
                        kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3003
3301
                for (i = 0; kctl && i < kctl->count; i++) {
3004
 
                        hda_nid_t *nids = spec->capsrc_nids;
 
3302
                        const hda_nid_t *nids = spec->capsrc_nids;
3005
3303
                        if (!nids)
3006
3304
                                nids = spec->adc_nids;
3007
3305
                        err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3079
3377
/*
3080
3378
 * generic initialization of ADC, input mixers and output mixers
3081
3379
 */
3082
 
static struct hda_verb alc880_volume_init_verbs[] = {
 
3380
static const struct hda_verb alc880_volume_init_verbs[] = {
3083
3381
        /*
3084
3382
         * Unmute ADC0-2 and set the default input to mic-in
3085
3383
         */
3130
3428
 * 3-stack pin configuration:
3131
3429
 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3132
3430
 */
3133
 
static struct hda_verb alc880_pin_3stack_init_verbs[] = {
 
3431
static const struct hda_verb alc880_pin_3stack_init_verbs[] = {
3134
3432
        /*
3135
3433
         * preset connection lists of input pins
3136
3434
         * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3168
3466
 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3169
3467
 * line-in/side = 0x1a, f-mic = 0x1b
3170
3468
 */
3171
 
static struct hda_verb alc880_pin_5stack_init_verbs[] = {
 
3469
static const struct hda_verb alc880_pin_5stack_init_verbs[] = {
3172
3470
        /*
3173
3471
         * preset connection lists of input pins
3174
3472
         * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3212
3510
 * W810 pin configuration:
3213
3511
 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3214
3512
 */
3215
 
static struct hda_verb alc880_pin_w810_init_verbs[] = {
 
3513
static const struct hda_verb alc880_pin_w810_init_verbs[] = {
3216
3514
        /* hphone/speaker input selector: front DAC */
3217
3515
        {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3218
3516
 
3233
3531
 * Z71V pin configuration:
3234
3532
 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3235
3533
 */
3236
 
static struct hda_verb alc880_pin_z71v_init_verbs[] = {
 
3534
static const struct hda_verb alc880_pin_z71v_init_verbs[] = {
3237
3535
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3238
3536
        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3239
3537
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3252
3550
 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3253
3551
 * f-mic = 0x19, line = 0x1a, HP = 0x1b
3254
3552
 */
3255
 
static struct hda_verb alc880_pin_6stack_init_verbs[] = {
 
3553
static const struct hda_verb alc880_pin_6stack_init_verbs[] = {
3256
3554
        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3257
3555
 
3258
3556
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3282
3580
 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3283
3581
 * line = 0x1a
3284
3582
 */
3285
 
static struct hda_verb alc880_uniwill_init_verbs[] = {
 
3583
static const struct hda_verb alc880_uniwill_init_verbs[] = {
3286
3584
        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3287
3585
 
3288
3586
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3320
3618
* Uniwill P53
3321
3619
* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
3322
3620
 */
3323
 
static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
 
3621
static const struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3324
3622
        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3325
3623
 
3326
3624
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3349
3647
        { }
3350
3648
};
3351
3649
 
3352
 
static struct hda_verb alc880_beep_init_verbs[] = {
 
3650
static const struct hda_verb alc880_beep_init_verbs[] = {
3353
3651
        { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3354
3652
        { }
3355
3653
};
3372
3670
        spec->autocfg.hp_pins[0] = 0x14;
3373
3671
        spec->autocfg.speaker_pins[0] = 0x15;
3374
3672
        spec->autocfg.speaker_pins[0] = 0x16;
 
3673
        spec->automute = 1;
 
3674
        spec->automute_mode = ALC_AUTOMUTE_AMP;
3375
3675
}
3376
3676
 
3377
3677
static void alc880_uniwill_init_hook(struct hda_codec *codec)
3378
3678
{
3379
 
        alc_automute_amp(codec);
 
3679
        alc_hp_automute(codec);
3380
3680
        alc88x_simple_mic_automute(codec);
3381
3681
}
3382
3682
 
3391
3691
                alc88x_simple_mic_automute(codec);
3392
3692
                break;
3393
3693
        default:
3394
 
                alc_automute_amp_unsol_event(codec, res);
 
3694
                alc_sku_unsol_event(codec, res);
3395
3695
                break;
3396
3696
        }
3397
3697
}
3402
3702
 
3403
3703
        spec->autocfg.hp_pins[0] = 0x14;
3404
3704
        spec->autocfg.speaker_pins[0] = 0x15;
 
3705
        spec->automute = 1;
 
3706
        spec->automute_mode = ALC_AUTOMUTE_AMP;
3405
3707
}
3406
3708
 
3407
3709
static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3426
3728
        if ((res >> 28) == ALC880_DCVOL_EVENT)
3427
3729
                alc880_uniwill_p53_dcvol_automute(codec);
3428
3730
        else
3429
 
                alc_automute_amp_unsol_event(codec, res);
 
3731
                alc_sku_unsol_event(codec, res);
3430
3732
}
3431
3733
 
3432
3734
/*
3433
3735
 * F1734 pin configuration:
3434
3736
 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3435
3737
 */
3436
 
static struct hda_verb alc880_pin_f1734_init_verbs[] = {
 
3738
static const struct hda_verb alc880_pin_f1734_init_verbs[] = {
3437
3739
        {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
3438
3740
        {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3439
3741
        {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3465
3767
 * ASUS pin configuration:
3466
3768
 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3467
3769
 */
3468
 
static struct hda_verb alc880_pin_asus_init_verbs[] = {
 
3770
static const struct hda_verb alc880_pin_asus_init_verbs[] = {
3469
3771
        {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3470
3772
        {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3471
3773
        {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3499
3801
#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
3500
3802
 
3501
3803
/* Clevo m520g init */
3502
 
static struct hda_verb alc880_pin_clevo_init_verbs[] = {
 
3804
static const struct hda_verb alc880_pin_clevo_init_verbs[] = {
3503
3805
        /* headphone output */
3504
3806
        {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3505
3807
        /* line-out */
3527
3829
        { }
3528
3830
};
3529
3831
 
3530
 
static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
 
3832
static const struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
3531
3833
        /* change to EAPD mode */
3532
3834
        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3533
3835
        {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
3565
3867
 */
3566
3868
 
3567
3869
/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3568
 
static hda_nid_t alc880_lg_dac_nids[3] = {
 
3870
static const hda_nid_t alc880_lg_dac_nids[3] = {
3569
3871
        0x05, 0x02, 0x03
3570
3872
};
3571
3873
 
3572
3874
/* seems analog CD is not working */
3573
 
static struct hda_input_mux alc880_lg_capture_source = {
 
3875
static const struct hda_input_mux alc880_lg_capture_source = {
3574
3876
        .num_items = 3,
3575
3877
        .items = {
3576
3878
                { "Mic", 0x1 },
3580
3882
};
3581
3883
 
3582
3884
/* 2,4,6 channel modes */
3583
 
static struct hda_verb alc880_lg_ch2_init[] = {
 
3885
static const struct hda_verb alc880_lg_ch2_init[] = {
3584
3886
        /* set line-in and mic-in to input */
3585
3887
        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3586
3888
        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3587
3889
        { }
3588
3890
};
3589
3891
 
3590
 
static struct hda_verb alc880_lg_ch4_init[] = {
 
3892
static const struct hda_verb alc880_lg_ch4_init[] = {
3591
3893
        /* set line-in to out and mic-in to input */
3592
3894
        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3593
3895
        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3594
3896
        { }
3595
3897
};
3596
3898
 
3597
 
static struct hda_verb alc880_lg_ch6_init[] = {
 
3899
static const struct hda_verb alc880_lg_ch6_init[] = {
3598
3900
        /* set line-in and mic-in to output */
3599
3901
        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3600
3902
        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3601
3903
        { }
3602
3904
};
3603
3905
 
3604
 
static struct hda_channel_mode alc880_lg_ch_modes[3] = {
 
3906
static const struct hda_channel_mode alc880_lg_ch_modes[3] = {
3605
3907
        { 2, alc880_lg_ch2_init },
3606
3908
        { 4, alc880_lg_ch4_init },
3607
3909
        { 6, alc880_lg_ch6_init },
3608
3910
};
3609
3911
 
3610
 
static struct snd_kcontrol_new alc880_lg_mixer[] = {
 
3912
static const struct snd_kcontrol_new alc880_lg_mixer[] = {
3611
3913
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3612
3914
        HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3613
3915
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3632
3934
        { } /* end */
3633
3935
};
3634
3936
 
3635
 
static struct hda_verb alc880_lg_init_verbs[] = {
 
3937
static const struct hda_verb alc880_lg_init_verbs[] = {
3636
3938
        /* set capture source to mic-in */
3637
3939
        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3638
3940
        {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3670
3972
 
3671
3973
        spec->autocfg.hp_pins[0] = 0x1b;
3672
3974
        spec->autocfg.speaker_pins[0] = 0x17;
 
3975
        spec->automute = 1;
 
3976
        spec->automute_mode = ALC_AUTOMUTE_AMP;
3673
3977
}
3674
3978
 
3675
3979
/*
3684
3988
 *   SPDIF-Out: 0x1e
3685
3989
 */
3686
3990
 
3687
 
static struct hda_input_mux alc880_lg_lw_capture_source = {
 
3991
static const struct hda_input_mux alc880_lg_lw_capture_source = {
3688
3992
        .num_items = 3,
3689
3993
        .items = {
3690
3994
                { "Mic", 0x0 },
3695
3999
 
3696
4000
#define alc880_lg_lw_modes alc880_threestack_modes
3697
4001
 
3698
 
static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
 
4002
static const struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3699
4003
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3700
4004
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3701
4005
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3720
4024
        { } /* end */
3721
4025
};
3722
4026
 
3723
 
static struct hda_verb alc880_lg_lw_init_verbs[] = {
 
4027
static const struct hda_verb alc880_lg_lw_init_verbs[] = {
3724
4028
        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3725
4029
        {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3726
4030
        {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3754
4058
 
3755
4059
        spec->autocfg.hp_pins[0] = 0x1b;
3756
4060
        spec->autocfg.speaker_pins[0] = 0x14;
 
4061
        spec->automute = 1;
 
4062
        spec->automute_mode = ALC_AUTOMUTE_AMP;
3757
4063
}
3758
4064
 
3759
 
static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
 
4065
static const struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3760
4066
        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3761
4067
        HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3762
4068
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3766
4072
        { } /* end */
3767
4073
};
3768
4074
 
3769
 
static struct hda_input_mux alc880_medion_rim_capture_source = {
 
4075
static const struct hda_input_mux alc880_medion_rim_capture_source = {
3770
4076
        .num_items = 2,
3771
4077
        .items = {
3772
4078
                { "Mic", 0x0 },
3774
4080
        },
3775
4081
};
3776
4082
 
3777
 
static struct hda_verb alc880_medion_rim_init_verbs[] = {
 
4083
static const struct hda_verb alc880_medion_rim_init_verbs[] = {
3778
4084
        {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3779
4085
 
3780
4086
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3801
4107
static void alc880_medion_rim_automute(struct hda_codec *codec)
3802
4108
{
3803
4109
        struct alc_spec *spec = codec->spec;
3804
 
        alc_automute_amp(codec);
 
4110
        alc_hp_automute(codec);
3805
4111
        /* toggle EAPD */
3806
4112
        if (spec->jack_present)
3807
4113
                snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3825
4131
 
3826
4132
        spec->autocfg.hp_pins[0] = 0x14;
3827
4133
        spec->autocfg.speaker_pins[0] = 0x1b;
 
4134
        spec->automute = 1;
 
4135
        spec->automute_mode = ALC_AUTOMUTE_AMP;
3828
4136
}
3829
4137
 
3830
4138
#ifdef CONFIG_SND_HDA_POWER_SAVE
3831
 
static struct hda_amp_list alc880_loopbacks[] = {
 
4139
static const struct hda_amp_list alc880_loopbacks[] = {
3832
4140
        { 0x0b, HDA_INPUT, 0 },
3833
4141
        { 0x0b, HDA_INPUT, 1 },
3834
4142
        { 0x0b, HDA_INPUT, 2 },
3837
4145
        { } /* end */
3838
4146
};
3839
4147
 
3840
 
static struct hda_amp_list alc880_lg_loopbacks[] = {
 
4148
static const struct hda_amp_list alc880_lg_loopbacks[] = {
3841
4149
        { 0x0b, HDA_INPUT, 1 },
3842
4150
        { 0x0b, HDA_INPUT, 6 },
3843
4151
        { 0x0b, HDA_INPUT, 7 },
4009
4317
        return 0;
4010
4318
}
4011
4319
 
4012
 
static struct hda_pcm_stream dualmic_pcm_analog_capture = {
 
4320
static const struct hda_pcm_stream dualmic_pcm_analog_capture = {
4013
4321
        .substreams = 1,
4014
4322
        .channels_min = 2,
4015
4323
        .channels_max = 2,
4022
4330
 
4023
4331
/*
4024
4332
 */
4025
 
static struct hda_pcm_stream alc880_pcm_analog_playback = {
 
4333
static const struct hda_pcm_stream alc880_pcm_analog_playback = {
4026
4334
        .substreams = 1,
4027
4335
        .channels_min = 2,
4028
4336
        .channels_max = 8,
4034
4342
        },
4035
4343
};
4036
4344
 
4037
 
static struct hda_pcm_stream alc880_pcm_analog_capture = {
4038
 
        .substreams = 1,
4039
 
        .channels_min = 2,
4040
 
        .channels_max = 2,
4041
 
        /* NID is set in alc_build_pcms */
4042
 
};
4043
 
 
4044
 
static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4045
 
        .substreams = 1,
4046
 
        .channels_min = 2,
4047
 
        .channels_max = 2,
4048
 
        /* NID is set in alc_build_pcms */
4049
 
};
4050
 
 
4051
 
static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
 
4345
static const struct hda_pcm_stream alc880_pcm_analog_capture = {
 
4346
        .substreams = 1,
 
4347
        .channels_min = 2,
 
4348
        .channels_max = 2,
 
4349
        /* NID is set in alc_build_pcms */
 
4350
};
 
4351
 
 
4352
static const struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
 
4353
        .substreams = 1,
 
4354
        .channels_min = 2,
 
4355
        .channels_max = 2,
 
4356
        /* NID is set in alc_build_pcms */
 
4357
};
 
4358
 
 
4359
static const struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4052
4360
        .substreams = 2, /* can be overridden */
4053
4361
        .channels_min = 2,
4054
4362
        .channels_max = 2,
4059
4367
        },
4060
4368
};
4061
4369
 
4062
 
static struct hda_pcm_stream alc880_pcm_digital_playback = {
 
4370
static const struct hda_pcm_stream alc880_pcm_digital_playback = {
4063
4371
        .substreams = 1,
4064
4372
        .channels_min = 2,
4065
4373
        .channels_max = 2,
4072
4380
        },
4073
4381
};
4074
4382
 
4075
 
static struct hda_pcm_stream alc880_pcm_digital_capture = {
 
4383
static const struct hda_pcm_stream alc880_pcm_digital_capture = {
4076
4384
        .substreams = 1,
4077
4385
        .channels_min = 2,
4078
4386
        .channels_max = 2,
4080
4388
};
4081
4389
 
4082
4390
/* Used by alc_build_pcms to flag that a PCM has no playback stream */
4083
 
static struct hda_pcm_stream alc_pcm_null_stream = {
 
4391
static const struct hda_pcm_stream alc_pcm_null_stream = {
4084
4392
        .substreams = 0,
4085
4393
        .channels_min = 0,
4086
4394
        .channels_max = 0,
4174
4482
                                alc_pcm_null_stream;
4175
4483
                        info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4176
4484
                }
4177
 
                if (spec->num_adc_nids > 1) {
 
4485
                if (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture) {
4178
4486
                        info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4179
4487
                                *spec->stream_analog_alt_capture;
4180
4488
                        info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4193
4501
 
4194
4502
static inline void alc_shutup(struct hda_codec *codec)
4195
4503
{
 
4504
        struct alc_spec *spec = codec->spec;
 
4505
 
 
4506
        if (spec && spec->shutup)
 
4507
                spec->shutup(codec);
4196
4508
        snd_hda_shutup_pins(codec);
4197
4509
}
4198
4510
 
4226
4538
#ifdef CONFIG_SND_HDA_POWER_SAVE
4227
4539
static void alc_power_eapd(struct hda_codec *codec)
4228
4540
{
4229
 
        /* We currently only handle front, HP */
4230
 
        switch (codec->vendor_id) {
4231
 
        case 0x10ec0260:
4232
 
                set_eapd(codec, 0x0f, 0);
4233
 
                set_eapd(codec, 0x10, 0);
4234
 
                break;
4235
 
        case 0x10ec0262:
4236
 
        case 0x10ec0267:
4237
 
        case 0x10ec0268:
4238
 
        case 0x10ec0269:
4239
 
        case 0x10ec0270:
4240
 
        case 0x10ec0272:
4241
 
        case 0x10ec0660:
4242
 
        case 0x10ec0662:
4243
 
        case 0x10ec0663:
4244
 
        case 0x10ec0665:
4245
 
        case 0x10ec0862:
4246
 
        case 0x10ec0889:
4247
 
                set_eapd(codec, 0x14, 0);
4248
 
                set_eapd(codec, 0x15, 0);
4249
 
                break;
4250
 
        }
 
4541
        alc_auto_setup_eapd(codec, false);
4251
4542
}
4252
4543
 
4253
4544
static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4263
4554
#ifdef SND_HDA_NEEDS_RESUME
4264
4555
static int alc_resume(struct hda_codec *codec)
4265
4556
{
 
4557
        msleep(150); /* to avoid pop noise */
4266
4558
        codec->patch_ops.init(codec);
4267
4559
        snd_hda_codec_resume_amp(codec);
4268
4560
        snd_hda_codec_resume_cache(codec);
4273
4565
 
4274
4566
/*
4275
4567
 */
4276
 
static struct hda_codec_ops alc_patch_ops = {
 
4568
static const struct hda_codec_ops alc_patch_ops = {
4277
4569
        .build_controls = alc_build_controls,
4278
4570
        .build_pcms = alc_build_pcms,
4279
4571
        .init = alc_init,
4308
4600
 * enum controls.
4309
4601
 */
4310
4602
#ifdef CONFIG_SND_DEBUG
4311
 
static hda_nid_t alc880_test_dac_nids[4] = {
 
4603
static const hda_nid_t alc880_test_dac_nids[4] = {
4312
4604
        0x02, 0x03, 0x04, 0x05
4313
4605
};
4314
4606
 
4315
 
static struct hda_input_mux alc880_test_capture_source = {
 
4607
static const struct hda_input_mux alc880_test_capture_source = {
4316
4608
        .num_items = 7,
4317
4609
        .items = {
4318
4610
                { "In-1", 0x0 },
4325
4617
        },
4326
4618
};
4327
4619
 
4328
 
static struct hda_channel_mode alc880_test_modes[4] = {
 
4620
static const struct hda_channel_mode alc880_test_modes[4] = {
4329
4621
        { 2, NULL },
4330
4622
        { 4, NULL },
4331
4623
        { 6, NULL },
4335
4627
static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4336
4628
                                 struct snd_ctl_elem_info *uinfo)
4337
4629
{
4338
 
        static char *texts[] = {
 
4630
        static const char * const texts[] = {
4339
4631
                "N/A", "Line Out", "HP Out",
4340
4632
                "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4341
4633
        };
4380
4672
{
4381
4673
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4382
4674
        hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4383
 
        static unsigned int ctls[] = {
 
4675
        static const unsigned int ctls[] = {
4384
4676
                0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4385
4677
                AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4386
4678
                AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4410
4702
static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4411
4703
                                 struct snd_ctl_elem_info *uinfo)
4412
4704
{
4413
 
        static char *texts[] = {
 
4705
        static const char * const texts[] = {
4414
4706
                "Front", "Surround", "CLFE", "Side"
4415
4707
        };
4416
4708
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4471
4763
                        .private_value = nid           \
4472
4764
                        }
4473
4765
 
4474
 
static struct snd_kcontrol_new alc880_test_mixer[] = {
 
4766
static const struct snd_kcontrol_new alc880_test_mixer[] = {
4475
4767
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4476
4768
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4477
4769
        HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4512
4804
        { } /* end */
4513
4805
};
4514
4806
 
4515
 
static struct hda_verb alc880_test_init_verbs[] = {
 
4807
static const struct hda_verb alc880_test_init_verbs[] = {
4516
4808
        /* Unmute inputs of 0x0c - 0x0f */
4517
4809
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4518
4810
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4596
4888
        [ALC880_AUTO]           = "auto",
4597
4889
};
4598
4890
 
4599
 
static struct snd_pci_quirk alc880_cfg_tbl[] = {
 
4891
static const struct snd_pci_quirk alc880_cfg_tbl[] = {
4600
4892
        SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
4601
4893
        SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4602
4894
        SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4607
4899
        SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4608
4900
        SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
4609
4901
        SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4610
 
        SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
4611
4902
        SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4612
4903
        SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4613
4904
        SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4676
4967
/*
4677
4968
 * ALC880 codec presets
4678
4969
 */
4679
 
static struct alc_config_preset alc880_presets[] = {
 
4970
static const struct alc_config_preset alc880_presets[] = {
4680
4971
        [ALC880_3ST] = {
4681
4972
                .mixers = { alc880_three_stack_mixer },
4682
4973
                .init_verbs = { alc880_volume_init_verbs,
4794
5085
                .input_mux = &alc880_f1734_capture_source,
4795
5086
                .unsol_event = alc880_uniwill_p53_unsol_event,
4796
5087
                .setup = alc880_uniwill_p53_setup,
4797
 
                .init_hook = alc_automute_amp,
 
5088
                .init_hook = alc_hp_automute,
4798
5089
        },
4799
5090
        [ALC880_ASUS] = {
4800
5091
                .mixers = { alc880_asus_mixer },
4885
5176
                .input_mux = &alc880_capture_source,
4886
5177
                .unsol_event = alc880_uniwill_p53_unsol_event,
4887
5178
                .setup = alc880_uniwill_p53_setup,
4888
 
                .init_hook = alc_automute_amp,
 
5179
                .init_hook = alc_hp_automute,
4889
5180
        },
4890
5181
        [ALC880_FUJITSU] = {
4891
5182
                .mixers = { alc880_fujitsu_mixer },
4900
5191
                .input_mux = &alc880_capture_source,
4901
5192
                .unsol_event = alc880_uniwill_p53_unsol_event,
4902
5193
                .setup = alc880_uniwill_p53_setup,
4903
 
                .init_hook = alc_automute_amp,
 
5194
                .init_hook = alc_hp_automute,
4904
5195
        },
4905
5196
        [ALC880_CLEVO] = {
4906
5197
                .mixers = { alc880_three_stack_mixer },
4925
5216
                .channel_mode = alc880_lg_ch_modes,
4926
5217
                .need_dac_fix = 1,
4927
5218
                .input_mux = &alc880_lg_capture_source,
4928
 
                .unsol_event = alc_automute_amp_unsol_event,
 
5219
                .unsol_event = alc_sku_unsol_event,
4929
5220
                .setup = alc880_lg_setup,
4930
 
                .init_hook = alc_automute_amp,
 
5221
                .init_hook = alc_hp_automute,
4931
5222
#ifdef CONFIG_SND_HDA_POWER_SAVE
4932
5223
                .loopbacks = alc880_lg_loopbacks,
4933
5224
#endif
4942
5233
                .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4943
5234
                .channel_mode = alc880_lg_lw_modes,
4944
5235
                .input_mux = &alc880_lg_lw_capture_source,
4945
 
                .unsol_event = alc_automute_amp_unsol_event,
 
5236
                .unsol_event = alc_sku_unsol_event,
4946
5237
                .setup = alc880_lg_lw_setup,
4947
 
                .init_hook = alc_automute_amp,
 
5238
                .init_hook = alc_hp_automute,
4948
5239
        },
4949
5240
        [ALC880_MEDION_RIM] = {
4950
5241
                .mixers = { alc880_medion_rim_mixer },
4984
5275
        ALC_CTL_WIDGET_MUTE,
4985
5276
        ALC_CTL_BIND_MUTE,
4986
5277
};
4987
 
static struct snd_kcontrol_new alc880_control_templates[] = {
 
5278
static const struct snd_kcontrol_new alc880_control_templates[] = {
4988
5279
        HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4989
5280
        HDA_CODEC_MUTE(NULL, 0, 0, 0),
4990
5281
        HDA_BIND_MUTE(NULL, 0, 0, 0),
4991
5282
};
4992
5283
 
 
5284
static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec)
 
5285
{
 
5286
        snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
 
5287
        return snd_array_new(&spec->kctls);
 
5288
}
 
5289
 
4993
5290
/* add dynamic controls */
4994
5291
static int add_control(struct alc_spec *spec, int type, const char *name,
4995
5292
                       int cidx, unsigned long val)
4996
5293
{
4997
5294
        struct snd_kcontrol_new *knew;
4998
5295
 
4999
 
        snd_array_init(&spec->kctls, sizeof(*knew), 32);
5000
 
        knew = snd_array_new(&spec->kctls);
 
5296
        knew = alc_kcontrol_new(spec);
5001
5297
        if (!knew)
5002
5298
                return -ENOMEM;
5003
5299
        *knew = alc880_control_templates[type];
5055
5351
                nid = cfg->line_out_pins[i];
5056
5352
                if (alc880_is_fixed_pin(nid)) {
5057
5353
                        int idx = alc880_fixed_pin_idx(nid);
5058
 
                        spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
 
5354
                        spec->private_dac_nids[i] = alc880_idx_to_dac(idx);
5059
5355
                        assigned[idx] = 1;
5060
5356
                }
5061
5357
        }
5067
5363
                /* search for an empty channel */
5068
5364
                for (j = 0; j < cfg->line_outs; j++) {
5069
5365
                        if (!assigned[j]) {
5070
 
                                spec->multiout.dac_nids[i] =
 
5366
                                spec->private_dac_nids[i] =
5071
5367
                                        alc880_idx_to_dac(j);
5072
5368
                                assigned[j] = 1;
5073
5369
                                break;
5078
5374
        return 0;
5079
5375
}
5080
5376
 
5081
 
static const char *alc_get_line_out_pfx(const struct auto_pin_cfg *cfg,
 
5377
static const char *alc_get_line_out_pfx(struct alc_spec *spec,
5082
5378
                                        bool can_be_master)
5083
5379
{
5084
 
        if (!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
 
5380
        struct auto_pin_cfg *cfg = &spec->autocfg;
 
5381
 
 
5382
        if (cfg->line_outs == 1 && !spec->multi_ios &&
 
5383
            !cfg->hp_outs && !cfg->speaker_outs && can_be_master)
5085
5384
                return "Master";
5086
5385
 
5087
5386
        switch (cfg->line_out_type) {
5092
5391
        case AUTO_PIN_HP_OUT:
5093
5392
                return "Headphone";
5094
5393
        default:
5095
 
                if (cfg->line_outs == 1)
 
5394
                if (cfg->line_outs == 1 && !spec->multi_ios)
5096
5395
                        return "PCM";
5097
5396
                break;
5098
5397
        }
5106
5405
        static const char * const chname[4] = {
5107
5406
                "Front", "Surround", NULL /*CLFE*/, "Side"
5108
5407
        };
5109
 
        const char *pfx = alc_get_line_out_pfx(cfg, false);
 
5408
        const char *pfx = alc_get_line_out_pfx(spec, false);
5110
5409
        hda_nid_t nid;
5111
 
        int i, err;
5112
 
 
5113
 
        for (i = 0; i < cfg->line_outs; i++) {
 
5410
        int i, err, noutputs;
 
5411
 
 
5412
        noutputs = cfg->line_outs;
 
5413
        if (spec->multi_ios > 0)
 
5414
                noutputs += spec->multi_ios;
 
5415
 
 
5416
        for (i = 0; i < noutputs; i++) {
5114
5417
                if (!spec->multiout.dac_nids[i])
5115
5418
                        continue;
5116
5419
                nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
5376
5679
        }
5377
5680
}
5378
5681
 
 
5682
static int alc_auto_add_multi_channel_mode(struct hda_codec *codec);
 
5683
 
5379
5684
/* parse the BIOS configuration and set up the alc_spec */
5380
5685
/* return 1 if successful, 0 if the proper config is not found,
5381
5686
 * or a negative error code
5384
5689
{
5385
5690
        struct alc_spec *spec = codec->spec;
5386
5691
        int err;
5387
 
        static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
 
5692
        static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
5388
5693
 
5389
5694
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5390
5695
                                           alc880_ignore);
5396
5701
        err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5397
5702
        if (err < 0)
5398
5703
                return err;
 
5704
        err = alc_auto_add_multi_channel_mode(codec);
 
5705
        if (err < 0)
 
5706
                return err;
5399
5707
        err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5400
5708
        if (err < 0)
5401
5709
                return err;
5467
5775
                        spec->capsrc_nids += i;
5468
5776
                spec->adc_nids += i;
5469
5777
                spec->num_adc_nids = 1;
 
5778
                /* optional dock-mic */
 
5779
                eidx = get_connection_index(codec, cap, spec->dock_mic.pin);
 
5780
                if (eidx < 0)
 
5781
                        spec->dock_mic.pin = 0;
 
5782
                else
 
5783
                        spec->dock_mic.mux_idx = eidx;
5470
5784
                return;
5471
5785
        }
5472
5786
        snd_printd(KERN_INFO "hda_codec: %s: "
5494
5808
        struct alc_spec *spec = codec->spec;
5495
5809
        int i;
5496
5810
 
 
5811
        if (!pin)
 
5812
                return 0;
5497
5813
        for (i = 0; i < spec->num_adc_nids; i++) {
5498
5814
                hda_nid_t cap = spec->capsrc_nids ?
5499
5815
                        spec->capsrc_nids[i] : spec->adc_nids[i];
5534
5850
{
5535
5851
        struct alc_spec *spec = codec->spec;
5536
5852
        init_capsrc_for_pin(codec, spec->ext_mic.pin);
 
5853
        init_capsrc_for_pin(codec, spec->dock_mic.pin);
5537
5854
        init_capsrc_for_pin(codec, spec->int_mic.pin);
5538
5855
}
5539
5856
 
5550
5867
static void set_capture_mixer(struct hda_codec *codec)
5551
5868
{
5552
5869
        struct alc_spec *spec = codec->spec;
5553
 
        static struct snd_kcontrol_new *caps[2][3] = {
 
5870
        static const struct snd_kcontrol_new *caps[2][3] = {
5554
5871
                { alc_capture_mixer_nosrc1,
5555
5872
                  alc_capture_mixer_nosrc2,
5556
5873
                  alc_capture_mixer_nosrc3 },
5576
5893
}
5577
5894
 
5578
5895
/* fill adc_nids (and capsrc_nids) containing all active input pins */
5579
 
static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
 
5896
static void fillup_priv_adc_nids(struct hda_codec *codec, const hda_nid_t *nids,
5580
5897
                                 int num_nids)
5581
5898
{
5582
5899
        struct alc_spec *spec = codec->spec;
5642
5959
#define set_beep_amp(spec, nid, idx, dir) \
5643
5960
        ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
5644
5961
 
5645
 
static struct snd_pci_quirk beep_white_list[] = {
 
5962
static const struct snd_pci_quirk beep_white_list[] = {
5646
5963
        SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
5647
5964
        SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
5648
5965
        SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
 
5966
        SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
5649
5967
        SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
5650
5968
        {}
5651
5969
};
5753
6071
 * ALC260 support
5754
6072
 */
5755
6073
 
5756
 
static hda_nid_t alc260_dac_nids[1] = {
 
6074
static const hda_nid_t alc260_dac_nids[1] = {
5757
6075
        /* front */
5758
6076
        0x02,
5759
6077
};
5760
6078
 
5761
 
static hda_nid_t alc260_adc_nids[1] = {
 
6079
static const hda_nid_t alc260_adc_nids[1] = {
5762
6080
        /* ADC0 */
5763
6081
        0x04,
5764
6082
};
5765
6083
 
5766
 
static hda_nid_t alc260_adc_nids_alt[1] = {
 
6084
static const hda_nid_t alc260_adc_nids_alt[1] = {
5767
6085
        /* ADC1 */
5768
6086
        0x05,
5769
6087
};
5771
6089
/* NIDs used when simultaneous access to both ADCs makes sense.  Note that
5772
6090
 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5773
6091
 */
5774
 
static hda_nid_t alc260_dual_adc_nids[2] = {
 
6092
static const hda_nid_t alc260_dual_adc_nids[2] = {
5775
6093
        /* ADC0, ADC1 */
5776
6094
        0x04, 0x05
5777
6095
};
5779
6097
#define ALC260_DIGOUT_NID       0x03
5780
6098
#define ALC260_DIGIN_NID        0x06
5781
6099
 
5782
 
static struct hda_input_mux alc260_capture_source = {
 
6100
static const struct hda_input_mux alc260_capture_source = {
5783
6101
        .num_items = 4,
5784
6102
        .items = {
5785
6103
                { "Mic", 0x0 },
5795
6113
 * recording the mixer output on the second ADC (ADC0 doesn't have a
5796
6114
 * connection to the mixer output).
5797
6115
 */
5798
 
static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
 
6116
static const struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5799
6117
        {
5800
6118
                .num_items = 3,
5801
6119
                .items = {
5819
6137
/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5820
6138
 * the Fujitsu S702x, but jacks are marked differently.
5821
6139
 */
5822
 
static struct hda_input_mux alc260_acer_capture_sources[2] = {
 
6140
static const struct hda_input_mux alc260_acer_capture_sources[2] = {
5823
6141
        {
5824
6142
                .num_items = 4,
5825
6143
                .items = {
5842
6160
};
5843
6161
 
5844
6162
/* Maxdata Favorit 100XS */
5845
 
static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
 
6163
static const struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5846
6164
        {
5847
6165
                .num_items = 2,
5848
6166
                .items = {
5866
6184
 * element which allows changing the channel mode, so the verb list is
5867
6185
 * never used.
5868
6186
 */
5869
 
static struct hda_channel_mode alc260_modes[1] = {
 
6187
static const struct hda_channel_mode alc260_modes[1] = {
5870
6188
        { 2, NULL },
5871
6189
};
5872
6190
 
5880
6198
 * acer: acer + capture
5881
6199
 */
5882
6200
 
5883
 
static struct snd_kcontrol_new alc260_base_output_mixer[] = {
 
6201
static const struct snd_kcontrol_new alc260_base_output_mixer[] = {
5884
6202
        HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5885
6203
        HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5886
6204
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5890
6208
        { } /* end */
5891
6209
};
5892
6210
 
5893
 
static struct snd_kcontrol_new alc260_input_mixer[] = {
 
6211
static const struct snd_kcontrol_new alc260_input_mixer[] = {
5894
6212
        HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5895
6213
        HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5896
6214
        HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5903
6221
};
5904
6222
 
5905
6223
/* update HP, line and mono out pins according to the master switch */
5906
 
static void alc260_hp_master_update(struct hda_codec *codec,
5907
 
                                    hda_nid_t hp, hda_nid_t line,
5908
 
                                    hda_nid_t mono)
 
6224
static void alc260_hp_master_update(struct hda_codec *codec)
5909
6225
{
5910
 
        struct alc_spec *spec = codec->spec;
5911
 
        unsigned int val = spec->master_sw ? PIN_HP : 0;
5912
 
        /* change HP and line-out pins */
5913
 
        snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5914
 
                            val);
5915
 
        snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5916
 
                            val);
5917
 
        /* mono (speaker) depending on the HP jack sense */
5918
 
        val = (val && !spec->jack_present) ? PIN_OUT : 0;
5919
 
        snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5920
 
                            val);
 
6226
        update_speakers(codec);
5921
6227
}
5922
6228
 
5923
6229
static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5925
6231
{
5926
6232
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5927
6233
        struct alc_spec *spec = codec->spec;
5928
 
        *ucontrol->value.integer.value = spec->master_sw;
 
6234
        *ucontrol->value.integer.value = !spec->master_mute;
5929
6235
        return 0;
5930
6236
}
5931
6237
 
5934
6240
{
5935
6241
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5936
6242
        struct alc_spec *spec = codec->spec;
5937
 
        int val = !!*ucontrol->value.integer.value;
5938
 
        hda_nid_t hp, line, mono;
 
6243
        int val = !*ucontrol->value.integer.value;
5939
6244
 
5940
 
        if (val == spec->master_sw)
 
6245
        if (val == spec->master_mute)
5941
6246
                return 0;
5942
 
        spec->master_sw = val;
5943
 
        hp = (kcontrol->private_value >> 16) & 0xff;
5944
 
        line = (kcontrol->private_value >> 8) & 0xff;
5945
 
        mono = kcontrol->private_value & 0xff;
5946
 
        alc260_hp_master_update(codec, hp, line, mono);
 
6247
        spec->master_mute = val;
 
6248
        alc260_hp_master_update(codec);
5947
6249
        return 1;
5948
6250
}
5949
6251
 
5950
 
static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
 
6252
static const struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5951
6253
        {
5952
6254
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5953
6255
                .name = "Master Playback Switch",
5955
6257
                .info = snd_ctl_boolean_mono_info,
5956
6258
                .get = alc260_hp_master_sw_get,
5957
6259
                .put = alc260_hp_master_sw_put,
5958
 
                .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5959
6260
        },
5960
6261
        HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5961
6262
        HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5967
6268
        { } /* end */
5968
6269
};
5969
6270
 
5970
 
static struct hda_verb alc260_hp_unsol_verbs[] = {
 
6271
static const struct hda_verb alc260_hp_unsol_verbs[] = {
5971
6272
        {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5972
6273
        {},
5973
6274
};
5974
6275
 
5975
 
static void alc260_hp_automute(struct hda_codec *codec)
 
6276
static void alc260_hp_setup(struct hda_codec *codec)
5976
6277
{
5977
6278
        struct alc_spec *spec = codec->spec;
5978
6279
 
5979
 
        spec->jack_present = snd_hda_jack_detect(codec, 0x10);
5980
 
        alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5981
 
}
5982
 
 
5983
 
static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5984
 
{
5985
 
        if ((res >> 26) == ALC880_HP_EVENT)
5986
 
                alc260_hp_automute(codec);
5987
 
}
5988
 
 
5989
 
static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
 
6280
        spec->autocfg.hp_pins[0] = 0x0f;
 
6281
        spec->autocfg.speaker_pins[0] = 0x10;
 
6282
        spec->autocfg.speaker_pins[1] = 0x11;
 
6283
        spec->automute = 1;
 
6284
        spec->automute_mode = ALC_AUTOMUTE_PIN;
 
6285
}
 
6286
 
 
6287
static const struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
5990
6288
        {
5991
6289
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5992
6290
                .name = "Master Playback Switch",
5994
6292
                .info = snd_ctl_boolean_mono_info,
5995
6293
                .get = alc260_hp_master_sw_get,
5996
6294
                .put = alc260_hp_master_sw_put,
5997
 
                .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
5998
6295
        },
5999
6296
        HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6000
6297
        HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6007
6304
        { } /* end */
6008
6305
};
6009
6306
 
6010
 
static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
 
6307
static void alc260_hp_3013_setup(struct hda_codec *codec)
 
6308
{
 
6309
        struct alc_spec *spec = codec->spec;
 
6310
 
 
6311
        spec->autocfg.hp_pins[0] = 0x15;
 
6312
        spec->autocfg.speaker_pins[0] = 0x10;
 
6313
        spec->autocfg.speaker_pins[1] = 0x11;
 
6314
        spec->automute = 1;
 
6315
        spec->automute_mode = ALC_AUTOMUTE_PIN;
 
6316
}
 
6317
 
 
6318
static const struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
6011
6319
        .ops = &snd_hda_bind_vol,
6012
6320
        .values = {
6013
6321
                HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
6017
6325
        },
6018
6326
};
6019
6327
 
6020
 
static struct hda_bind_ctls alc260_dc7600_bind_switch = {
 
6328
static const struct hda_bind_ctls alc260_dc7600_bind_switch = {
6021
6329
        .ops = &snd_hda_bind_sw,
6022
6330
        .values = {
6023
6331
                HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6026
6334
        },
6027
6335
};
6028
6336
 
6029
 
static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
 
6337
static const struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6030
6338
        HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6031
6339
        HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6032
6340
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6034
6342
        { } /* end */
6035
6343
};
6036
6344
 
6037
 
static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
 
6345
static const struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6038
6346
        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6039
6347
        {},
6040
6348
};
6041
6349
 
6042
 
static void alc260_hp_3013_automute(struct hda_codec *codec)
 
6350
static void alc260_hp_3012_setup(struct hda_codec *codec)
6043
6351
{
6044
6352
        struct alc_spec *spec = codec->spec;
6045
6353
 
6046
 
        spec->jack_present = snd_hda_jack_detect(codec, 0x15);
6047
 
        alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
6048
 
}
6049
 
 
6050
 
static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6051
 
                                       unsigned int res)
6052
 
{
6053
 
        if ((res >> 26) == ALC880_HP_EVENT)
6054
 
                alc260_hp_3013_automute(codec);
6055
 
}
6056
 
 
6057
 
static void alc260_hp_3012_automute(struct hda_codec *codec)
6058
 
{
6059
 
        unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
6060
 
 
6061
 
        snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6062
 
                            bits);
6063
 
        snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6064
 
                            bits);
6065
 
        snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6066
 
                            bits);
6067
 
}
6068
 
 
6069
 
static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6070
 
                                       unsigned int res)
6071
 
{
6072
 
        if ((res >> 26) == ALC880_HP_EVENT)
6073
 
                alc260_hp_3012_automute(codec);
 
6354
        spec->autocfg.hp_pins[0] = 0x10;
 
6355
        spec->autocfg.speaker_pins[0] = 0x0f;
 
6356
        spec->autocfg.speaker_pins[1] = 0x11;
 
6357
        spec->autocfg.speaker_pins[2] = 0x15;
 
6358
        spec->automute = 1;
 
6359
        spec->automute_mode = ALC_AUTOMUTE_PIN;
6074
6360
}
6075
6361
 
6076
6362
/* Fujitsu S702x series laptops.  ALC260 pin usage: Mic/Line jack = 0x12,
6077
6363
 * HP jack = 0x14, CD audio =  0x16, internal speaker = 0x10.
6078
6364
 */
6079
 
static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
 
6365
static const struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
6080
6366
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6081
6367
        HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
6082
6368
        ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6113
6399
 * controls for such models.  On models without a "mono speaker" the control
6114
6400
 * won't do anything.
6115
6401
 */
6116
 
static struct snd_kcontrol_new alc260_acer_mixer[] = {
 
6402
static const struct snd_kcontrol_new alc260_acer_mixer[] = {
6117
6403
        HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6118
6404
        HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6119
6405
        ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6134
6420
 
6135
6421
/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6136
6422
 */
6137
 
static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
 
6423
static const struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6138
6424
        HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6139
6425
        HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6140
6426
        ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6147
6433
/* Packard bell V7900  ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6148
6434
 * Line In jack = 0x14, CD audio =  0x16, pc beep = 0x17.
6149
6435
 */
6150
 
static struct snd_kcontrol_new alc260_will_mixer[] = {
 
6436
static const struct snd_kcontrol_new alc260_will_mixer[] = {
6151
6437
        HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6152
6438
        HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6153
6439
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6164
6450
/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6165
6451
 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6166
6452
 */
6167
 
static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
 
6453
static const struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6168
6454
        HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6169
6455
        HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6170
6456
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6181
6467
/*
6182
6468
 * initialization verbs
6183
6469
 */
6184
 
static struct hda_verb alc260_init_verbs[] = {
 
6470
static const struct hda_verb alc260_init_verbs[] = {
6185
6471
        /* Line In pin widget for input */
6186
6472
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6187
6473
        /* CD pin widget for input */
6245
6531
};
6246
6532
 
6247
6533
#if 0 /* should be identical with alc260_init_verbs? */
6248
 
static struct hda_verb alc260_hp_init_verbs[] = {
 
6534
static const struct hda_verb alc260_hp_init_verbs[] = {
6249
6535
        /* Headphone and output */
6250
6536
        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6251
6537
        /* mono output */
6295
6581
};
6296
6582
#endif
6297
6583
 
6298
 
static struct hda_verb alc260_hp_3013_init_verbs[] = {
 
6584
static const struct hda_verb alc260_hp_3013_init_verbs[] = {
6299
6585
        /* Line out and output */
6300
6586
        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6301
6587
        /* mono output */
6348
6634
 * laptops.  ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6349
6635
 * audio = 0x16, internal speaker = 0x10.
6350
6636
 */
6351
 
static struct hda_verb alc260_fujitsu_init_verbs[] = {
 
6637
static const struct hda_verb alc260_fujitsu_init_verbs[] = {
6352
6638
        /* Disable all GPIOs */
6353
6639
        {0x01, AC_VERB_SET_GPIO_MASK, 0},
6354
6640
        /* Internal speaker is connected to headphone pin */
6430
6716
/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6431
6717
 * similar laptops (adapted from Fujitsu init verbs).
6432
6718
 */
6433
 
static struct hda_verb alc260_acer_init_verbs[] = {
 
6719
static const struct hda_verb alc260_acer_init_verbs[] = {
6434
6720
        /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6435
6721
         * the headphone jack.  Turn this on and rely on the standard mute
6436
6722
         * methods whenever the user wants to turn these outputs off.
6518
6804
/* Initialisation sequence for Maxdata Favorit 100XS
6519
6805
 * (adapted from Acer init verbs).
6520
6806
 */
6521
 
static struct hda_verb alc260_favorit100_init_verbs[] = {
 
6807
static const struct hda_verb alc260_favorit100_init_verbs[] = {
6522
6808
        /* GPIO 0 enables the output jack.
6523
6809
         * Turn this on and rely on the standard mute
6524
6810
         * methods whenever the user wants to turn these outputs off.
6598
6884
        { }
6599
6885
};
6600
6886
 
6601
 
static struct hda_verb alc260_will_verbs[] = {
 
6887
static const struct hda_verb alc260_will_verbs[] = {
6602
6888
        {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6603
6889
        {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6604
6890
        {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6608
6894
        {}
6609
6895
};
6610
6896
 
6611
 
static struct hda_verb alc260_replacer_672v_verbs[] = {
 
6897
static const struct hda_verb alc260_replacer_672v_verbs[] = {
6612
6898
        {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6613
6899
        {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6614
6900
        {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6650
6936
                alc260_replacer_672v_automute(codec);
6651
6937
}
6652
6938
 
6653
 
static struct hda_verb alc260_hp_dc7600_verbs[] = {
 
6939
static const struct hda_verb alc260_hp_dc7600_verbs[] = {
6654
6940
        {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6655
6941
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6656
6942
        {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6668
6954
 * configuration.
6669
6955
 */
6670
6956
#ifdef CONFIG_SND_DEBUG
6671
 
static hda_nid_t alc260_test_dac_nids[1] = {
 
6957
static const hda_nid_t alc260_test_dac_nids[1] = {
6672
6958
        0x02,
6673
6959
};
6674
 
static hda_nid_t alc260_test_adc_nids[2] = {
 
6960
static const hda_nid_t alc260_test_adc_nids[2] = {
6675
6961
        0x04, 0x05,
6676
6962
};
6677
6963
/* For testing the ALC260, each input MUX needs its own definition since
6678
6964
 * the signal assignments are different.  This assumes that the first ADC
6679
6965
 * is NID 0x04.
6680
6966
 */
6681
 
static struct hda_input_mux alc260_test_capture_sources[2] = {
 
6967
static const struct hda_input_mux alc260_test_capture_sources[2] = {
6682
6968
        {
6683
6969
                .num_items = 7,
6684
6970
                .items = {
6705
6991
                },
6706
6992
        },
6707
6993
};
6708
 
static struct snd_kcontrol_new alc260_test_mixer[] = {
 
6994
static const struct snd_kcontrol_new alc260_test_mixer[] = {
6709
6995
        /* Output driver widgets */
6710
6996
        HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6711
6997
        HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6769
7055
 
6770
7056
        { } /* end */
6771
7057
};
6772
 
static struct hda_verb alc260_test_init_verbs[] = {
 
7058
static const struct hda_verb alc260_test_init_verbs[] = {
6773
7059
        /* Enable all GPIOs as outputs with an initial value of 0 */
6774
7060
        {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6775
7061
        {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6907
7193
 
6908
7194
        spec->multiout.num_dacs = 1;
6909
7195
        spec->multiout.dac_nids = spec->private_dac_nids;
6910
 
        spec->multiout.dac_nids[0] = 0x02;
 
7196
        spec->private_dac_nids[0] = 0x02;
6911
7197
 
6912
7198
        nid = cfg->line_out_pins[0];
6913
7199
        if (nid) {
7005
7291
/*
7006
7292
 * generic initialization of ADC, input mixers and output mixers
7007
7293
 */
7008
 
static struct hda_verb alc260_volume_init_verbs[] = {
 
7294
static const struct hda_verb alc260_volume_init_verbs[] = {
7009
7295
        /*
7010
7296
         * Unmute ADC0-1 and set the default input to mic-in
7011
7297
         */
7050
7336
{
7051
7337
        struct alc_spec *spec = codec->spec;
7052
7338
        int err;
7053
 
        static hda_nid_t alc260_ignore[] = { 0x17, 0 };
 
7339
        static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
7054
7340
 
7055
7341
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7056
7342
                                           alc260_ignore);
7095
7381
}
7096
7382
 
7097
7383
#ifdef CONFIG_SND_HDA_POWER_SAVE
7098
 
static struct hda_amp_list alc260_loopbacks[] = {
 
7384
static const struct hda_amp_list alc260_loopbacks[] = {
7099
7385
        { 0x07, HDA_INPUT, 0 },
7100
7386
        { 0x07, HDA_INPUT, 1 },
7101
7387
        { 0x07, HDA_INPUT, 2 },
7122
7408
        },
7123
7409
};
7124
7410
 
7125
 
static struct snd_pci_quirk alc260_fixup_tbl[] = {
 
7411
static const struct snd_pci_quirk alc260_fixup_tbl[] = {
7126
7412
        SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7127
7413
        {}
7128
7414
};
7146
7432
        [ALC260_AUTO]           = "auto",
7147
7433
};
7148
7434
 
7149
 
static struct snd_pci_quirk alc260_cfg_tbl[] = {
 
7435
static const struct snd_pci_quirk alc260_cfg_tbl[] = {
7150
7436
        SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
7151
7437
        SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
7152
7438
        SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
7170
7456
        {}
7171
7457
};
7172
7458
 
7173
 
static struct alc_config_preset alc260_presets[] = {
 
7459
static const struct alc_config_preset alc260_presets[] = {
7174
7460
        [ALC260_BASIC] = {
7175
7461
                .mixers = { alc260_base_output_mixer,
7176
7462
                            alc260_input_mixer },
7195
7481
                .num_channel_mode = ARRAY_SIZE(alc260_modes),
7196
7482
                .channel_mode = alc260_modes,
7197
7483
                .input_mux = &alc260_capture_source,
7198
 
                .unsol_event = alc260_hp_unsol_event,
7199
 
                .init_hook = alc260_hp_automute,
 
7484
                .unsol_event = alc_sku_unsol_event,
 
7485
                .setup = alc260_hp_setup,
 
7486
                .init_hook = alc_inithook,
7200
7487
        },
7201
7488
        [ALC260_HP_DC7600] = {
7202
7489
                .mixers = { alc260_hp_dc7600_mixer,
7210
7497
                .num_channel_mode = ARRAY_SIZE(alc260_modes),
7211
7498
                .channel_mode = alc260_modes,
7212
7499
                .input_mux = &alc260_capture_source,
7213
 
                .unsol_event = alc260_hp_3012_unsol_event,
7214
 
                .init_hook = alc260_hp_3012_automute,
 
7500
                .unsol_event = alc_sku_unsol_event,
 
7501
                .setup = alc260_hp_3012_setup,
 
7502
                .init_hook = alc_inithook,
7215
7503
        },
7216
7504
        [ALC260_HP_3013] = {
7217
7505
                .mixers = { alc260_hp_3013_mixer,
7225
7513
                .num_channel_mode = ARRAY_SIZE(alc260_modes),
7226
7514
                .channel_mode = alc260_modes,
7227
7515
                .input_mux = &alc260_capture_source,
7228
 
                .unsol_event = alc260_hp_3013_unsol_event,
7229
 
                .init_hook = alc260_hp_3013_automute,
 
7516
                .unsol_event = alc_sku_unsol_event,
 
7517
                .setup = alc260_hp_3013_setup,
 
7518
                .init_hook = alc_inithook,
7230
7519
        },
7231
7520
        [ALC260_FUJITSU_S702X] = {
7232
7521
                .mixers = { alc260_fujitsu_mixer },
7384
7673
        codec->patch_ops = alc_patch_ops;
7385
7674
        if (board_config == ALC260_AUTO)
7386
7675
                spec->init_hook = alc260_auto_init;
 
7676
        spec->shutup = alc_eapd_shutup;
7387
7677
#ifdef CONFIG_SND_HDA_POWER_SAVE
7388
7678
        if (!spec->loopback.amplist)
7389
7679
                spec->loopback.amplist = alc260_loopbacks;
7411
7701
#define ALC1200_DIGOUT_NID      0x10
7412
7702
 
7413
7703
 
7414
 
static struct hda_channel_mode alc882_ch_modes[1] = {
 
7704
static const struct hda_channel_mode alc882_ch_modes[1] = {
7415
7705
        { 8, NULL }
7416
7706
};
7417
7707
 
7418
7708
/* DACs */
7419
 
static hda_nid_t alc882_dac_nids[4] = {
 
7709
static const hda_nid_t alc882_dac_nids[4] = {
7420
7710
        /* front, rear, clfe, rear_surr */
7421
7711
        0x02, 0x03, 0x04, 0x05
7422
7712
};
7426
7716
#define alc882_adc_nids         alc880_adc_nids
7427
7717
#define alc882_adc_nids_alt     alc880_adc_nids_alt
7428
7718
#define alc883_adc_nids         alc882_adc_nids_alt
7429
 
static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7430
 
static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
 
7719
static const hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
 
7720
static const hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7431
7721
#define alc889_adc_nids         alc880_adc_nids
7432
7722
 
7433
 
static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7434
 
static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
 
7723
static const hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
 
7724
static const hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
7435
7725
#define alc883_capsrc_nids      alc882_capsrc_nids_alt
7436
 
static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
 
7726
static const hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7437
7727
#define alc889_capsrc_nids      alc882_capsrc_nids
7438
7728
 
7439
7729
/* input MUX */
7440
7730
/* FIXME: should be a matrix-type input source selection */
7441
7731
 
7442
 
static struct hda_input_mux alc882_capture_source = {
 
7732
static const struct hda_input_mux alc882_capture_source = {
7443
7733
        .num_items = 4,
7444
7734
        .items = {
7445
7735
                { "Mic", 0x0 },
7451
7741
 
7452
7742
#define alc883_capture_source   alc882_capture_source
7453
7743
 
7454
 
static struct hda_input_mux alc889_capture_source = {
 
7744
static const struct hda_input_mux alc889_capture_source = {
7455
7745
        .num_items = 3,
7456
7746
        .items = {
7457
7747
                { "Front Mic", 0x0 },
7460
7750
        },
7461
7751
};
7462
7752
 
7463
 
static struct hda_input_mux mb5_capture_source = {
 
7753
static const struct hda_input_mux mb5_capture_source = {
7464
7754
        .num_items = 3,
7465
7755
        .items = {
7466
7756
                { "Mic", 0x1 },
7469
7759
        },
7470
7760
};
7471
7761
 
7472
 
static struct hda_input_mux macmini3_capture_source = {
 
7762
static const struct hda_input_mux macmini3_capture_source = {
7473
7763
        .num_items = 2,
7474
7764
        .items = {
7475
7765
                { "Line", 0x2 },
7477
7767
        },
7478
7768
};
7479
7769
 
7480
 
static struct hda_input_mux alc883_3stack_6ch_intel = {
 
7770
static const struct hda_input_mux alc883_3stack_6ch_intel = {
7481
7771
        .num_items = 4,
7482
7772
        .items = {
7483
7773
                { "Mic", 0x1 },
7487
7777
        },
7488
7778
};
7489
7779
 
7490
 
static struct hda_input_mux alc883_lenovo_101e_capture_source = {
 
7780
static const struct hda_input_mux alc883_lenovo_101e_capture_source = {
7491
7781
        .num_items = 2,
7492
7782
        .items = {
7493
7783
                { "Mic", 0x1 },
7495
7785
        },
7496
7786
};
7497
7787
 
7498
 
static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
 
7788
static const struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7499
7789
        .num_items = 4,
7500
7790
        .items = {
7501
7791
                { "Mic", 0x0 },
7505
7795
        },
7506
7796
};
7507
7797
 
7508
 
static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
 
7798
static const struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7509
7799
        .num_items = 2,
7510
7800
        .items = {
7511
7801
                { "Mic", 0x0 },
7513
7803
        },
7514
7804
};
7515
7805
 
7516
 
static struct hda_input_mux alc883_lenovo_sky_capture_source = {
 
7806
static const struct hda_input_mux alc883_lenovo_sky_capture_source = {
7517
7807
        .num_items = 3,
7518
7808
        .items = {
7519
7809
                { "Mic", 0x0 },
7522
7812
        },
7523
7813
};
7524
7814
 
7525
 
static struct hda_input_mux alc883_asus_eee1601_capture_source = {
 
7815
static const struct hda_input_mux alc883_asus_eee1601_capture_source = {
7526
7816
        .num_items = 2,
7527
7817
        .items = {
7528
7818
                { "Mic", 0x0 },
7530
7820
        },
7531
7821
};
7532
7822
 
7533
 
static struct hda_input_mux alc889A_mb31_capture_source = {
 
7823
static const struct hda_input_mux alc889A_mb31_capture_source = {
7534
7824
        .num_items = 2,
7535
7825
        .items = {
7536
7826
                { "Mic", 0x0 },
7541
7831
        },
7542
7832
};
7543
7833
 
7544
 
static struct hda_input_mux alc889A_imac91_capture_source = {
 
7834
static const struct hda_input_mux alc889A_imac91_capture_source = {
7545
7835
        .num_items = 2,
7546
7836
        .items = {
7547
7837
                { "Mic", 0x01 },
7552
7842
/*
7553
7843
 * 2ch mode
7554
7844
 */
7555
 
static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
 
7845
static const struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7556
7846
        { 2, NULL }
7557
7847
};
7558
7848
 
7559
7849
/*
7560
7850
 * 2ch mode
7561
7851
 */
7562
 
static struct hda_verb alc882_3ST_ch2_init[] = {
 
7852
static const struct hda_verb alc882_3ST_ch2_init[] = {
7563
7853
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7564
7854
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7565
7855
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7570
7860
/*
7571
7861
 * 4ch mode
7572
7862
 */
7573
 
static struct hda_verb alc882_3ST_ch4_init[] = {
 
7863
static const struct hda_verb alc882_3ST_ch4_init[] = {
7574
7864
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7575
7865
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7576
7866
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7582
7872
/*
7583
7873
 * 6ch mode
7584
7874
 */
7585
 
static struct hda_verb alc882_3ST_ch6_init[] = {
 
7875
static const struct hda_verb alc882_3ST_ch6_init[] = {
7586
7876
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7587
7877
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7588
7878
        { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7592
7882
        { } /* end */
7593
7883
};
7594
7884
 
7595
 
static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
 
7885
static const struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
7596
7886
        { 2, alc882_3ST_ch2_init },
7597
7887
        { 4, alc882_3ST_ch4_init },
7598
7888
        { 6, alc882_3ST_ch6_init },
7603
7893
/*
7604
7894
 * 2ch mode
7605
7895
 */
7606
 
static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
 
7896
static const struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7607
7897
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7608
7898
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7609
7899
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7615
7905
/*
7616
7906
 * 4ch mode
7617
7907
 */
7618
 
static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
 
7908
static const struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7619
7909
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7620
7910
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7621
7911
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7628
7918
/*
7629
7919
 * 6ch mode
7630
7920
 */
7631
 
static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
 
7921
static const struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7632
7922
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7633
7923
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7634
7924
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7639
7929
        { } /* end */
7640
7930
};
7641
7931
 
7642
 
static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
 
7932
static const struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7643
7933
        { 2, alc883_3ST_ch2_clevo_init },
7644
7934
        { 4, alc883_3ST_ch4_clevo_init },
7645
7935
        { 6, alc883_3ST_ch6_clevo_init },
7649
7939
/*
7650
7940
 * 6ch mode
7651
7941
 */
7652
 
static struct hda_verb alc882_sixstack_ch6_init[] = {
 
7942
static const struct hda_verb alc882_sixstack_ch6_init[] = {
7653
7943
        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7654
7944
        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7655
7945
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7660
7950
/*
7661
7951
 * 8ch mode
7662
7952
 */
7663
 
static struct hda_verb alc882_sixstack_ch8_init[] = {
 
7953
static const struct hda_verb alc882_sixstack_ch8_init[] = {
7664
7954
        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7665
7955
        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7666
7956
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7668
7958
        { } /* end */
7669
7959
};
7670
7960
 
7671
 
static struct hda_channel_mode alc882_sixstack_modes[2] = {
 
7961
static const struct hda_channel_mode alc882_sixstack_modes[2] = {
7672
7962
        { 6, alc882_sixstack_ch6_init },
7673
7963
        { 8, alc882_sixstack_ch8_init },
7674
7964
};
7676
7966
 
7677
7967
/* Macbook Air 2,1 */
7678
7968
 
7679
 
static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
 
7969
static const struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7680
7970
      { 2, NULL },
7681
7971
};
7682
7972
 
7687
7977
/*
7688
7978
 * 2ch mode
7689
7979
 */
7690
 
static struct hda_verb alc885_mbp_ch2_init[] = {
 
7980
static const struct hda_verb alc885_mbp_ch2_init[] = {
7691
7981
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7692
7982
        { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7693
7983
        { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7697
7987
/*
7698
7988
 * 4ch mode
7699
7989
 */
7700
 
static struct hda_verb alc885_mbp_ch4_init[] = {
 
7990
static const struct hda_verb alc885_mbp_ch4_init[] = {
7701
7991
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7702
7992
        { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7703
7993
        { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7706
7996
        { } /* end */
7707
7997
};
7708
7998
 
7709
 
static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
 
7999
static const struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
7710
8000
        { 2, alc885_mbp_ch2_init },
7711
8001
        { 4, alc885_mbp_ch4_init },
7712
8002
};
7716
8006
 * Speakers/Woofer/HP = Front
7717
8007
 * LineIn = Input
7718
8008
 */
7719
 
static struct hda_verb alc885_mb5_ch2_init[] = {
 
8009
static const struct hda_verb alc885_mb5_ch2_init[] = {
7720
8010
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7721
8011
        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7722
8012
        { } /* end */
7728
8018
 * Woofer = LFE
7729
8019
 * LineIn = Surround
7730
8020
 */
7731
 
static struct hda_verb alc885_mb5_ch6_init[] = {
 
8021
static const struct hda_verb alc885_mb5_ch6_init[] = {
7732
8022
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7733
8023
        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7734
8024
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7735
8025
        { } /* end */
7736
8026
};
7737
8027
 
7738
 
static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
 
8028
static const struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7739
8029
        { 2, alc885_mb5_ch2_init },
7740
8030
        { 6, alc885_mb5_ch6_init },
7741
8031
};
7745
8035
/*
7746
8036
 * 2ch mode
7747
8037
 */
7748
 
static struct hda_verb alc883_4ST_ch2_init[] = {
 
8038
static const struct hda_verb alc883_4ST_ch2_init[] = {
7749
8039
        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7750
8040
        { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7751
8041
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7758
8048
/*
7759
8049
 * 4ch mode
7760
8050
 */
7761
 
static struct hda_verb alc883_4ST_ch4_init[] = {
 
8051
static const struct hda_verb alc883_4ST_ch4_init[] = {
7762
8052
        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7763
8053
        { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7764
8054
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7772
8062
/*
7773
8063
 * 6ch mode
7774
8064
 */
7775
 
static struct hda_verb alc883_4ST_ch6_init[] = {
 
8065
static const struct hda_verb alc883_4ST_ch6_init[] = {
7776
8066
        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7777
8067
        { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7778
8068
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7787
8077
/*
7788
8078
 * 8ch mode
7789
8079
 */
7790
 
static struct hda_verb alc883_4ST_ch8_init[] = {
 
8080
static const struct hda_verb alc883_4ST_ch8_init[] = {
7791
8081
        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7792
8082
        { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7793
8083
        { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7800
8090
        { } /* end */
7801
8091
};
7802
8092
 
7803
 
static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
 
8093
static const struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7804
8094
        { 2, alc883_4ST_ch2_init },
7805
8095
        { 4, alc883_4ST_ch4_init },
7806
8096
        { 6, alc883_4ST_ch6_init },
7811
8101
/*
7812
8102
 * 2ch mode
7813
8103
 */
7814
 
static struct hda_verb alc883_3ST_ch2_intel_init[] = {
 
8104
static const struct hda_verb alc883_3ST_ch2_intel_init[] = {
7815
8105
        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7816
8106
        { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7817
8107
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7822
8112
/*
7823
8113
 * 4ch mode
7824
8114
 */
7825
 
static struct hda_verb alc883_3ST_ch4_intel_init[] = {
 
8115
static const struct hda_verb alc883_3ST_ch4_intel_init[] = {
7826
8116
        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7827
8117
        { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7828
8118
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7834
8124
/*
7835
8125
 * 6ch mode
7836
8126
 */
7837
 
static struct hda_verb alc883_3ST_ch6_intel_init[] = {
 
8127
static const struct hda_verb alc883_3ST_ch6_intel_init[] = {
7838
8128
        { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7839
8129
        { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7840
8130
        { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7844
8134
        { } /* end */
7845
8135
};
7846
8136
 
7847
 
static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
 
8137
static const struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7848
8138
        { 2, alc883_3ST_ch2_intel_init },
7849
8139
        { 4, alc883_3ST_ch4_intel_init },
7850
8140
        { 6, alc883_3ST_ch6_intel_init },
7853
8143
/*
7854
8144
 * 2ch mode
7855
8145
 */
7856
 
static struct hda_verb alc889_ch2_intel_init[] = {
 
8146
static const struct hda_verb alc889_ch2_intel_init[] = {
7857
8147
        { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7858
8148
        { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7859
8149
        { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7866
8156
/*
7867
8157
 * 6ch mode
7868
8158
 */
7869
 
static struct hda_verb alc889_ch6_intel_init[] = {
 
8159
static const struct hda_verb alc889_ch6_intel_init[] = {
7870
8160
        { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7871
8161
        { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7872
8162
        { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7879
8169
/*
7880
8170
 * 8ch mode
7881
8171
 */
7882
 
static struct hda_verb alc889_ch8_intel_init[] = {
 
8172
static const struct hda_verb alc889_ch8_intel_init[] = {
7883
8173
        { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7884
8174
        { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7885
8175
        { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7890
8180
        { } /* end */
7891
8181
};
7892
8182
 
7893
 
static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
 
8183
static const struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7894
8184
        { 2, alc889_ch2_intel_init },
7895
8185
        { 6, alc889_ch6_intel_init },
7896
8186
        { 8, alc889_ch8_intel_init },
7899
8189
/*
7900
8190
 * 6ch mode
7901
8191
 */
7902
 
static struct hda_verb alc883_sixstack_ch6_init[] = {
 
8192
static const struct hda_verb alc883_sixstack_ch6_init[] = {
7903
8193
        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7904
8194
        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7905
8195
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7910
8200
/*
7911
8201
 * 8ch mode
7912
8202
 */
7913
 
static struct hda_verb alc883_sixstack_ch8_init[] = {
 
8203
static const struct hda_verb alc883_sixstack_ch8_init[] = {
7914
8204
        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7915
8205
        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7916
8206
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7918
8208
        { } /* end */
7919
8209
};
7920
8210
 
7921
 
static struct hda_channel_mode alc883_sixstack_modes[2] = {
 
8211
static const struct hda_channel_mode alc883_sixstack_modes[2] = {
7922
8212
        { 6, alc883_sixstack_ch6_init },
7923
8213
        { 8, alc883_sixstack_ch8_init },
7924
8214
};
7927
8217
/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7928
8218
 *                 Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7929
8219
 */
7930
 
static struct snd_kcontrol_new alc882_base_mixer[] = {
 
8220
static const struct snd_kcontrol_new alc882_base_mixer[] = {
7931
8221
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7932
8222
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7933
8223
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7954
8244
 
7955
8245
/* Macbook Air 2,1 same control for HP and internal Speaker */
7956
8246
 
7957
 
static struct snd_kcontrol_new alc885_mba21_mixer[] = {
 
8247
static const struct snd_kcontrol_new alc885_mba21_mixer[] = {
7958
8248
      HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7959
8249
      HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7960
8250
     { }
7961
8251
};
7962
8252
 
7963
8253
 
7964
 
static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
 
8254
static const struct snd_kcontrol_new alc885_mbp3_mixer[] = {
7965
8255
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7966
8256
        HDA_BIND_MUTE   ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7967
8257
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7976
8266
        { } /* end */
7977
8267
};
7978
8268
 
7979
 
static struct snd_kcontrol_new alc885_mb5_mixer[] = {
 
8269
static const struct snd_kcontrol_new alc885_mb5_mixer[] = {
7980
8270
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7981
8271
        HDA_BIND_MUTE   ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7982
8272
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7994
8284
        { } /* end */
7995
8285
};
7996
8286
 
7997
 
static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
 
8287
static const struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7998
8288
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7999
8289
        HDA_BIND_MUTE   ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8000
8290
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8009
8299
        { } /* end */
8010
8300
};
8011
8301
 
8012
 
static struct snd_kcontrol_new alc885_imac91_mixer[] = {
 
8302
static const struct snd_kcontrol_new alc885_imac91_mixer[] = {
8013
8303
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8014
8304
        HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
8015
8305
        { } /* end */
8016
8306
};
8017
8307
 
8018
8308
 
8019
 
static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
 
8309
static const struct snd_kcontrol_new alc882_w2jc_mixer[] = {
8020
8310
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8021
8311
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8022
8312
        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8029
8319
        { } /* end */
8030
8320
};
8031
8321
 
8032
 
static struct snd_kcontrol_new alc882_targa_mixer[] = {
 
8322
static const struct snd_kcontrol_new alc882_targa_mixer[] = {
8033
8323
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8034
8324
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8035
8325
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8049
8339
/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8050
8340
 *                 Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8051
8341
 */
8052
 
static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
 
8342
static const struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8053
8343
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8054
8344
        HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8055
8345
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8066
8356
        { } /* end */
8067
8357
};
8068
8358
 
8069
 
static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
 
8359
static const struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8070
8360
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8071
8361
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8072
8362
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8080
8370
        { } /* end */
8081
8371
};
8082
8372
 
8083
 
static struct snd_kcontrol_new alc882_chmode_mixer[] = {
 
8373
static const struct snd_kcontrol_new alc882_chmode_mixer[] = {
8084
8374
        {
8085
8375
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8086
8376
                .name = "Channel Mode",
8091
8381
        { } /* end */
8092
8382
};
8093
8383
 
8094
 
static struct hda_verb alc882_base_init_verbs[] = {
 
8384
static const struct hda_verb alc882_base_init_verbs[] = {
8095
8385
        /* Front mixer: unmute input/output amp left and right (volume = 0) */
8096
8386
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8097
8387
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8153
8443
        { }
8154
8444
};
8155
8445
 
8156
 
static struct hda_verb alc882_adc1_init_verbs[] = {
 
8446
static const struct hda_verb alc882_adc1_init_verbs[] = {
8157
8447
        /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8158
8448
        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8159
8449
        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8165
8455
        { }
8166
8456
};
8167
8457
 
8168
 
static struct hda_verb alc882_eapd_verbs[] = {
 
8458
static const struct hda_verb alc882_eapd_verbs[] = {
8169
8459
        /* change to EAPD mode */
8170
8460
        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8171
8461
        {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
8172
8462
        { }
8173
8463
};
8174
8464
 
8175
 
static struct hda_verb alc889_eapd_verbs[] = {
 
8465
static const struct hda_verb alc889_eapd_verbs[] = {
8176
8466
        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8177
8467
        {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8178
8468
        { }
8179
8469
};
8180
8470
 
8181
 
static struct hda_verb alc_hp15_unsol_verbs[] = {
 
8471
static const struct hda_verb alc_hp15_unsol_verbs[] = {
8182
8472
        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8183
8473
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8184
8474
        {}
8185
8475
};
8186
8476
 
8187
 
static struct hda_verb alc885_init_verbs[] = {
 
8477
static const struct hda_verb alc885_init_verbs[] = {
8188
8478
        /* Front mixer: unmute input/output amp left and right (volume = 0) */
8189
8479
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8190
8480
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8243
8533
        { }
8244
8534
};
8245
8535
 
8246
 
static struct hda_verb alc885_init_input_verbs[] = {
 
8536
static const struct hda_verb alc885_init_input_verbs[] = {
8247
8537
        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8248
8538
        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8249
8539
        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8252
8542
 
8253
8543
 
8254
8544
/* Unmute Selector 24h and set the default input to front mic */
8255
 
static struct hda_verb alc889_init_input_verbs[] = {
 
8545
static const struct hda_verb alc889_init_input_verbs[] = {
8256
8546
        {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8257
8547
        {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8258
8548
        { }
8262
8552
#define alc883_init_verbs       alc882_base_init_verbs
8263
8553
 
8264
8554
/* Mac Pro test */
8265
 
static struct snd_kcontrol_new alc882_macpro_mixer[] = {
 
8555
static const struct snd_kcontrol_new alc882_macpro_mixer[] = {
8266
8556
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8267
8557
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8268
8558
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8275
8565
        { } /* end */
8276
8566
};
8277
8567
 
8278
 
static struct hda_verb alc882_macpro_init_verbs[] = {
 
8568
static const struct hda_verb alc882_macpro_init_verbs[] = {
8279
8569
        /* Front mixer: unmute input/output amp left and right (volume = 0) */
8280
8570
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8281
8571
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8327
8617
};
8328
8618
 
8329
8619
/* Macbook 5,1 */
8330
 
static struct hda_verb alc885_mb5_init_verbs[] = {
 
8620
static const struct hda_verb alc885_mb5_init_verbs[] = {
8331
8621
        /* DACs */
8332
8622
        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8333
8623
        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8376
8666
};
8377
8667
 
8378
8668
/* Macmini 3,1 */
8379
 
static struct hda_verb alc885_macmini3_init_verbs[] = {
 
8669
static const struct hda_verb alc885_macmini3_init_verbs[] = {
8380
8670
        /* DACs */
8381
8671
        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8382
8672
        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8423
8713
};
8424
8714
 
8425
8715
 
8426
 
static struct hda_verb alc885_mba21_init_verbs[] = {
 
8716
static const struct hda_verb alc885_mba21_init_verbs[] = {
8427
8717
        /*Internal and HP Speaker Mixer*/
8428
8718
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8429
8719
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8446
8736
 
8447
8737
 
8448
8738
/* Macbook Pro rev3 */
8449
 
static struct hda_verb alc885_mbp3_init_verbs[] = {
 
8739
static const struct hda_verb alc885_mbp3_init_verbs[] = {
8450
8740
        /* Front mixer: unmute input/output amp left and right (volume = 0) */
8451
8741
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8452
8742
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8510
8800
};
8511
8801
 
8512
8802
/* iMac 9,1 */
8513
 
static struct hda_verb alc885_imac91_init_verbs[] = {
 
8803
static const struct hda_verb alc885_imac91_init_verbs[] = {
8514
8804
        /* Internal Speaker Pin (0x0c) */
8515
8805
        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8516
8806
        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8565
8855
};
8566
8856
 
8567
8857
/* iMac 24 mixer. */
8568
 
static struct snd_kcontrol_new alc885_imac24_mixer[] = {
 
8858
static const struct snd_kcontrol_new alc885_imac24_mixer[] = {
8569
8859
        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8570
8860
        HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8571
8861
        { } /* end */
8572
8862
};
8573
8863
 
8574
8864
/* iMac 24 init verbs. */
8575
 
static struct hda_verb alc885_imac24_init_verbs[] = {
 
8865
static const struct hda_verb alc885_imac24_init_verbs[] = {
8576
8866
        /* Internal speakers: output 0 (0x0c) */
8577
8867
        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8578
8868
        {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8600
8890
        spec->autocfg.hp_pins[0] = 0x14;
8601
8891
        spec->autocfg.speaker_pins[0] = 0x18;
8602
8892
        spec->autocfg.speaker_pins[1] = 0x1a;
 
8893
        spec->automute = 1;
 
8894
        spec->automute_mode = ALC_AUTOMUTE_AMP;
8603
8895
}
8604
8896
 
8605
8897
#define alc885_mb5_setup        alc885_imac24_setup
8612
8904
 
8613
8905
       spec->autocfg.hp_pins[0] = 0x14;
8614
8906
       spec->autocfg.speaker_pins[0] = 0x18;
 
8907
        spec->automute = 1;
 
8908
        spec->automute_mode = ALC_AUTOMUTE_AMP;
8615
8909
}
8616
8910
 
8617
8911
 
8622
8916
 
8623
8917
        spec->autocfg.hp_pins[0] = 0x15;
8624
8918
        spec->autocfg.speaker_pins[0] = 0x14;
 
8919
        spec->automute = 1;
 
8920
        spec->automute_mode = ALC_AUTOMUTE_AMP;
8625
8921
}
8626
8922
 
8627
8923
static void alc885_imac91_setup(struct hda_codec *codec)
8631
8927
        spec->autocfg.hp_pins[0] = 0x14;
8632
8928
        spec->autocfg.speaker_pins[0] = 0x18;
8633
8929
        spec->autocfg.speaker_pins[1] = 0x1a;
 
8930
        spec->automute = 1;
 
8931
        spec->automute_mode = ALC_AUTOMUTE_AMP;
8634
8932
}
8635
8933
 
8636
 
static struct hda_verb alc882_targa_verbs[] = {
 
8934
static const struct hda_verb alc882_targa_verbs[] = {
8637
8935
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8638
8936
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8639
8937
 
8652
8950
static void alc882_targa_automute(struct hda_codec *codec)
8653
8951
{
8654
8952
        struct alc_spec *spec = codec->spec;
8655
 
        alc_automute_amp(codec);
 
8953
        alc_hp_automute(codec);
8656
8954
        snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8657
8955
                                  spec->jack_present ? 1 : 3);
8658
8956
}
8663
8961
 
8664
8962
        spec->autocfg.hp_pins[0] = 0x14;
8665
8963
        spec->autocfg.speaker_pins[0] = 0x1b;
 
8964
        spec->automute = 1;
 
8965
        spec->automute_mode = ALC_AUTOMUTE_AMP;
8666
8966
}
8667
8967
 
8668
8968
static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8671
8971
                alc882_targa_automute(codec);
8672
8972
}
8673
8973
 
8674
 
static struct hda_verb alc882_asus_a7j_verbs[] = {
 
8974
static const struct hda_verb alc882_asus_a7j_verbs[] = {
8675
8975
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8676
8976
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8677
8977
 
8689
8989
        { } /* end */
8690
8990
};
8691
8991
 
8692
 
static struct hda_verb alc882_asus_a7m_verbs[] = {
 
8992
static const struct hda_verb alc882_asus_a7m_verbs[] = {
8693
8993
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8694
8994
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8695
8995
 
8750
9050
static void alc885_imac24_init_hook(struct hda_codec *codec)
8751
9051
{
8752
9052
        alc885_macpro_init_hook(codec);
8753
 
        alc_automute_amp(codec);
 
9053
        alc_hp_automute(codec);
8754
9054
}
8755
9055
 
8756
9056
/*
8757
9057
 * generic initialization of ADC, input mixers and output mixers
8758
9058
 */
8759
 
static struct hda_verb alc883_auto_init_verbs[] = {
 
9059
static const struct hda_verb alc883_auto_init_verbs[] = {
8760
9060
        /*
8761
9061
         * Unmute ADC0-2 and set the default input to mic-in
8762
9062
         */
8796
9096
};
8797
9097
 
8798
9098
/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8799
 
static struct hda_verb alc889A_mb31_ch2_init[] = {
 
9099
static const struct hda_verb alc889A_mb31_ch2_init[] = {
8800
9100
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},             /* HP as front */
8801
9101
        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8802
9102
        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},    /* Line as input */
8805
9105
};
8806
9106
 
8807
9107
/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8808
 
static struct hda_verb alc889A_mb31_ch4_init[] = {
 
9108
static const struct hda_verb alc889A_mb31_ch4_init[] = {
8809
9109
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},             /* HP as front */
8810
9110
        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8811
9111
        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},   /* Line as output */
8814
9114
};
8815
9115
 
8816
9116
/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8817
 
static struct hda_verb alc889A_mb31_ch5_init[] = {
 
9117
static const struct hda_verb alc889A_mb31_ch5_init[] = {
8818
9118
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},             /* HP as rear */
8819
9119
        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8820
9120
        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},    /* Line as input */
8823
9123
};
8824
9124
 
8825
9125
/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8826
 
static struct hda_verb alc889A_mb31_ch6_init[] = {
 
9126
static const struct hda_verb alc889A_mb31_ch6_init[] = {
8827
9127
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},             /* HP as front */
8828
9128
        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},   /* Subwoofer off */
8829
9129
        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},   /* Line as output */
8831
9131
        { } /* end */
8832
9132
};
8833
9133
 
8834
 
static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
 
9134
static const struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8835
9135
        { 2, alc889A_mb31_ch2_init },
8836
9136
        { 4, alc889A_mb31_ch4_init },
8837
9137
        { 5, alc889A_mb31_ch5_init },
8838
9138
        { 6, alc889A_mb31_ch6_init },
8839
9139
};
8840
9140
 
8841
 
static struct hda_verb alc883_medion_eapd_verbs[] = {
 
9141
static const struct hda_verb alc883_medion_eapd_verbs[] = {
8842
9142
        /* eanable EAPD on medion laptop */
8843
9143
        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8844
9144
        {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8847
9147
 
8848
9148
#define alc883_base_mixer       alc882_base_mixer
8849
9149
 
8850
 
static struct snd_kcontrol_new alc883_mitac_mixer[] = {
 
9150
static const struct snd_kcontrol_new alc883_mitac_mixer[] = {
8851
9151
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8852
9152
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8853
9153
        HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8864
9164
        { } /* end */
8865
9165
};
8866
9166
 
8867
 
static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
8868
 
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8869
 
        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8870
 
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8871
 
        HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8872
 
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8873
 
        HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
8874
 
        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8875
 
        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8876
 
        HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
8877
 
        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8878
 
        { } /* end */
8879
 
};
8880
 
 
8881
 
static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8882
 
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8883
 
        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8884
 
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8885
 
        HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8886
 
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8887
 
        HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
8888
 
        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8889
 
        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8890
 
        HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
8891
 
        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8892
 
        { } /* end */
8893
 
};
8894
 
 
8895
 
static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
 
9167
static const struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
 
9168
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
 
9169
        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
 
9170
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
 
9171
        HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
 
9172
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
 
9173
        HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
 
9174
        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
 
9175
        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
 
9176
        HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
 
9177
        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
 
9178
        { } /* end */
 
9179
};
 
9180
 
 
9181
static const struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
 
9182
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
 
9183
        HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
 
9184
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
 
9185
        HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
 
9186
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
 
9187
        HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
 
9188
        HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
 
9189
        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
 
9190
        HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
 
9191
        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
 
9192
        { } /* end */
 
9193
};
 
9194
 
 
9195
static const struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8896
9196
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8897
9197
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8898
9198
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8909
9209
        { } /* end */
8910
9210
};
8911
9211
 
8912
 
static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
 
9212
static const struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8913
9213
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8914
9214
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8915
9215
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8932
9232
        { } /* end */
8933
9233
};
8934
9234
 
8935
 
static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
 
9235
static const struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8936
9236
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8937
9237
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8938
9238
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8956
9256
        { } /* end */
8957
9257
};
8958
9258
 
8959
 
static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
 
9259
static const struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8960
9260
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8961
9261
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8962
9262
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8980
9280
        { } /* end */
8981
9281
};
8982
9282
 
8983
 
static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
 
9283
static const struct snd_kcontrol_new alc883_fivestack_mixer[] = {
8984
9284
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8985
9285
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8986
9286
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9003
9303
        { } /* end */
9004
9304
};
9005
9305
 
9006
 
static struct snd_kcontrol_new alc883_targa_mixer[] = {
 
9306
static const struct snd_kcontrol_new alc883_targa_mixer[] = {
9007
9307
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9008
9308
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9009
9309
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9024
9324
        { } /* end */
9025
9325
};
9026
9326
 
9027
 
static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
 
9327
static const struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
9028
9328
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9029
9329
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9030
9330
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9040
9340
        { } /* end */
9041
9341
};
9042
9342
 
9043
 
static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
 
9343
static const struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9044
9344
        HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9045
9345
        HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9046
9346
        HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9049
9349
        { } /* end */
9050
9350
};
9051
9351
 
9052
 
static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
 
9352
static const struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9053
9353
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9054
9354
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9055
9355
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9061
9361
        { } /* end */
9062
9362
};
9063
9363
 
9064
 
static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
 
9364
static const struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9065
9365
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9066
9366
        HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9067
9367
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9074
9374
        { } /* end */
9075
9375
};
9076
9376
 
9077
 
static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
 
9377
static const struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9078
9378
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9079
9379
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9080
9380
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9084
9384
        { } /* end */
9085
9385
};
9086
9386
 
9087
 
static struct hda_verb alc883_medion_wim2160_verbs[] = {
 
9387
static const struct hda_verb alc883_medion_wim2160_verbs[] = {
9088
9388
        /* Unmute front mixer */
9089
9389
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9090
9390
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9108
9408
 
9109
9409
        spec->autocfg.hp_pins[0] = 0x1a;
9110
9410
        spec->autocfg.speaker_pins[0] = 0x15;
 
9411
        spec->automute = 1;
 
9412
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9111
9413
}
9112
9414
 
9113
 
static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
 
9415
static const struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
9114
9416
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9115
9417
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9116
9418
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9122
9424
        { } /* end */
9123
9425
};
9124
9426
 
9125
 
static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
 
9427
static const struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9126
9428
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9127
9429
        HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9128
9430
        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9135
9437
        { } /* end */
9136
9438
};
9137
9439
 
9138
 
static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
 
9440
static const struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9139
9441
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9140
9442
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9141
9443
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9160
9462
        { } /* end */
9161
9463
};
9162
9464
 
9163
 
static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
 
9465
static const struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9164
9466
        /* Output mixers */
9165
9467
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9166
9468
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9186
9488
        { } /* end */
9187
9489
};
9188
9490
 
9189
 
static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
 
9491
static const struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9190
9492
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9191
9493
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9192
9494
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9196
9498
        { } /* end */
9197
9499
};
9198
9500
 
9199
 
static struct hda_bind_ctls alc883_bind_cap_vol = {
 
9501
static const struct hda_bind_ctls alc883_bind_cap_vol = {
9200
9502
        .ops = &snd_hda_bind_vol,
9201
9503
        .values = {
9202
9504
                HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9205
9507
        },
9206
9508
};
9207
9509
 
9208
 
static struct hda_bind_ctls alc883_bind_cap_switch = {
 
9510
static const struct hda_bind_ctls alc883_bind_cap_switch = {
9209
9511
        .ops = &snd_hda_bind_sw,
9210
9512
        .values = {
9211
9513
                HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9214
9516
        },
9215
9517
};
9216
9518
 
9217
 
static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
 
9519
static const struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9218
9520
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9219
9521
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9220
9522
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9226
9528
        { } /* end */
9227
9529
};
9228
9530
 
9229
 
static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
 
9531
static const struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
9230
9532
        HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9231
9533
        HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9232
9534
        {
9241
9543
        { } /* end */
9242
9544
};
9243
9545
 
9244
 
static struct snd_kcontrol_new alc883_chmode_mixer[] = {
 
9546
static const struct snd_kcontrol_new alc883_chmode_mixer[] = {
9245
9547
        {
9246
9548
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9247
9549
                .name = "Channel Mode",
9260
9562
        spec->autocfg.hp_pins[0] = 0x15;
9261
9563
        spec->autocfg.speaker_pins[0] = 0x14;
9262
9564
        spec->autocfg.speaker_pins[1] = 0x17;
 
9565
        spec->automute = 1;
 
9566
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9263
9567
}
9264
9568
 
9265
 
static struct hda_verb alc883_mitac_verbs[] = {
 
9569
static const struct hda_verb alc883_mitac_verbs[] = {
9266
9570
        /* HP */
9267
9571
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9268
9572
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9277
9581
        { } /* end */
9278
9582
};
9279
9583
 
9280
 
static struct hda_verb alc883_clevo_m540r_verbs[] = {
 
9584
static const struct hda_verb alc883_clevo_m540r_verbs[] = {
9281
9585
        /* HP */
9282
9586
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9283
9587
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9293
9597
        { } /* end */
9294
9598
};
9295
9599
 
9296
 
static struct hda_verb alc883_clevo_m720_verbs[] = {
 
9600
static const struct hda_verb alc883_clevo_m720_verbs[] = {
9297
9601
        /* HP */
9298
9602
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9299
9603
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9308
9612
        { } /* end */
9309
9613
};
9310
9614
 
9311
 
static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
 
9615
static const struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9312
9616
        /* HP */
9313
9617
        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9314
9618
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9322
9626
        { } /* end */
9323
9627
};
9324
9628
 
9325
 
static struct hda_verb alc883_targa_verbs[] = {
 
9629
static const struct hda_verb alc883_targa_verbs[] = {
9326
9630
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9327
9631
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9328
9632
 
9351
9655
        { } /* end */
9352
9656
};
9353
9657
 
9354
 
static struct hda_verb alc883_lenovo_101e_verbs[] = {
 
9658
static const struct hda_verb alc883_lenovo_101e_verbs[] = {
9355
9659
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9356
9660
        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9357
9661
        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9358
9662
        { } /* end */
9359
9663
};
9360
9664
 
9361
 
static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
 
9665
static const struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9362
9666
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9363
9667
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9364
9668
        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9366
9670
        { } /* end */
9367
9671
};
9368
9672
 
9369
 
static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
 
9673
static const struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9370
9674
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9371
9675
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9372
9676
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9375
9679
        { } /* end */
9376
9680
};
9377
9681
 
9378
 
static struct hda_verb alc883_haier_w66_verbs[] = {
 
9682
static const struct hda_verb alc883_haier_w66_verbs[] = {
9379
9683
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9380
9684
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9381
9685
 
9388
9692
        { } /* end */
9389
9693
};
9390
9694
 
9391
 
static struct hda_verb alc888_lenovo_sky_verbs[] = {
 
9695
static const struct hda_verb alc888_lenovo_sky_verbs[] = {
9392
9696
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9393
9697
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9394
9698
        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9400
9704
        { } /* end */
9401
9705
};
9402
9706
 
9403
 
static struct hda_verb alc888_6st_dell_verbs[] = {
 
9707
static const struct hda_verb alc888_6st_dell_verbs[] = {
9404
9708
        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9405
9709
        { }
9406
9710
};
9407
9711
 
9408
 
static struct hda_verb alc883_vaiott_verbs[] = {
 
9712
static const struct hda_verb alc883_vaiott_verbs[] = {
9409
9713
        /* HP */
9410
9714
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9411
9715
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9424
9728
        spec->autocfg.speaker_pins[0] = 0x14;
9425
9729
        spec->autocfg.speaker_pins[1] = 0x16;
9426
9730
        spec->autocfg.speaker_pins[2] = 0x18;
 
9731
        spec->automute = 1;
 
9732
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9427
9733
}
9428
9734
 
9429
 
static struct hda_verb alc888_3st_hp_verbs[] = {
 
9735
static const struct hda_verb alc888_3st_hp_verbs[] = {
9430
9736
        {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},  /* Front: output 0 (0x0c) */
9431
9737
        {0x16, AC_VERB_SET_CONNECT_SEL, 0x01},  /* Rear : output 1 (0x0d) */
9432
9738
        {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},  /* CLFE : output 2 (0x0e) */
9437
9743
/*
9438
9744
 * 2ch mode
9439
9745
 */
9440
 
static struct hda_verb alc888_3st_hp_2ch_init[] = {
 
9746
static const struct hda_verb alc888_3st_hp_2ch_init[] = {
9441
9747
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9442
9748
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9443
9749
        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9448
9754
/*
9449
9755
 * 4ch mode
9450
9756
 */
9451
 
static struct hda_verb alc888_3st_hp_4ch_init[] = {
 
9757
static const struct hda_verb alc888_3st_hp_4ch_init[] = {
9452
9758
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9453
9759
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9454
9760
        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9460
9766
/*
9461
9767
 * 6ch mode
9462
9768
 */
9463
 
static struct hda_verb alc888_3st_hp_6ch_init[] = {
 
9769
static const struct hda_verb alc888_3st_hp_6ch_init[] = {
9464
9770
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9465
9771
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9466
9772
        { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
9470
9776
        { } /* end */
9471
9777
};
9472
9778
 
9473
 
static struct hda_channel_mode alc888_3st_hp_modes[3] = {
 
9779
static const struct hda_channel_mode alc888_3st_hp_modes[3] = {
9474
9780
        { 2, alc888_3st_hp_2ch_init },
9475
9781
        { 4, alc888_3st_hp_4ch_init },
9476
9782
        { 6, alc888_3st_hp_6ch_init },
9477
9783
};
9478
9784
 
9479
 
/* toggle front-jack and RCA according to the hp-jack state */
9480
 
static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9481
 
{
9482
 
        unsigned int present = snd_hda_jack_detect(codec, 0x1b);
9483
 
 
9484
 
        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9485
 
                                 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9486
 
        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9487
 
                                 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9488
 
}
9489
 
 
9490
 
/* toggle RCA according to the front-jack state */
9491
 
static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9492
 
{
9493
 
        unsigned int present = snd_hda_jack_detect(codec, 0x14);
9494
 
 
9495
 
        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9496
 
                                 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9497
 
}
9498
 
 
9499
 
static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9500
 
                                             unsigned int res)
9501
 
{
9502
 
        if ((res >> 26) == ALC880_HP_EVENT)
9503
 
                alc888_lenovo_ms7195_front_automute(codec);
9504
 
        if ((res >> 26) == ALC880_FRONT_EVENT)
9505
 
                alc888_lenovo_ms7195_rca_automute(codec);
 
9785
static void alc888_lenovo_ms7195_setup(struct hda_codec *codec)
 
9786
{
 
9787
        struct alc_spec *spec = codec->spec;
 
9788
 
 
9789
        spec->autocfg.hp_pins[0] = 0x1b;
 
9790
        spec->autocfg.line_out_pins[0] = 0x14;
 
9791
        spec->autocfg.speaker_pins[0] = 0x15;
 
9792
        spec->automute = 1;
 
9793
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9506
9794
}
9507
9795
 
9508
9796
/* toggle speaker-output according to the hp-jack state */
9512
9800
 
9513
9801
        spec->autocfg.hp_pins[0] = 0x14;
9514
9802
        spec->autocfg.speaker_pins[0] = 0x15;
 
9803
        spec->automute = 1;
 
9804
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9515
9805
}
9516
9806
 
9517
9807
/* toggle speaker-output according to the hp-jack state */
9524
9814
 
9525
9815
        spec->autocfg.hp_pins[0] = 0x15;
9526
9816
        spec->autocfg.speaker_pins[0] = 0x14;
 
9817
        spec->automute = 1;
 
9818
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9527
9819
}
9528
9820
 
9529
9821
static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9530
9822
{
9531
 
        alc_automute_amp(codec);
 
9823
        alc_hp_automute(codec);
9532
9824
        alc88x_simple_mic_automute(codec);
9533
9825
}
9534
9826
 
9540
9832
                alc88x_simple_mic_automute(codec);
9541
9833
                break;
9542
9834
        default:
9543
 
                alc_automute_amp_unsol_event(codec, res);
 
9835
                alc_sku_unsol_event(codec, res);
9544
9836
                break;
9545
9837
        }
9546
9838
}
9552
9844
 
9553
9845
        spec->autocfg.hp_pins[0] = 0x14;
9554
9846
        spec->autocfg.speaker_pins[0] = 0x15;
 
9847
        spec->automute = 1;
 
9848
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9555
9849
}
9556
9850
 
9557
9851
static void alc883_haier_w66_setup(struct hda_codec *codec)
9560
9854
 
9561
9855
        spec->autocfg.hp_pins[0] = 0x1b;
9562
9856
        spec->autocfg.speaker_pins[0] = 0x14;
9563
 
}
9564
 
 
9565
 
static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9566
 
{
9567
 
        int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
9568
 
 
9569
 
        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9570
 
                                 HDA_AMP_MUTE, bits);
9571
 
}
9572
 
 
9573
 
static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9574
 
{
9575
 
        int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
9576
 
 
9577
 
        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9578
 
                                 HDA_AMP_MUTE, bits);
9579
 
        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9580
 
                                 HDA_AMP_MUTE, bits);
9581
 
}
9582
 
 
9583
 
static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9584
 
                                           unsigned int res)
9585
 
{
9586
 
        if ((res >> 26) == ALC880_HP_EVENT)
9587
 
                alc883_lenovo_101e_all_automute(codec);
9588
 
        if ((res >> 26) == ALC880_FRONT_EVENT)
9589
 
                alc883_lenovo_101e_ispeaker_automute(codec);
 
9857
        spec->automute = 1;
 
9858
        spec->automute_mode = ALC_AUTOMUTE_AMP;
 
9859
}
 
9860
 
 
9861
static void alc883_lenovo_101e_setup(struct hda_codec *codec)
 
9862
{
 
9863
        struct alc_spec *spec = codec->spec;
 
9864
 
 
9865
        spec->autocfg.hp_pins[0] = 0x1b;
 
9866
        spec->autocfg.line_out_pins[0] = 0x14;
 
9867
        spec->autocfg.speaker_pins[0] = 0x15;
 
9868
        spec->automute = 1;
 
9869
        spec->detect_line = 1;
 
9870
        spec->automute_lines = 1;
 
9871
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9590
9872
}
9591
9873
 
9592
9874
/* toggle speaker-output according to the hp-jack state */
9597
9879
        spec->autocfg.hp_pins[0] = 0x14;
9598
9880
        spec->autocfg.speaker_pins[0] = 0x15;
9599
9881
        spec->autocfg.speaker_pins[1] = 0x16;
 
9882
        spec->automute = 1;
 
9883
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9600
9884
}
9601
9885
 
9602
 
static struct hda_verb alc883_acer_eapd_verbs[] = {
 
9886
static const struct hda_verb alc883_acer_eapd_verbs[] = {
9603
9887
        /* HP Pin: output 0 (0x0c) */
9604
9888
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9605
9889
        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9626
9910
        spec->autocfg.speaker_pins[1] = 0x15;
9627
9911
        spec->autocfg.speaker_pins[2] = 0x16;
9628
9912
        spec->autocfg.speaker_pins[3] = 0x17;
 
9913
        spec->automute = 1;
 
9914
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9629
9915
}
9630
9916
 
9631
9917
static void alc888_lenovo_sky_setup(struct hda_codec *codec)
9638
9924
        spec->autocfg.speaker_pins[2] = 0x16;
9639
9925
        spec->autocfg.speaker_pins[3] = 0x17;
9640
9926
        spec->autocfg.speaker_pins[4] = 0x1a;
 
9927
        spec->automute = 1;
 
9928
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9641
9929
}
9642
9930
 
9643
9931
static void alc883_vaiott_setup(struct hda_codec *codec)
9647
9935
        spec->autocfg.hp_pins[0] = 0x15;
9648
9936
        spec->autocfg.speaker_pins[0] = 0x14;
9649
9937
        spec->autocfg.speaker_pins[1] = 0x17;
 
9938
        spec->automute = 1;
 
9939
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9650
9940
}
9651
9941
 
9652
 
static struct hda_verb alc888_asus_m90v_verbs[] = {
 
9942
static const struct hda_verb alc888_asus_m90v_verbs[] = {
9653
9943
        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9654
9944
        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9655
9945
        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9672
9962
        spec->ext_mic.mux_idx = 0;
9673
9963
        spec->int_mic.mux_idx = 1;
9674
9964
        spec->auto_mic = 1;
 
9965
        spec->automute = 1;
 
9966
        spec->automute_mode = ALC_AUTOMUTE_AMP;
9675
9967
}
9676
9968
 
9677
 
static struct hda_verb alc888_asus_eee1601_verbs[] = {
 
9969
static const struct hda_verb alc888_asus_eee1601_verbs[] = {
9678
9970
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9679
9971
        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9680
9972
        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9693
9985
 
9694
9986
        spec->autocfg.hp_pins[0] = 0x14;
9695
9987
        spec->autocfg.speaker_pins[0] = 0x1b;
9696
 
        alc_automute_pin(codec);
 
9988
        alc_hp_automute(codec);
9697
9989
}
9698
9990
 
9699
 
static struct hda_verb alc889A_mb31_verbs[] = {
 
9991
static const struct hda_verb alc889A_mb31_verbs[] = {
9700
9992
        /* Init rear pin (used as headphone output) */
9701
9993
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},    /* Apple Headphones */
9702
9994
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},           /* Connect to front */
9742
10034
#define alc882_pcm_digital_playback     alc880_pcm_digital_playback
9743
10035
#define alc882_pcm_digital_capture      alc880_pcm_digital_capture
9744
10036
 
9745
 
static hda_nid_t alc883_slave_dig_outs[] = {
 
10037
static const hda_nid_t alc883_slave_dig_outs[] = {
9746
10038
        ALC1200_DIGOUT_NID, 0,
9747
10039
};
9748
10040
 
9749
 
static hda_nid_t alc1200_slave_dig_outs[] = {
 
10041
static const hda_nid_t alc1200_slave_dig_outs[] = {
9750
10042
        ALC883_DIGOUT_NID, 0,
9751
10043
};
9752
10044
 
9805
10097
        [ALC882_AUTO]           = "auto",
9806
10098
};
9807
10099
 
9808
 
static struct snd_pci_quirk alc882_cfg_tbl[] = {
 
10100
static const struct snd_pci_quirk alc882_cfg_tbl[] = {
9809
10101
        SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9810
10102
 
9811
10103
        SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
9932
10224
};
9933
10225
 
9934
10226
/* codec SSID table for Intel Mac */
9935
 
static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
 
10227
static const struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9936
10228
        SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9937
10229
        SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9938
10230
        SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9959
10251
        {} /* terminator */
9960
10252
};
9961
10253
 
9962
 
static struct alc_config_preset alc882_presets[] = {
 
10254
static const struct alc_config_preset alc882_presets[] = {
9963
10255
        [ALC882_3ST_DIG] = {
9964
10256
                .mixers = { alc882_base_mixer },
9965
10257
                .init_verbs = { alc882_base_init_verbs,
10015
10307
                        .channel_mode = alc885_mba21_ch_modes,
10016
10308
                        .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10017
10309
                        .input_mux = &alc882_capture_source,
10018
 
                        .unsol_event = alc_automute_amp_unsol_event,
 
10310
                        .unsol_event = alc_sku_unsol_event,
10019
10311
                        .setup = alc885_mba21_setup,
10020
 
                        .init_hook = alc_automute_amp,
 
10312
                        .init_hook = alc_hp_automute,
10021
10313
       },
10022
10314
        [ALC885_MBP3] = {
10023
10315
                .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10031
10323
                .input_mux = &alc882_capture_source,
10032
10324
                .dig_out_nid = ALC882_DIGOUT_NID,
10033
10325
                .dig_in_nid = ALC882_DIGIN_NID,
10034
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10326
                .unsol_event = alc_sku_unsol_event,
10035
10327
                .setup = alc885_mbp3_setup,
10036
 
                .init_hook = alc_automute_amp,
 
10328
                .init_hook = alc_hp_automute,
10037
10329
        },
10038
10330
        [ALC885_MB5] = {
10039
10331
                .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10046
10338
                .input_mux = &mb5_capture_source,
10047
10339
                .dig_out_nid = ALC882_DIGOUT_NID,
10048
10340
                .dig_in_nid = ALC882_DIGIN_NID,
10049
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10341
                .unsol_event = alc_sku_unsol_event,
10050
10342
                .setup = alc885_mb5_setup,
10051
 
                .init_hook = alc_automute_amp,
 
10343
                .init_hook = alc_hp_automute,
10052
10344
        },
10053
10345
        [ALC885_MACMINI3] = {
10054
10346
                .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10061
10353
                .input_mux = &macmini3_capture_source,
10062
10354
                .dig_out_nid = ALC882_DIGOUT_NID,
10063
10355
                .dig_in_nid = ALC882_DIGIN_NID,
10064
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10356
                .unsol_event = alc_sku_unsol_event,
10065
10357
                .setup = alc885_macmini3_setup,
10066
 
                .init_hook = alc_automute_amp,
 
10358
                .init_hook = alc_hp_automute,
10067
10359
        },
10068
10360
        [ALC885_MACPRO] = {
10069
10361
                .mixers = { alc882_macpro_mixer },
10087
10379
                .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10088
10380
                .channel_mode = alc882_ch_modes,
10089
10381
                .input_mux = &alc882_capture_source,
10090
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10382
                .unsol_event = alc_sku_unsol_event,
10091
10383
                .setup = alc885_imac24_setup,
10092
10384
                .init_hook = alc885_imac24_init_hook,
10093
10385
        },
10102
10394
                .input_mux = &alc889A_imac91_capture_source,
10103
10395
                .dig_out_nid = ALC882_DIGOUT_NID,
10104
10396
                .dig_in_nid = ALC882_DIGIN_NID,
10105
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10397
                .unsol_event = alc_sku_unsol_event,
10106
10398
                .setup = alc885_imac91_setup,
10107
 
                .init_hook = alc_automute_amp,
 
10399
                .init_hook = alc_hp_automute,
10108
10400
        },
10109
10401
        [ALC882_TARGA] = {
10110
10402
                .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
10120
10412
                .channel_mode = alc882_3ST_6ch_modes,
10121
10413
                .need_dac_fix = 1,
10122
10414
                .input_mux = &alc882_capture_source,
10123
 
                .unsol_event = alc882_targa_unsol_event,
 
10415
                .unsol_event = alc_sku_unsol_event,
10124
10416
                .setup = alc882_targa_setup,
10125
10417
                .init_hook = alc882_targa_automute,
10126
10418
        },
10214
10506
                .capsrc_nids = alc889_capsrc_nids,
10215
10507
                .input_mux = &alc889_capture_source,
10216
10508
                .setup = alc889_automute_setup,
10217
 
                .init_hook = alc_automute_amp,
10218
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10509
                .init_hook = alc_hp_automute,
 
10510
                .unsol_event = alc_sku_unsol_event,
10219
10511
                .need_dac_fix = 1,
10220
10512
        },
10221
10513
        [ALC889_INTEL] = {
10235
10527
                .input_mux = &alc889_capture_source,
10236
10528
                .setup = alc889_automute_setup,
10237
10529
                .init_hook = alc889_intel_init_hook,
10238
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10530
                .unsol_event = alc_sku_unsol_event,
10239
10531
                .need_dac_fix = 1,
10240
10532
        },
10241
10533
        [ALC883_6ST_DIG] = {
10324
10616
                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10325
10617
                .channel_mode = alc883_3ST_2ch_modes,
10326
10618
                .input_mux = &alc883_capture_source,
10327
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10619
                .unsol_event = alc_sku_unsol_event,
10328
10620
                .setup = alc883_acer_aspire_setup,
10329
 
                .init_hook = alc_automute_amp,
 
10621
                .init_hook = alc_hp_automute,
10330
10622
        },
10331
10623
        [ALC888_ACER_ASPIRE_4930G] = {
10332
10624
                .mixers = { alc888_acer_aspire_4930g_mixer,
10346
10638
                .num_mux_defs =
10347
10639
                        ARRAY_SIZE(alc888_2_capture_sources),
10348
10640
                .input_mux = alc888_2_capture_sources,
10349
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10641
                .unsol_event = alc_sku_unsol_event,
10350
10642
                .setup = alc888_acer_aspire_4930g_setup,
10351
 
                .init_hook = alc_automute_amp,
 
10643
                .init_hook = alc_hp_automute,
10352
10644
        },
10353
10645
        [ALC888_ACER_ASPIRE_6530G] = {
10354
10646
                .mixers = { alc888_acer_aspire_6530_mixer },
10365
10657
                .num_mux_defs =
10366
10658
                        ARRAY_SIZE(alc888_2_capture_sources),
10367
10659
                .input_mux = alc888_acer_aspire_6530_sources,
10368
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10660
                .unsol_event = alc_sku_unsol_event,
10369
10661
                .setup = alc888_acer_aspire_6530g_setup,
10370
 
                .init_hook = alc_automute_amp,
 
10662
                .init_hook = alc_hp_automute,
10371
10663
        },
10372
10664
        [ALC888_ACER_ASPIRE_8930G] = {
10373
10665
                .mixers = { alc889_acer_aspire_8930g_mixer,
10388
10680
                .num_mux_defs =
10389
10681
                        ARRAY_SIZE(alc889_capture_sources),
10390
10682
                .input_mux = alc889_capture_sources,
10391
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10683
                .unsol_event = alc_sku_unsol_event,
10392
10684
                .setup = alc889_acer_aspire_8930g_setup,
10393
 
                .init_hook = alc_automute_amp,
 
10685
                .init_hook = alc_hp_automute,
10394
10686
#ifdef CONFIG_SND_HDA_POWER_SAVE
10395
10687
                .power_hook = alc_power_eapd,
10396
10688
#endif
10411
10703
                .need_dac_fix = 1,
10412
10704
                .const_channel_count = 6,
10413
10705
                .input_mux = &alc883_capture_source,
10414
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10706
                .unsol_event = alc_sku_unsol_event,
10415
10707
                .setup = alc888_acer_aspire_7730g_setup,
10416
 
                .init_hook = alc_automute_amp,
 
10708
                .init_hook = alc_hp_automute,
10417
10709
        },
10418
10710
        [ALC883_MEDION] = {
10419
10711
                .mixers = { alc883_fivestack_mixer,
10440
10732
                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10441
10733
                .channel_mode = alc883_3ST_2ch_modes,
10442
10734
                .input_mux = &alc883_capture_source,
10443
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10735
                .unsol_event = alc_sku_unsol_event,
10444
10736
                .setup = alc883_medion_wim2160_setup,
10445
 
                .init_hook = alc_automute_amp,
 
10737
                .init_hook = alc_hp_automute,
10446
10738
        },
10447
10739
        [ALC883_LAPTOP_EAPD] = {
10448
10740
                .mixers = { alc883_base_mixer },
10492
10784
                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10493
10785
                .channel_mode = alc883_3ST_2ch_modes,
10494
10786
                .input_mux = &alc883_lenovo_101e_capture_source,
10495
 
                .unsol_event = alc883_lenovo_101e_unsol_event,
10496
 
                .init_hook = alc883_lenovo_101e_all_automute,
 
10787
                .setup = alc883_lenovo_101e_setup,
 
10788
                .unsol_event = alc_sku_unsol_event,
 
10789
                .init_hook = alc_inithook,
10497
10790
        },
10498
10791
        [ALC883_LENOVO_NB0763] = {
10499
10792
                .mixers = { alc883_lenovo_nb0763_mixer },
10504
10797
                .channel_mode = alc883_3ST_2ch_modes,
10505
10798
                .need_dac_fix = 1,
10506
10799
                .input_mux = &alc883_lenovo_nb0763_capture_source,
10507
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10800
                .unsol_event = alc_sku_unsol_event,
10508
10801
                .setup = alc883_lenovo_nb0763_setup,
10509
 
                .init_hook = alc_automute_amp,
 
10802
                .init_hook = alc_hp_automute,
10510
10803
        },
10511
10804
        [ALC888_LENOVO_MS7195_DIG] = {
10512
10805
                .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10518
10811
                .channel_mode = alc883_3ST_6ch_modes,
10519
10812
                .need_dac_fix = 1,
10520
10813
                .input_mux = &alc883_capture_source,
10521
 
                .unsol_event = alc883_lenovo_ms7195_unsol_event,
10522
 
                .init_hook = alc888_lenovo_ms7195_front_automute,
 
10814
                .unsol_event = alc_sku_unsol_event,
 
10815
                .setup = alc888_lenovo_ms7195_setup,
 
10816
                .init_hook = alc_inithook,
10523
10817
        },
10524
10818
        [ALC883_HAIER_W66] = {
10525
10819
                .mixers = { alc883_targa_2ch_mixer},
10530
10824
                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10531
10825
                .channel_mode = alc883_3ST_2ch_modes,
10532
10826
                .input_mux = &alc883_capture_source,
10533
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10827
                .unsol_event = alc_sku_unsol_event,
10534
10828
                .setup = alc883_haier_w66_setup,
10535
 
                .init_hook = alc_automute_amp,
 
10829
                .init_hook = alc_hp_automute,
10536
10830
        },
10537
10831
        [ALC888_3ST_HP] = {
10538
10832
                .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10543
10837
                .channel_mode = alc888_3st_hp_modes,
10544
10838
                .need_dac_fix = 1,
10545
10839
                .input_mux = &alc883_capture_source,
10546
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10840
                .unsol_event = alc_sku_unsol_event,
10547
10841
                .setup = alc888_3st_hp_setup,
10548
 
                .init_hook = alc_automute_amp,
 
10842
                .init_hook = alc_hp_automute,
10549
10843
        },
10550
10844
        [ALC888_6ST_DELL] = {
10551
10845
                .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10557
10851
                .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10558
10852
                .channel_mode = alc883_sixstack_modes,
10559
10853
                .input_mux = &alc883_capture_source,
10560
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10854
                .unsol_event = alc_sku_unsol_event,
10561
10855
                .setup = alc888_6st_dell_setup,
10562
 
                .init_hook = alc_automute_amp,
 
10856
                .init_hook = alc_hp_automute,
10563
10857
        },
10564
10858
        [ALC883_MITAC] = {
10565
10859
                .mixers = { alc883_mitac_mixer },
10569
10863
                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10570
10864
                .channel_mode = alc883_3ST_2ch_modes,
10571
10865
                .input_mux = &alc883_capture_source,
10572
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10866
                .unsol_event = alc_sku_unsol_event,
10573
10867
                .setup = alc883_mitac_setup,
10574
 
                .init_hook = alc_automute_amp,
 
10868
                .init_hook = alc_hp_automute,
10575
10869
        },
10576
10870
        [ALC883_FUJITSU_PI2515] = {
10577
10871
                .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10583
10877
                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10584
10878
                .channel_mode = alc883_3ST_2ch_modes,
10585
10879
                .input_mux = &alc883_fujitsu_pi2515_capture_source,
10586
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10880
                .unsol_event = alc_sku_unsol_event,
10587
10881
                .setup = alc883_2ch_fujitsu_pi2515_setup,
10588
 
                .init_hook = alc_automute_amp,
 
10882
                .init_hook = alc_hp_automute,
10589
10883
        },
10590
10884
        [ALC888_FUJITSU_XA3530] = {
10591
10885
                .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10602
10896
                .num_mux_defs =
10603
10897
                        ARRAY_SIZE(alc888_2_capture_sources),
10604
10898
                .input_mux = alc888_2_capture_sources,
10605
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10899
                .unsol_event = alc_sku_unsol_event,
10606
10900
                .setup = alc888_fujitsu_xa3530_setup,
10607
 
                .init_hook = alc_automute_amp,
 
10901
                .init_hook = alc_hp_automute,
10608
10902
        },
10609
10903
        [ALC888_LENOVO_SKY] = {
10610
10904
                .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10616
10910
                .channel_mode = alc883_sixstack_modes,
10617
10911
                .need_dac_fix = 1,
10618
10912
                .input_mux = &alc883_lenovo_sky_capture_source,
10619
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10913
                .unsol_event = alc_sku_unsol_event,
10620
10914
                .setup = alc888_lenovo_sky_setup,
10621
 
                .init_hook = alc_automute_amp,
 
10915
                .init_hook = alc_hp_automute,
10622
10916
        },
10623
10917
        [ALC888_ASUS_M90V] = {
10624
10918
                .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10686
10980
                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10687
10981
                .channel_mode = alc883_3ST_2ch_modes,
10688
10982
                .input_mux = &alc883_capture_source,
10689
 
                .unsol_event = alc_automute_amp_unsol_event,
 
10983
                .unsol_event = alc_sku_unsol_event,
10690
10984
                .setup = alc883_vaiott_setup,
10691
 
                .init_hook = alc_automute_amp,
 
10985
                .init_hook = alc_hp_automute,
10692
10986
        },
10693
10987
};
10694
10988
 
10734
11028
        },
10735
11029
};
10736
11030
 
10737
 
static struct snd_pci_quirk alc882_fixup_tbl[] = {
 
11031
static const struct snd_pci_quirk alc882_fixup_tbl[] = {
10738
11032
        SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
10739
11033
        SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
10740
11034
        SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10842
11136
                const struct hda_input_mux *imux;
10843
11137
                int conns, mute, idx, item;
10844
11138
 
 
11139
                /* mute ADC */
 
11140
                snd_hda_codec_write(codec, spec->adc_nids[c], 0,
 
11141
                                    AC_VERB_SET_AMP_GAIN_MUTE,
 
11142
                                    AMP_IN_MUTE(0));
 
11143
 
10845
11144
                conns = snd_hda_get_connections(codec, nid, conn_list,
10846
11145
                                                ARRAY_SIZE(conn_list));
10847
11146
                if (conns < 0)
10921
11220
static int alc882_parse_auto_config(struct hda_codec *codec)
10922
11221
{
10923
11222
        struct alc_spec *spec = codec->spec;
10924
 
        static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
 
11223
        static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10925
11224
        int err;
10926
11225
 
10927
11226
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10934
11233
        err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10935
11234
        if (err < 0)
10936
11235
                return err;
 
11236
        err = alc_auto_add_multi_channel_mode(codec);
 
11237
        if (err < 0)
 
11238
                return err;
10937
11239
        err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10938
11240
        if (err < 0)
10939
11241
                return err;
11135
11437
#define alc262_modes            alc260_modes
11136
11438
#define alc262_capture_source   alc882_capture_source
11137
11439
 
11138
 
static hda_nid_t alc262_dmic_adc_nids[1] = {
 
11440
static const hda_nid_t alc262_dmic_adc_nids[1] = {
11139
11441
        /* ADC0 */
11140
11442
        0x09
11141
11443
};
11142
11444
 
11143
 
static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
 
11445
static const hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11144
11446
 
11145
 
static struct snd_kcontrol_new alc262_base_mixer[] = {
 
11447
static const struct snd_kcontrol_new alc262_base_mixer[] = {
11146
11448
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11147
11449
        HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11148
11450
        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11163
11465
};
11164
11466
 
11165
11467
/* update HP, line and mono-out pins according to the master switch */
11166
 
static void alc262_hp_master_update(struct hda_codec *codec)
11167
 
{
11168
 
        struct alc_spec *spec = codec->spec;
11169
 
        int val = spec->master_sw;
11170
 
 
11171
 
        /* HP & line-out */
11172
 
        snd_hda_codec_write_cache(codec, 0x1b, 0,
11173
 
                                  AC_VERB_SET_PIN_WIDGET_CONTROL,
11174
 
                                  val ? PIN_HP : 0);
11175
 
        snd_hda_codec_write_cache(codec, 0x15, 0,
11176
 
                                  AC_VERB_SET_PIN_WIDGET_CONTROL,
11177
 
                                  val ? PIN_HP : 0);
11178
 
        /* mono (speaker) depending on the HP jack sense */
11179
 
        val = val && !spec->jack_present;
11180
 
        snd_hda_codec_write_cache(codec, 0x16, 0,
11181
 
                                  AC_VERB_SET_PIN_WIDGET_CONTROL,
11182
 
                                  val ? PIN_OUT : 0);
11183
 
}
11184
 
 
11185
 
static void alc262_hp_bpc_automute(struct hda_codec *codec)
11186
 
{
11187
 
        struct alc_spec *spec = codec->spec;
11188
 
 
11189
 
        spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
11190
 
        alc262_hp_master_update(codec);
11191
 
}
11192
 
 
11193
 
static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11194
 
{
11195
 
        if ((res >> 26) != ALC880_HP_EVENT)
11196
 
                return;
11197
 
        alc262_hp_bpc_automute(codec);
11198
 
}
11199
 
 
11200
 
static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11201
 
{
11202
 
        struct alc_spec *spec = codec->spec;
11203
 
 
11204
 
        spec->jack_present = snd_hda_jack_detect(codec, 0x15);
11205
 
        alc262_hp_master_update(codec);
11206
 
}
11207
 
 
11208
 
static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11209
 
                                           unsigned int res)
11210
 
{
11211
 
        if ((res >> 26) != ALC880_HP_EVENT)
11212
 
                return;
11213
 
        alc262_hp_wildwest_automute(codec);
 
11468
#define alc262_hp_master_update         alc260_hp_master_update
 
11469
 
 
11470
static void alc262_hp_bpc_setup(struct hda_codec *codec)
 
11471
{
 
11472
        struct alc_spec *spec = codec->spec;
 
11473
 
 
11474
        spec->autocfg.hp_pins[0] = 0x1b;
 
11475
        spec->autocfg.speaker_pins[0] = 0x16;
 
11476
        spec->automute = 1;
 
11477
        spec->automute_mode = ALC_AUTOMUTE_PIN;
 
11478
}
 
11479
 
 
11480
static void alc262_hp_wildwest_setup(struct hda_codec *codec)
 
11481
{
 
11482
        struct alc_spec *spec = codec->spec;
 
11483
 
 
11484
        spec->autocfg.hp_pins[0] = 0x15;
 
11485
        spec->autocfg.speaker_pins[0] = 0x16;
 
11486
        spec->automute = 1;
 
11487
        spec->automute_mode = ALC_AUTOMUTE_PIN;
11214
11488
}
11215
11489
 
11216
11490
#define alc262_hp_master_sw_get         alc260_hp_master_sw_get
11217
 
 
11218
 
static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11219
 
                                   struct snd_ctl_elem_value *ucontrol)
11220
 
{
11221
 
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11222
 
        struct alc_spec *spec = codec->spec;
11223
 
        int val = !!*ucontrol->value.integer.value;
11224
 
 
11225
 
        if (val == spec->master_sw)
11226
 
                return 0;
11227
 
        spec->master_sw = val;
11228
 
        alc262_hp_master_update(codec);
11229
 
        return 1;
11230
 
}
 
11491
#define alc262_hp_master_sw_put         alc260_hp_master_sw_put
11231
11492
 
11232
11493
#define ALC262_HP_MASTER_SWITCH                                 \
11233
11494
        {                                                       \
11244
11505
        }
11245
11506
 
11246
11507
 
11247
 
static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
 
11508
static const struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
11248
11509
        ALC262_HP_MASTER_SWITCH,
11249
11510
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11250
11511
        HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11268
11529
        { } /* end */
11269
11530
};
11270
11531
 
11271
 
static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
 
11532
static const struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
11272
11533
        ALC262_HP_MASTER_SWITCH,
11273
11534
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11274
11535
        HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11288
11549
        { } /* end */
11289
11550
};
11290
11551
 
11291
 
static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
 
11552
static const struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11292
11553
        HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11293
11554
        HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11294
11555
        HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
11302
11563
 
11303
11564
        spec->autocfg.hp_pins[0] = 0x15;
11304
11565
        spec->autocfg.speaker_pins[0] = 0x14;
 
11566
        spec->automute = 1;
 
11567
        spec->automute_mode = ALC_AUTOMUTE_PIN;
11305
11568
}
11306
11569
 
11307
 
static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
 
11570
static const struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
11308
11571
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11309
11572
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11310
11573
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11315
11578
        { } /* end */
11316
11579
};
11317
11580
 
11318
 
static struct hda_verb alc262_hp_t5735_verbs[] = {
 
11581
static const struct hda_verb alc262_hp_t5735_verbs[] = {
11319
11582
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11320
11583
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11321
11584
 
11323
11586
        { }
11324
11587
};
11325
11588
 
11326
 
static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
 
11589
static const struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
11327
11590
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11328
11591
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11329
11592
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11333
11596
        { } /* end */
11334
11597
};
11335
11598
 
11336
 
static struct hda_verb alc262_hp_rp5700_verbs[] = {
 
11599
static const struct hda_verb alc262_hp_rp5700_verbs[] = {
11337
11600
        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11338
11601
        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11339
11602
        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11347
11610
        {}
11348
11611
};
11349
11612
 
11350
 
static struct hda_input_mux alc262_hp_rp5700_capture_source = {
 
11613
static const struct hda_input_mux alc262_hp_rp5700_capture_source = {
11351
11614
        .num_items = 1,
11352
11615
        .items = {
11353
11616
                { "Line", 0x1 },
11355
11618
};
11356
11619
 
11357
11620
/* bind hp and internal speaker mute (with plug check) as master switch */
11358
 
static void alc262_hippo_master_update(struct hda_codec *codec)
11359
 
{
11360
 
        struct alc_spec *spec = codec->spec;
11361
 
        hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11362
 
        hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11363
 
        hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11364
 
        unsigned int mute;
11365
 
 
11366
 
        /* HP */
11367
 
        mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11368
 
        snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11369
 
                                 HDA_AMP_MUTE, mute);
11370
 
        /* mute internal speaker per jack sense */
11371
 
        if (spec->jack_present)
11372
 
                mute = HDA_AMP_MUTE;
11373
 
        if (line_nid)
11374
 
                snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11375
 
                                         HDA_AMP_MUTE, mute);
11376
 
        if (speaker_nid && speaker_nid != line_nid)
11377
 
                snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11378
 
                                         HDA_AMP_MUTE, mute);
11379
 
}
11380
 
 
 
11621
#define alc262_hippo_master_update      alc262_hp_master_update
11381
11622
#define alc262_hippo_master_sw_get      alc262_hp_master_sw_get
11382
 
 
11383
 
static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11384
 
                                      struct snd_ctl_elem_value *ucontrol)
11385
 
{
11386
 
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11387
 
        struct alc_spec *spec = codec->spec;
11388
 
        int val = !!*ucontrol->value.integer.value;
11389
 
 
11390
 
        if (val == spec->master_sw)
11391
 
                return 0;
11392
 
        spec->master_sw = val;
11393
 
        alc262_hippo_master_update(codec);
11394
 
        return 1;
11395
 
}
 
11623
#define alc262_hippo_master_sw_put      alc262_hp_master_sw_put
11396
11624
 
11397
11625
#define ALC262_HIPPO_MASTER_SWITCH                              \
11398
11626
        {                                                       \
11409
11637
                             (SUBDEV_SPEAKER(0) << 16), \
11410
11638
        }
11411
11639
 
11412
 
static struct snd_kcontrol_new alc262_hippo_mixer[] = {
 
11640
static const struct snd_kcontrol_new alc262_hippo_mixer[] = {
11413
11641
        ALC262_HIPPO_MASTER_SWITCH,
11414
11642
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11415
11643
        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11426
11654
        { } /* end */
11427
11655
};
11428
11656
 
11429
 
static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
 
11657
static const struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11430
11658
        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11431
11659
        ALC262_HIPPO_MASTER_SWITCH,
11432
11660
        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11443
11671
};
11444
11672
 
11445
11673
/* mute/unmute internal speaker according to the hp jack and mute state */
11446
 
static void alc262_hippo_automute(struct hda_codec *codec)
11447
 
{
11448
 
        struct alc_spec *spec = codec->spec;
11449
 
        hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11450
 
 
11451
 
        spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
11452
 
        alc262_hippo_master_update(codec);
11453
 
}
11454
 
 
11455
 
static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11456
 
{
11457
 
        if ((res >> 26) != ALC880_HP_EVENT)
11458
 
                return;
11459
 
        alc262_hippo_automute(codec);
11460
 
}
11461
 
 
11462
11674
static void alc262_hippo_setup(struct hda_codec *codec)
11463
11675
{
11464
11676
        struct alc_spec *spec = codec->spec;
11465
11677
 
11466
11678
        spec->autocfg.hp_pins[0] = 0x15;
11467
11679
        spec->autocfg.speaker_pins[0] = 0x14;
 
11680
        spec->automute = 1;
 
11681
        spec->automute_mode = ALC_AUTOMUTE_AMP;
11468
11682
}
11469
11683
 
11470
11684
static void alc262_hippo1_setup(struct hda_codec *codec)
11473
11687
 
11474
11688
        spec->autocfg.hp_pins[0] = 0x1b;
11475
11689
        spec->autocfg.speaker_pins[0] = 0x14;
 
11690
        spec->automute = 1;
 
11691
        spec->automute_mode = ALC_AUTOMUTE_AMP;
11476
11692
}
11477
11693
 
11478
11694
 
11479
 
static struct snd_kcontrol_new alc262_sony_mixer[] = {
 
11695
static const struct snd_kcontrol_new alc262_sony_mixer[] = {
11480
11696
        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11481
11697
        ALC262_HIPPO_MASTER_SWITCH,
11482
11698
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11486
11702
        { } /* end */
11487
11703
};
11488
11704
 
11489
 
static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
 
11705
static const struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
11490
11706
        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11491
11707
        ALC262_HIPPO_MASTER_SWITCH,
11492
11708
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11497
11713
        { } /* end */
11498
11714
};
11499
11715
 
11500
 
static struct snd_kcontrol_new alc262_tyan_mixer[] = {
 
11716
static const struct snd_kcontrol_new alc262_tyan_mixer[] = {
11501
11717
        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11502
11718
        HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11503
11719
        HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11513
11729
        { } /* end */
11514
11730
};
11515
11731
 
11516
 
static struct hda_verb alc262_tyan_verbs[] = {
 
11732
static const struct hda_verb alc262_tyan_verbs[] = {
11517
11733
        /* Headphone automute */
11518
11734
        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11519
11735
        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11535
11751
 
11536
11752
        spec->autocfg.hp_pins[0] = 0x1b;
11537
11753
        spec->autocfg.speaker_pins[0] = 0x15;
 
11754
        spec->automute = 1;
 
11755
        spec->automute_mode = ALC_AUTOMUTE_AMP;
11538
11756
}
11539
11757
 
11540
11758
 
11544
11762
/*
11545
11763
 * generic initialization of ADC, input mixers and output mixers
11546
11764
 */
11547
 
static struct hda_verb alc262_init_verbs[] = {
 
11765
static const struct hda_verb alc262_init_verbs[] = {
11548
11766
        /*
11549
11767
         * Unmute ADC0-2 and set the default input to mic-in
11550
11768
         */
11620
11838
        { }
11621
11839
};
11622
11840
 
11623
 
static struct hda_verb alc262_eapd_verbs[] = {
 
11841
static const struct hda_verb alc262_eapd_verbs[] = {
11624
11842
        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11625
11843
        {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11626
11844
        { }
11627
11845
};
11628
11846
 
11629
 
static struct hda_verb alc262_hippo1_unsol_verbs[] = {
 
11847
static const struct hda_verb alc262_hippo1_unsol_verbs[] = {
11630
11848
        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11631
11849
        {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11632
11850
        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11636
11854
        {}
11637
11855
};
11638
11856
 
11639
 
static struct hda_verb alc262_sony_unsol_verbs[] = {
 
11857
static const struct hda_verb alc262_sony_unsol_verbs[] = {
11640
11858
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11641
11859
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11642
11860
        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},   // Front Mic
11646
11864
        {}
11647
11865
};
11648
11866
 
11649
 
static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
 
11867
static const struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11650
11868
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11651
11869
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11652
11870
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11655
11873
        { } /* end */
11656
11874
};
11657
11875
 
11658
 
static struct hda_verb alc262_toshiba_s06_verbs[] = {
 
11876
static const struct hda_verb alc262_toshiba_s06_verbs[] = {
11659
11877
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11660
11878
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11661
11879
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11678
11896
        spec->int_mic.pin = 0x12;
11679
11897
        spec->int_mic.mux_idx = 9;
11680
11898
        spec->auto_mic = 1;
 
11899
        spec->automute = 1;
 
11900
        spec->automute_mode = ALC_AUTOMUTE_PIN;
11681
11901
}
11682
11902
 
11683
11903
/*
11687
11907
 *  0x18 = external mic
11688
11908
 */
11689
11909
 
11690
 
static struct snd_kcontrol_new alc262_nec_mixer[] = {
 
11910
static const struct snd_kcontrol_new alc262_nec_mixer[] = {
11691
11911
        HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11692
11912
        HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11693
11913
 
11700
11920
        { } /* end */
11701
11921
};
11702
11922
 
11703
 
static struct hda_verb alc262_nec_verbs[] = {
 
11923
static const struct hda_verb alc262_nec_verbs[] = {
11704
11924
        /* Unmute Speaker */
11705
11925
        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11706
11926
 
11721
11941
 *  0x1b = port replicator headphone out
11722
11942
 */
11723
11943
 
11724
 
#define ALC_HP_EVENT    0x37
 
11944
#define ALC_HP_EVENT    ALC880_HP_EVENT
11725
11945
 
11726
 
static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
 
11946
static const struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11727
11947
        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11728
11948
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11729
11949
        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11731
11951
        {}
11732
11952
};
11733
11953
 
11734
 
static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
 
11954
static const struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11735
11955
        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11736
11956
        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11737
11957
        {}
11738
11958
};
11739
11959
 
11740
 
static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
 
11960
static const struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11741
11961
        /* Front Mic pin: input vref at 50% */
11742
11962
        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11743
11963
        {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11744
11964
        {}
11745
11965
};
11746
11966
 
11747
 
static struct hda_input_mux alc262_fujitsu_capture_source = {
 
11967
static const struct hda_input_mux alc262_fujitsu_capture_source = {
11748
11968
        .num_items = 3,
11749
11969
        .items = {
11750
11970
                { "Mic", 0x0 },
11753
11973
        },
11754
11974
};
11755
11975
 
11756
 
static struct hda_input_mux alc262_HP_capture_source = {
 
11976
static const struct hda_input_mux alc262_HP_capture_source = {
11757
11977
        .num_items = 5,
11758
11978
        .items = {
11759
11979
                { "Mic", 0x0 },
11764
11984
        },
11765
11985
};
11766
11986
 
11767
 
static struct hda_input_mux alc262_HP_D7000_capture_source = {
 
11987
static const struct hda_input_mux alc262_HP_D7000_capture_source = {
11768
11988
        .num_items = 4,
11769
11989
        .items = {
11770
11990
                { "Mic", 0x0 },
11774
11994
        },
11775
11995
};
11776
11996
 
11777
 
/* mute/unmute internal speaker according to the hp jacks and mute state */
11778
 
static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
 
11997
static void alc262_fujitsu_setup(struct hda_codec *codec)
11779
11998
{
11780
11999
        struct alc_spec *spec = codec->spec;
11781
 
        unsigned int mute;
11782
 
 
11783
 
        if (force || !spec->sense_updated) {
11784
 
                spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11785
 
                                     snd_hda_jack_detect(codec, 0x1b);
11786
 
                spec->sense_updated = 1;
11787
 
        }
11788
 
        /* unmute internal speaker only if both HPs are unplugged and
11789
 
         * master switch is on
11790
 
         */
11791
 
        if (spec->jack_present)
11792
 
                mute = HDA_AMP_MUTE;
11793
 
        else
11794
 
                mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11795
 
        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11796
 
                                 HDA_AMP_MUTE, mute);
11797
 
}
11798
 
 
11799
 
/* unsolicited event for HP jack sensing */
11800
 
static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11801
 
                                       unsigned int res)
11802
 
{
11803
 
        if ((res >> 26) != ALC_HP_EVENT)
11804
 
                return;
11805
 
        alc262_fujitsu_automute(codec, 1);
11806
 
}
11807
 
 
11808
 
static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11809
 
{
11810
 
        alc262_fujitsu_automute(codec, 1);
 
12000
 
 
12001
        spec->autocfg.hp_pins[0] = 0x14;
 
12002
        spec->autocfg.hp_pins[1] = 0x1b;
 
12003
        spec->autocfg.speaker_pins[0] = 0x15;
 
12004
        spec->automute = 1;
 
12005
        spec->automute_mode = ALC_AUTOMUTE_AMP;
11811
12006
}
11812
12007
 
11813
12008
/* bind volumes of both NID 0x0c and 0x0d */
11814
 
static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
 
12009
static const struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11815
12010
        .ops = &snd_hda_bind_vol,
11816
12011
        .values = {
11817
12012
                HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11820
12015
        },
11821
12016
};
11822
12017
 
11823
 
/* mute/unmute internal speaker according to the hp jack and mute state */
11824
 
static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11825
 
{
11826
 
        struct alc_spec *spec = codec->spec;
11827
 
        unsigned int mute;
11828
 
 
11829
 
        if (force || !spec->sense_updated) {
11830
 
                spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
11831
 
                spec->sense_updated = 1;
11832
 
        }
11833
 
        if (spec->jack_present) {
11834
 
                /* mute internal speaker */
11835
 
                snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11836
 
                                         HDA_AMP_MUTE, HDA_AMP_MUTE);
11837
 
                snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11838
 
                                         HDA_AMP_MUTE, HDA_AMP_MUTE);
11839
 
        } else {
11840
 
                /* unmute internal speaker if necessary */
11841
 
                mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11842
 
                snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11843
 
                                         HDA_AMP_MUTE, mute);
11844
 
                snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11845
 
                                         HDA_AMP_MUTE, mute);
11846
 
        }
11847
 
}
11848
 
 
11849
 
/* unsolicited event for HP jack sensing */
11850
 
static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11851
 
                                       unsigned int res)
11852
 
{
11853
 
        if ((res >> 26) != ALC_HP_EVENT)
11854
 
                return;
11855
 
        alc262_lenovo_3000_automute(codec, 1);
11856
 
}
11857
 
 
11858
 
static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11859
 
                                  int dir, int idx, long *valp)
11860
 
{
11861
 
        int i, change = 0;
11862
 
 
11863
 
        for (i = 0; i < 2; i++, valp++)
11864
 
                change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11865
 
                                                   HDA_AMP_MUTE,
11866
 
                                                   *valp ? 0 : HDA_AMP_MUTE);
11867
 
        return change;
11868
 
}
11869
 
 
11870
 
/* bind hp and internal speaker mute (with plug check) */
11871
 
static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11872
 
                                         struct snd_ctl_elem_value *ucontrol)
11873
 
{
11874
 
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11875
 
        long *valp = ucontrol->value.integer.value;
11876
 
        int change;
11877
 
 
11878
 
        change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11879
 
        change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
11880
 
        if (change)
11881
 
                alc262_fujitsu_automute(codec, 0);
11882
 
        return change;
11883
 
}
11884
 
 
11885
 
static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
 
12018
static const struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
11886
12019
        HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11887
12020
        {
11888
12021
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11889
12022
                .name = "Master Playback Switch",
11890
 
                .subdevice = HDA_SUBDEV_AMP_FLAG,
11891
 
                .info = snd_hda_mixer_amp_switch_info,
11892
 
                .get = snd_hda_mixer_amp_switch_get,
11893
 
                .put = alc262_fujitsu_master_sw_put,
11894
 
                .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
 
12023
                .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
 
12024
                .info = snd_ctl_boolean_mono_info,
 
12025
                .get = alc262_hp_master_sw_get,
 
12026
                .put = alc262_hp_master_sw_put,
11895
12027
        },
11896
12028
        {
11897
12029
                .iface = NID_MAPPING,
11909
12041
        { } /* end */
11910
12042
};
11911
12043
 
11912
 
/* bind hp and internal speaker mute (with plug check) */
11913
 
static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11914
 
                                         struct snd_ctl_elem_value *ucontrol)
 
12044
static void alc262_lenovo_3000_setup(struct hda_codec *codec)
11915
12045
{
11916
 
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11917
 
        long *valp = ucontrol->value.integer.value;
11918
 
        int change;
 
12046
        struct alc_spec *spec = codec->spec;
11919
12047
 
11920
 
        change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
11921
 
        if (change)
11922
 
                alc262_lenovo_3000_automute(codec, 0);
11923
 
        return change;
 
12048
        spec->autocfg.hp_pins[0] = 0x1b;
 
12049
        spec->autocfg.speaker_pins[0] = 0x14;
 
12050
        spec->autocfg.speaker_pins[1] = 0x16;
 
12051
        spec->automute = 1;
 
12052
        spec->automute_mode = ALC_AUTOMUTE_AMP;
11924
12053
}
11925
12054
 
11926
 
static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
 
12055
static const struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11927
12056
        HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11928
12057
        {
11929
12058
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11930
12059
                .name = "Master Playback Switch",
11931
 
                .subdevice = HDA_SUBDEV_AMP_FLAG,
11932
 
                .info = snd_hda_mixer_amp_switch_info,
11933
 
                .get = snd_hda_mixer_amp_switch_get,
11934
 
                .put = alc262_lenovo_3000_master_sw_put,
11935
 
                .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
 
12060
                .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
 
12061
                .info = snd_ctl_boolean_mono_info,
 
12062
                .get = alc262_hp_master_sw_get,
 
12063
                .put = alc262_hp_master_sw_put,
11936
12064
        },
11937
12065
        HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11938
12066
        HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11945
12073
        { } /* end */
11946
12074
};
11947
12075
 
11948
 
static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
 
12076
static const struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11949
12077
        HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11950
12078
        ALC262_HIPPO_MASTER_SWITCH,
11951
12079
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11958
12086
};
11959
12087
 
11960
12088
/* additional init verbs for Benq laptops */
11961
 
static struct hda_verb alc262_EAPD_verbs[] = {
 
12089
static const struct hda_verb alc262_EAPD_verbs[] = {
11962
12090
        {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11963
12091
        {0x20, AC_VERB_SET_PROC_COEF,  0x3070},
11964
12092
        {}
11965
12093
};
11966
12094
 
11967
 
static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
 
12095
static const struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11968
12096
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11969
12097
        {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11970
12098
 
11974
12102
};
11975
12103
 
11976
12104
/* Samsung Q1 Ultra Vista model setup */
11977
 
static struct snd_kcontrol_new alc262_ultra_mixer[] = {
 
12105
static const struct snd_kcontrol_new alc262_ultra_mixer[] = {
11978
12106
        HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11979
12107
        HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11980
12108
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11984
12112
        { } /* end */
11985
12113
};
11986
12114
 
11987
 
static struct hda_verb alc262_ultra_verbs[] = {
 
12115
static const struct hda_verb alc262_ultra_verbs[] = {
11988
12116
        /* output mixer */
11989
12117
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11990
12118
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12047
12175
        alc262_ultra_automute(codec);
12048
12176
}
12049
12177
 
12050
 
static struct hda_input_mux alc262_ultra_capture_source = {
 
12178
static const struct hda_input_mux alc262_ultra_capture_source = {
12051
12179
        .num_items = 2,
12052
12180
        .items = {
12053
12181
                { "Mic", 0x1 },
12073
12201
        return ret;
12074
12202
}
12075
12203
 
12076
 
static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
 
12204
static const struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12077
12205
        HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12078
12206
        HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12079
12207
        {
12148
12276
 
12149
12277
        spec->multiout.num_dacs = 1;    /* only use one dac */
12150
12278
        spec->multiout.dac_nids = spec->private_dac_nids;
12151
 
        spec->multiout.dac_nids[0] = 2;
 
12279
        spec->private_dac_nids[0] = 2;
12152
12280
 
12153
 
        pfx = alc_get_line_out_pfx(cfg, true);
 
12281
        pfx = alc_get_line_out_pfx(spec, true);
12154
12282
        if (!pfx)
12155
12283
                pfx = "Front";
12156
12284
        for (i = 0; i < 2; i++) {
12204
12332
/*
12205
12333
 * generic initialization of ADC, input mixers and output mixers
12206
12334
 */
12207
 
static struct hda_verb alc262_volume_init_verbs[] = {
 
12335
static const struct hda_verb alc262_volume_init_verbs[] = {
12208
12336
        /*
12209
12337
         * Unmute ADC0-2 and set the default input to mic-in
12210
12338
         */
12265
12393
        { }
12266
12394
};
12267
12395
 
12268
 
static struct hda_verb alc262_HP_BPC_init_verbs[] = {
 
12396
static const struct hda_verb alc262_HP_BPC_init_verbs[] = {
12269
12397
        /*
12270
12398
         * Unmute ADC0-2 and set the default input to mic-in
12271
12399
         */
12369
12497
        { }
12370
12498
};
12371
12499
 
12372
 
static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
 
12500
static const struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12373
12501
        /*
12374
12502
         * Unmute ADC0-2 and set the default input to mic-in
12375
12503
         */
12465
12593
        { }
12466
12594
};
12467
12595
 
12468
 
static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
 
12596
static const struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12469
12597
 
12470
12598
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },       /* Front Speaker */
12471
12599
        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12487
12615
 */
12488
12616
enum {
12489
12617
        PINFIX_FSC_H270,
 
12618
        PINFIX_HP_Z200,
12490
12619
};
12491
12620
 
12492
12621
static const struct alc_fixup alc262_fixups[] = {
12499
12628
                        { }
12500
12629
                }
12501
12630
        },
 
12631
        [PINFIX_HP_Z200] = {
 
12632
                .type = ALC_FIXUP_PINS,
 
12633
                .v.pins = (const struct alc_pincfg[]) {
 
12634
                        { 0x16, 0x99130120 }, /* internal speaker */
 
12635
                        { }
 
12636
                }
 
12637
        },
12502
12638
};
12503
12639
 
12504
 
static struct snd_pci_quirk alc262_fixup_tbl[] = {
 
12640
static const struct snd_pci_quirk alc262_fixup_tbl[] = {
 
12641
        SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", PINFIX_HP_Z200),
12505
12642
        SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12506
12643
        {}
12507
12644
};
12524
12661
{
12525
12662
        struct alc_spec *spec = codec->spec;
12526
12663
        int err;
12527
 
        static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
 
12664
        static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12528
12665
 
12529
12666
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12530
12667
                                           alc262_ignore);
12609
12746
        [ALC262_AUTO]           = "auto",
12610
12747
};
12611
12748
 
12612
 
static struct snd_pci_quirk alc262_cfg_tbl[] = {
 
12749
static const struct snd_pci_quirk alc262_cfg_tbl[] = {
12613
12750
        SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
12614
12751
        SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
12615
12752
        SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12618
12755
                           ALC262_HP_BPC),
12619
12756
        SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12620
12757
                           ALC262_HP_BPC),
 
12758
        SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200",
 
12759
                           ALC262_AUTO),
12621
12760
        SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12622
12761
                           ALC262_HP_BPC),
12623
12762
        SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
12661
12800
        {}
12662
12801
};
12663
12802
 
12664
 
static struct alc_config_preset alc262_presets[] = {
 
12803
static const struct alc_config_preset alc262_presets[] = {
12665
12804
        [ALC262_BASIC] = {
12666
12805
                .mixers = { alc262_base_mixer },
12667
12806
                .init_verbs = { alc262_init_verbs },
12682
12821
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12683
12822
                .channel_mode = alc262_modes,
12684
12823
                .input_mux = &alc262_capture_source,
12685
 
                .unsol_event = alc262_hippo_unsol_event,
 
12824
                .unsol_event = alc_sku_unsol_event,
12686
12825
                .setup = alc262_hippo_setup,
12687
 
                .init_hook = alc262_hippo_automute,
 
12826
                .init_hook = alc_inithook,
12688
12827
        },
12689
12828
        [ALC262_HIPPO_1] = {
12690
12829
                .mixers = { alc262_hippo1_mixer },
12696
12835
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12697
12836
                .channel_mode = alc262_modes,
12698
12837
                .input_mux = &alc262_capture_source,
12699
 
                .unsol_event = alc262_hippo_unsol_event,
 
12838
                .unsol_event = alc_sku_unsol_event,
12700
12839
                .setup = alc262_hippo1_setup,
12701
 
                .init_hook = alc262_hippo_automute,
 
12840
                .init_hook = alc_inithook,
12702
12841
        },
12703
12842
        [ALC262_FUJITSU] = {
12704
12843
                .mixers = { alc262_fujitsu_mixer },
12711
12850
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12712
12851
                .channel_mode = alc262_modes,
12713
12852
                .input_mux = &alc262_fujitsu_capture_source,
12714
 
                .unsol_event = alc262_fujitsu_unsol_event,
12715
 
                .init_hook = alc262_fujitsu_init_hook,
 
12853
                .unsol_event = alc_sku_unsol_event,
 
12854
                .setup = alc262_fujitsu_setup,
 
12855
                .init_hook = alc_inithook,
12716
12856
        },
12717
12857
        [ALC262_HP_BPC] = {
12718
12858
                .mixers = { alc262_HP_BPC_mixer },
12723
12863
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12724
12864
                .channel_mode = alc262_modes,
12725
12865
                .input_mux = &alc262_HP_capture_source,
12726
 
                .unsol_event = alc262_hp_bpc_unsol_event,
12727
 
                .init_hook = alc262_hp_bpc_automute,
 
12866
                .unsol_event = alc_sku_unsol_event,
 
12867
                .setup = alc262_hp_bpc_setup,
 
12868
                .init_hook = alc_inithook,
12728
12869
        },
12729
12870
        [ALC262_HP_BPC_D7000_WF] = {
12730
12871
                .mixers = { alc262_HP_BPC_WildWest_mixer },
12735
12876
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12736
12877
                .channel_mode = alc262_modes,
12737
12878
                .input_mux = &alc262_HP_D7000_capture_source,
12738
 
                .unsol_event = alc262_hp_wildwest_unsol_event,
12739
 
                .init_hook = alc262_hp_wildwest_automute,
 
12879
                .unsol_event = alc_sku_unsol_event,
 
12880
                .setup = alc262_hp_wildwest_setup,
 
12881
                .init_hook = alc_inithook,
12740
12882
        },
12741
12883
        [ALC262_HP_BPC_D7000_WL] = {
12742
12884
                .mixers = { alc262_HP_BPC_WildWest_mixer,
12748
12890
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12749
12891
                .channel_mode = alc262_modes,
12750
12892
                .input_mux = &alc262_HP_D7000_capture_source,
12751
 
                .unsol_event = alc262_hp_wildwest_unsol_event,
12752
 
                .init_hook = alc262_hp_wildwest_automute,
 
12893
                .unsol_event = alc_sku_unsol_event,
 
12894
                .setup = alc262_hp_wildwest_setup,
 
12895
                .init_hook = alc_inithook,
12753
12896
        },
12754
12897
        [ALC262_HP_TC_T5735] = {
12755
12898
                .mixers = { alc262_hp_t5735_mixer },
12792
12935
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12793
12936
                .channel_mode = alc262_modes,
12794
12937
                .input_mux = &alc262_capture_source,
12795
 
                .unsol_event = alc262_hippo_unsol_event,
 
12938
                .unsol_event = alc_sku_unsol_event,
12796
12939
                .setup = alc262_hippo_setup,
12797
 
                .init_hook = alc262_hippo_automute,
 
12940
                .init_hook = alc_inithook,
12798
12941
        },
12799
12942
        [ALC262_BENQ_T31] = {
12800
12943
                .mixers = { alc262_benq_t31_mixer },
12806
12949
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12807
12950
                .channel_mode = alc262_modes,
12808
12951
                .input_mux = &alc262_capture_source,
12809
 
                .unsol_event = alc262_hippo_unsol_event,
 
12952
                .unsol_event = alc_sku_unsol_event,
12810
12953
                .setup = alc262_hippo_setup,
12811
 
                .init_hook = alc262_hippo_automute,
 
12954
                .init_hook = alc_inithook,
12812
12955
        },
12813
12956
        [ALC262_ULTRA] = {
12814
12957
                .mixers = { alc262_ultra_mixer },
12837
12980
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12838
12981
                .channel_mode = alc262_modes,
12839
12982
                .input_mux = &alc262_fujitsu_capture_source,
12840
 
                .unsol_event = alc262_lenovo_3000_unsol_event,
 
12983
                .unsol_event = alc_sku_unsol_event,
 
12984
                .setup = alc262_lenovo_3000_setup,
 
12985
                .init_hook = alc_inithook,
12841
12986
        },
12842
12987
        [ALC262_NEC] = {
12843
12988
                .mixers = { alc262_nec_mixer },
12874
13019
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12875
13020
                .channel_mode = alc262_modes,
12876
13021
                .input_mux = &alc262_capture_source,
12877
 
                .unsol_event = alc262_hippo_unsol_event,
 
13022
                .unsol_event = alc_sku_unsol_event,
12878
13023
                .setup = alc262_hippo_setup,
12879
 
                .init_hook = alc262_hippo_automute,
 
13024
                .init_hook = alc_inithook,
12880
13025
        },
12881
13026
        [ALC262_TYAN] = {
12882
13027
                .mixers = { alc262_tyan_mixer },
12888
13033
                .num_channel_mode = ARRAY_SIZE(alc262_modes),
12889
13034
                .channel_mode = alc262_modes,
12890
13035
                .input_mux = &alc262_capture_source,
12891
 
                .unsol_event = alc_automute_amp_unsol_event,
 
13036
                .unsol_event = alc_sku_unsol_event,
12892
13037
                .setup = alc262_tyan_setup,
12893
 
                .init_hook = alc_automute_amp,
 
13038
                .init_hook = alc_hp_automute,
12894
13039
        },
12895
13040
};
12896
13041
 
13011
13156
        codec->patch_ops = alc_patch_ops;
13012
13157
        if (board_config == ALC262_AUTO)
13013
13158
                spec->init_hook = alc262_auto_init;
 
13159
        spec->shutup = alc_eapd_shutup;
13014
13160
 
13015
13161
        alc_init_jacks(codec);
13016
13162
#ifdef CONFIG_SND_HDA_POWER_SAVE
13027
13173
#define ALC268_DIGOUT_NID       ALC880_DIGOUT_NID
13028
13174
#define alc268_modes            alc260_modes
13029
13175
 
13030
 
static hda_nid_t alc268_dac_nids[2] = {
 
13176
static const hda_nid_t alc268_dac_nids[2] = {
13031
13177
        /* front, hp */
13032
13178
        0x02, 0x03
13033
13179
};
13034
13180
 
13035
 
static hda_nid_t alc268_adc_nids[2] = {
 
13181
static const hda_nid_t alc268_adc_nids[2] = {
13036
13182
        /* ADC0-1 */
13037
13183
        0x08, 0x07
13038
13184
};
13039
13185
 
13040
 
static hda_nid_t alc268_adc_nids_alt[1] = {
 
13186
static const hda_nid_t alc268_adc_nids_alt[1] = {
13041
13187
        /* ADC0 */
13042
13188
        0x08
13043
13189
};
13044
13190
 
13045
 
static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
 
13191
static const hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13046
13192
 
13047
 
static struct snd_kcontrol_new alc268_base_mixer[] = {
 
13193
static const struct snd_kcontrol_new alc268_base_mixer[] = {
13048
13194
        /* output mixer control */
13049
13195
        HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13050
13196
        HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13056
13202
        { }
13057
13203
};
13058
13204
 
13059
 
static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
 
13205
static const struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13060
13206
        /* output mixer control */
13061
13207
        HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13062
13208
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13068
13214
};
13069
13215
 
13070
13216
/* bind Beep switches of both NID 0x0f and 0x10 */
13071
 
static struct hda_bind_ctls alc268_bind_beep_sw = {
 
13217
static const struct hda_bind_ctls alc268_bind_beep_sw = {
13072
13218
        .ops = &snd_hda_bind_sw,
13073
13219
        .values = {
13074
13220
                HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13077
13223
        },
13078
13224
};
13079
13225
 
13080
 
static struct snd_kcontrol_new alc268_beep_mixer[] = {
 
13226
static const struct snd_kcontrol_new alc268_beep_mixer[] = {
13081
13227
        HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13082
13228
        HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13083
13229
        { }
13084
13230
};
13085
13231
 
13086
 
static struct hda_verb alc268_eapd_verbs[] = {
 
13232
static const struct hda_verb alc268_eapd_verbs[] = {
13087
13233
        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13088
13234
        {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13089
13235
        { }
13090
13236
};
13091
13237
 
13092
13238
/* Toshiba specific */
13093
 
static struct hda_verb alc268_toshiba_verbs[] = {
 
13239
static const struct hda_verb alc268_toshiba_verbs[] = {
13094
13240
        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13095
13241
        { } /* end */
13096
13242
};
13097
13243
 
13098
13244
/* Acer specific */
13099
13245
/* bind volumes of both NID 0x02 and 0x03 */
13100
 
static struct hda_bind_ctls alc268_acer_bind_master_vol = {
 
13246
static const struct hda_bind_ctls alc268_acer_bind_master_vol = {
13101
13247
        .ops = &snd_hda_bind_vol,
13102
13248
        .values = {
13103
13249
                HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13106
13252
        },
13107
13253
};
13108
13254
 
13109
 
/* mute/unmute internal speaker according to the hp jack and mute state */
13110
 
static void alc268_acer_automute(struct hda_codec *codec, int force)
 
13255
static void alc268_acer_setup(struct hda_codec *codec)
13111
13256
{
13112
13257
        struct alc_spec *spec = codec->spec;
13113
 
        unsigned int mute;
13114
 
 
13115
 
        if (force || !spec->sense_updated) {
13116
 
                spec->jack_present = snd_hda_jack_detect(codec, 0x14);
13117
 
                spec->sense_updated = 1;
13118
 
        }
13119
 
        if (spec->jack_present)
13120
 
                mute = HDA_AMP_MUTE; /* mute internal speaker */
13121
 
        else /* unmute internal speaker if necessary */
13122
 
                mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13123
 
        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13124
 
                                 HDA_AMP_MUTE, mute);
13125
 
}
13126
 
 
13127
 
 
13128
 
/* bind hp and internal speaker mute (with plug check) */
13129
 
static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13130
 
                                     struct snd_ctl_elem_value *ucontrol)
13131
 
{
13132
 
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13133
 
        long *valp = ucontrol->value.integer.value;
13134
 
        int change;
13135
 
 
13136
 
        change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
13137
 
        if (change)
13138
 
                alc268_acer_automute(codec, 0);
13139
 
        return change;
13140
 
}
13141
 
 
13142
 
static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
 
13258
 
 
13259
        spec->autocfg.hp_pins[0] = 0x14;
 
13260
        spec->autocfg.speaker_pins[0] = 0x15;
 
13261
        spec->automute = 1;
 
13262
        spec->automute_mode = ALC_AUTOMUTE_AMP;
 
13263
}
 
13264
 
 
13265
#define alc268_acer_master_sw_get       alc262_hp_master_sw_get
 
13266
#define alc268_acer_master_sw_put       alc262_hp_master_sw_put
 
13267
 
 
13268
static const struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13143
13269
        /* output mixer control */
13144
13270
        HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13145
13271
        {
13146
13272
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13147
13273
                .name = "Master Playback Switch",
13148
 
                .subdevice = HDA_SUBDEV_AMP_FLAG,
13149
 
                .info = snd_hda_mixer_amp_switch_info,
13150
 
                .get = snd_hda_mixer_amp_switch_get,
 
13274
                .subdevice = HDA_SUBDEV_NID_FLAG | 0x15,
 
13275
                .info = snd_ctl_boolean_mono_info,
 
13276
                .get = alc268_acer_master_sw_get,
13151
13277
                .put = alc268_acer_master_sw_put,
13152
 
                .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13153
13278
        },
13154
13279
        HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13155
13280
        { }
13156
13281
};
13157
13282
 
13158
 
static struct snd_kcontrol_new alc268_acer_mixer[] = {
 
13283
static const struct snd_kcontrol_new alc268_acer_mixer[] = {
13159
13284
        /* output mixer control */
13160
13285
        HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13161
13286
        {
13162
13287
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13163
13288
                .name = "Master Playback Switch",
13164
 
                .subdevice = HDA_SUBDEV_AMP_FLAG,
13165
 
                .info = snd_hda_mixer_amp_switch_info,
13166
 
                .get = snd_hda_mixer_amp_switch_get,
 
13289
                .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
 
13290
                .info = snd_ctl_boolean_mono_info,
 
13291
                .get = alc268_acer_master_sw_get,
13167
13292
                .put = alc268_acer_master_sw_put,
13168
 
                .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13169
13293
        },
13170
13294
        HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13171
13295
        HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13173
13297
        { }
13174
13298
};
13175
13299
 
13176
 
static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
 
13300
static const struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13177
13301
        /* output mixer control */
13178
13302
        HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13179
13303
        {
13180
13304
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13181
13305
                .name = "Master Playback Switch",
13182
 
                .subdevice = HDA_SUBDEV_AMP_FLAG,
13183
 
                .info = snd_hda_mixer_amp_switch_info,
13184
 
                .get = snd_hda_mixer_amp_switch_get,
 
13306
                .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
 
13307
                .info = snd_ctl_boolean_mono_info,
 
13308
                .get = alc268_acer_master_sw_get,
13185
13309
                .put = alc268_acer_master_sw_put,
13186
 
                .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13187
13310
        },
13188
13311
        HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13189
13312
        HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
13190
13313
        { }
13191
13314
};
13192
13315
 
13193
 
static struct hda_verb alc268_acer_aspire_one_verbs[] = {
 
13316
static const struct hda_verb alc268_acer_aspire_one_verbs[] = {
13194
13317
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13195
13318
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13196
13319
        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13200
13323
        { }
13201
13324
};
13202
13325
 
13203
 
static struct hda_verb alc268_acer_verbs[] = {
 
13326
static const struct hda_verb alc268_acer_verbs[] = {
13204
13327
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13205
13328
        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13206
13329
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13212
13335
};
13213
13336
 
13214
13337
/* unsolicited event for HP jack sensing */
13215
 
#define alc268_toshiba_unsol_event      alc262_hippo_unsol_event
13216
13338
#define alc268_toshiba_setup            alc262_hippo_setup
13217
 
#define alc268_toshiba_automute         alc262_hippo_automute
13218
 
 
13219
 
static void alc268_acer_unsol_event(struct hda_codec *codec,
13220
 
                                       unsigned int res)
13221
 
{
13222
 
        if ((res >> 26) != ALC880_HP_EVENT)
13223
 
                return;
13224
 
        alc268_acer_automute(codec, 1);
13225
 
}
13226
 
 
13227
 
static void alc268_acer_init_hook(struct hda_codec *codec)
13228
 
{
13229
 
        alc268_acer_automute(codec, 1);
13230
 
}
13231
 
 
13232
 
/* toggle speaker-output according to the hp-jack state */
13233
 
static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13234
 
{
13235
 
        unsigned int present;
13236
 
        unsigned char bits;
13237
 
 
13238
 
        present = snd_hda_jack_detect(codec, 0x15);
13239
 
        bits = present ? HDA_AMP_MUTE : 0;
13240
 
        snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
13241
 
                                 HDA_AMP_MUTE, bits);
13242
 
        snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
13243
 
                                 HDA_AMP_MUTE, bits);
13244
 
}
13245
 
 
13246
 
static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13247
 
                                    unsigned int res)
13248
 
{
13249
 
        switch (res >> 26) {
13250
 
        case ALC880_HP_EVENT:
13251
 
                alc268_aspire_one_speaker_automute(codec);
13252
 
                break;
13253
 
        case ALC880_MIC_EVENT:
13254
 
                alc_mic_automute(codec);
13255
 
                break;
13256
 
        }
13257
 
}
13258
13339
 
13259
13340
static void alc268_acer_lc_setup(struct hda_codec *codec)
13260
13341
{
13261
13342
        struct alc_spec *spec = codec->spec;
 
13343
        spec->autocfg.hp_pins[0] = 0x15;
 
13344
        spec->autocfg.speaker_pins[0] = 0x14;
 
13345
        spec->automute = 1;
 
13346
        spec->automute_mode = ALC_AUTOMUTE_AMP;
13262
13347
        spec->ext_mic.pin = 0x18;
13263
13348
        spec->ext_mic.mux_idx = 0;
13264
13349
        spec->int_mic.pin = 0x12;
13266
13351
        spec->auto_mic = 1;
13267
13352
}
13268
13353
 
13269
 
static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13270
 
{
13271
 
        alc268_aspire_one_speaker_automute(codec);
13272
 
        alc_mic_automute(codec);
13273
 
}
13274
 
 
13275
 
static struct snd_kcontrol_new alc268_dell_mixer[] = {
 
13354
static const struct snd_kcontrol_new alc268_dell_mixer[] = {
13276
13355
        /* output mixer control */
13277
13356
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13278
13357
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13283
13362
        { }
13284
13363
};
13285
13364
 
13286
 
static struct hda_verb alc268_dell_verbs[] = {
 
13365
static const struct hda_verb alc268_dell_verbs[] = {
13287
13366
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13288
13367
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13289
13368
        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13303
13382
        spec->int_mic.pin = 0x19;
13304
13383
        spec->int_mic.mux_idx = 1;
13305
13384
        spec->auto_mic = 1;
 
13385
        spec->automute = 1;
 
13386
        spec->automute_mode = ALC_AUTOMUTE_PIN;
13306
13387
}
13307
13388
 
13308
 
static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
 
13389
static const struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13309
13390
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13310
13391
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13311
13392
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13317
13398
        { }
13318
13399
};
13319
13400
 
13320
 
static struct hda_verb alc267_quanta_il1_verbs[] = {
 
13401
static const struct hda_verb alc267_quanta_il1_verbs[] = {
13321
13402
        {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13322
13403
        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13323
13404
        { }
13333
13414
        spec->int_mic.pin = 0x19;
13334
13415
        spec->int_mic.mux_idx = 1;
13335
13416
        spec->auto_mic = 1;
 
13417
        spec->automute = 1;
 
13418
        spec->automute_mode = ALC_AUTOMUTE_PIN;
13336
13419
}
13337
13420
 
13338
13421
/*
13339
13422
 * generic initialization of ADC, input mixers and output mixers
13340
13423
 */
13341
 
static struct hda_verb alc268_base_init_verbs[] = {
 
13424
static const struct hda_verb alc268_base_init_verbs[] = {
13342
13425
        /* Unmute DAC0-1 and set vol = 0 */
13343
13426
        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13344
13427
        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13386
13469
/*
13387
13470
 * generic initialization of ADC, input mixers and output mixers
13388
13471
 */
13389
 
static struct hda_verb alc268_volume_init_verbs[] = {
 
13472
static const struct hda_verb alc268_volume_init_verbs[] = {
13390
13473
        /* set output DAC */
13391
13474
        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13392
13475
        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13412
13495
        { }
13413
13496
};
13414
13497
 
13415
 
static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
 
13498
static const struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13416
13499
        HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13417
13500
        HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13418
13501
        { } /* end */
13419
13502
};
13420
13503
 
13421
 
static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
 
13504
static const struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13422
13505
        HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13423
13506
        HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13424
13507
        _DEFINE_CAPSRC(1),
13425
13508
        { } /* end */
13426
13509
};
13427
13510
 
13428
 
static struct snd_kcontrol_new alc268_capture_mixer[] = {
 
13511
static const struct snd_kcontrol_new alc268_capture_mixer[] = {
13429
13512
        HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13430
13513
        HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13431
13514
        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13434
13517
        { } /* end */
13435
13518
};
13436
13519
 
13437
 
static struct hda_input_mux alc268_capture_source = {
 
13520
static const struct hda_input_mux alc268_capture_source = {
13438
13521
        .num_items = 4,
13439
13522
        .items = {
13440
13523
                { "Mic", 0x0 },
13444
13527
        },
13445
13528
};
13446
13529
 
13447
 
static struct hda_input_mux alc268_acer_capture_source = {
 
13530
static const struct hda_input_mux alc268_acer_capture_source = {
13448
13531
        .num_items = 3,
13449
13532
        .items = {
13450
13533
                { "Mic", 0x0 },
13453
13536
        },
13454
13537
};
13455
13538
 
13456
 
static struct hda_input_mux alc268_acer_dmic_capture_source = {
 
13539
static const struct hda_input_mux alc268_acer_dmic_capture_source = {
13457
13540
        .num_items = 3,
13458
13541
        .items = {
13459
13542
                { "Mic", 0x0 },
13463
13546
};
13464
13547
 
13465
13548
#ifdef CONFIG_SND_DEBUG
13466
 
static struct snd_kcontrol_new alc268_test_mixer[] = {
 
13549
static const struct snd_kcontrol_new alc268_test_mixer[] = {
13467
13550
        /* Volume widgets */
13468
13551
        HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13469
13552
        HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13542
13625
                                                      HDA_OUTPUT));
13543
13626
                if (err < 0)
13544
13627
                        return err;
13545
 
                spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
 
13628
                spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
13546
13629
        }
13547
13630
 
13548
13631
        if (nid != 0x16)
13715
13798
{
13716
13799
        struct alc_spec *spec = codec->spec;
13717
13800
        int err;
13718
 
        static hda_nid_t alc268_ignore[] = { 0 };
 
13801
        static const hda_nid_t alc268_ignore[] = { 0 };
13719
13802
 
13720
13803
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13721
13804
                                           alc268_ignore);
13795
13878
        [ALC268_AUTO]           = "auto",
13796
13879
};
13797
13880
 
13798
 
static struct snd_pci_quirk alc268_cfg_tbl[] = {
 
13881
static const struct snd_pci_quirk alc268_cfg_tbl[] = {
13799
13882
        SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
13800
13883
        SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
13801
13884
        SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
13804
13887
        SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13805
13888
                                                ALC268_ACER_ASPIRE_ONE),
13806
13889
        SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
 
13890
        SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron 910", ALC268_AUTO),
13807
13891
        SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13808
13892
                        "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
13809
13893
        /* almost compatible with toshiba but with optional digital outs;
13814
13898
        SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
13815
13899
        SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
13816
13900
        SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
13817
 
        SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
13818
13901
        SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
13819
13902
        {}
13820
13903
};
13821
13904
 
13822
13905
/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13823
 
static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
 
13906
static const struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13824
13907
        SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13825
13908
        SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13826
13909
        SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13828
13911
        {}
13829
13912
};
13830
13913
 
13831
 
static struct alc_config_preset alc268_presets[] = {
 
13914
static const struct alc_config_preset alc268_presets[] = {
13832
13915
        [ALC267_QUANTA_IL1] = {
13833
13916
                .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13834
13917
                            alc268_capture_nosrc_mixer },
13874
13957
                .num_channel_mode = ARRAY_SIZE(alc268_modes),
13875
13958
                .channel_mode = alc268_modes,
13876
13959
                .input_mux = &alc268_capture_source,
13877
 
                .unsol_event = alc268_toshiba_unsol_event,
 
13960
                .unsol_event = alc_sku_unsol_event,
13878
13961
                .setup = alc268_toshiba_setup,
13879
 
                .init_hook = alc268_toshiba_automute,
 
13962
                .init_hook = alc_inithook,
13880
13963
        },
13881
13964
        [ALC268_ACER] = {
13882
13965
                .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
13892
13975
                .num_channel_mode = ARRAY_SIZE(alc268_modes),
13893
13976
                .channel_mode = alc268_modes,
13894
13977
                .input_mux = &alc268_acer_capture_source,
13895
 
                .unsol_event = alc268_acer_unsol_event,
13896
 
                .init_hook = alc268_acer_init_hook,
 
13978
                .unsol_event = alc_sku_unsol_event,
 
13979
                .setup = alc268_acer_setup,
 
13980
                .init_hook = alc_inithook,
13897
13981
        },
13898
13982
        [ALC268_ACER_DMIC] = {
13899
13983
                .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13909
13993
                .num_channel_mode = ARRAY_SIZE(alc268_modes),
13910
13994
                .channel_mode = alc268_modes,
13911
13995
                .input_mux = &alc268_acer_dmic_capture_source,
13912
 
                .unsol_event = alc268_acer_unsol_event,
13913
 
                .init_hook = alc268_acer_init_hook,
 
13996
                .unsol_event = alc_sku_unsol_event,
 
13997
                .setup = alc268_acer_setup,
 
13998
                .init_hook = alc_inithook,
13914
13999
        },
13915
14000
        [ALC268_ACER_ASPIRE_ONE] = {
13916
14001
                .mixers = { alc268_acer_aspire_one_mixer,
13926
14011
                .hp_nid = 0x03,
13927
14012
                .num_channel_mode = ARRAY_SIZE(alc268_modes),
13928
14013
                .channel_mode = alc268_modes,
13929
 
                .unsol_event = alc268_acer_lc_unsol_event,
 
14014
                .unsol_event = alc_sku_unsol_event,
13930
14015
                .setup = alc268_acer_lc_setup,
13931
 
                .init_hook = alc268_acer_lc_init_hook,
 
14016
                .init_hook = alc_inithook,
13932
14017
        },
13933
14018
        [ALC268_DELL] = {
13934
14019
                .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13962
14047
                .num_channel_mode = ARRAY_SIZE(alc268_modes),
13963
14048
                .channel_mode = alc268_modes,
13964
14049
                .input_mux = &alc268_capture_source,
 
14050
                .unsol_event = alc_sku_unsol_event,
13965
14051
                .setup = alc268_toshiba_setup,
13966
 
                .init_hook = alc268_toshiba_automute,
 
14052
                .init_hook = alc_inithook,
13967
14053
        },
13968
14054
#ifdef CONFIG_SND_DEBUG
13969
14055
        [ALC268_TEST] = {
14085
14171
        codec->patch_ops = alc_patch_ops;
14086
14172
        if (board_config == ALC268_AUTO)
14087
14173
                spec->init_hook = alc268_auto_init;
 
14174
        spec->shutup = alc_eapd_shutup;
14088
14175
 
14089
14176
        alc_init_jacks(codec);
14090
14177
 
14098
14185
 
14099
14186
#define alc269_dac_nids         alc260_dac_nids
14100
14187
 
14101
 
static hda_nid_t alc269_adc_nids[1] = {
 
14188
static const hda_nid_t alc269_adc_nids[1] = {
14102
14189
        /* ADC1 */
14103
14190
        0x08,
14104
14191
};
14105
14192
 
14106
 
static hda_nid_t alc269_capsrc_nids[1] = {
 
14193
static const hda_nid_t alc269_capsrc_nids[1] = {
14107
14194
        0x23,
14108
14195
};
14109
14196
 
14110
 
static hda_nid_t alc269vb_adc_nids[1] = {
 
14197
static const hda_nid_t alc269vb_adc_nids[1] = {
14111
14198
        /* ADC1 */
14112
14199
        0x09,
14113
14200
};
14114
14201
 
14115
 
static hda_nid_t alc269vb_capsrc_nids[1] = {
 
14202
static const hda_nid_t alc269vb_capsrc_nids[1] = {
14116
14203
        0x22,
14117
14204
};
14118
14205
 
14119
 
static hda_nid_t alc269_adc_candidates[] = {
 
14206
static const hda_nid_t alc269_adc_candidates[] = {
14120
14207
        0x08, 0x09, 0x07, 0x11,
14121
14208
};
14122
14209
 
14123
14210
#define alc269_modes            alc260_modes
14124
14211
#define alc269_capture_source   alc880_lg_lw_capture_source
14125
14212
 
14126
 
static struct snd_kcontrol_new alc269_base_mixer[] = {
 
14213
static const struct snd_kcontrol_new alc269_base_mixer[] = {
14127
14214
        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14128
14215
        HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14129
14216
        HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14139
14226
        { } /* end */
14140
14227
};
14141
14228
 
14142
 
static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
 
14229
static const struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14143
14230
        /* output mixer control */
14144
14231
        HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14145
14232
        {
14160
14247
        { }
14161
14248
};
14162
14249
 
14163
 
static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
 
14250
static const struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14164
14251
        /* output mixer control */
14165
14252
        HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14166
14253
        {
14184
14271
        { }
14185
14272
};
14186
14273
 
14187
 
static struct snd_kcontrol_new alc269_laptop_mixer[] = {
 
14274
static const struct snd_kcontrol_new alc269_laptop_mixer[] = {
14188
14275
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14189
14276
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14190
14277
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14192
14279
        { } /* end */
14193
14280
};
14194
14281
 
14195
 
static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
 
14282
static const struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14196
14283
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14197
14284
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14198
14285
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14200
14287
        { } /* end */
14201
14288
};
14202
14289
 
14203
 
static struct snd_kcontrol_new alc269_asus_mixer[] = {
 
14290
static const struct snd_kcontrol_new alc269_asus_mixer[] = {
14204
14291
        HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14205
14292
        HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14206
14293
        { } /* end */
14207
14294
};
14208
14295
 
14209
14296
/* capture mixer elements */
14210
 
static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
 
14297
static const struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14211
14298
        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14212
14299
        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14213
14300
        HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14215
14302
        { } /* end */
14216
14303
};
14217
14304
 
14218
 
static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
 
14305
static const struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
14219
14306
        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14220
14307
        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14221
14308
        HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14222
14309
        { } /* end */
14223
14310
};
14224
14311
 
14225
 
static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
 
14312
static const struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14226
14313
        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14227
14314
        HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14228
14315
        HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14230
14317
        { } /* end */
14231
14318
};
14232
14319
 
14233
 
static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
 
14320
static const struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14234
14321
        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14235
14322
        HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14236
14323
        HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14240
14327
/* FSC amilo */
14241
14328
#define alc269_fujitsu_mixer    alc269_laptop_mixer
14242
14329
 
14243
 
static struct hda_verb alc269_quanta_fl1_verbs[] = {
 
14330
static const struct hda_verb alc269_quanta_fl1_verbs[] = {
14244
14331
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14245
14332
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14246
14333
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14250
14337
        { }
14251
14338
};
14252
14339
 
14253
 
static struct hda_verb alc269_lifebook_verbs[] = {
 
14340
static const struct hda_verb alc269_lifebook_verbs[] = {
14254
14341
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14255
14342
        {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14256
14343
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14267
14354
/* toggle speaker-output according to the hp-jack state */
14268
14355
static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14269
14356
{
14270
 
        unsigned int present;
14271
 
        unsigned char bits;
14272
 
 
14273
 
        present = snd_hda_jack_detect(codec, 0x15);
14274
 
        bits = present ? HDA_AMP_MUTE : 0;
14275
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
14276
 
                                 HDA_AMP_MUTE, bits);
14277
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
14278
 
                                 HDA_AMP_MUTE, bits);
14279
 
 
14280
 
        snd_hda_codec_write(codec, 0x20, 0,
14281
 
                        AC_VERB_SET_COEF_INDEX, 0x0c);
14282
 
        snd_hda_codec_write(codec, 0x20, 0,
14283
 
                        AC_VERB_SET_PROC_COEF, 0x680);
14284
 
 
14285
 
        snd_hda_codec_write(codec, 0x20, 0,
14286
 
                        AC_VERB_SET_COEF_INDEX, 0x0c);
14287
 
        snd_hda_codec_write(codec, 0x20, 0,
14288
 
                        AC_VERB_SET_PROC_COEF, 0x480);
14289
 
}
14290
 
 
14291
 
/* toggle speaker-output according to the hp-jacks state */
14292
 
static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14293
 
{
14294
 
        unsigned int present;
14295
 
        unsigned char bits;
14296
 
 
14297
 
        /* Check laptop headphone socket */
14298
 
        present = snd_hda_jack_detect(codec, 0x15);
14299
 
 
14300
 
        /* Check port replicator headphone socket */
14301
 
        present |= snd_hda_jack_detect(codec, 0x1a);
14302
 
 
14303
 
        bits = present ? HDA_AMP_MUTE : 0;
14304
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
14305
 
                                 HDA_AMP_MUTE, bits);
14306
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
14307
 
                                 HDA_AMP_MUTE, bits);
14308
 
 
14309
 
        snd_hda_codec_write(codec, 0x20, 0,
14310
 
                        AC_VERB_SET_COEF_INDEX, 0x0c);
14311
 
        snd_hda_codec_write(codec, 0x20, 0,
14312
 
                        AC_VERB_SET_PROC_COEF, 0x680);
14313
 
 
14314
 
        snd_hda_codec_write(codec, 0x20, 0,
14315
 
                        AC_VERB_SET_COEF_INDEX, 0x0c);
14316
 
        snd_hda_codec_write(codec, 0x20, 0,
14317
 
                        AC_VERB_SET_PROC_COEF, 0x480);
14318
 
}
 
14357
        alc_hp_automute(codec);
 
14358
 
 
14359
        snd_hda_codec_write(codec, 0x20, 0,
 
14360
                        AC_VERB_SET_COEF_INDEX, 0x0c);
 
14361
        snd_hda_codec_write(codec, 0x20, 0,
 
14362
                        AC_VERB_SET_PROC_COEF, 0x680);
 
14363
 
 
14364
        snd_hda_codec_write(codec, 0x20, 0,
 
14365
                        AC_VERB_SET_COEF_INDEX, 0x0c);
 
14366
        snd_hda_codec_write(codec, 0x20, 0,
 
14367
                        AC_VERB_SET_PROC_COEF, 0x480);
 
14368
}
 
14369
 
 
14370
#define alc269_lifebook_speaker_automute \
 
14371
        alc269_quanta_fl1_speaker_automute
14319
14372
 
14320
14373
static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14321
14374
{
14364
14417
        struct alc_spec *spec = codec->spec;
14365
14418
        spec->autocfg.hp_pins[0] = 0x15;
14366
14419
        spec->autocfg.speaker_pins[0] = 0x14;
 
14420
        spec->automute_mixer_nid[0] = 0x0c;
 
14421
        spec->automute = 1;
 
14422
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
14367
14423
        spec->ext_mic.pin = 0x18;
14368
14424
        spec->ext_mic.mux_idx = 0;
14369
14425
        spec->int_mic.pin = 0x19;
14377
14433
        alc_mic_automute(codec);
14378
14434
}
14379
14435
 
 
14436
static void alc269_lifebook_setup(struct hda_codec *codec)
 
14437
{
 
14438
        struct alc_spec *spec = codec->spec;
 
14439
        spec->autocfg.hp_pins[0] = 0x15;
 
14440
        spec->autocfg.hp_pins[1] = 0x1a;
 
14441
        spec->autocfg.speaker_pins[0] = 0x14;
 
14442
        spec->automute_mixer_nid[0] = 0x0c;
 
14443
        spec->automute = 1;
 
14444
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
 
14445
}
 
14446
 
14380
14447
static void alc269_lifebook_init_hook(struct hda_codec *codec)
14381
14448
{
14382
14449
        alc269_lifebook_speaker_automute(codec);
14383
14450
        alc269_lifebook_mic_autoswitch(codec);
14384
14451
}
14385
14452
 
14386
 
static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
 
14453
static const struct hda_verb alc269_laptop_dmic_init_verbs[] = {
14387
14454
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14388
14455
        {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14389
14456
        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14394
14461
        {}
14395
14462
};
14396
14463
 
14397
 
static struct hda_verb alc269_laptop_amic_init_verbs[] = {
 
14464
static const struct hda_verb alc269_laptop_amic_init_verbs[] = {
14398
14465
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14399
14466
        {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14400
14467
        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14404
14471
        {}
14405
14472
};
14406
14473
 
14407
 
static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
 
14474
static const struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14408
14475
        {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14409
14476
        {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14410
14477
        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14415
14482
        {}
14416
14483
};
14417
14484
 
14418
 
static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
 
14485
static const struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14419
14486
        {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14420
14487
        {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14421
14488
        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14426
14493
        {}
14427
14494
};
14428
14495
 
14429
 
static struct hda_verb alc271_acer_dmic_verbs[] = {
 
14496
static const struct hda_verb alc271_acer_dmic_verbs[] = {
14430
14497
        {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14431
14498
        {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14432
14499
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14440
14507
        { }
14441
14508
};
14442
14509
 
14443
 
/* toggle speaker-output according to the hp-jack state */
14444
 
static void alc269_speaker_automute(struct hda_codec *codec)
14445
 
{
14446
 
        struct alc_spec *spec = codec->spec;
14447
 
        unsigned int nid = spec->autocfg.hp_pins[0];
14448
 
        unsigned int present;
14449
 
        unsigned char bits;
14450
 
 
14451
 
        present = snd_hda_jack_detect(codec, nid);
14452
 
        bits = present ? HDA_AMP_MUTE : 0;
14453
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
14454
 
                                 HDA_AMP_MUTE, bits);
14455
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
14456
 
                                 HDA_AMP_MUTE, bits);
14457
 
        snd_hda_input_jack_report(codec, nid);
14458
 
}
14459
 
 
14460
 
/* unsolicited event for HP jack sensing */
14461
 
static void alc269_laptop_unsol_event(struct hda_codec *codec,
14462
 
                                     unsigned int res)
14463
 
{
14464
 
        switch (res >> 26) {
14465
 
        case ALC880_HP_EVENT:
14466
 
                alc269_speaker_automute(codec);
14467
 
                break;
14468
 
        case ALC880_MIC_EVENT:
14469
 
                alc_mic_automute(codec);
14470
 
                break;
14471
 
        }
14472
 
}
14473
 
 
14474
14510
static void alc269_laptop_amic_setup(struct hda_codec *codec)
14475
14511
{
14476
14512
        struct alc_spec *spec = codec->spec;
14477
14513
        spec->autocfg.hp_pins[0] = 0x15;
14478
14514
        spec->autocfg.speaker_pins[0] = 0x14;
 
14515
        spec->automute_mixer_nid[0] = 0x0c;
 
14516
        spec->automute = 1;
 
14517
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
14479
14518
        spec->ext_mic.pin = 0x18;
14480
14519
        spec->ext_mic.mux_idx = 0;
14481
14520
        spec->int_mic.pin = 0x19;
14488
14527
        struct alc_spec *spec = codec->spec;
14489
14528
        spec->autocfg.hp_pins[0] = 0x15;
14490
14529
        spec->autocfg.speaker_pins[0] = 0x14;
 
14530
        spec->automute_mixer_nid[0] = 0x0c;
 
14531
        spec->automute = 1;
 
14532
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
14491
14533
        spec->ext_mic.pin = 0x18;
14492
14534
        spec->ext_mic.mux_idx = 0;
14493
14535
        spec->int_mic.pin = 0x12;
14500
14542
        struct alc_spec *spec = codec->spec;
14501
14543
        spec->autocfg.hp_pins[0] = 0x21;
14502
14544
        spec->autocfg.speaker_pins[0] = 0x14;
 
14545
        spec->automute_mixer_nid[0] = 0x0c;
 
14546
        spec->automute = 1;
 
14547
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
14503
14548
        spec->ext_mic.pin = 0x18;
14504
14549
        spec->ext_mic.mux_idx = 0;
14505
14550
        spec->int_mic.pin = 0x19;
14512
14557
        struct alc_spec *spec = codec->spec;
14513
14558
        spec->autocfg.hp_pins[0] = 0x21;
14514
14559
        spec->autocfg.speaker_pins[0] = 0x14;
 
14560
        spec->automute_mixer_nid[0] = 0x0c;
 
14561
        spec->automute = 1;
 
14562
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
14515
14563
        spec->ext_mic.pin = 0x18;
14516
14564
        spec->ext_mic.mux_idx = 0;
14517
14565
        spec->int_mic.pin = 0x12;
14519
14567
        spec->auto_mic = 1;
14520
14568
}
14521
14569
 
14522
 
static void alc269_laptop_inithook(struct hda_codec *codec)
14523
 
{
14524
 
        alc269_speaker_automute(codec);
14525
 
        alc_mic_automute(codec);
14526
 
}
14527
 
 
14528
14570
/*
14529
14571
 * generic initialization of ADC, input mixers and output mixers
14530
14572
 */
14531
 
static struct hda_verb alc269_init_verbs[] = {
 
14573
static const struct hda_verb alc269_init_verbs[] = {
14532
14574
        /*
14533
14575
         * Unmute ADC0 and set the default input to mic-in
14534
14576
         */
14571
14613
        { }
14572
14614
};
14573
14615
 
14574
 
static struct hda_verb alc269vb_init_verbs[] = {
 
14616
static const struct hda_verb alc269vb_init_verbs[] = {
14575
14617
        /*
14576
14618
         * Unmute ADC0 and set the default input to mic-in
14577
14619
         */
14629
14671
#define alc269_pcm_digital_playback     alc880_pcm_digital_playback
14630
14672
#define alc269_pcm_digital_capture      alc880_pcm_digital_capture
14631
14673
 
14632
 
static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
 
14674
static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14633
14675
        .substreams = 1,
14634
14676
        .channels_min = 2,
14635
14677
        .channels_max = 8,
14642
14684
        },
14643
14685
};
14644
14686
 
14645
 
static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
 
14687
static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14646
14688
        .substreams = 1,
14647
14689
        .channels_min = 2,
14648
14690
        .channels_max = 2,
14726
14768
{
14727
14769
        struct alc_spec *spec = codec->spec;
14728
14770
        int err;
14729
 
        static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
 
14771
        static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14730
14772
 
14731
14773
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14732
14774
                                           alc269_ignore);
14796
14838
                alc_inithook(codec);
14797
14839
}
14798
14840
 
14799
 
#ifdef SND_HDA_NEEDS_RESUME
14800
14841
static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14801
14842
{
14802
14843
        int val = alc_read_coef_idx(codec, 0x04);
14807
14848
        alc_write_coef_idx(codec, 0x04, val);
14808
14849
}
14809
14850
 
14810
 
#ifdef CONFIG_SND_HDA_POWER_SAVE
14811
 
static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
 
14851
static void alc269_shutup(struct hda_codec *codec)
14812
14852
{
14813
 
        struct alc_spec *spec = codec->spec;
14814
 
 
14815
14853
        if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14816
14854
                alc269_toggle_power_output(codec, 0);
14817
14855
        if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14818
14856
                alc269_toggle_power_output(codec, 0);
14819
14857
                msleep(150);
14820
14858
        }
14821
 
 
14822
 
        alc_shutup(codec);
14823
 
        if (spec && spec->power_hook)
14824
 
                spec->power_hook(codec);
14825
 
        return 0;
14826
14859
}
14827
 
#endif /* CONFIG_SND_HDA_POWER_SAVE */
14828
14860
 
 
14861
#ifdef SND_HDA_NEEDS_RESUME
14829
14862
static int alc269_resume(struct hda_codec *codec)
14830
14863
{
14831
14864
        if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14864
14897
static void alc271_fixup_dmic(struct hda_codec *codec,
14865
14898
                              const struct alc_fixup *fix, int action)
14866
14899
{
14867
 
        static struct hda_verb verbs[] = {
 
14900
        static const struct hda_verb verbs[] = {
14868
14901
                {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14869
14902
                {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14870
14903
                {}
14947
14980
        },
14948
14981
};
14949
14982
 
14950
 
static struct snd_pci_quirk alc269_fixup_tbl[] = {
 
14983
static const struct snd_pci_quirk alc269_fixup_tbl[] = {
14951
14984
        SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
14952
14985
        SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14953
14986
        SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14978
15011
        [ALC269_AUTO]                   = "auto",
14979
15012
};
14980
15013
 
14981
 
static struct snd_pci_quirk alc269_cfg_tbl[] = {
 
15014
static const struct snd_pci_quirk alc269_cfg_tbl[] = {
14982
15015
        SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
14983
15016
        SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
14984
15017
        SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
15036
15069
        {}
15037
15070
};
15038
15071
 
15039
 
static struct alc_config_preset alc269_presets[] = {
 
15072
static const struct alc_config_preset alc269_presets[] = {
15040
15073
        [ALC269_BASIC] = {
15041
15074
                .mixers = { alc269_base_mixer },
15042
15075
                .init_verbs = { alc269_init_verbs },
15070
15103
                .hp_nid = 0x03,
15071
15104
                .num_channel_mode = ARRAY_SIZE(alc269_modes),
15072
15105
                .channel_mode = alc269_modes,
15073
 
                .unsol_event = alc269_laptop_unsol_event,
 
15106
                .unsol_event = alc_sku_unsol_event,
15074
15107
                .setup = alc269_laptop_amic_setup,
15075
 
                .init_hook = alc269_laptop_inithook,
 
15108
                .init_hook = alc_inithook,
15076
15109
        },
15077
15110
        [ALC269_DMIC] = {
15078
15111
                .mixers = { alc269_laptop_mixer },
15084
15117
                .hp_nid = 0x03,
15085
15118
                .num_channel_mode = ARRAY_SIZE(alc269_modes),
15086
15119
                .channel_mode = alc269_modes,
15087
 
                .unsol_event = alc269_laptop_unsol_event,
 
15120
                .unsol_event = alc_sku_unsol_event,
15088
15121
                .setup = alc269_laptop_dmic_setup,
15089
 
                .init_hook = alc269_laptop_inithook,
 
15122
                .init_hook = alc_inithook,
15090
15123
        },
15091
15124
        [ALC269VB_AMIC] = {
15092
15125
                .mixers = { alc269vb_laptop_mixer },
15098
15131
                .hp_nid = 0x03,
15099
15132
                .num_channel_mode = ARRAY_SIZE(alc269_modes),
15100
15133
                .channel_mode = alc269_modes,
15101
 
                .unsol_event = alc269_laptop_unsol_event,
 
15134
                .unsol_event = alc_sku_unsol_event,
15102
15135
                .setup = alc269vb_laptop_amic_setup,
15103
 
                .init_hook = alc269_laptop_inithook,
 
15136
                .init_hook = alc_inithook,
15104
15137
        },
15105
15138
        [ALC269VB_DMIC] = {
15106
15139
                .mixers = { alc269vb_laptop_mixer },
15112
15145
                .hp_nid = 0x03,
15113
15146
                .num_channel_mode = ARRAY_SIZE(alc269_modes),
15114
15147
                .channel_mode = alc269_modes,
15115
 
                .unsol_event = alc269_laptop_unsol_event,
 
15148
                .unsol_event = alc_sku_unsol_event,
15116
15149
                .setup = alc269vb_laptop_dmic_setup,
15117
 
                .init_hook = alc269_laptop_inithook,
 
15150
                .init_hook = alc_inithook,
15118
15151
        },
15119
15152
        [ALC269_FUJITSU] = {
15120
15153
                .mixers = { alc269_fujitsu_mixer },
15126
15159
                .hp_nid = 0x03,
15127
15160
                .num_channel_mode = ARRAY_SIZE(alc269_modes),
15128
15161
                .channel_mode = alc269_modes,
15129
 
                .unsol_event = alc269_laptop_unsol_event,
 
15162
                .unsol_event = alc_sku_unsol_event,
15130
15163
                .setup = alc269_laptop_dmic_setup,
15131
 
                .init_hook = alc269_laptop_inithook,
 
15164
                .init_hook = alc_inithook,
15132
15165
        },
15133
15166
        [ALC269_LIFEBOOK] = {
15134
15167
                .mixers = { alc269_lifebook_mixer },
15140
15173
                .channel_mode = alc269_modes,
15141
15174
                .input_mux = &alc269_capture_source,
15142
15175
                .unsol_event = alc269_lifebook_unsol_event,
 
15176
                .setup = alc269_lifebook_setup,
15143
15177
                .init_hook = alc269_lifebook_init_hook,
15144
15178
        },
15145
15179
        [ALC271_ACER] = {
15185
15219
                val = alc_read_coef_idx(codec, 0xd);
15186
15220
                if ((val & 0x0c00) >> 10 != 0x1) {
15187
15221
                        /* Capless ramp up clock control */
15188
 
                        alc_write_coef_idx(codec, 0xd, val | 1<<10);
 
15222
                        alc_write_coef_idx(codec, 0xd, val | (1<<10));
15189
15223
                }
15190
15224
                val = alc_read_coef_idx(codec, 0x17);
15191
15225
                if ((val & 0x01c0) >> 6 != 0x4) {
15192
15226
                        /* Class D power on reset */
15193
 
                        alc_write_coef_idx(codec, 0x17, val | 1<<7);
 
15227
                        alc_write_coef_idx(codec, 0x17, val | (1<<7));
15194
15228
                }
15195
15229
        }
 
15230
 
 
15231
        val = alc_read_coef_idx(codec, 0xd); /* Class D */
 
15232
        alc_write_coef_idx(codec, 0xd, val | (1<<14));
 
15233
 
 
15234
        val = alc_read_coef_idx(codec, 0x4); /* HP */
 
15235
        alc_write_coef_idx(codec, 0x4, val | (1<<11));
 
15236
 
15196
15237
        return 0;
15197
15238
}
15198
15239
 
15313
15354
        spec->vmaster_nid = 0x02;
15314
15355
 
15315
15356
        codec->patch_ops = alc_patch_ops;
15316
 
#ifdef CONFIG_SND_HDA_POWER_SAVE
15317
 
        codec->patch_ops.suspend = alc269_suspend;
15318
 
#endif
15319
15357
#ifdef SND_HDA_NEEDS_RESUME
15320
15358
        codec->patch_ops.resume = alc269_resume;
15321
15359
#endif
15322
15360
        if (board_config == ALC269_AUTO)
15323
15361
                spec->init_hook = alc269_auto_init;
 
15362
        spec->shutup = alc269_shutup;
15324
15363
 
15325
15364
        alc_init_jacks(codec);
15326
15365
#ifdef CONFIG_SND_HDA_POWER_SAVE
15341
15380
 * set the path ways for 2 channel output
15342
15381
 * need to set the codec line out and mic 1 pin widgets to inputs
15343
15382
 */
15344
 
static struct hda_verb alc861_threestack_ch2_init[] = {
 
15383
static const struct hda_verb alc861_threestack_ch2_init[] = {
15345
15384
        /* set pin widget 1Ah (line in) for input */
15346
15385
        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15347
15386
        /* set pin widget 18h (mic1/2) for input, for mic also enable
15360
15399
 * 6ch mode
15361
15400
 * need to set the codec line out and mic 1 pin widgets to outputs
15362
15401
 */
15363
 
static struct hda_verb alc861_threestack_ch6_init[] = {
 
15402
static const struct hda_verb alc861_threestack_ch6_init[] = {
15364
15403
        /* set pin widget 1Ah (line in) for output (Back Surround)*/
15365
15404
        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15366
15405
        /* set pin widget 18h (mic1) for output (CLFE)*/
15377
15416
        { } /* end */
15378
15417
};
15379
15418
 
15380
 
static struct hda_channel_mode alc861_threestack_modes[2] = {
 
15419
static const struct hda_channel_mode alc861_threestack_modes[2] = {
15381
15420
        { 2, alc861_threestack_ch2_init },
15382
15421
        { 6, alc861_threestack_ch6_init },
15383
15422
};
15384
15423
/* Set mic1 as input and unmute the mixer */
15385
 
static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
 
15424
static const struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15386
15425
        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15387
15426
        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15388
15427
        { } /* end */
15389
15428
};
15390
15429
/* Set mic1 as output and mute mixer */
15391
 
static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
 
15430
static const struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15392
15431
        { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15393
15432
        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15394
15433
        { } /* end */
15395
15434
};
15396
15435
 
15397
 
static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
 
15436
static const struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15398
15437
        { 2, alc861_uniwill_m31_ch2_init },
15399
15438
        { 4, alc861_uniwill_m31_ch4_init },
15400
15439
};
15401
15440
 
15402
15441
/* Set mic1 and line-in as input and unmute the mixer */
15403
 
static struct hda_verb alc861_asus_ch2_init[] = {
 
15442
static const struct hda_verb alc861_asus_ch2_init[] = {
15404
15443
        /* set pin widget 1Ah (line in) for input */
15405
15444
        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15406
15445
        /* set pin widget 18h (mic1/2) for input, for mic also enable
15416
15455
        { } /* end */
15417
15456
};
15418
15457
/* Set mic1 nad line-in as output and mute mixer */
15419
 
static struct hda_verb alc861_asus_ch6_init[] = {
 
15458
static const struct hda_verb alc861_asus_ch6_init[] = {
15420
15459
        /* set pin widget 1Ah (line in) for output (Back Surround)*/
15421
15460
        { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15422
15461
        /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15434
15473
        { } /* end */
15435
15474
};
15436
15475
 
15437
 
static struct hda_channel_mode alc861_asus_modes[2] = {
 
15476
static const struct hda_channel_mode alc861_asus_modes[2] = {
15438
15477
        { 2, alc861_asus_ch2_init },
15439
15478
        { 6, alc861_asus_ch6_init },
15440
15479
};
15441
15480
 
15442
15481
/* patch-ALC861 */
15443
15482
 
15444
 
static struct snd_kcontrol_new alc861_base_mixer[] = {
 
15483
static const struct snd_kcontrol_new alc861_base_mixer[] = {
15445
15484
        /* output mixer control */
15446
15485
        HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15447
15486
        HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15464
15503
        { } /* end */
15465
15504
};
15466
15505
 
15467
 
static struct snd_kcontrol_new alc861_3ST_mixer[] = {
 
15506
static const struct snd_kcontrol_new alc861_3ST_mixer[] = {
15468
15507
        /* output mixer control */
15469
15508
        HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15470
15509
        HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15495
15534
        { } /* end */
15496
15535
};
15497
15536
 
15498
 
static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
 
15537
static const struct snd_kcontrol_new alc861_toshiba_mixer[] = {
15499
15538
        /* output mixer control */
15500
15539
        HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15501
15540
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15504
15543
        { } /* end */
15505
15544
};
15506
15545
 
15507
 
static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
 
15546
static const struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15508
15547
        /* output mixer control */
15509
15548
        HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15510
15549
        HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15535
15574
        { } /* end */
15536
15575
};
15537
15576
 
15538
 
static struct snd_kcontrol_new alc861_asus_mixer[] = {
 
15577
static const struct snd_kcontrol_new alc861_asus_mixer[] = {
15539
15578
        /* output mixer control */
15540
15579
        HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15541
15580
        HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15567
15606
};
15568
15607
 
15569
15608
/* additional mixer */
15570
 
static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
 
15609
static const struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
15571
15610
        HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15572
15611
        HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15573
15612
        { }
15576
15615
/*
15577
15616
 * generic initialization of ADC, input mixers and output mixers
15578
15617
 */
15579
 
static struct hda_verb alc861_base_init_verbs[] = {
 
15618
static const struct hda_verb alc861_base_init_verbs[] = {
15580
15619
        /*
15581
15620
         * Unmute ADC0 and set the default input to mic-in
15582
15621
         */
15642
15681
        { }
15643
15682
};
15644
15683
 
15645
 
static struct hda_verb alc861_threestack_init_verbs[] = {
 
15684
static const struct hda_verb alc861_threestack_init_verbs[] = {
15646
15685
        /*
15647
15686
         * Unmute ADC0 and set the default input to mic-in
15648
15687
         */
15703
15742
        { }
15704
15743
};
15705
15744
 
15706
 
static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
 
15745
static const struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15707
15746
        /*
15708
15747
         * Unmute ADC0 and set the default input to mic-in
15709
15748
         */
15765
15804
        { }
15766
15805
};
15767
15806
 
15768
 
static struct hda_verb alc861_asus_init_verbs[] = {
 
15807
static const struct hda_verb alc861_asus_init_verbs[] = {
15769
15808
        /*
15770
15809
         * Unmute ADC0 and set the default input to mic-in
15771
15810
         */
15831
15870
};
15832
15871
 
15833
15872
/* additional init verbs for ASUS laptops */
15834
 
static struct hda_verb alc861_asus_laptop_init_verbs[] = {
 
15873
static const struct hda_verb alc861_asus_laptop_init_verbs[] = {
15835
15874
        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15836
15875
        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15837
15876
        { }
15840
15879
/*
15841
15880
 * generic initialization of ADC, input mixers and output mixers
15842
15881
 */
15843
 
static struct hda_verb alc861_auto_init_verbs[] = {
 
15882
static const struct hda_verb alc861_auto_init_verbs[] = {
15844
15883
        /*
15845
15884
         * Unmute ADC0 and set the default input to mic-in
15846
15885
         */
15889
15928
        { }
15890
15929
};
15891
15930
 
15892
 
static struct hda_verb alc861_toshiba_init_verbs[] = {
 
15931
static const struct hda_verb alc861_toshiba_init_verbs[] = {
15893
15932
        {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15894
15933
 
15895
15934
        { }
15922
15961
 
15923
15962
#define ALC861_DIGOUT_NID       0x07
15924
15963
 
15925
 
static struct hda_channel_mode alc861_8ch_modes[1] = {
 
15964
static const struct hda_channel_mode alc861_8ch_modes[1] = {
15926
15965
        { 8, NULL }
15927
15966
};
15928
15967
 
15929
 
static hda_nid_t alc861_dac_nids[4] = {
 
15968
static const hda_nid_t alc861_dac_nids[4] = {
15930
15969
        /* front, surround, clfe, side */
15931
15970
        0x03, 0x06, 0x05, 0x04
15932
15971
};
15933
15972
 
15934
 
static hda_nid_t alc660_dac_nids[3] = {
 
15973
static const hda_nid_t alc660_dac_nids[3] = {
15935
15974
        /* front, clfe, surround */
15936
15975
        0x03, 0x05, 0x06
15937
15976
};
15938
15977
 
15939
 
static hda_nid_t alc861_adc_nids[1] = {
 
15978
static const hda_nid_t alc861_adc_nids[1] = {
15940
15979
        /* ADC0-2 */
15941
15980
        0x08,
15942
15981
};
15943
15982
 
15944
 
static struct hda_input_mux alc861_capture_source = {
 
15983
static const struct hda_input_mux alc861_capture_source = {
15945
15984
        .num_items = 5,
15946
15985
        .items = {
15947
15986
                { "Mic", 0x0 },
15991
16030
                dac = alc861_look_for_dac(codec, nid);
15992
16031
                if (!dac)
15993
16032
                        continue;
15994
 
                spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
 
16033
                spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
15995
16034
        }
15996
16035
        return 0;
15997
16036
}
16014
16053
        static const char * const chname[4] = {
16015
16054
                "Front", "Surround", NULL /*CLFE*/, "Side"
16016
16055
        };
16017
 
        const char *pfx = alc_get_line_out_pfx(cfg, true);
 
16056
        const char *pfx = alc_get_line_out_pfx(spec, true);
16018
16057
        hda_nid_t nid;
16019
 
        int i, err;
16020
 
 
16021
 
        for (i = 0; i < cfg->line_outs; i++) {
 
16058
        int i, err, noutputs;
 
16059
 
 
16060
        noutputs = cfg->line_outs;
 
16061
        if (spec->multi_ios > 0)
 
16062
                noutputs += spec->multi_ios;
 
16063
 
 
16064
        for (i = 0; i < noutputs; i++) {
16022
16065
                nid = spec->multiout.dac_nids[i];
16023
16066
                if (!nid)
16024
16067
                        continue;
16151
16194
{
16152
16195
        struct alc_spec *spec = codec->spec;
16153
16196
        int err;
16154
 
        static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
 
16197
        static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16155
16198
 
16156
16199
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16157
16200
                                           alc861_ignore);
16163
16206
        err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
16164
16207
        if (err < 0)
16165
16208
                return err;
 
16209
        err = alc_auto_add_multi_channel_mode(codec);
 
16210
        if (err < 0)
 
16211
                return err;
16166
16212
        err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
16167
16213
        if (err < 0)
16168
16214
                return err;
16207
16253
}
16208
16254
 
16209
16255
#ifdef CONFIG_SND_HDA_POWER_SAVE
16210
 
static struct hda_amp_list alc861_loopbacks[] = {
 
16256
static const struct hda_amp_list alc861_loopbacks[] = {
16211
16257
        { 0x15, HDA_INPUT, 0 },
16212
16258
        { 0x15, HDA_INPUT, 1 },
16213
16259
        { 0x15, HDA_INPUT, 2 },
16232
16278
        [ALC861_AUTO]           = "auto",
16233
16279
};
16234
16280
 
16235
 
static struct snd_pci_quirk alc861_cfg_tbl[] = {
 
16281
static const struct snd_pci_quirk alc861_cfg_tbl[] = {
16236
16282
        SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
16237
16283
        SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16238
16284
        SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16256
16302
        {}
16257
16303
};
16258
16304
 
16259
 
static struct alc_config_preset alc861_presets[] = {
 
16305
static const struct alc_config_preset alc861_presets[] = {
16260
16306
        [ALC861_3ST] = {
16261
16307
                .mixers = { alc861_3ST_mixer },
16262
16308
                .init_verbs = { alc861_threestack_init_verbs },
16379
16425
        },
16380
16426
};
16381
16427
 
16382
 
static struct snd_pci_quirk alc861_fixup_tbl[] = {
 
16428
static const struct snd_pci_quirk alc861_fixup_tbl[] = {
16383
16429
        SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16384
16430
        {}
16385
16431
};
16472
16518
 */
16473
16519
#define ALC861VD_DIGOUT_NID     0x06
16474
16520
 
16475
 
static hda_nid_t alc861vd_dac_nids[4] = {
 
16521
static const hda_nid_t alc861vd_dac_nids[4] = {
16476
16522
        /* front, surr, clfe, side surr */
16477
16523
        0x02, 0x03, 0x04, 0x05
16478
16524
};
16484
16530
 * - and it is the same as in 861vd.
16485
16531
 * adc_nids in ALC660vd are (is) the same as in 861vd
16486
16532
 */
16487
 
static hda_nid_t alc660vd_dac_nids[3] = {
 
16533
static const hda_nid_t alc660vd_dac_nids[3] = {
16488
16534
        /* front, rear, clfe, rear_surr */
16489
16535
        0x02, 0x04, 0x03
16490
16536
};
16491
16537
 
16492
 
static hda_nid_t alc861vd_adc_nids[1] = {
 
16538
static const hda_nid_t alc861vd_adc_nids[1] = {
16493
16539
        /* ADC0 */
16494
16540
        0x09,
16495
16541
};
16496
16542
 
16497
 
static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
 
16543
static const hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16498
16544
 
16499
16545
/* input MUX */
16500
16546
/* FIXME: should be a matrix-type input source selection */
16501
 
static struct hda_input_mux alc861vd_capture_source = {
 
16547
static const struct hda_input_mux alc861vd_capture_source = {
16502
16548
        .num_items = 4,
16503
16549
        .items = {
16504
16550
                { "Mic", 0x0 },
16508
16554
        },
16509
16555
};
16510
16556
 
16511
 
static struct hda_input_mux alc861vd_dallas_capture_source = {
 
16557
static const struct hda_input_mux alc861vd_dallas_capture_source = {
16512
16558
        .num_items = 2,
16513
16559
        .items = {
16514
16560
                { "Mic", 0x0 },
16516
16562
        },
16517
16563
};
16518
16564
 
16519
 
static struct hda_input_mux alc861vd_hp_capture_source = {
 
16565
static const struct hda_input_mux alc861vd_hp_capture_source = {
16520
16566
        .num_items = 2,
16521
16567
        .items = {
16522
16568
                { "Front Mic", 0x0 },
16527
16573
/*
16528
16574
 * 2ch mode
16529
16575
 */
16530
 
static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
 
16576
static const struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16531
16577
        { 2, NULL }
16532
16578
};
16533
16579
 
16534
16580
/*
16535
16581
 * 6ch mode
16536
16582
 */
16537
 
static struct hda_verb alc861vd_6stack_ch6_init[] = {
 
16583
static const struct hda_verb alc861vd_6stack_ch6_init[] = {
16538
16584
        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16539
16585
        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16540
16586
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16545
16591
/*
16546
16592
 * 8ch mode
16547
16593
 */
16548
 
static struct hda_verb alc861vd_6stack_ch8_init[] = {
 
16594
static const struct hda_verb alc861vd_6stack_ch8_init[] = {
16549
16595
        { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16550
16596
        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16551
16597
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16553
16599
        { } /* end */
16554
16600
};
16555
16601
 
16556
 
static struct hda_channel_mode alc861vd_6stack_modes[2] = {
 
16602
static const struct hda_channel_mode alc861vd_6stack_modes[2] = {
16557
16603
        { 6, alc861vd_6stack_ch6_init },
16558
16604
        { 8, alc861vd_6stack_ch8_init },
16559
16605
};
16560
16606
 
16561
 
static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
 
16607
static const struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16562
16608
        {
16563
16609
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16564
16610
                .name = "Channel Mode",
16572
16618
/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16573
16619
 *                 Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16574
16620
 */
16575
 
static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
 
16621
static const struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16576
16622
        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16577
16623
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16578
16624
 
16608
16654
        { } /* end */
16609
16655
};
16610
16656
 
16611
 
static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
 
16657
static const struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16612
16658
        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16613
16659
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16614
16660
 
16631
16677
        { } /* end */
16632
16678
};
16633
16679
 
16634
 
static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
 
16680
static const struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16635
16681
        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16636
16682
        /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16637
16683
        HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16655
16701
/* Pin assignment: Speaker=0x14, HP = 0x15,
16656
16702
 *                 Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
16657
16703
 */
16658
 
static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
 
16704
static const struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
16659
16705
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16660
16706
        HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
16661
16707
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16672
16718
/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16673
16719
 *                 Front Mic=0x18, ATAPI Mic = 0x19,
16674
16720
 */
16675
 
static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
 
16721
static const struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16676
16722
        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16677
16723
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16678
16724
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16688
16734
/*
16689
16735
 * generic initialization of ADC, input mixers and output mixers
16690
16736
 */
16691
 
static struct hda_verb alc861vd_volume_init_verbs[] = {
 
16737
static const struct hda_verb alc861vd_volume_init_verbs[] = {
16692
16738
        /*
16693
16739
         * Unmute ADC0 and set the default input to mic-in
16694
16740
         */
16738
16784
 * 3-stack pin configuration:
16739
16785
 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16740
16786
 */
16741
 
static struct hda_verb alc861vd_3stack_init_verbs[] = {
 
16787
static const struct hda_verb alc861vd_3stack_init_verbs[] = {
16742
16788
        /*
16743
16789
         * Set pin mode and muting
16744
16790
         */
16769
16815
/*
16770
16816
 * 6-stack pin configuration:
16771
16817
 */
16772
 
static struct hda_verb alc861vd_6stack_init_verbs[] = {
 
16818
static const struct hda_verb alc861vd_6stack_init_verbs[] = {
16773
16819
        /*
16774
16820
         * Set pin mode and muting
16775
16821
         */
16810
16856
        { }
16811
16857
};
16812
16858
 
16813
 
static struct hda_verb alc861vd_eapd_verbs[] = {
 
16859
static const struct hda_verb alc861vd_eapd_verbs[] = {
16814
16860
        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16815
16861
        { }
16816
16862
};
16817
16863
 
16818
 
static struct hda_verb alc660vd_eapd_verbs[] = {
 
16864
static const struct hda_verb alc660vd_eapd_verbs[] = {
16819
16865
        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16820
16866
        {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16821
16867
        { }
16822
16868
};
16823
16869
 
16824
 
static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
 
16870
static const struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16825
16871
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16826
16872
        {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16827
16873
        {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16835
16881
        struct alc_spec *spec = codec->spec;
16836
16882
        spec->autocfg.hp_pins[0] = 0x1b;
16837
16883
        spec->autocfg.speaker_pins[0] = 0x14;
 
16884
        spec->automute = 1;
 
16885
        spec->automute_mode = ALC_AUTOMUTE_AMP;
16838
16886
}
16839
16887
 
16840
16888
static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16841
16889
{
16842
 
        alc_automute_amp(codec);
 
16890
        alc_hp_automute(codec);
16843
16891
        alc88x_simple_mic_automute(codec);
16844
16892
}
16845
16893
 
16851
16899
                alc88x_simple_mic_automute(codec);
16852
16900
                break;
16853
16901
        default:
16854
 
                alc_automute_amp_unsol_event(codec, res);
 
16902
                alc_sku_unsol_event(codec, res);
16855
16903
                break;
16856
16904
        }
16857
16905
}
16858
16906
 
16859
 
static struct hda_verb alc861vd_dallas_verbs[] = {
 
16907
static const struct hda_verb alc861vd_dallas_verbs[] = {
16860
16908
        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16861
16909
        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16862
16910
        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16908
16956
 
16909
16957
        spec->autocfg.hp_pins[0] = 0x15;
16910
16958
        spec->autocfg.speaker_pins[0] = 0x14;
 
16959
        spec->automute = 1;
 
16960
        spec->automute_mode = ALC_AUTOMUTE_AMP;
16911
16961
}
16912
16962
 
16913
16963
#ifdef CONFIG_SND_HDA_POWER_SAVE
16936
16986
        [ALC861VD_AUTO]         = "auto",
16937
16987
};
16938
16988
 
16939
 
static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
 
16989
static const struct snd_pci_quirk alc861vd_cfg_tbl[] = {
16940
16990
        SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16941
16991
        SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
16942
16992
        SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
16955
17005
        {}
16956
17006
};
16957
17007
 
16958
 
static struct alc_config_preset alc861vd_presets[] = {
 
17008
static const struct alc_config_preset alc861vd_presets[] = {
16959
17009
        [ALC660VD_3ST] = {
16960
17010
                .mixers = { alc861vd_3st_mixer },
16961
17011
                .init_verbs = { alc861vd_volume_init_verbs,
17032
17082
                .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17033
17083
                .channel_mode = alc861vd_3stack_2ch_modes,
17034
17084
                .input_mux = &alc861vd_dallas_capture_source,
17035
 
                .unsol_event = alc_automute_amp_unsol_event,
 
17085
                .unsol_event = alc_sku_unsol_event,
17036
17086
                .setup = alc861vd_dallas_setup,
17037
 
                .init_hook = alc_automute_amp,
 
17087
                .init_hook = alc_hp_automute,
17038
17088
        },
17039
17089
        [ALC861VD_HP] = {
17040
17090
                .mixers = { alc861vd_hp_mixer },
17045
17095
                .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17046
17096
                .channel_mode = alc861vd_3stack_2ch_modes,
17047
17097
                .input_mux = &alc861vd_hp_capture_source,
17048
 
                .unsol_event = alc_automute_amp_unsol_event,
 
17098
                .unsol_event = alc_sku_unsol_event,
17049
17099
                .setup = alc861vd_dallas_setup,
17050
 
                .init_hook = alc_automute_amp,
 
17100
                .init_hook = alc_hp_automute,
17051
17101
        },
17052
17102
        [ALC660VD_ASUS_V1S] = {
17053
17103
                .mixers = { alc861vd_lenovo_mixer },
17146
17196
        static const char * const chname[4] = {
17147
17197
                "Front", "Surround", "CLFE", "Side"
17148
17198
        };
17149
 
        const char *pfx = alc_get_line_out_pfx(cfg, true);
 
17199
        const char *pfx = alc_get_line_out_pfx(spec, true);
17150
17200
        hda_nid_t nid_v, nid_s;
17151
 
        int i, err;
17152
 
 
17153
 
        for (i = 0; i < cfg->line_outs; i++) {
 
17201
        int i, err, noutputs;
 
17202
 
 
17203
        noutputs = cfg->line_outs;
 
17204
        if (spec->multi_ios > 0)
 
17205
                noutputs += spec->multi_ios;
 
17206
 
 
17207
        for (i = 0; i < noutputs; i++) {
17154
17208
                if (!spec->multiout.dac_nids[i])
17155
17209
                        continue;
17156
17210
                nid_v = alc861vd_idx_to_mixer_vol(
17263
17317
{
17264
17318
        struct alc_spec *spec = codec->spec;
17265
17319
        int err;
17266
 
        static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
 
17320
        static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17267
17321
 
17268
17322
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17269
17323
                                           alc861vd_ignore);
17275
17329
        err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17276
17330
        if (err < 0)
17277
17331
                return err;
 
17332
        err = alc_auto_add_multi_channel_mode(codec);
 
17333
        if (err < 0)
 
17334
                return err;
17278
17335
        err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17279
17336
        if (err < 0)
17280
17337
                return err;
17343
17400
        },
17344
17401
};
17345
17402
 
17346
 
static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
 
17403
static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17347
17404
        SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17348
17405
        {}
17349
17406
};
17426
17483
 
17427
17484
        if (board_config == ALC861VD_AUTO)
17428
17485
                spec->init_hook = alc861vd_auto_init;
 
17486
        spec->shutup = alc_eapd_shutup;
17429
17487
#ifdef CONFIG_SND_HDA_POWER_SAVE
17430
17488
        if (!spec->loopback.amplist)
17431
17489
                spec->loopback.amplist = alc861vd_loopbacks;
17448
17506
#define ALC662_DIGOUT_NID       0x06
17449
17507
#define ALC662_DIGIN_NID        0x0a
17450
17508
 
17451
 
static hda_nid_t alc662_dac_nids[4] = {
17452
 
        /* front, rear, clfe, rear_surr */
 
17509
static const hda_nid_t alc662_dac_nids[3] = {
 
17510
        /* front, rear, clfe */
17453
17511
        0x02, 0x03, 0x04
17454
17512
};
17455
17513
 
17456
 
static hda_nid_t alc272_dac_nids[2] = {
 
17514
static const hda_nid_t alc272_dac_nids[2] = {
17457
17515
        0x02, 0x03
17458
17516
};
17459
17517
 
17460
 
static hda_nid_t alc662_adc_nids[2] = {
 
17518
static const hda_nid_t alc662_adc_nids[2] = {
17461
17519
        /* ADC1-2 */
17462
17520
        0x09, 0x08
17463
17521
};
17464
17522
 
17465
 
static hda_nid_t alc272_adc_nids[1] = {
 
17523
static const hda_nid_t alc272_adc_nids[1] = {
17466
17524
        /* ADC1-2 */
17467
17525
        0x08,
17468
17526
};
17469
17527
 
17470
 
static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
17471
 
static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
 
17528
static const hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
 
17529
static const hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17472
17530
 
17473
17531
 
17474
17532
/* input MUX */
17475
17533
/* FIXME: should be a matrix-type input source selection */
17476
 
static struct hda_input_mux alc662_capture_source = {
 
17534
static const struct hda_input_mux alc662_capture_source = {
17477
17535
        .num_items = 4,
17478
17536
        .items = {
17479
17537
                { "Mic", 0x0 },
17483
17541
        },
17484
17542
};
17485
17543
 
17486
 
static struct hda_input_mux alc662_lenovo_101e_capture_source = {
 
17544
static const struct hda_input_mux alc662_lenovo_101e_capture_source = {
17487
17545
        .num_items = 2,
17488
17546
        .items = {
17489
17547
                { "Mic", 0x1 },
17491
17549
        },
17492
17550
};
17493
17551
 
17494
 
static struct hda_input_mux alc663_capture_source = {
 
17552
static const struct hda_input_mux alc663_capture_source = {
17495
17553
        .num_items = 3,
17496
17554
        .items = {
17497
17555
                { "Mic", 0x0 },
17501
17559
};
17502
17560
 
17503
17561
#if 0 /* set to 1 for testing other input sources below */
17504
 
static struct hda_input_mux alc272_nc10_capture_source = {
 
17562
static const struct hda_input_mux alc272_nc10_capture_source = {
17505
17563
        .num_items = 16,
17506
17564
        .items = {
17507
17565
                { "Autoselect Mic", 0x0 },
17527
17585
/*
17528
17586
 * 2ch mode
17529
17587
 */
17530
 
static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
 
17588
static const struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17531
17589
        { 2, NULL }
17532
17590
};
17533
17591
 
17534
17592
/*
17535
17593
 * 2ch mode
17536
17594
 */
17537
 
static struct hda_verb alc662_3ST_ch2_init[] = {
 
17595
static const struct hda_verb alc662_3ST_ch2_init[] = {
17538
17596
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17539
17597
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17540
17598
        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17545
17603
/*
17546
17604
 * 6ch mode
17547
17605
 */
17548
 
static struct hda_verb alc662_3ST_ch6_init[] = {
 
17606
static const struct hda_verb alc662_3ST_ch6_init[] = {
17549
17607
        { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17550
17608
        { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17551
17609
        { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17555
17613
        { } /* end */
17556
17614
};
17557
17615
 
17558
 
static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
 
17616
static const struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17559
17617
        { 2, alc662_3ST_ch2_init },
17560
17618
        { 6, alc662_3ST_ch6_init },
17561
17619
};
17563
17621
/*
17564
17622
 * 2ch mode
17565
17623
 */
17566
 
static struct hda_verb alc662_sixstack_ch6_init[] = {
 
17624
static const struct hda_verb alc662_sixstack_ch6_init[] = {
17567
17625
        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17568
17626
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17569
17627
        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17573
17631
/*
17574
17632
 * 6ch mode
17575
17633
 */
17576
 
static struct hda_verb alc662_sixstack_ch8_init[] = {
 
17634
static const struct hda_verb alc662_sixstack_ch8_init[] = {
17577
17635
        { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17578
17636
        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17579
17637
        { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17580
17638
        { } /* end */
17581
17639
};
17582
17640
 
17583
 
static struct hda_channel_mode alc662_5stack_modes[2] = {
 
17641
static const struct hda_channel_mode alc662_5stack_modes[2] = {
17584
17642
        { 2, alc662_sixstack_ch6_init },
17585
17643
        { 6, alc662_sixstack_ch8_init },
17586
17644
};
17589
17647
 *                 Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17590
17648
 */
17591
17649
 
17592
 
static struct snd_kcontrol_new alc662_base_mixer[] = {
 
17650
static const struct snd_kcontrol_new alc662_base_mixer[] = {
17593
17651
        /* output mixer control */
17594
17652
        HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
17595
17653
        HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
17613
17671
        { } /* end */
17614
17672
};
17615
17673
 
17616
 
static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
 
17674
static const struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17617
17675
        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17618
17676
        HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
17619
17677
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17628
17686
        { } /* end */
17629
17687
};
17630
17688
 
17631
 
static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
 
17689
static const struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17632
17690
        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17633
17691
        HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
17634
17692
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17649
17707
        { } /* end */
17650
17708
};
17651
17709
 
17652
 
static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
 
17710
static const struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17653
17711
        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17654
17712
        HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
17655
17713
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17662
17720
        { } /* end */
17663
17721
};
17664
17722
 
17665
 
static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
 
17723
static const struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
17666
17724
        HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17667
17725
        ALC262_HIPPO_MASTER_SWITCH,
17668
17726
 
17676
17734
        { } /* end */
17677
17735
};
17678
17736
 
17679
 
static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
 
17737
static const struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
17680
17738
        ALC262_HIPPO_MASTER_SWITCH,
17681
17739
        HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17682
17740
        HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17690
17748
        { } /* end */
17691
17749
};
17692
17750
 
17693
 
static struct hda_bind_ctls alc663_asus_bind_master_vol = {
 
17751
static const struct hda_bind_ctls alc663_asus_bind_master_vol = {
17694
17752
        .ops = &snd_hda_bind_vol,
17695
17753
        .values = {
17696
17754
                HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17699
17757
        },
17700
17758
};
17701
17759
 
17702
 
static struct hda_bind_ctls alc663_asus_one_bind_switch = {
 
17760
static const struct hda_bind_ctls alc663_asus_one_bind_switch = {
17703
17761
        .ops = &snd_hda_bind_sw,
17704
17762
        .values = {
17705
17763
                HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17708
17766
        },
17709
17767
};
17710
17768
 
17711
 
static struct snd_kcontrol_new alc663_m51va_mixer[] = {
 
17769
static const struct snd_kcontrol_new alc663_m51va_mixer[] = {
17712
17770
        HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17713
17771
        HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17714
17772
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17716
17774
        { } /* end */
17717
17775
};
17718
17776
 
17719
 
static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
 
17777
static const struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17720
17778
        .ops = &snd_hda_bind_sw,
17721
17779
        .values = {
17722
17780
                HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17726
17784
        },
17727
17785
};
17728
17786
 
17729
 
static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
 
17787
static const struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17730
17788
        HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17731
17789
        HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17732
17790
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17737
17795
        { } /* end */
17738
17796
};
17739
17797
 
17740
 
static struct hda_bind_ctls alc663_asus_four_bind_switch = {
 
17798
static const struct hda_bind_ctls alc663_asus_four_bind_switch = {
17741
17799
        .ops = &snd_hda_bind_sw,
17742
17800
        .values = {
17743
17801
                HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17747
17805
        },
17748
17806
};
17749
17807
 
17750
 
static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
 
17808
static const struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17751
17809
        HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17752
17810
        HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17753
17811
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17757
17815
        { } /* end */
17758
17816
};
17759
17817
 
17760
 
static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
 
17818
static const struct snd_kcontrol_new alc662_1bjd_mixer[] = {
17761
17819
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17762
17820
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17763
17821
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17768
17826
        { } /* end */
17769
17827
};
17770
17828
 
17771
 
static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
 
17829
static const struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17772
17830
        .ops = &snd_hda_bind_vol,
17773
17831
        .values = {
17774
17832
                HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17777
17835
        },
17778
17836
};
17779
17837
 
17780
 
static struct hda_bind_ctls alc663_asus_two_bind_switch = {
 
17838
static const struct hda_bind_ctls alc663_asus_two_bind_switch = {
17781
17839
        .ops = &snd_hda_bind_sw,
17782
17840
        .values = {
17783
17841
                HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17786
17844
        },
17787
17845
};
17788
17846
 
17789
 
static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
 
17847
static const struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17790
17848
        HDA_BIND_VOL("Master Playback Volume",
17791
17849
                                &alc663_asus_two_bind_master_vol),
17792
17850
        HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17797
17855
        { } /* end */
17798
17856
};
17799
17857
 
17800
 
static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
 
17858
static const struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17801
17859
        HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17802
17860
        HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17803
17861
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17807
17865
        { } /* end */
17808
17866
};
17809
17867
 
17810
 
static struct snd_kcontrol_new alc663_g71v_mixer[] = {
 
17868
static const struct snd_kcontrol_new alc663_g71v_mixer[] = {
17811
17869
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17812
17870
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17813
17871
        HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17821
17879
        { } /* end */
17822
17880
};
17823
17881
 
17824
 
static struct snd_kcontrol_new alc663_g50v_mixer[] = {
 
17882
static const struct snd_kcontrol_new alc663_g50v_mixer[] = {
17825
17883
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17826
17884
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17827
17885
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17835
17893
        { } /* end */
17836
17894
};
17837
17895
 
17838
 
static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
 
17896
static const struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17839
17897
        .ops = &snd_hda_bind_sw,
17840
17898
        .values = {
17841
17899
                HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17847
17905
        },
17848
17906
};
17849
17907
 
17850
 
static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
 
17908
static const struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17851
17909
        .ops = &snd_hda_bind_sw,
17852
17910
        .values = {
17853
17911
                HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17856
17914
        },
17857
17915
};
17858
17916
 
17859
 
static struct snd_kcontrol_new alc663_mode7_mixer[] = {
 
17917
static const struct snd_kcontrol_new alc663_mode7_mixer[] = {
17860
17918
        HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17861
17919
        HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17862
17920
        HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17869
17927
        { } /* end */
17870
17928
};
17871
17929
 
17872
 
static struct snd_kcontrol_new alc663_mode8_mixer[] = {
 
17930
static const struct snd_kcontrol_new alc663_mode8_mixer[] = {
17873
17931
        HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17874
17932
        HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17875
17933
        HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17881
17939
};
17882
17940
 
17883
17941
 
17884
 
static struct snd_kcontrol_new alc662_chmode_mixer[] = {
 
17942
static const struct snd_kcontrol_new alc662_chmode_mixer[] = {
17885
17943
        {
17886
17944
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17887
17945
                .name = "Channel Mode",
17892
17950
        { } /* end */
17893
17951
};
17894
17952
 
17895
 
static struct hda_verb alc662_init_verbs[] = {
 
17953
static const struct hda_verb alc662_init_verbs[] = {
17896
17954
        /* ADC: mute amp left and right */
17897
17955
        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17898
17956
        {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
17938
17996
        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17939
17997
        {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17940
17998
 
 
17999
        { }
 
18000
};
 
18001
 
 
18002
static const struct hda_verb alc662_eapd_init_verbs[] = {
17941
18003
        /* always trun on EAPD */
17942
18004
        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17943
18005
        {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17944
 
 
17945
 
        { }
17946
 
};
17947
 
 
17948
 
static struct hda_verb alc663_init_verbs[] = {
17949
 
        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17950
 
        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17951
 
        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17952
 
        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17953
 
        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17954
 
        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17955
 
        { }
17956
 
};
17957
 
 
17958
 
static struct hda_verb alc272_init_verbs[] = {
17959
 
        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17960
 
        {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17961
 
        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17962
 
        {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17963
 
        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17964
 
        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17965
 
        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17966
 
        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17967
 
        { }
17968
 
};
17969
 
 
17970
 
static struct hda_verb alc662_sue_init_verbs[] = {
 
18006
        { }
 
18007
};
 
18008
 
 
18009
static const struct hda_verb alc662_sue_init_verbs[] = {
17971
18010
        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17972
18011
        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17973
18012
        {}
17974
18013
};
17975
18014
 
17976
 
static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
 
18015
static const struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17977
18016
        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17978
18017
        {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17979
18018
        {}
17980
18019
};
17981
18020
 
17982
18021
/* Set Unsolicited Event*/
17983
 
static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
 
18022
static const struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17984
18023
        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17985
18024
        {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17986
18025
        {}
17987
18026
};
17988
18027
 
17989
 
static struct hda_verb alc663_m51va_init_verbs[] = {
 
18028
static const struct hda_verb alc663_m51va_init_verbs[] = {
17990
18029
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17991
18030
        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17992
18031
        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17999
18038
        {}
18000
18039
};
18001
18040
 
18002
 
static struct hda_verb alc663_21jd_amic_init_verbs[] = {
 
18041
static const struct hda_verb alc663_21jd_amic_init_verbs[] = {
18003
18042
        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18004
18043
        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18005
18044
        {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},  /* Headphone */
18010
18049
        {}
18011
18050
};
18012
18051
 
18013
 
static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
 
18052
static const struct hda_verb alc662_1bjd_amic_init_verbs[] = {
18014
18053
        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18015
18054
        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18016
18055
        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18022
18061
        {}
18023
18062
};
18024
18063
 
18025
 
static struct hda_verb alc663_15jd_amic_init_verbs[] = {
 
18064
static const struct hda_verb alc663_15jd_amic_init_verbs[] = {
18026
18065
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18027
18066
        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18028
18067
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},  /* Headphone */
18033
18072
        {}
18034
18073
};
18035
18074
 
18036
 
static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
 
18075
static const struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
18037
18076
        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18038
18077
        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18039
18078
        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18049
18088
        {}
18050
18089
};
18051
18090
 
18052
 
static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
 
18091
static const struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18053
18092
        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18054
18093
        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18055
18094
        {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18065
18104
        {}
18066
18105
};
18067
18106
 
18068
 
static struct hda_verb alc663_g71v_init_verbs[] = {
 
18107
static const struct hda_verb alc663_g71v_init_verbs[] = {
18069
18108
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18070
18109
        /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18071
18110
        /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18080
18119
        {}
18081
18120
};
18082
18121
 
18083
 
static struct hda_verb alc663_g50v_init_verbs[] = {
 
18122
static const struct hda_verb alc663_g50v_init_verbs[] = {
18084
18123
        {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18085
18124
        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18086
18125
        {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},  /* Headphone */
18090
18129
        {}
18091
18130
};
18092
18131
 
18093
 
static struct hda_verb alc662_ecs_init_verbs[] = {
 
18132
static const struct hda_verb alc662_ecs_init_verbs[] = {
18094
18133
        {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18095
18134
        {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18096
18135
        {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18098
18137
        {}
18099
18138
};
18100
18139
 
18101
 
static struct hda_verb alc272_dell_zm1_init_verbs[] = {
 
18140
static const struct hda_verb alc272_dell_zm1_init_verbs[] = {
18102
18141
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18103
18142
        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18104
18143
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18113
18152
        {}
18114
18153
};
18115
18154
 
18116
 
static struct hda_verb alc272_dell_init_verbs[] = {
 
18155
static const struct hda_verb alc272_dell_init_verbs[] = {
18117
18156
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18118
18157
        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18119
18158
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18128
18167
        {}
18129
18168
};
18130
18169
 
18131
 
static struct hda_verb alc663_mode7_init_verbs[] = {
 
18170
static const struct hda_verb alc663_mode7_init_verbs[] = {
18132
18171
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18133
18172
        {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18134
18173
        {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18147
18186
        {}
18148
18187
};
18149
18188
 
18150
 
static struct hda_verb alc663_mode8_init_verbs[] = {
 
18189
static const struct hda_verb alc663_mode8_init_verbs[] = {
18151
18190
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18152
18191
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18153
18192
        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18167
18206
        {}
18168
18207
};
18169
18208
 
18170
 
static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
 
18209
static const struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18171
18210
        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18172
18211
        HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18173
18212
        { } /* end */
18174
18213
};
18175
18214
 
18176
 
static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
 
18215
static const struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18177
18216
        HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18178
18217
        HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18179
18218
        { } /* end */
18180
18219
};
18181
18220
 
18182
 
static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18183
 
{
18184
 
        unsigned int present;
18185
 
        unsigned char bits;
18186
 
 
18187
 
        present = snd_hda_jack_detect(codec, 0x14);
18188
 
        bits = present ? HDA_AMP_MUTE : 0;
18189
 
 
18190
 
        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18191
 
                                 HDA_AMP_MUTE, bits);
18192
 
}
18193
 
 
18194
 
static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18195
 
{
18196
 
        unsigned int present;
18197
 
        unsigned char bits;
18198
 
 
18199
 
        present = snd_hda_jack_detect(codec, 0x1b);
18200
 
        bits = present ? HDA_AMP_MUTE : 0;
18201
 
 
18202
 
        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18203
 
                                 HDA_AMP_MUTE, bits);
18204
 
        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18205
 
                                 HDA_AMP_MUTE, bits);
18206
 
}
18207
 
 
18208
 
static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18209
 
                                           unsigned int res)
18210
 
{
18211
 
        if ((res >> 26) == ALC880_HP_EVENT)
18212
 
                alc662_lenovo_101e_all_automute(codec);
18213
 
        if ((res >> 26) == ALC880_FRONT_EVENT)
18214
 
                alc662_lenovo_101e_ispeaker_automute(codec);
18215
 
}
18216
 
 
18217
 
/* unsolicited event for HP jack sensing */
18218
 
static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18219
 
                                     unsigned int res)
18220
 
{
18221
 
        if ((res >> 26) == ALC880_MIC_EVENT)
18222
 
                alc_mic_automute(codec);
18223
 
        else
18224
 
                alc262_hippo_unsol_event(codec, res);
 
18221
static void alc662_lenovo_101e_setup(struct hda_codec *codec)
 
18222
{
 
18223
        struct alc_spec *spec = codec->spec;
 
18224
 
 
18225
        spec->autocfg.hp_pins[0] = 0x1b;
 
18226
        spec->autocfg.line_out_pins[0] = 0x14;
 
18227
        spec->autocfg.speaker_pins[0] = 0x15;
 
18228
        spec->automute = 1;
 
18229
        spec->detect_line = 1;
 
18230
        spec->automute_lines = 1;
 
18231
        spec->automute_mode = ALC_AUTOMUTE_AMP;
18225
18232
}
18226
18233
 
18227
18234
static void alc662_eeepc_setup(struct hda_codec *codec)
18236
18243
        spec->auto_mic = 1;
18237
18244
}
18238
18245
 
18239
 
static void alc662_eeepc_inithook(struct hda_codec *codec)
18240
 
{
18241
 
        alc262_hippo_automute(codec);
18242
 
        alc_mic_automute(codec);
18243
 
}
18244
 
 
18245
18246
static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
18246
18247
{
18247
18248
        struct alc_spec *spec = codec->spec;
18248
18249
 
18249
18250
        spec->autocfg.hp_pins[0] = 0x14;
18250
18251
        spec->autocfg.speaker_pins[0] = 0x1b;
18251
 
}
18252
 
 
18253
 
#define alc662_eeepc_ep20_inithook      alc262_hippo_master_update
18254
 
 
18255
 
static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18256
 
{
18257
 
        unsigned int present;
18258
 
        unsigned char bits;
18259
 
 
18260
 
        present = snd_hda_jack_detect(codec, 0x21);
18261
 
        bits = present ? HDA_AMP_MUTE : 0;
18262
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
18263
 
                                 HDA_AMP_MUTE, bits);
18264
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
18265
 
                                 HDA_AMP_MUTE, bits);
18266
 
}
18267
 
 
18268
 
static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18269
 
{
18270
 
        unsigned int present;
18271
 
        unsigned char bits;
18272
 
 
18273
 
        present = snd_hda_jack_detect(codec, 0x21);
18274
 
        bits = present ? HDA_AMP_MUTE : 0;
18275
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
18276
 
                                 HDA_AMP_MUTE, bits);
18277
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
18278
 
                                 HDA_AMP_MUTE, bits);
18279
 
        snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
18280
 
                                 HDA_AMP_MUTE, bits);
18281
 
        snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
18282
 
                                 HDA_AMP_MUTE, bits);
18283
 
}
18284
 
 
18285
 
static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18286
 
{
18287
 
        unsigned int present;
18288
 
        unsigned char bits;
18289
 
 
18290
 
        present = snd_hda_jack_detect(codec, 0x15);
18291
 
        bits = present ? HDA_AMP_MUTE : 0;
18292
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
18293
 
                                 HDA_AMP_MUTE, bits);
18294
 
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
18295
 
                                 HDA_AMP_MUTE, bits);
18296
 
        snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
18297
 
                                 HDA_AMP_MUTE, bits);
18298
 
        snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
18299
 
                                 HDA_AMP_MUTE, bits);
18300
 
}
18301
 
 
18302
 
static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18303
 
{
18304
 
        unsigned int present;
18305
 
        unsigned char bits;
18306
 
 
18307
 
        present = snd_hda_jack_detect(codec, 0x1b);
18308
 
        bits = present ? 0 : PIN_OUT;
18309
 
        snd_hda_codec_write(codec, 0x14, 0,
18310
 
                         AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18311
 
}
18312
 
 
18313
 
static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18314
 
{
18315
 
        unsigned int present1, present2;
18316
 
 
18317
 
        present1 = snd_hda_jack_detect(codec, 0x21);
18318
 
        present2 = snd_hda_jack_detect(codec, 0x15);
18319
 
 
18320
 
        if (present1 || present2) {
18321
 
                snd_hda_codec_write_cache(codec, 0x14, 0,
18322
 
                        AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18323
 
        } else {
18324
 
                snd_hda_codec_write_cache(codec, 0x14, 0,
18325
 
                        AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18326
 
        }
18327
 
}
18328
 
 
18329
 
static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18330
 
{
18331
 
        unsigned int present1, present2;
18332
 
 
18333
 
        present1 = snd_hda_jack_detect(codec, 0x1b);
18334
 
        present2 = snd_hda_jack_detect(codec, 0x15);
18335
 
 
18336
 
        if (present1 || present2) {
18337
 
                snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
18338
 
                                         HDA_AMP_MUTE, HDA_AMP_MUTE);
18339
 
                snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
18340
 
                                         HDA_AMP_MUTE, HDA_AMP_MUTE);
18341
 
        } else {
18342
 
                snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
18343
 
                                         HDA_AMP_MUTE, 0);
18344
 
                snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
18345
 
                                         HDA_AMP_MUTE, 0);
18346
 
        }
18347
 
}
18348
 
 
18349
 
static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18350
 
{
18351
 
        unsigned int present1, present2;
18352
 
 
18353
 
        present1 = snd_hda_codec_read(codec, 0x1b, 0,
18354
 
                        AC_VERB_GET_PIN_SENSE, 0)
18355
 
                        & AC_PINSENSE_PRESENCE;
18356
 
        present2 = snd_hda_codec_read(codec, 0x21, 0,
18357
 
                        AC_VERB_GET_PIN_SENSE, 0)
18358
 
                        & AC_PINSENSE_PRESENCE;
18359
 
 
18360
 
        if (present1 || present2) {
18361
 
                snd_hda_codec_write_cache(codec, 0x14, 0,
18362
 
                        AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18363
 
                snd_hda_codec_write_cache(codec, 0x17, 0,
18364
 
                        AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18365
 
        } else {
18366
 
                snd_hda_codec_write_cache(codec, 0x14, 0,
18367
 
                        AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18368
 
                snd_hda_codec_write_cache(codec, 0x17, 0,
18369
 
                        AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18370
 
        }
18371
 
}
18372
 
 
18373
 
static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18374
 
{
18375
 
        unsigned int present1, present2;
18376
 
 
18377
 
        present1 = snd_hda_codec_read(codec, 0x21, 0,
18378
 
                        AC_VERB_GET_PIN_SENSE, 0)
18379
 
                        & AC_PINSENSE_PRESENCE;
18380
 
        present2 = snd_hda_codec_read(codec, 0x15, 0,
18381
 
                        AC_VERB_GET_PIN_SENSE, 0)
18382
 
                        & AC_PINSENSE_PRESENCE;
18383
 
 
18384
 
        if (present1 || present2) {
18385
 
                snd_hda_codec_write_cache(codec, 0x14, 0,
18386
 
                        AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18387
 
                snd_hda_codec_write_cache(codec, 0x17, 0,
18388
 
                        AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18389
 
        } else {
18390
 
                snd_hda_codec_write_cache(codec, 0x14, 0,
18391
 
                        AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18392
 
                snd_hda_codec_write_cache(codec, 0x17, 0,
18393
 
                        AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18394
 
        }
18395
 
}
18396
 
 
18397
 
static void alc663_m51va_unsol_event(struct hda_codec *codec,
18398
 
                                           unsigned int res)
18399
 
{
18400
 
        switch (res >> 26) {
18401
 
        case ALC880_HP_EVENT:
18402
 
                alc663_m51va_speaker_automute(codec);
18403
 
                break;
18404
 
        case ALC880_MIC_EVENT:
18405
 
                alc_mic_automute(codec);
18406
 
                break;
18407
 
        }
 
18252
        spec->automute = 1;
 
18253
        spec->automute_mode = ALC_AUTOMUTE_AMP;
18408
18254
}
18409
18255
 
18410
18256
static void alc663_m51va_setup(struct hda_codec *codec)
18411
18257
{
18412
18258
        struct alc_spec *spec = codec->spec;
 
18259
        spec->autocfg.hp_pins[0] = 0x21;
 
18260
        spec->autocfg.speaker_pins[0] = 0x14;
 
18261
        spec->automute_mixer_nid[0] = 0x0c;
 
18262
        spec->automute = 1;
 
18263
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
18413
18264
        spec->ext_mic.pin = 0x18;
18414
18265
        spec->ext_mic.mux_idx = 0;
18415
18266
        spec->int_mic.pin = 0x12;
18417
18268
        spec->auto_mic = 1;
18418
18269
}
18419
18270
 
18420
 
static void alc663_m51va_inithook(struct hda_codec *codec)
18421
 
{
18422
 
        alc663_m51va_speaker_automute(codec);
18423
 
        alc_mic_automute(codec);
18424
 
}
18425
 
 
18426
18271
/* ***************** Mode1 ******************************/
18427
 
#define alc663_mode1_unsol_event        alc663_m51va_unsol_event
18428
 
 
18429
18272
static void alc663_mode1_setup(struct hda_codec *codec)
18430
18273
{
18431
18274
        struct alc_spec *spec = codec->spec;
 
18275
        spec->autocfg.hp_pins[0] = 0x21;
 
18276
        spec->autocfg.speaker_pins[0] = 0x14;
 
18277
        spec->automute_mixer_nid[0] = 0x0c;
 
18278
        spec->automute = 1;
 
18279
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
18432
18280
        spec->ext_mic.pin = 0x18;
18433
18281
        spec->ext_mic.mux_idx = 0;
18434
18282
        spec->int_mic.pin = 0x19;
18436
18284
        spec->auto_mic = 1;
18437
18285
}
18438
18286
 
18439
 
#define alc663_mode1_inithook           alc663_m51va_inithook
18440
 
 
18441
18287
/* ***************** Mode2 ******************************/
18442
 
static void alc662_mode2_unsol_event(struct hda_codec *codec,
18443
 
                                           unsigned int res)
18444
 
{
18445
 
        switch (res >> 26) {
18446
 
        case ALC880_HP_EVENT:
18447
 
                alc662_f5z_speaker_automute(codec);
18448
 
                break;
18449
 
        case ALC880_MIC_EVENT:
18450
 
                alc_mic_automute(codec);
18451
 
                break;
18452
 
        }
18453
 
}
18454
 
 
18455
 
#define alc662_mode2_setup      alc663_mode1_setup
18456
 
 
18457
 
static void alc662_mode2_inithook(struct hda_codec *codec)
18458
 
{
18459
 
        alc662_f5z_speaker_automute(codec);
18460
 
        alc_mic_automute(codec);
18461
 
}
 
18288
static void alc662_mode2_setup(struct hda_codec *codec)
 
18289
{
 
18290
        struct alc_spec *spec = codec->spec;
 
18291
        spec->autocfg.hp_pins[0] = 0x1b;
 
18292
        spec->autocfg.speaker_pins[0] = 0x14;
 
18293
        spec->automute = 1;
 
18294
        spec->automute_mode = ALC_AUTOMUTE_PIN;
 
18295
        spec->ext_mic.pin = 0x18;
 
18296
        spec->ext_mic.mux_idx = 0;
 
18297
        spec->int_mic.pin = 0x19;
 
18298
        spec->int_mic.mux_idx = 1;
 
18299
        spec->auto_mic = 1;
 
18300
}
 
18301
 
18462
18302
/* ***************** Mode3 ******************************/
18463
 
static void alc663_mode3_unsol_event(struct hda_codec *codec,
18464
 
                                           unsigned int res)
18465
 
{
18466
 
        switch (res >> 26) {
18467
 
        case ALC880_HP_EVENT:
18468
 
                alc663_two_hp_m1_speaker_automute(codec);
18469
 
                break;
18470
 
        case ALC880_MIC_EVENT:
18471
 
                alc_mic_automute(codec);
18472
 
                break;
18473
 
        }
18474
 
}
18475
 
 
18476
 
#define alc663_mode3_setup      alc663_mode1_setup
18477
 
 
18478
 
static void alc663_mode3_inithook(struct hda_codec *codec)
18479
 
{
18480
 
        alc663_two_hp_m1_speaker_automute(codec);
18481
 
        alc_mic_automute(codec);
18482
 
}
 
18303
static void alc663_mode3_setup(struct hda_codec *codec)
 
18304
{
 
18305
        struct alc_spec *spec = codec->spec;
 
18306
        spec->autocfg.hp_pins[0] = 0x21;
 
18307
        spec->autocfg.hp_pins[0] = 0x15;
 
18308
        spec->autocfg.speaker_pins[0] = 0x14;
 
18309
        spec->automute = 1;
 
18310
        spec->automute_mode = ALC_AUTOMUTE_PIN;
 
18311
        spec->ext_mic.pin = 0x18;
 
18312
        spec->ext_mic.mux_idx = 0;
 
18313
        spec->int_mic.pin = 0x19;
 
18314
        spec->int_mic.mux_idx = 1;
 
18315
        spec->auto_mic = 1;
 
18316
}
 
18317
 
18483
18318
/* ***************** Mode4 ******************************/
18484
 
static void alc663_mode4_unsol_event(struct hda_codec *codec,
18485
 
                                           unsigned int res)
18486
 
{
18487
 
        switch (res >> 26) {
18488
 
        case ALC880_HP_EVENT:
18489
 
                alc663_21jd_two_speaker_automute(codec);
18490
 
                break;
18491
 
        case ALC880_MIC_EVENT:
18492
 
                alc_mic_automute(codec);
18493
 
                break;
18494
 
        }
18495
 
}
18496
 
 
18497
 
#define alc663_mode4_setup      alc663_mode1_setup
18498
 
 
18499
 
static void alc663_mode4_inithook(struct hda_codec *codec)
18500
 
{
18501
 
        alc663_21jd_two_speaker_automute(codec);
18502
 
        alc_mic_automute(codec);
18503
 
}
 
18319
static void alc663_mode4_setup(struct hda_codec *codec)
 
18320
{
 
18321
        struct alc_spec *spec = codec->spec;
 
18322
        spec->autocfg.hp_pins[0] = 0x21;
 
18323
        spec->autocfg.speaker_pins[0] = 0x14;
 
18324
        spec->autocfg.speaker_pins[1] = 0x16;
 
18325
        spec->automute_mixer_nid[0] = 0x0c;
 
18326
        spec->automute_mixer_nid[1] = 0x0e;
 
18327
        spec->automute = 1;
 
18328
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
 
18329
        spec->ext_mic.pin = 0x18;
 
18330
        spec->ext_mic.mux_idx = 0;
 
18331
        spec->int_mic.pin = 0x19;
 
18332
        spec->int_mic.mux_idx = 1;
 
18333
        spec->auto_mic = 1;
 
18334
}
 
18335
 
18504
18336
/* ***************** Mode5 ******************************/
18505
 
static void alc663_mode5_unsol_event(struct hda_codec *codec,
18506
 
                                           unsigned int res)
18507
 
{
18508
 
        switch (res >> 26) {
18509
 
        case ALC880_HP_EVENT:
18510
 
                alc663_15jd_two_speaker_automute(codec);
18511
 
                break;
18512
 
        case ALC880_MIC_EVENT:
18513
 
                alc_mic_automute(codec);
18514
 
                break;
18515
 
        }
18516
 
}
18517
 
 
18518
 
#define alc663_mode5_setup      alc663_mode1_setup
18519
 
 
18520
 
static void alc663_mode5_inithook(struct hda_codec *codec)
18521
 
{
18522
 
        alc663_15jd_two_speaker_automute(codec);
18523
 
        alc_mic_automute(codec);
18524
 
}
 
18337
static void alc663_mode5_setup(struct hda_codec *codec)
 
18338
{
 
18339
        struct alc_spec *spec = codec->spec;
 
18340
        spec->autocfg.hp_pins[0] = 0x15;
 
18341
        spec->autocfg.speaker_pins[0] = 0x14;
 
18342
        spec->autocfg.speaker_pins[1] = 0x16;
 
18343
        spec->automute_mixer_nid[0] = 0x0c;
 
18344
        spec->automute_mixer_nid[1] = 0x0e;
 
18345
        spec->automute = 1;
 
18346
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
 
18347
        spec->ext_mic.pin = 0x18;
 
18348
        spec->ext_mic.mux_idx = 0;
 
18349
        spec->int_mic.pin = 0x19;
 
18350
        spec->int_mic.mux_idx = 1;
 
18351
        spec->auto_mic = 1;
 
18352
}
 
18353
 
18525
18354
/* ***************** Mode6 ******************************/
18526
 
static void alc663_mode6_unsol_event(struct hda_codec *codec,
18527
 
                                           unsigned int res)
18528
 
{
18529
 
        switch (res >> 26) {
18530
 
        case ALC880_HP_EVENT:
18531
 
                alc663_two_hp_m2_speaker_automute(codec);
18532
 
                break;
18533
 
        case ALC880_MIC_EVENT:
18534
 
                alc_mic_automute(codec);
18535
 
                break;
18536
 
        }
18537
 
}
18538
 
 
18539
 
#define alc663_mode6_setup      alc663_mode1_setup
18540
 
 
18541
 
static void alc663_mode6_inithook(struct hda_codec *codec)
18542
 
{
18543
 
        alc663_two_hp_m2_speaker_automute(codec);
18544
 
        alc_mic_automute(codec);
 
18355
static void alc663_mode6_setup(struct hda_codec *codec)
 
18356
{
 
18357
        struct alc_spec *spec = codec->spec;
 
18358
        spec->autocfg.hp_pins[0] = 0x1b;
 
18359
        spec->autocfg.hp_pins[0] = 0x15;
 
18360
        spec->autocfg.speaker_pins[0] = 0x14;
 
18361
        spec->automute_mixer_nid[0] = 0x0c;
 
18362
        spec->automute = 1;
 
18363
        spec->automute_mode = ALC_AUTOMUTE_MIXER;
 
18364
        spec->ext_mic.pin = 0x18;
 
18365
        spec->ext_mic.mux_idx = 0;
 
18366
        spec->int_mic.pin = 0x19;
 
18367
        spec->int_mic.mux_idx = 1;
 
18368
        spec->auto_mic = 1;
18545
18369
}
18546
18370
 
18547
18371
/* ***************** Mode7 ******************************/
18548
 
static void alc663_mode7_unsol_event(struct hda_codec *codec,
18549
 
                                           unsigned int res)
18550
 
{
18551
 
        switch (res >> 26) {
18552
 
        case ALC880_HP_EVENT:
18553
 
                alc663_two_hp_m7_speaker_automute(codec);
18554
 
                break;
18555
 
        case ALC880_MIC_EVENT:
18556
 
                alc_mic_automute(codec);
18557
 
                break;
18558
 
        }
18559
 
}
18560
 
 
18561
 
#define alc663_mode7_setup      alc663_mode1_setup
18562
 
 
18563
 
static void alc663_mode7_inithook(struct hda_codec *codec)
18564
 
{
18565
 
        alc663_two_hp_m7_speaker_automute(codec);
18566
 
        alc_mic_automute(codec);
 
18372
static void alc663_mode7_setup(struct hda_codec *codec)
 
18373
{
 
18374
        struct alc_spec *spec = codec->spec;
 
18375
        spec->autocfg.hp_pins[0] = 0x1b;
 
18376
        spec->autocfg.hp_pins[0] = 0x21;
 
18377
        spec->autocfg.speaker_pins[0] = 0x14;
 
18378
        spec->autocfg.speaker_pins[0] = 0x17;
 
18379
        spec->automute = 1;
 
18380
        spec->automute_mode = ALC_AUTOMUTE_PIN;
 
18381
        spec->ext_mic.pin = 0x18;
 
18382
        spec->ext_mic.mux_idx = 0;
 
18383
        spec->int_mic.pin = 0x19;
 
18384
        spec->int_mic.mux_idx = 1;
 
18385
        spec->auto_mic = 1;
18567
18386
}
18568
18387
 
18569
18388
/* ***************** Mode8 ******************************/
18570
 
static void alc663_mode8_unsol_event(struct hda_codec *codec,
18571
 
                                           unsigned int res)
18572
 
{
18573
 
        switch (res >> 26) {
18574
 
        case ALC880_HP_EVENT:
18575
 
                alc663_two_hp_m8_speaker_automute(codec);
18576
 
                break;
18577
 
        case ALC880_MIC_EVENT:
18578
 
                alc_mic_automute(codec);
18579
 
                break;
18580
 
        }
18581
 
}
18582
 
 
18583
 
#define alc663_mode8_setup      alc663_m51va_setup
18584
 
 
18585
 
static void alc663_mode8_inithook(struct hda_codec *codec)
18586
 
{
18587
 
        alc663_two_hp_m8_speaker_automute(codec);
18588
 
        alc_mic_automute(codec);
18589
 
}
18590
 
 
18591
 
static void alc663_g71v_hp_automute(struct hda_codec *codec)
18592
 
{
18593
 
        unsigned int present;
18594
 
        unsigned char bits;
18595
 
 
18596
 
        present = snd_hda_jack_detect(codec, 0x21);
18597
 
        bits = present ? HDA_AMP_MUTE : 0;
18598
 
        snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18599
 
                                 HDA_AMP_MUTE, bits);
18600
 
        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18601
 
                                 HDA_AMP_MUTE, bits);
18602
 
}
18603
 
 
18604
 
static void alc663_g71v_front_automute(struct hda_codec *codec)
18605
 
{
18606
 
        unsigned int present;
18607
 
        unsigned char bits;
18608
 
 
18609
 
        present = snd_hda_jack_detect(codec, 0x15);
18610
 
        bits = present ? HDA_AMP_MUTE : 0;
18611
 
        snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18612
 
                                 HDA_AMP_MUTE, bits);
18613
 
}
18614
 
 
18615
 
static void alc663_g71v_unsol_event(struct hda_codec *codec,
18616
 
                                           unsigned int res)
18617
 
{
18618
 
        switch (res >> 26) {
18619
 
        case ALC880_HP_EVENT:
18620
 
                alc663_g71v_hp_automute(codec);
18621
 
                break;
18622
 
        case ALC880_FRONT_EVENT:
18623
 
                alc663_g71v_front_automute(codec);
18624
 
                break;
18625
 
        case ALC880_MIC_EVENT:
18626
 
                alc_mic_automute(codec);
18627
 
                break;
18628
 
        }
18629
 
}
18630
 
 
18631
 
#define alc663_g71v_setup       alc663_m51va_setup
18632
 
 
18633
 
static void alc663_g71v_inithook(struct hda_codec *codec)
18634
 
{
18635
 
        alc663_g71v_front_automute(codec);
18636
 
        alc663_g71v_hp_automute(codec);
18637
 
        alc_mic_automute(codec);
18638
 
}
18639
 
 
18640
 
static void alc663_g50v_unsol_event(struct hda_codec *codec,
18641
 
                                           unsigned int res)
18642
 
{
18643
 
        switch (res >> 26) {
18644
 
        case ALC880_HP_EVENT:
18645
 
                alc663_m51va_speaker_automute(codec);
18646
 
                break;
18647
 
        case ALC880_MIC_EVENT:
18648
 
                alc_mic_automute(codec);
18649
 
                break;
18650
 
        }
 
18389
static void alc663_mode8_setup(struct hda_codec *codec)
 
18390
{
 
18391
        struct alc_spec *spec = codec->spec;
 
18392
        spec->autocfg.hp_pins[0] = 0x21;
 
18393
        spec->autocfg.hp_pins[1] = 0x15;
 
18394
        spec->autocfg.speaker_pins[0] = 0x14;
 
18395
        spec->autocfg.speaker_pins[0] = 0x17;
 
18396
        spec->automute = 1;
 
18397
        spec->automute_mode = ALC_AUTOMUTE_PIN;
 
18398
        spec->ext_mic.pin = 0x18;
 
18399
        spec->ext_mic.mux_idx = 0;
 
18400
        spec->int_mic.pin = 0x12;
 
18401
        spec->int_mic.mux_idx = 9;
 
18402
        spec->auto_mic = 1;
 
18403
}
 
18404
 
 
18405
static void alc663_g71v_setup(struct hda_codec *codec)
 
18406
{
 
18407
        struct alc_spec *spec = codec->spec;
 
18408
        spec->autocfg.hp_pins[0] = 0x21;
 
18409
        spec->autocfg.line_out_pins[0] = 0x15;
 
18410
        spec->autocfg.speaker_pins[0] = 0x14;
 
18411
        spec->automute = 1;
 
18412
        spec->automute_mode = ALC_AUTOMUTE_AMP;
 
18413
        spec->detect_line = 1;
 
18414
        spec->automute_lines = 1;
 
18415
        spec->ext_mic.pin = 0x18;
 
18416
        spec->ext_mic.mux_idx = 0;
 
18417
        spec->int_mic.pin = 0x12;
 
18418
        spec->int_mic.mux_idx = 9;
 
18419
        spec->auto_mic = 1;
18651
18420
}
18652
18421
 
18653
18422
#define alc663_g50v_setup       alc663_m51va_setup
18654
18423
 
18655
 
static void alc663_g50v_inithook(struct hda_codec *codec)
18656
 
{
18657
 
        alc663_m51va_speaker_automute(codec);
18658
 
        alc_mic_automute(codec);
18659
 
}
18660
 
 
18661
 
static struct snd_kcontrol_new alc662_ecs_mixer[] = {
 
18424
static const struct snd_kcontrol_new alc662_ecs_mixer[] = {
18662
18425
        HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18663
18426
        ALC262_HIPPO_MASTER_SWITCH,
18664
18427
 
18672
18435
        { } /* end */
18673
18436
};
18674
18437
 
18675
 
static struct snd_kcontrol_new alc272_nc10_mixer[] = {
 
18438
static const struct snd_kcontrol_new alc272_nc10_mixer[] = {
18676
18439
        /* Master Playback automatically created from Speaker and Headphone */
18677
18440
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18678
18441
        HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18707
18470
        [ALC662_3ST_2ch_DIG]    = "3stack-dig",
18708
18471
        [ALC662_3ST_6ch_DIG]    = "3stack-6ch-dig",
18709
18472
        [ALC662_3ST_6ch]        = "3stack-6ch",
18710
 
        [ALC662_5ST_DIG]        = "6stack-dig",
 
18473
        [ALC662_5ST_DIG]        = "5stack-dig",
18711
18474
        [ALC662_LENOVO_101E]    = "lenovo-101e",
18712
18475
        [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
18713
18476
        [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
18730
18493
        [ALC662_AUTO]           = "auto",
18731
18494
};
18732
18495
 
18733
 
static struct snd_pci_quirk alc662_cfg_tbl[] = {
 
18496
static const struct snd_pci_quirk alc662_cfg_tbl[] = {
18734
18497
        SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
18735
18498
        SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18736
18499
        SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
18812
18575
        {}
18813
18576
};
18814
18577
 
18815
 
static struct alc_config_preset alc662_presets[] = {
 
18578
static const struct alc_config_preset alc662_presets[] = {
18816
18579
        [ALC662_3ST_2ch_DIG] = {
18817
18580
                .mixers = { alc662_3ST_2ch_mixer },
18818
 
                .init_verbs = { alc662_init_verbs },
 
18581
                .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
18819
18582
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18820
18583
                .dac_nids = alc662_dac_nids,
18821
18584
                .dig_out_nid = ALC662_DIGOUT_NID,
18826
18589
        },
18827
18590
        [ALC662_3ST_6ch_DIG] = {
18828
18591
                .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
18829
 
                .init_verbs = { alc662_init_verbs },
 
18592
                .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
18830
18593
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18831
18594
                .dac_nids = alc662_dac_nids,
18832
18595
                .dig_out_nid = ALC662_DIGOUT_NID,
18838
18601
        },
18839
18602
        [ALC662_3ST_6ch] = {
18840
18603
                .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
18841
 
                .init_verbs = { alc662_init_verbs },
 
18604
                .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
18842
18605
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18843
18606
                .dac_nids = alc662_dac_nids,
18844
18607
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18848
18611
        },
18849
18612
        [ALC662_5ST_DIG] = {
18850
18613
                .mixers = { alc662_base_mixer, alc662_chmode_mixer },
18851
 
                .init_verbs = { alc662_init_verbs },
 
18614
                .init_verbs = { alc662_init_verbs, alc662_eapd_init_verbs },
18852
18615
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18853
18616
                .dac_nids = alc662_dac_nids,
18854
18617
                .dig_out_nid = ALC662_DIGOUT_NID,
18859
18622
        },
18860
18623
        [ALC662_LENOVO_101E] = {
18861
18624
                .mixers = { alc662_lenovo_101e_mixer },
18862
 
                .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
 
18625
                .init_verbs = { alc662_init_verbs,
 
18626
                                alc662_eapd_init_verbs,
 
18627
                                alc662_sue_init_verbs },
18863
18628
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18864
18629
                .dac_nids = alc662_dac_nids,
18865
18630
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18866
18631
                .channel_mode = alc662_3ST_2ch_modes,
18867
18632
                .input_mux = &alc662_lenovo_101e_capture_source,
18868
 
                .unsol_event = alc662_lenovo_101e_unsol_event,
18869
 
                .init_hook = alc662_lenovo_101e_all_automute,
 
18633
                .unsol_event = alc_sku_unsol_event,
 
18634
                .setup = alc662_lenovo_101e_setup,
 
18635
                .init_hook = alc_inithook,
18870
18636
        },
18871
18637
        [ALC662_ASUS_EEEPC_P701] = {
18872
18638
                .mixers = { alc662_eeepc_p701_mixer },
18873
18639
                .init_verbs = { alc662_init_verbs,
 
18640
                                alc662_eapd_init_verbs,
18874
18641
                                alc662_eeepc_sue_init_verbs },
18875
18642
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18876
18643
                .dac_nids = alc662_dac_nids,
18877
18644
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18878
18645
                .channel_mode = alc662_3ST_2ch_modes,
18879
 
                .unsol_event = alc662_eeepc_unsol_event,
 
18646
                .unsol_event = alc_sku_unsol_event,
18880
18647
                .setup = alc662_eeepc_setup,
18881
 
                .init_hook = alc662_eeepc_inithook,
 
18648
                .init_hook = alc_inithook,
18882
18649
        },
18883
18650
        [ALC662_ASUS_EEEPC_EP20] = {
18884
18651
                .mixers = { alc662_eeepc_ep20_mixer,
18885
18652
                            alc662_chmode_mixer },
18886
18653
                .init_verbs = { alc662_init_verbs,
 
18654
                                alc662_eapd_init_verbs,
18887
18655
                                alc662_eeepc_ep20_sue_init_verbs },
18888
18656
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18889
18657
                .dac_nids = alc662_dac_nids,
18890
18658
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18891
18659
                .channel_mode = alc662_3ST_6ch_modes,
18892
18660
                .input_mux = &alc662_lenovo_101e_capture_source,
18893
 
                .unsol_event = alc662_eeepc_unsol_event,
 
18661
                .unsol_event = alc_sku_unsol_event,
18894
18662
                .setup = alc662_eeepc_ep20_setup,
18895
 
                .init_hook = alc662_eeepc_ep20_inithook,
 
18663
                .init_hook = alc_inithook,
18896
18664
        },
18897
18665
        [ALC662_ECS] = {
18898
18666
                .mixers = { alc662_ecs_mixer },
18899
18667
                .init_verbs = { alc662_init_verbs,
 
18668
                                alc662_eapd_init_verbs,
18900
18669
                                alc662_ecs_init_verbs },
18901
18670
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18902
18671
                .dac_nids = alc662_dac_nids,
18903
18672
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18904
18673
                .channel_mode = alc662_3ST_2ch_modes,
18905
 
                .unsol_event = alc662_eeepc_unsol_event,
 
18674
                .unsol_event = alc_sku_unsol_event,
18906
18675
                .setup = alc662_eeepc_setup,
18907
 
                .init_hook = alc662_eeepc_inithook,
 
18676
                .init_hook = alc_inithook,
18908
18677
        },
18909
18678
        [ALC663_ASUS_M51VA] = {
18910
18679
                .mixers = { alc663_m51va_mixer },
18911
 
                .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
 
18680
                .init_verbs = { alc662_init_verbs,
 
18681
                                alc662_eapd_init_verbs,
 
18682
                                alc663_m51va_init_verbs },
18912
18683
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18913
18684
                .dac_nids = alc662_dac_nids,
18914
18685
                .dig_out_nid = ALC662_DIGOUT_NID,
18915
18686
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18916
18687
                .channel_mode = alc662_3ST_2ch_modes,
18917
 
                .unsol_event = alc663_m51va_unsol_event,
 
18688
                .unsol_event = alc_sku_unsol_event,
18918
18689
                .setup = alc663_m51va_setup,
18919
 
                .init_hook = alc663_m51va_inithook,
 
18690
                .init_hook = alc_inithook,
18920
18691
        },
18921
18692
        [ALC663_ASUS_G71V] = {
18922
18693
                .mixers = { alc663_g71v_mixer },
18923
 
                .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
 
18694
                .init_verbs = { alc662_init_verbs,
 
18695
                                alc662_eapd_init_verbs,
 
18696
                                alc663_g71v_init_verbs },
18924
18697
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18925
18698
                .dac_nids = alc662_dac_nids,
18926
18699
                .dig_out_nid = ALC662_DIGOUT_NID,
18927
18700
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18928
18701
                .channel_mode = alc662_3ST_2ch_modes,
18929
 
                .unsol_event = alc663_g71v_unsol_event,
 
18702
                .unsol_event = alc_sku_unsol_event,
18930
18703
                .setup = alc663_g71v_setup,
18931
 
                .init_hook = alc663_g71v_inithook,
 
18704
                .init_hook = alc_inithook,
18932
18705
        },
18933
18706
        [ALC663_ASUS_H13] = {
18934
18707
                .mixers = { alc663_m51va_mixer },
18935
 
                .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
 
18708
                .init_verbs = { alc662_init_verbs,
 
18709
                                alc662_eapd_init_verbs,
 
18710
                                alc663_m51va_init_verbs },
18936
18711
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18937
18712
                .dac_nids = alc662_dac_nids,
18938
18713
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18939
18714
                .channel_mode = alc662_3ST_2ch_modes,
18940
 
                .unsol_event = alc663_m51va_unsol_event,
18941
 
                .init_hook = alc663_m51va_inithook,
 
18715
                .setup = alc663_m51va_setup,
 
18716
                .unsol_event = alc_sku_unsol_event,
 
18717
                .init_hook = alc_inithook,
18942
18718
        },
18943
18719
        [ALC663_ASUS_G50V] = {
18944
18720
                .mixers = { alc663_g50v_mixer },
18945
 
                .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
 
18721
                .init_verbs = { alc662_init_verbs,
 
18722
                                alc662_eapd_init_verbs,
 
18723
                                alc663_g50v_init_verbs },
18946
18724
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18947
18725
                .dac_nids = alc662_dac_nids,
18948
18726
                .dig_out_nid = ALC662_DIGOUT_NID,
18949
18727
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18950
18728
                .channel_mode = alc662_3ST_6ch_modes,
18951
18729
                .input_mux = &alc663_capture_source,
18952
 
                .unsol_event = alc663_g50v_unsol_event,
 
18730
                .unsol_event = alc_sku_unsol_event,
18953
18731
                .setup = alc663_g50v_setup,
18954
 
                .init_hook = alc663_g50v_inithook,
 
18732
                .init_hook = alc_inithook,
18955
18733
        },
18956
18734
        [ALC663_ASUS_MODE1] = {
18957
18735
                .mixers = { alc663_m51va_mixer },
18958
18736
                .cap_mixer = alc662_auto_capture_mixer,
18959
18737
                .init_verbs = { alc662_init_verbs,
 
18738
                                alc662_eapd_init_verbs,
18960
18739
                                alc663_21jd_amic_init_verbs },
18961
18740
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18962
18741
                .hp_nid = 0x03,
18964
18743
                .dig_out_nid = ALC662_DIGOUT_NID,
18965
18744
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18966
18745
                .channel_mode = alc662_3ST_2ch_modes,
18967
 
                .unsol_event = alc663_mode1_unsol_event,
 
18746
                .unsol_event = alc_sku_unsol_event,
18968
18747
                .setup = alc663_mode1_setup,
18969
 
                .init_hook = alc663_mode1_inithook,
 
18748
                .init_hook = alc_inithook,
18970
18749
        },
18971
18750
        [ALC662_ASUS_MODE2] = {
18972
18751
                .mixers = { alc662_1bjd_mixer },
18973
18752
                .cap_mixer = alc662_auto_capture_mixer,
18974
18753
                .init_verbs = { alc662_init_verbs,
 
18754
                                alc662_eapd_init_verbs,
18975
18755
                                alc662_1bjd_amic_init_verbs },
18976
18756
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18977
18757
                .dac_nids = alc662_dac_nids,
18978
18758
                .dig_out_nid = ALC662_DIGOUT_NID,
18979
18759
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18980
18760
                .channel_mode = alc662_3ST_2ch_modes,
18981
 
                .unsol_event = alc662_mode2_unsol_event,
 
18761
                .unsol_event = alc_sku_unsol_event,
18982
18762
                .setup = alc662_mode2_setup,
18983
 
                .init_hook = alc662_mode2_inithook,
 
18763
                .init_hook = alc_inithook,
18984
18764
        },
18985
18765
        [ALC663_ASUS_MODE3] = {
18986
18766
                .mixers = { alc663_two_hp_m1_mixer },
18987
18767
                .cap_mixer = alc662_auto_capture_mixer,
18988
18768
                .init_verbs = { alc662_init_verbs,
 
18769
                                alc662_eapd_init_verbs,
18989
18770
                                alc663_two_hp_amic_m1_init_verbs },
18990
18771
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18991
18772
                .hp_nid = 0x03,
18993
18774
                .dig_out_nid = ALC662_DIGOUT_NID,
18994
18775
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18995
18776
                .channel_mode = alc662_3ST_2ch_modes,
18996
 
                .unsol_event = alc663_mode3_unsol_event,
 
18777
                .unsol_event = alc_sku_unsol_event,
18997
18778
                .setup = alc663_mode3_setup,
18998
 
                .init_hook = alc663_mode3_inithook,
 
18779
                .init_hook = alc_inithook,
18999
18780
        },
19000
18781
        [ALC663_ASUS_MODE4] = {
19001
18782
                .mixers = { alc663_asus_21jd_clfe_mixer },
19002
18783
                .cap_mixer = alc662_auto_capture_mixer,
19003
18784
                .init_verbs = { alc662_init_verbs,
 
18785
                                alc662_eapd_init_verbs,
19004
18786
                                alc663_21jd_amic_init_verbs},
19005
18787
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19006
18788
                .hp_nid = 0x03,
19008
18790
                .dig_out_nid = ALC662_DIGOUT_NID,
19009
18791
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19010
18792
                .channel_mode = alc662_3ST_2ch_modes,
19011
 
                .unsol_event = alc663_mode4_unsol_event,
 
18793
                .unsol_event = alc_sku_unsol_event,
19012
18794
                .setup = alc663_mode4_setup,
19013
 
                .init_hook = alc663_mode4_inithook,
 
18795
                .init_hook = alc_inithook,
19014
18796
        },
19015
18797
        [ALC663_ASUS_MODE5] = {
19016
18798
                .mixers = { alc663_asus_15jd_clfe_mixer },
19017
18799
                .cap_mixer = alc662_auto_capture_mixer,
19018
18800
                .init_verbs = { alc662_init_verbs,
 
18801
                                alc662_eapd_init_verbs,
19019
18802
                                alc663_15jd_amic_init_verbs },
19020
18803
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19021
18804
                .hp_nid = 0x03,
19023
18806
                .dig_out_nid = ALC662_DIGOUT_NID,
19024
18807
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19025
18808
                .channel_mode = alc662_3ST_2ch_modes,
19026
 
                .unsol_event = alc663_mode5_unsol_event,
 
18809
                .unsol_event = alc_sku_unsol_event,
19027
18810
                .setup = alc663_mode5_setup,
19028
 
                .init_hook = alc663_mode5_inithook,
 
18811
                .init_hook = alc_inithook,
19029
18812
        },
19030
18813
        [ALC663_ASUS_MODE6] = {
19031
18814
                .mixers = { alc663_two_hp_m2_mixer },
19032
18815
                .cap_mixer = alc662_auto_capture_mixer,
19033
18816
                .init_verbs = { alc662_init_verbs,
 
18817
                                alc662_eapd_init_verbs,
19034
18818
                                alc663_two_hp_amic_m2_init_verbs },
19035
18819
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19036
18820
                .hp_nid = 0x03,
19038
18822
                .dig_out_nid = ALC662_DIGOUT_NID,
19039
18823
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19040
18824
                .channel_mode = alc662_3ST_2ch_modes,
19041
 
                .unsol_event = alc663_mode6_unsol_event,
 
18825
                .unsol_event = alc_sku_unsol_event,
19042
18826
                .setup = alc663_mode6_setup,
19043
 
                .init_hook = alc663_mode6_inithook,
 
18827
                .init_hook = alc_inithook,
19044
18828
        },
19045
18829
        [ALC663_ASUS_MODE7] = {
19046
18830
                .mixers = { alc663_mode7_mixer },
19047
18831
                .cap_mixer = alc662_auto_capture_mixer,
19048
18832
                .init_verbs = { alc662_init_verbs,
 
18833
                                alc662_eapd_init_verbs,
19049
18834
                                alc663_mode7_init_verbs },
19050
18835
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19051
18836
                .hp_nid = 0x03,
19053
18838
                .dig_out_nid = ALC662_DIGOUT_NID,
19054
18839
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19055
18840
                .channel_mode = alc662_3ST_2ch_modes,
19056
 
                .unsol_event = alc663_mode7_unsol_event,
 
18841
                .unsol_event = alc_sku_unsol_event,
19057
18842
                .setup = alc663_mode7_setup,
19058
 
                .init_hook = alc663_mode7_inithook,
 
18843
                .init_hook = alc_inithook,
19059
18844
        },
19060
18845
        [ALC663_ASUS_MODE8] = {
19061
18846
                .mixers = { alc663_mode8_mixer },
19062
18847
                .cap_mixer = alc662_auto_capture_mixer,
19063
18848
                .init_verbs = { alc662_init_verbs,
 
18849
                                alc662_eapd_init_verbs,
19064
18850
                                alc663_mode8_init_verbs },
19065
18851
                .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19066
18852
                .hp_nid = 0x03,
19068
18854
                .dig_out_nid = ALC662_DIGOUT_NID,
19069
18855
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19070
18856
                .channel_mode = alc662_3ST_2ch_modes,
19071
 
                .unsol_event = alc663_mode8_unsol_event,
 
18857
                .unsol_event = alc_sku_unsol_event,
19072
18858
                .setup = alc663_mode8_setup,
19073
 
                .init_hook = alc663_mode8_inithook,
 
18859
                .init_hook = alc_inithook,
19074
18860
        },
19075
18861
        [ALC272_DELL] = {
19076
18862
                .mixers = { alc663_m51va_mixer },
19077
18863
                .cap_mixer = alc272_auto_capture_mixer,
19078
 
                .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
 
18864
                .init_verbs = { alc662_init_verbs,
 
18865
                                alc662_eapd_init_verbs,
 
18866
                                alc272_dell_init_verbs },
19079
18867
                .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19080
 
                .dac_nids = alc662_dac_nids,
 
18868
                .dac_nids = alc272_dac_nids,
19081
18869
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19082
18870
                .adc_nids = alc272_adc_nids,
19083
18871
                .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
19084
18872
                .capsrc_nids = alc272_capsrc_nids,
19085
18873
                .channel_mode = alc662_3ST_2ch_modes,
19086
 
                .unsol_event = alc663_m51va_unsol_event,
 
18874
                .unsol_event = alc_sku_unsol_event,
19087
18875
                .setup = alc663_m51va_setup,
19088
 
                .init_hook = alc663_m51va_inithook,
 
18876
                .init_hook = alc_inithook,
19089
18877
        },
19090
18878
        [ALC272_DELL_ZM1] = {
19091
18879
                .mixers = { alc663_m51va_mixer },
19092
18880
                .cap_mixer = alc662_auto_capture_mixer,
19093
 
                .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
 
18881
                .init_verbs = { alc662_init_verbs,
 
18882
                                alc662_eapd_init_verbs,
 
18883
                                alc272_dell_zm1_init_verbs },
19094
18884
                .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19095
 
                .dac_nids = alc662_dac_nids,
 
18885
                .dac_nids = alc272_dac_nids,
19096
18886
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19097
18887
                .adc_nids = alc662_adc_nids,
19098
18888
                .num_adc_nids = 1,
19099
18889
                .capsrc_nids = alc662_capsrc_nids,
19100
18890
                .channel_mode = alc662_3ST_2ch_modes,
19101
 
                .unsol_event = alc663_m51va_unsol_event,
 
18891
                .unsol_event = alc_sku_unsol_event,
19102
18892
                .setup = alc663_m51va_setup,
19103
 
                .init_hook = alc663_m51va_inithook,
 
18893
                .init_hook = alc_inithook,
19104
18894
        },
19105
18895
        [ALC272_SAMSUNG_NC10] = {
19106
18896
                .mixers = { alc272_nc10_mixer },
19107
18897
                .init_verbs = { alc662_init_verbs,
 
18898
                                alc662_eapd_init_verbs,
19108
18899
                                alc663_21jd_amic_init_verbs },
19109
18900
                .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19110
18901
                .dac_nids = alc272_dac_nids,
19111
18902
                .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19112
18903
                .channel_mode = alc662_3ST_2ch_modes,
19113
18904
                /*.input_mux = &alc272_nc10_capture_source,*/
19114
 
                .unsol_event = alc663_mode4_unsol_event,
 
18905
                .unsol_event = alc_sku_unsol_event,
19115
18906
                .setup = alc663_mode4_setup,
19116
 
                .init_hook = alc663_mode4_inithook,
 
18907
                .init_hook = alc_inithook,
19117
18908
        },
19118
18909
};
19119
18910
 
19123
18914
 */
19124
18915
 
19125
18916
/* convert from MIX nid to DAC */
19126
 
static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19127
 
{
19128
 
        if (nid == 0x0f)
19129
 
                return 0x02;
19130
 
        else if (nid >= 0x0c && nid <= 0x0e)
19131
 
                return nid - 0x0c + 0x02;
19132
 
        else if (nid == 0x26) /* ALC887-VD has this DAC too */
19133
 
                return 0x25;
19134
 
        else
19135
 
                return 0;
 
18917
static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
 
18918
{
 
18919
        hda_nid_t list[5];
 
18920
        int i, num;
 
18921
 
 
18922
        num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
 
18923
        for (i = 0; i < num; i++) {
 
18924
                if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT)
 
18925
                        return list[i];
 
18926
        }
 
18927
        return 0;
 
18928
}
 
18929
 
 
18930
/* go down to the selector widget before the mixer */
 
18931
static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
 
18932
{
 
18933
        hda_nid_t srcs[5];
 
18934
        int num = snd_hda_get_connections(codec, pin, srcs,
 
18935
                                          ARRAY_SIZE(srcs));
 
18936
        if (num != 1 ||
 
18937
            get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
 
18938
                return pin;
 
18939
        return srcs[0];
19136
18940
}
19137
18941
 
19138
18942
/* get MIX nid connected to the given pin targeted to DAC */
19139
 
static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
 
18943
static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19140
18944
                                   hda_nid_t dac)
19141
18945
{
19142
18946
        hda_nid_t mix[5];
19143
18947
        int i, num;
19144
18948
 
 
18949
        pin = alc_go_down_to_selector(codec, pin);
19145
18950
        num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19146
18951
        for (i = 0; i < num; i++) {
19147
 
                if (alc662_mix_to_dac(mix[i]) == dac)
 
18952
                if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
19148
18953
                        return mix[i];
19149
18954
        }
19150
18955
        return 0;
19151
18956
}
19152
18957
 
 
18958
/* select the connection from pin to DAC if needed */
 
18959
static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin,
 
18960
                               hda_nid_t dac)
 
18961
{
 
18962
        hda_nid_t mix[5];
 
18963
        int i, num;
 
18964
 
 
18965
        pin = alc_go_down_to_selector(codec, pin);
 
18966
        num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
 
18967
        if (num < 2)
 
18968
                return 0;
 
18969
        for (i = 0; i < num; i++) {
 
18970
                if (alc_auto_mix_to_dac(codec, mix[i]) == dac) {
 
18971
                        snd_hda_codec_update_cache(codec, pin, 0,
 
18972
                                                   AC_VERB_SET_CONNECT_SEL, i);
 
18973
                        return 0;
 
18974
                }
 
18975
        }
 
18976
        return 0;
 
18977
}
 
18978
 
19153
18979
/* look for an empty DAC slot */
19154
 
static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
 
18980
static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19155
18981
{
19156
18982
        struct alc_spec *spec = codec->spec;
19157
18983
        hda_nid_t srcs[5];
19158
18984
        int i, j, num;
19159
18985
 
 
18986
        pin = alc_go_down_to_selector(codec, pin);
19160
18987
        num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19161
 
        if (num < 0)
19162
 
                return 0;
19163
18988
        for (i = 0; i < num; i++) {
19164
 
                hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
 
18989
                hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
19165
18990
                if (!nid)
19166
18991
                        continue;
19167
18992
                for (j = 0; j < spec->multiout.num_dacs; j++)
19183
19008
 
19184
19009
        spec->multiout.dac_nids = spec->private_dac_nids;
19185
19010
        for (i = 0; i < cfg->line_outs; i++) {
19186
 
                dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
 
19011
                dac = alc_auto_look_for_dac(codec, cfg->line_out_pins[i]);
19187
19012
                if (!dac)
19188
19013
                        continue;
19189
 
                spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
 
19014
                spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
19190
19015
        }
19191
19016
        return 0;
19192
19017
}
19222
19047
        static const char * const chname[4] = {
19223
19048
                "Front", "Surround", NULL /*CLFE*/, "Side"
19224
19049
        };
19225
 
        const char *pfx = alc_get_line_out_pfx(cfg, true);
19226
 
        hda_nid_t nid, mix;
19227
 
        int i, err;
19228
 
 
19229
 
        for (i = 0; i < cfg->line_outs; i++) {
 
19050
        const char *pfx = alc_get_line_out_pfx(spec, true);
 
19051
        hda_nid_t nid, mix, pin;
 
19052
        int i, err, noutputs;
 
19053
 
 
19054
        noutputs = cfg->line_outs;
 
19055
        if (spec->multi_ios > 0)
 
19056
                noutputs += spec->multi_ios;
 
19057
 
 
19058
        for (i = 0; i < noutputs; i++) {
19230
19059
                nid = spec->multiout.dac_nids[i];
19231
19060
                if (!nid)
19232
19061
                        continue;
19233
 
                mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
 
19062
                if (i >= cfg->line_outs)
 
19063
                        pin = spec->multi_io[i - 1].pin;
 
19064
                else
 
19065
                        pin = cfg->line_out_pins[i];
 
19066
                mix = alc_auto_dac_to_mix(codec, pin, nid);
19234
19067
                if (!mix)
19235
19068
                        continue;
19236
19069
                if (!pfx && i == 2) {
19276
19109
 
19277
19110
        if (!pin)
19278
19111
                return 0;
19279
 
        nid = alc662_look_for_dac(codec, pin);
 
19112
        nid = alc_auto_look_for_dac(codec, pin);
19280
19113
        if (!nid) {
19281
19114
                /* the corresponding DAC is already occupied */
19282
19115
                if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19286
19119
                                   HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19287
19120
        }
19288
19121
 
19289
 
        mix = alc662_dac_to_mix(codec, pin, nid);
 
19122
        mix = alc_auto_dac_to_mix(codec, pin, nid);
19290
19123
        if (!mix)
19291
19124
                return 0;
19292
19125
        err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19310
19143
        hda_nid_t srcs[HDA_MAX_CONNECTIONS];
19311
19144
 
19312
19145
        alc_set_pin_output(codec, nid, pin_type);
19313
 
        /* need the manual connection? */
19314
19146
        num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19315
 
        if (num <= 1)
19316
 
                return;
19317
19147
        for (i = 0; i < num; i++) {
19318
 
                if (alc662_mix_to_dac(srcs[i]) != dac)
 
19148
                if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
19319
19149
                        continue;
19320
 
                snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
 
19150
                /* need the manual connection? */
 
19151
                if (num > 1)
 
19152
                        snd_hda_codec_write(codec, nid, 0,
 
19153
                                            AC_VERB_SET_CONNECT_SEL, i);
 
19154
                /* unmute mixer widget inputs */
 
19155
                snd_hda_codec_write(codec, srcs[i], 0,
 
19156
                                    AC_VERB_SET_AMP_GAIN_MUTE,
 
19157
                                    AMP_IN_UNMUTE(0));
 
19158
                snd_hda_codec_write(codec, srcs[i], 0,
 
19159
                                    AC_VERB_SET_AMP_GAIN_MUTE,
 
19160
                                    AMP_IN_UNMUTE(1));
19321
19161
                return;
19322
19162
        }
19323
19163
}
19374
19214
 
19375
19215
#define alc662_auto_init_input_src      alc882_auto_init_input_src
19376
19216
 
 
19217
/*
 
19218
 * multi-io helper
 
19219
 */
 
19220
static int alc_auto_fill_multi_ios(struct hda_codec *codec,
 
19221
                                   unsigned int location)
 
19222
{
 
19223
        struct alc_spec *spec = codec->spec;
 
19224
        struct auto_pin_cfg *cfg = &spec->autocfg;
 
19225
        int type, i, num_pins = 0;
 
19226
 
 
19227
        for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
 
19228
                for (i = 0; i < cfg->num_inputs; i++) {
 
19229
                        hda_nid_t nid = cfg->inputs[i].pin;
 
19230
                        hda_nid_t dac;
 
19231
                        unsigned int defcfg, caps;
 
19232
                        if (cfg->inputs[i].type != type)
 
19233
                                continue;
 
19234
                        defcfg = snd_hda_codec_get_pincfg(codec, nid);
 
19235
                        if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX)
 
19236
                                continue;
 
19237
                        if (location && get_defcfg_location(defcfg) != location)
 
19238
                                continue;
 
19239
                        caps = snd_hda_query_pin_caps(codec, nid);
 
19240
                        if (!(caps & AC_PINCAP_OUT))
 
19241
                                continue;
 
19242
                        dac = alc_auto_look_for_dac(codec, nid);
 
19243
                        if (!dac)
 
19244
                                continue;
 
19245
                        spec->multi_io[num_pins].pin = nid;
 
19246
                        spec->multi_io[num_pins].dac = dac;
 
19247
                        num_pins++;
 
19248
                        spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
 
19249
                }
 
19250
        }
 
19251
        spec->multiout.num_dacs = 1;
 
19252
        if (num_pins < 2)
 
19253
                return 0;
 
19254
        return num_pins;
 
19255
}
 
19256
 
 
19257
static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol,
 
19258
                                 struct snd_ctl_elem_info *uinfo)
 
19259
{
 
19260
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
 
19261
        struct alc_spec *spec = codec->spec;
 
19262
 
 
19263
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
 
19264
        uinfo->count = 1;
 
19265
        uinfo->value.enumerated.items = spec->multi_ios + 1;
 
19266
        if (uinfo->value.enumerated.item > spec->multi_ios)
 
19267
                uinfo->value.enumerated.item = spec->multi_ios;
 
19268
        sprintf(uinfo->value.enumerated.name, "%dch",
 
19269
                (uinfo->value.enumerated.item + 1) * 2);
 
19270
        return 0;
 
19271
}
 
19272
 
 
19273
static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol,
 
19274
                                struct snd_ctl_elem_value *ucontrol)
 
19275
{
 
19276
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
 
19277
        struct alc_spec *spec = codec->spec;
 
19278
        ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2;
 
19279
        return 0;
 
19280
}
 
19281
 
 
19282
static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output)
 
19283
{
 
19284
        struct alc_spec *spec = codec->spec;
 
19285
        hda_nid_t nid = spec->multi_io[idx].pin;
 
19286
 
 
19287
        if (!spec->multi_io[idx].ctl_in)
 
19288
                spec->multi_io[idx].ctl_in =
 
19289
                        snd_hda_codec_read(codec, nid, 0,
 
19290
                                           AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
 
19291
        if (output) {
 
19292
                snd_hda_codec_update_cache(codec, nid, 0,
 
19293
                                           AC_VERB_SET_PIN_WIDGET_CONTROL,
 
19294
                                           PIN_OUT);
 
19295
                if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
 
19296
                        snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
 
19297
                                                 HDA_AMP_MUTE, 0);
 
19298
                alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac);
 
19299
        } else {
 
19300
                if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
 
19301
                        snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
 
19302
                                                 HDA_AMP_MUTE, HDA_AMP_MUTE);
 
19303
                snd_hda_codec_update_cache(codec, nid, 0,
 
19304
                                           AC_VERB_SET_PIN_WIDGET_CONTROL,
 
19305
                                           spec->multi_io[idx].ctl_in);
 
19306
        }
 
19307
        return 0;
 
19308
}
 
19309
 
 
19310
static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol,
 
19311
                                struct snd_ctl_elem_value *ucontrol)
 
19312
{
 
19313
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
 
19314
        struct alc_spec *spec = codec->spec;
 
19315
        int i, ch;
 
19316
 
 
19317
        ch = ucontrol->value.enumerated.item[0];
 
19318
        if (ch < 0 || ch > spec->multi_ios)
 
19319
                return -EINVAL;
 
19320
        if (ch == (spec->ext_channel_count - 1) / 2)
 
19321
                return 0;
 
19322
        spec->ext_channel_count = (ch + 1) * 2;
 
19323
        for (i = 0; i < spec->multi_ios; i++)
 
19324
                alc_set_multi_io(codec, i, i < ch);
 
19325
        spec->multiout.max_channels = spec->ext_channel_count;
 
19326
        return 1;
 
19327
}
 
19328
 
 
19329
static const struct snd_kcontrol_new alc_auto_channel_mode_enum = {
 
19330
        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 
19331
        .name = "Channel Mode",
 
19332
        .info = alc_auto_ch_mode_info,
 
19333
        .get = alc_auto_ch_mode_get,
 
19334
        .put = alc_auto_ch_mode_put,
 
19335
};
 
19336
 
 
19337
static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
 
19338
{
 
19339
        struct alc_spec *spec = codec->spec;
 
19340
        struct auto_pin_cfg *cfg = &spec->autocfg;
 
19341
        unsigned int location, defcfg;
 
19342
        int num_pins;
 
19343
 
 
19344
        if (cfg->line_outs != 1 ||
 
19345
            cfg->line_out_type != AUTO_PIN_LINE_OUT)
 
19346
                return 0;
 
19347
 
 
19348
        defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]);
 
19349
        location = get_defcfg_location(defcfg);
 
19350
 
 
19351
        num_pins = alc_auto_fill_multi_ios(codec, location);
 
19352
        if (num_pins > 0) {
 
19353
                struct snd_kcontrol_new *knew;
 
19354
 
 
19355
                knew = alc_kcontrol_new(spec);
 
19356
                if (!knew)
 
19357
                        return -ENOMEM;
 
19358
                *knew = alc_auto_channel_mode_enum;
 
19359
                knew->name = kstrdup("Channel Mode", GFP_KERNEL);
 
19360
                if (!knew->name)
 
19361
                        return -ENOMEM;
 
19362
 
 
19363
                spec->multi_ios = num_pins;
 
19364
                spec->ext_channel_count = 2;
 
19365
                spec->multiout.num_dacs = num_pins + 1;
 
19366
        }
 
19367
        return 0;
 
19368
}
 
19369
 
19377
19370
static int alc662_parse_auto_config(struct hda_codec *codec)
19378
19371
{
19379
19372
        struct alc_spec *spec = codec->spec;
19380
19373
        int err;
19381
 
        static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
 
19374
        static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19382
19375
 
19383
19376
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19384
19377
                                           alc662_ignore);
19390
19383
        err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
19391
19384
        if (err < 0)
19392
19385
                return err;
 
19386
        err = alc_auto_add_multi_channel_mode(codec);
 
19387
        if (err < 0)
 
19388
                return err;
19393
19389
        err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
19394
19390
        if (err < 0)
19395
19391
                return err;
19420
19416
        spec->num_mux_defs = 1;
19421
19417
        spec->input_mux = &spec->private_imux[0];
19422
19418
 
19423
 
        add_verb(spec, alc662_init_verbs);
19424
 
        if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19425
 
            codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19426
 
                add_verb(spec, alc663_init_verbs);
19427
 
 
19428
 
        if (codec->vendor_id == 0x10ec0272)
19429
 
                add_verb(spec, alc272_init_verbs);
19430
 
 
19431
19419
        err = alc_auto_add_mic_boost(codec);
19432
19420
        if (err < 0)
19433
19421
                return err;
19508
19496
        },
19509
19497
};
19510
19498
 
19511
 
static struct snd_pci_quirk alc662_fixup_tbl[] = {
 
19499
static const struct snd_pci_quirk alc662_fixup_tbl[] = {
19512
19500
        SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
19513
19501
        SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
19514
19502
        SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
19626
19614
        codec->patch_ops = alc_patch_ops;
19627
19615
        if (board_config == ALC662_AUTO)
19628
19616
                spec->init_hook = alc662_auto_init;
 
19617
        spec->shutup = alc_eapd_shutup;
19629
19618
 
19630
19619
        alc_init_jacks(codec);
19631
19620
 
19654
19643
        return patch_alc882(codec);
19655
19644
}
19656
19645
 
 
19646
static int patch_alc899(struct hda_codec *codec)
 
19647
{
 
19648
        if ((alc_read_coef_idx(codec, 0) & 0x2000) != 0x2000) {
 
19649
                kfree(codec->chip_name);
 
19650
                codec->chip_name = kstrdup("ALC898", GFP_KERNEL);
 
19651
        }
 
19652
        return patch_alc882(codec);
 
19653
}
 
19654
 
19657
19655
/*
19658
19656
 * ALC680 support
19659
19657
 */
19661
19659
#define ALC680_DIGOUT_NID       ALC880_DIGOUT_NID
19662
19660
#define alc680_modes            alc260_modes
19663
19661
 
19664
 
static hda_nid_t alc680_dac_nids[3] = {
 
19662
static const hda_nid_t alc680_dac_nids[3] = {
19665
19663
        /* Lout1, Lout2, hp */
19666
19664
        0x02, 0x03, 0x04
19667
19665
};
19668
19666
 
19669
 
static hda_nid_t alc680_adc_nids[3] = {
 
19667
static const hda_nid_t alc680_adc_nids[3] = {
19670
19668
        /* ADC0-2 */
19671
19669
        /* DMIC, MIC, Line-in*/
19672
19670
        0x07, 0x08, 0x09
19686
19684
 
19687
19685
        for (i = 0; i < cfg->num_inputs; i++) {
19688
19686
                nid = cfg->inputs[i].pin;
19689
 
                if (!(snd_hda_query_pin_caps(codec, nid) &
19690
 
                      AC_PINCAP_PRES_DETECT))
 
19687
                if (!is_jack_detectable(codec, nid))
19691
19688
                        continue;
19692
19689
                if (snd_hda_jack_detect(codec, nid)) {
19693
19690
                        if (cfg->inputs[i].type < type_found) {
19734
19731
        return 0;
19735
19732
}
19736
19733
 
19737
 
static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
 
19734
static const struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19738
19735
        .substreams = 1, /* can be overridden */
19739
19736
        .channels_min = 2,
19740
19737
        .channels_max = 2,
19745
19742
        },
19746
19743
};
19747
19744
 
19748
 
static struct snd_kcontrol_new alc680_base_mixer[] = {
 
19745
static const struct snd_kcontrol_new alc680_base_mixer[] = {
19749
19746
        /* output mixer control */
19750
19747
        HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19751
19748
        HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19757
19754
        { }
19758
19755
};
19759
19756
 
19760
 
static struct hda_bind_ctls alc680_bind_cap_vol = {
 
19757
static const struct hda_bind_ctls alc680_bind_cap_vol = {
19761
19758
        .ops = &snd_hda_bind_vol,
19762
19759
        .values = {
19763
19760
                HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19767
19764
        },
19768
19765
};
19769
19766
 
19770
 
static struct hda_bind_ctls alc680_bind_cap_switch = {
 
19767
static const struct hda_bind_ctls alc680_bind_cap_switch = {
19771
19768
        .ops = &snd_hda_bind_sw,
19772
19769
        .values = {
19773
19770
                HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19777
19774
        },
19778
19775
};
19779
19776
 
19780
 
static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
 
19777
static const struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19781
19778
        HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19782
19779
        HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
19783
19780
        { } /* end */
19786
19783
/*
19787
19784
 * generic initialization of ADC, input mixers and output mixers
19788
19785
 */
19789
 
static struct hda_verb alc680_init_verbs[] = {
 
19786
static const struct hda_verb alc680_init_verbs[] = {
19790
19787
        {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19791
19788
        {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19792
19789
        {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19824
19821
        spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19825
19822
        spec->autocfg.inputs[1].pin = 0x19;
19826
19823
        spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
 
19824
        spec->automute = 1;
 
19825
        spec->automute_mode = ALC_AUTOMUTE_AMP;
19827
19826
}
19828
19827
 
19829
19828
static void alc680_unsol_event(struct hda_codec *codec,
19830
19829
                                           unsigned int res)
19831
19830
{
19832
19831
        if ((res >> 26) == ALC880_HP_EVENT)
19833
 
                alc_automute_amp(codec);
 
19832
                alc_hp_automute(codec);
19834
19833
        if ((res >> 26) == ALC880_MIC_EVENT)
19835
19834
                alc680_rec_autoswitch(codec);
19836
19835
}
19837
19836
 
19838
19837
static void alc680_inithook(struct hda_codec *codec)
19839
19838
{
19840
 
        alc_automute_amp(codec);
 
19839
        alc_hp_automute(codec);
19841
19840
        alc680_rec_autoswitch(codec);
19842
19841
}
19843
19842
 
19874
19873
 
19875
19874
                if (err < 0)
19876
19875
                        return err;
19877
 
                spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
 
19876
                spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
19878
19877
        }
19879
19878
 
19880
19879
        return 0;
19960
19959
{
19961
19960
        struct alc_spec *spec = codec->spec;
19962
19961
        int err;
19963
 
        static hda_nid_t alc680_ignore[] = { 0 };
 
19962
        static const hda_nid_t alc680_ignore[] = { 0 };
19964
19963
 
19965
19964
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19966
19965
                                           alc680_ignore);
20018
20017
        [ALC680_AUTO]           = "auto",
20019
20018
};
20020
20019
 
20021
 
static struct snd_pci_quirk alc680_cfg_tbl[] = {
 
20020
static const struct snd_pci_quirk alc680_cfg_tbl[] = {
20022
20021
        SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
20023
20022
        {}
20024
20023
};
20025
20024
 
20026
 
static struct alc_config_preset alc680_presets[] = {
 
20025
static const struct alc_config_preset alc680_presets[] = {
20027
20026
        [ALC680_BASE] = {
20028
20027
                .mixers = { alc680_base_mixer },
20029
20028
                .cap_mixer =  alc680_master_capture_mixer,
20104
20103
/*
20105
20104
 * patch entries
20106
20105
 */
20107
 
static struct hda_codec_preset snd_hda_preset_realtek[] = {
 
20106
static const struct hda_codec_preset snd_hda_preset_realtek[] = {
 
20107
        { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
20108
20108
        { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
20109
20109
        { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
20110
20110
        { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
20113
20113
        { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
20114
20114
        { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
20115
20115
        { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
 
20116
        { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
20116
20117
        { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
20117
20118
          .patch = patch_alc861 },
20118
20119
        { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20140
20141
        { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
20141
20142
        { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
20142
20143
        { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
 
20144
        { .id = 0x10ec0899, .name = "ALC899", .patch = patch_alc899 },
20143
20145
        {} /* terminator */
20144
20146
};
20145
20147