Quinn Male | 2e88375 | 2019-03-22 11:28:54 -0700 | [diff] [blame] | 1 | /* sound_trigger_prop_intf.h |
| 2 | * |
| 3 | * Interface for sound trigger related communication |
| 4 | * across modules. |
| 5 | * |
Quinn Male | d409e41 | 2019-12-09 14:50:48 -0800 | [diff] [blame] | 6 | * Copyright (c) 2014, 2016-2020, The Linux Foundation. All rights reserved. |
Quinn Male | 2e88375 | 2019-03-22 11:28:54 -0700 | [diff] [blame] | 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions are |
| 10 | * met: |
| 11 | * * Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * * Redistributions in binary form must reproduce the above |
| 14 | * copyright notice, this list of conditions and the following |
| 15 | * disclaimer in the documentation and/or other materials provided |
| 16 | * with the distribution. |
| 17 | * * Neither the name of The Linux Foundation nor the names of its |
| 18 | * contributors may be used to endorse or promote products derived |
| 19 | * from this software without specific prior written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 23 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 28 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 31 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | */ |
| 33 | #ifndef SOUND_TRIGGER_PROP_INTF_H |
| 34 | #define SOUND_TRIGGER_PROP_INTF_H |
| 35 | |
| 36 | #include <hardware/sound_trigger.h> |
| 37 | #include "tinyalsa/asoundlib.h" |
| 38 | |
| 39 | #define MAKE_HAL_VERSION(maj, min) ((((maj) & 0xff) << 8) | ((min) & 0xff)) |
| 40 | #define MAJOR_VERSION(ver) (((ver) & 0xff00) >> 8) |
| 41 | #define MINOR_VERSION(ver) ((ver) & 0x00ff) |
| 42 | |
| 43 | /* Proprietary interface version used for compatibility with AHAL */ |
Quinn Male | d409e41 | 2019-12-09 14:50:48 -0800 | [diff] [blame] | 44 | #define STHAL_PROP_API_VERSION_2_0 MAKE_HAL_VERSION(2, 0) |
| 45 | #define STHAL_PROP_API_CURRENT_VERSION STHAL_PROP_API_VERSION_2_0 |
Quinn Male | 2e88375 | 2019-03-22 11:28:54 -0700 | [diff] [blame] | 46 | |
| 47 | #define ST_EVENT_CONFIG_MAX_STR_VALUE 32 |
| 48 | |
| 49 | enum sound_trigger_event_type { |
| 50 | ST_EVENT_SESSION_REGISTER, |
| 51 | ST_EVENT_SESSION_DEREGISTER, |
| 52 | ST_EVENT_START_KEEP_ALIVE, |
| 53 | ST_EVENT_STOP_KEEP_ALIVE, |
| 54 | ST_EVENT_UPDATE_ECHO_REF |
| 55 | }; |
| 56 | typedef enum sound_trigger_event_type sound_trigger_event_type_t; |
| 57 | |
| 58 | enum audio_event_type { |
| 59 | AUDIO_EVENT_CAPTURE_DEVICE_INACTIVE, |
| 60 | AUDIO_EVENT_CAPTURE_DEVICE_ACTIVE, |
| 61 | AUDIO_EVENT_PLAYBACK_STREAM_INACTIVE, |
| 62 | AUDIO_EVENT_PLAYBACK_STREAM_ACTIVE, |
| 63 | AUDIO_EVENT_STOP_LAB, |
| 64 | AUDIO_EVENT_SSR, |
| 65 | AUDIO_EVENT_NUM_ST_SESSIONS, |
| 66 | AUDIO_EVENT_READ_SAMPLES, |
| 67 | AUDIO_EVENT_DEVICE_CONNECT, |
| 68 | AUDIO_EVENT_DEVICE_DISCONNECT, |
| 69 | AUDIO_EVENT_SVA_EXEC_MODE, |
| 70 | AUDIO_EVENT_SVA_EXEC_MODE_STATUS, |
| 71 | AUDIO_EVENT_CAPTURE_STREAM_INACTIVE, |
| 72 | AUDIO_EVENT_CAPTURE_STREAM_ACTIVE, |
| 73 | AUDIO_EVENT_BATTERY_STATUS_CHANGED, |
| 74 | AUDIO_EVENT_GET_PARAM, |
Quinn Male | cc1affd | 2019-07-18 16:13:31 -0700 | [diff] [blame] | 75 | AUDIO_EVENT_UPDATE_ECHO_REF, |
| 76 | AUDIO_EVENT_SCREEN_STATUS_CHANGED |
Quinn Male | 2e88375 | 2019-03-22 11:28:54 -0700 | [diff] [blame] | 77 | }; |
| 78 | typedef enum audio_event_type audio_event_type_t; |
| 79 | |
| 80 | typedef enum { |
| 81 | USECASE_TYPE_PCM_PLAYBACK, |
| 82 | USECASE_TYPE_PCM_CAPTURE, |
| 83 | USECASE_TYPE_VOICE_CALL, |
| 84 | USECASE_TYPE_VOIP_CALL, |
| 85 | } audio_stream_usecase_type_t; |
| 86 | |
| 87 | enum ssr_event_status { |
| 88 | SND_CARD_STATUS_OFFLINE, |
| 89 | SND_CARD_STATUS_ONLINE, |
| 90 | CPE_STATUS_OFFLINE, |
| 91 | CPE_STATUS_ONLINE, |
| 92 | SLPI_STATUS_OFFLINE, |
| 93 | SLPI_STATUS_ONLINE |
| 94 | }; |
| 95 | |
| 96 | struct sound_trigger_session_info { |
| 97 | void* p_ses; /* opaque pointer to st_session obj */ |
| 98 | int capture_handle; |
| 99 | struct pcm *pcm; |
| 100 | struct pcm_config config; |
| 101 | }; |
| 102 | |
| 103 | struct audio_read_samples_info { |
| 104 | struct sound_trigger_session_info *ses_info; |
| 105 | void *buf; |
| 106 | size_t num_bytes; |
| 107 | }; |
| 108 | |
| 109 | struct audio_hal_usecase { |
| 110 | audio_stream_usecase_type_t type; |
| 111 | }; |
| 112 | |
| 113 | struct sound_trigger_event_info { |
| 114 | struct sound_trigger_session_info st_ses; |
| 115 | bool st_ec_ref_enabled; |
| 116 | }; |
| 117 | |
| 118 | struct sound_trigger_device_info { |
Quinn Male | d409e41 | 2019-12-09 14:50:48 -0800 | [diff] [blame] | 119 | struct listnode devices; |
Quinn Male | 2e88375 | 2019-03-22 11:28:54 -0700 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | struct sound_trigger_get_param_data { |
| 123 | char *param; |
| 124 | int sm_handle; |
| 125 | struct str_parms *reply; |
| 126 | }; |
| 127 | |
| 128 | typedef struct sound_trigger_event_info sound_trigger_event_info_t; |
| 129 | |
| 130 | struct audio_event_info { |
| 131 | union { |
| 132 | enum ssr_event_status status; |
| 133 | int value; |
| 134 | struct sound_trigger_session_info ses_info; |
| 135 | struct audio_read_samples_info aud_info; |
| 136 | char str_value[ST_EVENT_CONFIG_MAX_STR_VALUE]; |
| 137 | struct audio_hal_usecase usecase; |
| 138 | bool audio_ec_ref_enabled; |
| 139 | struct sound_trigger_get_param_data st_get_param_data; |
| 140 | } u; |
| 141 | struct sound_trigger_device_info device_info; |
| 142 | }; |
| 143 | typedef struct audio_event_info audio_event_info_t; |
| 144 | |
| 145 | struct sthw_extn_fptrs { |
| 146 | int (*set_parameters)(const struct sound_trigger_hw_device *dev, |
| 147 | sound_model_handle_t sound_model_handle, |
| 148 | const char *kv_pairs); |
| 149 | size_t (*get_buffer_size)(const struct sound_trigger_hw_device *dev, |
| 150 | sound_model_handle_t sound_model_handle); |
| 151 | int (*read_buffer)(const struct sound_trigger_hw_device *dev, |
| 152 | sound_model_handle_t sound_model_handle, |
| 153 | unsigned char *buf, |
| 154 | size_t bytes); |
| 155 | int (*stop_buffering)(const struct sound_trigger_hw_device *dev, |
| 156 | sound_model_handle_t sound_model_handle); |
| 157 | int (*get_param_data)(const struct sound_trigger_hw_device *dev, |
| 158 | sound_model_handle_t sound_model_handle, |
| 159 | const char *param, |
| 160 | void *payload, |
| 161 | size_t payload_size, |
| 162 | size_t *param_data_size); |
| 163 | }; |
| 164 | typedef struct sthw_extn_fptrs sthw_extn_fptrs_t; |
| 165 | |
| 166 | /* STHAL callback which is called by AHAL */ |
| 167 | typedef int (*sound_trigger_hw_call_back_t)(enum audio_event_type, |
| 168 | struct audio_event_info*); |
| 169 | |
| 170 | /* STHAL version queried by AHAL */ |
| 171 | typedef int (*sound_trigger_hw_get_version_t)(); |
| 172 | |
| 173 | /* STHAL extn interface functionality called by qti wrapper */ |
| 174 | typedef void (*sthw_extn_get_fptrs_t)(sthw_extn_fptrs_t *fptrs); |
| 175 | |
| 176 | /* AHAL callback which is called by STHAL */ |
| 177 | typedef void (*audio_hw_call_back_t)(enum sound_trigger_event_type, |
| 178 | struct sound_trigger_event_info*); |
| 179 | |
| 180 | /* AHAL function which is called by STHAL */ |
| 181 | typedef int (*audio_hw_acdb_init_t)(int snd_card_num); |
| 182 | |
| 183 | /* AHAL function which is called by STHAL */ |
| 184 | typedef int (*audio_hw_acdb_init_v2_t)(struct mixer *mixer); |
| 185 | |
| 186 | /* AHAL extn util function which is called by STHAL */ |
| 187 | typedef int (*audio_hw_get_snd_card_num_t)(); |
| 188 | |
| 189 | /* AHAL extn util function which is called by STHAL */ |
| 190 | typedef int (*audio_hw_open_snd_mixer_t)(struct mixer **mixer); |
| 191 | |
| 192 | /* AHAL extn util function which is called by STHAL */ |
| 193 | typedef void (*audio_hw_close_snd_mixer_t)(struct mixer *mixer); |
| 194 | #endif /* SOUND_TRIGGER_PROP_INTF_H */ |