blob: 755553b2f0af8c5d01797170bfe1c35ae01d98ec [file] [log] [blame]
Sidipotu Ashok404f26d2017-10-10 22:27:51 +05301/*
Ralf Herzaec80262018-07-03 07:08:49 +02002 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
Sidipotu Ashok404f26d2017-10-10 22:27:51 +05303 * 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
Ralf Herzaec80262018-07-03 07:08:49 +0200173#define QAHW_INPUT_FLAG_PASSTHROUGH 0x20000000
Sidipotu Ashok404f26d2017-10-10 22:27:51 +0530174
175/* Query fm volume */
176#define QAHW_PARAMETER_KEY_FM_VOLUME "fm_volume"
177
178/* Query if a2dp is supported */
179#define QAHW_PARAMETER_KEY_HANDLE_A2DP_DEVICE "isA2dpDeviceSupported"
180
181#define MAX_OUT_CHANNELS 8
182#define MAX_INP_CHANNELS 8
183
184#define QAHW_PCM_CHANNEL_FL 1 /* Front left channel. */
185#define QAHW_PCM_CHANNEL_FR 2 /* Front right channel. */
186#define QAHW_PCM_CHANNEL_FC 3 /* Front center channel. */
187#define QAHW_PCM_CHANNEL_LS 4 /* Left surround channel. */
188#define QAHW_PCM_CHANNEL_RS 5 /* Right surround channel. */
189#define QAHW_PCM_CHANNEL_LFE 6 /* Low frequency effect channel. */
190#define QAHW_PCM_CHANNEL_CS 7 /* Center surround channel; Rear center channel. */
191#define QAHW_PCM_CHANNEL_LB 8 /* Left back channel; Rear left channel. */
192#define QAHW_PCM_CHANNEL_RB 9 /* Right back channel; Rear right channel. */
193#define QAHW_PCM_CHANNEL_TS 10 /* Top surround channel. */
194#define QAHW_PCM_CHANNEL_CVH 11 /* Center vertical height channel. */
195#define QAHW_PCM_CHANNEL_MS 12 /* Mono surround channel. */
196#define QAHW_PCM_CHANNEL_FLC 13 /* Front left of center. */
197#define QAHW_PCM_CHANNEL_FRC 14 /* Front right of center. */
198#define QAHW_PCM_CHANNEL_RLC 15 /* Rear left of center. */
199#define QAHW_PCM_CHANNEL_RRC 16 /* Rear right of center. */
Manish Dewangan4affcfe2018-09-10 13:45:57 +0530200#define QAHW_PCM_CHANNEL_LFE2 17 /* Secondary low frequency effect channel. */
201#define QAHW_PCM_CHANNEL_SL 18 /* Side left channel. */
202#define QAHW_PCM_CHANNEL_SR 19 /* Side right channel. */
203#define QAHW_PCM_CHANNEL_TFL 20 /* Top front left channel. */
204#define QAHW_PCM_CHANNEL_LVH QAHW_PCM_CHANNEL_TFL /* Left vertical height channel.*/
205#define QAHW_PCM_CHANNEL_TFR 21 /* Top front right channel. */
206#define QAHW_PCM_CHANNEL_RVH QAHW_PCM_CHANNEL_TFR /* Right vertical height channel.*/
207#define QAHW_PCM_CHANNEL_TC 22 /* Top center channel. */
208#define QAHW_PCM_CHANNEL_TBL 23 /* Top back left channel. */
209#define QAHW_PCM_CHANNEL_TBR 24 /* Top back right channel. */
210#define QAHW_PCM_CHANNEL_TSL 25 /* Top side left channel. */
211#define QAHW_PCM_CHANNEL_TSR 26 /* Top side right channel. */
212#define QAHW_PCM_CHANNEL_TBC 27 /* Top back center channel. */
213#define QAHW_PCM_CHANNEL_BFC 28 /* Bottom front center channel. */
214#define QAHW_PCM_CHANNEL_BFL 29 /* Bottom front left channel. */
215#define QAHW_PCM_CHANNEL_BFR 30 /* Bottom front right channel. */
216#define QAHW_PCM_CHANNEL_LW 31 /* Left wide channel. */
217#define QAHW_PCM_CHANNEL_RW 32 /* Right wide channel. */
218#define QAHW_PCM_CHANNEL_RSD 34 /* Right side direct channel. */
Sidipotu Ashok404f26d2017-10-10 22:27:51 +0530219
220/* type of asynchronous write callback events. Mutually exclusive */
221typedef enum {
222 QAHW_STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */
223 QAHW_STREAM_CBK_EVENT_DRAIN_READY, /* drain completed */
224 QAHW_STREAM_CBK_EVENT_ERROR, /* stream hit some error */
225
226 QAHW_STREAM_CBK_EVENT_ADSP = 0x100 /* callback event from ADSP PP,
227 * corresponding payload will be
228 * sent as is to the client
229 */
230} qahw_stream_callback_event_t;
231
232typedef int qahw_stream_callback_t(qahw_stream_callback_event_t event,
233 void *param,
234 void *cookie);
235
236/* type of drain requested to audio_stream_out->drain(). Mutually exclusive */
237typedef enum {
238 QAHW_DRAIN_ALL, /* drain() returns when all data has been played */
239 QAHW_DRAIN_EARLY_NOTIFY /* drain() returns a short time before all data
240 from the current track has been played to
241 give time for gapless track switch */
242} qahw_drain_type_t;
243
244/* meta data flags */
245/*TBD: Extend this based on stb requirement*/
246typedef enum {
247 QAHW_META_DATA_FLAGS_NONE = 0,
248} qahw_meta_data_flags_t;
249
250typedef struct {
251 const void *buffer; /* write buffer pointer */
252 size_t bytes; /* size of buffer */
253 size_t offset; /* offset in buffer from where valid byte starts */
254 int64_t *timestamp; /* timestmap */
255 qahw_meta_data_flags_t flags; /* meta data flags */
256 uint32_t reserved[64]; /*reserved for future */
257} qahw_out_buffer_t;
258
259typedef struct {
260 void *buffer; /* read buffer pointer */
261 size_t bytes; /* size of buffer */
262 size_t offset; /* offset in buffer from where valid byte starts */
263 int64_t *timestamp; /* timestmap */
264 uint32_t reserved[64]; /*reserved for future */
265} qahw_in_buffer_t;
266
267#define MAX_SECTORS 8
268
269struct qahw_source_tracking_param {
270 uint8_t vad[MAX_SECTORS];
271 uint16_t doa_speech;
272 uint16_t doa_noise[3];
273 uint8_t polar_activity[360];
274};
275
276struct qahw_sound_focus_param {
277 uint16_t start_angle[MAX_SECTORS];
278 uint8_t enable[MAX_SECTORS];
279 uint16_t gain_step;
280};
281
282struct aptx_dec_bt_addr {
283 uint32_t nap;
284 uint32_t uap;
285 uint32_t lap;
286};
287
288struct qahw_aptx_dec_param {
289 struct aptx_dec_bt_addr bt_addr;
290};
291
292struct qahw_avt_device_drift_param {
293 /* Flag to indicate if resync is required on the client side for
294 * drift correction. Flag is set to TRUE for the first get_param response
295 * after device interface starts. This flag value can be used by client
296 * to identify if device interface restart has happened and if any
297 * re-sync is required at their end for drift correction.
298 */
299 uint32_t resync_flag;
300 /* Accumulated drift value in microseconds.
301 * Positive drift value indicates AV timer is running faster than device.
302 * Negative drift value indicates AV timer is running slower than device.
303 */
304 int32_t avt_device_drift_value;
305 /* 64-bit absolute timestamp of reference */
306 uint64_t ref_timer_abs_ts;
307};
308
309/*use these for setting infine window.i.e free run mode */
310#define QAHW_MAX_RENDER_START_WINDOW 0x8000000000000000
311#define QAHW_MAX_RENDER_END_WINDOW 0x7FFFFFFFFFFFFFFF
312
313struct qahw_out_render_window_param {
314 uint64_t render_ws; /* render window start value microseconds*/
315 uint64_t render_we; /* render window end value microseconds*/
316};
317
318struct qahw_out_start_delay_param {
319 uint64_t start_delay; /* session start delay in microseconds*/
320};
321
322struct qahw_out_enable_drift_correction {
323 bool enable; /* enable drift correction*/
324};
325
326struct qahw_out_correct_drift {
327 /*
328 * adjust time in microseconds, a positive value
329 * to advance the clock or a negative value to
330 * delay the clock.
331 */
332 int64_t adjust_time;
333};
334
335#define QAHW_MAX_ADSP_STREAM_CMD_PAYLOAD_LEN 512
336
337typedef enum {
338 QAHW_STREAM_PP_EVENT = 0,
339 QAHW_STREAM_ENCDEC_EVENT = 1,
340} qahw_event_id;
341
342/* payload format for HAL parameter
343 * QAHW_PARAM_ADSP_STREAM_CMD
344 */
345struct qahw_adsp_event {
346 qahw_event_id event_type; /* type of the event */
347 uint32_t payload_length; /* length in bytes of the payload */
348 void *payload; /* the actual payload */
349};
350
351struct qahw_out_channel_map_param {
352 uint8_t channels; /* Input Channels */
353 uint8_t channel_map[AUDIO_CHANNEL_COUNT_MAX]; /* Input Channel Map */
354};
355
356struct qahw_device_cfg_param {
357 uint32_t sample_rate;
358 uint32_t channels;
359 uint32_t bit_width;
360 audio_format_t format;
361 audio_devices_t device;
362 uint8_t channel_map[AUDIO_CHANNEL_COUNT_MAX];
363 uint16_t channel_allocation;
364};
365
366typedef struct qahw_mix_matrix_params {
367 uint16_t num_output_channels;
368 uint16_t num_input_channels;
369 uint8_t has_output_channel_map;
370 uint32_t output_channel_map[AUDIO_CHANNEL_COUNT_MAX];
371 uint8_t has_input_channel_map;
372 uint32_t input_channel_map[AUDIO_CHANNEL_COUNT_MAX];
373 uint8_t has_mixer_coeffs;
374 float mixer_coeffs[AUDIO_CHANNEL_COUNT_MAX][AUDIO_CHANNEL_COUNT_MAX];
375} qahw_mix_matrix_params_t;
376
Surendar karka30569792018-05-08 12:02:21 +0530377#define QAHW_LICENCE_STR_MAX_LENGTH (64)
378#define QAHW_PRODUCT_STR_MAX_LENGTH (64)
379typedef struct qahw_license_params {
380 char product[QAHW_PRODUCT_STR_MAX_LENGTH + 1];
381 int key;
382 char license[QAHW_LICENCE_STR_MAX_LENGTH + 1];
383} qahw_license_params_t;
384
Sidipotu Ashok404f26d2017-10-10 22:27:51 +0530385typedef union {
386 struct qahw_source_tracking_param st_params;
387 struct qahw_sound_focus_param sf_params;
388 struct qahw_aptx_dec_param aptx_params;
389 struct qahw_avt_device_drift_param drift_params;
390 struct qahw_out_render_window_param render_window_params;
391 struct qahw_out_start_delay_param start_delay;
392 struct qahw_out_enable_drift_correction drift_enable_param;
393 struct qahw_out_correct_drift drift_correction_param;
394 struct qahw_adsp_event adsp_event_params;
395 struct qahw_out_channel_map_param channel_map_params;
396 struct qahw_device_cfg_param device_cfg_params;
397 struct qahw_mix_matrix_params mix_matrix_params;
Surendar karka30569792018-05-08 12:02:21 +0530398 struct qahw_license_params license_params;
Sidipotu Ashok404f26d2017-10-10 22:27:51 +0530399} qahw_param_payload;
400
401typedef enum {
402 QAHW_PARAM_SOURCE_TRACK,
403 QAHW_PARAM_SOUND_FOCUS,
404 QAHW_PARAM_APTX_DEC,
405 QAHW_PARAM_AVT_DEVICE_DRIFT, /* PARAM to query AV timer vs device drift */
406 QAHW_PARAM_OUT_RENDER_WINDOW, /* PARAM to set render window */
407 QAHW_PARAM_OUT_START_DELAY, /* PARAM to set session start delay*/
408 /* enable adsp drift correction this must be called before out_write */
409 QAHW_PARAM_OUT_ENABLE_DRIFT_CORRECTION,
410 /* param to set drift value to be adjusted by dsp */
411 QAHW_PARAM_OUT_CORRECT_DRIFT,
412 QAHW_PARAM_ADSP_STREAM_CMD,
413 QAHW_PARAM_OUT_CHANNEL_MAP, /* PARAM to set i/p channel map */
414 QAHW_PARAM_DEVICE_CONFIG, /* PARAM to set device config */
415 QAHW_PARAM_OUT_MIX_MATRIX_PARAMS,
416 QAHW_PARAM_CH_MIX_MATRIX_PARAMS,
Surendar karka30569792018-05-08 12:02:21 +0530417 QAHW_PARAM_LICENSE_PARAMS,
Sidipotu Ashok404f26d2017-10-10 22:27:51 +0530418} qahw_param_id;
419
Trinath Thammishetty580f1de2018-09-28 12:43:24 +0530420typedef union {
421 struct qahw_out_render_window_param render_window_params;
422} qahw_loopback_param_payload;
423
424typedef enum {
425 QAHW_PARAM_LOOPBACK_RENDER_WINDOW /* PARAM to set render window */
426} qahw_loopback_param_id;
427
Sidipotu Ashok404f26d2017-10-10 22:27:51 +0530428__END_DECLS
429
430#endif // QTI_AUDIO_HAL_DEFS_H
431