qahw: test: Implement new api of set param for SourceTrack
Implement new api qahw_set_param_data to set SourceTracking parameters in given payload. Change-Id: I5499d91eab08342c6d567a28997f8a58e8f0a71e
This commit is contained in:
parent
daf1d06ff2
commit
53ea158352
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
|
||||
* Not a Contribution.
|
||||
*
|
||||
* Copyright (C) 2011 The Android Open Source Project *
|
||||
|
@ -428,6 +428,13 @@ int qahw_get_param_data(const qahw_module_handle_t *hw_module,
|
|||
qahw_param_id param_id,
|
||||
qahw_param_payload *payload);
|
||||
|
||||
/* Api to implement set parameters based on keyword param_id
|
||||
* and data present in payload.
|
||||
*/
|
||||
int qahw_set_param_data(const qahw_module_handle_t *hw_module,
|
||||
qahw_param_id param_id,
|
||||
qahw_param_payload *payload);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // QTI_AUDIO_HAL_API_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
|
@ -50,6 +50,12 @@
|
|||
typedef uint64_t (*qahwi_in_read_v2_t)(audio_stream_in_t *in, void* buffer,
|
||||
size_t bytes, uint64_t *timestamp);
|
||||
|
||||
typedef int (*qahwi_get_param_data_t) (const audio_hw_device_t *,
|
||||
qahw_param_id, qahw_param_payload *);
|
||||
|
||||
typedef int (*qahwi_set_param_data_t) (audio_hw_device_t *,
|
||||
qahw_param_id, qahw_param_payload *);
|
||||
|
||||
typedef struct {
|
||||
audio_hw_device_t *audio_device;
|
||||
char module_name[MAX_MODULE_NAME_LENGTH];
|
||||
|
@ -59,6 +65,8 @@ typedef struct {
|
|||
pthread_mutex_t lock;
|
||||
uint32_t ref_count;
|
||||
const hw_module_t* module;
|
||||
qahwi_get_param_data_t qahwi_get_param_data;
|
||||
qahwi_set_param_data_t qahwi_set_param_data;
|
||||
} qahw_module_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -91,9 +99,6 @@ static struct listnode qahw_module_list;
|
|||
static int qahw_list_count;
|
||||
static pthread_mutex_t qahw_module_init_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
typedef int (*qahwi_get_param_data_t) (const struct audio_device *,
|
||||
qahw_param_id, qahw_param_payload *);
|
||||
qahwi_get_param_data_t qahwi_get_param_data;
|
||||
|
||||
/** Start of internal functions */
|
||||
/******************************************************************************/
|
||||
|
@ -1233,8 +1238,43 @@ int qahw_get_param_data(const qahw_module_handle_t *hw_module,
|
|||
|
||||
pthread_mutex_lock(&qahw_module->lock);
|
||||
|
||||
if (qahwi_get_param_data){
|
||||
ret = qahwi_get_param_data (qahw_module->audio_device, param_id, payload);
|
||||
if (qahw_module->qahwi_get_param_data){
|
||||
ret = qahw_module->qahwi_get_param_data (qahw_module->audio_device,
|
||||
param_id, payload);
|
||||
} else {
|
||||
ret = -ENOSYS;
|
||||
ALOGE("%s not supported\n",__func__);
|
||||
}
|
||||
pthread_mutex_unlock(&qahw_module->lock);
|
||||
|
||||
exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Api to implement set parameters based on keyword param_id
|
||||
* and data present in payload.
|
||||
*/
|
||||
int qahw_set_param_data(const qahw_module_handle_t *hw_module,
|
||||
qahw_param_id param_id,
|
||||
qahw_param_payload *payload)
|
||||
{
|
||||
int ret = 0;
|
||||
qahw_module_t *qahw_module = (qahw_module_t *)hw_module;
|
||||
qahw_module_t *qahw_module_temp;
|
||||
|
||||
pthread_mutex_lock(&qahw_module_init_lock);
|
||||
qahw_module_temp = get_qahw_module_by_ptr(qahw_module);
|
||||
pthread_mutex_unlock(&qahw_module_init_lock);
|
||||
if (qahw_module_temp == NULL) {
|
||||
ALOGE("%s:: invalid hw module %p", __func__, qahw_module);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&qahw_module->lock);
|
||||
|
||||
if (qahw_module->qahwi_set_param_data){
|
||||
ret = qahw_module->qahwi_set_param_data (qahw_module->audio_device,
|
||||
param_id, payload);
|
||||
} else {
|
||||
ret = -ENOSYS;
|
||||
ALOGE("%s not supported\n",__func__);
|
||||
|
@ -1544,11 +1584,16 @@ qahw_module_handle_t *qahw_load_module(const char *hw_module_id)
|
|||
qahw_module->module = module;
|
||||
ALOGD("%s::Loaded HAL %s module %p", __func__, ahal_name, qahw_module);
|
||||
|
||||
qahwi_get_param_data = (qahwi_get_param_data_t) dlsym (module->dso,
|
||||
qahw_module->qahwi_get_param_data = (qahwi_get_param_data_t) dlsym (module->dso,
|
||||
"qahwi_get_param_data");
|
||||
if (!qahwi_get_param_data)
|
||||
if (!qahw_module->qahwi_get_param_data)
|
||||
ALOGD("%s::qahwi_get_param_data api is not defined\n",__func__);
|
||||
|
||||
qahw_module->qahwi_set_param_data = (qahwi_set_param_data_t) dlsym (module->dso,
|
||||
"qahwi_set_param_data");
|
||||
if (!qahw_module->qahwi_set_param_data)
|
||||
ALOGD("%s::qahwi_set_param_data api is not defined\n",__func__);
|
||||
|
||||
if (!qahw_list_count)
|
||||
list_init(&qahw_module_list);
|
||||
qahw_list_count++;
|
||||
|
|
|
@ -85,13 +85,9 @@ static pthread_mutex_t glock;
|
|||
static volatile int tests_running;
|
||||
static volatile int tests_completed;
|
||||
|
||||
#define SOUNDFOCUS_SET_PARAMS_STR_LEN 100
|
||||
#define SOUNDFOCUS_SET_PARAMS "SoundFocus.start_angles=%s;"\
|
||||
"SoundFocus.enable_sectors=%s;" \
|
||||
"SoundFocus.gain_step=%d"
|
||||
int sourcetrack_done = 0;
|
||||
static pthread_mutex_t sourcetrack_lock;
|
||||
char soundfocus_param[100];
|
||||
struct qahw_sound_focus_param sound_focus_data;
|
||||
|
||||
void stop_signal_handler(int signal)
|
||||
{
|
||||
|
@ -101,21 +97,24 @@ void stop_signal_handler(int signal)
|
|||
|
||||
void read_soundfocus_param(void)
|
||||
{
|
||||
char params[50] = {0};
|
||||
char *start_angle = NULL;
|
||||
char *enable_sector = NULL;
|
||||
unsigned int gain_step;
|
||||
int i = 0;
|
||||
uint16_t start_angle[4] = {0};
|
||||
uint8_t enable_sector[4] = {0};
|
||||
uint16_t gain_step;
|
||||
|
||||
printf("Enter soundfocusparams (startangle;enablesector;gainstep):::::");
|
||||
scanf("%s",params);
|
||||
printf("\nEnter soundfocusparams startangle :::::");
|
||||
scanf("%hd %hd %hd %hd",&start_angle[0], &start_angle[1],
|
||||
&start_angle[2], &start_angle[3]);
|
||||
memcpy(&sound_focus_data.start_angle, start_angle, sizeof(start_angle));
|
||||
|
||||
start_angle = strtok(params, ";");
|
||||
enable_sector = strtok(NULL, ";" );
|
||||
gain_step = atoi(strtok(NULL, ";"));
|
||||
printf("\nEnter soundfocusparams enablesector :::::");
|
||||
scanf("%hhd %hhd %hhd %hhd",&enable_sector[0], &enable_sector[1],
|
||||
&enable_sector[2], &enable_sector[3]);
|
||||
memcpy(&sound_focus_data.enable, enable_sector, sizeof(enable_sector));
|
||||
|
||||
snprintf(soundfocus_param, SOUNDFOCUS_SET_PARAMS_STR_LEN,
|
||||
SOUNDFOCUS_SET_PARAMS, start_angle, enable_sector,
|
||||
gain_step);
|
||||
printf("\nEnter soundfocusparams gainstep:::::");
|
||||
scanf("%hd",&gain_step);
|
||||
memcpy(&sound_focus_data.gain_step, &gain_step, sizeof(gain_step));
|
||||
}
|
||||
|
||||
void sourcetrack_signal_handler(int signal)
|
||||
|
@ -133,7 +132,6 @@ void *read_sourcetrack_data(void* data)
|
|||
int idx =0, status = 0,count = 0, sect = 0;
|
||||
qahw_param_id param;
|
||||
qahw_param_payload payload;
|
||||
struct qahw_sound_focus_param sound_focus_data;
|
||||
qahw_module_handle_t *qawh_module_handle = NULL;
|
||||
|
||||
qawh_module_handle = (qahw_module_handle_t *)data;
|
||||
|
@ -144,12 +142,13 @@ void *read_sourcetrack_data(void* data)
|
|||
return NULL;
|
||||
|
||||
pthread_mutex_lock(&sourcetrack_lock);
|
||||
status = qahw_set_parameters(qawh_module_handle, soundfocus_param);
|
||||
payload = (qahw_param_payload)sound_focus_data;
|
||||
param = QAHW_PARAM_SOUND_FOCUS;
|
||||
status = qahw_set_param_data(qawh_module_handle, param, &payload);
|
||||
if (status != 0)
|
||||
fprintf(log_file, "Error.Failed Set SoundFocus Params\n");
|
||||
|
||||
fprintf(log_file, "\nGet SoundFocus Params from app");
|
||||
param = QAHW_PARAM_SOUND_FOCUS;
|
||||
status = qahw_get_param_data(qawh_module_handle, param, &payload);
|
||||
if (status < 0) {
|
||||
fprintf(log_file, "Failed to get sound focus params\n");
|
||||
|
@ -535,6 +534,8 @@ void usage() {
|
|||
printf(" format 1[AUDIO_FORMAT_PCM_16_BIT], sample rate 44100, \n");
|
||||
printf(" channels 2[AUDIO_CHANNEL_IN_STEREO], record data for 8 secs\n");
|
||||
printf(" start recording after 2 secs.\n\n");
|
||||
printf(" hal_rec_test -S -c 1 -r 48000 -t 30 -> Enable Sourcetracking\n");
|
||||
printf(" For mono channel 48kHz rate for 30seconds\n\n");
|
||||
printf(" hal_rec_test -F 1 --kpi-mode -> start a recording with low latency input flag and calculate latency KPIs\n\n");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue