]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame_incremental - sound/soc/intel/sst-mfld-platform-pcm.c
ASoC: Intel: mark sst_set_stream_status as non static
[mirror_ubuntu-jammy-kernel.git] / sound / soc / intel / sst-mfld-platform-pcm.c
... / ...
CommitLineData
1/*
2 * sst_mfld_platform.c - Intel MID Platform driver
3 *
4 * Copyright (C) 2010-2013 Intel Corp
5 * Author: Vinod Koul <vinod.koul@intel.com>
6 * Author: Harsha Priya <priya.harsha@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */
20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21
22#include <linux/slab.h>
23#include <linux/io.h>
24#include <linux/module.h>
25#include <sound/core.h>
26#include <sound/pcm.h>
27#include <sound/pcm_params.h>
28#include <sound/soc.h>
29#include <sound/compress_driver.h>
30#include "sst-mfld-platform.h"
31
32static struct sst_device *sst;
33static DEFINE_MUTEX(sst_lock);
34
35int sst_register_dsp(struct sst_device *dev)
36{
37 if (WARN_ON(!dev))
38 return -EINVAL;
39 if (!try_module_get(dev->dev->driver->owner))
40 return -ENODEV;
41 mutex_lock(&sst_lock);
42 if (sst) {
43 pr_err("we already have a device %s\n", sst->name);
44 module_put(dev->dev->driver->owner);
45 mutex_unlock(&sst_lock);
46 return -EEXIST;
47 }
48 pr_debug("registering device %s\n", dev->name);
49 sst = dev;
50 mutex_unlock(&sst_lock);
51 return 0;
52}
53EXPORT_SYMBOL_GPL(sst_register_dsp);
54
55int sst_unregister_dsp(struct sst_device *dev)
56{
57 if (WARN_ON(!dev))
58 return -EINVAL;
59 if (dev != sst)
60 return -EINVAL;
61
62 mutex_lock(&sst_lock);
63
64 if (!sst) {
65 mutex_unlock(&sst_lock);
66 return -EIO;
67 }
68
69 module_put(sst->dev->driver->owner);
70 pr_debug("unreg %s\n", sst->name);
71 sst = NULL;
72 mutex_unlock(&sst_lock);
73 return 0;
74}
75EXPORT_SYMBOL_GPL(sst_unregister_dsp);
76
77static struct snd_pcm_hardware sst_platform_pcm_hw = {
78 .info = (SNDRV_PCM_INFO_INTERLEAVED |
79 SNDRV_PCM_INFO_DOUBLE |
80 SNDRV_PCM_INFO_PAUSE |
81 SNDRV_PCM_INFO_RESUME |
82 SNDRV_PCM_INFO_MMAP|
83 SNDRV_PCM_INFO_MMAP_VALID |
84 SNDRV_PCM_INFO_BLOCK_TRANSFER |
85 SNDRV_PCM_INFO_SYNC_START),
86 .buffer_bytes_max = SST_MAX_BUFFER,
87 .period_bytes_min = SST_MIN_PERIOD_BYTES,
88 .period_bytes_max = SST_MAX_PERIOD_BYTES,
89 .periods_min = SST_MIN_PERIODS,
90 .periods_max = SST_MAX_PERIODS,
91 .fifo_size = SST_FIFO_SIZE,
92};
93
94/* MFLD - MSIC */
95static struct snd_soc_dai_driver sst_platform_dai[] = {
96{
97 .name = "Headset-cpu-dai",
98 .id = 0,
99 .playback = {
100 .channels_min = SST_STEREO,
101 .channels_max = SST_STEREO,
102 .rates = SNDRV_PCM_RATE_48000,
103 .formats = SNDRV_PCM_FMTBIT_S24_LE,
104 },
105 .capture = {
106 .channels_min = 1,
107 .channels_max = 5,
108 .rates = SNDRV_PCM_RATE_48000,
109 .formats = SNDRV_PCM_FMTBIT_S24_LE,
110 },
111},
112{
113 .name = "Speaker-cpu-dai",
114 .id = 1,
115 .playback = {
116 .channels_min = SST_MONO,
117 .channels_max = SST_STEREO,
118 .rates = SNDRV_PCM_RATE_48000,
119 .formats = SNDRV_PCM_FMTBIT_S24_LE,
120 },
121},
122{
123 .name = "Vibra1-cpu-dai",
124 .id = 2,
125 .playback = {
126 .channels_min = SST_MONO,
127 .channels_max = SST_MONO,
128 .rates = SNDRV_PCM_RATE_48000,
129 .formats = SNDRV_PCM_FMTBIT_S24_LE,
130 },
131},
132{
133 .name = "Vibra2-cpu-dai",
134 .id = 3,
135 .playback = {
136 .channels_min = SST_MONO,
137 .channels_max = SST_STEREO,
138 .rates = SNDRV_PCM_RATE_48000,
139 .formats = SNDRV_PCM_FMTBIT_S24_LE,
140 },
141},
142{
143 .name = "Compress-cpu-dai",
144 .compress_dai = 1,
145 .playback = {
146 .channels_min = SST_STEREO,
147 .channels_max = SST_STEREO,
148 .rates = SNDRV_PCM_RATE_44100|SNDRV_PCM_RATE_48000,
149 .formats = SNDRV_PCM_FMTBIT_S16_LE,
150 },
151},
152};
153
154/* helper functions */
155void sst_set_stream_status(struct sst_runtime_stream *stream,
156 int state)
157{
158 unsigned long flags;
159 spin_lock_irqsave(&stream->status_lock, flags);
160 stream->stream_status = state;
161 spin_unlock_irqrestore(&stream->status_lock, flags);
162}
163
164static inline int sst_get_stream_status(struct sst_runtime_stream *stream)
165{
166 int state;
167 unsigned long flags;
168
169 spin_lock_irqsave(&stream->status_lock, flags);
170 state = stream->stream_status;
171 spin_unlock_irqrestore(&stream->status_lock, flags);
172 return state;
173}
174
175static void sst_fill_pcm_params(struct snd_pcm_substream *substream,
176 struct sst_pcm_params *param)
177{
178
179 param->codec = SST_CODEC_TYPE_PCM;
180 param->num_chan = (u8) substream->runtime->channels;
181 param->pcm_wd_sz = substream->runtime->sample_bits;
182 param->reserved = 0;
183 param->sfreq = substream->runtime->rate;
184 param->ring_buffer_size = snd_pcm_lib_buffer_bytes(substream);
185 param->period_count = substream->runtime->period_size;
186 param->ring_buffer_addr = virt_to_phys(substream->dma_buffer.area);
187 pr_debug("period_cnt = %d\n", param->period_count);
188 pr_debug("sfreq= %d, wd_sz = %d\n", param->sfreq, param->pcm_wd_sz);
189}
190
191static int sst_platform_alloc_stream(struct snd_pcm_substream *substream)
192{
193 struct sst_runtime_stream *stream =
194 substream->runtime->private_data;
195 struct sst_pcm_params param = {0};
196 struct sst_stream_params str_params = {0};
197 int ret_val;
198
199 /* set codec params and inform SST driver the same */
200 sst_fill_pcm_params(substream, &param);
201 substream->runtime->dma_area = substream->dma_buffer.area;
202 str_params.sparams = param;
203 str_params.codec = param.codec;
204 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
205 str_params.ops = STREAM_OPS_PLAYBACK;
206 str_params.device_type = substream->pcm->device + 1;
207 pr_debug("Playbck stream,Device %d\n",
208 substream->pcm->device);
209 } else {
210 str_params.ops = STREAM_OPS_CAPTURE;
211 str_params.device_type = SND_SST_DEVICE_CAPTURE;
212 pr_debug("Capture stream,Device %d\n",
213 substream->pcm->device);
214 }
215 ret_val = stream->ops->open(&str_params);
216 pr_debug("SST_SND_PLAY/CAPTURE ret_val = %x\n", ret_val);
217 if (ret_val < 0)
218 return ret_val;
219
220 stream->stream_info.str_id = ret_val;
221 pr_debug("str id : %d\n", stream->stream_info.str_id);
222 return ret_val;
223}
224
225static void sst_period_elapsed(void *mad_substream)
226{
227 struct snd_pcm_substream *substream = mad_substream;
228 struct sst_runtime_stream *stream;
229 int status;
230
231 if (!substream || !substream->runtime)
232 return;
233 stream = substream->runtime->private_data;
234 if (!stream)
235 return;
236 status = sst_get_stream_status(stream);
237 if (status != SST_PLATFORM_RUNNING)
238 return;
239 snd_pcm_period_elapsed(substream);
240}
241
242static int sst_platform_init_stream(struct snd_pcm_substream *substream)
243{
244 struct sst_runtime_stream *stream =
245 substream->runtime->private_data;
246 int ret_val;
247
248 pr_debug("setting buffer ptr param\n");
249 sst_set_stream_status(stream, SST_PLATFORM_INIT);
250 stream->stream_info.period_elapsed = sst_period_elapsed;
251 stream->stream_info.mad_substream = substream;
252 stream->stream_info.buffer_ptr = 0;
253 stream->stream_info.sfreq = substream->runtime->rate;
254 ret_val = stream->ops->device_control(
255 SST_SND_STREAM_INIT, &stream->stream_info);
256 if (ret_val)
257 pr_err("control_set ret error %d\n", ret_val);
258 return ret_val;
259
260}
261/* end -- helper functions */
262
263static int sst_platform_open(struct snd_pcm_substream *substream)
264{
265 struct snd_pcm_runtime *runtime = substream->runtime;
266 struct sst_runtime_stream *stream;
267 int ret_val;
268
269 pr_debug("sst_platform_open called\n");
270
271 snd_soc_set_runtime_hwparams(substream, &sst_platform_pcm_hw);
272 ret_val = snd_pcm_hw_constraint_integer(runtime,
273 SNDRV_PCM_HW_PARAM_PERIODS);
274 if (ret_val < 0)
275 return ret_val;
276
277 stream = kzalloc(sizeof(*stream), GFP_KERNEL);
278 if (!stream)
279 return -ENOMEM;
280 spin_lock_init(&stream->status_lock);
281
282 /* get the sst ops */
283 mutex_lock(&sst_lock);
284 if (!sst) {
285 pr_err("no device available to run\n");
286 mutex_unlock(&sst_lock);
287 kfree(stream);
288 return -ENODEV;
289 }
290 if (!try_module_get(sst->dev->driver->owner)) {
291 mutex_unlock(&sst_lock);
292 kfree(stream);
293 return -ENODEV;
294 }
295 stream->ops = sst->ops;
296 mutex_unlock(&sst_lock);
297
298 stream->stream_info.str_id = 0;
299 sst_set_stream_status(stream, SST_PLATFORM_INIT);
300 stream->stream_info.mad_substream = substream;
301 /* allocate memory for SST API set */
302 runtime->private_data = stream;
303
304 return 0;
305}
306
307static int sst_platform_close(struct snd_pcm_substream *substream)
308{
309 struct sst_runtime_stream *stream;
310 int ret_val = 0, str_id;
311
312 pr_debug("sst_platform_close called\n");
313 stream = substream->runtime->private_data;
314 str_id = stream->stream_info.str_id;
315 if (str_id)
316 ret_val = stream->ops->close(str_id);
317 module_put(sst->dev->driver->owner);
318 kfree(stream);
319 return ret_val;
320}
321
322static int sst_platform_pcm_prepare(struct snd_pcm_substream *substream)
323{
324 struct sst_runtime_stream *stream;
325 int ret_val = 0, str_id;
326
327 pr_debug("sst_platform_pcm_prepare called\n");
328 stream = substream->runtime->private_data;
329 str_id = stream->stream_info.str_id;
330 if (stream->stream_info.str_id) {
331 ret_val = stream->ops->device_control(
332 SST_SND_DROP, &str_id);
333 return ret_val;
334 }
335
336 ret_val = sst_platform_alloc_stream(substream);
337 if (ret_val < 0)
338 return ret_val;
339 snprintf(substream->pcm->id, sizeof(substream->pcm->id),
340 "%d", stream->stream_info.str_id);
341
342 ret_val = sst_platform_init_stream(substream);
343 if (ret_val)
344 return ret_val;
345 substream->runtime->hw.info = SNDRV_PCM_INFO_BLOCK_TRANSFER;
346 return ret_val;
347}
348
349static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream,
350 int cmd)
351{
352 int ret_val = 0, str_id;
353 struct sst_runtime_stream *stream;
354 int str_cmd, status;
355
356 pr_debug("sst_platform_pcm_trigger called\n");
357 stream = substream->runtime->private_data;
358 str_id = stream->stream_info.str_id;
359 switch (cmd) {
360 case SNDRV_PCM_TRIGGER_START:
361 pr_debug("sst: Trigger Start\n");
362 str_cmd = SST_SND_START;
363 status = SST_PLATFORM_RUNNING;
364 stream->stream_info.mad_substream = substream;
365 break;
366 case SNDRV_PCM_TRIGGER_STOP:
367 pr_debug("sst: in stop\n");
368 str_cmd = SST_SND_DROP;
369 status = SST_PLATFORM_DROPPED;
370 break;
371 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
372 pr_debug("sst: in pause\n");
373 str_cmd = SST_SND_PAUSE;
374 status = SST_PLATFORM_PAUSED;
375 break;
376 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
377 pr_debug("sst: in pause release\n");
378 str_cmd = SST_SND_RESUME;
379 status = SST_PLATFORM_RUNNING;
380 break;
381 default:
382 return -EINVAL;
383 }
384 ret_val = stream->ops->device_control(str_cmd, &str_id);
385 if (!ret_val)
386 sst_set_stream_status(stream, status);
387
388 return ret_val;
389}
390
391
392static snd_pcm_uframes_t sst_platform_pcm_pointer
393 (struct snd_pcm_substream *substream)
394{
395 struct sst_runtime_stream *stream;
396 int ret_val, status;
397 struct pcm_stream_info *str_info;
398
399 stream = substream->runtime->private_data;
400 status = sst_get_stream_status(stream);
401 if (status == SST_PLATFORM_INIT)
402 return 0;
403 str_info = &stream->stream_info;
404 ret_val = stream->ops->device_control(
405 SST_SND_BUFFER_POINTER, str_info);
406 if (ret_val) {
407 pr_err("sst: error code = %d\n", ret_val);
408 return ret_val;
409 }
410 return stream->stream_info.buffer_ptr;
411}
412
413static int sst_platform_pcm_hw_params(struct snd_pcm_substream *substream,
414 struct snd_pcm_hw_params *params)
415{
416 snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
417 memset(substream->runtime->dma_area, 0, params_buffer_bytes(params));
418
419 return 0;
420}
421
422static int sst_platform_pcm_hw_free(struct snd_pcm_substream *substream)
423{
424 return snd_pcm_lib_free_pages(substream);
425}
426
427static struct snd_pcm_ops sst_platform_ops = {
428 .open = sst_platform_open,
429 .close = sst_platform_close,
430 .ioctl = snd_pcm_lib_ioctl,
431 .prepare = sst_platform_pcm_prepare,
432 .trigger = sst_platform_pcm_trigger,
433 .pointer = sst_platform_pcm_pointer,
434 .hw_params = sst_platform_pcm_hw_params,
435 .hw_free = sst_platform_pcm_hw_free,
436};
437
438static void sst_pcm_free(struct snd_pcm *pcm)
439{
440 pr_debug("sst_pcm_free called\n");
441 snd_pcm_lib_preallocate_free_for_all(pcm);
442}
443
444static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
445{
446 struct snd_pcm *pcm = rtd->pcm;
447 int retval = 0;
448
449 pr_debug("sst_pcm_new called\n");
450 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream ||
451 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
452 retval = snd_pcm_lib_preallocate_pages_for_all(pcm,
453 SNDRV_DMA_TYPE_CONTINUOUS,
454 snd_dma_continuous_data(GFP_KERNEL),
455 SST_MIN_BUFFER, SST_MAX_BUFFER);
456 if (retval) {
457 pr_err("dma buffer allocationf fail\n");
458 return retval;
459 }
460 }
461 return retval;
462}
463
464/* compress stream operations */
465static void sst_compr_fragment_elapsed(void *arg)
466{
467 struct snd_compr_stream *cstream = (struct snd_compr_stream *)arg;
468
469 pr_debug("fragment elapsed by driver\n");
470 if (cstream)
471 snd_compr_fragment_elapsed(cstream);
472}
473
474static int sst_platform_compr_open(struct snd_compr_stream *cstream)
475{
476
477 int ret_val = 0;
478 struct snd_compr_runtime *runtime = cstream->runtime;
479 struct sst_runtime_stream *stream;
480
481 stream = kzalloc(sizeof(*stream), GFP_KERNEL);
482 if (!stream)
483 return -ENOMEM;
484
485 spin_lock_init(&stream->status_lock);
486
487 /* get the sst ops */
488 if (!sst || !try_module_get(sst->dev->driver->owner)) {
489 pr_err("no device available to run\n");
490 ret_val = -ENODEV;
491 goto out_ops;
492 }
493 stream->compr_ops = sst->compr_ops;
494
495 stream->id = 0;
496 sst_set_stream_status(stream, SST_PLATFORM_INIT);
497 runtime->private_data = stream;
498 return 0;
499out_ops:
500 kfree(stream);
501 return ret_val;
502}
503
504static int sst_platform_compr_free(struct snd_compr_stream *cstream)
505{
506 struct sst_runtime_stream *stream;
507 int ret_val = 0, str_id;
508
509 stream = cstream->runtime->private_data;
510 /*need to check*/
511 str_id = stream->id;
512 if (str_id)
513 ret_val = stream->compr_ops->close(str_id);
514 module_put(sst->dev->driver->owner);
515 kfree(stream);
516 pr_debug("%s: %d\n", __func__, ret_val);
517 return 0;
518}
519
520static int sst_platform_compr_set_params(struct snd_compr_stream *cstream,
521 struct snd_compr_params *params)
522{
523 struct sst_runtime_stream *stream;
524 int retval;
525 struct snd_sst_params str_params;
526 struct sst_compress_cb cb;
527
528 stream = cstream->runtime->private_data;
529 /* construct fw structure for this*/
530 memset(&str_params, 0, sizeof(str_params));
531
532 str_params.ops = STREAM_OPS_PLAYBACK;
533 str_params.stream_type = SST_STREAM_TYPE_MUSIC;
534 str_params.device_type = SND_SST_DEVICE_COMPRESS;
535
536 switch (params->codec.id) {
537 case SND_AUDIOCODEC_MP3: {
538 str_params.codec = SST_CODEC_TYPE_MP3;
539 str_params.sparams.uc.mp3_params.codec = SST_CODEC_TYPE_MP3;
540 str_params.sparams.uc.mp3_params.num_chan = params->codec.ch_in;
541 str_params.sparams.uc.mp3_params.pcm_wd_sz = 16;
542 break;
543 }
544
545 case SND_AUDIOCODEC_AAC: {
546 str_params.codec = SST_CODEC_TYPE_AAC;
547 str_params.sparams.uc.aac_params.codec = SST_CODEC_TYPE_AAC;
548 str_params.sparams.uc.aac_params.num_chan = params->codec.ch_in;
549 str_params.sparams.uc.aac_params.pcm_wd_sz = 16;
550 if (params->codec.format == SND_AUDIOSTREAMFORMAT_MP4ADTS)
551 str_params.sparams.uc.aac_params.bs_format =
552 AAC_BIT_STREAM_ADTS;
553 else if (params->codec.format == SND_AUDIOSTREAMFORMAT_RAW)
554 str_params.sparams.uc.aac_params.bs_format =
555 AAC_BIT_STREAM_RAW;
556 else {
557 pr_err("Undefined format%d\n", params->codec.format);
558 return -EINVAL;
559 }
560 str_params.sparams.uc.aac_params.externalsr =
561 params->codec.sample_rate;
562 break;
563 }
564
565 default:
566 pr_err("codec not supported, id =%d\n", params->codec.id);
567 return -EINVAL;
568 }
569
570 str_params.aparams.ring_buf_info[0].addr =
571 virt_to_phys(cstream->runtime->buffer);
572 str_params.aparams.ring_buf_info[0].size =
573 cstream->runtime->buffer_size;
574 str_params.aparams.sg_count = 1;
575 str_params.aparams.frag_size = cstream->runtime->fragment_size;
576
577 cb.param = cstream;
578 cb.compr_cb = sst_compr_fragment_elapsed;
579
580 retval = stream->compr_ops->open(&str_params, &cb);
581 if (retval < 0) {
582 pr_err("stream allocation failed %d\n", retval);
583 return retval;
584 }
585
586 stream->id = retval;
587 return 0;
588}
589
590static int sst_platform_compr_trigger(struct snd_compr_stream *cstream, int cmd)
591{
592 struct sst_runtime_stream *stream =
593 cstream->runtime->private_data;
594
595 return stream->compr_ops->control(cmd, stream->id);
596}
597
598static int sst_platform_compr_pointer(struct snd_compr_stream *cstream,
599 struct snd_compr_tstamp *tstamp)
600{
601 struct sst_runtime_stream *stream;
602
603 stream = cstream->runtime->private_data;
604 stream->compr_ops->tstamp(stream->id, tstamp);
605 tstamp->byte_offset = tstamp->copied_total %
606 (u32)cstream->runtime->buffer_size;
607 pr_debug("calc bytes offset/copied bytes as %d\n", tstamp->byte_offset);
608 return 0;
609}
610
611static int sst_platform_compr_ack(struct snd_compr_stream *cstream,
612 size_t bytes)
613{
614 struct sst_runtime_stream *stream;
615
616 stream = cstream->runtime->private_data;
617 stream->compr_ops->ack(stream->id, (unsigned long)bytes);
618 stream->bytes_written += bytes;
619
620 return 0;
621}
622
623static int sst_platform_compr_get_caps(struct snd_compr_stream *cstream,
624 struct snd_compr_caps *caps)
625{
626 struct sst_runtime_stream *stream =
627 cstream->runtime->private_data;
628
629 return stream->compr_ops->get_caps(caps);
630}
631
632static int sst_platform_compr_get_codec_caps(struct snd_compr_stream *cstream,
633 struct snd_compr_codec_caps *codec)
634{
635 struct sst_runtime_stream *stream =
636 cstream->runtime->private_data;
637
638 return stream->compr_ops->get_codec_caps(codec);
639}
640
641static int sst_platform_compr_set_metadata(struct snd_compr_stream *cstream,
642 struct snd_compr_metadata *metadata)
643{
644 struct sst_runtime_stream *stream =
645 cstream->runtime->private_data;
646
647 return stream->compr_ops->set_metadata(stream->id, metadata);
648}
649
650static struct snd_compr_ops sst_platform_compr_ops = {
651
652 .open = sst_platform_compr_open,
653 .free = sst_platform_compr_free,
654 .set_params = sst_platform_compr_set_params,
655 .set_metadata = sst_platform_compr_set_metadata,
656 .trigger = sst_platform_compr_trigger,
657 .pointer = sst_platform_compr_pointer,
658 .ack = sst_platform_compr_ack,
659 .get_caps = sst_platform_compr_get_caps,
660 .get_codec_caps = sst_platform_compr_get_codec_caps,
661};
662
663static struct snd_soc_platform_driver sst_soc_platform_drv = {
664 .ops = &sst_platform_ops,
665 .compr_ops = &sst_platform_compr_ops,
666 .pcm_new = sst_pcm_new,
667 .pcm_free = sst_pcm_free,
668};
669
670static const struct snd_soc_component_driver sst_component = {
671 .name = "sst",
672};
673
674
675static int sst_platform_probe(struct platform_device *pdev)
676{
677 int ret;
678
679 pr_debug("sst_platform_probe called\n");
680 sst = NULL;
681 ret = snd_soc_register_platform(&pdev->dev, &sst_soc_platform_drv);
682 if (ret) {
683 pr_err("registering soc platform failed\n");
684 return ret;
685 }
686
687 ret = snd_soc_register_component(&pdev->dev, &sst_component,
688 sst_platform_dai, ARRAY_SIZE(sst_platform_dai));
689 if (ret) {
690 pr_err("registering cpu dais failed\n");
691 snd_soc_unregister_platform(&pdev->dev);
692 }
693 return ret;
694}
695
696static int sst_platform_remove(struct platform_device *pdev)
697{
698
699 snd_soc_unregister_component(&pdev->dev);
700 snd_soc_unregister_platform(&pdev->dev);
701 pr_debug("sst_platform_remove success\n");
702 return 0;
703}
704
705static struct platform_driver sst_platform_driver = {
706 .driver = {
707 .name = "sst-mfld-platform",
708 .owner = THIS_MODULE,
709 },
710 .probe = sst_platform_probe,
711 .remove = sst_platform_remove,
712};
713
714module_platform_driver(sst_platform_driver);
715
716MODULE_DESCRIPTION("ASoC Intel(R) MID Platform driver");
717MODULE_AUTHOR("Vinod Koul <vinod.koul@intel.com>");
718MODULE_AUTHOR("Harsha Priya <priya.harsha@intel.com>");
719MODULE_LICENSE("GPL v2");
720MODULE_ALIAS("platform:sst-mfld-platform");