blob: c13a1a44ee26d671652d308b449ee29661aaa59e [file] [log] [blame]
Sidipotu Ashok404f26d2017-10-10 22:27:51 +05301/*
2 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
3 * Not a Contribution.
4 *
5 * Copyright (C) 2011 The Android Open Source Project *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#include <sys/cdefs.h>
20#include <stdint.h>
21
22#ifndef QTI_AUDIO_HAL_DEFS_H
23#define QTI_AUDIO_HAL_DEFS_H
24
25__BEGIN_DECLS
26
27/**************************************/
28
29/**
30 * standard audio parameters that the HAL may need to handle
31 */
32
33/**
34 * audio device parameters
35 */
36
37/* BT SCO Noise Reduction + Echo Cancellation parameters */
38#define QAHW_PARAMETER_KEY_BT_NREC "bt_headset_nrec"
39#define QAHW_PARAMETER_VALUE_ON "on"
40#define QAHW_PARAMETER_VALUE_OFF "off"
41
42/* TTY mode selection */
43#define QAHW_PARAMETER_KEY_TTY_MODE "tty_mode"
44#define QAHW_PARAMETER_VALUE_TTY_OFF "tty_off"
45#define QAHW_PARAMETER_VALUE_TTY_VCO "tty_vco"
46#define QAHW_PARAMETER_VALUE_TTY_HCO "tty_hco"
47#define QAHW_PARAMETER_VALUE_TTY_FULL "tty_full"
48
49/* Hearing Aid Compatibility - Telecoil (HAC-T) mode on/off
50 Strings must be in sync with CallFeaturesSetting.java */
51#define QAHW_PARAMETER_KEY_HAC "HACSetting"
52#define QAHW_PARAMETER_VALUE_HAC_ON "ON"
53#define QAHW_PARAMETER_VALUE_HAC_OFF "OFF"
54
55/* A2DP sink address set by framework */
56#define QAHW_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address"
57
58/* A2DP source address set by framework */
59#define QAHW_PARAMETER_A2DP_SOURCE_ADDRESS "a2dp_source_address"
60
61/* Screen state */
62#define QAHW_PARAMETER_KEY_SCREEN_STATE "screen_state"
63
64/* Bluetooth SCO wideband */
65#define QAHW_PARAMETER_KEY_BT_SCO_WB "bt_wbs"
66
67/* Get a new HW synchronization source identifier.
68 * Return a valid source (positive integer) or AUDIO_HW_SYNC_INVALID if an error occurs
69 * or no HW sync is available. */
70#define QAHW_PARAMETER_HW_AV_SYNC "hw_av_sync"
71
72/**
73 * audio stream parameters
74 */
75
76#define QAHW_PARAMETER_STREAM_ROUTING "routing" /* audio_devices_t */
77#define QAHW_PARAMETER_STREAM_FORMAT "format" /* audio_format_t */
78#define QAHW_PARAMETER_STREAM_CHANNELS "channels" /* audio_channel_mask_t */
79#define QAHW_PARAMETER_STREAM_FRAME_COUNT "frame_count" /* size_t */
80#define QAHW_PARAMETER_STREAM_INPUT_SOURCE "input_source" /* audio_source_t */
81#define QAHW_PARAMETER_STREAM_SAMPLING_RATE "sampling_rate" /* uint32_t */
82
83#define QAHW_PARAMETER_DEVICE_CONNECT "connect" /* audio_devices_t */
84#define QAHW_PARAMETER_DEVICE_DISCONNECT "disconnect" /* audio_devices_t */
85
86/* Query supported formats. The response is a '|' separated list of strings from
87 * audio_format_t enum e.g: "sup_formats=AUDIO_FORMAT_PCM_16_BIT" */
88#define QAHW_PARAMETER_STREAM_SUP_FORMATS "sup_formats"
89
90/* Query supported channel masks. The response is a '|' separated list of
91 * strings from audio_channel_mask_t enum
92 * e.g: "sup_channels=AUDIO_CHANNEL_OUT_STEREO|AUDIO_CHANNEL_OUT_MONO" */
93#define QAHW_PARAMETER_STREAM_SUP_CHANNELS "sup_channels"
94
95/* Query supported sampling rates. The response is a '|' separated list of
96 * integer values e.g: "sup_sampling_rates=44100|48000" */
97#define QAHW_PARAMETER_STREAM_SUP_SAMPLING_RATES "sup_sampling_rates"
98
99/* Set the HW synchronization source for an output stream. */
100#define QAHW_PARAMETER_STREAM_HW_AV_SYNC "hw_av_sync"
101
102/* Enable mono audio playback if 1, else should be 0. */
103#define QAHW_PARAMETER_MONO_OUTPUT "mono_output"
104
105/**
106 * audio codec parameters
107 */
108
109#define QAHW_OFFLOAD_CODEC_PARAMS "music_offload_codec_param"
110#define QAHW_OFFLOAD_CODEC_BIT_PER_SAMPLE "music_offload_bit_per_sample"
111#define QAHW_OFFLOAD_CODEC_BIT_RATE "music_offload_bit_rate"
112#define QAHW_OFFLOAD_CODEC_AVG_BIT_RATE "music_offload_avg_bit_rate"
113#define QAHW_OFFLOAD_CODEC_ID "music_offload_codec_id"
114#define QAHW_OFFLOAD_CODEC_BLOCK_ALIGN "music_offload_block_align"
115#define QAHW_OFFLOAD_CODEC_SAMPLE_RATE "music_offload_sample_rate"
116#define QAHW_OFFLOAD_CODEC_ENCODE_OPTION "music_offload_encode_option"
117#define QAHW_OFFLOAD_CODEC_NUM_CHANNEL "music_offload_num_channels"
118#define QAHW_OFFLOAD_CODEC_DOWN_SAMPLING "music_offload_down_sampling"
119#define QAHW_OFFLOAD_CODEC_DELAY_SAMPLES "delay_samples"
120#define QAHW_OFFLOAD_CODEC_PADDING_SAMPLES "padding_samples"
121
122/**
123 * extended audio codec parameters
124 */
125
126#define QAHW_OFFLOAD_CODEC_WMA_FORMAT_TAG "music_offload_wma_format_tag"
127#define QAHW_OFFLOAD_CODEC_WMA_BLOCK_ALIGN "music_offload_wma_block_align"
128#define QAHW_OFFLOAD_CODEC_WMA_BIT_PER_SAMPLE "music_offload_wma_bit_per_sample"
129#define QAHW_OFFLOAD_CODEC_WMA_CHANNEL_MASK "music_offload_wma_channel_mask"
130#define QAHW_OFFLOAD_CODEC_WMA_ENCODE_OPTION "music_offload_wma_encode_option"
131#define QAHW_OFFLOAD_CODEC_WMA_ENCODE_OPTION1 "music_offload_wma_encode_option1"
132#define QAHW_OFFLOAD_CODEC_WMA_ENCODE_OPTION2 "music_offload_wma_encode_option2"
133
134#define QAHW_OFFLOAD_CODEC_FLAC_MIN_BLK_SIZE "music_offload_flac_min_blk_size"
135#define QAHW_OFFLOAD_CODEC_FLAC_MAX_BLK_SIZE "music_offload_flac_max_blk_size"
136#define QAHW_OFFLOAD_CODEC_FLAC_MIN_FRAME_SIZE "music_offload_flac_min_frame_size"
137#define QAHW_OFFLOAD_CODEC_FLAC_MAX_FRAME_SIZE "music_offload_flac_max_frame_size"
138
139#define QAHW_OFFLOAD_CODEC_ALAC_FRAME_LENGTH "music_offload_alac_frame_length"
140#define QAHW_OFFLOAD_CODEC_ALAC_COMPATIBLE_VERSION "music_offload_alac_compatible_version"
141#define QAHW_OFFLOAD_CODEC_ALAC_BIT_DEPTH "music_offload_alac_bit_depth"
142#define QAHW_OFFLOAD_CODEC_ALAC_PB "music_offload_alac_pb"
143#define QAHW_OFFLOAD_CODEC_ALAC_MB "music_offload_alac_mb"
144#define QAHW_OFFLOAD_CODEC_ALAC_KB "music_offload_alac_kb"
145#define QAHW_OFFLOAD_CODEC_ALAC_NUM_CHANNELS "music_offload_alac_num_channels"
146#define QAHW_OFFLOAD_CODEC_ALAC_MAX_RUN "music_offload_alac_max_run"
147#define QAHW_OFFLOAD_CODEC_ALAC_MAX_FRAME_BYTES "music_offload_alac_max_frame_bytes"
148#define QAHW_OFFLOAD_CODEC_ALAC_AVG_BIT_RATE "music_offload_alac_avg_bit_rate"
149#define QAHW_OFFLOAD_CODEC_ALAC_SAMPLING_RATE "music_offload_alac_sampling_rate"
150#define QAHW_OFFLOAD_CODEC_ALAC_CHANNEL_LAYOUT_TAG "music_offload_alac_channel_layout_tag"
151
152#define QAHW_OFFLOAD_CODEC_APE_COMPATIBLE_VERSION "music_offload_ape_compatible_version"
153#define QAHW_OFFLOAD_CODEC_APE_COMPRESSION_LEVEL "music_offload_ape_compression_level"
154#define QAHW_OFFLOAD_CODEC_APE_FORMAT_FLAGS "music_offload_ape_format_flags"
155#define QAHW_OFFLOAD_CODEC_APE_BLOCKS_PER_FRAME "music_offload_ape_blocks_per_frame"
156#define QAHW_OFFLOAD_CODEC_APE_FINAL_FRAME_BLOCKS "music_offload_ape_final_frame_blocks"
157#define QAHW_OFFLOAD_CODEC_APE_TOTAL_FRAMES "music_offload_ape_total_frames"
158#define QAHW_OFFLOAD_CODEC_APE_BITS_PER_SAMPLE "music_offload_ape_bits_per_sample"
159#define QAHW_OFFLOAD_CODEC_APE_NUM_CHANNELS "music_offload_ape_num_channels"
160#define QAHW_OFFLOAD_CODEC_APE_SAMPLE_RATE "music_offload_ape_sample_rate"
161#define QAHW_OFFLOAD_CODEC_APE_SEEK_TABLE_PRESENT "music_offload_seek_table_present"
162
163#define QAHW_OFFLOAD_CODEC_VORBIS_BITSTREAM_FMT "music_offload_vorbis_bitstream_fmt"
164
165/* Set or Query stream profile type */
166#define QAHW_PARAMETER_STREAM_PROFILE "audio_stream_profile"
167
168/* audio input flags for compress and timestamp mode.
169 * check other input flags defined in audio.h for conflicts
170 */
171#define QAHW_INPUT_FLAG_TIMESTAMP 0x80000000
172#define QAHW_INPUT_FLAG_COMPRESS 0x40000000
173
174/* Query fm volume */
175#define QAHW_PARAMETER_KEY_FM_VOLUME "fm_volume"
176
177/* Query if a2dp is supported */
178#define QAHW_PARAMETER_KEY_HANDLE_A2DP_DEVICE "isA2dpDeviceSupported"
179
180#define MAX_OUT_CHANNELS 8
181#define MAX_INP_CHANNELS 8
182
183#define QAHW_PCM_CHANNEL_FL 1 /* Front left channel. */
184#define QAHW_PCM_CHANNEL_FR 2 /* Front right channel. */
185#define QAHW_PCM_CHANNEL_FC 3 /* Front center channel. */
186#define QAHW_PCM_CHANNEL_LS 4 /* Left surround channel. */
187#define QAHW_PCM_CHANNEL_RS 5 /* Right surround channel. */
188#define QAHW_PCM_CHANNEL_LFE 6 /* Low frequency effect channel. */
189#define QAHW_PCM_CHANNEL_CS 7 /* Center surround channel; Rear center channel. */
190#define QAHW_PCM_CHANNEL_LB 8 /* Left back channel; Rear left channel. */
191#define QAHW_PCM_CHANNEL_RB 9 /* Right back channel; Rear right channel. */
192#define QAHW_PCM_CHANNEL_TS 10 /* Top surround channel. */
193#define QAHW_PCM_CHANNEL_CVH 11 /* Center vertical height channel. */
194#define QAHW_PCM_CHANNEL_MS 12 /* Mono surround channel. */
195#define QAHW_PCM_CHANNEL_FLC 13 /* Front left of center. */
196#define QAHW_PCM_CHANNEL_FRC 14 /* Front right of center. */
197#define QAHW_PCM_CHANNEL_RLC 15 /* Rear left of center. */
198#define QAHW_PCM_CHANNEL_RRC 16 /* Rear right of center. */
199
200/* type of asynchronous write callback events. Mutually exclusive */
201typedef enum {
202 QAHW_STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */
203 QAHW_STREAM_CBK_EVENT_DRAIN_READY, /* drain completed */
204 QAHW_STREAM_CBK_EVENT_ERROR, /* stream hit some error */
205
206 QAHW_STREAM_CBK_EVENT_ADSP = 0x100 /* callback event from ADSP PP,
207 * corresponding payload will be
208 * sent as is to the client
209 */
210} qahw_stream_callback_event_t;
211
212typedef int qahw_stream_callback_t(qahw_stream_callback_event_t event,
213 void *param,
214 void *cookie);
215
216/* type of drain requested to audio_stream_out->drain(). Mutually exclusive */
217typedef enum {
218 QAHW_DRAIN_ALL, /* drain() returns when all data has been played */
219 QAHW_DRAIN_EARLY_NOTIFY /* drain() returns a short time before all data
220 from the current track has been played to
221 give time for gapless track switch */
222} qahw_drain_type_t;
223
224/* meta data flags */
225/*TBD: Extend this based on stb requirement*/
226typedef enum {
227 QAHW_META_DATA_FLAGS_NONE = 0,
228} qahw_meta_data_flags_t;
229
230typedef struct {
231 const void *buffer; /* write buffer pointer */
232 size_t bytes; /* size of buffer */
233 size_t offset; /* offset in buffer from where valid byte starts */
234 int64_t *timestamp; /* timestmap */
235 qahw_meta_data_flags_t flags; /* meta data flags */
236 uint32_t reserved[64]; /*reserved for future */
237} qahw_out_buffer_t;
238
239typedef struct {
240 void *buffer; /* read buffer pointer */
241 size_t bytes; /* size of buffer */
242 size_t offset; /* offset in buffer from where valid byte starts */
243 int64_t *timestamp; /* timestmap */
244 uint32_t reserved[64]; /*reserved for future */
245} qahw_in_buffer_t;
246
247#define MAX_SECTORS 8
248
249struct qahw_source_tracking_param {
250 uint8_t vad[MAX_SECTORS];
251 uint16_t doa_speech;
252 uint16_t doa_noise[3];
253 uint8_t polar_activity[360];
254};
255
256struct qahw_sound_focus_param {
257 uint16_t start_angle[MAX_SECTORS];
258 uint8_t enable[MAX_SECTORS];
259 uint16_t gain_step;
260};
261
262struct aptx_dec_bt_addr {
263 uint32_t nap;
264 uint32_t uap;
265 uint32_t lap;
266};
267
268struct qahw_aptx_dec_param {
269 struct aptx_dec_bt_addr bt_addr;
270};
271
272struct qahw_avt_device_drift_param {
273 /* Flag to indicate if resync is required on the client side for
274 * drift correction. Flag is set to TRUE for the first get_param response
275 * after device interface starts. This flag value can be used by client
276 * to identify if device interface restart has happened and if any
277 * re-sync is required at their end for drift correction.
278 */
279 uint32_t resync_flag;
280 /* Accumulated drift value in microseconds.
281 * Positive drift value indicates AV timer is running faster than device.
282 * Negative drift value indicates AV timer is running slower than device.
283 */
284 int32_t avt_device_drift_value;
285 /* 64-bit absolute timestamp of reference */
286 uint64_t ref_timer_abs_ts;
287};
288
289/*use these for setting infine window.i.e free run mode */
290#define QAHW_MAX_RENDER_START_WINDOW 0x8000000000000000
291#define QAHW_MAX_RENDER_END_WINDOW 0x7FFFFFFFFFFFFFFF
292
293struct qahw_out_render_window_param {
294 uint64_t render_ws; /* render window start value microseconds*/
295 uint64_t render_we; /* render window end value microseconds*/
296};
297
298struct qahw_out_start_delay_param {
299 uint64_t start_delay; /* session start delay in microseconds*/
300};
301
302struct qahw_out_enable_drift_correction {
303 bool enable; /* enable drift correction*/
304};
305
306struct qahw_out_correct_drift {
307 /*
308 * adjust time in microseconds, a positive value
309 * to advance the clock or a negative value to
310 * delay the clock.
311 */
312 int64_t adjust_time;
313};
314
315#define QAHW_MAX_ADSP_STREAM_CMD_PAYLOAD_LEN 512
316
317typedef enum {
318 QAHW_STREAM_PP_EVENT = 0,
319 QAHW_STREAM_ENCDEC_EVENT = 1,
320} qahw_event_id;
321
322/* payload format for HAL parameter
323 * QAHW_PARAM_ADSP_STREAM_CMD
324 */
325struct qahw_adsp_event {
326 qahw_event_id event_type; /* type of the event */
327 uint32_t payload_length; /* length in bytes of the payload */
328 void *payload; /* the actual payload */
329};
330
331struct qahw_out_channel_map_param {
332 uint8_t channels; /* Input Channels */
333 uint8_t channel_map[AUDIO_CHANNEL_COUNT_MAX]; /* Input Channel Map */
334};
335
336struct qahw_device_cfg_param {
337 uint32_t sample_rate;
338 uint32_t channels;
339 uint32_t bit_width;
340 audio_format_t format;
341 audio_devices_t device;
342 uint8_t channel_map[AUDIO_CHANNEL_COUNT_MAX];
343 uint16_t channel_allocation;
344};
345
346typedef struct qahw_mix_matrix_params {
347 uint16_t num_output_channels;
348 uint16_t num_input_channels;
349 uint8_t has_output_channel_map;
350 uint32_t output_channel_map[AUDIO_CHANNEL_COUNT_MAX];
351 uint8_t has_input_channel_map;
352 uint32_t input_channel_map[AUDIO_CHANNEL_COUNT_MAX];
353 uint8_t has_mixer_coeffs;
354 float mixer_coeffs[AUDIO_CHANNEL_COUNT_MAX][AUDIO_CHANNEL_COUNT_MAX];
355} qahw_mix_matrix_params_t;
356
357typedef union {
358 struct qahw_source_tracking_param st_params;
359 struct qahw_sound_focus_param sf_params;
360 struct qahw_aptx_dec_param aptx_params;
361 struct qahw_avt_device_drift_param drift_params;
362 struct qahw_out_render_window_param render_window_params;
363 struct qahw_out_start_delay_param start_delay;
364 struct qahw_out_enable_drift_correction drift_enable_param;
365 struct qahw_out_correct_drift drift_correction_param;
366 struct qahw_adsp_event adsp_event_params;
367 struct qahw_out_channel_map_param channel_map_params;
368 struct qahw_device_cfg_param device_cfg_params;
369 struct qahw_mix_matrix_params mix_matrix_params;
370} qahw_param_payload;
371
372typedef enum {
373 QAHW_PARAM_SOURCE_TRACK,
374 QAHW_PARAM_SOUND_FOCUS,
375 QAHW_PARAM_APTX_DEC,
376 QAHW_PARAM_AVT_DEVICE_DRIFT, /* PARAM to query AV timer vs device drift */
377 QAHW_PARAM_OUT_RENDER_WINDOW, /* PARAM to set render window */
378 QAHW_PARAM_OUT_START_DELAY, /* PARAM to set session start delay*/
379 /* enable adsp drift correction this must be called before out_write */
380 QAHW_PARAM_OUT_ENABLE_DRIFT_CORRECTION,
381 /* param to set drift value to be adjusted by dsp */
382 QAHW_PARAM_OUT_CORRECT_DRIFT,
383 QAHW_PARAM_ADSP_STREAM_CMD,
384 QAHW_PARAM_OUT_CHANNEL_MAP, /* PARAM to set i/p channel map */
385 QAHW_PARAM_DEVICE_CONFIG, /* PARAM to set device config */
386 QAHW_PARAM_OUT_MIX_MATRIX_PARAMS,
387 QAHW_PARAM_CH_MIX_MATRIX_PARAMS,
388} qahw_param_id;
389
390__END_DECLS
391
392#endif // QTI_AUDIO_HAL_DEFS_H
393