Merge "hal: set stream channel map for noirq mode."
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 9993c33..523cdc9 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3083,6 +3083,10 @@
}
}
+ if (out->realtime)
+ platform_set_stream_channel_map(adev->platform, out->channel_mask,
+ out->pcm_device_id, &out->channel_map_param.channel_map[0]);
+
while (1) {
ATRACE_BEGIN("pcm_open");
out->pcm = pcm_open(adev->snd_card, out->pcm_device_id,
@@ -3111,7 +3115,8 @@
}
break;
}
- platform_set_stream_channel_map(adev->platform, out->channel_mask,
+ if (!out->realtime)
+ platform_set_stream_channel_map(adev->platform, out->channel_mask,
out->pcm_device_id, &out->channel_map_param.channel_map[0]);
ALOGV("%s: pcm_prepare", __func__);
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 13b936f..e6af9e0 100755
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -163,6 +163,7 @@
/* Query external audio device connection status */
#define AUDIO_PARAMETER_KEY_EXT_AUDIO_DEVICE "ext_audio_device"
+#define AUDIO_PARAMETER_KEY_SPKR_DEVICE_CHMAP "spkr_device_chmap"
#define EVENT_EXTERNAL_SPK_1 "qc_ext_spk_1"
#define EVENT_EXTERNAL_SPK_2 "qc_ext_spk_2"
#define EVENT_EXTERNAL_MIC "qc_ext_mic"
@@ -307,6 +308,12 @@
bool is_asrc_supported;
struct listnode acdb_meta_key_list;
bool use_generic_handset;
+ struct spkr_device_chmap *spkr_ch_map;
+};
+
+struct spkr_device_chmap {
+ int num_ch;
+ char chmap[AUDIO_CHANNEL_COUNT_MAX];
};
static bool is_external_codec = false;
@@ -2281,6 +2288,7 @@
my_data->is_wsa_speaker = false;
my_data->hw_dep_fd = -1;
my_data->mono_speaker = SPKR_1;
+ my_data->spkr_ch_map = NULL;
be_dai_name_table = NULL;
@@ -2789,6 +2797,11 @@
my_data->adev->mixer = NULL;
}
+ if (my_data->spkr_ch_map) {
+ free(my_data->spkr_ch_map);
+ my_data->spkr_ch_map = NULL;
+ }
+
int32_t idx;
for (idx = 0; idx < MAX_CODEC_BACKENDS; idx++) {
@@ -5050,6 +5063,46 @@
if(dptr != NULL)
free(dptr);
}
+static void platform_spkr_device_set_params(struct platform_data *platform,
+ struct str_parms *parms,
+ char *value, int len)
+{
+ int err = 0, i = 0, num_ch = 0;
+ char *test_r = NULL;
+ char *opts = NULL;
+ char *ch_count = NULL;
+
+ err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SPKR_DEVICE_CHMAP,
+ value, len);
+ if (err >= 0) {
+ platform->spkr_ch_map = calloc(1, sizeof(struct spkr_device_chmap));
+ if (!platform->spkr_ch_map) {
+ ALOGE("%s: failed to allocate mem for adm channel map\n", __func__);
+ str_parms_del(parms, AUDIO_PARAMETER_KEY_SPKR_DEVICE_CHMAP);
+ return ;
+ }
+
+ ch_count = strtok_r(value, ", ", &test_r);
+ if (ch_count == NULL) {
+ ALOGE("%s: incorrect ch_map\n", __func__);
+ free(platform->spkr_ch_map);
+ platform->spkr_ch_map = NULL;
+ str_parms_del(parms, AUDIO_PARAMETER_KEY_SPKR_DEVICE_CHMAP);
+ return;
+ }
+
+ num_ch = atoi(ch_count);
+ if ((num_ch > 0) && (num_ch <= AUDIO_CHANNEL_COUNT_MAX) ) {
+ platform->spkr_ch_map->num_ch = num_ch;
+ for (i = 0; i < num_ch; i++) {
+ opts = strtok_r(NULL, ", ", &test_r);
+ platform->spkr_ch_map->chmap[i] = strtoul(opts, NULL, 16);
+ }
+ }
+ str_parms_del(parms, AUDIO_PARAMETER_KEY_SPKR_DEVICE_CHMAP);
+ }
+}
+
int platform_set_parameters(void *platform, struct str_parms *parms)
{
struct platform_data *my_data = (struct platform_data *)platform;
@@ -5174,6 +5227,7 @@
audio_extn_hfp_set_parameters(my_data->adev, parms);
true_32_bit_set_params(parms, value, len);
audio_extn_ffv_set_parameters(my_data->adev, parms);
+ platform_spkr_device_set_params(platform, parms, value, len);
ALOGV("%s: exit with code(%d)", __func__, ret);
return ret;
}
@@ -6346,6 +6400,7 @@
int i, num_devices = 1;
struct audio_backend_cfg backend_cfg;
bool ret = false;
+ struct platform_data *my_data = (struct platform_data *)adev->platform;
backend_idx = platform_get_backend_index(snd_device);
@@ -6385,6 +6440,11 @@
backend_cfg.sample_rate, backend_cfg.channels, backend_idx, usecase->id,
platform_get_snd_device_name(snd_device));
+ if ((my_data->spkr_ch_map != NULL) &&
+ (platform_get_backend_index(snd_device) == DEFAULT_CODEC_BACKEND))
+ platform_set_channel_map(my_data, my_data->spkr_ch_map->num_ch,
+ my_data->spkr_ch_map->chmap, -1);
+
if (platform_split_snd_device(adev->platform, snd_device,
&num_devices, new_snd_devices) < 0)
new_snd_devices[0] = snd_device;
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 7c950e5..d92b9d4 100755
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -140,6 +140,7 @@
* device for voice usecase
*/
#define AUDIO_PARAMETER_KEY_DP_FOR_VOICE_USECASE "dp_for_voice"
+#define AUDIO_PARAMETER_KEY_SPKR_DEVICE_CHMAP "spkr_device_chmap"
#define EVENT_EXTERNAL_SPK_1 "qc_ext_spk_1"
#define EVENT_EXTERNAL_SPK_2 "qc_ext_spk_2"
@@ -283,6 +284,12 @@
bool is_asrc_supported;
struct listnode acdb_meta_key_list;
bool use_generic_handset;
+ struct spkr_device_chmap *spkr_ch_map;
+};
+
+struct spkr_device_chmap {
+ int num_ch;
+ char chmap[AUDIO_CHANNEL_COUNT_MAX];
};
static int pcm_device_table[AUDIO_USECASE_MAX][2] = {
@@ -2075,6 +2082,7 @@
my_data->hw_dep_fd = -1;
my_data->mono_speaker = SPKR_1;
my_data->speaker_lr_swap = false;
+ my_data->spkr_ch_map = NULL;
be_dai_name_table = NULL;
@@ -2593,6 +2601,11 @@
my_data->adev->mixer = NULL;
}
+ if (my_data->spkr_ch_map) {
+ free(my_data->spkr_ch_map);
+ my_data->spkr_ch_map = NULL;
+ }
+
int32_t idx;
for (idx = 0; idx < MAX_CODEC_BACKENDS; idx++) {
@@ -4941,6 +4954,46 @@
}
}
+static void platform_spkr_device_set_params(struct platform_data *platform,
+ struct str_parms *parms,
+ char *value, int len)
+{
+ int err = 0, i = 0, num_ch = 0;
+ char *test_r = NULL;
+ char *opts = NULL;
+ char *ch_count = NULL;
+
+ err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SPKR_DEVICE_CHMAP,
+ value, len);
+ if (err >= 0) {
+ platform->spkr_ch_map = calloc(1, sizeof(struct spkr_device_chmap));
+ if (!platform->spkr_ch_map) {
+ ALOGE("%s: failed to allocate mem for adm channel map\n", __func__);
+ str_parms_del(parms, AUDIO_PARAMETER_KEY_SPKR_DEVICE_CHMAP);
+ return ;
+ }
+
+ ch_count = strtok_r(value, ", ", &test_r);
+ if (ch_count == NULL) {
+ ALOGE("%s: incorrect ch_map\n", __func__);
+ free(platform->spkr_ch_map);
+ platform->spkr_ch_map = NULL;
+ str_parms_del(parms, AUDIO_PARAMETER_KEY_SPKR_DEVICE_CHMAP);
+ return;
+ }
+
+ num_ch = atoi(ch_count);
+ if ((num_ch > 0) && (num_ch <= AUDIO_CHANNEL_COUNT_MAX) ) {
+ platform->spkr_ch_map->num_ch = num_ch;
+ for (i = 0; i < num_ch; i++) {
+ opts = strtok_r(NULL, ", ", &test_r);
+ platform->spkr_ch_map->chmap[i] = strtoul(opts, NULL, 16);
+ }
+ }
+ str_parms_del(parms, AUDIO_PARAMETER_KEY_SPKR_DEVICE_CHMAP);
+ }
+}
+
int platform_set_parameters(void *platform, struct str_parms *parms)
{
struct platform_data *my_data = (struct platform_data *)platform;
@@ -5082,6 +5135,7 @@
audio_extn_hfp_set_parameters(adev, parms);
perf_lock_set_params(platform, parms, value, len);
true_32_bit_set_params(parms, value, len);
+ platform_spkr_device_set_params(platform, parms, value, len);
done:
ALOGV("%s: exit with code(%d)", __func__, ret);
if(kv_pairs != NULL)
@@ -6276,6 +6330,11 @@
backend_cfg.sample_rate, backend_cfg.channels, backend_idx, usecase->id,
platform_get_snd_device_name(snd_device));
+ if ((my_data->spkr_ch_map != NULL) &&
+ (platform_get_backend_index(snd_device) == DEFAULT_CODEC_BACKEND))
+ platform_set_channel_map(my_data, my_data->spkr_ch_map->num_ch,
+ my_data->spkr_ch_map->chmap, -1);
+
if (platform_split_snd_device(my_data, snd_device, &num_devices,
new_snd_devices) < 0)
new_snd_devices[0] = snd_device;