qahw: Add support for new stream APIs

Add support for new APIs to support voice call and
voice call features.

CRs-fixed: 2381271
Change-Id: Id3ba4417f1365018e5a26d243caea83571857f63
This commit is contained in:
Josh Kirsch 2019-01-15 11:50:53 -08:00 committed by Gerrit - the friendly Code Review server
parent 15fa15d8ac
commit c03f31d9e5
10 changed files with 1523 additions and 5 deletions

View File

@ -141,6 +141,7 @@ AM_CONDITIONAL([CUSTOM_STEREO], [test x$AUDIO_FEATURE_ENABLED_CUSTOM_STEREO = xt
AM_CONDITIONAL([RUN_KEEP_ALIVE_IN_ARM_FFV], [test x$AUDIO_FEATURE_ENABLED_KEEP_ALIVE_ARM_FFV = xtrue])
AM_CONDITIONAL([INSTANCE_ID], [test x$AUDIO_FEATURE_ENABLED_INSTANCE_ID = xtrue])
AM_CONDITIONAL([LL_AS_PRIMARY_OUTPUT], [test x$AUDIO_USE_LL_AS_PRIMARY_OUTPUT = xtrue])
AM_CONDITIONAL([QAHW_V1], [test x$AUDIO_FEATURE_ENABLED_QAHW_1_0 = xtrue])
AC_CONFIG_FILES([ \
Makefile \

View File

@ -17,6 +17,10 @@ if SVA_AUDIO_CONCURRENCY
AM_CFLAGS += -DSVA_AUDIO_CONC
endif
if QAHW_V1
AM_CFLAGS += -DQAHW_V1
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

@ -30,6 +30,7 @@ AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
AM_CONDITIONAL([SVA_AUDIO_CONCURRENCY],[test x$BOARD_SUPPORTS_SVA_AUDIO_CONCURRENCY = xtrue])
AM_CONDITIONAL([QAHW_V1], [test x$AUDIO_FEATURE_ENABLED_QAHW_1_0 = 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-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2011 The Android Open Source Project *
@ -45,6 +45,9 @@ __BEGIN_DECLS
/* First generation of audio devices had version hardcoded to 0. all devices with
* versions < 1.0 will be considered of first generation API.
*/
#if QAHW_V1
#define QAHW_MODULE_API_VERSION_1_0 QAHW_MAKE_API_VERSION(1, 0)
#endif
#define QAHW_MODULE_API_VERSION_0_0 QAHW_MAKE_API_VERSION(0, 0)
/* Minimal QTI audio HAL version supported by the audio framework */

View File

@ -18,6 +18,7 @@
#include <sys/cdefs.h>
#include <stdint.h>
#include <system/audio.h>
#ifndef QTI_AUDIO_HAL_DEFS_H
#define QTI_AUDIO_HAL_DEFS_H
@ -171,6 +172,9 @@ __BEGIN_DECLS
#define QAHW_INPUT_FLAG_TIMESTAMP 0x80000000
#define QAHW_INPUT_FLAG_COMPRESS 0x40000000
#define QAHW_INPUT_FLAG_PASSTHROUGH 0x20000000
#define QAHW_OUTPUT_FLAG_INCALL_MUSIC 0x80000000
#define QAHW_AUDIO_FLAG_HPCM_TX 0x00020000
#define QAHW_AUDIO_FLAG_HPCM_RX 0x00040000
/* Query fm volume */
#define QAHW_PARAMETER_KEY_FM_VOLUME "fm_volume"
@ -267,6 +271,14 @@ typedef struct {
uint32_t reserved[64]; /*reserved for future */
} qahw_in_buffer_t;
typedef struct {
void *buffer; /* write buffer pointer */
size_t size; /* size of buffer */
size_t offset; /* offset in buffer from where valid byte starts */
int64_t *timestamp; /* timestmap */
qahw_meta_data_flags_t flags; /* meta data flags */
} qahw_buffer_t;
#define MAX_SECTORS 8
struct qahw_source_tracking_param {
@ -391,6 +403,42 @@ typedef struct qahw_license_params {
char license[QAHW_LICENCE_STR_MAX_LENGTH + 1];
} qahw_license_params_t;
typedef struct qahw_dtmf_gen_params {
bool enable;
uint16_t low_freq;
uint16_t high_freq;
uint16_t gain;
} qahw_dtmf_gen_params_t;
enum {
QAHW_TTY_MODE_OFF,
QAHW_TTY_MODE_FULL,
QAHW_TTY_MODE_VCO,
QAHW_TTY_MODE_HCO,
QAHW_TTY_MODE_MAX,
};
typedef struct qahw_tty_params {
uint32_t mode;
} qahw_tty_params_t;
typedef enum {
QAHW_HPCM_TAP_POINT_RX = 1,
QAHW_HPCM_TAP_POINT_TX = 2,
QAHW_HPCM_TAP_POINT_RX_TX = 3,
} qahw_hpcm_tap_point;
typedef enum {
QAHW_HPCM_DIRECTION_OUT,
QAHW_HPCM_DIRECTION_IN,
QAHW_HPCM_DIRECTION_OUT_IN,
} qahw_hpcm_direction;
typedef struct qahw_hpcm_params {
qahw_hpcm_tap_point tap_point;
qahw_hpcm_direction direction;
} qahw_hpcm_params_t;
typedef union {
struct qahw_source_tracking_param st_params;
struct qahw_sound_focus_param sf_params;
@ -406,6 +454,9 @@ typedef union {
struct qahw_mix_matrix_params mix_matrix_params;
struct qahw_license_params license_params;
struct qahw_out_presentation_position_param pos_param;
struct qahw_dtmf_gen_params dtmf_gen_params;
struct qahw_tty_params tty_mode_params;
struct qahw_hpcm_params hpcm_params;
} qahw_param_payload;
typedef enum {
@ -426,6 +477,9 @@ typedef enum {
QAHW_PARAM_CH_MIX_MATRIX_PARAMS,
QAHW_PARAM_LICENSE_PARAMS,
QAHW_PARAM_OUT_PRESENTATION_POSITION,
QAHW_PARAM_DTMF_GEN,
QAHW_PARAM_TTY_MODE,
QAHW_PARAM_HPCM,
} qahw_param_id;
typedef union {
@ -436,6 +490,94 @@ typedef enum {
QAHW_PARAM_LOOPBACK_RENDER_WINDOW /* PARAM to set render window */
} qahw_loopback_param_id;
/** stream direction enumeration */
typedef enum {
QAHW_STREAM_INPUT,
QAHW_STREAM_OUTPUT,
QAHW_STREAM_INPUT_OUTPUT,
} qahw_stream_direction;
/** stream types */
typedef enum {
QAHW_STREAM_TYPE_INVALID,
QAHW_AUDIO_PLAYBACK_LOW_LATENCY, /**< low latency, higher power*/
QAHW_AUDIO_PLAYBACK_DEEP_BUFFER, /**< low power, higher latency*/
QAHW_AUDIO_PLAYBACK_COMPRESSED, /**< compresssed audio*/
QAHW_AUDIO_PLAYBACK_VOIP, /**< pcm voip audio*/
QAHW_AUDIO_PLAYBACK_VOICE_CALL_MUSIC, /**< pcm voip audio*/
QAHW_AUDIO_CAPTURE_LOW_LATENCY, /**< low latency, higher power*/
QAHW_AUDIO_CAPTURE_DEEP_BUFFER, /**< low power, higher latency*/
QAHW_AUDIO_CAPTURE_COMPRESSED, /**< compresssed audio*/
QAHW_AUDIO_CAPTURE_RAW, /**< pcm no post processing*/
QAHW_AUDIO_CAPTURE_VOIP, /**< pcm voip audio*/
QAHW_AUDIO_CAPTURE_VOICE_ACTIVATION, /**< voice activation*/
QAHW_AUDIO_CAPTURE_VOICE_CALL_RX, /**< incall record, downlink */
QAHW_AUDIO_CAPTURE_VOICE_CALL_TX, /**< incall record, uplink */
QAHW_AUDIO_CAPTURE_VOICE_CALL_RX_TX, /**< incall record, uplink & Downlink */
QAHW_VOICE_CALL, /**< voice call */
QAHW_AUDIO_TRANSCODE, /**< audio transcode */
QAHW_AUDIO_HOST_PCM_TX,
QAHW_AUDIO_HOST_PCM_RX,
QAHW_AUDIO_HOST_PCM_TX_RX,
QAHW_AUDIO_STREAM_TYPE_MAX,
} qahw_audio_stream_type;
typedef uint32_t qahw_device_t;
/**< Key value pair to identify the topology of a usecase from default */
struct qahw_modifier_kv {
uint32_t key;
uint32_t value;
};
struct qahw_shared_attributes{
audio_config_t config;
};
struct qahw_voice_attributes{
audio_config_t config;
const char *vsid;
};
struct qahw_audio_attributes{
audio_config_t config;
};
typedef union {
struct qahw_shared_attributes shared;
struct qahw_voice_attributes voice;
struct qahw_audio_attributes audio;
} qahw_stream_attributes_config;
struct qahw_stream_attributes {
qahw_audio_stream_type type;
qahw_stream_direction direction;
qahw_stream_attributes_config attr;
};
typedef enum {
QAHW_CHANNEL_L = 0, /*left channel*/
QAHW_CHANNEL_R = 1, /*right channel*/
QAHW_CHANNELS_MAX = 2, /*max number of supported streams*/
} qahw_channel_map;
struct qahw_channel_vol {
qahw_channel_map channel;
float vol;
};
struct qahw_volume_data {
uint32_t num_of_channels;
struct qahw_channel_vol *vol_pair;
};
struct qahw_mute_data {
bool enable;
qahw_stream_direction direction;
};
__END_DECLS
#endif // QTI_AUDIO_HAL_DEFS_H

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2019, 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
@ -45,8 +45,13 @@
/*
* The current HAL API version.
* version 1.0 has support for voice only in new stream based APIS
*/
#ifdef QAHW_MODULE_API_VERSION_1_0
#define QAHW_MODULE_API_VERSION_CURRENT QAHW_MODULE_API_VERSION_1_0
#else
#define QAHW_MODULE_API_VERSION_CURRENT QAHW_MODULE_API_VERSION_0_0
#endif
typedef uint64_t (*qahwi_out_write_v2_t)(audio_stream_out_t *out, const void* buffer,

View File

@ -22,8 +22,13 @@ libqahw_la_CPPFLAGS := $(AM_CPPFLAGS)
libqahw_la_CPPFLAGS += -std=c++11 -DHAVE_PTHREADS -DHAVE_ANDROID_OS
libqahw_la_CPPFLAGS += -DDEBUG_REFS_CALLSTACK_ENABLED=0
libqahw_la_CPPFLAGS += -DNDEBUG
libqahw_la_LDFLAGS = -ltinyalsa -lhardware -lexpat -lcutils -llog -ldl -shared -avoid-version -lpthread -lutils
libqahw_la_CPPFLAGS += $(GLIB_CFLAGS) -include glib.h
libqahw_la_LDFLAGS = -ltinyalsa -lhardware -lexpat -lcutils -llog -ldl -shared -avoid-version -lpthread -lutils $(GLIB_LIBS)
if QTI_AUDIO_SERVER_ENABLED
AM_CPPFLAGS += -DQTI_AUDIO_SERVER_ENABLED
libqahw_la_LDFLAGS += -lqtiaudioserver -lbinder
endif
if QAHW_V1
AM_CPPFLAGS += -DQAHW_V1
endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2011 The Android Open Source Project *
@ -485,6 +485,75 @@ int qahw_set_audio_port_config(qahw_module_handle_t *hw_module,
void qahw_register_qas_death_notify_cb(audio_error_callback cb, void* context);
/* updated new stream APIs to support voice and Audio use cases */
int qahw_stream_open(qahw_module_handle_t *hw_module,
struct qahw_stream_attributes attr,
uint32_t num_of_devices,
qahw_device_t *devices,
uint32_t no_of_modifiers,
struct qahw_modifier_kv *modifiers,
qahw_stream_callback_t cb,
void *cookie,
qahw_stream_handle_t **stream_handle);
int qahw_stream_close(qahw_stream_handle_t *stream_handle);
int qahw_stream_start(qahw_stream_handle_t *stream_handle);
int qahw_stream_stop(qahw_stream_handle_t *stream_handle);
int qahw_stream_set_device(qahw_stream_handle_t *stream_handle,
uint32_t num_of_dev,
qahw_device_t *devices);
int qahw_stream_get_device(qahw_stream_handle_t *stream_handle,
uint32_t *num_of_dev,
qahw_device_t **devices);
int qahw_stream_set_volume(qahw_stream_handle_t *stream_handle,
struct qahw_volume_data vol_data);
int qahw_stream_get_volume(qahw_stream_handle_t *stream_handle,
struct qahw_volume_data **vol_data);
int qahw_stream_set_mute(qahw_stream_handle_t *stream_handle,
struct qahw_mute_data mute_data);
int qahw_stream_get_mute(qahw_stream_handle_t *stream_handle,
struct qahw_mute_data *mute_data);
ssize_t qahw_stream_read(qahw_stream_handle_t *stream_handle,
qahw_buffer_t *in_buf);
ssize_t qahw_stream_write(qahw_stream_handle_t *stream_handle,
qahw_buffer_t *out_buf);
int32_t qahw_stream_pause(qahw_stream_handle_t *stream_handle);
int32_t qahw_stream_standby(qahw_stream_handle_t *stream_handle);
int32_t qahw_stream_resume(qahw_stream_handle_t *stream_handle);
int32_t qahw_stream_flush(qahw_stream_handle_t *stream_handle);
int32_t qahw_stream_drain(qahw_stream_handle_t *stream_handle,
qahw_drain_type_t type);
int32_t qahw_stream_get_buffer_size(const qahw_stream_handle_t *stream_handle,
size_t *in_buffer, size_t *out_buffer);
int32_t qahw_stream_set_buffer_size(const qahw_stream_handle_t *stream_handle,
size_t in_buffer, size_t out_buffer);
int32_t qahw_stream_set_parameters(qahw_stream_handle_t *stream_handle,
uint32_t param_id,
qahw_param_payload *param_payload);
int32_t qahw_stream_get_parameters(qahw_stream_handle_t *stream_handle,
uint32_t param_id,
qahw_param_payload *param_payload);
__END_DECLS
#endif // QTI_AUDIO_QAHW_API_H

View File

@ -18,6 +18,7 @@
#include <sys/cdefs.h>
#include <stdint.h>
#include <system/audio.h>
#ifndef QTI_AUDIO_HAL_DEFS_H
#define QTI_AUDIO_HAL_DEFS_H
@ -171,6 +172,9 @@ __BEGIN_DECLS
#define QAHW_INPUT_FLAG_TIMESTAMP 0x80000000
#define QAHW_INPUT_FLAG_COMPRESS 0x40000000
#define QAHW_INPUT_FLAG_PASSTHROUGH 0x20000000
#define QAHW_OUTPUT_FLAG_INCALL_MUSIC 0x80000000
#define QAHW_AUDIO_FLAG_HPCM_TX 0x00020000
#define QAHW_AUDIO_FLAG_HPCM_RX 0x00040000
/* Query fm volume */
#define QAHW_PARAMETER_KEY_FM_VOLUME "fm_volume"
@ -245,6 +249,14 @@ typedef struct {
uint32_t reserved[64]; /*reserved for future */
} qahw_in_buffer_t;
typedef struct {
void *buffer; /* write buffer pointer */
size_t size; /* size of buffer */
size_t offset; /* offset in buffer from where valid byte starts */
int64_t *timestamp; /* timestmap */
qahw_meta_data_flags_t flags; /* meta data flags */
} qahw_buffer_t;
#define MAX_SECTORS 8
struct qahw_source_tracking_param {
@ -370,6 +382,42 @@ typedef struct qahw_license_params {
char license[QAHW_LICENCE_STR_MAX_LENGTH + 1];
} qahw_license_params_t;
typedef struct qahw_dtmf_gen_params {
bool enable;
uint16_t low_freq;
uint16_t high_freq;
uint16_t gain;
} qahw_dtmf_gen_params_t;
enum {
QAHW_TTY_MODE_OFF,
QAHW_TTY_MODE_FULL,
QAHW_TTY_MODE_VCO,
QAHW_TTY_MODE_HCO,
QAHW_TTY_MODE_MAX,
};
typedef struct qahw_tty_params {
uint32_t mode;
} qahw_tty_params_t;
typedef enum {
QAHW_HPCM_TAP_POINT_RX = 1,
QAHW_HPCM_TAP_POINT_TX = 2,
QAHW_HPCM_TAP_POINT_RX_TX = 3,
} qahw_hpcm_tap_point;
typedef enum {
QAHW_HPCM_DIRECTION_OUT,
QAHW_HPCM_DIRECTION_IN,
QAHW_HPCM_DIRECTION_OUT_IN,
} qahw_hpcm_direction;
typedef struct qahw_hpcm_params {
qahw_hpcm_tap_point tap_point;
qahw_hpcm_direction direction;
} qahw_hpcm_params_t;
typedef union {
struct qahw_source_tracking_param st_params;
struct qahw_sound_focus_param sf_params;
@ -385,6 +433,9 @@ typedef union {
struct qahw_mix_matrix_params mix_matrix_params;
struct qahw_license_params license_params;
struct qahw_out_presentation_position_param pos_param;
struct qahw_dtmf_gen_params dtmf_gen_params;
struct qahw_tty_params tty_mode_params;
struct qahw_hpcm_params hpcm_params;
} qahw_param_payload;
typedef enum {
@ -405,6 +456,9 @@ typedef enum {
QAHW_PARAM_CH_MIX_MATRIX_PARAMS,
QAHW_PARAM_LICENSE_PARAMS,
QAHW_PARAM_OUT_PRESENTATION_POSITION,
QAHW_PARAM_DTMF_GEN,
QAHW_PARAM_TTY_MODE,
QAHW_PARAM_HPCM,
} qahw_param_id;
@ -416,6 +470,94 @@ typedef enum {
QAHW_PARAM_LOOPBACK_RENDER_WINDOW /* PARAM to set render window */
} qahw_loopback_param_id;
/** stream direction enumeration */
typedef enum {
QAHW_STREAM_INPUT,
QAHW_STREAM_OUTPUT,
QAHW_STREAM_INPUT_OUTPUT,
} qahw_stream_direction;
/** stream types */
typedef enum {
QAHW_STREAM_TYPE_INVALID,
QAHW_AUDIO_PLAYBACK_LOW_LATENCY, /**< low latency, higher power*/
QAHW_AUDIO_PLAYBACK_DEEP_BUFFER, /**< low power, higher latency*/
QAHW_AUDIO_PLAYBACK_COMPRESSED, /**< compresssed audio*/
QAHW_AUDIO_PLAYBACK_VOIP, /**< pcm voip audio*/
QAHW_AUDIO_PLAYBACK_VOICE_CALL_MUSIC, /**< pcm voip audio*/
QAHW_AUDIO_CAPTURE_LOW_LATENCY, /**< low latency, higher power*/
QAHW_AUDIO_CAPTURE_DEEP_BUFFER, /**< low power, higher latency*/
QAHW_AUDIO_CAPTURE_COMPRESSED, /**< compresssed audio*/
QAHW_AUDIO_CAPTURE_RAW, /**< pcm no post processing*/
QAHW_AUDIO_CAPTURE_VOIP, /**< pcm voip audio*/
QAHW_AUDIO_CAPTURE_VOICE_ACTIVATION, /**< voice activation*/
QAHW_AUDIO_CAPTURE_VOICE_CALL_RX, /**< incall record, downlink */
QAHW_AUDIO_CAPTURE_VOICE_CALL_TX, /**< incall record, uplink */
QAHW_AUDIO_CAPTURE_VOICE_CALL_RX_TX, /**< incall record, uplink & Downlink */
QAHW_VOICE_CALL, /**< voice call */
QAHW_AUDIO_TRANSCODE, /**< audio transcode */
QAHW_AUDIO_HOST_PCM_TX,
QAHW_AUDIO_HOST_PCM_RX,
QAHW_AUDIO_HOST_PCM_TX_RX,
QAHW_AUDIO_STREAM_TYPE_MAX,
} qahw_audio_stream_type;
typedef uint32_t qahw_device_t;
/**< Key value pair to identify the topology of a usecase from default */
struct qahw_modifier_kv {
uint32_t key;
uint32_t value;
};
struct qahw_shared_attributes{
audio_config_t config;
};
struct qahw_voice_attributes{
audio_config_t config;
const char *vsid;
};
struct qahw_audio_attributes{
audio_config_t config;
};
typedef union {
struct qahw_shared_attributes shared;
struct qahw_voice_attributes voice;
struct qahw_audio_attributes audio;
} qahw_stream_attributes_config;
struct qahw_stream_attributes {
qahw_audio_stream_type type;
qahw_stream_direction direction;
qahw_stream_attributes_config attr;
};
typedef enum {
QAHW_CHANNEL_L = 0, /*left channel*/
QAHW_CHANNEL_R = 1, /*right channel*/
QAHW_CHANNELS_MAX = 2, /*max number of supported streams*/
} qahw_channel_map;
struct qahw_channel_vol {
qahw_channel_map channel;
float vol;
};
struct qahw_volume_data {
uint32_t num_of_channels;
struct qahw_channel_vol *vol_pair;
};
struct qahw_mute_data {
bool enable;
qahw_stream_direction direction;
};
__END_DECLS
#endif // QTI_AUDIO_HAL_DEFS_H

File diff suppressed because it is too large Load Diff