1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
3 // This file is provided under a dual BSD/GPLv2 license. When using or
4 // redistributing this file, you may do so under either license.
6 // Copyright(c) 2018 Intel Corporation. All rights reserved.
8 // Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
10 // PCM Layer, interface between ALSA and IPC.
13 #include <linux/pm_runtime.h>
14 #include <sound/pcm_params.h>
15 #include <sound/sof.h>
17 #include "sof-audio.h"
20 /* Create DMA buffer page table for DSP */
21 static int create_page_table(struct snd_soc_component *component,
22 struct snd_pcm_substream *substream,
23 unsigned char *dma_area, size_t size)
25 struct snd_soc_pcm_runtime *rtd = substream->private_data;
26 struct snd_sof_pcm *spcm;
27 struct snd_dma_buffer *dmab = snd_pcm_get_dma_buf(substream);
28 int stream = substream->stream;
30 spcm = snd_sof_find_spcm_dai(component, rtd);
34 return snd_sof_create_page_table(component->dev, dmab,
35 spcm->stream[stream].page_table.area, size);
38 static int sof_pcm_dsp_params(struct snd_sof_pcm *spcm, struct snd_pcm_substream *substream,
39 const struct sof_ipc_pcm_params_reply *reply)
41 struct snd_soc_component *scomp = spcm->scomp;
42 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
45 int ret = snd_sof_ipc_pcm_params(sdev, substream, reply);
48 dev_err(scomp->dev, "error: got wrong reply for PCM %d\n",
55 * sof pcm period elapse work
57 static void sof_pcm_period_elapsed_work(struct work_struct *work)
59 struct snd_sof_pcm_stream *sps =
60 container_of(work, struct snd_sof_pcm_stream,
63 snd_pcm_period_elapsed(sps->substream);
67 * sof pcm period elapse, this could be called at irq thread context.
69 void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream)
71 struct snd_soc_pcm_runtime *rtd = substream->private_data;
72 struct snd_soc_component *component =
73 snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
74 struct snd_sof_pcm *spcm;
76 spcm = snd_sof_find_spcm_dai(component, rtd);
78 dev_err(component->dev,
79 "error: period elapsed for unknown stream!\n");
84 * snd_pcm_period_elapsed() can be called in interrupt context
85 * before IRQ_HANDLED is returned. Inside snd_pcm_period_elapsed(),
86 * when the PCM is done draining or xrun happened, a STOP IPC will
87 * then be sent and this IPC will hit IPC timeout.
88 * To avoid sending IPC before the previous IPC is handled, we
89 * schedule delayed work here to call the snd_pcm_period_elapsed().
91 schedule_work(&spcm->stream[substream->stream].period_elapsed_work);
93 EXPORT_SYMBOL(snd_sof_pcm_period_elapsed);
95 /* this may get called several times by oss emulation */
96 static int sof_pcm_hw_params(struct snd_soc_component *component,
97 struct snd_pcm_substream *substream,
98 struct snd_pcm_hw_params *params)
100 struct snd_soc_pcm_runtime *rtd = substream->private_data;
101 struct snd_pcm_runtime *runtime = substream->runtime;
102 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
103 struct snd_sof_pcm *spcm;
104 struct sof_ipc_pcm_params pcm;
105 struct sof_ipc_pcm_params_reply ipc_params_reply;
108 /* nothing to do for BE */
109 if (rtd->dai_link->no_pcm)
112 spcm = snd_sof_find_spcm_dai(component, rtd);
116 dev_dbg(component->dev, "pcm: hw params stream %d dir %d\n",
117 spcm->pcm.pcm_id, substream->stream);
119 memset(&pcm, 0, sizeof(pcm));
121 /* allocate audio buffer pages */
122 ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
124 dev_err(component->dev, "error: could not allocate %d bytes for PCM %d\n",
125 params_buffer_bytes(params), spcm->pcm.pcm_id);
130 * ret == 1 means the buffer is changed
131 * create compressed page table for audio firmware
132 * ret == 0 means the buffer is not changed
133 * so no need to regenerate the page table
135 ret = create_page_table(component, substream, runtime->dma_area,
141 /* number of pages should be rounded up */
142 pcm.params.buffer.pages = PFN_UP(runtime->dma_bytes);
144 /* set IPC PCM parameters */
145 pcm.hdr.size = sizeof(pcm);
146 pcm.hdr.cmd = SOF_IPC_GLB_STREAM_MSG | SOF_IPC_STREAM_PCM_PARAMS;
147 pcm.comp_id = spcm->stream[substream->stream].comp_id;
148 pcm.params.hdr.size = sizeof(pcm.params);
149 pcm.params.buffer.phy_addr =
150 spcm->stream[substream->stream].page_table.addr;
151 pcm.params.buffer.size = runtime->dma_bytes;
152 pcm.params.direction = substream->stream;
153 pcm.params.sample_valid_bytes = params_width(params) >> 3;
154 pcm.params.buffer_fmt = SOF_IPC_BUFFER_INTERLEAVED;
155 pcm.params.rate = params_rate(params);
156 pcm.params.channels = params_channels(params);
157 pcm.params.host_period_bytes = params_period_bytes(params);
160 ret = snd_pcm_format_physical_width(params_format(params));
163 pcm.params.sample_container_bytes = ret >> 3;
166 switch (params_format(params)) {
167 case SNDRV_PCM_FORMAT_S16:
168 pcm.params.frame_fmt = SOF_IPC_FRAME_S16_LE;
170 case SNDRV_PCM_FORMAT_S24:
171 pcm.params.frame_fmt = SOF_IPC_FRAME_S24_4LE;
173 case SNDRV_PCM_FORMAT_S32:
174 pcm.params.frame_fmt = SOF_IPC_FRAME_S32_LE;
176 case SNDRV_PCM_FORMAT_FLOAT:
177 pcm.params.frame_fmt = SOF_IPC_FRAME_FLOAT;
183 /* firmware already configured host stream */
184 ret = snd_sof_pcm_platform_hw_params(sdev,
189 dev_err(component->dev, "error: platform hw params failed\n");
193 dev_dbg(component->dev, "stream_tag %d", pcm.params.stream_tag);
195 /* send IPC to the DSP */
196 ret = sof_ipc_tx_message(sdev->ipc, pcm.hdr.cmd, &pcm, sizeof(pcm),
197 &ipc_params_reply, sizeof(ipc_params_reply));
199 dev_err(component->dev, "error: hw params ipc failed for stream %d\n",
200 pcm.params.stream_tag);
204 ret = sof_pcm_dsp_params(spcm, substream, &ipc_params_reply);
208 spcm->prepared[substream->stream] = true;
210 /* save pcm hw_params */
211 memcpy(&spcm->params[substream->stream], params, sizeof(*params));
216 static int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream,
217 struct snd_sof_dev *sdev,
218 struct snd_sof_pcm *spcm)
220 struct sof_ipc_stream stream;
221 struct sof_ipc_reply reply;
224 stream.hdr.size = sizeof(stream);
225 stream.hdr.cmd = SOF_IPC_GLB_STREAM_MSG | SOF_IPC_STREAM_PCM_FREE;
226 stream.comp_id = spcm->stream[substream->stream].comp_id;
228 /* send IPC to the DSP */
229 ret = sof_ipc_tx_message(sdev->ipc, stream.hdr.cmd, &stream,
230 sizeof(stream), &reply, sizeof(reply));
232 spcm->prepared[substream->stream] = false;
237 static int sof_pcm_hw_free(struct snd_soc_component *component,
238 struct snd_pcm_substream *substream)
240 struct snd_soc_pcm_runtime *rtd = substream->private_data;
241 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
242 struct snd_sof_pcm *spcm;
245 /* nothing to do for BE */
246 if (rtd->dai_link->no_pcm)
249 spcm = snd_sof_find_spcm_dai(component, rtd);
253 dev_dbg(component->dev, "pcm: free stream %d dir %d\n",
254 spcm->pcm.pcm_id, substream->stream);
256 if (spcm->prepared[substream->stream]) {
257 ret = sof_pcm_dsp_pcm_free(substream, sdev, spcm);
262 snd_pcm_lib_free_pages(substream);
264 cancel_work_sync(&spcm->stream[substream->stream].period_elapsed_work);
266 ret = snd_sof_pcm_platform_hw_free(sdev, substream);
268 dev_err(component->dev, "error: platform hw free failed\n");
275 static int sof_pcm_prepare(struct snd_soc_component *component,
276 struct snd_pcm_substream *substream)
278 struct snd_soc_pcm_runtime *rtd = substream->private_data;
279 struct snd_sof_pcm *spcm;
282 /* nothing to do for BE */
283 if (rtd->dai_link->no_pcm)
286 spcm = snd_sof_find_spcm_dai(component, rtd);
290 if (spcm->prepared[substream->stream])
293 dev_dbg(component->dev, "pcm: prepare stream %d dir %d\n",
294 spcm->pcm.pcm_id, substream->stream);
297 ret = sof_pcm_hw_params(component,
298 substream, &spcm->params[substream->stream]);
300 dev_err(component->dev,
301 "error: set pcm hw_params after resume\n");
309 * FE dai link trigger actions are always executed in non-atomic context because
310 * they involve IPC's.
312 static int sof_pcm_trigger(struct snd_soc_component *component,
313 struct snd_pcm_substream *substream, int cmd)
315 struct snd_soc_pcm_runtime *rtd = substream->private_data;
316 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
317 struct snd_sof_pcm *spcm;
318 struct sof_ipc_stream stream;
319 struct sof_ipc_reply reply;
320 bool reset_hw_params = false;
321 bool ipc_first = false;
324 /* nothing to do for BE */
325 if (rtd->dai_link->no_pcm)
328 spcm = snd_sof_find_spcm_dai(component, rtd);
332 dev_dbg(component->dev, "pcm: trigger stream %d dir %d cmd %d\n",
333 spcm->pcm.pcm_id, substream->stream, cmd);
335 stream.hdr.size = sizeof(stream);
336 stream.hdr.cmd = SOF_IPC_GLB_STREAM_MSG;
337 stream.comp_id = spcm->stream[substream->stream].comp_id;
340 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
341 stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_PAUSE;
344 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
345 stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_RELEASE;
347 case SNDRV_PCM_TRIGGER_RESUME:
348 if (spcm->stream[substream->stream].suspend_ignored) {
350 * this case will be triggered when INFO_RESUME is
351 * supported, no need to resume streams that remained
354 spcm->stream[substream->stream].suspend_ignored = false;
358 /* set up hw_params */
359 ret = sof_pcm_prepare(component, substream);
361 dev_err(component->dev,
362 "error: failed to set up hw_params upon resume\n");
367 case SNDRV_PCM_TRIGGER_START:
368 if (spcm->stream[substream->stream].suspend_ignored) {
370 * This case will be triggered when INFO_RESUME is
371 * not supported, no need to re-start streams that
372 * remained enabled in D0ix.
374 spcm->stream[substream->stream].suspend_ignored = false;
377 stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_START;
379 case SNDRV_PCM_TRIGGER_SUSPEND:
380 if (sdev->s0_suspend &&
381 spcm->stream[substream->stream].d0i3_compatible) {
383 * trap the event, not sending trigger stop to
384 * prevent the FW pipelines from being stopped,
385 * and mark the flag to ignore the upcoming DAPM
388 spcm->stream[substream->stream].suspend_ignored = true;
392 case SNDRV_PCM_TRIGGER_STOP:
393 stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_STOP;
395 reset_hw_params = true;
398 dev_err(component->dev, "error: unhandled trigger cmd %d\n",
404 * DMA and IPC sequence is different for start and stop. Need to send
405 * STOP IPC before stop DMA
408 snd_sof_pcm_platform_trigger(sdev, substream, cmd);
410 /* send IPC to the DSP */
411 ret = sof_ipc_tx_message(sdev->ipc, stream.hdr.cmd, &stream,
412 sizeof(stream), &reply, sizeof(reply));
414 /* need to STOP DMA even if STOP IPC failed */
416 snd_sof_pcm_platform_trigger(sdev, substream, cmd);
418 /* free PCM if reset_hw_params is set and the STOP IPC is successful */
419 if (!ret && reset_hw_params)
420 ret = sof_pcm_dsp_pcm_free(substream, sdev, spcm);
425 static snd_pcm_uframes_t sof_pcm_pointer(struct snd_soc_component *component,
426 struct snd_pcm_substream *substream)
428 struct snd_soc_pcm_runtime *rtd = substream->private_data;
429 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
430 struct snd_sof_pcm *spcm;
431 snd_pcm_uframes_t host, dai;
433 /* nothing to do for BE */
434 if (rtd->dai_link->no_pcm)
437 /* use dsp ops pointer callback directly if set */
438 if (sof_ops(sdev)->pcm_pointer)
439 return sof_ops(sdev)->pcm_pointer(sdev, substream);
441 spcm = snd_sof_find_spcm_dai(component, rtd);
445 /* read position from DSP */
446 host = bytes_to_frames(substream->runtime,
447 spcm->stream[substream->stream].posn.host_posn);
448 dai = bytes_to_frames(substream->runtime,
449 spcm->stream[substream->stream].posn.dai_posn);
451 dev_dbg(component->dev,
452 "PCM: stream %d dir %d DMA position %lu DAI position %lu\n",
453 spcm->pcm.pcm_id, substream->stream, host, dai);
458 static int sof_pcm_open(struct snd_soc_component *component,
459 struct snd_pcm_substream *substream)
461 struct snd_soc_pcm_runtime *rtd = substream->private_data;
462 struct snd_pcm_runtime *runtime = substream->runtime;
463 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
464 const struct snd_sof_dsp_ops *ops = sof_ops(sdev);
465 struct snd_sof_pcm *spcm;
466 struct snd_soc_tplg_stream_caps *caps;
469 /* nothing to do for BE */
470 if (rtd->dai_link->no_pcm)
473 spcm = snd_sof_find_spcm_dai(component, rtd);
477 dev_dbg(component->dev, "pcm: open stream %d dir %d\n",
478 spcm->pcm.pcm_id, substream->stream);
480 INIT_WORK(&spcm->stream[substream->stream].period_elapsed_work,
481 sof_pcm_period_elapsed_work);
483 caps = &spcm->pcm.caps[substream->stream];
485 /* set any runtime constraints based on topology */
486 snd_pcm_hw_constraint_step(substream->runtime, 0,
487 SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
488 le32_to_cpu(caps->period_size_min));
489 snd_pcm_hw_constraint_step(substream->runtime, 0,
490 SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
491 le32_to_cpu(caps->period_size_min));
493 /* set runtime config */
494 runtime->hw.info = ops->hw_info; /* platform-specific */
496 runtime->hw.formats = le64_to_cpu(caps->formats);
497 runtime->hw.period_bytes_min = le32_to_cpu(caps->period_size_min);
498 runtime->hw.period_bytes_max = le32_to_cpu(caps->period_size_max);
499 runtime->hw.periods_min = le32_to_cpu(caps->periods_min);
500 runtime->hw.periods_max = le32_to_cpu(caps->periods_max);
503 * caps->buffer_size_min is not used since the
504 * snd_pcm_hardware structure only defines buffer_bytes_max
506 runtime->hw.buffer_bytes_max = le32_to_cpu(caps->buffer_size_max);
508 dev_dbg(component->dev, "period min %zd max %zd bytes\n",
509 runtime->hw.period_bytes_min,
510 runtime->hw.period_bytes_max);
511 dev_dbg(component->dev, "period count %d max %d\n",
512 runtime->hw.periods_min,
513 runtime->hw.periods_max);
514 dev_dbg(component->dev, "buffer max %zd bytes\n",
515 runtime->hw.buffer_bytes_max);
517 /* set wait time - TODO: come from topology */
518 substream->wait_time = 500;
520 spcm->stream[substream->stream].posn.host_posn = 0;
521 spcm->stream[substream->stream].posn.dai_posn = 0;
522 spcm->stream[substream->stream].substream = substream;
523 spcm->prepared[substream->stream] = false;
525 ret = snd_sof_pcm_platform_open(sdev, substream);
527 dev_err(component->dev, "error: pcm open failed %d\n", ret);
532 static int sof_pcm_close(struct snd_soc_component *component,
533 struct snd_pcm_substream *substream)
535 struct snd_soc_pcm_runtime *rtd = substream->private_data;
536 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
537 struct snd_sof_pcm *spcm;
540 /* nothing to do for BE */
541 if (rtd->dai_link->no_pcm)
544 spcm = snd_sof_find_spcm_dai(component, rtd);
548 dev_dbg(component->dev, "pcm: close stream %d dir %d\n",
549 spcm->pcm.pcm_id, substream->stream);
551 err = snd_sof_pcm_platform_close(sdev, substream);
553 dev_err(component->dev, "error: pcm close failed %d\n",
556 * keep going, no point in preventing the close
565 * Pre-allocate playback/capture audio buffer pages.
566 * no need to explicitly release memory preallocated by sof_pcm_new in pcm_free
567 * snd_pcm_lib_preallocate_free_for_all() is called by the core.
569 static int sof_pcm_new(struct snd_soc_component *component,
570 struct snd_soc_pcm_runtime *rtd)
572 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
573 struct snd_sof_pcm *spcm;
574 struct snd_pcm *pcm = rtd->pcm;
575 struct snd_soc_tplg_stream_caps *caps;
576 int stream = SNDRV_PCM_STREAM_PLAYBACK;
578 /* find SOF PCM for this RTD */
579 spcm = snd_sof_find_spcm_dai(component, rtd);
581 dev_warn(component->dev, "warn: can't find PCM with DAI ID %d\n",
586 dev_dbg(component->dev, "creating new PCM %s\n", spcm->pcm.pcm_name);
588 /* do we need to pre-allocate playback audio buffer pages */
589 if (!spcm->pcm.playback)
592 caps = &spcm->pcm.caps[stream];
594 /* pre-allocate playback audio buffer pages */
595 dev_dbg(component->dev,
596 "spcm: allocate %s playback DMA buffer size 0x%x max 0x%x\n",
597 caps->name, caps->buffer_size_min, caps->buffer_size_max);
599 snd_pcm_lib_preallocate_pages(pcm->streams[stream].substream,
600 SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
601 le32_to_cpu(caps->buffer_size_min),
602 le32_to_cpu(caps->buffer_size_max));
604 stream = SNDRV_PCM_STREAM_CAPTURE;
606 /* do we need to pre-allocate capture audio buffer pages */
607 if (!spcm->pcm.capture)
610 caps = &spcm->pcm.caps[stream];
612 /* pre-allocate capture audio buffer pages */
613 dev_dbg(component->dev,
614 "spcm: allocate %s capture DMA buffer size 0x%x max 0x%x\n",
615 caps->name, caps->buffer_size_min, caps->buffer_size_max);
617 snd_pcm_lib_preallocate_pages(pcm->streams[stream].substream,
618 SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
619 le32_to_cpu(caps->buffer_size_min),
620 le32_to_cpu(caps->buffer_size_max));
625 /* fixup the BE DAI link to match any values from topology */
626 static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
627 struct snd_pcm_hw_params *params)
629 struct snd_interval *rate = hw_param_interval(params,
630 SNDRV_PCM_HW_PARAM_RATE);
631 struct snd_interval *channels = hw_param_interval(params,
632 SNDRV_PCM_HW_PARAM_CHANNELS);
633 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
634 struct snd_soc_component *component =
635 snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
636 struct snd_sof_dai *dai =
637 snd_sof_find_dai(component, (char *)rtd->dai_link->name);
639 /* no topology exists for this BE, try a common configuration */
641 dev_warn(component->dev,
642 "warning: no topology found for BE DAI %s config\n",
643 rtd->dai_link->name);
645 /* set 48k, stereo, 16bits by default */
653 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
658 /* read format from topology */
661 switch (dai->comp_dai.config.frame_fmt) {
662 case SOF_IPC_FRAME_S16_LE:
663 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
665 case SOF_IPC_FRAME_S24_4LE:
666 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
668 case SOF_IPC_FRAME_S32_LE:
669 snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S32_LE);
672 dev_err(component->dev, "error: No available DAI format!\n");
676 /* read rate and channels from topology */
677 switch (dai->dai_config->type) {
678 case SOF_DAI_INTEL_SSP:
679 rate->min = dai->dai_config->ssp.fsync_rate;
680 rate->max = dai->dai_config->ssp.fsync_rate;
681 channels->min = dai->dai_config->ssp.tdm_slots;
682 channels->max = dai->dai_config->ssp.tdm_slots;
684 dev_dbg(component->dev,
685 "rate_min: %d rate_max: %d\n", rate->min, rate->max);
686 dev_dbg(component->dev,
687 "channels_min: %d channels_max: %d\n",
688 channels->min, channels->max);
691 case SOF_DAI_INTEL_DMIC:
692 /* DMIC only supports 16 or 32 bit formats */
693 if (dai->comp_dai.config.frame_fmt == SOF_IPC_FRAME_S24_4LE) {
694 dev_err(component->dev,
695 "error: invalid fmt %d for DAI type %d\n",
696 dai->comp_dai.config.frame_fmt,
697 dai->dai_config->type);
700 case SOF_DAI_INTEL_HDA:
701 /* do nothing for HDA dai_link */
703 case SOF_DAI_INTEL_ALH:
704 /* do nothing for ALH dai_link */
706 case SOF_DAI_IMX_ESAI:
707 channels->min = dai->dai_config->esai.tdm_slots;
708 channels->max = dai->dai_config->esai.tdm_slots;
710 dev_dbg(component->dev,
711 "channels_min: %d channels_max: %d\n",
712 channels->min, channels->max);
715 dev_err(component->dev, "error: invalid DAI type %d\n",
716 dai->dai_config->type);
723 static int sof_pcm_probe(struct snd_soc_component *component)
725 struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
726 struct snd_sof_pdata *plat_data = sdev->pdata;
727 const char *tplg_filename;
730 /* load the default topology */
731 sdev->component = component;
733 tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL,
735 plat_data->tplg_filename_prefix,
736 plat_data->tplg_filename);
740 ret = snd_sof_load_topology(component, tplg_filename);
742 dev_err(component->dev, "error: failed to load DSP topology %d\n",
750 static void sof_pcm_remove(struct snd_soc_component *component)
752 /* remove topology */
753 snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL);
756 void snd_sof_new_platform_drv(struct snd_sof_dev *sdev)
758 struct snd_soc_component_driver *pd = &sdev->plat_drv;
759 struct snd_sof_pdata *plat_data = sdev->pdata;
760 const char *drv_name;
762 drv_name = plat_data->machine->drv_name;
764 pd->name = "sof-audio-component";
765 pd->probe = sof_pcm_probe;
766 pd->remove = sof_pcm_remove;
767 pd->open = sof_pcm_open;
768 pd->close = sof_pcm_close;
769 pd->ioctl = snd_soc_pcm_lib_ioctl;
770 pd->hw_params = sof_pcm_hw_params;
771 pd->prepare = sof_pcm_prepare;
772 pd->hw_free = sof_pcm_hw_free;
773 pd->trigger = sof_pcm_trigger;
774 pd->pointer = sof_pcm_pointer;
776 #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS)
777 pd->compr_ops = &sof_compressed_ops;
779 pd->pcm_construct = sof_pcm_new;
780 pd->ignore_machine = drv_name;
781 pd->be_hw_params_fixup = sof_pcm_dai_link_fixup;
782 pd->be_pcm_base = SOF_BE_PCM_BASE;
783 pd->use_dai_pcm_id = true;
784 pd->topology_name_prefix = "sof";
786 /* increment module refcount when a pcm is opened */
787 pd->module_get_upon_open = 1;