aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-02-20 03:26:04 -0500
committerTakashi Iwai <tiwai@suse.de>2015-02-26 09:36:52 -0500
commitbb573928e187fc5b1f91c3a7684791d5dfcca640 (patch)
treebc4877b0a4deaba4428bd6f73ada6152d181abb4
parentcc72da7d4d063ab9e690e56e0ef1ca1c24ee1635 (diff)
ALSA: hda - Drop power_save value indirection in hda_bus
We used to pass the power_save option value to hda_bus via a given pointer. This was needed to refer to the value from the HD-audio core side. However, after the transition to the runtime PM, this is no longer needed. This patch drops the power_save value indirection in hda_bus above, and let the controller driver reprograms the autosuspend value explicitly by a new helper, snd_hda_set_power_save(). Without this call, the HD-audio core doesn't set up the autosuspend and flip the runtime PM. (User may still be able to set up via sysfs, though.) Along with this change, the pointer argument of azx_bus_create() is dropped as well. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/hda_codec.c34
-rw-r--r--sound/pci/hda/hda_codec.h5
-rw-r--r--sound/pci/hda/hda_controller.c5
-rw-r--r--sound/pci/hda/hda_controller.h2
-rw-r--r--sound/pci/hda/hda_intel.c10
-rw-r--r--sound/pci/hda/hda_tegra.c5
6 files changed, 29 insertions, 32 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index d0dbc62c9147..36cebe0e76b2 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1175,10 +1175,8 @@ static int snd_hda_codec_dev_register(struct snd_device *device)
1175 struct hda_codec *codec = device->device_data; 1175 struct hda_codec *codec = device->device_data;
1176 1176
1177 snd_hda_register_beep_device(codec); 1177 snd_hda_register_beep_device(codec);
1178 if (device_is_registered(hda_codec_dev(codec))) { 1178 if (device_is_registered(hda_codec_dev(codec)))
1179 snd_hda_power_sync(codec);
1180 pm_runtime_enable(hda_codec_dev(codec)); 1179 pm_runtime_enable(hda_codec_dev(codec));
1181 }
1182 return 0; 1180 return 0;
1183} 1181}
1184 1182
@@ -4778,21 +4776,10 @@ void snd_hda_power_down(struct hda_codec *codec)
4778} 4776}
4779EXPORT_SYMBOL_GPL(snd_hda_power_down); 4777EXPORT_SYMBOL_GPL(snd_hda_power_down);
4780 4778
4781/** 4779static void codec_set_power_save(struct hda_codec *codec, int delay)
4782 * snd_hda_power_sync - Synchronize the power_save option
4783 * @codec: HD-audio codec
4784 *
4785 * Synchronize the runtime PM autosuspend state from the power_save option.
4786 */
4787void snd_hda_power_sync(struct hda_codec *codec)
4788{ 4780{
4789 struct device *dev = hda_codec_dev(codec); 4781 struct device *dev = hda_codec_dev(codec);
4790 int delay;
4791 4782
4792 if (!codec->bus->power_save)
4793 return;
4794
4795 delay = *codec->bus->power_save * 1000;
4796 if (delay > 0) { 4783 if (delay > 0) {
4797 pm_runtime_set_autosuspend_delay(dev, delay); 4784 pm_runtime_set_autosuspend_delay(dev, delay);
4798 pm_runtime_use_autosuspend(dev); 4785 pm_runtime_use_autosuspend(dev);
@@ -4804,7 +4791,22 @@ void snd_hda_power_sync(struct hda_codec *codec)
4804 pm_runtime_forbid(dev); 4791 pm_runtime_forbid(dev);
4805 } 4792 }
4806} 4793}
4807EXPORT_SYMBOL_GPL(snd_hda_power_sync); 4794
4795/**
4796 * snd_hda_set_power_save - reprogram autosuspend for the given delay
4797 * @bus: HD-audio bus
4798 * @delay: autosuspend delay in msec, 0 = off
4799 *
4800 * Synchronize the runtime PM autosuspend state from the power_save option.
4801 */
4802void snd_hda_set_power_save(struct hda_bus *bus, int delay)
4803{
4804 struct hda_codec *c;
4805
4806 list_for_each_entry(c, &bus->codec_list, list)
4807 codec_set_power_save(c, delay);
4808}
4809EXPORT_SYMBOL_GPL(snd_hda_set_power_save);
4808 4810
4809/** 4811/**
4810 * snd_hda_check_amp_list_power - Check the amp list and update the power 4812 * snd_hda_check_amp_list_power - Check the amp list and update the power
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 593956fc384b..89908f5b9601 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -122,7 +122,6 @@ struct hda_bus {
122 void *private_data; 122 void *private_data;
123 struct pci_dev *pci; 123 struct pci_dev *pci;
124 const char *modelname; 124 const char *modelname;
125 int *power_save;
126 struct hda_bus_ops ops; 125 struct hda_bus_ops ops;
127 126
128 /* codec linked list */ 127 /* codec linked list */
@@ -592,12 +591,12 @@ const char *snd_hda_get_jack_location(u32 cfg);
592#ifdef CONFIG_PM 591#ifdef CONFIG_PM
593void snd_hda_power_up(struct hda_codec *codec); 592void snd_hda_power_up(struct hda_codec *codec);
594void snd_hda_power_down(struct hda_codec *codec); 593void snd_hda_power_down(struct hda_codec *codec);
595void snd_hda_power_sync(struct hda_codec *codec); 594void snd_hda_set_power_save(struct hda_bus *bus, int delay);
596void snd_hda_update_power_acct(struct hda_codec *codec); 595void snd_hda_update_power_acct(struct hda_codec *codec);
597#else 596#else
598static inline void snd_hda_power_up(struct hda_codec *codec) {} 597static inline void snd_hda_power_up(struct hda_codec *codec) {}
599static inline void snd_hda_power_down(struct hda_codec *codec) {} 598static inline void snd_hda_power_down(struct hda_codec *codec) {}
600static inline void snd_hda_power_sync(struct hda_codec *codec) {} 599static inline void snd_hda_set_power_save(struct hda_bus *bus, int delay) {}
601#endif 600#endif
602 601
603#ifdef CONFIG_SND_HDA_PATCH_LOADER 602#ifdef CONFIG_SND_HDA_PATCH_LOADER
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index 522c54f94740..cfe2c55296b6 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -1838,7 +1838,7 @@ static struct hda_bus_ops bus_ops = {
1838}; 1838};
1839 1839
1840/* HD-audio bus initialization */ 1840/* HD-audio bus initialization */
1841int azx_bus_create(struct azx *chip, const char *model, int *power_save_to) 1841int azx_bus_create(struct azx *chip, const char *model)
1842{ 1842{
1843 struct hda_bus *bus; 1843 struct hda_bus *bus;
1844 int err; 1844 int err;
@@ -1852,9 +1852,6 @@ int azx_bus_create(struct azx *chip, const char *model, int *power_save_to)
1852 bus->pci = chip->pci; 1852 bus->pci = chip->pci;
1853 bus->modelname = model; 1853 bus->modelname = model;
1854 bus->ops = bus_ops; 1854 bus->ops = bus_ops;
1855#ifdef CONFIG_PM
1856 bus->power_save = power_save_to;
1857#endif
1858 1855
1859 if (chip->driver_caps & AZX_DCAPS_RIRB_DELAY) { 1856 if (chip->driver_caps & AZX_DCAPS_RIRB_DELAY) {
1860 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); 1857 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");
diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h
index 0d09aa6b49ac..e4f46a21698a 100644
--- a/sound/pci/hda/hda_controller.h
+++ b/sound/pci/hda/hda_controller.h
@@ -432,7 +432,7 @@ void azx_enter_link_reset(struct azx *chip);
432irqreturn_t azx_interrupt(int irq, void *dev_id); 432irqreturn_t azx_interrupt(int irq, void *dev_id);
433 433
434/* Codec interface */ 434/* Codec interface */
435int azx_bus_create(struct azx *chip, const char *model, int *power_save_to); 435int azx_bus_create(struct azx *chip, const char *model);
436int azx_probe_codecs(struct azx *chip, unsigned int max_slots); 436int azx_probe_codecs(struct azx *chip, unsigned int max_slots);
437int azx_codec_configure(struct azx *chip); 437int azx_codec_configure(struct azx *chip);
438int azx_init_stream(struct azx *chip); 438int azx_init_stream(struct azx *chip);
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 26510e60cbe2..40540048b002 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -173,7 +173,6 @@ static struct kernel_param_ops param_ops_xint = {
173#define param_check_xint param_check_int 173#define param_check_xint param_check_int
174 174
175static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; 175static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
176static int *power_save_addr = &power_save;
177module_param(power_save, xint, 0644); 176module_param(power_save, xint, 0644);
178MODULE_PARM_DESC(power_save, "Automatic power-saving timeout " 177MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
179 "(in second, 0 = disable)."); 178 "(in second, 0 = disable).");
@@ -186,7 +185,7 @@ static bool power_save_controller = 1;
186module_param(power_save_controller, bool, 0644); 185module_param(power_save_controller, bool, 0644);
187MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode."); 186MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
188#else 187#else
189static int *power_save_addr; 188#define power_save 0
190#endif /* CONFIG_PM */ 189#endif /* CONFIG_PM */
191 190
192static int align_buffer_size = -1; 191static int align_buffer_size = -1;
@@ -740,7 +739,6 @@ static int param_set_xint(const char *val, const struct kernel_param *kp)
740{ 739{
741 struct hda_intel *hda; 740 struct hda_intel *hda;
742 struct azx *chip; 741 struct azx *chip;
743 struct hda_codec *c;
744 int prev = power_save; 742 int prev = power_save;
745 int ret = param_set_int(val, kp); 743 int ret = param_set_int(val, kp);
746 744
@@ -752,8 +750,7 @@ static int param_set_xint(const char *val, const struct kernel_param *kp)
752 chip = &hda->chip; 750 chip = &hda->chip;
753 if (!chip->bus || chip->disabled) 751 if (!chip->bus || chip->disabled)
754 continue; 752 continue;
755 list_for_each_entry(c, &chip->bus->codec_list, list) 753 snd_hda_set_power_save(chip->bus, power_save * 1000);
756 snd_hda_power_sync(c);
757 } 754 }
758 mutex_unlock(&card_list_lock); 755 mutex_unlock(&card_list_lock);
759 return 0; 756 return 0;
@@ -1889,7 +1886,7 @@ static int azx_probe_continue(struct azx *chip)
1889#endif 1886#endif
1890 1887
1891 /* create codec instances */ 1888 /* create codec instances */
1892 err = azx_bus_create(chip, model[dev], power_save_addr); 1889 err = azx_bus_create(chip, model[dev]);
1893 if (err < 0) 1890 if (err < 0)
1894 goto out_free; 1891 goto out_free;
1895 1892
@@ -1933,6 +1930,7 @@ static int azx_probe_continue(struct azx *chip)
1933 power_down_all_codecs(chip); 1930 power_down_all_codecs(chip);
1934 azx_notifier_register(chip); 1931 azx_notifier_register(chip);
1935 azx_add_card_list(chip); 1932 azx_add_card_list(chip);
1933 snd_hda_set_power_save(chip->bus, power_save * 1000);
1936 if (azx_has_pm_runtime(chip) || hda->use_vga_switcheroo) 1934 if (azx_has_pm_runtime(chip) || hda->use_vga_switcheroo)
1937 pm_runtime_put_noidle(&pci->dev); 1935 pm_runtime_put_noidle(&pci->dev);
1938 1936
diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
index f6949e413a50..42bc17655df0 100644
--- a/sound/pci/hda/hda_tegra.c
+++ b/sound/pci/hda/hda_tegra.c
@@ -81,7 +81,7 @@ module_param(power_save, bint, 0644);
81MODULE_PARM_DESC(power_save, 81MODULE_PARM_DESC(power_save,
82 "Automatic power-saving timeout (in seconds, 0 = disable)."); 82 "Automatic power-saving timeout (in seconds, 0 = disable).");
83#else 83#else
84static int power_save = 0; 84#define power_save 0
85#endif 85#endif
86 86
87/* 87/*
@@ -496,7 +496,7 @@ static int hda_tegra_probe(struct platform_device *pdev)
496 goto out_free; 496 goto out_free;
497 497
498 /* create codec instances */ 498 /* create codec instances */
499 err = azx_bus_create(chip, NULL, &power_save); 499 err = azx_bus_create(chip, NULL);
500 if (err < 0) 500 if (err < 0)
501 goto out_free; 501 goto out_free;
502 502
@@ -525,6 +525,7 @@ static int hda_tegra_probe(struct platform_device *pdev)
525 chip->running = 1; 525 chip->running = 1;
526 power_down_all_codecs(chip); 526 power_down_all_codecs(chip);
527 azx_notifier_register(chip); 527 azx_notifier_register(chip);
528 snd_hda_set_power_save(chip->bus, power_save * 1000);
528 529
529 return 0; 530 return 0;
530 531