summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisael Lopez Cruz2017-09-19 16:30:58 -0500
committerPraneeth Bajjuri2017-09-19 16:45:28 -0500
commit1ec5d1ec3591503d8697615c7453a3e76854e493 (patch)
tree78f3b19419185b2483e7d59b9526da46476e7fff
parentbec1541eec254c48d4fa70d3adaaf46b92457a0d (diff)
downloaddevice-ti-am57xevm-1ec5d1ec3591503d8697615c7453a3e76854e493.tar.gz
device-ti-am57xevm-1ec5d1ec3591503d8697615c7453a3e76854e493.tar.xz
device-ti-am57xevm-1ec5d1ec3591503d8697615c7453a3e76854e493.zip
am57xevm: sync audio from jacinto6evm project
sync hdmi and audio changes from jacinto6evm device project. this patch is combination of audio: Move HALs and policy files to vendor partition Move the audio policy configuration file and the J6 audio HALs (primary and HDMI) to the 'vendor' partition. --- 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. Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com> [synced from jacinto6evm but not jamr3] Signed-off-by: Praneeth Bajjuri <praneeth@ti.com> Change-Id: Ie1f04cc8d636b4828e265ff6e8d5de0ee7063bab
-rw-r--r--audio/hdmi/Android.mk2
-rw-r--r--audio/hdmi/hdmi_audio_hw.c40
-rw-r--r--audio/primary/Android.mk2
-rw-r--r--audio/primary/audio_hw.c53
-rw-r--r--device.mk4
5 files changed, 84 insertions, 17 deletions
diff --git a/audio/hdmi/Android.mk b/audio/hdmi/Android.mk
index 976f84b..9376f95 100644
--- a/audio/hdmi/Android.mk
+++ b/audio/hdmi/Android.mk
@@ -20,7 +20,7 @@ include $(CLEAR_VARS)
20 20
21LOCAL_MODULE := audio.hdmi.$(TARGET_BOARD_PLATFORM) 21LOCAL_MODULE := audio.hdmi.$(TARGET_BOARD_PLATFORM)
22 22
23LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 23LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/hw
24LOCAL_SRC_FILES := hdmi_audio_hw.c \ 24LOCAL_SRC_FILES := hdmi_audio_hw.c \
25 hdmi_audio_utils.c 25 hdmi_audio_utils.c
26 26
diff --git a/audio/hdmi/hdmi_audio_hw.c b/audio/hdmi/hdmi_audio_hw.c
index 1f5c520..11803bb 100644
--- a/audio/hdmi/hdmi_audio_hw.c
+++ b/audio/hdmi/hdmi_audio_hw.c
@@ -51,12 +51,7 @@
51 51
52#define UNUSED(x) (void)(x) 52#define UNUSED(x) (void)(x)
53 53
54/* XXX TODO: Dynamically detect the HDMI card 54#define MAX_CARD_COUNT 10
55 * E.g. if a USB device is plugged in at boot time,
56 * it sometimes takes the card #1 slot and puts us
57 * on card #2.
58 */
59#define HDMI_PCM_CARD 1
60#define HDMI_PCM_DEV 0 55#define HDMI_PCM_DEV 0
61#define HDMI_SAMPLING_RATE 44100 56#define HDMI_SAMPLING_RATE 44100
62#define HDMI_PERIOD_SIZE 1920 57#define HDMI_PERIOD_SIZE 1920
@@ -322,9 +317,40 @@ int hdmi_out_set_volume(struct audio_stream_out *stream, float left, float right
322 return -ENOSYS; 317 return -ENOSYS;
323} 318}
324 319
320static int hdmi_out_find_card(void)
321{
322 struct mixer *mixer;
323 const char *name;
324 int card = 0;
325 int found = 0;
326 int i;
327
328 do {
329 /* returns an error after last valid card */
330 mixer = mixer_open(card);
331 if (!mixer)
332 break;
333
334 name = mixer_get_name(mixer);
335
336 if (strstr(name, "HDMI") || strstr(name, "hdmi")) {
337 TRACEM("HDMI card '%s' found at %d", name, card);
338 found = 1;
339 }
340
341 mixer_close(mixer);
342 } while (!found && (card++ < MAX_CARD_COUNT));
343
344 /* Use default card number if not found */
345 if (!found)
346 card = 1;
347
348 return card;
349}
350
325static int hdmi_out_open_pcm(hdmi_out_t *out) 351static int hdmi_out_open_pcm(hdmi_out_t *out)
326{ 352{
327 int card = HDMI_PCM_CARD; 353 int card = hdmi_out_find_card();
328 int dev = HDMI_PCM_DEV; 354 int dev = HDMI_PCM_DEV;
329 int ret; 355 int ret;
330 356
diff --git a/audio/primary/Android.mk b/audio/primary/Android.mk
index 40f60da..50ed668 100644
--- a/audio/primary/Android.mk
+++ b/audio/primary/Android.mk
@@ -20,7 +20,7 @@ include $(CLEAR_VARS)
20 20
21LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM) 21LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM)
22 22
23LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 23LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/hw
24LOCAL_SRC_FILES := audio_hw.c 24LOCAL_SRC_FILES := audio_hw.c
25 25
26LOCAL_C_INCLUDES += \ 26LOCAL_C_INCLUDES += \
diff --git a/audio/primary/audio_hw.c b/audio/primary/audio_hw.c
index 95f0f06..0ae1f54 100644
--- a/audio/primary/audio_hw.c
+++ b/audio/primary/audio_hw.c
@@ -140,13 +140,15 @@ struct j6_stream_out {
140static const char *supported_media_cards[] = { 140static const char *supported_media_cards[] = {
141 "dra7evm", 141 "dra7evm",
142 "VayuEVM", 142 "VayuEVM",
143 "DRA7xxEVM", 143 "DRA7xx-EVM",
144}; 144};
145 145
146static const char *supported_bt_cards[] = { 146static const char *supported_bt_cards[] = {
147 "DRA7xxWiLink", 147 "DRA7xxWiLink",
148}; 148};
149 149
150#define MAX_CARD_COUNT 10
151
150#define SUPPORTED_IN_DEVICES (AUDIO_DEVICE_IN_BUILTIN_MIC | \ 152#define SUPPORTED_IN_DEVICES (AUDIO_DEVICE_IN_BUILTIN_MIC | \
151 AUDIO_DEVICE_IN_WIRED_HEADSET | \ 153 AUDIO_DEVICE_IN_WIRED_HEADSET | \
152 AUDIO_DEVICE_IN_DEFAULT) 154 AUDIO_DEVICE_IN_DEFAULT)
@@ -170,6 +172,8 @@ static const char *supported_bt_cards[] = {
170#define BT_PERIOD_COUNT 4 172#define BT_PERIOD_COUNT 4
171#define BT_BUFFER_SIZE (BT_PERIOD_SIZE * BT_PERIOD_COUNT) 173#define BT_BUFFER_SIZE (BT_PERIOD_SIZE * BT_PERIOD_COUNT)
172 174
175#define MIXER_XML_PATH "/vendor/etc/mixer_paths.xml"
176
173struct pcm_config pcm_config_capture = { 177struct pcm_config pcm_config_capture = {
174 .channels = 2, 178 .channels = 2,
175 .rate = CAPTURE_SAMPLE_RATE, 179 .rate = CAPTURE_SAMPLE_RATE,
@@ -207,6 +211,40 @@ struct pcm_config pcm_config_bt_out = {
207 .period_count = BT_PERIOD_COUNT, 211 .period_count = BT_PERIOD_COUNT,
208}; 212};
209 213
214static int find_card_index(const char *supported_cards[], int num_supported)
215{
216 struct mixer *mixer;
217 const char *name;
218 int card = 0;
219 int found = 0;
220 int i;
221
222 do {
223 /* returns an error after last valid card */
224 mixer = mixer_open(card);
225 if (!mixer)
226 break;
227
228 name = mixer_get_name(mixer);
229
230 for (i = 0; i < num_supported; ++i) {
231 if (supported_cards[i] && !strcmp(name, supported_cards[i])) {
232 ALOGV("Supported card '%s' found at %d", name, card);
233 found = 1;
234 break;
235 }
236 }
237
238 mixer_close(mixer);
239 } while (!found && (card++ < MAX_CARD_COUNT));
240
241 /* Use default card number if not found */
242 if (!found)
243 card = 0;
244
245 return card;
246}
247
210static void do_out_standby(struct j6_stream_out *out); 248static void do_out_standby(struct j6_stream_out *out);
211 249
212/* must be called with device lock held */ 250/* must be called with device lock held */
@@ -1212,8 +1250,8 @@ static ssize_t read_frames(struct j6_stream_in *in, void *buffer, ssize_t frames
1212 &frames_rd); 1250 &frames_rd);
1213 } else { 1251 } else {
1214 struct resampler_buffer buf = { 1252 struct resampler_buffer buf = {
1215 { raw : NULL, }, 1253 { .raw = NULL, },
1216 frame_count : frames_rd, 1254 .frame_count = frames_rd,
1217 }; 1255 };
1218 get_next_buffer(&in->buf_provider, &buf); 1256 get_next_buffer(&in->buf_provider, &buf);
1219 if (buf.raw) { 1257 if (buf.raw) {
@@ -1729,11 +1767,14 @@ static int adev_open(const hw_module_t* module, const char* name,
1729 1767
1730 adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC; 1768 adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC;
1731 adev->out_device = AUDIO_DEVICE_OUT_SPEAKER; 1769 adev->out_device = AUDIO_DEVICE_OUT_SPEAKER;
1732 adev->card = 0; 1770 adev->card = find_card_index(supported_media_cards,
1771 ARRAY_SIZE(supported_media_cards));
1733 adev->in_port = 0; 1772 adev->in_port = 0;
1734 adev->out_port = 0; 1773 adev->out_port = 0;
1735 ALOGI("Media card is hw:%d\n", adev->card); 1774 ALOGI("Media card is hw:%d\n", adev->card);
1736 adev->bt_card=2; 1775
1776 adev->bt_card = find_card_index(supported_bt_cards,
1777 ARRAY_SIZE(supported_bt_cards));
1737 adev->bt_port = 0; 1778 adev->bt_port = 0;
1738 ALOGI("Bluetooth SCO card is hw:%d\n", adev->bt_card); 1779 ALOGI("Bluetooth SCO card is hw:%d\n", adev->bt_card);
1739 1780
@@ -1741,7 +1782,7 @@ static int adev_open(const hw_module_t* module, const char* name,
1741 adev->in_call = false; 1782 adev->in_call = false;
1742 adev->mode = AUDIO_MODE_NORMAL; 1783 adev->mode = AUDIO_MODE_NORMAL;
1743 1784
1744 adev->route = audio_route_init(adev->card, NULL); 1785 adev->route = audio_route_init(adev->card, MIXER_XML_PATH);
1745 if (!adev->route) { 1786 if (!adev->route) {
1746 ALOGE("Unable to initialize audio routes"); 1787 ALOGE("Unable to initialize audio routes");
1747 free(adev); 1788 free(adev);
diff --git a/device.mk b/device.mk
index e7d5db7..95ef2af 100644
--- a/device.mk
+++ b/device.mk
@@ -62,8 +62,8 @@ PRODUCT_COPY_FILES += \
62 62
63# Audio 63# Audio
64PRODUCT_COPY_FILES += \ 64PRODUCT_COPY_FILES += \
65 device/ti/am57xevm/audio/primary/mixer_paths.xml:system/etc/mixer_paths.xml \ 65 device/ti/am57xevm/audio/primary/mixer_paths.xml:vendor/etc/mixer_paths.xml \
66 device/ti/am57xevm/audio/audio_policy.conf:system/etc/audio_policy.conf 66 device/ti/am57xevm/audio/audio_policy.conf:vendor/etc/audio_policy.conf
67 67
68# cpuset configuration 68# cpuset configuration
69PRODUCT_COPY_FILES += \ 69PRODUCT_COPY_FILES += \