2 * Copyright (c) 2013-2017, Linux Foundation. All rights reserved.
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.
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.
14 #ifndef __CPE_CORE_H__
15 #define __CPE_CORE_H__
17 #include <linux/types.h>
18 #include <linux/wait.h>
19 #include <linux/dma-mapping.h>
20 #include <sound/lsm_params.h>
29 WCD_CPE_PRE_ENABLE = 1,
35 struct wcd_cpe_afe_port_cfg {
42 struct lsm_out_fmt_cfg {
49 struct lsm_hw_params {
55 struct cpe_lsm_session {
56 /* sound model related */
61 /* Clients private data */
64 void (*event_cb) (void *priv_data,
66 u8 size, u8 *payload);
68 struct completion cmd_comp;
69 struct wcd_cpe_afe_port_cfg afe_port_cfg;
70 struct wcd_cpe_afe_port_cfg afe_out_port_cfg;
71 struct mutex lsm_lock;
77 u8 num_confidence_levels;
79 struct task_struct *lsm_lab_thread;
83 struct lsm_out_fmt_cfg out_fmt_cfg;
85 bool is_topology_used;
88 struct wcd_cpe_afe_ops {
89 int (*afe_set_params) (void *core_handle,
90 struct wcd_cpe_afe_port_cfg *cfg,
93 int (*afe_port_start) (void *core_handle,
94 struct wcd_cpe_afe_port_cfg *cfg);
96 int (*afe_port_stop) (void *core_handle,
97 struct wcd_cpe_afe_port_cfg *cfg);
99 int (*afe_port_suspend) (void *core_handle,
100 struct wcd_cpe_afe_port_cfg *cfg);
102 int (*afe_port_resume) (void *core_handle,
103 struct wcd_cpe_afe_port_cfg *cfg);
105 int (*afe_port_cmd_cfg)(void *core_handle,
106 struct wcd_cpe_afe_port_cfg *cfg);
109 struct wcd_cpe_lsm_ops {
111 struct cpe_lsm_session *(*lsm_alloc_session)
112 (void *core_handle, void *lsm_priv_d,
113 void (*event_cb) (void *priv_data,
115 u8 size, u8 *payload));
117 int (*lsm_dealloc_session)
118 (void *core_handle, struct cpe_lsm_session *);
120 int (*lsm_open_tx) (void *core_handle,
121 struct cpe_lsm_session *, u16, u16);
123 int (*lsm_close_tx) (void *core_handle,
124 struct cpe_lsm_session *);
126 int (*lsm_shmem_alloc) (void *core_handle,
127 struct cpe_lsm_session *, u32 size);
129 int (*lsm_shmem_dealloc) (void *core_handle,
130 struct cpe_lsm_session *);
132 int (*lsm_register_snd_model) (void *core_handle,
133 struct cpe_lsm_session *,
134 enum lsm_detection_mode, bool);
136 int (*lsm_deregister_snd_model) (void *core_handle,
137 struct cpe_lsm_session *);
139 int (*lsm_get_afe_out_port_id)(void *core_handle,
140 struct cpe_lsm_session *session);
142 int (*lsm_start) (void *core_handle,
143 struct cpe_lsm_session *);
145 int (*lsm_stop) (void *core_handle,
146 struct cpe_lsm_session *);
148 int (*lsm_lab_control)(void *core_handle,
149 struct cpe_lsm_session *session,
152 int (*lab_ch_setup)(void *core_handle,
153 struct cpe_lsm_session *session,
154 enum wcd_cpe_event event);
156 int (*lsm_set_data) (void *core_handle,
157 struct cpe_lsm_session *session,
158 enum lsm_detection_mode detect_mode,
159 bool detect_failure);
160 int (*lsm_set_fmt_cfg)(void *core_handle,
161 struct cpe_lsm_session *session);
162 int (*lsm_set_one_param)(void *core_handle,
163 struct cpe_lsm_session *session,
164 struct lsm_params_info *p_info,
165 void *data, uint32_t param_type);
166 void (*lsm_get_snd_model_offset)
167 (void *core_handle, struct cpe_lsm_session *,
169 int (*lsm_set_media_fmt_params)(void *core_handle,
170 struct cpe_lsm_session *session,
171 struct lsm_hw_params *param);
172 int (*lsm_set_port)(void *core_handle,
173 struct cpe_lsm_session *session, void *data);
176 int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *);
177 int wcd_cpe_get_afe_ops(struct wcd_cpe_afe_ops *);
178 void *wcd_cpe_get_core_handle(struct snd_soc_codec *);