2013-01-18 00:50:22 +00:00
|
|
|
/*
|
2018-12-18 22:23:57 +00:00
|
|
|
* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
|
2013-10-01 22:49:05 +00:00
|
|
|
* Not a contribution.
|
|
|
|
*
|
2013-01-18 00:50:22 +00:00
|
|
|
* Copyright (C) 2013 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2014-11-23 03:34:13 +00:00
|
|
|
*
|
|
|
|
* This file was modified by DTS, Inc. The portions of the
|
|
|
|
* code modified by DTS, Inc are copyrighted and
|
|
|
|
* licensed separately, as follows:
|
|
|
|
*
|
|
|
|
* (C) 2014 DTS, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2013-01-18 00:50:22 +00:00
|
|
|
*/
|
|
|
|
|
2013-05-14 22:27:20 +00:00
|
|
|
#ifndef QCOM_AUDIO_HW_H
|
|
|
|
#define QCOM_AUDIO_HW_H
|
|
|
|
|
2015-07-01 23:57:32 +00:00
|
|
|
#include <stdlib.h>
|
2018-12-18 22:23:57 +00:00
|
|
|
#include <cutils/str_parms.h>
|
2013-05-14 22:27:20 +00:00
|
|
|
#include <cutils/list.h>
|
2013-01-18 00:50:22 +00:00
|
|
|
#include <hardware/audio.h>
|
|
|
|
#include <tinyalsa/asoundlib.h>
|
2013-07-17 22:22:04 +00:00
|
|
|
#include <tinycompress/tinycompress.h>
|
2013-01-18 00:50:22 +00:00
|
|
|
|
|
|
|
#include <audio_route/audio_route.h>
|
2018-12-18 22:23:57 +00:00
|
|
|
#include <audio_utils/ErrorLog.h>
|
2014-07-11 17:39:59 +00:00
|
|
|
#include "audio_defs.h"
|
2013-10-01 22:49:05 +00:00
|
|
|
#include "voice.h"
|
2016-10-25 12:32:58 +00:00
|
|
|
#include "audio_hw_extn_api.h"
|
2013-01-18 00:50:22 +00:00
|
|
|
|
2016-11-23 11:29:35 +00:00
|
|
|
#if LINUX_ENABLED
|
2018-02-22 07:39:48 +00:00
|
|
|
#if defined(__LP64__)
|
|
|
|
#define VISUALIZER_LIBRARY_PATH "/usr/lib64/libqcomvisualizer.so"
|
|
|
|
#define OFFLOAD_EFFECTS_BUNDLE_LIBRARY_PATH "/usr/lib64/libqcompostprocbundle.so"
|
|
|
|
#define ADM_LIBRARY_PATH "/usr/lib64/libadm.so"
|
|
|
|
#else
|
|
|
|
#define VISUALIZER_LIBRARY_PATH "/usr/lib/libqcomvisualizer.so"
|
|
|
|
#define OFFLOAD_EFFECTS_BUNDLE_LIBRARY_PATH "/usr/lib/libqcompostprocbundle.so"
|
|
|
|
#define ADM_LIBRARY_PATH "/usr/lib/libadm.so"
|
|
|
|
#endif
|
2016-11-23 11:29:35 +00:00
|
|
|
#else
|
2017-06-30 05:37:47 +00:00
|
|
|
#define VISUALIZER_LIBRARY_PATH "/vendor/lib/soundfx/libqcomvisualizer.so"
|
|
|
|
#define OFFLOAD_EFFECTS_BUNDLE_LIBRARY_PATH "/vendor/lib/soundfx/libqcompostprocbundle.so"
|
2017-03-15 18:39:33 +00:00
|
|
|
#define ADM_LIBRARY_PATH "/vendor/lib/libadm.so"
|
2016-11-23 11:29:35 +00:00
|
|
|
#endif
|
2013-09-13 00:45:53 +00:00
|
|
|
|
2013-05-14 22:27:20 +00:00
|
|
|
/* Flags used to initialize acdb_settings variable that goes to ACDB library */
|
2014-03-27 14:17:56 +00:00
|
|
|
#define NONE_FLAG 0x00000000
|
2014-04-07 19:11:47 +00:00
|
|
|
#define ANC_FLAG 0x00000001
|
2014-03-27 14:17:56 +00:00
|
|
|
#define DMIC_FLAG 0x00000002
|
|
|
|
#define QMIC_FLAG 0x00000004
|
2017-12-13 08:01:26 +00:00
|
|
|
/* Include TMIC Flag after existing QMIC flag to avoid backward compatibility
|
|
|
|
* issues since they are bit masked */
|
|
|
|
#define TMIC_FLAG 0x00000008
|
2014-03-27 14:17:56 +00:00
|
|
|
#define TTY_MODE_OFF 0x00000010
|
|
|
|
#define TTY_MODE_FULL 0x00000020
|
|
|
|
#define TTY_MODE_VCO 0x00000040
|
|
|
|
#define TTY_MODE_HCO 0x00000080
|
|
|
|
#define TTY_MODE_CLEAR 0xFFFFFF0F
|
|
|
|
#define FLUENCE_MODE_CLEAR 0xFFFFFFF0
|
2013-05-14 22:27:20 +00:00
|
|
|
|
2013-01-18 00:50:22 +00:00
|
|
|
#define ACDB_DEV_TYPE_OUT 1
|
|
|
|
#define ACDB_DEV_TYPE_IN 2
|
|
|
|
|
2018-12-18 22:23:57 +00:00
|
|
|
/* support positional and index masks to 8ch */
|
|
|
|
#define MAX_SUPPORTED_CHANNEL_MASKS (2 * FCC_8)
|
2016-02-18 02:08:05 +00:00
|
|
|
#define MAX_SUPPORTED_FORMATS 15
|
|
|
|
#define MAX_SUPPORTED_SAMPLE_RATES 7
|
2013-10-06 19:52:49 +00:00
|
|
|
#define DEFAULT_HDMI_OUT_CHANNELS 2
|
2016-04-13 18:54:02 +00:00
|
|
|
#define DEFAULT_HDMI_OUT_SAMPLE_RATE 48000
|
|
|
|
#define DEFAULT_HDMI_OUT_FORMAT AUDIO_FORMAT_PCM_16_BIT
|
2013-01-18 00:50:22 +00:00
|
|
|
|
2018-12-18 22:23:57 +00:00
|
|
|
#define ERROR_LOG_ENTRIES 16
|
|
|
|
|
2017-05-19 09:56:33 +00:00
|
|
|
#define SND_CARD_STATE_OFFLINE 0
|
|
|
|
#define SND_CARD_STATE_ONLINE 1
|
|
|
|
|
|
|
|
#define STREAM_DIRECTION_IN 0
|
|
|
|
#define STREAM_DIRECTION_OUT 1
|
|
|
|
|
2015-09-16 20:23:25 +00:00
|
|
|
#define MAX_PERF_LOCK_OPTS 20
|
|
|
|
|
2016-12-01 17:57:29 +00:00
|
|
|
#define MAX_STREAM_PROFILE_STR_LEN 32
|
2017-08-04 01:04:55 +00:00
|
|
|
typedef enum {
|
|
|
|
EFFECT_NONE = 0,
|
|
|
|
EFFECT_AEC,
|
|
|
|
EFFECT_NS,
|
|
|
|
EFFECT_MAX
|
|
|
|
} effect_type_t;
|
|
|
|
|
|
|
|
struct audio_effect_config {
|
|
|
|
uint32_t module_id;
|
|
|
|
uint32_t instance_id;
|
|
|
|
uint32_t param_id;
|
|
|
|
uint32_t param_value;
|
|
|
|
};
|
2016-12-01 17:57:29 +00:00
|
|
|
|
2017-01-13 22:56:59 +00:00
|
|
|
#define MAX_MIXER_PATH_LEN 64
|
|
|
|
|
2016-08-09 22:43:13 +00:00
|
|
|
typedef enum card_status_t {
|
|
|
|
CARD_STATUS_OFFLINE,
|
|
|
|
CARD_STATUS_ONLINE
|
|
|
|
} card_status_t;
|
|
|
|
|
2013-01-18 00:50:22 +00:00
|
|
|
/* These are the supported use cases by the hardware.
|
|
|
|
* Each usecase is mapped to a specific PCM device.
|
|
|
|
* Refer to pcm_device_table[].
|
|
|
|
*/
|
2014-08-20 23:24:38 +00:00
|
|
|
enum {
|
2013-01-18 00:50:22 +00:00
|
|
|
USECASE_INVALID = -1,
|
|
|
|
/* Playback usecases */
|
|
|
|
USECASE_AUDIO_PLAYBACK_DEEP_BUFFER = 0,
|
|
|
|
USECASE_AUDIO_PLAYBACK_LOW_LATENCY,
|
|
|
|
USECASE_AUDIO_PLAYBACK_MULTI_CH,
|
2013-07-17 22:22:04 +00:00
|
|
|
USECASE_AUDIO_PLAYBACK_OFFLOAD,
|
2014-04-02 04:03:10 +00:00
|
|
|
USECASE_AUDIO_PLAYBACK_OFFLOAD2,
|
|
|
|
USECASE_AUDIO_PLAYBACK_OFFLOAD3,
|
|
|
|
USECASE_AUDIO_PLAYBACK_OFFLOAD4,
|
|
|
|
USECASE_AUDIO_PLAYBACK_OFFLOAD5,
|
|
|
|
USECASE_AUDIO_PLAYBACK_OFFLOAD6,
|
|
|
|
USECASE_AUDIO_PLAYBACK_OFFLOAD7,
|
|
|
|
USECASE_AUDIO_PLAYBACK_OFFLOAD8,
|
|
|
|
USECASE_AUDIO_PLAYBACK_OFFLOAD9,
|
2015-06-26 03:08:01 +00:00
|
|
|
USECASE_AUDIO_PLAYBACK_ULL,
|
2017-06-01 00:16:49 +00:00
|
|
|
USECASE_AUDIO_PLAYBACK_MMAP,
|
2017-08-01 01:55:17 +00:00
|
|
|
USECASE_AUDIO_PLAYBACK_HIFI,
|
2018-12-18 22:23:57 +00:00
|
|
|
USECASE_AUDIO_PLAYBACK_TTS,
|
2014-04-02 04:03:10 +00:00
|
|
|
|
2013-10-06 21:39:35 +00:00
|
|
|
/* FM usecase */
|
|
|
|
USECASE_AUDIO_PLAYBACK_FM,
|
2013-01-18 00:50:22 +00:00
|
|
|
|
2013-11-05 23:57:39 +00:00
|
|
|
/* HFP Use case*/
|
|
|
|
USECASE_AUDIO_HFP_SCO,
|
2013-12-20 21:23:39 +00:00
|
|
|
USECASE_AUDIO_HFP_SCO_WB,
|
2013-11-05 23:57:39 +00:00
|
|
|
|
2013-01-18 00:50:22 +00:00
|
|
|
/* Capture usecases */
|
|
|
|
USECASE_AUDIO_RECORD,
|
2013-10-25 23:26:03 +00:00
|
|
|
USECASE_AUDIO_RECORD_COMPRESS,
|
2016-10-25 12:32:58 +00:00
|
|
|
USECASE_AUDIO_RECORD_COMPRESS2,
|
|
|
|
USECASE_AUDIO_RECORD_COMPRESS3,
|
|
|
|
USECASE_AUDIO_RECORD_COMPRESS4,
|
2017-09-28 16:56:23 +00:00
|
|
|
USECASE_AUDIO_RECORD_COMPRESS5,
|
|
|
|
USECASE_AUDIO_RECORD_COMPRESS6,
|
2013-01-18 00:50:22 +00:00
|
|
|
USECASE_AUDIO_RECORD_LOW_LATENCY,
|
2013-11-01 21:58:16 +00:00
|
|
|
USECASE_AUDIO_RECORD_FM_VIRTUAL,
|
2017-08-01 01:55:17 +00:00
|
|
|
USECASE_AUDIO_RECORD_HIFI,
|
2013-01-18 00:50:22 +00:00
|
|
|
|
2017-06-08 01:16:14 +00:00
|
|
|
USECASE_AUDIO_PLAYBACK_VOIP,
|
|
|
|
USECASE_AUDIO_RECORD_VOIP,
|
2013-10-01 22:49:05 +00:00
|
|
|
/* Voice usecase */
|
2013-01-18 00:50:22 +00:00
|
|
|
USECASE_VOICE_CALL,
|
2017-06-01 00:16:49 +00:00
|
|
|
USECASE_AUDIO_RECORD_MMAP,
|
2013-01-18 00:50:22 +00:00
|
|
|
|
2013-10-01 22:49:05 +00:00
|
|
|
/* Voice extension usecases */
|
|
|
|
USECASE_VOICE2_CALL,
|
|
|
|
USECASE_VOLTE_CALL,
|
|
|
|
USECASE_QCHAT_CALL,
|
2014-02-13 01:58:59 +00:00
|
|
|
USECASE_VOWLAN_CALL,
|
2015-02-13 01:38:22 +00:00
|
|
|
USECASE_VOICEMMODE1_CALL,
|
|
|
|
USECASE_VOICEMMODE2_CALL,
|
2013-11-15 23:21:40 +00:00
|
|
|
USECASE_COMPRESS_VOIP_CALL,
|
2013-10-01 22:49:05 +00:00
|
|
|
|
2013-10-17 18:16:13 +00:00
|
|
|
USECASE_INCALL_REC_UPLINK,
|
|
|
|
USECASE_INCALL_REC_DOWNLINK,
|
|
|
|
USECASE_INCALL_REC_UPLINK_AND_DOWNLINK,
|
2013-12-04 00:54:40 +00:00
|
|
|
USECASE_INCALL_REC_UPLINK_COMPRESS,
|
|
|
|
USECASE_INCALL_REC_DOWNLINK_COMPRESS,
|
|
|
|
USECASE_INCALL_REC_UPLINK_AND_DOWNLINK_COMPRESS,
|
2013-10-17 18:16:13 +00:00
|
|
|
|
2013-10-22 23:38:08 +00:00
|
|
|
USECASE_INCALL_MUSIC_UPLINK,
|
|
|
|
USECASE_INCALL_MUSIC_UPLINK2,
|
|
|
|
|
2013-10-28 21:06:03 +00:00
|
|
|
USECASE_AUDIO_SPKR_CALIB_RX,
|
|
|
|
USECASE_AUDIO_SPKR_CALIB_TX,
|
2014-09-05 20:51:35 +00:00
|
|
|
|
|
|
|
USECASE_AUDIO_PLAYBACK_AFE_PROXY,
|
|
|
|
USECASE_AUDIO_RECORD_AFE_PROXY,
|
2018-12-18 22:23:57 +00:00
|
|
|
USECASE_AUDIO_DSM_FEEDBACK,
|
2014-09-05 20:51:35 +00:00
|
|
|
|
2018-01-25 13:26:31 +00:00
|
|
|
USECASE_AUDIO_PLAYBACK_SILENCE,
|
2016-09-03 21:13:26 +00:00
|
|
|
|
2018-08-28 08:51:37 +00:00
|
|
|
USECASE_AUDIO_TRANSCODE_LOOPBACK_RX,
|
|
|
|
USECASE_AUDIO_TRANSCODE_LOOPBACK_TX,
|
2017-07-06 14:18:56 +00:00
|
|
|
|
|
|
|
USECASE_AUDIO_PLAYBACK_INTERACTIVE_STREAM1,
|
|
|
|
USECASE_AUDIO_PLAYBACK_INTERACTIVE_STREAM2,
|
|
|
|
USECASE_AUDIO_PLAYBACK_INTERACTIVE_STREAM3,
|
|
|
|
USECASE_AUDIO_PLAYBACK_INTERACTIVE_STREAM4,
|
|
|
|
USECASE_AUDIO_PLAYBACK_INTERACTIVE_STREAM5,
|
|
|
|
USECASE_AUDIO_PLAYBACK_INTERACTIVE_STREAM6,
|
|
|
|
USECASE_AUDIO_PLAYBACK_INTERACTIVE_STREAM7,
|
|
|
|
USECASE_AUDIO_PLAYBACK_INTERACTIVE_STREAM8,
|
2017-09-29 04:51:22 +00:00
|
|
|
|
|
|
|
USECASE_AUDIO_EC_REF_LOOPBACK,
|
2018-02-21 03:26:10 +00:00
|
|
|
|
|
|
|
USECASE_AUDIO_A2DP_ABR_FEEDBACK,
|
|
|
|
|
2013-01-18 00:50:22 +00:00
|
|
|
AUDIO_USECASE_MAX
|
2014-08-20 23:24:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const char * const use_case_table[AUDIO_USECASE_MAX];
|
2013-01-18 00:50:22 +00:00
|
|
|
|
|
|
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* tinyAlsa library interprets period size as number of frames
|
|
|
|
* one frame = channel_count * sizeof (pcm sample)
|
|
|
|
* so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes
|
|
|
|
* DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes
|
|
|
|
* We should take care of returning proper size when AudioFlinger queries for
|
|
|
|
* the buffer size of an input/output stream
|
|
|
|
*/
|
2013-07-17 22:22:04 +00:00
|
|
|
enum {
|
|
|
|
OFFLOAD_CMD_EXIT, /* exit compress offload thread loop*/
|
|
|
|
OFFLOAD_CMD_DRAIN, /* send a full drain request to DSP */
|
|
|
|
OFFLOAD_CMD_PARTIAL_DRAIN, /* send a partial drain request to DSP */
|
|
|
|
OFFLOAD_CMD_WAIT_FOR_BUFFER, /* wait for buffer released by DSP */
|
2016-08-09 22:43:13 +00:00
|
|
|
OFFLOAD_CMD_ERROR, /* offload playback hit some error */
|
2013-07-17 22:22:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
OFFLOAD_STATE_IDLE,
|
|
|
|
OFFLOAD_STATE_PLAYING,
|
|
|
|
OFFLOAD_STATE_PAUSED,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct offload_cmd {
|
|
|
|
struct listnode node;
|
|
|
|
int cmd;
|
|
|
|
int data[];
|
|
|
|
};
|
|
|
|
|
2017-01-30 12:05:36 +00:00
|
|
|
typedef enum render_mode {
|
|
|
|
RENDER_MODE_AUDIO_NO_TIMESTAMP = 0,
|
|
|
|
RENDER_MODE_AUDIO_MASTER,
|
|
|
|
RENDER_MODE_AUDIO_STC_MASTER,
|
|
|
|
} render_mode_t;
|
|
|
|
|
2014-03-10 21:43:05 +00:00
|
|
|
struct stream_app_type_cfg {
|
|
|
|
int sample_rate;
|
2014-09-05 23:14:17 +00:00
|
|
|
uint32_t bit_width;
|
2014-03-10 21:43:05 +00:00
|
|
|
int app_type;
|
2018-12-18 22:23:57 +00:00
|
|
|
int gain[2];
|
2014-03-10 21:43:05 +00:00
|
|
|
};
|
|
|
|
|
2017-05-19 09:56:33 +00:00
|
|
|
struct stream_config {
|
|
|
|
unsigned int sample_rate;
|
|
|
|
audio_channel_mask_t channel_mask;
|
|
|
|
audio_format_t format;
|
|
|
|
audio_devices_t devices;
|
|
|
|
unsigned int bit_width;
|
|
|
|
};
|
|
|
|
struct stream_inout {
|
|
|
|
pthread_mutex_t lock; /* see note below on mutex acquisition order */
|
|
|
|
pthread_mutex_t pre_lock; /* acquire before lock to avoid DOS by playback thread */
|
|
|
|
pthread_cond_t cond;
|
|
|
|
struct stream_config in_config;
|
|
|
|
struct stream_config out_config;
|
2017-08-08 05:45:25 +00:00
|
|
|
struct stream_app_type_cfg out_app_type_cfg;
|
|
|
|
char profile[MAX_STREAM_PROFILE_STR_LEN];
|
2017-05-23 01:26:24 +00:00
|
|
|
struct audio_device *dev;
|
|
|
|
void *adsp_hdlr_stream_handle;
|
|
|
|
void *ip_hdlr_handle;
|
|
|
|
stream_callback_t client_callback;
|
|
|
|
void *client_cookie;
|
2017-05-19 09:56:33 +00:00
|
|
|
};
|
2013-01-18 00:50:22 +00:00
|
|
|
struct stream_out {
|
|
|
|
struct audio_stream_out stream;
|
2013-02-27 22:31:02 +00:00
|
|
|
pthread_mutex_t lock; /* see note below on mutex acquisition order */
|
2015-09-28 22:23:06 +00:00
|
|
|
pthread_mutex_t pre_lock; /* acquire before lock to avoid DOS by playback thread */
|
2017-05-26 12:52:46 +00:00
|
|
|
pthread_mutex_t compr_mute_lock; /* acquire before setting compress volume */
|
2018-01-10 09:50:59 +00:00
|
|
|
pthread_mutex_t position_query_lock; /* acquire before updating/getting position of track offload*/
|
2013-07-17 22:22:04 +00:00
|
|
|
pthread_cond_t cond;
|
2013-01-18 00:50:22 +00:00
|
|
|
struct pcm_config config;
|
2013-07-17 22:22:04 +00:00
|
|
|
struct compr_config compr_config;
|
2013-01-18 00:50:22 +00:00
|
|
|
struct pcm *pcm;
|
2013-07-17 22:22:04 +00:00
|
|
|
struct compress *compr;
|
2013-01-18 00:50:22 +00:00
|
|
|
int standby;
|
|
|
|
int pcm_device_id;
|
2013-07-17 22:22:04 +00:00
|
|
|
unsigned int sample_rate;
|
2013-01-18 00:50:22 +00:00
|
|
|
audio_channel_mask_t channel_mask;
|
2013-07-17 22:22:04 +00:00
|
|
|
audio_format_t format;
|
2013-01-18 00:50:22 +00:00
|
|
|
audio_devices_t devices;
|
|
|
|
audio_output_flags_t flags;
|
2016-12-01 17:57:29 +00:00
|
|
|
char profile[MAX_STREAM_PROFILE_STR_LEN];
|
2013-01-18 00:50:22 +00:00
|
|
|
audio_usecase_t usecase;
|
|
|
|
/* Array of supported channel mask configurations. +1 so that the last entry is always 0 */
|
|
|
|
audio_channel_mask_t supported_channel_masks[MAX_SUPPORTED_CHANNEL_MASKS + 1];
|
2014-10-20 23:17:01 +00:00
|
|
|
audio_format_t supported_formats[MAX_SUPPORTED_FORMATS+1];
|
2016-02-18 02:08:05 +00:00
|
|
|
uint32_t supported_sample_rates[MAX_SUPPORTED_SAMPLE_RATES+1];
|
2013-04-04 16:19:12 +00:00
|
|
|
bool muted;
|
2013-09-10 16:04:31 +00:00
|
|
|
uint64_t written; /* total frames written, not cleared when entering standby */
|
2013-09-13 00:45:53 +00:00
|
|
|
audio_io_handle_t handle;
|
2014-03-10 21:43:05 +00:00
|
|
|
struct stream_app_type_cfg app_type_cfg;
|
2013-01-18 00:50:22 +00:00
|
|
|
|
2013-07-17 22:22:04 +00:00
|
|
|
int non_blocking;
|
|
|
|
int playback_started;
|
|
|
|
int offload_state;
|
|
|
|
pthread_cond_t offload_cond;
|
|
|
|
pthread_t offload_thread;
|
|
|
|
struct listnode offload_cmd_list;
|
|
|
|
bool offload_thread_blocked;
|
2018-01-10 09:50:59 +00:00
|
|
|
struct timespec writeAt;
|
2013-07-17 22:22:04 +00:00
|
|
|
|
2017-02-23 02:05:17 +00:00
|
|
|
void *adsp_hdlr_stream_handle;
|
2017-05-05 01:55:45 +00:00
|
|
|
void *ip_hdlr_handle;
|
2017-02-23 02:05:17 +00:00
|
|
|
|
|
|
|
stream_callback_t client_callback;
|
|
|
|
void *client_cookie;
|
2013-07-26 07:00:15 +00:00
|
|
|
struct compr_gapless_mdata gapless_mdata;
|
|
|
|
int send_new_metadata;
|
2015-07-24 08:45:05 +00:00
|
|
|
bool send_next_track_params;
|
|
|
|
bool is_compr_metadata_avail;
|
2014-08-04 21:23:35 +00:00
|
|
|
unsigned int bit_width;
|
2016-06-28 09:04:17 +00:00
|
|
|
uint32_t hal_fragment_size;
|
|
|
|
audio_format_t hal_ip_format;
|
|
|
|
audio_format_t hal_op_format;
|
|
|
|
void *convert_buffer;
|
2013-01-18 00:50:22 +00:00
|
|
|
|
2016-06-28 01:33:40 +00:00
|
|
|
bool realtime;
|
|
|
|
int af_period_multiplier;
|
2013-01-18 00:50:22 +00:00
|
|
|
struct audio_device *dev;
|
2017-05-25 11:55:30 +00:00
|
|
|
card_status_t card_status;
|
2017-01-30 12:05:36 +00:00
|
|
|
|
2016-09-12 06:12:10 +00:00
|
|
|
void* qaf_stream_handle;
|
|
|
|
pthread_cond_t qaf_offload_cond;
|
|
|
|
pthread_t qaf_offload_thread;
|
|
|
|
struct listnode qaf_offload_cmd_list;
|
2016-11-04 13:51:12 +00:00
|
|
|
uint32_t platform_latency;
|
2017-01-30 12:05:36 +00:00
|
|
|
render_mode_t render_mode;
|
2017-04-17 10:13:48 +00:00
|
|
|
bool drift_correction_enabled;
|
2017-01-30 12:05:36 +00:00
|
|
|
|
2017-04-27 12:24:30 +00:00
|
|
|
struct audio_out_channel_map_param channel_map_param; /* input channel map */
|
2016-11-04 13:51:12 +00:00
|
|
|
audio_offload_info_t info;
|
2017-05-18 15:27:40 +00:00
|
|
|
int started;
|
2017-01-05 08:35:35 +00:00
|
|
|
qahwi_stream_out_t qahwi_out;
|
2017-06-09 06:58:37 +00:00
|
|
|
|
|
|
|
bool is_iec61937_info_available;
|
2017-05-26 12:52:46 +00:00
|
|
|
bool a2dp_compress_mute;
|
|
|
|
float volume_l;
|
|
|
|
float volume_r;
|
2018-04-13 12:28:24 +00:00
|
|
|
bool apply_volume;
|
2017-01-13 22:56:59 +00:00
|
|
|
|
|
|
|
char pm_qos_mixer_path[MAX_MIXER_PATH_LEN];
|
2017-11-07 02:29:44 +00:00
|
|
|
int hal_output_suspend_supported;
|
|
|
|
int dynamic_pm_qos_config_supported;
|
2017-08-18 12:00:46 +00:00
|
|
|
bool stream_config_changed;
|
2017-07-06 14:18:56 +00:00
|
|
|
mix_matrix_params_t pan_scale_params;
|
|
|
|
mix_matrix_params_t downmix_params;
|
2018-04-26 05:58:38 +00:00
|
|
|
bool set_dual_mono;
|
2019-02-20 09:03:45 +00:00
|
|
|
bool prev_card_status_offline;
|
2018-12-18 22:23:57 +00:00
|
|
|
|
|
|
|
error_log_t *error_log;
|
2013-01-18 00:50:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct stream_in {
|
|
|
|
struct audio_stream_in stream;
|
2013-02-27 22:31:02 +00:00
|
|
|
pthread_mutex_t lock; /* see note below on mutex acquisition order */
|
2015-09-28 22:23:06 +00:00
|
|
|
pthread_mutex_t pre_lock; /* acquire before lock to avoid DOS by playback thread */
|
2013-01-18 00:50:22 +00:00
|
|
|
struct pcm_config config;
|
|
|
|
struct pcm *pcm;
|
|
|
|
int standby;
|
|
|
|
int source;
|
|
|
|
int pcm_device_id;
|
2014-09-05 20:51:35 +00:00
|
|
|
audio_devices_t device;
|
2013-01-18 00:50:22 +00:00
|
|
|
audio_channel_mask_t channel_mask;
|
|
|
|
audio_usecase_t usecase;
|
2013-04-16 22:55:53 +00:00
|
|
|
bool enable_aec;
|
2013-11-07 23:42:19 +00:00
|
|
|
bool enable_ns;
|
2013-11-15 23:21:40 +00:00
|
|
|
audio_format_t format;
|
2014-09-09 23:06:42 +00:00
|
|
|
audio_io_handle_t capture_handle;
|
2015-06-15 17:35:19 +00:00
|
|
|
audio_input_flags_t flags;
|
2016-12-01 17:57:29 +00:00
|
|
|
char profile[MAX_STREAM_PROFILE_STR_LEN];
|
2014-09-09 23:06:42 +00:00
|
|
|
bool is_st_session;
|
2015-02-05 22:27:59 +00:00
|
|
|
bool is_st_session_active;
|
2016-12-09 16:30:40 +00:00
|
|
|
unsigned int sample_rate;
|
|
|
|
unsigned int bit_width;
|
2016-06-28 01:33:40 +00:00
|
|
|
bool realtime;
|
|
|
|
int af_period_multiplier;
|
2016-10-13 10:41:03 +00:00
|
|
|
struct stream_app_type_cfg app_type_cfg;
|
2016-10-25 12:32:58 +00:00
|
|
|
void *cin_extn;
|
|
|
|
qahwi_stream_in_t qahwi_in;
|
2016-10-13 10:41:03 +00:00
|
|
|
|
2013-01-18 00:50:22 +00:00
|
|
|
struct audio_device *dev;
|
2017-05-25 11:55:30 +00:00
|
|
|
card_status_t card_status;
|
2017-06-01 00:16:49 +00:00
|
|
|
int capture_started;
|
2017-08-01 01:55:17 +00:00
|
|
|
|
|
|
|
/* Array of supported channel mask configurations. +1 so that the last entry is always 0 */
|
|
|
|
audio_channel_mask_t supported_channel_masks[MAX_SUPPORTED_CHANNEL_MASKS + 1];
|
|
|
|
audio_format_t supported_formats[MAX_SUPPORTED_FORMATS + 1];
|
|
|
|
uint32_t supported_sample_rates[MAX_SUPPORTED_SAMPLE_RATES + 1];
|
2018-12-18 22:23:57 +00:00
|
|
|
|
|
|
|
int64_t frames_read; /* total frames read, not cleared when entering standby */
|
|
|
|
int64_t frames_muted; /* total frames muted, not cleared when entering standby */
|
|
|
|
|
|
|
|
error_log_t *error_log;
|
2013-01-18 00:50:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PCM_PLAYBACK,
|
|
|
|
PCM_CAPTURE,
|
2013-11-15 23:21:40 +00:00
|
|
|
VOICE_CALL,
|
2013-11-05 23:57:39 +00:00
|
|
|
VOIP_CALL,
|
2017-05-19 09:56:33 +00:00
|
|
|
PCM_HFP_CALL,
|
2018-08-28 08:51:37 +00:00
|
|
|
TRANSCODE_LOOPBACK_RX,
|
2018-12-18 22:23:57 +00:00
|
|
|
TRANSCODE_LOOPBACK_TX,
|
|
|
|
USECASE_TYPE_MAX
|
2013-01-18 00:50:22 +00:00
|
|
|
} usecase_type_t;
|
|
|
|
|
2013-03-01 04:54:57 +00:00
|
|
|
union stream_ptr {
|
|
|
|
struct stream_in *in;
|
|
|
|
struct stream_out *out;
|
2017-05-19 09:56:33 +00:00
|
|
|
struct stream_inout *inout;
|
2013-03-01 04:54:57 +00:00
|
|
|
};
|
|
|
|
|
2013-01-18 00:50:22 +00:00
|
|
|
struct audio_usecase {
|
2013-02-28 07:01:21 +00:00
|
|
|
struct listnode list;
|
2013-01-18 00:50:22 +00:00
|
|
|
audio_usecase_t id;
|
|
|
|
usecase_type_t type;
|
|
|
|
audio_devices_t devices;
|
2013-03-11 06:50:28 +00:00
|
|
|
snd_device_t out_snd_device;
|
|
|
|
snd_device_t in_snd_device;
|
2016-10-13 10:41:03 +00:00
|
|
|
struct stream_app_type_cfg out_app_type_cfg;
|
|
|
|
struct stream_app_type_cfg in_app_type_cfg;
|
2013-03-01 04:54:57 +00:00
|
|
|
union stream_ptr stream;
|
2013-01-18 00:50:22 +00:00
|
|
|
};
|
|
|
|
|
2014-03-10 21:43:05 +00:00
|
|
|
struct stream_format {
|
|
|
|
struct listnode list;
|
|
|
|
audio_format_t format;
|
|
|
|
};
|
|
|
|
|
2014-08-01 21:52:58 +00:00
|
|
|
struct stream_sample_rate {
|
|
|
|
struct listnode list;
|
|
|
|
uint32_t sample_rate;
|
|
|
|
};
|
|
|
|
|
2016-10-13 10:41:03 +00:00
|
|
|
typedef union {
|
|
|
|
audio_output_flags_t out_flags;
|
|
|
|
audio_input_flags_t in_flags;
|
|
|
|
} audio_io_flags_t;
|
|
|
|
|
|
|
|
struct streams_io_cfg {
|
2014-03-10 21:43:05 +00:00
|
|
|
struct listnode list;
|
2016-10-13 10:41:03 +00:00
|
|
|
audio_io_flags_t flags;
|
2016-12-01 17:57:29 +00:00
|
|
|
char profile[MAX_STREAM_PROFILE_STR_LEN];
|
2014-03-10 21:43:05 +00:00
|
|
|
struct listnode format_list;
|
2014-08-01 21:52:58 +00:00
|
|
|
struct listnode sample_rate_list;
|
2014-03-10 21:43:05 +00:00
|
|
|
struct stream_app_type_cfg app_type_cfg;
|
|
|
|
};
|
|
|
|
|
2015-06-15 17:35:19 +00:00
|
|
|
typedef void* (*adm_init_t)();
|
|
|
|
typedef void (*adm_deinit_t)(void *);
|
|
|
|
typedef void (*adm_register_output_stream_t)(void *, audio_io_handle_t, audio_output_flags_t);
|
|
|
|
typedef void (*adm_register_input_stream_t)(void *, audio_io_handle_t, audio_input_flags_t);
|
|
|
|
typedef void (*adm_deregister_stream_t)(void *, audio_io_handle_t);
|
|
|
|
typedef void (*adm_request_focus_t)(void *, audio_io_handle_t);
|
|
|
|
typedef void (*adm_abandon_focus_t)(void *, audio_io_handle_t);
|
2016-06-28 01:33:40 +00:00
|
|
|
typedef void (*adm_set_config_t)(void *, audio_io_handle_t,
|
|
|
|
struct pcm *,
|
|
|
|
struct pcm_config *);
|
|
|
|
typedef void (*adm_request_focus_v2_t)(void *, audio_io_handle_t, long);
|
|
|
|
typedef bool (*adm_is_noirq_avail_t)(void *, int, int, int);
|
|
|
|
typedef void (*adm_on_routing_change_t)(void *, audio_io_handle_t);
|
2015-06-15 17:35:19 +00:00
|
|
|
|
2013-01-18 00:50:22 +00:00
|
|
|
struct audio_device {
|
|
|
|
struct audio_hw_device device;
|
2013-02-27 22:31:02 +00:00
|
|
|
pthread_mutex_t lock; /* see note below on mutex acquisition order */
|
2019-03-05 15:39:45 +00:00
|
|
|
pthread_mutex_t cal_lock;
|
2013-01-18 00:50:22 +00:00
|
|
|
struct mixer *mixer;
|
|
|
|
audio_mode_t mode;
|
|
|
|
audio_devices_t out_device;
|
2013-02-15 03:04:54 +00:00
|
|
|
struct stream_in *active_input;
|
2013-03-01 04:54:57 +00:00
|
|
|
struct stream_out *primary_output;
|
2014-09-05 20:51:35 +00:00
|
|
|
struct stream_out *voice_tx_output;
|
|
|
|
struct stream_out *current_call_output;
|
2013-01-18 00:50:22 +00:00
|
|
|
bool bluetooth_nrec;
|
|
|
|
bool screen_off;
|
2013-05-14 22:27:20 +00:00
|
|
|
int *snd_dev_ref_cnt;
|
2013-02-28 07:01:21 +00:00
|
|
|
struct listnode usecase_list;
|
2014-03-10 21:43:05 +00:00
|
|
|
struct listnode streams_output_cfg_list;
|
2016-10-13 10:41:03 +00:00
|
|
|
struct listnode streams_input_cfg_list;
|
2013-01-18 00:50:22 +00:00
|
|
|
struct audio_route *audio_route;
|
|
|
|
int acdb_settings;
|
2013-05-24 23:55:17 +00:00
|
|
|
bool speaker_lr_swap;
|
2013-10-01 22:49:05 +00:00
|
|
|
struct voice voice;
|
2013-10-06 19:52:49 +00:00
|
|
|
unsigned int cur_hdmi_channels;
|
2016-04-13 18:54:02 +00:00
|
|
|
audio_format_t cur_hdmi_format;
|
|
|
|
unsigned int cur_hdmi_sample_rate;
|
|
|
|
unsigned int cur_hdmi_bit_width;
|
2014-02-14 22:45:49 +00:00
|
|
|
unsigned int cur_wfd_channels;
|
2014-07-29 22:22:21 +00:00
|
|
|
bool bt_wb_speech_enabled;
|
2016-04-13 01:56:03 +00:00
|
|
|
bool allow_afe_proxy_usage;
|
2018-04-13 22:29:54 +00:00
|
|
|
bool is_charging; // from battery listener
|
2018-02-22 01:12:00 +00:00
|
|
|
bool mic_break_enabled;
|
2018-12-18 22:23:57 +00:00
|
|
|
bool enable_hfp;
|
|
|
|
bool mic_muted;
|
|
|
|
bool enable_voicerx;
|
2019-01-30 23:55:40 +00:00
|
|
|
unsigned int num_va_sessions;
|
2013-01-18 00:50:22 +00:00
|
|
|
|
2013-12-04 19:57:47 +00:00
|
|
|
int snd_card;
|
2017-05-25 11:55:30 +00:00
|
|
|
card_status_t card_status;
|
2015-02-20 02:19:36 +00:00
|
|
|
unsigned int cur_codec_backend_samplerate;
|
|
|
|
unsigned int cur_codec_backend_bit_width;
|
2015-05-13 05:22:34 +00:00
|
|
|
bool is_channel_status_set;
|
2013-05-14 22:27:20 +00:00
|
|
|
void *platform;
|
2018-12-18 22:23:57 +00:00
|
|
|
void *extspk;
|
2014-04-02 04:03:10 +00:00
|
|
|
unsigned int offload_usecases_state;
|
2018-12-18 11:10:52 +00:00
|
|
|
unsigned int pcm_record_uc_state;
|
2013-09-13 00:45:53 +00:00
|
|
|
void *visualizer_lib;
|
2013-11-13 21:31:50 +00:00
|
|
|
int (*visualizer_start_output)(audio_io_handle_t, int);
|
|
|
|
int (*visualizer_stop_output)(audio_io_handle_t, int);
|
|
|
|
void *offload_effects_lib;
|
2016-05-11 13:53:33 +00:00
|
|
|
int (*offload_effects_start_output)(audio_io_handle_t, int, struct mixer *);
|
2013-11-13 21:31:50 +00:00
|
|
|
int (*offload_effects_stop_output)(audio_io_handle_t, int);
|
2014-05-11 19:35:52 +00:00
|
|
|
|
2014-11-23 03:34:13 +00:00
|
|
|
int (*offload_effects_set_hpx_state)(bool);
|
2015-06-15 17:35:19 +00:00
|
|
|
|
|
|
|
void *adm_data;
|
|
|
|
void *adm_lib;
|
|
|
|
adm_init_t adm_init;
|
|
|
|
adm_deinit_t adm_deinit;
|
|
|
|
adm_register_input_stream_t adm_register_input_stream;
|
|
|
|
adm_register_output_stream_t adm_register_output_stream;
|
|
|
|
adm_deregister_stream_t adm_deregister_stream;
|
|
|
|
adm_request_focus_t adm_request_focus;
|
|
|
|
adm_abandon_focus_t adm_abandon_focus;
|
2016-06-28 01:33:40 +00:00
|
|
|
adm_set_config_t adm_set_config;
|
|
|
|
adm_request_focus_v2_t adm_request_focus_v2;
|
|
|
|
adm_is_noirq_avail_t adm_is_noirq_avail;
|
|
|
|
adm_on_routing_change_t adm_on_routing_change;
|
2015-09-04 08:09:26 +00:00
|
|
|
|
|
|
|
void (*offload_effects_get_parameters)(struct str_parms *,
|
|
|
|
struct str_parms *);
|
|
|
|
void (*offload_effects_set_parameters)(struct str_parms *);
|
2015-09-14 17:57:35 +00:00
|
|
|
|
|
|
|
bool multi_offload_enable;
|
2015-09-16 20:23:25 +00:00
|
|
|
int perf_lock_handle;
|
|
|
|
int perf_lock_opts[MAX_PERF_LOCK_OPTS];
|
|
|
|
int perf_lock_opts_size;
|
2015-11-05 09:12:20 +00:00
|
|
|
bool native_playback_enabled;
|
2016-08-17 19:02:06 +00:00
|
|
|
bool asrc_mode_enabled;
|
2016-10-25 12:32:58 +00:00
|
|
|
qahwi_device_t qahwi_dev;
|
2017-02-21 22:20:12 +00:00
|
|
|
bool vr_audio_mode_enabled;
|
2017-08-03 07:52:29 +00:00
|
|
|
uint32_t dsp_bit_width_enforce_mode;
|
2017-05-18 15:27:40 +00:00
|
|
|
bool bt_sco_on;
|
2017-07-04 17:18:59 +00:00
|
|
|
struct audio_device_config_param *device_cfg_params;
|
2017-07-06 14:18:56 +00:00
|
|
|
unsigned int interactive_usecase_state;
|
2017-12-04 06:34:26 +00:00
|
|
|
bool dp_allowed_for_voice;
|
2014-11-24 20:39:14 +00:00
|
|
|
void *ext_hw_plugin;
|
2018-12-18 22:23:57 +00:00
|
|
|
|
|
|
|
/* logging */
|
|
|
|
snd_device_t last_logged_snd_device[AUDIO_USECASE_MAX][2]; /* [out, in] */
|
|
|
|
|
|
|
|
/* The pcm_params use_case_table is loaded by adev_verify_devices() upon
|
|
|
|
* calling adev_open().
|
|
|
|
*
|
|
|
|
* If an entry is not NULL, it can be used to determine if extended precision
|
|
|
|
* or other capabilities are present for the device corresponding to that usecase.
|
|
|
|
*/
|
|
|
|
struct pcm_params *use_case_table[AUDIO_USECASE_MAX];
|
2013-01-18 00:50:22 +00:00
|
|
|
};
|
|
|
|
|
2013-10-06 21:39:35 +00:00
|
|
|
int select_devices(struct audio_device *adev,
|
|
|
|
audio_usecase_t uc_id);
|
|
|
|
int disable_audio_route(struct audio_device *adev,
|
2014-04-24 18:55:48 +00:00
|
|
|
struct audio_usecase *usecase);
|
2013-10-06 21:39:35 +00:00
|
|
|
int disable_snd_device(struct audio_device *adev,
|
2014-04-24 18:55:48 +00:00
|
|
|
snd_device_t snd_device);
|
2013-10-28 21:06:03 +00:00
|
|
|
int enable_snd_device(struct audio_device *adev,
|
2014-04-24 18:55:48 +00:00
|
|
|
snd_device_t snd_device);
|
|
|
|
|
2013-10-28 21:06:03 +00:00
|
|
|
int enable_audio_route(struct audio_device *adev,
|
2014-04-24 18:55:48 +00:00
|
|
|
struct audio_usecase *usecase);
|
|
|
|
|
2016-01-29 23:49:38 +00:00
|
|
|
struct audio_usecase *get_usecase_from_list(const struct audio_device *adev,
|
2013-10-06 21:39:35 +00:00
|
|
|
audio_usecase_t uc_id);
|
2013-11-22 04:39:59 +00:00
|
|
|
|
2017-04-18 08:53:15 +00:00
|
|
|
struct stream_in *get_next_active_input(const struct audio_device *adev);
|
|
|
|
|
2014-04-02 04:03:10 +00:00
|
|
|
bool is_offload_usecase(audio_usecase_t uc_id);
|
|
|
|
|
2015-11-05 09:12:20 +00:00
|
|
|
bool audio_is_true_native_stream_active(struct audio_device *adev);
|
|
|
|
|
2016-07-19 13:03:53 +00:00
|
|
|
bool audio_is_dsd_native_stream_active(struct audio_device *adev);
|
2016-08-17 19:02:06 +00:00
|
|
|
|
2017-08-03 07:52:29 +00:00
|
|
|
uint32_t adev_get_dsp_bit_width_enforce_mode();
|
|
|
|
|
2014-06-07 00:11:23 +00:00
|
|
|
int pcm_ioctl(struct pcm *pcm, int request, ...);
|
|
|
|
|
2016-01-29 23:49:38 +00:00
|
|
|
audio_usecase_t get_usecase_id_from_usecase_type(const struct audio_device *adev,
|
2015-03-06 22:57:35 +00:00
|
|
|
usecase_type_t type);
|
2014-07-09 10:59:28 +00:00
|
|
|
|
2017-05-26 12:52:46 +00:00
|
|
|
int check_a2dp_restore(struct audio_device *adev, struct stream_out *out, bool restore);
|
|
|
|
|
2016-09-12 06:12:10 +00:00
|
|
|
int adev_open_output_stream(struct audio_hw_device *dev,
|
|
|
|
audio_io_handle_t handle,
|
|
|
|
audio_devices_t devices,
|
|
|
|
audio_output_flags_t flags,
|
|
|
|
struct audio_config *config,
|
|
|
|
struct audio_stream_out **stream_out,
|
|
|
|
const char *address __unused);
|
|
|
|
void adev_close_output_stream(struct audio_hw_device *dev __unused,
|
|
|
|
struct audio_stream_out *stream);
|
|
|
|
|
2017-07-06 14:18:56 +00:00
|
|
|
bool is_interactive_usecase(audio_usecase_t uc_id);
|
|
|
|
|
2013-11-22 04:39:59 +00:00
|
|
|
#define LITERAL_TO_STRING(x) #x
|
|
|
|
#define CHECK(condition) LOG_ALWAYS_FATAL_IF(!(condition), "%s",\
|
|
|
|
__FILE__ ":" LITERAL_TO_STRING(__LINE__)\
|
|
|
|
" ASSERT_FATAL(" #condition ") failed.")
|
|
|
|
|
2013-02-27 22:31:02 +00:00
|
|
|
/*
|
|
|
|
* NOTE: when multiple mutexes have to be acquired, always take the
|
|
|
|
* stream_in or stream_out mutex first, followed by the audio_device mutex.
|
|
|
|
*/
|
|
|
|
|
2013-05-14 22:27:20 +00:00
|
|
|
#endif // QCOM_AUDIO_HW_H
|