Commit 709949fb authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Power down codec automatically at registration

So far, we let the controller driver power down the all codecs at the
end of probe.  But this can be done better in the codec's dev_register
callback.  This results in the reduction of duplicated codes in each
control driver.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 55ed9cd1
...@@ -1163,6 +1163,8 @@ static int snd_hda_codec_dev_register(struct snd_device *device) ...@@ -1163,6 +1163,8 @@ static int snd_hda_codec_dev_register(struct snd_device *device)
snd_hda_register_beep_device(codec); snd_hda_register_beep_device(codec);
if (device_is_registered(hda_codec_dev(codec))) if (device_is_registered(hda_codec_dev(codec)))
pm_runtime_enable(hda_codec_dev(codec)); pm_runtime_enable(hda_codec_dev(codec));
/* it was powered up in snd_hda_codec_new(), now all done */
snd_hda_power_down(codec);
return 0; return 0;
} }
...@@ -1260,8 +1262,7 @@ int snd_hda_codec_new(struct hda_bus *bus, ...@@ -1260,8 +1262,7 @@ int snd_hda_codec_new(struct hda_bus *bus,
#ifdef CONFIG_PM #ifdef CONFIG_PM
/* snd_hda_codec_new() marks the codec as power-up, and leave it as is. /* snd_hda_codec_new() marks the codec as power-up, and leave it as is.
* the caller has to power down appropriatley after initialization * it's powered down later in snd_hda_codec_dev_register().
* phase.
*/ */
set_bit(codec->addr, &bus->codec_powered); set_bit(codec->addr, &bus->codec_powered);
pm_runtime_set_active(hda_codec_dev(codec)); pm_runtime_set_active(hda_codec_dev(codec));
......
...@@ -1604,19 +1604,6 @@ static int azx_first_init(struct azx *chip) ...@@ -1604,19 +1604,6 @@ static int azx_first_init(struct azx *chip)
return 0; return 0;
} }
static void power_down_all_codecs(struct azx *chip)
{
#ifdef CONFIG_PM
/* The codecs were powered up in snd_hda_codec_new().
* Now all initialization done, so turn them down if possible
*/
struct hda_codec *codec;
list_for_each_entry(codec, &chip->bus->codec_list, list) {
snd_hda_power_down(codec);
}
#endif
}
#ifdef CONFIG_SND_HDA_PATCH_LOADER #ifdef CONFIG_SND_HDA_PATCH_LOADER
/* callback from request_firmware_nowait() */ /* callback from request_firmware_nowait() */
static void azx_firmware_cb(const struct firmware *fw, void *context) static void azx_firmware_cb(const struct firmware *fw, void *context)
...@@ -1926,7 +1913,6 @@ static int azx_probe_continue(struct azx *chip) ...@@ -1926,7 +1913,6 @@ static int azx_probe_continue(struct azx *chip)
goto out_free; goto out_free;
chip->running = 1; chip->running = 1;
power_down_all_codecs(chip);
azx_notifier_register(chip); azx_notifier_register(chip);
azx_add_card_list(chip); azx_add_card_list(chip);
snd_hda_set_power_save(chip->bus, power_save * 1000); snd_hda_set_power_save(chip->bus, power_save * 1000);
......
...@@ -337,17 +337,6 @@ static int hda_tegra_init_chip(struct azx *chip, struct platform_device *pdev) ...@@ -337,17 +337,6 @@ static int hda_tegra_init_chip(struct azx *chip, struct platform_device *pdev)
return 0; return 0;
} }
/*
* The codecs were powered up in snd_hda_codec_new().
* Now all initialization done, so turn them down if possible
*/
static void power_down_all_codecs(struct azx *chip)
{
struct hda_codec *codec;
list_for_each_entry(codec, &chip->bus->codec_list, list)
snd_hda_power_down(codec);
}
static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev)
{ {
struct snd_card *card = chip->card; struct snd_card *card = chip->card;
...@@ -523,7 +512,6 @@ static int hda_tegra_probe(struct platform_device *pdev) ...@@ -523,7 +512,6 @@ static int hda_tegra_probe(struct platform_device *pdev)
goto out_free; goto out_free;
chip->running = 1; chip->running = 1;
power_down_all_codecs(chip);
azx_notifier_register(chip); azx_notifier_register(chip);
snd_hda_set_power_save(chip->bus, power_save * 1000); snd_hda_set_power_save(chip->bus, power_save * 1000);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment