summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMisael Lopez Cruz <misael.lopez@ti.com>2017-09-13 01:01:56 -0500
committerVishal Mahaveer <vishalm@ti.com>2017-09-13 14:51:33 -0500
commit412b2b3bc900ca08670de7a39140bdc6d8f3ce58 (patch)
tree94883eb91cf552a20bf48453f5aa1178aabf93d6
parentf5fc870952e03d2859a013a85295bfcb432e8f1e (diff)
downloadjacinto6evm-412b2b3bc900ca08670de7a39140bdc6d8f3ce58.tar.gz
audio: Get card name via mixer_get_name()
The card index detection mechanism used in the audio HALs was based on a customized function which isn't part of the tinyalsa library. tinyalsa provides the mixer_get_name() function which also returns the card name. The audio HALs now make the card index detection based on this function and no longer rely on a customized tinyalsa library. Change-Id: I10b52df27ad1d4937bfa59a4b2f1b777701c70c0 Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
-rw-r--r--audio/hdmi/hdmi_audio_hw.c25
-rw-r--r--audio/jamr3/jamr3_audio_hw.c19
-rw-r--r--audio/primary/audio_hw.c21
3 files changed, 37 insertions, 28 deletions
diff --git a/audio/hdmi/hdmi_audio_hw.c b/audio/hdmi/hdmi_audio_hw.c
index 768b414..11803bb 100644
--- a/audio/hdmi/hdmi_audio_hw.c
+++ b/audio/hdmi/hdmi_audio_hw.c
@@ -51,11 +51,7 @@
#define UNUSED(x) (void)(x)
-/* XXX TODO: Dynamically detect the HDMI card
- * E.g. if a USB device is plugged in at boot time,
- * it sometimes takes the card #1 slot and puts us
- * on card #2.
- */
+#define MAX_CARD_COUNT 10
#define HDMI_PCM_DEV 0
#define HDMI_SAMPLING_RATE 44100
#define HDMI_PERIOD_SIZE 1920
@@ -323,24 +319,27 @@ int hdmi_out_set_volume(struct audio_stream_out *stream, float left, float right
static int hdmi_out_find_card(void)
{
- char name[256] = "";
+ struct mixer *mixer;
+ const char *name;
int card = 0;
int found = 0;
+ int i;
-#ifdef OMAP_ENHANCEMENT
do {
- /* return an error after last valid card */
- int ret = mixer_get_card_name(card, name, sizeof(name));
- if (ret)
+ /* returns an error after last valid card */
+ mixer = mixer_open(card);
+ if (!mixer)
break;
+ name = mixer_get_name(mixer);
+
if (strstr(name, "HDMI") || strstr(name, "hdmi")) {
TRACEM("HDMI card '%s' found at %d", name, card);
found = 1;
- break;
}
- } while (card++ < MAX_CARD_COUNT);
-#endif
+
+ mixer_close(mixer);
+ } while (!found && (card++ < MAX_CARD_COUNT));
/* Use default card number if not found */
if (!found)
diff --git a/audio/jamr3/jamr3_audio_hw.c b/audio/jamr3/jamr3_audio_hw.c
index cf2772f..7dd8c2c 100644
--- a/audio/jamr3/jamr3_audio_hw.c
+++ b/audio/jamr3/jamr3_audio_hw.c
@@ -95,9 +95,11 @@ struct j6_stream_in {
};
static const char *supported_cards[] = {
- "DRA7xxJAMR3",
+ "DRA7xx-JAMR3",
};
+#define MAX_CARD_COUNT 10
+
#define SUPPORTED_IN_DEVICES AUDIO_DEVICE_IN_LINE
#define CAPTURE_SAMPLE_RATE 44100
@@ -119,18 +121,20 @@ struct pcm_config pcm_config_capture = {
static int find_card_index(const char *supported_cards[], int num_supported)
{
- char name[256] = "";
+ struct mixer *mixer;
+ const char *name;
int card = 0;
int found = 0;
int i;
-#ifdef OMAP_ENHANCEMENT
do {
/* returns an error after last valid card */
- int ret = mixer_get_card_name(card, name, sizeof(name));
- if (ret)
+ mixer = mixer_open(card);
+ if (!mixer)
break;
+ name = mixer_get_name(mixer);
+
for (i = 0; i < num_supported; ++i) {
if (supported_cards[i] && !strcmp(name, supported_cards[i])) {
ALOGV("Supported card '%s' found at %d", name, card);
@@ -138,12 +142,13 @@ static int find_card_index(const char *supported_cards[], int num_supported)
break;
}
}
+
+ mixer_close(mixer);
} while (!found && (card++ < MAX_CARD_COUNT));
-#endif
/* Use default card number if not found */
if (!found)
- card = 0;
+ card = 2;
return card;
}
diff --git a/audio/primary/audio_hw.c b/audio/primary/audio_hw.c
index a0cdc5e..6e09047 100644
--- a/audio/primary/audio_hw.c
+++ b/audio/primary/audio_hw.c
@@ -140,13 +140,15 @@ struct j6_stream_out {
static const char *supported_media_cards[] = {
"dra7evm",
"VayuEVM",
- "DRA7xxEVM",
+ "DRA7xx-EVM",
};
static const char *supported_bt_cards[] = {
"DRA7xxWiLink",
};
+#define MAX_CARD_COUNT 10
+
#define SUPPORTED_IN_DEVICES (AUDIO_DEVICE_IN_BUILTIN_MIC | \
AUDIO_DEVICE_IN_WIRED_HEADSET | \
AUDIO_DEVICE_IN_DEFAULT)
@@ -209,18 +211,20 @@ struct pcm_config pcm_config_bt_out = {
static int find_card_index(const char *supported_cards[], int num_supported)
{
- char name[256] = "";
+ struct mixer *mixer;
+ const char *name;
int card = 0;
int found = 0;
int i;
-#ifdef OMAP_ENHANCEMENT
do {
/* returns an error after last valid card */
- int ret = mixer_get_card_name(card, name, sizeof(name));
- if (ret)
+ mixer = mixer_open(card);
+ if (!mixer)
break;
+ name = mixer_get_name(mixer);
+
for (i = 0; i < num_supported; ++i) {
if (supported_cards[i] && !strcmp(name, supported_cards[i])) {
ALOGV("Supported card '%s' found at %d", name, card);
@@ -228,8 +232,9 @@ static int find_card_index(const char *supported_cards[], int num_supported)
break;
}
}
+
+ mixer_close(mixer);
} while (!found && (card++ < MAX_CARD_COUNT));
-#endif
/* Use default card number if not found */
if (!found)
@@ -1243,8 +1248,8 @@ static ssize_t read_frames(struct j6_stream_in *in, void *buffer, ssize_t frames
&frames_rd);
} else {
struct resampler_buffer buf = {
- { raw : NULL, },
- frame_count : frames_rd,
+ { .raw = NULL, },
+ .frame_count = frames_rd,
};
get_next_buffer(&in->buf_provider, &buf);
if (buf.raw) {