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