aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-06-17 03:33:52 -0400
committerTakashi Iwai <tiwai@suse.de>2009-06-24 05:52:59 -0400
commita1e21c9078fb8005e5accb921696ec9e2f38176e (patch)
tree53b6495d7d60354688031b28aa331d7e58286d6e /sound/pci
parent8c8145b8734028f6deb487f7d64748da4c6c39ac (diff)
ALSA: hda - Don't call snd_hda_codec_configure in snd_hda_codec_new()
The codec setup call via snd_hda_codec_configure() isn't necessarily called in snd_hda_codec_new(). For the later added feature, it's better to change the code flow like: - create all codec instances - configure each codec Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_codec.c8
-rw-r--r--sound/pci/hda/hda_codec.h3
-rw-r--r--sound/pci/hda/hda_intel.c21
-rw-r--r--sound/pci/hda/hda_local.h1
4 files changed, 21 insertions, 12 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 462e2cedaa6a..506f46ef0304 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -885,7 +885,7 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
885 * Returns 0 if successful, or a negative error code. 885 * Returns 0 if successful, or a negative error code.
886 */ 886 */
887int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, 887int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
888 int do_init, struct hda_codec **codecp) 888 struct hda_codec **codecp)
889{ 889{
890 struct hda_codec *codec; 890 struct hda_codec *codec;
891 char component[31]; 891 char component[31];
@@ -978,11 +978,6 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
978 codec->afg ? codec->afg : codec->mfg, 978 codec->afg ? codec->afg : codec->mfg,
979 AC_PWRST_D0); 979 AC_PWRST_D0);
980 980
981 if (do_init) {
982 err = snd_hda_codec_configure(codec);
983 if (err < 0)
984 goto error;
985 }
986 snd_hda_codec_proc_new(codec); 981 snd_hda_codec_proc_new(codec);
987 982
988 snd_hda_create_hwdep(codec); 983 snd_hda_create_hwdep(codec);
@@ -1036,6 +1031,7 @@ int snd_hda_codec_configure(struct hda_codec *codec)
1036 err = init_unsol_queue(codec->bus); 1031 err = init_unsol_queue(codec->bus);
1037 return err; 1032 return err;
1038} 1033}
1034EXPORT_SYMBOL_HDA(snd_hda_codec_configure);
1039 1035
1040/** 1036/**
1041 * snd_hda_codec_setup_stream - set up the codec for streaming 1037 * snd_hda_codec_setup_stream - set up the codec for streaming
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index cad79efaabc9..b7ca7d5bbe8c 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -830,7 +830,8 @@ enum {
830int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, 830int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
831 struct hda_bus **busp); 831 struct hda_bus **busp);
832int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, 832int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
833 int do_init, struct hda_codec **codecp); 833 struct hda_codec **codecp);
834int snd_hda_codec_configure(struct hda_codec *codec);
834 835
835/* 836/*
836 * low level functions 837 * low level functions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 4e9ea7080270..da58f2ca9151 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1286,8 +1286,7 @@ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = {
1286 [AZX_DRIVER_TERA] = 1, 1286 [AZX_DRIVER_TERA] = 1,
1287}; 1287};
1288 1288
1289static int __devinit azx_codec_create(struct azx *chip, const char *model, 1289static int __devinit azx_codec_create(struct azx *chip, const char *model)
1290 int no_init)
1291{ 1290{
1292 struct hda_bus_template bus_temp; 1291 struct hda_bus_template bus_temp;
1293 int c, codecs, err; 1292 int c, codecs, err;
@@ -1346,7 +1345,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1346 for (c = 0; c < max_slots; c++) { 1345 for (c = 0; c < max_slots; c++) {
1347 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) { 1346 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1348 struct hda_codec *codec; 1347 struct hda_codec *codec;
1349 err = snd_hda_codec_new(chip->bus, c, !no_init, &codec); 1348 err = snd_hda_codec_new(chip->bus, c, &codec);
1350 if (err < 0) 1349 if (err < 0)
1351 continue; 1350 continue;
1352 codecs++; 1351 codecs++;
@@ -1356,7 +1355,16 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1356 snd_printk(KERN_ERR SFX "no codecs initialized\n"); 1355 snd_printk(KERN_ERR SFX "no codecs initialized\n");
1357 return -ENXIO; 1356 return -ENXIO;
1358 } 1357 }
1358 return 0;
1359}
1359 1360
1361/* configure each codec instance */
1362static int __devinit azx_codec_configure(struct azx *chip)
1363{
1364 struct hda_codec *codec;
1365 list_for_each_entry(codec, &chip->bus->codec_list, list) {
1366 snd_hda_codec_configure(codec);
1367 }
1360 return 0; 1368 return 0;
1361} 1369}
1362 1370
@@ -2466,9 +2474,14 @@ static int __devinit azx_probe(struct pci_dev *pci,
2466 card->private_data = chip; 2474 card->private_data = chip;
2467 2475
2468 /* create codec instances */ 2476 /* create codec instances */
2469 err = azx_codec_create(chip, model[dev], probe_only[dev]); 2477 err = azx_codec_create(chip, model[dev]);
2470 if (err < 0) 2478 if (err < 0)
2471 goto out_free; 2479 goto out_free;
2480 if (!probe_only[dev]) {
2481 err = azx_codec_configure(chip);
2482 if (err < 0)
2483 goto out_free;
2484 }
2472 2485
2473 /* create PCM streams */ 2486 /* create PCM streams */
2474 err = snd_hda_build_pcms(chip->bus); 2487 err = snd_hda_build_pcms(chip->bus);
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 83349013b4df..75aa3785212f 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -99,7 +99,6 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
99int snd_hda_add_vmaster(struct hda_codec *codec, char *name, 99int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
100 unsigned int *tlv, const char **slaves); 100 unsigned int *tlv, const char **slaves);
101int snd_hda_codec_reset(struct hda_codec *codec); 101int snd_hda_codec_reset(struct hda_codec *codec);
102int snd_hda_codec_configure(struct hda_codec *codec);
103 102
104/* amp value bits */ 103/* amp value bits */
105#define HDA_AMP_MUTE 0x80 104#define HDA_AMP_MUTE 0x80