diff options
Diffstat (limited to 'sound/pci/hda/hda_codec.h')
-rw-r--r-- | sound/pci/hda/hda_codec.h | 108 |
1 files changed, 29 insertions, 79 deletions
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 96421a3b32cd..457fc589eb46 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -83,10 +83,6 @@ struct hda_bus_ops { | |||
83 | struct hda_pcm *pcm); | 83 | struct hda_pcm *pcm); |
84 | /* reset bus for retry verb */ | 84 | /* reset bus for retry verb */ |
85 | void (*bus_reset)(struct hda_bus *bus); | 85 | void (*bus_reset)(struct hda_bus *bus); |
86 | #ifdef CONFIG_PM | ||
87 | /* notify power-up/down from codec to controller */ | ||
88 | void (*pm_notify)(struct hda_bus *bus, bool power_up); | ||
89 | #endif | ||
90 | #ifdef CONFIG_SND_HDA_DSP_LOADER | 86 | #ifdef CONFIG_SND_HDA_DSP_LOADER |
91 | /* prepare DSP transfer */ | 87 | /* prepare DSP transfer */ |
92 | int (*load_dsp_prepare)(struct hda_bus *bus, unsigned int format, | 88 | int (*load_dsp_prepare)(struct hda_bus *bus, unsigned int format, |
@@ -122,7 +118,6 @@ struct hda_bus { | |||
122 | void *private_data; | 118 | void *private_data; |
123 | struct pci_dev *pci; | 119 | struct pci_dev *pci; |
124 | const char *modelname; | 120 | const char *modelname; |
125 | int *power_save; | ||
126 | struct hda_bus_ops ops; | 121 | struct hda_bus_ops ops; |
127 | 122 | ||
128 | /* codec linked list */ | 123 | /* codec linked list */ |
@@ -151,10 +146,10 @@ struct hda_bus { | |||
151 | unsigned int rirb_error:1; /* error in codec communication */ | 146 | unsigned int rirb_error:1; /* error in codec communication */ |
152 | unsigned int response_reset:1; /* controller was reset */ | 147 | unsigned int response_reset:1; /* controller was reset */ |
153 | unsigned int in_reset:1; /* during reset operation */ | 148 | unsigned int in_reset:1; /* during reset operation */ |
154 | unsigned int power_keep_link_on:1; /* don't power off HDA link */ | ||
155 | unsigned int no_response_fallback:1; /* don't fallback at RIRB error */ | 149 | unsigned int no_response_fallback:1; /* don't fallback at RIRB error */ |
156 | 150 | ||
157 | int primary_dig_out_type; /* primary digital out PCM type */ | 151 | int primary_dig_out_type; /* primary digital out PCM type */ |
152 | unsigned long codec_powered; /* bit flags of powered codecs */ | ||
158 | }; | 153 | }; |
159 | 154 | ||
160 | /* | 155 | /* |
@@ -174,15 +169,22 @@ struct hda_codec_preset { | |||
174 | int (*patch)(struct hda_codec *codec); | 169 | int (*patch)(struct hda_codec *codec); |
175 | }; | 170 | }; |
176 | 171 | ||
177 | struct hda_codec_preset_list { | 172 | #define HDA_CODEC_ID_GENERIC_HDMI 0x00000101 |
173 | #define HDA_CODEC_ID_GENERIC 0x00000201 | ||
174 | |||
175 | struct hda_codec_driver { | ||
176 | struct device_driver driver; | ||
178 | const struct hda_codec_preset *preset; | 177 | const struct hda_codec_preset *preset; |
179 | struct module *owner; | ||
180 | struct list_head list; | ||
181 | }; | 178 | }; |
182 | 179 | ||
183 | /* initial hook */ | 180 | int __hda_codec_driver_register(struct hda_codec_driver *drv, const char *name, |
184 | int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset); | 181 | struct module *owner); |
185 | int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset); | 182 | #define hda_codec_driver_register(drv) \ |
183 | __hda_codec_driver_register(drv, KBUILD_MODNAME, THIS_MODULE) | ||
184 | void hda_codec_driver_unregister(struct hda_codec_driver *drv); | ||
185 | #define module_hda_codec_driver(drv) \ | ||
186 | module_driver(drv, hda_codec_driver_register, \ | ||
187 | hda_codec_driver_unregister) | ||
186 | 188 | ||
187 | /* ops set by the preset patch */ | 189 | /* ops set by the preset patch */ |
188 | struct hda_codec_ops { | 190 | struct hda_codec_ops { |
@@ -286,11 +288,10 @@ struct hda_codec { | |||
286 | u32 vendor_id; | 288 | u32 vendor_id; |
287 | u32 subsystem_id; | 289 | u32 subsystem_id; |
288 | u32 revision_id; | 290 | u32 revision_id; |
291 | u32 probe_id; /* overridden id for probing */ | ||
289 | 292 | ||
290 | /* detected preset */ | 293 | /* detected preset */ |
291 | const struct hda_codec_preset *preset; | 294 | const struct hda_codec_preset *preset; |
292 | struct module *owner; | ||
293 | int (*parser)(struct hda_codec *codec); | ||
294 | const char *vendor_name; /* codec vendor name */ | 295 | const char *vendor_name; /* codec vendor name */ |
295 | const char *chip_name; /* codec chip name */ | 296 | const char *chip_name; /* codec chip name */ |
296 | const char *modelname; /* model name for preset */ | 297 | const char *modelname; /* model name for preset */ |
@@ -366,17 +367,11 @@ struct hda_codec { | |||
366 | unsigned int dp_mst:1; /* support DP1.2 Multi-stream transport */ | 367 | unsigned int dp_mst:1; /* support DP1.2 Multi-stream transport */ |
367 | unsigned int dump_coef:1; /* dump processing coefs in codec proc file */ | 368 | unsigned int dump_coef:1; /* dump processing coefs in codec proc file */ |
368 | #ifdef CONFIG_PM | 369 | #ifdef CONFIG_PM |
369 | unsigned int power_on :1; /* current (global) power-state */ | ||
370 | unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */ | 370 | unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */ |
371 | unsigned int pm_up_notified:1; /* PM notified to controller */ | 371 | atomic_t in_pm; /* suspend/resume being performed */ |
372 | unsigned int in_pm:1; /* suspend/resume being performed */ | ||
373 | int power_transition; /* power-state in transition */ | ||
374 | int power_count; /* current (global) power refcount */ | ||
375 | struct delayed_work power_work; /* delayed task for powerdown */ | ||
376 | unsigned long power_on_acct; | 372 | unsigned long power_on_acct; |
377 | unsigned long power_off_acct; | 373 | unsigned long power_off_acct; |
378 | unsigned long power_jiffies; | 374 | unsigned long power_jiffies; |
379 | spinlock_t power_lock; | ||
380 | #endif | 375 | #endif |
381 | 376 | ||
382 | /* filter the requested power state per nid */ | 377 | /* filter the requested power state per nid */ |
@@ -408,6 +403,11 @@ struct hda_codec { | |||
408 | struct snd_array verbs; | 403 | struct snd_array verbs; |
409 | }; | 404 | }; |
410 | 405 | ||
406 | #define dev_to_hda_codec(_dev) container_of(_dev, struct hda_codec, dev) | ||
407 | #define hda_codec_dev(_dev) (&(_dev)->dev) | ||
408 | |||
409 | extern struct bus_type snd_hda_bus_type; | ||
410 | |||
411 | /* direction */ | 411 | /* direction */ |
412 | enum { | 412 | enum { |
413 | HDA_INPUT, HDA_OUTPUT | 413 | HDA_INPUT, HDA_OUTPUT |
@@ -556,14 +556,12 @@ void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg, | |||
556 | 556 | ||
557 | int snd_hda_lock_devices(struct hda_bus *bus); | 557 | int snd_hda_lock_devices(struct hda_bus *bus); |
558 | void snd_hda_unlock_devices(struct hda_bus *bus); | 558 | void snd_hda_unlock_devices(struct hda_bus *bus); |
559 | void snd_hda_bus_reset(struct hda_bus *bus); | ||
559 | 560 | ||
560 | /* | 561 | /* |
561 | * power management | 562 | * power management |
562 | */ | 563 | */ |
563 | #ifdef CONFIG_PM | 564 | extern const struct dev_pm_ops hda_codec_driver_pm; |
564 | int snd_hda_suspend(struct hda_bus *bus); | ||
565 | int snd_hda_resume(struct hda_bus *bus); | ||
566 | #endif | ||
567 | 565 | ||
568 | static inline | 566 | static inline |
569 | int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid) | 567 | int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
@@ -586,64 +584,16 @@ const char *snd_hda_get_jack_location(u32 cfg); | |||
586 | * power saving | 584 | * power saving |
587 | */ | 585 | */ |
588 | #ifdef CONFIG_PM | 586 | #ifdef CONFIG_PM |
589 | void snd_hda_power_save(struct hda_codec *codec, int delta, bool d3wait); | 587 | void snd_hda_power_up(struct hda_codec *codec); |
588 | void snd_hda_power_down(struct hda_codec *codec); | ||
589 | void snd_hda_set_power_save(struct hda_bus *bus, int delay); | ||
590 | void snd_hda_update_power_acct(struct hda_codec *codec); | 590 | void snd_hda_update_power_acct(struct hda_codec *codec); |
591 | #else | 591 | #else |
592 | static inline void snd_hda_power_save(struct hda_codec *codec, int delta, | 592 | static inline void snd_hda_power_up(struct hda_codec *codec) {} |
593 | bool d3wait) {} | 593 | static inline void snd_hda_power_down(struct hda_codec *codec) {} |
594 | static inline void snd_hda_set_power_save(struct hda_bus *bus, int delay) {} | ||
594 | #endif | 595 | #endif |
595 | 596 | ||
596 | /** | ||
597 | * snd_hda_power_up - Power-up the codec | ||
598 | * @codec: HD-audio codec | ||
599 | * | ||
600 | * Increment the power-up counter and power up the hardware really when | ||
601 | * not turned on yet. | ||
602 | */ | ||
603 | static inline void snd_hda_power_up(struct hda_codec *codec) | ||
604 | { | ||
605 | snd_hda_power_save(codec, 1, false); | ||
606 | } | ||
607 | |||
608 | /** | ||
609 | * snd_hda_power_up_d3wait - Power-up the codec after waiting for any pending | ||
610 | * D3 transition to complete. This differs from snd_hda_power_up() when | ||
611 | * power_transition == -1. snd_hda_power_up sees this case as a nop, | ||
612 | * snd_hda_power_up_d3wait waits for the D3 transition to complete then powers | ||
613 | * back up. | ||
614 | * @codec: HD-audio codec | ||
615 | * | ||
616 | * Cancel any power down operation hapenning on the work queue, then power up. | ||
617 | */ | ||
618 | static inline void snd_hda_power_up_d3wait(struct hda_codec *codec) | ||
619 | { | ||
620 | snd_hda_power_save(codec, 1, true); | ||
621 | } | ||
622 | |||
623 | /** | ||
624 | * snd_hda_power_down - Power-down the codec | ||
625 | * @codec: HD-audio codec | ||
626 | * | ||
627 | * Decrement the power-up counter and schedules the power-off work if | ||
628 | * the counter rearches to zero. | ||
629 | */ | ||
630 | static inline void snd_hda_power_down(struct hda_codec *codec) | ||
631 | { | ||
632 | snd_hda_power_save(codec, -1, false); | ||
633 | } | ||
634 | |||
635 | /** | ||
636 | * snd_hda_power_sync - Synchronize the power-save status | ||
637 | * @codec: HD-audio codec | ||
638 | * | ||
639 | * Synchronize the actual power state with the power account; | ||
640 | * called when power_save parameter is changed | ||
641 | */ | ||
642 | static inline void snd_hda_power_sync(struct hda_codec *codec) | ||
643 | { | ||
644 | snd_hda_power_save(codec, 0, false); | ||
645 | } | ||
646 | |||
647 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | 597 | #ifdef CONFIG_SND_HDA_PATCH_LOADER |
648 | /* | 598 | /* |
649 | * patch firmware | 599 | * patch firmware |