/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2020-2020. All rights reserved. * Description: audio hal top layer header file. * Author: Hisilicon * Create: 2020-05-11 * Notes: NA * History: 2020-05-11 yinyingcai for CodingStyle */ #ifndef AUDIO_HW_H #define AUDIO_HW_H #include #include #include #include #include "audio_hal_common.h" #ifdef TV_TYPE #include "audio_setting.h" #include "audio_phone.h" #endif #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif #define NOT_INITED_HANDLE (-1) #define SAMPLE_RATE_8000 8000 #define SAMPLE_RATE_11025 11025 #define SAMPLE_RATE_12000 12000 #define SAMPLE_RATE_16000 16000 #define SAMPLE_RATE_22050 22050 #define SAMPLE_RATE_24000 24000 #define SAMPLE_RATE_32000 32000 #define SAMPLE_RATE_44100 44100 #define SAMPLE_RATE_48000 48000 #define SAMPLE_RATE_96000 96000 #define SAMPLE_RATE_176000 176000 #define SAMPLE_RATE_192000 192000 #define MAX_SUPPORTED_CHANNEL_MASKS 2 #define MAX_SUPPORTED_FORMATS 15 #define MAX_SUPPORTED_SAMPLE_RATES 8 #define DIRECTOUT_ES_DEEP_PERIOD_SIZE 1024 #define SECOND_TO_MS 1000 #define DIRECTOUT_ES_PERIOD_SIZE 1024 #define AUDIO_MONO_CHANNELS 1 #define AUDIO_STEREO_CHANNELS 2 #define AUDIO_5POINT1_CHANNELS 6 #define AUDIO_7POINT1_CHANNELS 8 #define AC3_LIB_TYPE_NONE 0 #define AC3_LIB_TYPE_LICENCE 1 #define AC3_LIB_TYPE_PASSTHROUGH 2 /* * audio_container_of - get the struct ptr * @ptr: the &struct list_head pointer. * @type: the type of the struct this is embedded in. * @member: the name of the list_struct within the struct. */ #define osal_offsetof(TYPE, MEMBER) ((int)(unsigned long)&((TYPE *)0)->MEMBER) #define audio_container_of(ptr, type, member) ({ \ const __typeof__(((type *)0)->member) *__mptr = (ptr); \ (type *)((char *)__mptr - osal_offsetof(type, member)); }) enum { USECASE_INVALID = -1, /* Playback usecases */ USECASE_AUDIO_PLAYBACK_NORMAL = 0, USECASE_AUDIO_PLAYBACK_MULTI_CH, USECASE_AUDIO_PLAYBACK_DIRECT, USECASE_AUDIO_PLAYBACK_DIRECT_TUNNEL, USECASE_AUDIO_PLAYBACK_DIRECT_NONTUNNEL, USECASE_AUDIO_PLAYBACK_OFFLOAD, USECASE_AUDIO_PHONE_TX, USECASE_AUDIO_PLAYBACK_LOW_LATENCY, /* Capture usecases */ USECASE_AUDIO_RECORD, USECASE_AUDIO_CAST, USECASE_AUDIO_RECORD_LOW_LATENCY, USECASE_AUDIO_PHONE_RX, /* Begin: customized define */ USECASE_AUDIO_CUSTOM_BEGIN = 1000, USECASE_AUDIO_CUSTOM_END = 2000, AUDIO_USECASE_MAX }; enum { STREAM_NONE = 0, STREAM_DDP_2_0, STREAM_DDP_5_1, STREAM_ATMOS, STREAM_MAX }; enum { PRODUCT_TYPE_TV = 0, PRODUCT_TYPE_STB, PRODUCT_TYPE_AR, PRODUCT_TYPE_VR, PRODUCT_TYPE_CAR, PRODUCT_TYPE_TABLET, PRODUCT_TYPE_MAX }; struct drc_config { int DrcMode; int DrcRange; }; struct audio_device { struct audio_hw_device hw_device; int hw_sync_id; int vol_index; int32_t decimal_gain; int32_t integer_gain; float gain; bool mic_muted; bool muted; bool hdoSupport; float vol_master; unsigned int stream_type; pthread_mutex_t lock; /* device lock share by in&out */ struct drc_config drc_cfg; int CertDeepBuffer; uint32_t ac3_lib_type; bool cast_muted; /* support passthrough mute when volume min */ struct hci_device_attr device_attr; int32_t product_type; void *custom_private_data; int mode; #ifdef TV_TYPE struct audio_setting setting; #if (UAPI_VERSION_CODE == UAPI_VERSION(1, 0)) aiao_ctx ctx; #endif #endif }; struct stream_out { struct audio_stream_out stream; struct hpo_data *hpo; struct hdo_data *hdo; struct pcm_config config; struct audio_device *adev; unsigned int sample_rate; audio_channel_mask_t channel_mask; audio_format_t format; audio_output_flags_t flags; audio_devices_t devices; pthread_mutex_t lock; unsigned int usecase; bool standby; bool is_pause; audio_io_handle_t handle; 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]; void *custom_priv_data; }; struct stream_in { struct audio_stream_in stream; struct hpi_data *hpi; struct pcm_config config; struct audio_device *adev; struct hci_data *hci; unsigned int sample_rate; audio_channel_mask_t channel_mask; audio_format_t format; audio_input_flags_t flags; audio_devices_t devices; pthread_mutex_t lock; unsigned int usecase; bool standby; uint32_t read_success_cnt; uint32_t read_fail_cnt; audio_io_handle_t handle; 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]; void *custom_priv_data; }; struct audio_attr { audio_format_t format; uint32_t usecase; struct pcm_config* pConfig; int DrcMode; int DrcRange; int CertDeepBuffer; uint32_t ac3LibType; }; #endif