diff options
author | Misael Lopez Cruz | 2013-05-02 17:45:54 -0500 |
---|---|---|
committer | Gerrit Code Review | 2013-05-07 09:11:59 -0500 |
commit | 8d2029a8e93e7182f15576453d90bbde3d1184f1 (patch) | |
tree | 71570cb6bba51dcb659185ecb6864033022a46a5 | |
parent | 159888db12a922d6374e76d6ca4a9f3267c0b98e (diff) | |
download | device-ti-common-open-8d2029a8e93e7182f15576453d90bbde3d1184f1.tar.gz device-ti-common-open-8d2029a8e93e7182f15576453d90bbde3d1184f1.tar.xz device-ti-common-open-8d2029a8e93e7182f15576453d90bbde3d1184f1.zip |
audio: hdmi: Detect card number dynamically
Detect HDMI sound card dynamically based on the card name.
If the name contains "hdmi" then it's picked. Previously it
assumed the HDMI was always the card 1.
Change-Id: Ic9d84e3ed47dab9851c9989f25f1abc80f30e016
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
-rw-r--r-- | audio/hdmi_audio_hw.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/audio/hdmi_audio_hw.c b/audio/hdmi_audio_hw.c index cd44aec..18b9f6f 100644 --- a/audio/hdmi_audio_hw.c +++ b/audio/hdmi_audio_hw.c | |||
@@ -297,12 +297,28 @@ int hdmi_out_set_volume(struct audio_stream_out *stream, float left, float right | |||
297 | 297 | ||
298 | static int hdmi_out_find_card(void) | 298 | static int hdmi_out_find_card(void) |
299 | { | 299 | { |
300 | /* XXX TODO: Dynamically detect HDMI card | 300 | char name[256] = ""; |
301 | * If another audio device is present at boot time (e.g. | 301 | int card = 0; |
302 | * USB Audio device) then it might take the card #1 | 302 | int found = 0; |
303 | * position, putting HDMI on card #2. | 303 | |
304 | */ | 304 | do { |
305 | return 1; | 305 | /* return an error after last valid card */ |
306 | int ret = mixer_get_card_name(card, name, sizeof(name)); | ||
307 | if (ret) | ||
308 | break; | ||
309 | |||
310 | if (strstr(name, "HDMI") || strstr(name, "hdmi")) { | ||
311 | TRACEM("HDMI card '%s' found at %d", name, card); | ||
312 | found = 1; | ||
313 | break; | ||
314 | } | ||
315 | } while (card++ < MAX_CARD_COUNT); | ||
316 | |||
317 | /* Use default card number if not found */ | ||
318 | if (!found) | ||
319 | card = 1; | ||
320 | |||
321 | return card; | ||
306 | } | 322 | } |
307 | 323 | ||
308 | static int hdmi_out_open_pcm(hdmi_out_t *out) | 324 | static int hdmi_out_open_pcm(hdmi_out_t *out) |