blob: 5c9d4b920be26810ee774170554ad721582eeb08 [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>
21#include <mach/msm_subsystem_map.h>
22
23typedef void (*app_cb)(uint32_t opcode, uint32_t token,
24 uint32_t *payload, void *priv);
25
26struct lsm_sound_model {
27 dma_addr_t phys;
28 void *data;
29 uint32_t size; /* size of buffer */
30 uint32_t actual_size; /* actual number of bytes read by DSP */
31 struct ion_handle *handle;
32 struct ion_client *client;
33 uint32_t mem_map_handle;
34};
35
36struct lsm_client {
37 int session;
38 app_cb cb;
39 atomic_t cmd_state;
40 void *priv;
41 struct apr_svc *apr;
42 struct apr_svc *mmap_apr;
43 struct mutex cmd_lock;
44 struct lsm_sound_model sound_model;
45 wait_queue_head_t cmd_wait;
46 uint16_t mode;
47 uint16_t connect_to_port;
48 uint16_t user_sensitivity;
49 uint16_t kw_sensitivity;
50 bool started;
51};
52
53struct lsm_stream_cmd_open_tx {
54 struct apr_hdr hdr;
55 uint16_t app_id;
56 uint16_t reserved;
57 uint32_t sampling_rate;
58} __packed;
59
60struct lsm_param_payload_common {
61 uint32_t module_id;
62 uint32_t param_id;
63 uint16_t param_size;
64 uint16_t reserved;
65} __packed;
66
67struct lsm_param_op_mode {
68 struct lsm_param_payload_common common;
69 uint32_t minor_version;
70 uint16_t mode;
71 uint16_t reserved;
72} __packed;
73
74struct lsm_param_connect_to_port {
75 struct lsm_param_payload_common common;
76 uint32_t minor_version;
77 /* AFE port id that receives voice wake up data */
78 uint16_t port_id;
79 uint16_t reserved;
80} __packed;
81
82struct lsm_param_kw_detect_sensitivity {
83 struct lsm_param_payload_common common;
84 uint32_t minor_version;
85 /* scale factor to change the keyword confidence thresholds */
86 uint16_t keyword_sensitivity;
87 uint16_t reserved;
88} __packed;
89
90struct lsm_param_user_detect_sensitivity {
91 struct lsm_param_payload_common common;
92 uint32_t minor_version;
93 /* scale factor to change the user confidence thresholds */
94 uint16_t user_sensitivity;
95 uint16_t reserved;
96} __packed;
97
98struct lsm_params_payload {
99 struct lsm_param_connect_to_port connect_to_port;
100 struct lsm_param_op_mode op_mode;
101 struct lsm_param_kw_detect_sensitivity kwds;
102 struct lsm_param_user_detect_sensitivity uds;
103} __packed;
104
105struct lsm_cmd_set_params {
106 struct apr_hdr hdr;
107 uint32_t data_payload_size;
108 uint32_t data_payload_addr_lsw;
109 uint32_t data_payload_addr_msw;
110 uint32_t mem_map_handle;
111 struct lsm_params_payload payload;
112} __packed;
113
114struct lsm_cmd_reg_snd_model {
115 struct apr_hdr hdr;
116 uint32_t model_size;
117 uint32_t model_addr_lsw;
118 uint32_t model_addr_msw;
119 uint32_t mem_map_handle;
120} __packed;
121
122struct lsm_client *q6lsm_client_alloc(app_cb cb, void *priv);
123void q6lsm_client_free(struct lsm_client *client);
124int q6lsm_open(struct lsm_client *client);
125int q6lsm_start(struct lsm_client *client, bool wait);
126int q6lsm_stop(struct lsm_client *client, bool wait);
127int q6lsm_snd_model_buf_alloc(struct lsm_client *client, uint32_t len);
128int q6lsm_close(struct lsm_client *client);
129int q6lsm_register_sound_model(struct lsm_client *client,
130 enum lsm_detection_mode mode, u16 minkeyword,
131 u16 minuser, bool detectfailure);
132int q6lsm_deregister_sound_model(struct lsm_client *client);
133
134#endif /* __Q6LSM_H__ */