Joonwoo Park | b91e48e | 2013-02-21 10:24:56 -0800 | [diff] [blame] | 1 | /* |
Venkat Sudhir | 735f155 | 2014-02-19 00:06:46 -0800 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, Linux Foundation. All rights reserved. |
Joonwoo Park | b91e48e | 2013-02-21 10:24:56 -0800 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | #ifndef __Q6LSM_H__ |
| 14 | #define __Q6LSM_H__ |
| 15 | |
| 16 | #include <linux/list.h> |
| 17 | #include <linux/msm_ion.h> |
| 18 | #include <sound/apr_audio-v2.h> |
| 19 | #include <sound/lsm_params.h> |
| 20 | #include <mach/qdsp6v2/apr.h> |
Joonwoo Park | b91e48e | 2013-02-21 10:24:56 -0800 | [diff] [blame] | 21 | |
Ben Romberger | 971765c | 2013-07-23 17:27:18 -0700 | [diff] [blame] | 22 | typedef void (*lsm_app_cb)(uint32_t opcode, uint32_t token, |
Joonwoo Park | b91e48e | 2013-02-21 10:24:56 -0800 | [diff] [blame] | 23 | uint32_t *payload, void *priv); |
| 24 | |
| 25 | struct lsm_sound_model { |
| 26 | dma_addr_t phys; |
| 27 | void *data; |
| 28 | uint32_t size; /* size of buffer */ |
| 29 | uint32_t actual_size; /* actual number of bytes read by DSP */ |
| 30 | struct ion_handle *handle; |
| 31 | struct ion_client *client; |
| 32 | uint32_t mem_map_handle; |
| 33 | }; |
| 34 | |
| 35 | struct lsm_client { |
| 36 | int session; |
Ben Romberger | 971765c | 2013-07-23 17:27:18 -0700 | [diff] [blame] | 37 | lsm_app_cb cb; |
Joonwoo Park | b91e48e | 2013-02-21 10:24:56 -0800 | [diff] [blame] | 38 | atomic_t cmd_state; |
| 39 | void *priv; |
| 40 | struct apr_svc *apr; |
| 41 | struct apr_svc *mmap_apr; |
| 42 | struct mutex cmd_lock; |
| 43 | struct lsm_sound_model sound_model; |
| 44 | wait_queue_head_t cmd_wait; |
| 45 | uint16_t mode; |
| 46 | uint16_t connect_to_port; |
| 47 | uint16_t user_sensitivity; |
| 48 | uint16_t kw_sensitivity; |
| 49 | bool started; |
Venkat Sudhir | 735f155 | 2014-02-19 00:06:46 -0800 | [diff] [blame] | 50 | dma_addr_t lsm_cal_phy_addr; |
| 51 | uint32_t lsm_cal_size; |
Joonwoo Park | b91e48e | 2013-02-21 10:24:56 -0800 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | struct lsm_stream_cmd_open_tx { |
| 55 | struct apr_hdr hdr; |
| 56 | uint16_t app_id; |
| 57 | uint16_t reserved; |
| 58 | uint32_t sampling_rate; |
| 59 | } __packed; |
| 60 | |
| 61 | struct lsm_param_payload_common { |
| 62 | uint32_t module_id; |
| 63 | uint32_t param_id; |
| 64 | uint16_t param_size; |
| 65 | uint16_t reserved; |
| 66 | } __packed; |
| 67 | |
| 68 | struct lsm_param_op_mode { |
| 69 | struct lsm_param_payload_common common; |
| 70 | uint32_t minor_version; |
| 71 | uint16_t mode; |
| 72 | uint16_t reserved; |
| 73 | } __packed; |
| 74 | |
| 75 | struct lsm_param_connect_to_port { |
| 76 | struct lsm_param_payload_common common; |
| 77 | uint32_t minor_version; |
| 78 | /* AFE port id that receives voice wake up data */ |
| 79 | uint16_t port_id; |
| 80 | uint16_t reserved; |
| 81 | } __packed; |
| 82 | |
| 83 | struct lsm_param_kw_detect_sensitivity { |
| 84 | struct lsm_param_payload_common common; |
| 85 | uint32_t minor_version; |
| 86 | /* scale factor to change the keyword confidence thresholds */ |
| 87 | uint16_t keyword_sensitivity; |
| 88 | uint16_t reserved; |
| 89 | } __packed; |
| 90 | |
| 91 | struct lsm_param_user_detect_sensitivity { |
| 92 | struct lsm_param_payload_common common; |
| 93 | uint32_t minor_version; |
| 94 | /* scale factor to change the user confidence thresholds */ |
| 95 | uint16_t user_sensitivity; |
| 96 | uint16_t reserved; |
| 97 | } __packed; |
| 98 | |
| 99 | struct lsm_params_payload { |
| 100 | struct lsm_param_connect_to_port connect_to_port; |
| 101 | struct lsm_param_op_mode op_mode; |
| 102 | struct lsm_param_kw_detect_sensitivity kwds; |
| 103 | struct lsm_param_user_detect_sensitivity uds; |
| 104 | } __packed; |
| 105 | |
| 106 | struct lsm_cmd_set_params { |
| 107 | struct apr_hdr hdr; |
| 108 | uint32_t data_payload_size; |
| 109 | uint32_t data_payload_addr_lsw; |
| 110 | uint32_t data_payload_addr_msw; |
| 111 | uint32_t mem_map_handle; |
| 112 | struct lsm_params_payload payload; |
| 113 | } __packed; |
| 114 | |
| 115 | struct lsm_cmd_reg_snd_model { |
| 116 | struct apr_hdr hdr; |
| 117 | uint32_t model_size; |
| 118 | uint32_t model_addr_lsw; |
| 119 | uint32_t model_addr_msw; |
| 120 | uint32_t mem_map_handle; |
| 121 | } __packed; |
| 122 | |
Ben Romberger | 971765c | 2013-07-23 17:27:18 -0700 | [diff] [blame] | 123 | struct lsm_client *q6lsm_client_alloc(lsm_app_cb cb, void *priv); |
Joonwoo Park | b91e48e | 2013-02-21 10:24:56 -0800 | [diff] [blame] | 124 | void q6lsm_client_free(struct lsm_client *client); |
| 125 | int q6lsm_open(struct lsm_client *client); |
| 126 | int q6lsm_start(struct lsm_client *client, bool wait); |
| 127 | int q6lsm_stop(struct lsm_client *client, bool wait); |
Venkat Sudhir | 735f155 | 2014-02-19 00:06:46 -0800 | [diff] [blame] | 128 | int q6lsm_snd_model_buf_alloc(struct lsm_client *client, size_t len); |
Kiran Kandi | c161ec1 | 2013-05-28 18:23:20 -0700 | [diff] [blame] | 129 | int q6lsm_snd_model_buf_free(struct lsm_client *client); |
Joonwoo Park | b91e48e | 2013-02-21 10:24:56 -0800 | [diff] [blame] | 130 | int q6lsm_close(struct lsm_client *client); |
Joonwoo Park | b91e48e | 2013-02-21 10:24:56 -0800 | [diff] [blame] | 131 | int q6lsm_register_sound_model(struct lsm_client *client, |
| 132 | enum lsm_detection_mode mode, u16 minkeyword, |
| 133 | u16 minuser, bool detectfailure); |
| 134 | int q6lsm_deregister_sound_model(struct lsm_client *client); |
| 135 | |
| 136 | #endif /* __Q6LSM_H__ */ |