Home | History | Annotate | Download | only in sound
      1 #ifndef _UAPI_LSM_PARAMS_H__
      2 #define _UAPI_LSM_PARAMS_H__
      3 
      4 #include <linux/types.h>
      5 #include <sound/asound.h>
      6 
      7 #define SNDRV_LSM_VERSION SNDRV_PROTOCOL_VERSION(0, 1, 0)
      8 
      9 #define LSM_OUT_FORMAT_PCM (0)
     10 #define LSM_OUT_FORMAT_ADPCM (1 << 0)
     11 
     12 #define LSM_OUT_DATA_RAW (0)
     13 #define LSM_OUT_DATA_PACKED (1)
     14 
     15 #define LSM_OUT_DATA_EVENTS_DISABLED (0)
     16 #define LSM_OUT_DATA_EVENTS_ENABLED (1)
     17 
     18 #define LSM_OUT_TRANSFER_MODE_RT (0)
     19 #define LSM_OUT_TRANSFER_MODE_FTRT (1)
     20 
     21 enum lsm_app_id {
     22 	LSM_VOICE_WAKEUP_APP_ID = 1,
     23 	LSM_VOICE_WAKEUP_APP_ID_V2 = 2,
     24 };
     25 
     26 enum lsm_detection_mode {
     27 	LSM_MODE_KEYWORD_ONLY_DETECTION = 1,
     28 	LSM_MODE_USER_KEYWORD_DETECTION
     29 };
     30 
     31 enum lsm_vw_status {
     32 	LSM_VOICE_WAKEUP_STATUS_RUNNING = 1,
     33 	LSM_VOICE_WAKEUP_STATUS_DETECTED,
     34 	LSM_VOICE_WAKEUP_STATUS_END_SPEECH,
     35 	LSM_VOICE_WAKEUP_STATUS_REJECTED
     36 };
     37 
     38 enum LSM_PARAM_TYPE {
     39 	LSM_ENDPOINT_DETECT_THRESHOLD = 0,
     40 	LSM_OPERATION_MODE,
     41 	LSM_GAIN,
     42 	LSM_MIN_CONFIDENCE_LEVELS,
     43 	LSM_REG_SND_MODEL,
     44 	LSM_DEREG_SND_MODEL,
     45 	LSM_CUSTOM_PARAMS,
     46 	/* driver ioctl will parse only so many params */
     47 	LSM_PARAMS_MAX,
     48 };
     49 
     50 /*
     51  * Data for LSM_ENDPOINT_DETECT_THRESHOLD param_type
     52  * @epd_begin: Begin threshold
     53  * @epd_end: End threshold
     54  */
     55 struct snd_lsm_ep_det_thres {
     56 	__u32 epd_begin;
     57 	__u32 epd_end;
     58 };
     59 
     60 /*
     61  * Data for LSM_OPERATION_MODE param_type
     62  * @mode: The detection mode to be used
     63  * @detect_failure: Setting to enable failure detections.
     64  */
     65 struct snd_lsm_detect_mode {
     66 	enum lsm_detection_mode mode;
     67 	bool detect_failure;
     68 };
     69 
     70 /*
     71  * Data for LSM_GAIN param_type
     72  * @gain: The gain to be applied on LSM
     73  */
     74 struct snd_lsm_gain {
     75 	__u16 gain;
     76 };
     77 
     78 
     79 struct snd_lsm_sound_model_v2 {
     80 	__u8 __user *data;
     81 	__u8 *confidence_level;
     82 	__u32 data_size;
     83 	enum lsm_detection_mode detection_mode;
     84 	__u8 num_confidence_levels;
     85 	bool detect_failure;
     86 };
     87 
     88 struct snd_lsm_session_data {
     89 	enum lsm_app_id app_id;
     90 };
     91 
     92 struct snd_lsm_event_status {
     93 	__u16 status;
     94 	__u16 payload_size;
     95 	__u8 payload[0];
     96 };
     97 
     98 struct snd_lsm_detection_params {
     99 	__u8 *conf_level;
    100 	enum lsm_detection_mode detect_mode;
    101 	__u8 num_confidence_levels;
    102 	bool detect_failure;
    103 };
    104 
    105 /*
    106  * Param info for each parameter type
    107  * @module_id: Module to which parameter is to be set
    108  * @param_id: Parameter that is to be set
    109  * @param_size: size (in number of bytes) for the data
    110  *		in param_data.
    111  *		For confidence levels, this is num_conf_levels
    112  *		For REG_SND_MODEL, this is size of sound model
    113  *		For CUSTOM_PARAMS, this is size of the entire blob of data
    114  * @param_data: Data for the parameter.
    115  *		For some param_types this is a structure defined, ex: LSM_GAIN
    116  *		For CONFIDENCE_LEVELS, this is array of confidence levels
    117  *		For REG_SND_MODEL, this is the sound model data
    118  *		For CUSTOM_PARAMS, this is the blob of custom data.
    119  */
    120 struct lsm_params_info {
    121 	__u32 module_id;
    122 	__u32 param_id;
    123 	__u32 param_size;
    124 	__u8 __user *param_data;
    125 	enum LSM_PARAM_TYPE param_type;
    126 };
    127 
    128 /*
    129  * Data passed to the SET_PARAM_V2 IOCTL
    130  * @num_params: Number of params that are to be set
    131  *		should not be greater than LSM_PARAMS_MAX
    132  * @params: Points to an array of lsm_params_info
    133  *	    Each entry points to one parameter to set
    134  * @data_size: size (in bytes) for params
    135  *	       should be equal to
    136  *	       num_params * sizeof(struct lsm_parms_info)
    137  */
    138 struct snd_lsm_module_params {
    139 	__u8 __user *params;
    140 	__u32 num_params;
    141 	__u32 data_size;
    142 };
    143 
    144 /*
    145  * Data passed to LSM_OUT_FORMAT_CFG IOCTL
    146  * @format: The media format enum
    147  * @packing: indicates the packing method used for data path
    148  * @events: indicates whether data path events need to be enabled
    149  * @transfer_mode: indicates whether FTRT mode or RT mode.
    150  */
    151 struct snd_lsm_output_format_cfg {
    152 	__u8 format;
    153 	__u8 packing;
    154 	__u8 events;
    155 	__u8 mode;
    156 };
    157 
    158 #define SNDRV_LSM_DEREG_SND_MODEL _IOW('U', 0x01, int)
    159 #define SNDRV_LSM_EVENT_STATUS	_IOW('U', 0x02, struct snd_lsm_event_status)
    160 #define SNDRV_LSM_ABORT_EVENT	_IOW('U', 0x03, int)
    161 #define SNDRV_LSM_START		_IOW('U', 0x04, int)
    162 #define SNDRV_LSM_STOP		_IOW('U', 0x05, int)
    163 #define SNDRV_LSM_SET_SESSION_DATA _IOW('U', 0x06, struct snd_lsm_session_data)
    164 #define SNDRV_LSM_REG_SND_MODEL_V2 _IOW('U', 0x07,\
    165 					struct snd_lsm_sound_model_v2)
    166 #define SNDRV_LSM_LAB_CONTROL	_IOW('U', 0x08, uint32_t)
    167 #define SNDRV_LSM_STOP_LAB	_IO('U', 0x09)
    168 #define SNDRV_LSM_SET_PARAMS	_IOW('U', 0x0A, \
    169 					struct snd_lsm_detection_params)
    170 #define SNDRV_LSM_SET_MODULE_PARAMS	_IOW('U', 0x0B, \
    171 					struct snd_lsm_module_params)
    172 #define SNDRV_LSM_OUT_FORMAT_CFG _IOW('U', 0x0C, \
    173 				      struct snd_lsm_output_format_cfg)
    174 
    175 #endif
    176