ALSA: hda - Move fixup code into struct hda_codec
authorTakashi Iwai <tiwai@suse.de>
Tue, 18 Dec 2012 17:12:44 +0000 (18:12 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sat, 12 Jan 2013 07:30:45 +0000 (08:30 +0100)
Since the fixup code is used commonly, it's worth to move it to the
common place, struct hda_codec, instead of keeping in hda_gen_spec.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_auto_parser.c
sound/pci/hda/hda_auto_parser.h
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/hda_local.h
sound/pci/hda/patch_cirrus.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_via.c

index 7da883a464e327f7880c2974cdb5130770eca75e..d4606884f6a3aef3253ac3b0d26d30ef04088ee0 100644 (file)
@@ -622,28 +622,27 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
 }
 EXPORT_SYMBOL_HDA(snd_hda_get_pin_label);
 
-int snd_hda_gen_add_verbs(struct hda_gen_spec *spec,
-                         const struct hda_verb *list)
+int snd_hda_add_verbs(struct hda_codec *codec,
+                     const struct hda_verb *list)
 {
        const struct hda_verb **v;
-       v = snd_array_new(&spec->verbs);
+       v = snd_array_new(&codec->verbs);
        if (!v)
                return -ENOMEM;
        *v = list;
        return 0;
 }
-EXPORT_SYMBOL_HDA(snd_hda_gen_add_verbs);
+EXPORT_SYMBOL_HDA(snd_hda_add_verbs);
 
-void snd_hda_gen_apply_verbs(struct hda_codec *codec)
+void snd_hda_apply_verbs(struct hda_codec *codec)
 {
-       struct hda_gen_spec *spec = codec->spec;
        int i;
-       for (i = 0; i < spec->verbs.used; i++) {
-               struct hda_verb **v = snd_array_elem(&spec->verbs, i);
+       for (i = 0; i < codec->verbs.used; i++) {
+               struct hda_verb **v = snd_array_elem(&codec->verbs, i);
                snd_hda_sequence_write(codec, *v);
        }
 }
-EXPORT_SYMBOL_HDA(snd_hda_gen_apply_verbs);
+EXPORT_SYMBOL_HDA(snd_hda_apply_verbs);
 
 void snd_hda_apply_pincfgs(struct hda_codec *codec,
                           const struct hda_pintbl *cfg)
@@ -655,18 +654,17 @@ EXPORT_SYMBOL_HDA(snd_hda_apply_pincfgs);
 
 void snd_hda_apply_fixup(struct hda_codec *codec, int action)
 {
-       struct hda_gen_spec *spec = codec->spec;
-       int id = spec->fixup_id;
+       int id = codec->fixup_id;
 #ifdef CONFIG_SND_DEBUG_VERBOSE
-       const char *modelname = spec->fixup_name;
+       const char *modelname = codec->fixup_name;
 #endif
        int depth = 0;
 
-       if (!spec->fixup_list)
+       if (!codec->fixup_list)
                return;
 
        while (id >= 0) {
-               const struct hda_fixup *fix = spec->fixup_list + id;
+               const struct hda_fixup *fix = codec->fixup_list + id;
 
                switch (fix->type) {
                case HDA_FIXUP_PINS:
@@ -683,7 +681,7 @@ void snd_hda_apply_fixup(struct hda_codec *codec, int action)
                        snd_printdd(KERN_INFO SFX
                                    "%s: Apply fix-verbs for %s\n",
                                    codec->chip_name, modelname);
-                       snd_hda_gen_add_verbs(codec->spec, fix->v.verbs);
+                       snd_hda_add_verbs(codec, fix->v.verbs);
                        break;
                case HDA_FIXUP_FUNC:
                        if (!fix->v.func)
@@ -713,15 +711,14 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
                        const struct snd_pci_quirk *quirk,
                        const struct hda_fixup *fixlist)
 {
-       struct hda_gen_spec *spec = codec->spec;
        const struct snd_pci_quirk *q;
        int id = -1;
        const char *name = NULL;
 
        /* when model=nofixup is given, don't pick up any fixups */
        if (codec->modelname && !strcmp(codec->modelname, "nofixup")) {
-               spec->fixup_list = NULL;
-               spec->fixup_id = -1;
+               codec->fixup_list = NULL;
+               codec->fixup_id = -1;
                return;
        }
 
@@ -759,10 +756,10 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
                }
        }
 
-       spec->fixup_id = id;
+       codec->fixup_id = id;
        if (id >= 0) {
-               spec->fixup_list = fixlist;
-               spec->fixup_name = name;
+               codec->fixup_list = fixlist;
+               codec->fixup_name = name;
        }
 }
 EXPORT_SYMBOL_HDA(snd_hda_pick_fixup);
index 632ad0ad3007491b827f7e2e3edcb87dba280c6e..ff11074b6c8b6a1f2a00bd2376b051c6775ca2cb 100644 (file)
@@ -89,82 +89,4 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
 #define snd_hda_parse_pin_def_config(codec, cfg, ignore) \
        snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0)
 
-/*
- */
-
-struct hda_gen_spec {
-       /* fix-up list */
-       int fixup_id;
-       const struct hda_fixup *fixup_list;
-       const char *fixup_name;
-
-       /* additional init verbs */
-       struct snd_array verbs;
-};
-
-
-/*
- * Fix-up pin default configurations and add default verbs
- */
-
-struct hda_pintbl {
-       hda_nid_t nid;
-       u32 val;
-};
-
-struct hda_model_fixup {
-       const int id;
-       const char *name;
-};
-
-struct hda_fixup {
-       int type;
-       bool chained;
-       int chain_id;
-       union {
-               const struct hda_pintbl *pins;
-               const struct hda_verb *verbs;
-               void (*func)(struct hda_codec *codec,
-                            const struct hda_fixup *fix,
-                            int action);
-       } v;
-};
-
-/* fixup types */
-enum {
-       HDA_FIXUP_INVALID,
-       HDA_FIXUP_PINS,
-       HDA_FIXUP_VERBS,
-       HDA_FIXUP_FUNC,
-};
-
-/* fixup action definitions */
-enum {
-       HDA_FIXUP_ACT_PRE_PROBE,
-       HDA_FIXUP_ACT_PROBE,
-       HDA_FIXUP_ACT_INIT,
-       HDA_FIXUP_ACT_BUILD,
-};
-
-int snd_hda_gen_add_verbs(struct hda_gen_spec *spec,
-                         const struct hda_verb *list);
-void snd_hda_gen_apply_verbs(struct hda_codec *codec);
-void snd_hda_apply_pincfgs(struct hda_codec *codec,
-                          const struct hda_pintbl *cfg);
-void snd_hda_apply_fixup(struct hda_codec *codec, int action);
-void snd_hda_pick_fixup(struct hda_codec *codec,
-                       const struct hda_model_fixup *models,
-                       const struct snd_pci_quirk *quirk,
-                       const struct hda_fixup *fixlist);
-
-static inline void snd_hda_gen_init(struct hda_gen_spec *spec)
-{
-       snd_array_init(&spec->verbs, sizeof(struct hda_verb *), 8);
-}
-
-static inline void snd_hda_gen_free(struct hda_gen_spec *spec)
-{
-       snd_array_free(&spec->verbs);
-}
-
 #endif /* __SOUND_HDA_AUTO_PARSER_H */
index 0037147dcd544035993bc5d6829c002435c36fab..e7749dee7c407d67dba0a5fa2bcef6bc41f5233a 100644 (file)
@@ -1253,6 +1253,7 @@ int snd_hda_codec_new(struct hda_bus *bus,
        snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64);
        snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16);
        snd_array_init(&codec->jacktbl, sizeof(struct hda_jack_tbl), 16);
+       snd_array_init(&codec->verbs, sizeof(struct hda_verb *), 8);
        INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work);
 
 #ifdef CONFIG_PM
@@ -2407,6 +2408,7 @@ int snd_hda_codec_reset(struct hda_codec *codec)
        snd_array_free(&codec->driver_pins);
        snd_array_free(&codec->cvt_setups);
        snd_array_free(&codec->spdif_out);
+       snd_array_free(&codec->verbs);
        codec->num_pcms = 0;
        codec->pcm_info = NULL;
        codec->preset = NULL;
index cab39b23d37c89e4f89d6b548f3e8a509a8d9b21..a1cb28ff39681f81fbf7eb5a3e8d7cc9238f5fba 100644 (file)
@@ -896,6 +896,14 @@ struct hda_codec {
        /* jack detection */
        struct snd_array jacks;
 #endif
+
+       /* fix-up list */
+       int fixup_id;
+       const struct hda_fixup *fixup_list;
+       const char *fixup_name;
+
+       /* additional init verbs */
+       struct snd_array verbs;
 };
 
 /* direction */
index ff56da82b7a0b7fb0455d8ba0974f41829ebaa4d..de12dcc5accc051ea8ce7c6f32aab49326b2320c 100644 (file)
@@ -385,6 +385,59 @@ int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
 int snd_hda_add_new_ctls(struct hda_codec *codec,
                         const struct snd_kcontrol_new *knew);
 
+/*
+ * Fix-up pin default configurations and add default verbs
+ */
+
+struct hda_pintbl {
+       hda_nid_t nid;
+       u32 val;
+};
+
+struct hda_model_fixup {
+       const int id;
+       const char *name;
+};
+
+struct hda_fixup {
+       int type;
+       bool chained;
+       int chain_id;
+       union {
+               const struct hda_pintbl *pins;
+               const struct hda_verb *verbs;
+               void (*func)(struct hda_codec *codec,
+                            const struct hda_fixup *fix,
+                            int action);
+       } v;
+};
+
+/* fixup types */
+enum {
+       HDA_FIXUP_INVALID,
+       HDA_FIXUP_PINS,
+       HDA_FIXUP_VERBS,
+       HDA_FIXUP_FUNC,
+};
+
+/* fixup action definitions */
+enum {
+       HDA_FIXUP_ACT_PRE_PROBE,
+       HDA_FIXUP_ACT_PROBE,
+       HDA_FIXUP_ACT_INIT,
+       HDA_FIXUP_ACT_BUILD,
+};
+
+int snd_hda_add_verbs(struct hda_codec *codec, const struct hda_verb *list);
+void snd_hda_apply_verbs(struct hda_codec *codec);
+void snd_hda_apply_pincfgs(struct hda_codec *codec,
+                          const struct hda_pintbl *cfg);
+void snd_hda_apply_fixup(struct hda_codec *codec, int action);
+void snd_hda_pick_fixup(struct hda_codec *codec,
+                       const struct hda_model_fixup *models,
+                       const struct snd_pci_quirk *quirk,
+                       const struct hda_fixup *fixlist);
+
 /*
  * unsolicited event handler
  */
index a2537b2f87240ae20f2d75d5d3cb7a0ebdc81510..7b0b8c3057375a692b549d82b941f653dd98136c 100644 (file)
@@ -34,8 +34,6 @@
  */
 
 struct cs_spec {
-       struct hda_gen_spec gen;
-
        struct auto_pin_cfg autocfg;
        struct hda_multi_out multiout;
        struct snd_kcontrol *vmaster_sw;
@@ -1201,7 +1199,7 @@ static int cs_init(struct hda_codec *codec)
 
        snd_hda_sequence_write(codec, cs_coef_init_verbs);
 
-       snd_hda_gen_apply_verbs(codec);
+       snd_hda_apply_verbs(codec);
 
        if (spec->gpio_mask) {
                snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
@@ -1252,7 +1250,6 @@ static void cs_free(struct hda_codec *codec)
        struct cs_spec *spec = codec->spec;
        kfree(spec->capture_bind[0]);
        kfree(spec->capture_bind[1]);
-       snd_hda_gen_free(&spec->gen);
        kfree(codec->spec);
 }
 
@@ -1443,7 +1440,6 @@ static int patch_cs420x(struct hda_codec *codec)
        if (!spec)
                return -ENOMEM;
        codec->spec = spec;
-       snd_hda_gen_init(&spec->gen);
 
        spec->vendor_nid = CS420X_VENDOR_NID;
 
@@ -1981,7 +1977,6 @@ static int patch_cs4210(struct hda_codec *codec)
        if (!spec)
                return -ENOMEM;
        codec->spec = spec;
-       snd_hda_gen_init(&spec->gen);
 
        spec->vendor_nid = CS4210_VENDOR_NID;
 
@@ -2021,7 +2016,6 @@ static int patch_cs4213(struct hda_codec *codec)
        if (!spec)
                return -ENOMEM;
        codec->spec = spec;
-       snd_hda_gen_init(&spec->gen);
 
        spec->vendor_nid = CS4213_VENDOR_NID;
 
index dd798c3196ff224f71bad57b1ca357c820e7fc35..a52f5662f69c55e8a3696f927e4d38bf4f6d2ba4 100644 (file)
@@ -67,8 +67,6 @@ struct imux_info {
 };
 
 struct conexant_spec {
-       struct hda_gen_spec gen;
-
        const struct snd_kcontrol_new *mixers[5];
        int num_mixers;
        hda_nid_t vmaster_nid;
@@ -451,7 +449,6 @@ static int conexant_init(struct hda_codec *codec)
 static void conexant_free(struct hda_codec *codec)
 {
        struct conexant_spec *spec = codec->spec;
-       snd_hda_gen_free(&spec->gen);
        snd_hda_detach_beep_device(codec);
        kfree(spec);
 }
@@ -4033,7 +4030,7 @@ static void cx_auto_init_digital(struct hda_codec *codec)
 static int cx_auto_init(struct hda_codec *codec)
 {
        struct conexant_spec *spec = codec->spec;
-       snd_hda_gen_apply_verbs(codec);
+       snd_hda_apply_verbs(codec);
        cx_auto_init_output(codec);
        cx_auto_init_input(codec);
        cx_auto_init_digital(codec);
@@ -4533,7 +4530,6 @@ static int patch_conexant_auto(struct hda_codec *codec)
        if (!spec)
                return -ENOMEM;
        codec->spec = spec;
-       snd_hda_gen_init(&spec->gen);
 
        switch (codec->vendor_id) {
        case 0x14f15045:
index fbdcbded3417d7168c7ee3fcf01653251e6e1f48..567d93f6c69837b488dd2a542c93ae8d94bc1387 100644 (file)
@@ -121,8 +121,6 @@ struct nid_path {
 };
 
 struct alc_spec {
-       struct hda_gen_spec gen;
-
        /* codec parameterization */
        const struct snd_kcontrol_new *mixers[5];       /* mixer arrays */
        unsigned int num_mixers;
@@ -1727,7 +1725,7 @@ static int alc_init(struct hda_codec *codec)
        alc_fix_pll(codec);
        alc_auto_init_amp(codec, spec->init_amp);
 
-       snd_hda_gen_apply_verbs(codec);
+       snd_hda_apply_verbs(codec);
        alc_auto_init_std(codec);
 
        if (spec->vmaster_mute.sw_kctl && spec->vmaster_mute.hook)
@@ -2117,7 +2115,6 @@ static void alc_free(struct hda_codec *codec)
        alc_free_kctls(codec);
        alc_free_bind_ctls(codec);
        snd_array_free(&spec->paths);
-       snd_hda_gen_free(&spec->gen);
        kfree(spec);
        snd_hda_detach_beep_device(codec);
 }
@@ -4525,7 +4522,6 @@ static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
        codec->spec = spec;
        codec->single_adc_amp = 1;
        spec->mixer_nid = mixer_nid;
-       snd_hda_gen_init(&spec->gen);
        snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
        snd_array_init(&spec->bind_ctls, sizeof(struct hda_bind_ctls *), 8);
        snd_array_init(&spec->paths, sizeof(struct nid_path), 8);
@@ -5001,7 +4997,7 @@ static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
                spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
                snd_hda_jack_detect_enable_callback(codec, 0x0f, ALC_HP_EVENT,
                                                    alc_hp_automute);
-               snd_hda_gen_add_verbs(&spec->gen, alc_gpio1_init_verbs);
+               snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
        }
 }
 
@@ -5878,7 +5874,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
        if (err > 0) {
                if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) {
                        add_mixer(spec, alc268_beep_mixer);
-                       snd_hda_gen_add_verbs(&spec->gen, alc268_beep_init_verbs);
+                       snd_hda_add_verbs(codec, alc268_beep_init_verbs);
                }
        }
        return err;
index 09bb64996d72ee3dba0335fa07b2cb3bf44fa2a9..b224b3d68184e5fca58314050dba7307a7037557 100644 (file)
@@ -120,8 +120,6 @@ enum {
 };
 
 struct via_spec {
-       struct hda_gen_spec gen;
-
        /* codec parameterization */
        const struct snd_kcontrol_new *mixers[6];
        unsigned int num_mixers;
@@ -252,7 +250,6 @@ static struct via_spec * via_new_spec(struct hda_codec *codec)
        /* VT1708BCE & VT1708S are almost same */
        if (spec->codec_type == VT1708BCE)
                spec->codec_type = VT1708S;
-       snd_hda_gen_init(&spec->gen);
        return spec;
 }
 
@@ -1657,7 +1654,6 @@ static void via_free(struct hda_codec *codec)
        vt1708_stop_hp_work(spec);
        kfree(spec->bind_cap_vol);
        kfree(spec->bind_cap_sw);
-       snd_hda_gen_free(&spec->gen);
        kfree(spec);
 }