diff options
author | Matthew Ranostay <mranostay@embeddedalley.com> | 2008-10-25 01:05:45 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-10-27 03:15:15 -0400 |
commit | 50a9f7905fb3e6ae25e80ba443a14d878caef0c9 (patch) | |
tree | 03472d8af217599280bfa5c5a4fbf9c6cf5c0bf6 /sound | |
parent | 282cd76ffca781013151344c4b0f9229e9ea3c35 (diff) |
ALSA: hda: add snd_hda_get_jack* functions
This patch adds snd_hda_get_jack* functions for reporting jack location,
device, and connectivity type.
Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 46 | ||||
-rw-r--r-- | sound/pci/hda/hda_codec.h | 7 | ||||
-rw-r--r-- | sound/pci/hda/hda_proc.c | 39 |
3 files changed, 56 insertions, 36 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 9a8adc600a57..eaa8b5676eae 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -107,6 +107,52 @@ static void hda_keep_power_on(struct hda_codec *codec); | |||
107 | static inline void hda_keep_power_on(struct hda_codec *codec) {} | 107 | static inline void hda_keep_power_on(struct hda_codec *codec) {} |
108 | #endif | 108 | #endif |
109 | 109 | ||
110 | const char *snd_hda_get_jack_location(u32 cfg) | ||
111 | { | ||
112 | static char *bases[7] = { | ||
113 | "N/A", "Rear", "Front", "Left", "Right", "Top", "Bottom", | ||
114 | }; | ||
115 | static unsigned char specials_idx[] = { | ||
116 | 0x07, 0x08, | ||
117 | 0x17, 0x18, 0x19, | ||
118 | 0x37, 0x38 | ||
119 | }; | ||
120 | static char *specials[] = { | ||
121 | "Rear Panel", "Drive Bar", | ||
122 | "Riser", "HDMI", "ATAPI", | ||
123 | "Mobile-In", "Mobile-Out" | ||
124 | }; | ||
125 | int i; | ||
126 | cfg = (cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT; | ||
127 | if ((cfg & 0x0f) < 7) | ||
128 | return bases[cfg & 0x0f]; | ||
129 | for (i = 0; i < ARRAY_SIZE(specials_idx); i++) { | ||
130 | if (cfg == specials_idx[i]) | ||
131 | return specials[i]; | ||
132 | } | ||
133 | return "UNKNOWN"; | ||
134 | } | ||
135 | |||
136 | const char *snd_hda_get_jack_connectivity(u32 cfg) | ||
137 | { | ||
138 | static char *jack_locations[4] = { "Ext", "Int", "Sep", "Oth" }; | ||
139 | |||
140 | return jack_locations[(cfg >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3]; | ||
141 | } | ||
142 | |||
143 | const char *snd_hda_get_jack_type(u32 cfg) | ||
144 | { | ||
145 | static char *jack_types[16] = { | ||
146 | "Line Out", "Speaker", "HP Out", "CD", | ||
147 | "SPDIF Out", "Digital Out", "Modem Line", "Modem Hand", | ||
148 | "Line In", "Aux", "Mic", "Telephony", | ||
149 | "SPDIF In", "Digitial In", "Reserved", "Other" | ||
150 | }; | ||
151 | |||
152 | return jack_types[(cfg & AC_DEFCFG_DEVICE) | ||
153 | >> AC_DEFCFG_DEVICE_SHIFT]; | ||
154 | } | ||
155 | |||
110 | /** | 156 | /** |
111 | * snd_hda_codec_read - send a command and get the response | 157 | * snd_hda_codec_read - send a command and get the response |
112 | * @codec: the HDA codec | 158 | * @codec: the HDA codec |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index a77ba223af40..c5f91c918d19 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -860,6 +860,13 @@ int snd_hda_resume(struct hda_bus *bus); | |||
860 | #endif | 860 | #endif |
861 | 861 | ||
862 | /* | 862 | /* |
863 | * get widget information | ||
864 | */ | ||
865 | const char *snd_hda_get_jack_connectivity(u32 cfg); | ||
866 | const char *snd_hda_get_jack_type(u32 cfg); | ||
867 | const char *snd_hda_get_jack_location(u32 cfg); | ||
868 | |||
869 | /* | ||
863 | * power saving | 870 | * power saving |
864 | */ | 871 | */ |
865 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 872 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 64ab19f14f79..b36d4d06485d 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c | |||
@@ -145,32 +145,6 @@ static void print_pcm_caps(struct snd_info_buffer *buffer, | |||
145 | print_pcm_formats(buffer, stream); | 145 | print_pcm_formats(buffer, stream); |
146 | } | 146 | } |
147 | 147 | ||
148 | static const char *get_jack_location(u32 cfg) | ||
149 | { | ||
150 | static char *bases[7] = { | ||
151 | "N/A", "Rear", "Front", "Left", "Right", "Top", "Bottom", | ||
152 | }; | ||
153 | static unsigned char specials_idx[] = { | ||
154 | 0x07, 0x08, | ||
155 | 0x17, 0x18, 0x19, | ||
156 | 0x37, 0x38 | ||
157 | }; | ||
158 | static char *specials[] = { | ||
159 | "Rear Panel", "Drive Bar", | ||
160 | "Riser", "HDMI", "ATAPI", | ||
161 | "Mobile-In", "Mobile-Out" | ||
162 | }; | ||
163 | int i; | ||
164 | cfg = (cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT; | ||
165 | if ((cfg & 0x0f) < 7) | ||
166 | return bases[cfg & 0x0f]; | ||
167 | for (i = 0; i < ARRAY_SIZE(specials_idx); i++) { | ||
168 | if (cfg == specials_idx[i]) | ||
169 | return specials[i]; | ||
170 | } | ||
171 | return "UNKNOWN"; | ||
172 | } | ||
173 | |||
174 | static const char *get_jack_connection(u32 cfg) | 148 | static const char *get_jack_connection(u32 cfg) |
175 | { | 149 | { |
176 | static char *names[16] = { | 150 | static char *names[16] = { |
@@ -206,13 +180,6 @@ static void print_pin_caps(struct snd_info_buffer *buffer, | |||
206 | int *supports_vref) | 180 | int *supports_vref) |
207 | { | 181 | { |
208 | static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" }; | 182 | static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" }; |
209 | static char *jack_types[16] = { | ||
210 | "Line Out", "Speaker", "HP Out", "CD", | ||
211 | "SPDIF Out", "Digital Out", "Modem Line", "Modem Hand", | ||
212 | "Line In", "Aux", "Mic", "Telephony", | ||
213 | "SPDIF In", "Digitial In", "Reserved", "Other" | ||
214 | }; | ||
215 | static char *jack_locations[4] = { "Ext", "Int", "Sep", "Oth" }; | ||
216 | unsigned int caps, val; | 183 | unsigned int caps, val; |
217 | 184 | ||
218 | caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | 185 | caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
@@ -274,9 +241,9 @@ static void print_pin_caps(struct snd_info_buffer *buffer, | |||
274 | caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | 241 | caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); |
275 | snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps, | 242 | snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps, |
276 | jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT], | 243 | jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT], |
277 | jack_types[(caps & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT], | 244 | snd_hda_get_jack_type(caps), |
278 | jack_locations[(caps >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3], | 245 | snd_hda_get_jack_connectivity(caps), |
279 | get_jack_location(caps)); | 246 | snd_hda_get_jack_location(caps)); |
280 | snd_iprintf(buffer, " Conn = %s, Color = %s\n", | 247 | snd_iprintf(buffer, " Conn = %s, Color = %s\n", |
281 | get_jack_connection(caps), | 248 | get_jack_connection(caps), |
282 | get_jack_color(caps)); | 249 | get_jack_color(caps)); |