blob: 8f06f20cff32f585d84949778951c513b2e96e14 [file] [log] [blame]
Joonwoo Parkb91e48e2013-02-21 10:24:56 -08001/*
Venkat Sudhir735f1552014-02-19 00:06:46 -08002 * Copyright (c) 2013-2014, Linux Foundation. All rights reserved.
Joonwoo Parkb91e48e2013-02-21 10:24:56 -08003 *
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
Ben Romberger971765c2013-07-23 17:27:18 -070022typedef void (*lsm_app_cb)(uint32_t opcode, uint32_t token,
Joonwoo Parkb91e48e2013-02-21 10:24:56 -080023 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;
Ben Romberger971765c2013-07-23 17:27:18 -070037 lsm_app_cb cb;
Joonwoo Parkb91e48e2013-02-21 10:24:56 -080038 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 Sudhir735f1552014-02-19 00:06:46 -080050 dma_addr_t lsm_cal_phy_addr;
51 uint32_t lsm_cal_size;
Joonwoo Parkb91e48e2013-02-21 10:24:56 -080052};
53
54struct 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
61struct 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
68struct 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
75struct 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
83struct 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
91struct 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
99struct 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
106struct 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
115struct 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 Romberger971765c2013-07-23 17:27:18 -0700123struct lsm_client *q6lsm_client_alloc(lsm_app_cb cb, void *priv);
Joonwoo Parkb91e48e2013-02-21 10:24:56 -0800124void q6lsm_client_free(struct lsm_client *client);
125int q6lsm_open(struct lsm_client *client);
126int q6lsm_start(struct lsm_client *client, bool wait);
127int q6lsm_stop(struct lsm_client *client, bool wait);
Venkat Sudhir735f1552014-02-19 00:06:46 -0800128int q6lsm_snd_model_buf_alloc(struct lsm_client *client, size_t len);
Kiran Kandic161ec12013-05-28 18:23:20 -0700129int q6lsm_snd_model_buf_free(struct lsm_client *client);
Joonwoo Parkb91e48e2013-02-21 10:24:56 -0800130int q6lsm_close(struct lsm_client *client);
Joonwoo Parkb91e48e2013-02-21 10:24:56 -0800131int q6lsm_register_sound_model(struct lsm_client *client,
132 enum lsm_detection_mode mode, u16 minkeyword,
133 u16 minuser, bool detectfailure);
134int q6lsm_deregister_sound_model(struct lsm_client *client);
135
136#endif /* __Q6LSM_H__ */