qahw: Load sound trigger HAL when concurrency enabled

Load sound trigger HAL during audio use case is running when sva and audio
concurrency is enabled.

CRs-Fixed: 2173226
Change-Id: I80b797857eae9dfc2cfaad340ec145dccd3c095f
This commit is contained in:
Dhanalakshmi Siddani 2018-03-05 19:57:06 +05:30
parent b34a9950b7
commit 7764e3fec0
3 changed files with 49 additions and 2 deletions

View File

@ -13,6 +13,10 @@ lib_LTLIBRARIES = libqahwwrapper.la
libqahwwrapper_la_SOURCES = src/qahw.c \
src/qahw_effect.c
if SVA_AUDIO_CONCURRENCY
AM_CFLAGS += -DSVA_AUDIO_CONC
endif
libqahwwrapper_la_CFLAGS = $(AM_CFLAGS)
libqahwwrapper_la_CFLAGS += -include stddef.h
libqahwwrapper_la_CFLAGS += -Dstrlcpy=g_strlcpy $(GLIB_CFLAGS) -include glib.h

View File

@ -29,6 +29,7 @@ AC_PROG_LN_S
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
AM_CONDITIONAL([SVA_AUDIO_CONCURRENCY],[test x$BOARD_SUPPORTS_SVA_AUDIO_CONCURRENCY = xtrue])
AC_ARG_WITH([glib],
AC_HELP_STRING([--with-glib],
[enable glib, Build against glib. Use this when building for HLOS systems which use glib]))

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2018, 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
@ -37,6 +37,7 @@
#include <cutils/list.h>
#include <hardware/audio.h>
#include <hardware/sound_trigger.h>
#include "qahw.h"
#define NO_ERROR 0
@ -113,6 +114,7 @@ typedef enum {
static struct listnode qahw_module_list;
static int qahw_list_count;
static pthread_mutex_t qahw_module_init_lock = PTHREAD_MUTEX_INITIALIZER;
sound_trigger_hw_device_t *st_hw_device = NULL;
/** Start of internal functions */
@ -1776,6 +1778,45 @@ int qahw_get_version_l() {
return QAHW_MODULE_API_VERSION_CURRENT;
}
/* Load AHAL module to run audio and sva concurrency */
static void load_st_hal()
{
#ifdef SVA_AUDIO_CONC
int rc = -EINVAL;
const hw_module_t* module = NULL;
rc = hw_get_module_by_class(SOUND_TRIGGER_HARDWARE_MODULE_ID, "primary", &module);
if (rc) {
ALOGE("%s: AHAL Loading failed %d", __func__, rc);
goto error;
}
rc = sound_trigger_hw_device_open(module, &st_hw_device);
if (rc) {
ALOGE("%s: AHAL Device open failed %d", __func__, rc);
st_hw_device = NULL;
}
error:
return;
#else
return;
#endif /*SVA_AUDIO_CONC*/
}
static void unload_st_hal()
{
#ifdef SVA_AUDIO_CONC
if (st_hw_device == NULL) {
ALOGE("%s: audio device is NULL",__func__);
return;
}
sound_trigger_hw_device_close(st_hw_device);
st_hw_device = NULL;
#else
return;
#endif /*SVA_AUDIO_CONC*/
}
/* convenience API for opening and closing an audio HAL module */
qahw_module_handle_t *qahw_load_module_l(const char *hw_module_id)
@ -1867,7 +1908,7 @@ qahw_module_handle_t *qahw_load_module_l(const char *hw_module_id)
/* Add module list to global module list */
list_add_tail(&qahw_module_list, &qahw_module->module_list);
load_st_hal();
error_exit:
pthread_mutex_unlock(&qahw_module_init_lock);
@ -1924,6 +1965,7 @@ int qahw_unload_module_l(qahw_module_handle_t *hw_module)
"is not closed", __func__);
rc = -EINVAL;
}
unload_st_hal();
error_exit:
pthread_mutex_unlock(&qahw_module_init_lock);