blob: af6be3ad4515a54eb3752d9e8f79382be3c38434 [file] [log] [blame]
Meng Wang43bbb872018-12-10 12:32:05 +08001// SPDX-License-Identifier: GPL-2.0-only
Laxminath Kasamd08ab1f2020-01-30 19:07:58 +05302/* Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05303 */
4
5#include <linux/init.h>
6#include <linux/err.h>
7#include <linux/module.h>
8#include <linux/platform_device.h>
9#include <linux/slab.h>
10#include <linux/dma-mapping.h>
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053011#include <sound/core.h>
12#include <sound/soc.h>
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053013#include <sound/pcm.h>
14#include <sound/initval.h>
15#include <sound/control.h>
16#include <sound/tlv.h>
17#include <asm/dma.h>
Laxminath Kasam605b42f2017-08-01 22:02:15 +053018#include <dsp/apr_audio-v2.h>
19#include <dsp/q6audio-v2.h>
20#include <dsp/q6asm-v2.h>
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053021
22#include "msm-pcm-routing-v2.h"
23
Meng Wangee084a02018-09-04 16:11:58 +080024#define DRV_NAME "msm-pcm-loopback-v2"
25
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053026#define LOOPBACK_VOL_MAX_STEPS 0x2000
27#define LOOPBACK_SESSION_MAX 4
28
29static DEFINE_MUTEX(loopback_session_lock);
30static const DECLARE_TLV_DB_LINEAR(loopback_rx_vol_gain, 0,
31 LOOPBACK_VOL_MAX_STEPS);
32
33struct msm_pcm_loopback {
34 struct snd_pcm_substream *playback_substream;
35 struct snd_pcm_substream *capture_substream;
36
37 int instance;
38
39 struct mutex lock;
40
41 uint32_t samp_rate;
42 uint32_t channel_mode;
43
44 int playback_start;
45 int capture_start;
46 int session_id;
47 struct audio_client *audio_client;
48 uint32_t volume;
49};
50
51struct fe_dai_session_map {
52 char stream_name[32];
53 struct msm_pcm_loopback *loopback_priv;
54};
55
56static struct fe_dai_session_map session_map[LOOPBACK_SESSION_MAX] = {
57 { {}, NULL},
58 { {}, NULL},
59 { {}, NULL},
60 { {}, NULL},
61};
62
63static u32 hfp_tx_mute;
64
65struct msm_pcm_pdata {
66 int perf_mode;
Dhananjay Kumar807f7e92018-12-11 18:10:08 +053067 struct snd_pcm *pcm_device[MSM_FRONTEND_DAI_MM_SIZE];
68 struct msm_pcm_channel_mixer *chmixer_pspd[MSM_FRONTEND_DAI_MM_SIZE][2];
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053069};
70
71static void stop_pcm(struct msm_pcm_loopback *pcm);
72static int msm_pcm_loopback_get_session(struct snd_soc_pcm_runtime *rtd,
73 struct msm_pcm_loopback **pcm);
74
75static void msm_pcm_route_event_handler(enum msm_pcm_routing_event event,
76 void *priv_data)
77{
78 struct msm_pcm_loopback *pcm = priv_data;
79
80 WARN_ON(!pcm);
81
82 pr_debug("%s: event 0x%x\n", __func__, event);
83
84 switch (event) {
85 case MSM_PCM_RT_EVT_DEVSWITCH:
86 q6asm_cmd(pcm->audio_client, CMD_PAUSE);
87 q6asm_cmd(pcm->audio_client, CMD_FLUSH);
88 q6asm_run(pcm->audio_client, 0, 0, 0);
89 /* fallthrough */
90 default:
91 pr_err("%s: default event 0x%x\n", __func__, event);
92 break;
93 }
94}
95
96static void msm_pcm_loopback_event_handler(uint32_t opcode, uint32_t token,
97 uint32_t *payload, void *priv)
98{
99 pr_debug("%s:\n", __func__);
100 switch (opcode) {
101 case APR_BASIC_RSP_RESULT: {
102 switch (payload[0]) {
103 break;
104 default:
105 break;
106 }
107 }
108 break;
109 default:
110 pr_err("%s: Not Supported Event opcode[0x%x]\n",
111 __func__, opcode);
112 break;
113 }
114}
115
116static int msm_loopback_session_mute_get(struct snd_kcontrol *kcontrol,
117 struct snd_ctl_elem_value *ucontrol)
118{
119 ucontrol->value.integer.value[0] = hfp_tx_mute;
120 return 0;
121}
122
123static int msm_loopback_session_mute_put(struct snd_kcontrol *kcontrol,
124 struct snd_ctl_elem_value *ucontrol)
125{
126 int ret = 0, n = 0;
127 int mute = ucontrol->value.integer.value[0];
128 struct msm_pcm_loopback *pcm = NULL;
129
130 if ((mute < 0) || (mute > 1)) {
131 pr_err(" %s Invalid arguments", __func__);
132 ret = -EINVAL;
133 goto done;
134 }
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530135 mutex_lock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530136 pr_debug("%s: mute=%d\n", __func__, mute);
137 hfp_tx_mute = mute;
138 for (n = 0; n < LOOPBACK_SESSION_MAX; n++) {
139 if (!strcmp(session_map[n].stream_name, "MultiMedia6"))
140 pcm = session_map[n].loopback_priv;
141 }
142 if (pcm && pcm->audio_client) {
143 ret = q6asm_set_mute(pcm->audio_client, mute);
144 if (ret < 0)
145 pr_err("%s: Send mute command failed rc=%d\n",
146 __func__, ret);
147 }
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530148 mutex_unlock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530149done:
150 return ret;
151}
152
153static struct snd_kcontrol_new msm_loopback_controls[] = {
154 SOC_SINGLE_EXT("HFP TX Mute", SND_SOC_NOPM, 0, 1, 0,
155 msm_loopback_session_mute_get,
156 msm_loopback_session_mute_put),
157};
158
Meng Wangee084a02018-09-04 16:11:58 +0800159static int msm_pcm_loopback_probe(struct snd_soc_component *component)
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530160{
Meng Wangee084a02018-09-04 16:11:58 +0800161 snd_soc_add_component_controls(component, msm_loopback_controls,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530162 ARRAY_SIZE(msm_loopback_controls));
163
164 return 0;
165}
166static int pcm_loopback_set_volume(struct msm_pcm_loopback *prtd,
167 uint32_t volume)
168{
169 int rc = -EINVAL;
170
171 pr_debug("%s: Setting volume 0x%x\n", __func__, volume);
172
173 if (prtd && prtd->audio_client) {
174 rc = q6asm_set_volume(prtd->audio_client, volume);
175 if (rc < 0) {
176 pr_err("%s: Send Volume command failed rc = %d\n",
177 __func__, rc);
178 return rc;
179 }
180 prtd->volume = volume;
181 }
182 return rc;
183}
184
185static int msm_pcm_loopback_get_session(struct snd_soc_pcm_runtime *rtd,
186 struct msm_pcm_loopback **pcm)
187{
Meng Wangee084a02018-09-04 16:11:58 +0800188 struct snd_soc_component *component =
189 snd_soc_rtdcom_lookup(rtd, DRV_NAME);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530190 int ret = 0;
191 int n, index = -1;
192
Meng Wangee084a02018-09-04 16:11:58 +0800193 if (!component) {
194 pr_err("%s: component is NULL\n", __func__);
195 return -EINVAL;
196 }
197
198 dev_dbg(component->dev, "%s: stream %s\n", __func__,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530199 rtd->dai_link->stream_name);
200
201 mutex_lock(&loopback_session_lock);
202 for (n = 0; n < LOOPBACK_SESSION_MAX; n++) {
203 if (!strcmp(rtd->dai_link->stream_name,
204 session_map[n].stream_name)) {
205 *pcm = session_map[n].loopback_priv;
206 goto exit;
207 }
208 /*
209 * Store the min index value for allocating a new session.
210 * Here, if session stream name is not found in the
211 * existing entries after the loop iteration, then this
212 * index will be used to allocate the new session.
213 * This index variable is expected to point to the topmost
214 * available free session.
215 */
216 if (!(session_map[n].stream_name[0]) && (index < 0))
217 index = n;
218 }
219
220 if (index < 0) {
Meng Wangee084a02018-09-04 16:11:58 +0800221 dev_err(component->dev, "%s: Max Sessions allocated\n",
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530222 __func__);
223 ret = -EAGAIN;
224 goto exit;
225 }
226
227 session_map[index].loopback_priv = kzalloc(
228 sizeof(struct msm_pcm_loopback), GFP_KERNEL);
229 if (!session_map[index].loopback_priv) {
230 ret = -ENOMEM;
231 goto exit;
232 }
233
234 strlcpy(session_map[index].stream_name,
235 rtd->dai_link->stream_name,
236 sizeof(session_map[index].stream_name));
Meng Wangee084a02018-09-04 16:11:58 +0800237 dev_dbg(component->dev, "%s: stream %s index %d\n",
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530238 __func__, session_map[index].stream_name, index);
239
240 mutex_init(&session_map[index].loopback_priv->lock);
241 *pcm = session_map[index].loopback_priv;
242exit:
243 mutex_unlock(&loopback_session_lock);
244 return ret;
245}
246
247static int msm_pcm_open(struct snd_pcm_substream *substream)
248{
249 struct snd_pcm_runtime *runtime = substream->runtime;
250 struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
Meng Wangee084a02018-09-04 16:11:58 +0800251 struct snd_soc_component *component =
252 snd_soc_rtdcom_lookup(rtd, DRV_NAME);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530253 struct msm_pcm_loopback *pcm = NULL;
254 int ret = 0;
255 uint16_t bits_per_sample = 16;
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530256 struct asm_session_mtmx_strtr_param_window_v2_t asm_mtmx_strtr_window;
257 uint32_t param_id;
258 struct msm_pcm_pdata *pdata;
259
Meng Wangee084a02018-09-04 16:11:58 +0800260 if (!component) {
261 pr_err("%s: component is NULL\n", __func__);
262 return -EINVAL;
263 }
264
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530265 ret = msm_pcm_loopback_get_session(rtd, &pcm);
266 if (ret)
267 return ret;
268
269 mutex_lock(&pcm->lock);
270
271 pcm->volume = 0x2000;
272
273 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
274 pcm->playback_substream = substream;
275 else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
276 pcm->capture_substream = substream;
277
278 pcm->instance++;
Meng Wangee084a02018-09-04 16:11:58 +0800279 dev_dbg(component->dev, "%s: pcm out open: %d,%d\n", __func__,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530280 pcm->instance, substream->stream);
281 if (pcm->instance == 2) {
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530282 if (pcm->audio_client != NULL)
283 stop_pcm(pcm);
284
285 pdata = (struct msm_pcm_pdata *)
Meng Wangee084a02018-09-04 16:11:58 +0800286 dev_get_drvdata(component->dev);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530287 if (!pdata) {
Meng Wangee084a02018-09-04 16:11:58 +0800288 dev_err(component->dev,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530289 "%s: platform data not populated\n", __func__);
290 mutex_unlock(&pcm->lock);
291 return -EINVAL;
292 }
293
294 pcm->audio_client = q6asm_audio_client_alloc(
295 (app_cb)msm_pcm_loopback_event_handler, pcm);
296 if (!pcm->audio_client) {
Meng Wangee084a02018-09-04 16:11:58 +0800297 dev_err(component->dev,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530298 "%s: Could not allocate memory\n", __func__);
299 mutex_unlock(&pcm->lock);
300 return -ENOMEM;
301 }
302 pcm->session_id = pcm->audio_client->session;
303 pcm->audio_client->perf_mode = pdata->perf_mode;
304 ret = q6asm_open_loopback_v2(pcm->audio_client,
305 bits_per_sample);
306 if (ret < 0) {
Meng Wangee084a02018-09-04 16:11:58 +0800307 dev_err(component->dev,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530308 "%s: pcm out open failed\n", __func__);
309 q6asm_audio_client_free(pcm->audio_client);
Deru Wangfbe5c7c2020-03-24 20:06:55 +0800310 pcm->audio_client = NULL;
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530311 mutex_unlock(&pcm->lock);
312 return -ENOMEM;
313 }
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530314 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
315 pcm->playback_substream = substream;
316 ret = pcm_loopback_set_volume(pcm, pcm->volume);
317 if (ret < 0)
Meng Wangee084a02018-09-04 16:11:58 +0800318 dev_err(component->dev,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530319 "Error %d setting volume", ret);
320 }
321 /* Set to largest negative value */
322 asm_mtmx_strtr_window.window_lsw = 0x00000000;
323 asm_mtmx_strtr_window.window_msw = 0x80000000;
324 param_id = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_START_V2;
325 q6asm_send_mtmx_strtr_window(pcm->audio_client,
326 &asm_mtmx_strtr_window,
327 param_id);
328 /* Set to largest positive value */
329 asm_mtmx_strtr_window.window_lsw = 0xffffffff;
330 asm_mtmx_strtr_window.window_msw = 0x7fffffff;
331 param_id = ASM_SESSION_MTMX_STRTR_PARAM_RENDER_WINDOW_END_V2;
332 q6asm_send_mtmx_strtr_window(pcm->audio_client,
333 &asm_mtmx_strtr_window,
334 param_id);
335 }
Meng Wangee084a02018-09-04 16:11:58 +0800336 dev_info(component->dev, "%s: Instance = %d, Stream ID = %s\n",
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530337 __func__, pcm->instance, substream->pcm->id);
338 runtime->private_data = pcm;
339
340 mutex_unlock(&pcm->lock);
341
342 return 0;
343}
344
345static void stop_pcm(struct msm_pcm_loopback *pcm)
346{
347 struct snd_soc_pcm_runtime *soc_pcm_rx;
348 struct snd_soc_pcm_runtime *soc_pcm_tx;
349
Deru Wangfbe5c7c2020-03-24 20:06:55 +0800350 if (pcm->audio_client == NULL) {
351 pr_err("%s: audio client freed\n", __func__);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530352 return;
Deru Wangfbe5c7c2020-03-24 20:06:55 +0800353 }
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530354
355 mutex_lock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530356 q6asm_cmd(pcm->audio_client, CMD_CLOSE);
357
358 if (pcm->playback_substream != NULL) {
359 soc_pcm_rx = pcm->playback_substream->private_data;
360 msm_pcm_routing_dereg_phy_stream(soc_pcm_rx->dai_link->id,
361 SNDRV_PCM_STREAM_PLAYBACK);
362 }
363 if (pcm->capture_substream != NULL) {
364 soc_pcm_tx = pcm->capture_substream->private_data;
365 msm_pcm_routing_dereg_phy_stream(soc_pcm_tx->dai_link->id,
366 SNDRV_PCM_STREAM_CAPTURE);
367 }
368 q6asm_audio_client_free(pcm->audio_client);
369 pcm->audio_client = NULL;
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530370 mutex_unlock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530371}
372
373static int msm_pcm_close(struct snd_pcm_substream *substream)
374{
375 struct snd_pcm_runtime *runtime = substream->runtime;
376 struct msm_pcm_loopback *pcm = runtime->private_data;
377 struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
Meng Wangee084a02018-09-04 16:11:58 +0800378 struct snd_soc_component *component =
379 snd_soc_rtdcom_lookup(rtd, DRV_NAME);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530380 int ret = 0, n;
381 bool found = false;
382
Meng Wangee084a02018-09-04 16:11:58 +0800383 if (!component) {
384 pr_err("%s: component is NULL\n", __func__);
385 return -EINVAL;
386 }
387
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530388 mutex_lock(&pcm->lock);
389
Meng Wangee084a02018-09-04 16:11:58 +0800390 dev_dbg(component->dev, "%s: end pcm call:%d\n",
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530391 __func__, substream->stream);
392 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
393 pcm->playback_start = 0;
394 else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
395 pcm->capture_start = 0;
396
397 pcm->instance--;
398 if (!pcm->playback_start || !pcm->capture_start) {
Meng Wangee084a02018-09-04 16:11:58 +0800399 dev_dbg(component->dev, "%s: end pcm call\n", __func__);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530400 stop_pcm(pcm);
401 }
402
403 if (!pcm->instance) {
404 mutex_lock(&loopback_session_lock);
405 for (n = 0; n < LOOPBACK_SESSION_MAX; n++) {
406 if (!strcmp(rtd->dai_link->stream_name,
407 session_map[n].stream_name)) {
408 found = true;
409 break;
410 }
411 }
412 if (found) {
413 memset(session_map[n].stream_name, 0,
414 sizeof(session_map[n].stream_name));
415 mutex_unlock(&pcm->lock);
416 mutex_destroy(&session_map[n].loopback_priv->lock);
417 session_map[n].loopback_priv = NULL;
418 kfree(pcm);
Meng Wangee084a02018-09-04 16:11:58 +0800419 dev_dbg(component->dev, "%s: stream freed %s\n",
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530420 __func__, rtd->dai_link->stream_name);
421 mutex_unlock(&loopback_session_lock);
422 return 0;
423 }
424 mutex_unlock(&loopback_session_lock);
425 }
426 mutex_unlock(&pcm->lock);
427 return ret;
428}
429
430static int msm_pcm_prepare(struct snd_pcm_substream *substream)
431{
432 int ret = 0;
433 struct snd_pcm_runtime *runtime = substream->runtime;
434 struct msm_pcm_loopback *pcm = runtime->private_data;
435 struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
Meng Wangee084a02018-09-04 16:11:58 +0800436 struct snd_soc_component *component =
437 snd_soc_rtdcom_lookup(rtd, DRV_NAME);
Cong Tangd083a832019-08-27 16:21:06 +0530438 struct msm_pcm_routing_evt event;
Meng Wangee084a02018-09-04 16:11:58 +0800439
Cong Tangd083a832019-08-27 16:21:06 +0530440 memset(&event, 0, sizeof(event));
Meng Wangee084a02018-09-04 16:11:58 +0800441 if (!component) {
442 pr_err("%s: component is NULL\n", __func__);
443 return -EINVAL;
444 }
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530445
446 mutex_lock(&pcm->lock);
447
Meng Wangee084a02018-09-04 16:11:58 +0800448 dev_dbg(component->dev, "%s: ASM loopback stream:%d\n",
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530449 __func__, substream->stream);
Cong Tangd083a832019-08-27 16:21:06 +0530450
451 if (pcm->playback_start && pcm->capture_start) {
452 mutex_unlock(&pcm->lock);
453 return ret;
454 }
455
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530456 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
457 if (!pcm->playback_start)
458 pcm->playback_start = 1;
459 } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
460 if (!pcm->capture_start)
461 pcm->capture_start = 1;
462 }
Cong Tangd083a832019-08-27 16:21:06 +0530463
464 if (pcm->playback_start && pcm->capture_start) {
465 struct snd_soc_pcm_runtime *soc_pcm_rx =
466 pcm->playback_substream->private_data;
467 struct snd_soc_pcm_runtime *soc_pcm_tx =
468 pcm->capture_substream->private_data;
469 event.event_func = msm_pcm_route_event_handler;
470 event.priv_data = (void *) pcm;
Guodong Hu100a2502020-04-14 23:03:31 +0800471
472 if (!pcm->audio_client) {
473 mutex_unlock(&pcm->lock);
474 pr_err("%s: audio client freed\n", __func__);
475 return -EINVAL;
476 }
Cong Tangd083a832019-08-27 16:21:06 +0530477 msm_pcm_routing_reg_phy_stream(soc_pcm_tx->dai_link->id,
478 pcm->audio_client->perf_mode,
479 pcm->session_id, pcm->capture_substream->stream);
480 msm_pcm_routing_reg_phy_stream_v2(soc_pcm_rx->dai_link->id,
481 pcm->audio_client->perf_mode,
482 pcm->session_id, pcm->playback_substream->stream,
483 event);
484 }
485
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530486 mutex_unlock(&pcm->lock);
487
488 return ret;
489}
490
491static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
492{
493 struct snd_pcm_runtime *runtime = substream->runtime;
494 struct msm_pcm_loopback *pcm = runtime->private_data;
495 struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
Meng Wangee084a02018-09-04 16:11:58 +0800496 struct snd_soc_component *component =
497 snd_soc_rtdcom_lookup(rtd, DRV_NAME);
498
499 if (!component) {
500 pr_err("%s: component is NULL\n", __func__);
501 return -EINVAL;
502 }
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530503
504 switch (cmd) {
505 case SNDRV_PCM_TRIGGER_START:
506 case SNDRV_PCM_TRIGGER_RESUME:
507 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
Meng Wangee084a02018-09-04 16:11:58 +0800508 dev_dbg(component->dev,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530509 "%s: playback_start:%d,capture_start:%d\n", __func__,
510 pcm->playback_start, pcm->capture_start);
511 if (pcm->playback_start && pcm->capture_start)
512 q6asm_run_nowait(pcm->audio_client, 0, 0, 0);
513 break;
514 case SNDRV_PCM_TRIGGER_SUSPEND:
515 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
516 case SNDRV_PCM_TRIGGER_STOP:
Meng Wangee084a02018-09-04 16:11:58 +0800517 dev_dbg(component->dev,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530518 "%s:Pause/Stop - playback_start:%d,capture_start:%d\n",
519 __func__, pcm->playback_start, pcm->capture_start);
520 if (pcm->playback_start && pcm->capture_start)
521 q6asm_cmd_nowait(pcm->audio_client, CMD_PAUSE);
522 break;
523 default:
524 pr_err("%s: default cmd %d\n", __func__, cmd);
525 break;
526 }
527
528 return 0;
529}
530
531static const struct snd_pcm_ops msm_pcm_ops = {
532 .open = msm_pcm_open,
533 .close = msm_pcm_close,
534 .prepare = msm_pcm_prepare,
535 .trigger = msm_pcm_trigger,
536};
537
538static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol)
540{
541 int rc = 0;
542 struct snd_pcm_volume *vol = kcontrol->private_data;
543 struct snd_pcm_substream *substream = vol->pcm->streams[0].substream;
544 struct msm_pcm_loopback *prtd;
545 int volume = ucontrol->value.integer.value[0];
546
547 pr_debug("%s: volume : 0x%x\n", __func__, volume);
548 if ((!substream) || (!substream->runtime)) {
549 pr_err("%s substream or runtime not found\n", __func__);
550 rc = -ENODEV;
551 goto exit;
552 }
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530553 mutex_lock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530554 prtd = substream->runtime->private_data;
555 if (!prtd) {
556 rc = -ENODEV;
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530557 mutex_unlock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530558 goto exit;
559 }
560 rc = pcm_loopback_set_volume(prtd, volume);
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530561 mutex_unlock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530562exit:
563 return rc;
564}
565
566static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
568{
569 int rc = 0;
570 struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
Laxminath Kasamd08ab1f2020-01-30 19:07:58 +0530571 struct snd_pcm_substream *substream = NULL;
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530572 struct msm_pcm_loopback *prtd;
573
574 pr_debug("%s\n", __func__);
Laxminath Kasamd08ab1f2020-01-30 19:07:58 +0530575 if (!vol) {
576 pr_err("%s: vol is NULL\n", __func__);
577 return -ENODEV;
578 }
579 substream = vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530580 if ((!substream) || (!substream->runtime)) {
Vignesh Kulothungan2ce67842018-09-25 16:40:29 -0700581 pr_debug("%s substream or runtime not found\n", __func__);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530582 rc = -ENODEV;
583 goto exit;
584 }
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530585 mutex_lock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530586 prtd = substream->runtime->private_data;
587 if (!prtd) {
588 rc = -ENODEV;
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530589 mutex_unlock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530590 goto exit;
591 }
592 ucontrol->value.integer.value[0] = prtd->volume;
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530593 mutex_unlock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530594exit:
595 return rc;
596}
597
598static int msm_pcm_add_volume_controls(struct snd_soc_pcm_runtime *rtd)
599{
600 struct snd_pcm *pcm = rtd->pcm->streams[0].pcm;
601 struct snd_pcm_volume *volume_info;
602 struct snd_kcontrol *kctl;
603 int ret = 0;
604
605 dev_dbg(rtd->dev, "%s, Volume cntrl add\n", __func__);
606 ret = snd_pcm_add_volume_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
607 NULL, 1,
608 rtd->dai_link->id,
609 &volume_info);
610 if (ret < 0)
611 return ret;
612 kctl = volume_info->kctl;
613 kctl->put = msm_pcm_volume_ctl_put;
614 kctl->get = msm_pcm_volume_ctl_get;
615 kctl->tlv.p = loopback_rx_vol_gain;
616 return 0;
617}
618
619static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
620 struct snd_ctl_elem_value *ucontrol)
621{
622 u64 fe_id = kcontrol->private_value;
623 int session_type = SESSION_TYPE_RX;
624 int be_id = ucontrol->value.integer.value[3];
625 struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
626 int ret = 0;
627
628 cfg_data.app_type = ucontrol->value.integer.value[0];
629 cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
630 if (ucontrol->value.integer.value[2] != 0)
631 cfg_data.sample_rate = ucontrol->value.integer.value[2];
632 pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
633 __func__, fe_id, session_type, be_id,
634 cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
635 ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
636 be_id, &cfg_data);
637 if (ret < 0)
638 pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
639 __func__, ret);
640
641 return ret;
642}
643
644static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_value *ucontrol)
646{
647 u64 fe_id = kcontrol->private_value;
648 int session_type = SESSION_TYPE_RX;
649 int be_id = 0;
650 struct msm_pcm_stream_app_type_cfg cfg_data = {0};
651 int ret = 0;
652
653 ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
654 &be_id, &cfg_data);
655 if (ret < 0) {
656 pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
657 __func__, ret);
658 goto done;
659 }
660
661 ucontrol->value.integer.value[0] = cfg_data.app_type;
662 ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
663 ucontrol->value.integer.value[2] = cfg_data.sample_rate;
664 ucontrol->value.integer.value[3] = be_id;
665 pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
666 __func__, fe_id, session_type, be_id,
667 cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
668done:
669 return ret;
670}
671
672static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
674{
675 u64 fe_id = kcontrol->private_value;
676 int session_type = SESSION_TYPE_TX;
677 int be_id = ucontrol->value.integer.value[3];
678 struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
679 int ret = 0;
680
681 cfg_data.app_type = ucontrol->value.integer.value[0];
682 cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
683 if (ucontrol->value.integer.value[2] != 0)
684 cfg_data.sample_rate = ucontrol->value.integer.value[2];
685 pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
686 __func__, fe_id, session_type, be_id,
687 cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
688 ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
689 be_id, &cfg_data);
690 if (ret < 0)
691 pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
692 __func__, ret);
693
694 return ret;
695}
696
697static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
698 struct snd_ctl_elem_value *ucontrol)
699{
700 u64 fe_id = kcontrol->private_value;
701 int session_type = SESSION_TYPE_TX;
702 int be_id = 0;
703 struct msm_pcm_stream_app_type_cfg cfg_data = {0};
704 int ret = 0;
705
706 ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
707 &be_id, &cfg_data);
708 if (ret < 0) {
709 pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
710 __func__, ret);
711 goto done;
712 }
713
714 ucontrol->value.integer.value[0] = cfg_data.app_type;
715 ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
716 ucontrol->value.integer.value[2] = cfg_data.sample_rate;
717 ucontrol->value.integer.value[3] = be_id;
718 pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
719 __func__, fe_id, session_type, be_id,
720 cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
721done:
722 return ret;
723}
724
725static int msm_pcm_add_app_type_controls(struct snd_soc_pcm_runtime *rtd)
726{
727 struct snd_pcm *pcm = rtd->pcm->streams[0].pcm;
728 struct snd_pcm_usr *app_type_info;
729 struct snd_kcontrol *kctl;
730 const char *playback_mixer_ctl_name = "Audio Stream";
731 const char *capture_mixer_ctl_name = "Audio Stream Capture";
732 const char *deviceNo = "NN";
733 const char *suffix = "App Type Cfg";
734 int ctl_len, ret = 0;
735
736 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
737 ctl_len = strlen(playback_mixer_ctl_name) + 1 +
738 strlen(deviceNo) + 1 + strlen(suffix) + 1;
739 pr_debug("%s: Playback app type cntrl add\n", __func__);
740 ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
741 NULL, 1, ctl_len, rtd->dai_link->id,
742 &app_type_info);
743 if (ret < 0)
744 return ret;
745 kctl = app_type_info->kctl;
746 snprintf(kctl->id.name, ctl_len, "%s %d %s",
747 playback_mixer_ctl_name, rtd->pcm->device, suffix);
748 kctl->put = msm_pcm_playback_app_type_cfg_ctl_put;
749 kctl->get = msm_pcm_playback_app_type_cfg_ctl_get;
750 }
751
752 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
753 ctl_len = strlen(capture_mixer_ctl_name) + 1 +
754 strlen(deviceNo) + 1 + strlen(suffix) + 1;
755 pr_debug("%s: Capture app type cntrl add\n", __func__);
756 ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_CAPTURE,
757 NULL, 1, ctl_len, rtd->dai_link->id,
758 &app_type_info);
759 if (ret < 0)
760 return ret;
761 kctl = app_type_info->kctl;
762 snprintf(kctl->id.name, ctl_len, "%s %d %s",
763 capture_mixer_ctl_name, rtd->pcm->device, suffix);
764 kctl->put = msm_pcm_capture_app_type_cfg_ctl_put;
765 kctl->get = msm_pcm_capture_app_type_cfg_ctl_get;
766 }
767
768 return 0;
769}
770
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530771static struct msm_pcm_channel_mixer *msm_pcm_get_chmixer(
772 struct msm_pcm_pdata *pdata,
773 u64 fe_id, int session_type)
774{
775 if (!pdata) {
776 pr_err("%s: missing pdata\n", __func__);
777 return NULL;
778 }
779
780 if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
781 pr_err("%s: invalid FE %llu\n", __func__, fe_id);
782 return NULL;
783 }
784
785 if ((session_type != SESSION_TYPE_TX) &&
786 (session_type != SESSION_TYPE_RX)) {
787 pr_err("%s: invalid session type %d\n", __func__, session_type);
788 return NULL;
789 }
790
791 return pdata->chmixer_pspd[fe_id][session_type];
792}
793
794static int msm_pcm_channel_mixer_cfg_ctl_put(struct snd_kcontrol *kcontrol,
795 struct snd_ctl_elem_value *ucontrol)
796{
797 u64 fe_id = kcontrol->private_value & 0xFF;
798 int session_type = (kcontrol->private_value >> 8) & 0xFF;
799 int ret = 0;
800 int stream_id = 0;
801 int be_id = 0, i = 0;
802 struct msm_pcm_loopback *prtd = NULL;
803 struct snd_soc_component *component =
804 snd_soc_kcontrol_component(kcontrol);
805 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
806 struct snd_pcm *pcm = NULL;
807 struct snd_pcm_substream *substream = NULL;
808 struct msm_pcm_channel_mixer *chmixer_pspd = NULL;
809 u8 asm_ch_map[PCM_FORMAT_MAX_NUM_CHANNEL_V8] = {0};
810 bool reset_override_out_ch_map = false;
811 bool reset_override_in_ch_map = false;
812
813 pcm = pdata->pcm_device[fe_id];
814 if (!pcm) {
815 pr_err("%s invalid pcm handle for fe_id %llu\n",
816 __func__, fe_id);
817 return -EINVAL;
818 }
819
820 if (session_type == SESSION_TYPE_RX)
821 substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
822 else
823 substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
824 if (!substream) {
825 pr_err("%s substream not found\n", __func__);
826 return -EINVAL;
827 }
828
829 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
830 if (!chmixer_pspd) {
831 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
832 return -EINVAL;
833 }
834
835 chmixer_pspd->enable = ucontrol->value.integer.value[0];
836 chmixer_pspd->rule = ucontrol->value.integer.value[1];
837 chmixer_pspd->input_channel = ucontrol->value.integer.value[2];
838 chmixer_pspd->output_channel = ucontrol->value.integer.value[3];
839 chmixer_pspd->port_idx = ucontrol->value.integer.value[4];
840
841 if (chmixer_pspd->enable) {
842 if (session_type == SESSION_TYPE_RX &&
843 !chmixer_pspd->override_in_ch_map) {
Rohit kumar2a64e522019-02-04 11:22:49 +0530844 if (chmixer_pspd->input_channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
845 pr_err("%s: Invalid channel count %d\n",
846 __func__, chmixer_pspd->input_channel);
847 return -EINVAL;
848 }
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530849 q6asm_map_channels(asm_ch_map,
850 chmixer_pspd->input_channel, false);
851 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
852 chmixer_pspd->in_ch_map[i] = asm_ch_map[i];
853 chmixer_pspd->override_in_ch_map = true;
854 reset_override_in_ch_map = true;
855 } else if (session_type == SESSION_TYPE_TX &&
856 !chmixer_pspd->override_out_ch_map) {
Rohit kumar2a64e522019-02-04 11:22:49 +0530857 if (chmixer_pspd->output_channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
858 pr_err("%s: Invalid channel count %d\n",
859 __func__, chmixer_pspd->output_channel);
860 return -EINVAL;
861 }
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530862 q6asm_map_channels(asm_ch_map,
863 chmixer_pspd->output_channel, false);
864 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
865 chmixer_pspd->out_ch_map[i] = asm_ch_map[i];
866 chmixer_pspd->override_out_ch_map = true;
867 reset_override_out_ch_map = true;
868 }
869 } else {
870 chmixer_pspd->override_out_ch_map = false;
871 chmixer_pspd->override_in_ch_map = false;
872 }
873
874 /* cache value and take effect during adm_open stage */
875 msm_pcm_routing_set_channel_mixer_cfg(fe_id,
876 session_type,
877 chmixer_pspd);
878
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530879 mutex_lock(&loopback_session_lock);
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530880 if (chmixer_pspd->enable && substream->runtime) {
881 prtd = substream->runtime->private_data;
882 if (!prtd) {
883 pr_err("%s find invalid prtd fail\n", __func__);
884 ret = -EINVAL;
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530885 mutex_unlock(&loopback_session_lock);
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530886 goto done;
887 }
888
889 if (prtd->audio_client) {
890 stream_id = prtd->audio_client->session;
891 be_id = chmixer_pspd->port_idx;
892 msm_pcm_routing_set_channel_mixer_runtime(be_id,
893 stream_id,
894 session_type,
895 chmixer_pspd);
896 }
897 }
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530898 mutex_unlock(&loopback_session_lock);
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530899 if (reset_override_out_ch_map)
900 chmixer_pspd->override_out_ch_map = false;
901 if (reset_override_in_ch_map)
902 chmixer_pspd->override_in_ch_map = false;
903
904done:
905 return ret;
906}
907
908static int msm_pcm_channel_mixer_cfg_ctl_get(struct snd_kcontrol *kcontrol,
909 struct snd_ctl_elem_value *ucontrol)
910{
911 u64 fe_id = kcontrol->private_value & 0xFF;
912 int session_type = (kcontrol->private_value >> 8) & 0xFF;
913 struct snd_soc_component *component =
914 snd_soc_kcontrol_component(kcontrol);
915 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
916 struct msm_pcm_channel_mixer *chmixer_pspd;
917
918 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
919 if (!chmixer_pspd) {
920 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
921 return -EINVAL;
922 }
923
924 ucontrol->value.integer.value[0] = chmixer_pspd->enable;
925 ucontrol->value.integer.value[1] = chmixer_pspd->rule;
926 ucontrol->value.integer.value[2] = chmixer_pspd->input_channel;
927 ucontrol->value.integer.value[3] = chmixer_pspd->output_channel;
928 ucontrol->value.integer.value[4] = chmixer_pspd->port_idx;
929 return 0;
930}
931
932static int msm_pcm_channel_mixer_output_map_ctl_put(
933 struct snd_kcontrol *kcontrol,
934 struct snd_ctl_elem_value *ucontrol)
935{
936 u64 fe_id = kcontrol->private_value & 0xFF;
937 int session_type = (kcontrol->private_value >> 8) & 0xFF;
938 int i = 0;
939 struct snd_soc_component *component =
940 snd_soc_kcontrol_component(kcontrol);
941 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
942 struct msm_pcm_channel_mixer *chmixer_pspd;
943
944 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
945 if (!chmixer_pspd) {
946 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
947 return -EINVAL;
948 }
949
950 chmixer_pspd->override_out_ch_map = true;
951 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
952 chmixer_pspd->out_ch_map[i] =
953 ucontrol->value.integer.value[i];
954
955 return 0;
956}
957
958static int msm_pcm_channel_mixer_output_map_ctl_get(
959 struct snd_kcontrol *kcontrol,
960 struct snd_ctl_elem_value *ucontrol)
961{
962 u64 fe_id = kcontrol->private_value & 0xFF;
963 int session_type = (kcontrol->private_value >> 8) & 0xFF;
964 int i = 0;
965 struct snd_soc_component *component =
966 snd_soc_kcontrol_component(kcontrol);
967 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
968 struct msm_pcm_channel_mixer *chmixer_pspd;
969
970 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
971 if (!chmixer_pspd) {
972 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
973 return -EINVAL;
974 }
975
976 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
977 ucontrol->value.integer.value[i] =
978 chmixer_pspd->out_ch_map[i];
979 return 0;
980}
981
982static int msm_pcm_channel_mixer_input_map_ctl_put(
983 struct snd_kcontrol *kcontrol,
984 struct snd_ctl_elem_value *ucontrol)
985{
986 u64 fe_id = kcontrol->private_value & 0xFF;
987 int session_type = (kcontrol->private_value >> 8) & 0xFF;
988 int i = 0;
989 struct snd_soc_component *component =
990 snd_soc_kcontrol_component(kcontrol);
991 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
992 struct msm_pcm_channel_mixer *chmixer_pspd;
993
994 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
995 if (!chmixer_pspd) {
996 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
997 return -EINVAL;
998 }
999
1000 chmixer_pspd->override_in_ch_map = true;
1001 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
1002 chmixer_pspd->in_ch_map[i] = ucontrol->value.integer.value[i];
1003
1004 return 0;
1005}
1006
1007static int msm_pcm_channel_mixer_input_map_ctl_get(
1008 struct snd_kcontrol *kcontrol,
1009 struct snd_ctl_elem_value *ucontrol)
1010{
1011 u64 fe_id = kcontrol->private_value & 0xFF;
1012 int session_type = (kcontrol->private_value >> 8) & 0xFF;
1013 int i = 0;
1014 struct snd_soc_component *component =
1015 snd_soc_kcontrol_component(kcontrol);
1016 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
1017 struct msm_pcm_channel_mixer *chmixer_pspd;
1018
1019 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
1020 if (!chmixer_pspd) {
1021 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
1022 return -EINVAL;
1023 }
1024
1025 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
1026 ucontrol->value.integer.value[i] =
1027 chmixer_pspd->in_ch_map[i];
1028 return 0;
1029}
1030
1031static int msm_pcm_channel_mixer_weight_ctl_put(
1032 struct snd_kcontrol *kcontrol,
1033 struct snd_ctl_elem_value *ucontrol)
1034{
1035 u64 fe_id = kcontrol->private_value & 0xFF;
1036 int session_type = (kcontrol->private_value >> 8) & 0xFF;
1037 int channel = (kcontrol->private_value >> 16) & 0xFF;
1038 int i = 0;
1039 struct snd_soc_component *component =
1040 snd_soc_kcontrol_component(kcontrol);
1041 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
1042 struct msm_pcm_channel_mixer *chmixer_pspd;
1043
1044 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
1045 if (!chmixer_pspd) {
1046 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
1047 return -EINVAL;
1048 }
1049
1050 if (channel <= 0 || channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
1051 pr_err("%s: invalid channel number %d\n", __func__, channel);
1052 return -EINVAL;
1053 }
1054 channel--;
1055
1056 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
1057 chmixer_pspd->channel_weight[channel][i] =
1058 ucontrol->value.integer.value[i];
1059 return 0;
1060}
1061
1062static int msm_pcm_channel_mixer_weight_ctl_get(
1063 struct snd_kcontrol *kcontrol,
1064 struct snd_ctl_elem_value *ucontrol)
1065{
1066 u64 fe_id = kcontrol->private_value & 0xFF;
1067 int session_type = (kcontrol->private_value >> 8) & 0xFF;
1068 int channel = (kcontrol->private_value >> 16) & 0xFF;
1069 struct snd_soc_component *component =
1070 snd_soc_kcontrol_component(kcontrol);
1071 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
1072 int i = 0;
1073 struct msm_pcm_channel_mixer *chmixer_pspd;
1074
1075 if (channel <= 0 || channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
1076 pr_err("%s: invalid channel number %d\n", __func__, channel);
1077 return -EINVAL;
1078 }
1079 channel--;
1080
1081 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
1082 if (!chmixer_pspd) {
1083 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
1084 return -EINVAL;
1085 }
1086
1087 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
1088 ucontrol->value.integer.value[i] =
1089 chmixer_pspd->channel_weight[channel][i];
1090 return 0;
1091}
1092
1093static int msm_pcm_add_platform_controls(struct snd_kcontrol_new *kctl,
1094 struct snd_soc_pcm_runtime *rtd, const char *name_prefix,
1095 const char *name_suffix, int session_type, int channels)
1096{
1097 int ret = -EINVAL;
1098 char *mixer_name = NULL;
1099 struct snd_pcm *pcm = rtd->pcm;
1100 const char *deviceNo = "NN";
1101 const char *channelNo = "NN";
1102 int ctl_len = 0;
1103 struct snd_soc_component *component = NULL;
1104
1105 component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
1106 if (!component) {
1107 pr_err("%s: component is NULL\n", __func__);
1108 return -EINVAL;
1109 }
1110
1111 ctl_len = strlen(name_prefix) + 1 + strlen(deviceNo) + 1 +
1112 strlen(channelNo) + 1 + strlen(name_suffix) + 1;
1113
1114 mixer_name = kzalloc(ctl_len, GFP_KERNEL);
1115 if (mixer_name == NULL)
1116 return -ENOMEM;
1117
1118 if (channels >= 0) {
1119 snprintf(mixer_name, ctl_len, "%s %d %s %d",
1120 name_prefix, pcm->device, name_suffix, channels);
1121 kctl->private_value = (rtd->dai_link->id) | (session_type << 8) |
1122 (channels << 16);
1123 } else {
1124 snprintf(mixer_name, ctl_len, "%s %d %s",
1125 name_prefix, pcm->device, name_suffix);
1126 kctl->private_value = (rtd->dai_link->id) | (session_type << 8);
1127 }
1128
1129 kctl->name = mixer_name;
1130 ret = snd_soc_add_component_controls(component, kctl, 1);
1131 kfree(mixer_name);
1132 return ret;
1133}
1134
1135static int msm_pcm_channel_mixer_output_map_info(struct snd_kcontrol *kcontrol,
1136 struct snd_ctl_elem_info *uinfo)
1137{
1138 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1139 uinfo->count = PCM_FORMAT_MAX_NUM_CHANNEL_V8;
1140 /* Valid channel map value ranges from 1 to 64 */
1141 uinfo->value.integer.min = 1;
1142 uinfo->value.integer.max = 64;
1143 return 0;
1144}
1145
1146static int msm_pcm_add_channel_mixer_output_map_controls(
1147 struct snd_soc_pcm_runtime *rtd)
1148{
1149 struct snd_pcm *pcm = rtd->pcm;
1150 const char *playback_mixer_ctl_name = "AudStr";
1151 const char *capture_mixer_ctl_name = "AudStr Capture";
1152 const char *suffix = "ChMixer Output Map";
1153 int session_type = 0, ret = 0, channel = -1;
1154 struct snd_kcontrol_new channel_mixer_output_map_control = {
1155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1156 .name = "?",
1157 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1158 .info = msm_pcm_channel_mixer_output_map_info,
1159 .put = msm_pcm_channel_mixer_output_map_ctl_put,
1160 .get = msm_pcm_channel_mixer_output_map_ctl_get,
1161 .private_value = 0,
1162 };
1163
1164 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream != NULL) {
1165 session_type = SESSION_TYPE_RX;
1166 ret = msm_pcm_add_platform_controls(&channel_mixer_output_map_control,
1167 rtd, playback_mixer_ctl_name, suffix, session_type, channel);
1168 if (ret < 0)
1169 goto fail;
1170 }
1171
1172 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream != NULL) {
1173 session_type = SESSION_TYPE_TX;
1174 ret = msm_pcm_add_platform_controls(&channel_mixer_output_map_control,
1175 rtd, capture_mixer_ctl_name, suffix, session_type, channel);
1176 if (ret < 0)
1177 goto fail;
1178 }
1179 return 0;
1180
1181fail:
1182 pr_err("%s: failed add platform ctl, err = %d\n",
1183 __func__, ret);
1184
1185 return ret;
1186}
1187
1188static int msm_pcm_channel_mixer_input_map_info(struct snd_kcontrol *kcontrol,
1189 struct snd_ctl_elem_info *uinfo)
1190{
1191 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1192 uinfo->count = PCM_FORMAT_MAX_NUM_CHANNEL_V8;
1193 /* Valid channel map value ranges from 1 to 64 */
1194 uinfo->value.integer.min = 1;
1195 uinfo->value.integer.max = 64;
1196 return 0;
1197}
1198
1199static int msm_pcm_add_channel_mixer_input_map_controls(
1200 struct snd_soc_pcm_runtime *rtd)
1201{
1202 struct snd_pcm *pcm = rtd->pcm;
1203 const char *playback_mixer_ctl_name = "AudStr";
1204 const char *capture_mixer_ctl_name = "AudStr Capture";
1205 const char *suffix = "ChMixer Input Map";
1206 int session_type = 0, ret = 0, channel = -1;
1207 struct snd_kcontrol_new channel_mixer_input_map_control = {
1208 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1209 .name = "?",
1210 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1211 .info = msm_pcm_channel_mixer_input_map_info,
1212 .put = msm_pcm_channel_mixer_input_map_ctl_put,
1213 .get = msm_pcm_channel_mixer_input_map_ctl_get,
1214 .private_value = 0,
1215 };
1216
1217 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream != NULL) {
1218 session_type = SESSION_TYPE_RX;
1219 ret = msm_pcm_add_platform_controls(&channel_mixer_input_map_control,
1220 rtd, playback_mixer_ctl_name, suffix, session_type, channel);
1221 if (ret < 0)
1222 goto fail;
1223 }
1224
1225 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream != NULL) {
1226 session_type = SESSION_TYPE_TX;
1227 ret = msm_pcm_add_platform_controls(&channel_mixer_input_map_control,
1228 rtd, capture_mixer_ctl_name, suffix, session_type, channel);
1229 if (ret < 0)
1230 goto fail;
1231 }
1232 return 0;
1233
1234fail:
1235 pr_err("%s: failed add platform ctl, err = %d\n",
1236 __func__, ret);
1237 return ret;
1238}
1239
1240static int msm_pcm_channel_mixer_cfg_info(struct snd_kcontrol *kcontrol,
1241 struct snd_ctl_elem_info *uinfo)
1242{
1243 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1244 /* five int values: enable, rule, in_channels, out_channels and port_id */
1245 uinfo->count = 5;
1246 /* Valid range is all positive values to support above controls */
1247 uinfo->value.integer.min = 0;
1248 uinfo->value.integer.max = INT_MAX;
1249 return 0;
1250}
1251
1252static int msm_pcm_add_channel_mixer_cfg_controls(
1253 struct snd_soc_pcm_runtime *rtd)
1254{
1255 struct snd_pcm *pcm = rtd->pcm;
1256 const char *playback_mixer_ctl_name = "AudStr";
1257 const char *capture_mixer_ctl_name = "AudStr Capture";
1258 const char *suffix = "ChMixer Cfg";
1259 int session_type = 0, ret = 0, channel = -1;
1260 struct msm_pcm_pdata *pdata = NULL;
1261 struct snd_soc_component *component = NULL;
1262 struct snd_kcontrol_new channel_mixer_cfg_control = {
1263 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1264 .name = "?",
1265 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1266 .info = msm_pcm_channel_mixer_cfg_info,
1267 .put = msm_pcm_channel_mixer_cfg_ctl_put,
1268 .get = msm_pcm_channel_mixer_cfg_ctl_get,
1269 .private_value = 0,
1270 };
1271
1272 component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
1273 if (!component) {
1274 pr_err("%s: component is NULL\n", __func__);
1275 return -EINVAL;
1276 }
1277 pdata = (struct msm_pcm_pdata *)
1278 dev_get_drvdata(component->dev);
1279 if (pdata == NULL) {
1280 pr_err("%s: platform data not populated\n", __func__);
1281 return -EINVAL;
1282 }
1283
1284 pdata->pcm_device[rtd->dai_link->id] = rtd->pcm;
1285
1286 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream != NULL) {
1287 session_type = SESSION_TYPE_RX;
1288 ret = msm_pcm_add_platform_controls(&channel_mixer_cfg_control,
1289 rtd, playback_mixer_ctl_name, suffix, session_type, channel);
1290 if (ret < 0)
1291 goto fail;
1292 }
1293
1294 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream != NULL) {
1295 session_type = SESSION_TYPE_TX;
1296 ret = msm_pcm_add_platform_controls(&channel_mixer_cfg_control,
1297 rtd, capture_mixer_ctl_name, suffix, session_type, channel);
1298 if (ret < 0)
1299 goto fail;
1300 }
1301 return 0;
1302
1303fail:
1304 pr_err("%s: failed add platform ctl, err = %d\n",
1305 __func__, ret);
1306
1307 return ret;
1308}
1309
1310static int msm_pcm_channel_mixer_weight_info(struct snd_kcontrol *kcontrol,
1311 struct snd_ctl_elem_info *uinfo)
1312{
1313 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1314 uinfo->count = PCM_FORMAT_MAX_NUM_CHANNEL_V8;
1315 /* Valid range: 0 to 0x4000(Unity) gain weightage */
1316 uinfo->value.integer.min = 0;
1317 uinfo->value.integer.max = 0x4000;
1318 return 0;
1319}
1320
1321static int msm_pcm_add_channel_mixer_weight_controls(
1322 struct snd_soc_pcm_runtime *rtd,
1323 int channel)
1324{
1325 struct snd_pcm *pcm = rtd->pcm;
1326 const char *playback_mixer_ctl_name = "AudStr";
1327 const char *capture_mixer_ctl_name = "AudStr Capture";
1328 const char *suffix = "ChMixer Weight Ch";
1329 int session_type = 0, ret = 0;
1330 struct snd_kcontrol_new channel_mixer_weight_control = {
1331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1332 .name = "?",
1333 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1334 .info = msm_pcm_channel_mixer_weight_info,
1335 .put = msm_pcm_channel_mixer_weight_ctl_put,
1336 .get = msm_pcm_channel_mixer_weight_ctl_get,
1337 .private_value = 0,
1338 };
1339
1340 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream != NULL) {
1341 session_type = SESSION_TYPE_RX;
1342 ret = msm_pcm_add_platform_controls(&channel_mixer_weight_control,
1343 rtd, playback_mixer_ctl_name, suffix, session_type, channel);
1344 if (ret < 0)
1345 goto fail;
1346 }
1347
1348 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream != NULL) {
1349 session_type = SESSION_TYPE_TX;
1350 ret = msm_pcm_add_platform_controls(&channel_mixer_weight_control,
1351 rtd, capture_mixer_ctl_name, suffix, session_type, channel);
1352 if (ret < 0)
1353 goto fail;
1354 }
1355 return 0;
1356
1357fail:
1358 pr_err("%s: failed add platform ctl, err = %d\n",
1359 __func__, ret);
1360
1361 return ret;
1362}
1363
1364static int msm_pcm_add_channel_mixer_controls(struct snd_soc_pcm_runtime *rtd)
1365{
1366 int i, ret = 0;
1367 struct snd_pcm *pcm = NULL;
1368 struct msm_pcm_pdata *pdata = NULL;
1369 struct snd_soc_component *component = NULL;
1370
1371 if (!rtd || !rtd->pcm) {
1372 pr_err("%s invalid rtd or pcm\n", __func__);
1373 return -EINVAL;
1374 }
1375 pcm = rtd->pcm;
1376
1377 component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
1378 if (!component) {
1379 pr_err("%s: component is NULL\n", __func__);
1380 return -EINVAL;
1381 }
1382
1383 pdata = (struct msm_pcm_pdata *)
1384 dev_get_drvdata(component->dev);
1385 if (!pdata) {
1386 pr_err("%s: platform data not populated\n", __func__);
1387 return -EINVAL;
1388 }
1389
1390 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream &&
1391 !pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_RX]) {
1392 pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_RX] =
1393 kzalloc(sizeof(struct msm_pcm_channel_mixer), GFP_KERNEL);
1394 if (!pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_RX]) {
1395 ret = -ENOMEM;
1396 goto fail;
1397 }
1398 }
1399
1400 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream &&
1401 !pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_TX]) {
1402 pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_TX] =
1403 kzalloc(sizeof(struct msm_pcm_channel_mixer), GFP_KERNEL);
1404 if (!pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_TX]) {
1405 ret = -ENOMEM;
1406 goto fail;
1407 }
1408 }
1409
1410 ret = msm_pcm_add_channel_mixer_cfg_controls(rtd);
1411 if (ret) {
1412 pr_err("%s: pcm add channel mixer cfg controls failed:%d\n",
1413 __func__, ret);
1414 goto fail;
1415 }
1416 ret = msm_pcm_add_channel_mixer_input_map_controls(rtd);
1417 if (ret) {
1418 pr_err("%s: pcm add channel mixer input map controls failed:%d\n",
1419 __func__, ret);
1420 goto fail;
1421 }
1422 ret = msm_pcm_add_channel_mixer_output_map_controls(rtd);
1423 if (ret) {
1424 pr_err("%s: pcm add channel mixer output map controls failed:%d\n",
1425 __func__, ret);
1426 goto fail;
1427 }
1428
1429 for (i = 1; i <= PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++) {
1430 ret = msm_pcm_add_channel_mixer_weight_controls(rtd, i);
1431 if (ret) {
1432 pr_err("%s: pcm add channel mixer weight controls failed:%d\n",
1433 __func__, ret);
1434 goto fail;
1435 }
1436 }
1437 return 0;
1438
1439fail:
1440 kfree(pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_RX]);
1441 kfree(pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_TX]);
1442 pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_RX] = NULL;
1443 pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_TX] = NULL;
1444
1445 return ret;
1446}
1447
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301448static int msm_pcm_add_controls(struct snd_soc_pcm_runtime *rtd)
1449{
1450 int ret = 0;
1451
1452 pr_debug("%s\n", __func__);
1453 ret = msm_pcm_add_volume_controls(rtd);
1454 if (ret)
1455 pr_err("%s: pcm add volume controls failed:%d\n",
1456 __func__, ret);
1457 ret = msm_pcm_add_app_type_controls(rtd);
1458 if (ret)
1459 pr_err("%s: pcm add app type controls failed:%d\n",
1460 __func__, ret);
Dhananjay Kumar807f7e92018-12-11 18:10:08 +05301461
1462 ret = msm_pcm_add_channel_mixer_controls(rtd);
1463 if (ret)
1464 pr_err("%s: pcm add channel mixer controls failed:%d\n",
1465 __func__, ret);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301466 return ret;
1467}
1468
1469static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
1470{
1471 struct snd_card *card = rtd->card->snd_card;
1472 int ret = 0;
1473
1474 if (!card->dev->coherent_dma_mask)
1475 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
1476
1477 ret = msm_pcm_add_controls(rtd);
1478 if (ret)
1479 dev_err(rtd->dev, "%s, kctl add failed\n", __func__);
1480 return ret;
1481}
1482
Meng Wangee084a02018-09-04 16:11:58 +08001483static struct snd_soc_component_driver msm_soc_component = {
1484 .name = DRV_NAME,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301485 .ops = &msm_pcm_ops,
1486 .pcm_new = msm_asoc_pcm_new,
1487 .probe = msm_pcm_loopback_probe,
1488};
1489
1490static int msm_pcm_probe(struct platform_device *pdev)
1491{
1492 struct msm_pcm_pdata *pdata;
1493
1494 dev_dbg(&pdev->dev, "%s: dev name %s\n",
1495 __func__, dev_name(&pdev->dev));
1496
1497 pdata = kzalloc(sizeof(struct msm_pcm_pdata), GFP_KERNEL);
1498 if (!pdata)
1499 return -ENOMEM;
1500
1501 if (of_property_read_bool(pdev->dev.of_node,
1502 "qcom,msm-pcm-loopback-low-latency"))
1503 pdata->perf_mode = LOW_LATENCY_PCM_MODE;
1504 else
1505 pdata->perf_mode = LEGACY_PCM_MODE;
1506
1507 dev_set_drvdata(&pdev->dev, pdata);
1508
Meng Wangee084a02018-09-04 16:11:58 +08001509 return snd_soc_register_component(&pdev->dev,
1510 &msm_soc_component,
1511 NULL, 0);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301512}
1513
1514static int msm_pcm_remove(struct platform_device *pdev)
1515{
Dhananjay Kumar807f7e92018-12-11 18:10:08 +05301516 struct msm_pcm_pdata *pdata;
1517 int i = 0;
1518
1519 pdata = dev_get_drvdata(&pdev->dev);
1520 if (pdata) {
1521 for (i = 0; i < MSM_FRONTEND_DAI_MM_SIZE; i++) {
1522 kfree(pdata->chmixer_pspd[i][SESSION_TYPE_RX]);
1523 kfree(pdata->chmixer_pspd[i][SESSION_TYPE_TX]);
1524 }
1525 }
1526 kfree(pdata);
Meng Wangee084a02018-09-04 16:11:58 +08001527 snd_soc_unregister_component(&pdev->dev);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301528 return 0;
1529}
1530
1531static const struct of_device_id msm_pcm_loopback_dt_match[] = {
1532 {.compatible = "qcom,msm-pcm-loopback"},
1533 {}
1534};
1535
1536static struct platform_driver msm_pcm_driver = {
1537 .driver = {
1538 .name = "msm-pcm-loopback",
1539 .owner = THIS_MODULE,
1540 .of_match_table = msm_pcm_loopback_dt_match,
Xiaojun Sang53cd13a2018-06-29 15:14:37 +08001541 .suppress_bind_attrs = true,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301542 },
1543 .probe = msm_pcm_probe,
1544 .remove = msm_pcm_remove,
1545};
1546
Laxminath Kasam8b1366a2017-10-05 01:44:16 +05301547int __init msm_pcm_loopback_init(void)
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301548{
1549 return platform_driver_register(&msm_pcm_driver);
1550}
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301551
Asish Bhattacharya5faacb32017-12-04 17:23:15 +05301552void msm_pcm_loopback_exit(void)
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301553{
1554 platform_driver_unregister(&msm_pcm_driver);
1555}
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301556
1557MODULE_DESCRIPTION("PCM loopback platform driver");
1558MODULE_LICENSE("GPL v2");