]>
git.ipfire.org Git - thirdparty/linux.git/blob - sound/pci/hda/hda_auto_parser.c
2 * BIOS auto-parser helper functions for HD-audio
4 * Copyright (c) 2012 Takashi Iwai <tiwai@suse.de>
6 * This driver is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/slab.h>
13 #include <linux/export.h>
14 #include <sound/core.h>
15 #include "hda_codec.h"
16 #include "hda_auto_parser.h"
18 #define SFX "hda_codec: "
20 int snd_hda_gen_add_verbs(struct hda_gen_spec
*spec
,
21 const struct hda_verb
*list
)
23 const struct hda_verb
**v
;
24 snd_array_init(&spec
->verbs
, sizeof(struct hda_verb
*), 8);
25 v
= snd_array_new(&spec
->verbs
);
31 EXPORT_SYMBOL_HDA(snd_hda_gen_add_verbs
);
33 void snd_hda_gen_apply_verbs(struct hda_codec
*codec
)
35 struct hda_gen_spec
*spec
= codec
->spec
;
37 for (i
= 0; i
< spec
->verbs
.used
; i
++) {
38 struct hda_verb
**v
= snd_array_elem(&spec
->verbs
, i
);
39 snd_hda_sequence_write(codec
, *v
);
42 EXPORT_SYMBOL_HDA(snd_hda_gen_apply_verbs
);
44 void snd_hda_apply_pincfgs(struct hda_codec
*codec
,
45 const struct hda_pintbl
*cfg
)
47 for (; cfg
->nid
; cfg
++)
48 snd_hda_codec_set_pincfg(codec
, cfg
->nid
, cfg
->val
);
50 EXPORT_SYMBOL_HDA(snd_hda_apply_pincfgs
);
52 void snd_hda_apply_fixup(struct hda_codec
*codec
, int action
)
54 struct hda_gen_spec
*spec
= codec
->spec
;
55 int id
= spec
->fixup_id
;
56 #ifdef CONFIG_SND_DEBUG_VERBOSE
57 const char *modelname
= spec
->fixup_name
;
61 if (!spec
->fixup_list
)
65 const struct hda_fixup
*fix
= spec
->fixup_list
+ id
;
69 if (action
!= HDA_FIXUP_ACT_PRE_PROBE
|| !fix
->v
.pins
)
71 snd_printdd(KERN_INFO SFX
72 "%s: Apply pincfg for %s\n",
73 codec
->chip_name
, modelname
);
74 snd_hda_apply_pincfgs(codec
, fix
->v
.pins
);
77 if (action
!= HDA_FIXUP_ACT_PROBE
|| !fix
->v
.verbs
)
79 snd_printdd(KERN_INFO SFX
80 "%s: Apply fix-verbs for %s\n",
81 codec
->chip_name
, modelname
);
82 snd_hda_gen_add_verbs(codec
->spec
, fix
->v
.verbs
);
87 snd_printdd(KERN_INFO SFX
88 "%s: Apply fix-func for %s\n",
89 codec
->chip_name
, modelname
);
90 fix
->v
.func(codec
, fix
, action
);
93 snd_printk(KERN_ERR SFX
94 "%s: Invalid fixup type %d\n",
95 codec
->chip_name
, fix
->type
);
105 EXPORT_SYMBOL_HDA(snd_hda_apply_fixup
);
107 void snd_hda_pick_fixup(struct hda_codec
*codec
,
108 const struct hda_model_fixup
*models
,
109 const struct snd_pci_quirk
*quirk
,
110 const struct hda_fixup
*fixlist
)
112 struct hda_gen_spec
*spec
= codec
->spec
;
113 const struct snd_pci_quirk
*q
;
115 const char *name
= NULL
;
117 /* when model=nofixup is given, don't pick up any fixups */
118 if (codec
->modelname
&& !strcmp(codec
->modelname
, "nofixup")) {
119 spec
->fixup_list
= NULL
;
124 if (codec
->modelname
&& models
) {
125 while (models
->name
) {
126 if (!strcmp(codec
->modelname
, models
->name
)) {
135 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, quirk
);
138 #ifdef CONFIG_SND_DEBUG_VERBOSE
144 for (q
= quirk
; q
->subvendor
; q
++) {
145 unsigned int vendorid
=
146 q
->subdevice
| (q
->subvendor
<< 16);
147 if (vendorid
== codec
->subsystem_id
) {
149 #ifdef CONFIG_SND_DEBUG_VERBOSE
159 spec
->fixup_list
= fixlist
;
160 spec
->fixup_name
= name
;
163 EXPORT_SYMBOL_HDA(snd_hda_pick_fixup
);