diff options
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 148 |
1 files changed, 134 insertions, 14 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index e15254204c72..ca98f5209f8f 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -77,6 +77,10 @@ static struct hda_vendor_id hda_vendor_ids[] = { | |||
77 | static DEFINE_MUTEX(preset_mutex); | 77 | static DEFINE_MUTEX(preset_mutex); |
78 | static LIST_HEAD(hda_preset_tables); | 78 | static LIST_HEAD(hda_preset_tables); |
79 | 79 | ||
80 | /** | ||
81 | * snd_hda_add_codec_preset - Add a codec preset to the chain | ||
82 | * @preset: codec preset table to add | ||
83 | */ | ||
80 | int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset) | 84 | int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset) |
81 | { | 85 | { |
82 | mutex_lock(&preset_mutex); | 86 | mutex_lock(&preset_mutex); |
@@ -86,6 +90,10 @@ int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset) | |||
86 | } | 90 | } |
87 | EXPORT_SYMBOL_GPL(snd_hda_add_codec_preset); | 91 | EXPORT_SYMBOL_GPL(snd_hda_add_codec_preset); |
88 | 92 | ||
93 | /** | ||
94 | * snd_hda_delete_codec_preset - Delete a codec preset from the chain | ||
95 | * @preset: codec preset table to delete | ||
96 | */ | ||
89 | int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset) | 97 | int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset) |
90 | { | 98 | { |
91 | mutex_lock(&preset_mutex); | 99 | mutex_lock(&preset_mutex); |
@@ -1187,7 +1195,16 @@ unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid) | |||
1187 | } | 1195 | } |
1188 | EXPORT_SYMBOL_GPL(snd_hda_codec_get_pincfg); | 1196 | EXPORT_SYMBOL_GPL(snd_hda_codec_get_pincfg); |
1189 | 1197 | ||
1190 | /* remember the current pinctl target value */ | 1198 | /** |
1199 | * snd_hda_codec_set_pin_target - remember the current pinctl target value | ||
1200 | * @codec: the HDA codec | ||
1201 | * @nid: pin NID | ||
1202 | * @val: assigned pinctl value | ||
1203 | * | ||
1204 | * This function stores the given value to a pinctl target value in the | ||
1205 | * pincfg table. This isn't always as same as the actually written value | ||
1206 | * but can be referred at any time via snd_hda_codec_get_pin_target(). | ||
1207 | */ | ||
1191 | int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid, | 1208 | int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid, |
1192 | unsigned int val) | 1209 | unsigned int val) |
1193 | { | 1210 | { |
@@ -1201,7 +1218,11 @@ int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid, | |||
1201 | } | 1218 | } |
1202 | EXPORT_SYMBOL_GPL(snd_hda_codec_set_pin_target); | 1219 | EXPORT_SYMBOL_GPL(snd_hda_codec_set_pin_target); |
1203 | 1220 | ||
1204 | /* return the current pinctl target value */ | 1221 | /** |
1222 | * snd_hda_codec_get_pin_target - return the current pinctl target value | ||
1223 | * @codec: the HDA codec | ||
1224 | * @nid: pin NID | ||
1225 | */ | ||
1205 | int snd_hda_codec_get_pin_target(struct hda_codec *codec, hda_nid_t nid) | 1226 | int snd_hda_codec_get_pin_target(struct hda_codec *codec, hda_nid_t nid) |
1206 | { | 1227 | { |
1207 | struct hda_pincfg *pin; | 1228 | struct hda_pincfg *pin; |
@@ -1573,6 +1594,13 @@ int snd_hda_codec_new(struct hda_bus *bus, | |||
1573 | } | 1594 | } |
1574 | EXPORT_SYMBOL_GPL(snd_hda_codec_new); | 1595 | EXPORT_SYMBOL_GPL(snd_hda_codec_new); |
1575 | 1596 | ||
1597 | /** | ||
1598 | * snd_hda_codec_update_widgets - Refresh widget caps and pin defaults | ||
1599 | * @codec: the HDA codec | ||
1600 | * | ||
1601 | * Forcibly refresh the all widget caps and the init pin configurations of | ||
1602 | * the given codec. | ||
1603 | */ | ||
1576 | int snd_hda_codec_update_widgets(struct hda_codec *codec) | 1604 | int snd_hda_codec_update_widgets(struct hda_codec *codec) |
1577 | { | 1605 | { |
1578 | hda_nid_t fg; | 1606 | hda_nid_t fg; |
@@ -2239,7 +2267,17 @@ int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid, | |||
2239 | } | 2267 | } |
2240 | EXPORT_SYMBOL_GPL(snd_hda_codec_amp_stereo); | 2268 | EXPORT_SYMBOL_GPL(snd_hda_codec_amp_stereo); |
2241 | 2269 | ||
2242 | /* Works like snd_hda_codec_amp_update() but it writes the value only at | 2270 | /** |
2271 | * snd_hda_codec_amp_init - initialize the AMP value | ||
2272 | * @codec: the HDA codec | ||
2273 | * @nid: NID to read the AMP value | ||
2274 | * @ch: channel (left=0 or right=1) | ||
2275 | * @dir: #HDA_INPUT or #HDA_OUTPUT | ||
2276 | * @idx: the index value (only for input direction) | ||
2277 | * @mask: bit mask to set | ||
2278 | * @val: the bits value to set | ||
2279 | * | ||
2280 | * Works like snd_hda_codec_amp_update() but it writes the value only at | ||
2243 | * the first access. If the amp was already initialized / updated beforehand, | 2281 | * the first access. If the amp was already initialized / updated beforehand, |
2244 | * this does nothing. | 2282 | * this does nothing. |
2245 | */ | 2283 | */ |
@@ -2250,6 +2288,17 @@ int snd_hda_codec_amp_init(struct hda_codec *codec, hda_nid_t nid, int ch, | |||
2250 | } | 2288 | } |
2251 | EXPORT_SYMBOL_GPL(snd_hda_codec_amp_init); | 2289 | EXPORT_SYMBOL_GPL(snd_hda_codec_amp_init); |
2252 | 2290 | ||
2291 | /** | ||
2292 | * snd_hda_codec_amp_init_stereo - initialize the stereo AMP value | ||
2293 | * @codec: the HDA codec | ||
2294 | * @nid: NID to read the AMP value | ||
2295 | * @dir: #HDA_INPUT or #HDA_OUTPUT | ||
2296 | * @idx: the index value (only for input direction) | ||
2297 | * @mask: bit mask to set | ||
2298 | * @val: the bits value to set | ||
2299 | * | ||
2300 | * Call snd_hda_codec_amp_init() for both stereo channels. | ||
2301 | */ | ||
2253 | int snd_hda_codec_amp_init_stereo(struct hda_codec *codec, hda_nid_t nid, | 2302 | int snd_hda_codec_amp_init_stereo(struct hda_codec *codec, hda_nid_t nid, |
2254 | int dir, int idx, int mask, int val) | 2303 | int dir, int idx, int mask, int val) |
2255 | { | 2304 | { |
@@ -2644,7 +2693,10 @@ void snd_hda_ctls_clear(struct hda_codec *codec) | |||
2644 | snd_array_free(&codec->nids); | 2693 | snd_array_free(&codec->nids); |
2645 | } | 2694 | } |
2646 | 2695 | ||
2647 | /* pseudo device locking | 2696 | /** |
2697 | * snd_hda_lock_devices - pseudo device locking | ||
2698 | * @bus: the BUS | ||
2699 | * | ||
2648 | * toggle card->shutdown to allow/disallow the device access (as a hack) | 2700 | * toggle card->shutdown to allow/disallow the device access (as a hack) |
2649 | */ | 2701 | */ |
2650 | int snd_hda_lock_devices(struct hda_bus *bus) | 2702 | int snd_hda_lock_devices(struct hda_bus *bus) |
@@ -2681,6 +2733,10 @@ int snd_hda_lock_devices(struct hda_bus *bus) | |||
2681 | } | 2733 | } |
2682 | EXPORT_SYMBOL_GPL(snd_hda_lock_devices); | 2734 | EXPORT_SYMBOL_GPL(snd_hda_lock_devices); |
2683 | 2735 | ||
2736 | /** | ||
2737 | * snd_hda_unlock_devices - pseudo device unlocking | ||
2738 | * @bus: the BUS | ||
2739 | */ | ||
2684 | void snd_hda_unlock_devices(struct hda_bus *bus) | 2740 | void snd_hda_unlock_devices(struct hda_bus *bus) |
2685 | { | 2741 | { |
2686 | struct snd_card *card = bus->card; | 2742 | struct snd_card *card = bus->card; |
@@ -2867,7 +2923,7 @@ static int add_slave(struct hda_codec *codec, | |||
2867 | } | 2923 | } |
2868 | 2924 | ||
2869 | /** | 2925 | /** |
2870 | * snd_hda_add_vmaster - create a virtual master control and add slaves | 2926 | * __snd_hda_add_vmaster - create a virtual master control and add slaves |
2871 | * @codec: HD-audio codec | 2927 | * @codec: HD-audio codec |
2872 | * @name: vmaster control name | 2928 | * @name: vmaster control name |
2873 | * @tlv: TLV data (optional) | 2929 | * @tlv: TLV data (optional) |
@@ -2970,10 +3026,15 @@ static struct snd_kcontrol_new vmaster_mute_mode = { | |||
2970 | .put = vmaster_mute_mode_put, | 3026 | .put = vmaster_mute_mode_put, |
2971 | }; | 3027 | }; |
2972 | 3028 | ||
2973 | /* | 3029 | /** |
2974 | * Add a mute-LED hook with the given vmaster switch kctl | 3030 | * snd_hda_add_vmaster_hook - Add a vmaster hook for mute-LED |
2975 | * "Mute-LED Mode" control is automatically created and associated with | 3031 | * @codec: the HDA codec |
2976 | * the given hook. | 3032 | * @hook: the vmaster hook object |
3033 | * @expose_enum_ctl: flag to create an enum ctl | ||
3034 | * | ||
3035 | * Add a mute-LED hook with the given vmaster switch kctl. | ||
3036 | * When @expose_enum_ctl is set, "Mute-LED Mode" control is automatically | ||
3037 | * created and associated with the given hook. | ||
2977 | */ | 3038 | */ |
2978 | int snd_hda_add_vmaster_hook(struct hda_codec *codec, | 3039 | int snd_hda_add_vmaster_hook(struct hda_codec *codec, |
2979 | struct hda_vmaster_mute_hook *hook, | 3040 | struct hda_vmaster_mute_hook *hook, |
@@ -2995,9 +3056,12 @@ int snd_hda_add_vmaster_hook(struct hda_codec *codec, | |||
2995 | } | 3056 | } |
2996 | EXPORT_SYMBOL_GPL(snd_hda_add_vmaster_hook); | 3057 | EXPORT_SYMBOL_GPL(snd_hda_add_vmaster_hook); |
2997 | 3058 | ||
2998 | /* | 3059 | /** |
2999 | * Call the hook with the current value for synchronization | 3060 | * snd_hda_sync_vmaster_hook - Sync vmaster hook |
3000 | * Should be called in init callback | 3061 | * @hook: the vmaster hook |
3062 | * | ||
3063 | * Call the hook with the current value for synchronization. | ||
3064 | * Should be called in init callback. | ||
3001 | */ | 3065 | */ |
3002 | void snd_hda_sync_vmaster_hook(struct hda_vmaster_mute_hook *hook) | 3066 | void snd_hda_sync_vmaster_hook(struct hda_vmaster_mute_hook *hook) |
3003 | { | 3067 | { |
@@ -3599,7 +3663,11 @@ int snd_hda_create_dig_out_ctls(struct hda_codec *codec, | |||
3599 | } | 3663 | } |
3600 | EXPORT_SYMBOL_GPL(snd_hda_create_dig_out_ctls); | 3664 | EXPORT_SYMBOL_GPL(snd_hda_create_dig_out_ctls); |
3601 | 3665 | ||
3602 | /* get the hda_spdif_out entry from the given NID | 3666 | /** |
3667 | * snd_hda_spdif_out_of_nid - get the hda_spdif_out entry from the given NID | ||
3668 | * @codec: the HDA codec | ||
3669 | * @nid: widget NID | ||
3670 | * | ||
3603 | * call within spdif_mutex lock | 3671 | * call within spdif_mutex lock |
3604 | */ | 3672 | */ |
3605 | struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec, | 3673 | struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec, |
@@ -3616,6 +3684,13 @@ struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec, | |||
3616 | } | 3684 | } |
3617 | EXPORT_SYMBOL_GPL(snd_hda_spdif_out_of_nid); | 3685 | EXPORT_SYMBOL_GPL(snd_hda_spdif_out_of_nid); |
3618 | 3686 | ||
3687 | /** | ||
3688 | * snd_hda_spdif_ctls_unassign - Unassign the given SPDIF ctl | ||
3689 | * @codec: the HDA codec | ||
3690 | * @idx: the SPDIF ctl index | ||
3691 | * | ||
3692 | * Unassign the widget from the given SPDIF control. | ||
3693 | */ | ||
3619 | void snd_hda_spdif_ctls_unassign(struct hda_codec *codec, int idx) | 3694 | void snd_hda_spdif_ctls_unassign(struct hda_codec *codec, int idx) |
3620 | { | 3695 | { |
3621 | struct hda_spdif_out *spdif; | 3696 | struct hda_spdif_out *spdif; |
@@ -3627,6 +3702,14 @@ void snd_hda_spdif_ctls_unassign(struct hda_codec *codec, int idx) | |||
3627 | } | 3702 | } |
3628 | EXPORT_SYMBOL_GPL(snd_hda_spdif_ctls_unassign); | 3703 | EXPORT_SYMBOL_GPL(snd_hda_spdif_ctls_unassign); |
3629 | 3704 | ||
3705 | /** | ||
3706 | * snd_hda_spdif_ctls_assign - Assign the SPDIF controls to the given NID | ||
3707 | * @codec: the HDA codec | ||
3708 | * @idx: the SPDIF ctl idx | ||
3709 | * @nid: widget NID | ||
3710 | * | ||
3711 | * Assign the widget to the SPDIF control with the given index. | ||
3712 | */ | ||
3630 | void snd_hda_spdif_ctls_assign(struct hda_codec *codec, int idx, hda_nid_t nid) | 3713 | void snd_hda_spdif_ctls_assign(struct hda_codec *codec, int idx, hda_nid_t nid) |
3631 | { | 3714 | { |
3632 | struct hda_spdif_out *spdif; | 3715 | struct hda_spdif_out *spdif; |
@@ -3946,6 +4029,16 @@ void snd_hda_codec_flush_cache(struct hda_codec *codec) | |||
3946 | } | 4029 | } |
3947 | EXPORT_SYMBOL_GPL(snd_hda_codec_flush_cache); | 4030 | EXPORT_SYMBOL_GPL(snd_hda_codec_flush_cache); |
3948 | 4031 | ||
4032 | /** | ||
4033 | * snd_hda_codec_set_power_to_all - Set the power state to all widgets | ||
4034 | * @codec: the HDA codec | ||
4035 | * @fg: function group (not used now) | ||
4036 | * @power_state: the power state to set (AC_PWRST_*) | ||
4037 | * | ||
4038 | * Set the given power state to all widgets that have the power control. | ||
4039 | * If the codec has power_filter set, it evaluates the power state and | ||
4040 | * filter out if it's unchanged as D3. | ||
4041 | */ | ||
3949 | void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg, | 4042 | void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg, |
3950 | unsigned int power_state) | 4043 | unsigned int power_state) |
3951 | { | 4044 | { |
@@ -4010,7 +4103,15 @@ static unsigned int hda_sync_power_state(struct hda_codec *codec, | |||
4010 | return state; | 4103 | return state; |
4011 | } | 4104 | } |
4012 | 4105 | ||
4013 | /* don't power down the widget if it controls eapd and EAPD_BTLENABLE is set */ | 4106 | /** |
4107 | * snd_hda_codec_eapd_power_filter - A power filter callback for EAPD | ||
4108 | * @codec: the HDA codec | ||
4109 | * @nid: widget NID | ||
4110 | * @power_state: power state to evalue | ||
4111 | * | ||
4112 | * Don't power down the widget if it controls eapd and EAPD_BTLENABLE is set. | ||
4113 | * This can be used a codec power_filter callback. | ||
4114 | */ | ||
4014 | unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec, | 4115 | unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec, |
4015 | hda_nid_t nid, | 4116 | hda_nid_t nid, |
4016 | unsigned int power_state) | 4117 | unsigned int power_state) |
@@ -4671,6 +4772,17 @@ static int set_pcm_default_values(struct hda_codec *codec, | |||
4671 | /* | 4772 | /* |
4672 | * codec prepare/cleanup entries | 4773 | * codec prepare/cleanup entries |
4673 | */ | 4774 | */ |
4775 | /** | ||
4776 | * snd_hda_codec_prepare - Prepare a stream | ||
4777 | * @codec: the HDA codec | ||
4778 | * @hinfo: PCM information | ||
4779 | * @stream: stream tag to assign | ||
4780 | * @format: format id to assign | ||
4781 | * @substream: PCM substream to assign | ||
4782 | * | ||
4783 | * Calls the prepare callback set by the codec with the given arguments. | ||
4784 | * Clean up the inactive streams when successful. | ||
4785 | */ | ||
4674 | int snd_hda_codec_prepare(struct hda_codec *codec, | 4786 | int snd_hda_codec_prepare(struct hda_codec *codec, |
4675 | struct hda_pcm_stream *hinfo, | 4787 | struct hda_pcm_stream *hinfo, |
4676 | unsigned int stream, | 4788 | unsigned int stream, |
@@ -4687,6 +4799,14 @@ int snd_hda_codec_prepare(struct hda_codec *codec, | |||
4687 | } | 4799 | } |
4688 | EXPORT_SYMBOL_GPL(snd_hda_codec_prepare); | 4800 | EXPORT_SYMBOL_GPL(snd_hda_codec_prepare); |
4689 | 4801 | ||
4802 | /** | ||
4803 | * snd_hda_codec_cleanup - Prepare a stream | ||
4804 | * @codec: the HDA codec | ||
4805 | * @hinfo: PCM information | ||
4806 | * @substream: PCM substream | ||
4807 | * | ||
4808 | * Calls the cleanup callback set by the codec with the given arguments. | ||
4809 | */ | ||
4690 | void snd_hda_codec_cleanup(struct hda_codec *codec, | 4810 | void snd_hda_codec_cleanup(struct hda_codec *codec, |
4691 | struct hda_pcm_stream *hinfo, | 4811 | struct hda_pcm_stream *hinfo, |
4692 | struct snd_pcm_substream *substream) | 4812 | struct snd_pcm_substream *substream) |