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