blob: e9ca91d40849a5c37150bf79554477b2bc5383d6 [file] [log] [blame]
Joonwoo Parkb91e48e2013-02-21 10:24:56 -08001/*
2 * Copyright (c) 2013, Linux Foundation. All rights reserved.
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 Parkb91e48e2013-02-21 10:24:56 -080021
22typedef void (*app_cb)(uint32_t opcode, uint32_t token,
23 uint32_t *payload, void *priv);
24
25struct 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
35struct lsm_client {
36 int session;
37 app_cb cb;
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;
50};
51
52struct lsm_stream_cmd_open_tx {
53 struct apr_hdr hdr;
54 uint16_t app_id;
55 uint16_t reserved;
56 uint32_t sampling_rate;
57} __packed;
58
59struct lsm_param_payload_common {
60 uint32_t module_id;
61 uint32_t param_id;
62 uint16_t param_size;
63 uint16_t reserved;
64} __packed;
65
66struct lsm_param_op_mode {
67 struct lsm_param_payload_common common;
68 uint32_t minor_version;
69 uint16_t mode;
70 uint16_t reserved;
71} __packed;
72
73struct lsm_param_connect_to_port {
74 struct lsm_param_payload_common common;
75 uint32_t minor_version;
76 /* AFE port id that receives voice wake up data */
77 uint16_t port_id;
78 uint16_t reserved;
79} __packed;
80
81struct lsm_param_kw_detect_sensitivity {
82 struct lsm_param_payload_common common;
83 uint32_t minor_version;
84 /* scale factor to change the keyword confidence thresholds */
85 uint16_t keyword_sensitivity;
86 uint16_t reserved;
87} __packed;
88
89struct lsm_param_user_detect_sensitivity {
90 struct lsm_param_payload_common common;
91 uint32_t minor_version;
92 /* scale factor to change the user confidence thresholds */
93 uint16_t user_sensitivity;
94 uint16_t reserved;
95} __packed;
96
97struct lsm_params_payload {
98 struct lsm_param_connect_to_port connect_to_port;
99 struct lsm_param_op_mode op_mode;
100 struct lsm_param_kw_detect_sensitivity kwds;
101 struct lsm_param_user_detect_sensitivity uds;
102} __packed;
103
104struct lsm_cmd_set_params {
105 struct apr_hdr hdr;
106 uint32_t data_payload_size;
107 uint32_t data_payload_addr_lsw;
108 uint32_t data_payload_addr_msw;
109 uint32_t mem_map_handle;
110 struct lsm_params_payload payload;
111} __packed;
112
113struct lsm_cmd_reg_snd_model {
114 struct apr_hdr hdr;
115 uint32_t model_size;
116 uint32_t model_addr_lsw;
117 uint32_t model_addr_msw;
118 uint32_t mem_map_handle;
119} __packed;
120
121struct lsm_client *q6lsm_client_alloc(app_cb cb, void *priv);
122void q6lsm_client_free(struct lsm_client *client);
123int q6lsm_open(struct lsm_client *client);
124int q6lsm_start(struct lsm_client *client, bool wait);
125int q6lsm_stop(struct lsm_client *client, bool wait);
126int q6lsm_snd_model_buf_alloc(struct lsm_client *client, uint32_t len);
127int q6lsm_close(struct lsm_client *client);
128int q6lsm_register_sound_model(struct lsm_client *client,
129 enum lsm_detection_mode mode, u16 minkeyword,
130 u16 minuser, bool detectfailure);
131int q6lsm_deregister_sound_model(struct lsm_client *client);
132
133#endif /* __Q6LSM_H__ */