blob: 86e8c81b0aec594d4125466d9f35141b30a6b811 [file] [log] [blame]
Meng Wang43bbb872018-12-10 12:32:05 +08001// SPDX-License-Identifier: GPL-2.0-only
Dhananjay Kumar807f7e92018-12-11 18:10:08 +05302/* Copyright (c) 2013-2019, 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
Deru Wangfbe5c7c2020-03-24 20:06:55 +0800451 if (!pcm || !pcm->audio_client) {
452 mutex_unlock(&pcm->lock);
453 pr_err("%s: private data null or audio client freed\n", __func__);
454 return -EINVAL;
455 }
456
Cong Tangd083a832019-08-27 16:21:06 +0530457 if (pcm->playback_start && pcm->capture_start) {
458 mutex_unlock(&pcm->lock);
459 return ret;
460 }
461
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530462 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
463 if (!pcm->playback_start)
464 pcm->playback_start = 1;
465 } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
466 if (!pcm->capture_start)
467 pcm->capture_start = 1;
468 }
Cong Tangd083a832019-08-27 16:21:06 +0530469
470 if (pcm->playback_start && pcm->capture_start) {
471 struct snd_soc_pcm_runtime *soc_pcm_rx =
472 pcm->playback_substream->private_data;
473 struct snd_soc_pcm_runtime *soc_pcm_tx =
474 pcm->capture_substream->private_data;
475 event.event_func = msm_pcm_route_event_handler;
476 event.priv_data = (void *) pcm;
477 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);
571 struct snd_pcm_substream *substream =
572 vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
573 struct msm_pcm_loopback *prtd;
574
575 pr_debug("%s\n", __func__);
576 if ((!substream) || (!substream->runtime)) {
Vignesh Kulothungan2ce67842018-09-25 16:40:29 -0700577 pr_debug("%s substream or runtime not found\n", __func__);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530578 rc = -ENODEV;
579 goto exit;
580 }
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530581 mutex_lock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530582 prtd = substream->runtime->private_data;
583 if (!prtd) {
584 rc = -ENODEV;
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530585 mutex_unlock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530586 goto exit;
587 }
588 ucontrol->value.integer.value[0] = prtd->volume;
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530589 mutex_unlock(&loopback_session_lock);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530590exit:
591 return rc;
592}
593
594static int msm_pcm_add_volume_controls(struct snd_soc_pcm_runtime *rtd)
595{
596 struct snd_pcm *pcm = rtd->pcm->streams[0].pcm;
597 struct snd_pcm_volume *volume_info;
598 struct snd_kcontrol *kctl;
599 int ret = 0;
600
601 dev_dbg(rtd->dev, "%s, Volume cntrl add\n", __func__);
602 ret = snd_pcm_add_volume_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
603 NULL, 1,
604 rtd->dai_link->id,
605 &volume_info);
606 if (ret < 0)
607 return ret;
608 kctl = volume_info->kctl;
609 kctl->put = msm_pcm_volume_ctl_put;
610 kctl->get = msm_pcm_volume_ctl_get;
611 kctl->tlv.p = loopback_rx_vol_gain;
612 return 0;
613}
614
615static int msm_pcm_playback_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
617{
618 u64 fe_id = kcontrol->private_value;
619 int session_type = SESSION_TYPE_RX;
620 int be_id = ucontrol->value.integer.value[3];
621 struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
622 int ret = 0;
623
624 cfg_data.app_type = ucontrol->value.integer.value[0];
625 cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
626 if (ucontrol->value.integer.value[2] != 0)
627 cfg_data.sample_rate = ucontrol->value.integer.value[2];
628 pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
629 __func__, fe_id, session_type, be_id,
630 cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
631 ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
632 be_id, &cfg_data);
633 if (ret < 0)
634 pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
635 __func__, ret);
636
637 return ret;
638}
639
640static int msm_pcm_playback_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
642{
643 u64 fe_id = kcontrol->private_value;
644 int session_type = SESSION_TYPE_RX;
645 int be_id = 0;
646 struct msm_pcm_stream_app_type_cfg cfg_data = {0};
647 int ret = 0;
648
649 ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
650 &be_id, &cfg_data);
651 if (ret < 0) {
652 pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
653 __func__, ret);
654 goto done;
655 }
656
657 ucontrol->value.integer.value[0] = cfg_data.app_type;
658 ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
659 ucontrol->value.integer.value[2] = cfg_data.sample_rate;
660 ucontrol->value.integer.value[3] = be_id;
661 pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
662 __func__, fe_id, session_type, be_id,
663 cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
664done:
665 return ret;
666}
667
668static int msm_pcm_capture_app_type_cfg_ctl_put(struct snd_kcontrol *kcontrol,
669 struct snd_ctl_elem_value *ucontrol)
670{
671 u64 fe_id = kcontrol->private_value;
672 int session_type = SESSION_TYPE_TX;
673 int be_id = ucontrol->value.integer.value[3];
674 struct msm_pcm_stream_app_type_cfg cfg_data = {0, 0, 48000};
675 int ret = 0;
676
677 cfg_data.app_type = ucontrol->value.integer.value[0];
678 cfg_data.acdb_dev_id = ucontrol->value.integer.value[1];
679 if (ucontrol->value.integer.value[2] != 0)
680 cfg_data.sample_rate = ucontrol->value.integer.value[2];
681 pr_debug("%s: fe_id- %llu session_type- %d be_id- %d app_type- %d acdb_dev_id- %d sample_rate- %d\n",
682 __func__, fe_id, session_type, be_id,
683 cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
684 ret = msm_pcm_routing_reg_stream_app_type_cfg(fe_id, session_type,
685 be_id, &cfg_data);
686 if (ret < 0)
687 pr_err("%s: msm_pcm_routing_reg_stream_app_type_cfg failed returned %d\n",
688 __func__, ret);
689
690 return ret;
691}
692
693static int msm_pcm_capture_app_type_cfg_ctl_get(struct snd_kcontrol *kcontrol,
694 struct snd_ctl_elem_value *ucontrol)
695{
696 u64 fe_id = kcontrol->private_value;
697 int session_type = SESSION_TYPE_TX;
698 int be_id = 0;
699 struct msm_pcm_stream_app_type_cfg cfg_data = {0};
700 int ret = 0;
701
702 ret = msm_pcm_routing_get_stream_app_type_cfg(fe_id, session_type,
703 &be_id, &cfg_data);
704 if (ret < 0) {
705 pr_err("%s: msm_pcm_routing_get_stream_app_type_cfg failed returned %d\n",
706 __func__, ret);
707 goto done;
708 }
709
710 ucontrol->value.integer.value[0] = cfg_data.app_type;
711 ucontrol->value.integer.value[1] = cfg_data.acdb_dev_id;
712 ucontrol->value.integer.value[2] = cfg_data.sample_rate;
713 ucontrol->value.integer.value[3] = be_id;
714 pr_debug("%s: fedai_id %llu, session_type %d, be_id %d, app_type %d, acdb_dev_id %d, sample_rate %d\n",
715 __func__, fe_id, session_type, be_id,
716 cfg_data.app_type, cfg_data.acdb_dev_id, cfg_data.sample_rate);
717done:
718 return ret;
719}
720
721static int msm_pcm_add_app_type_controls(struct snd_soc_pcm_runtime *rtd)
722{
723 struct snd_pcm *pcm = rtd->pcm->streams[0].pcm;
724 struct snd_pcm_usr *app_type_info;
725 struct snd_kcontrol *kctl;
726 const char *playback_mixer_ctl_name = "Audio Stream";
727 const char *capture_mixer_ctl_name = "Audio Stream Capture";
728 const char *deviceNo = "NN";
729 const char *suffix = "App Type Cfg";
730 int ctl_len, ret = 0;
731
732 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
733 ctl_len = strlen(playback_mixer_ctl_name) + 1 +
734 strlen(deviceNo) + 1 + strlen(suffix) + 1;
735 pr_debug("%s: Playback app type cntrl add\n", __func__);
736 ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
737 NULL, 1, ctl_len, rtd->dai_link->id,
738 &app_type_info);
739 if (ret < 0)
740 return ret;
741 kctl = app_type_info->kctl;
742 snprintf(kctl->id.name, ctl_len, "%s %d %s",
743 playback_mixer_ctl_name, rtd->pcm->device, suffix);
744 kctl->put = msm_pcm_playback_app_type_cfg_ctl_put;
745 kctl->get = msm_pcm_playback_app_type_cfg_ctl_get;
746 }
747
748 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
749 ctl_len = strlen(capture_mixer_ctl_name) + 1 +
750 strlen(deviceNo) + 1 + strlen(suffix) + 1;
751 pr_debug("%s: Capture app type cntrl add\n", __func__);
752 ret = snd_pcm_add_usr_ctls(pcm, SNDRV_PCM_STREAM_CAPTURE,
753 NULL, 1, ctl_len, rtd->dai_link->id,
754 &app_type_info);
755 if (ret < 0)
756 return ret;
757 kctl = app_type_info->kctl;
758 snprintf(kctl->id.name, ctl_len, "%s %d %s",
759 capture_mixer_ctl_name, rtd->pcm->device, suffix);
760 kctl->put = msm_pcm_capture_app_type_cfg_ctl_put;
761 kctl->get = msm_pcm_capture_app_type_cfg_ctl_get;
762 }
763
764 return 0;
765}
766
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530767static struct msm_pcm_channel_mixer *msm_pcm_get_chmixer(
768 struct msm_pcm_pdata *pdata,
769 u64 fe_id, int session_type)
770{
771 if (!pdata) {
772 pr_err("%s: missing pdata\n", __func__);
773 return NULL;
774 }
775
776 if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
777 pr_err("%s: invalid FE %llu\n", __func__, fe_id);
778 return NULL;
779 }
780
781 if ((session_type != SESSION_TYPE_TX) &&
782 (session_type != SESSION_TYPE_RX)) {
783 pr_err("%s: invalid session type %d\n", __func__, session_type);
784 return NULL;
785 }
786
787 return pdata->chmixer_pspd[fe_id][session_type];
788}
789
790static int msm_pcm_channel_mixer_cfg_ctl_put(struct snd_kcontrol *kcontrol,
791 struct snd_ctl_elem_value *ucontrol)
792{
793 u64 fe_id = kcontrol->private_value & 0xFF;
794 int session_type = (kcontrol->private_value >> 8) & 0xFF;
795 int ret = 0;
796 int stream_id = 0;
797 int be_id = 0, i = 0;
798 struct msm_pcm_loopback *prtd = NULL;
799 struct snd_soc_component *component =
800 snd_soc_kcontrol_component(kcontrol);
801 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
802 struct snd_pcm *pcm = NULL;
803 struct snd_pcm_substream *substream = NULL;
804 struct msm_pcm_channel_mixer *chmixer_pspd = NULL;
805 u8 asm_ch_map[PCM_FORMAT_MAX_NUM_CHANNEL_V8] = {0};
806 bool reset_override_out_ch_map = false;
807 bool reset_override_in_ch_map = false;
808
809 pcm = pdata->pcm_device[fe_id];
810 if (!pcm) {
811 pr_err("%s invalid pcm handle for fe_id %llu\n",
812 __func__, fe_id);
813 return -EINVAL;
814 }
815
816 if (session_type == SESSION_TYPE_RX)
817 substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
818 else
819 substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
820 if (!substream) {
821 pr_err("%s substream not found\n", __func__);
822 return -EINVAL;
823 }
824
825 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
826 if (!chmixer_pspd) {
827 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
828 return -EINVAL;
829 }
830
831 chmixer_pspd->enable = ucontrol->value.integer.value[0];
832 chmixer_pspd->rule = ucontrol->value.integer.value[1];
833 chmixer_pspd->input_channel = ucontrol->value.integer.value[2];
834 chmixer_pspd->output_channel = ucontrol->value.integer.value[3];
835 chmixer_pspd->port_idx = ucontrol->value.integer.value[4];
836
837 if (chmixer_pspd->enable) {
838 if (session_type == SESSION_TYPE_RX &&
839 !chmixer_pspd->override_in_ch_map) {
Rohit kumar2a64e522019-02-04 11:22:49 +0530840 if (chmixer_pspd->input_channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
841 pr_err("%s: Invalid channel count %d\n",
842 __func__, chmixer_pspd->input_channel);
843 return -EINVAL;
844 }
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530845 q6asm_map_channels(asm_ch_map,
846 chmixer_pspd->input_channel, false);
847 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
848 chmixer_pspd->in_ch_map[i] = asm_ch_map[i];
849 chmixer_pspd->override_in_ch_map = true;
850 reset_override_in_ch_map = true;
851 } else if (session_type == SESSION_TYPE_TX &&
852 !chmixer_pspd->override_out_ch_map) {
Rohit kumar2a64e522019-02-04 11:22:49 +0530853 if (chmixer_pspd->output_channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
854 pr_err("%s: Invalid channel count %d\n",
855 __func__, chmixer_pspd->output_channel);
856 return -EINVAL;
857 }
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530858 q6asm_map_channels(asm_ch_map,
859 chmixer_pspd->output_channel, false);
860 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
861 chmixer_pspd->out_ch_map[i] = asm_ch_map[i];
862 chmixer_pspd->override_out_ch_map = true;
863 reset_override_out_ch_map = true;
864 }
865 } else {
866 chmixer_pspd->override_out_ch_map = false;
867 chmixer_pspd->override_in_ch_map = false;
868 }
869
870 /* cache value and take effect during adm_open stage */
871 msm_pcm_routing_set_channel_mixer_cfg(fe_id,
872 session_type,
873 chmixer_pspd);
874
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530875 mutex_lock(&loopback_session_lock);
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530876 if (chmixer_pspd->enable && substream->runtime) {
877 prtd = substream->runtime->private_data;
878 if (!prtd) {
879 pr_err("%s find invalid prtd fail\n", __func__);
880 ret = -EINVAL;
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530881 mutex_unlock(&loopback_session_lock);
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530882 goto done;
883 }
884
885 if (prtd->audio_client) {
886 stream_id = prtd->audio_client->session;
887 be_id = chmixer_pspd->port_idx;
888 msm_pcm_routing_set_channel_mixer_runtime(be_id,
889 stream_id,
890 session_type,
891 chmixer_pspd);
892 }
893 }
Prasad Kumpatla2ef0c882019-10-04 15:11:10 +0530894 mutex_unlock(&loopback_session_lock);
Dhananjay Kumar807f7e92018-12-11 18:10:08 +0530895 if (reset_override_out_ch_map)
896 chmixer_pspd->override_out_ch_map = false;
897 if (reset_override_in_ch_map)
898 chmixer_pspd->override_in_ch_map = false;
899
900done:
901 return ret;
902}
903
904static int msm_pcm_channel_mixer_cfg_ctl_get(struct snd_kcontrol *kcontrol,
905 struct snd_ctl_elem_value *ucontrol)
906{
907 u64 fe_id = kcontrol->private_value & 0xFF;
908 int session_type = (kcontrol->private_value >> 8) & 0xFF;
909 struct snd_soc_component *component =
910 snd_soc_kcontrol_component(kcontrol);
911 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
912 struct msm_pcm_channel_mixer *chmixer_pspd;
913
914 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
915 if (!chmixer_pspd) {
916 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
917 return -EINVAL;
918 }
919
920 ucontrol->value.integer.value[0] = chmixer_pspd->enable;
921 ucontrol->value.integer.value[1] = chmixer_pspd->rule;
922 ucontrol->value.integer.value[2] = chmixer_pspd->input_channel;
923 ucontrol->value.integer.value[3] = chmixer_pspd->output_channel;
924 ucontrol->value.integer.value[4] = chmixer_pspd->port_idx;
925 return 0;
926}
927
928static int msm_pcm_channel_mixer_output_map_ctl_put(
929 struct snd_kcontrol *kcontrol,
930 struct snd_ctl_elem_value *ucontrol)
931{
932 u64 fe_id = kcontrol->private_value & 0xFF;
933 int session_type = (kcontrol->private_value >> 8) & 0xFF;
934 int i = 0;
935 struct snd_soc_component *component =
936 snd_soc_kcontrol_component(kcontrol);
937 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
938 struct msm_pcm_channel_mixer *chmixer_pspd;
939
940 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
941 if (!chmixer_pspd) {
942 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
943 return -EINVAL;
944 }
945
946 chmixer_pspd->override_out_ch_map = true;
947 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
948 chmixer_pspd->out_ch_map[i] =
949 ucontrol->value.integer.value[i];
950
951 return 0;
952}
953
954static int msm_pcm_channel_mixer_output_map_ctl_get(
955 struct snd_kcontrol *kcontrol,
956 struct snd_ctl_elem_value *ucontrol)
957{
958 u64 fe_id = kcontrol->private_value & 0xFF;
959 int session_type = (kcontrol->private_value >> 8) & 0xFF;
960 int i = 0;
961 struct snd_soc_component *component =
962 snd_soc_kcontrol_component(kcontrol);
963 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
964 struct msm_pcm_channel_mixer *chmixer_pspd;
965
966 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
967 if (!chmixer_pspd) {
968 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
969 return -EINVAL;
970 }
971
972 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
973 ucontrol->value.integer.value[i] =
974 chmixer_pspd->out_ch_map[i];
975 return 0;
976}
977
978static int msm_pcm_channel_mixer_input_map_ctl_put(
979 struct snd_kcontrol *kcontrol,
980 struct snd_ctl_elem_value *ucontrol)
981{
982 u64 fe_id = kcontrol->private_value & 0xFF;
983 int session_type = (kcontrol->private_value >> 8) & 0xFF;
984 int i = 0;
985 struct snd_soc_component *component =
986 snd_soc_kcontrol_component(kcontrol);
987 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
988 struct msm_pcm_channel_mixer *chmixer_pspd;
989
990 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
991 if (!chmixer_pspd) {
992 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
993 return -EINVAL;
994 }
995
996 chmixer_pspd->override_in_ch_map = true;
997 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
998 chmixer_pspd->in_ch_map[i] = ucontrol->value.integer.value[i];
999
1000 return 0;
1001}
1002
1003static int msm_pcm_channel_mixer_input_map_ctl_get(
1004 struct snd_kcontrol *kcontrol,
1005 struct snd_ctl_elem_value *ucontrol)
1006{
1007 u64 fe_id = kcontrol->private_value & 0xFF;
1008 int session_type = (kcontrol->private_value >> 8) & 0xFF;
1009 int i = 0;
1010 struct snd_soc_component *component =
1011 snd_soc_kcontrol_component(kcontrol);
1012 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
1013 struct msm_pcm_channel_mixer *chmixer_pspd;
1014
1015 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
1016 if (!chmixer_pspd) {
1017 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
1018 return -EINVAL;
1019 }
1020
1021 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
1022 ucontrol->value.integer.value[i] =
1023 chmixer_pspd->in_ch_map[i];
1024 return 0;
1025}
1026
1027static int msm_pcm_channel_mixer_weight_ctl_put(
1028 struct snd_kcontrol *kcontrol,
1029 struct snd_ctl_elem_value *ucontrol)
1030{
1031 u64 fe_id = kcontrol->private_value & 0xFF;
1032 int session_type = (kcontrol->private_value >> 8) & 0xFF;
1033 int channel = (kcontrol->private_value >> 16) & 0xFF;
1034 int i = 0;
1035 struct snd_soc_component *component =
1036 snd_soc_kcontrol_component(kcontrol);
1037 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
1038 struct msm_pcm_channel_mixer *chmixer_pspd;
1039
1040 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
1041 if (!chmixer_pspd) {
1042 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
1043 return -EINVAL;
1044 }
1045
1046 if (channel <= 0 || channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
1047 pr_err("%s: invalid channel number %d\n", __func__, channel);
1048 return -EINVAL;
1049 }
1050 channel--;
1051
1052 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
1053 chmixer_pspd->channel_weight[channel][i] =
1054 ucontrol->value.integer.value[i];
1055 return 0;
1056}
1057
1058static int msm_pcm_channel_mixer_weight_ctl_get(
1059 struct snd_kcontrol *kcontrol,
1060 struct snd_ctl_elem_value *ucontrol)
1061{
1062 u64 fe_id = kcontrol->private_value & 0xFF;
1063 int session_type = (kcontrol->private_value >> 8) & 0xFF;
1064 int channel = (kcontrol->private_value >> 16) & 0xFF;
1065 struct snd_soc_component *component =
1066 snd_soc_kcontrol_component(kcontrol);
1067 struct msm_pcm_pdata *pdata = dev_get_drvdata(component->dev);
1068 int i = 0;
1069 struct msm_pcm_channel_mixer *chmixer_pspd;
1070
1071 if (channel <= 0 || channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
1072 pr_err("%s: invalid channel number %d\n", __func__, channel);
1073 return -EINVAL;
1074 }
1075 channel--;
1076
1077 chmixer_pspd = msm_pcm_get_chmixer(pdata, fe_id, session_type);
1078 if (!chmixer_pspd) {
1079 pr_err("%s: invalid chmixer_pspd in pdata", __func__);
1080 return -EINVAL;
1081 }
1082
1083 for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
1084 ucontrol->value.integer.value[i] =
1085 chmixer_pspd->channel_weight[channel][i];
1086 return 0;
1087}
1088
1089static int msm_pcm_add_platform_controls(struct snd_kcontrol_new *kctl,
1090 struct snd_soc_pcm_runtime *rtd, const char *name_prefix,
1091 const char *name_suffix, int session_type, int channels)
1092{
1093 int ret = -EINVAL;
1094 char *mixer_name = NULL;
1095 struct snd_pcm *pcm = rtd->pcm;
1096 const char *deviceNo = "NN";
1097 const char *channelNo = "NN";
1098 int ctl_len = 0;
1099 struct snd_soc_component *component = NULL;
1100
1101 component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
1102 if (!component) {
1103 pr_err("%s: component is NULL\n", __func__);
1104 return -EINVAL;
1105 }
1106
1107 ctl_len = strlen(name_prefix) + 1 + strlen(deviceNo) + 1 +
1108 strlen(channelNo) + 1 + strlen(name_suffix) + 1;
1109
1110 mixer_name = kzalloc(ctl_len, GFP_KERNEL);
1111 if (mixer_name == NULL)
1112 return -ENOMEM;
1113
1114 if (channels >= 0) {
1115 snprintf(mixer_name, ctl_len, "%s %d %s %d",
1116 name_prefix, pcm->device, name_suffix, channels);
1117 kctl->private_value = (rtd->dai_link->id) | (session_type << 8) |
1118 (channels << 16);
1119 } else {
1120 snprintf(mixer_name, ctl_len, "%s %d %s",
1121 name_prefix, pcm->device, name_suffix);
1122 kctl->private_value = (rtd->dai_link->id) | (session_type << 8);
1123 }
1124
1125 kctl->name = mixer_name;
1126 ret = snd_soc_add_component_controls(component, kctl, 1);
1127 kfree(mixer_name);
1128 return ret;
1129}
1130
1131static int msm_pcm_channel_mixer_output_map_info(struct snd_kcontrol *kcontrol,
1132 struct snd_ctl_elem_info *uinfo)
1133{
1134 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1135 uinfo->count = PCM_FORMAT_MAX_NUM_CHANNEL_V8;
1136 /* Valid channel map value ranges from 1 to 64 */
1137 uinfo->value.integer.min = 1;
1138 uinfo->value.integer.max = 64;
1139 return 0;
1140}
1141
1142static int msm_pcm_add_channel_mixer_output_map_controls(
1143 struct snd_soc_pcm_runtime *rtd)
1144{
1145 struct snd_pcm *pcm = rtd->pcm;
1146 const char *playback_mixer_ctl_name = "AudStr";
1147 const char *capture_mixer_ctl_name = "AudStr Capture";
1148 const char *suffix = "ChMixer Output Map";
1149 int session_type = 0, ret = 0, channel = -1;
1150 struct snd_kcontrol_new channel_mixer_output_map_control = {
1151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1152 .name = "?",
1153 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1154 .info = msm_pcm_channel_mixer_output_map_info,
1155 .put = msm_pcm_channel_mixer_output_map_ctl_put,
1156 .get = msm_pcm_channel_mixer_output_map_ctl_get,
1157 .private_value = 0,
1158 };
1159
1160 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream != NULL) {
1161 session_type = SESSION_TYPE_RX;
1162 ret = msm_pcm_add_platform_controls(&channel_mixer_output_map_control,
1163 rtd, playback_mixer_ctl_name, suffix, session_type, channel);
1164 if (ret < 0)
1165 goto fail;
1166 }
1167
1168 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream != NULL) {
1169 session_type = SESSION_TYPE_TX;
1170 ret = msm_pcm_add_platform_controls(&channel_mixer_output_map_control,
1171 rtd, capture_mixer_ctl_name, suffix, session_type, channel);
1172 if (ret < 0)
1173 goto fail;
1174 }
1175 return 0;
1176
1177fail:
1178 pr_err("%s: failed add platform ctl, err = %d\n",
1179 __func__, ret);
1180
1181 return ret;
1182}
1183
1184static int msm_pcm_channel_mixer_input_map_info(struct snd_kcontrol *kcontrol,
1185 struct snd_ctl_elem_info *uinfo)
1186{
1187 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1188 uinfo->count = PCM_FORMAT_MAX_NUM_CHANNEL_V8;
1189 /* Valid channel map value ranges from 1 to 64 */
1190 uinfo->value.integer.min = 1;
1191 uinfo->value.integer.max = 64;
1192 return 0;
1193}
1194
1195static int msm_pcm_add_channel_mixer_input_map_controls(
1196 struct snd_soc_pcm_runtime *rtd)
1197{
1198 struct snd_pcm *pcm = rtd->pcm;
1199 const char *playback_mixer_ctl_name = "AudStr";
1200 const char *capture_mixer_ctl_name = "AudStr Capture";
1201 const char *suffix = "ChMixer Input Map";
1202 int session_type = 0, ret = 0, channel = -1;
1203 struct snd_kcontrol_new channel_mixer_input_map_control = {
1204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1205 .name = "?",
1206 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1207 .info = msm_pcm_channel_mixer_input_map_info,
1208 .put = msm_pcm_channel_mixer_input_map_ctl_put,
1209 .get = msm_pcm_channel_mixer_input_map_ctl_get,
1210 .private_value = 0,
1211 };
1212
1213 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream != NULL) {
1214 session_type = SESSION_TYPE_RX;
1215 ret = msm_pcm_add_platform_controls(&channel_mixer_input_map_control,
1216 rtd, playback_mixer_ctl_name, suffix, session_type, channel);
1217 if (ret < 0)
1218 goto fail;
1219 }
1220
1221 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream != NULL) {
1222 session_type = SESSION_TYPE_TX;
1223 ret = msm_pcm_add_platform_controls(&channel_mixer_input_map_control,
1224 rtd, capture_mixer_ctl_name, suffix, session_type, channel);
1225 if (ret < 0)
1226 goto fail;
1227 }
1228 return 0;
1229
1230fail:
1231 pr_err("%s: failed add platform ctl, err = %d\n",
1232 __func__, ret);
1233 return ret;
1234}
1235
1236static int msm_pcm_channel_mixer_cfg_info(struct snd_kcontrol *kcontrol,
1237 struct snd_ctl_elem_info *uinfo)
1238{
1239 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1240 /* five int values: enable, rule, in_channels, out_channels and port_id */
1241 uinfo->count = 5;
1242 /* Valid range is all positive values to support above controls */
1243 uinfo->value.integer.min = 0;
1244 uinfo->value.integer.max = INT_MAX;
1245 return 0;
1246}
1247
1248static int msm_pcm_add_channel_mixer_cfg_controls(
1249 struct snd_soc_pcm_runtime *rtd)
1250{
1251 struct snd_pcm *pcm = rtd->pcm;
1252 const char *playback_mixer_ctl_name = "AudStr";
1253 const char *capture_mixer_ctl_name = "AudStr Capture";
1254 const char *suffix = "ChMixer Cfg";
1255 int session_type = 0, ret = 0, channel = -1;
1256 struct msm_pcm_pdata *pdata = NULL;
1257 struct snd_soc_component *component = NULL;
1258 struct snd_kcontrol_new channel_mixer_cfg_control = {
1259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1260 .name = "?",
1261 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1262 .info = msm_pcm_channel_mixer_cfg_info,
1263 .put = msm_pcm_channel_mixer_cfg_ctl_put,
1264 .get = msm_pcm_channel_mixer_cfg_ctl_get,
1265 .private_value = 0,
1266 };
1267
1268 component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
1269 if (!component) {
1270 pr_err("%s: component is NULL\n", __func__);
1271 return -EINVAL;
1272 }
1273 pdata = (struct msm_pcm_pdata *)
1274 dev_get_drvdata(component->dev);
1275 if (pdata == NULL) {
1276 pr_err("%s: platform data not populated\n", __func__);
1277 return -EINVAL;
1278 }
1279
1280 pdata->pcm_device[rtd->dai_link->id] = rtd->pcm;
1281
1282 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream != NULL) {
1283 session_type = SESSION_TYPE_RX;
1284 ret = msm_pcm_add_platform_controls(&channel_mixer_cfg_control,
1285 rtd, playback_mixer_ctl_name, suffix, session_type, channel);
1286 if (ret < 0)
1287 goto fail;
1288 }
1289
1290 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream != NULL) {
1291 session_type = SESSION_TYPE_TX;
1292 ret = msm_pcm_add_platform_controls(&channel_mixer_cfg_control,
1293 rtd, capture_mixer_ctl_name, suffix, session_type, channel);
1294 if (ret < 0)
1295 goto fail;
1296 }
1297 return 0;
1298
1299fail:
1300 pr_err("%s: failed add platform ctl, err = %d\n",
1301 __func__, ret);
1302
1303 return ret;
1304}
1305
1306static int msm_pcm_channel_mixer_weight_info(struct snd_kcontrol *kcontrol,
1307 struct snd_ctl_elem_info *uinfo)
1308{
1309 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1310 uinfo->count = PCM_FORMAT_MAX_NUM_CHANNEL_V8;
1311 /* Valid range: 0 to 0x4000(Unity) gain weightage */
1312 uinfo->value.integer.min = 0;
1313 uinfo->value.integer.max = 0x4000;
1314 return 0;
1315}
1316
1317static int msm_pcm_add_channel_mixer_weight_controls(
1318 struct snd_soc_pcm_runtime *rtd,
1319 int channel)
1320{
1321 struct snd_pcm *pcm = rtd->pcm;
1322 const char *playback_mixer_ctl_name = "AudStr";
1323 const char *capture_mixer_ctl_name = "AudStr Capture";
1324 const char *suffix = "ChMixer Weight Ch";
1325 int session_type = 0, ret = 0;
1326 struct snd_kcontrol_new channel_mixer_weight_control = {
1327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1328 .name = "?",
1329 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1330 .info = msm_pcm_channel_mixer_weight_info,
1331 .put = msm_pcm_channel_mixer_weight_ctl_put,
1332 .get = msm_pcm_channel_mixer_weight_ctl_get,
1333 .private_value = 0,
1334 };
1335
1336 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream != NULL) {
1337 session_type = SESSION_TYPE_RX;
1338 ret = msm_pcm_add_platform_controls(&channel_mixer_weight_control,
1339 rtd, playback_mixer_ctl_name, suffix, session_type, channel);
1340 if (ret < 0)
1341 goto fail;
1342 }
1343
1344 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream != NULL) {
1345 session_type = SESSION_TYPE_TX;
1346 ret = msm_pcm_add_platform_controls(&channel_mixer_weight_control,
1347 rtd, capture_mixer_ctl_name, suffix, session_type, channel);
1348 if (ret < 0)
1349 goto fail;
1350 }
1351 return 0;
1352
1353fail:
1354 pr_err("%s: failed add platform ctl, err = %d\n",
1355 __func__, ret);
1356
1357 return ret;
1358}
1359
1360static int msm_pcm_add_channel_mixer_controls(struct snd_soc_pcm_runtime *rtd)
1361{
1362 int i, ret = 0;
1363 struct snd_pcm *pcm = NULL;
1364 struct msm_pcm_pdata *pdata = NULL;
1365 struct snd_soc_component *component = NULL;
1366
1367 if (!rtd || !rtd->pcm) {
1368 pr_err("%s invalid rtd or pcm\n", __func__);
1369 return -EINVAL;
1370 }
1371 pcm = rtd->pcm;
1372
1373 component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
1374 if (!component) {
1375 pr_err("%s: component is NULL\n", __func__);
1376 return -EINVAL;
1377 }
1378
1379 pdata = (struct msm_pcm_pdata *)
1380 dev_get_drvdata(component->dev);
1381 if (!pdata) {
1382 pr_err("%s: platform data not populated\n", __func__);
1383 return -EINVAL;
1384 }
1385
1386 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream &&
1387 !pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_RX]) {
1388 pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_RX] =
1389 kzalloc(sizeof(struct msm_pcm_channel_mixer), GFP_KERNEL);
1390 if (!pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_RX]) {
1391 ret = -ENOMEM;
1392 goto fail;
1393 }
1394 }
1395
1396 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream &&
1397 !pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_TX]) {
1398 pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_TX] =
1399 kzalloc(sizeof(struct msm_pcm_channel_mixer), GFP_KERNEL);
1400 if (!pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_TX]) {
1401 ret = -ENOMEM;
1402 goto fail;
1403 }
1404 }
1405
1406 ret = msm_pcm_add_channel_mixer_cfg_controls(rtd);
1407 if (ret) {
1408 pr_err("%s: pcm add channel mixer cfg controls failed:%d\n",
1409 __func__, ret);
1410 goto fail;
1411 }
1412 ret = msm_pcm_add_channel_mixer_input_map_controls(rtd);
1413 if (ret) {
1414 pr_err("%s: pcm add channel mixer input map controls failed:%d\n",
1415 __func__, ret);
1416 goto fail;
1417 }
1418 ret = msm_pcm_add_channel_mixer_output_map_controls(rtd);
1419 if (ret) {
1420 pr_err("%s: pcm add channel mixer output map controls failed:%d\n",
1421 __func__, ret);
1422 goto fail;
1423 }
1424
1425 for (i = 1; i <= PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++) {
1426 ret = msm_pcm_add_channel_mixer_weight_controls(rtd, i);
1427 if (ret) {
1428 pr_err("%s: pcm add channel mixer weight controls failed:%d\n",
1429 __func__, ret);
1430 goto fail;
1431 }
1432 }
1433 return 0;
1434
1435fail:
1436 kfree(pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_RX]);
1437 kfree(pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_TX]);
1438 pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_RX] = NULL;
1439 pdata->chmixer_pspd[rtd->dai_link->id][SESSION_TYPE_TX] = NULL;
1440
1441 return ret;
1442}
1443
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301444static int msm_pcm_add_controls(struct snd_soc_pcm_runtime *rtd)
1445{
1446 int ret = 0;
1447
1448 pr_debug("%s\n", __func__);
1449 ret = msm_pcm_add_volume_controls(rtd);
1450 if (ret)
1451 pr_err("%s: pcm add volume controls failed:%d\n",
1452 __func__, ret);
1453 ret = msm_pcm_add_app_type_controls(rtd);
1454 if (ret)
1455 pr_err("%s: pcm add app type controls failed:%d\n",
1456 __func__, ret);
Dhananjay Kumar807f7e92018-12-11 18:10:08 +05301457
1458 ret = msm_pcm_add_channel_mixer_controls(rtd);
1459 if (ret)
1460 pr_err("%s: pcm add channel mixer controls failed:%d\n",
1461 __func__, ret);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301462 return ret;
1463}
1464
1465static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
1466{
1467 struct snd_card *card = rtd->card->snd_card;
1468 int ret = 0;
1469
1470 if (!card->dev->coherent_dma_mask)
1471 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
1472
1473 ret = msm_pcm_add_controls(rtd);
1474 if (ret)
1475 dev_err(rtd->dev, "%s, kctl add failed\n", __func__);
1476 return ret;
1477}
1478
Meng Wangee084a02018-09-04 16:11:58 +08001479static struct snd_soc_component_driver msm_soc_component = {
1480 .name = DRV_NAME,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301481 .ops = &msm_pcm_ops,
1482 .pcm_new = msm_asoc_pcm_new,
1483 .probe = msm_pcm_loopback_probe,
1484};
1485
1486static int msm_pcm_probe(struct platform_device *pdev)
1487{
1488 struct msm_pcm_pdata *pdata;
1489
1490 dev_dbg(&pdev->dev, "%s: dev name %s\n",
1491 __func__, dev_name(&pdev->dev));
1492
1493 pdata = kzalloc(sizeof(struct msm_pcm_pdata), GFP_KERNEL);
1494 if (!pdata)
1495 return -ENOMEM;
1496
1497 if (of_property_read_bool(pdev->dev.of_node,
1498 "qcom,msm-pcm-loopback-low-latency"))
1499 pdata->perf_mode = LOW_LATENCY_PCM_MODE;
1500 else
1501 pdata->perf_mode = LEGACY_PCM_MODE;
1502
1503 dev_set_drvdata(&pdev->dev, pdata);
1504
Meng Wangee084a02018-09-04 16:11:58 +08001505 return snd_soc_register_component(&pdev->dev,
1506 &msm_soc_component,
1507 NULL, 0);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301508}
1509
1510static int msm_pcm_remove(struct platform_device *pdev)
1511{
Dhananjay Kumar807f7e92018-12-11 18:10:08 +05301512 struct msm_pcm_pdata *pdata;
1513 int i = 0;
1514
1515 pdata = dev_get_drvdata(&pdev->dev);
1516 if (pdata) {
1517 for (i = 0; i < MSM_FRONTEND_DAI_MM_SIZE; i++) {
1518 kfree(pdata->chmixer_pspd[i][SESSION_TYPE_RX]);
1519 kfree(pdata->chmixer_pspd[i][SESSION_TYPE_TX]);
1520 }
1521 }
1522 kfree(pdata);
Meng Wangee084a02018-09-04 16:11:58 +08001523 snd_soc_unregister_component(&pdev->dev);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301524 return 0;
1525}
1526
1527static const struct of_device_id msm_pcm_loopback_dt_match[] = {
1528 {.compatible = "qcom,msm-pcm-loopback"},
1529 {}
1530};
1531
1532static struct platform_driver msm_pcm_driver = {
1533 .driver = {
1534 .name = "msm-pcm-loopback",
1535 .owner = THIS_MODULE,
1536 .of_match_table = msm_pcm_loopback_dt_match,
Xiaojun Sang53cd13a2018-06-29 15:14:37 +08001537 .suppress_bind_attrs = true,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301538 },
1539 .probe = msm_pcm_probe,
1540 .remove = msm_pcm_remove,
1541};
1542
Laxminath Kasam8b1366a2017-10-05 01:44:16 +05301543int __init msm_pcm_loopback_init(void)
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301544{
1545 return platform_driver_register(&msm_pcm_driver);
1546}
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301547
Asish Bhattacharya5faacb32017-12-04 17:23:15 +05301548void msm_pcm_loopback_exit(void)
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301549{
1550 platform_driver_unregister(&msm_pcm_driver);
1551}
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301552
1553MODULE_DESCRIPTION("PCM loopback platform driver");
1554MODULE_LICENSE("GPL v2");