-
Notifications
You must be signed in to change notification settings - Fork 144
ASoC: SOF: Initial support for IPC4 compress offload #5647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: topic/sof-dev
Are you sure you want to change the base?
Changes from 1 commit
ed05eda
cc11ca2
54afdb9
d53d3e8
90369a3
930dbb5
329ee14
9e5839a
6946767
9895118
42c61e3
2f8be3c
a1a7b17
66c8d8a
1ae0a3c
fe8dcb6
99b7de8
6be8ed0
a7e79c7
4670715
c319fe0
9ae5254
787627d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,6 +151,71 @@ int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev, | |
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_pcm_hw_params, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| int hda_dsp_compr_hw_params(struct snd_sof_dev *sdev, | ||
| struct snd_compr_stream *cstream, | ||
| struct snd_compr_params *params, | ||
| struct snd_sof_platform_stream_params *platform_params) | ||
| { | ||
| struct hdac_stream *hstream = cstream->runtime->private_data; | ||
| struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream); | ||
| struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; | ||
| struct snd_dma_buffer *dmab; | ||
| u32 bits, rate; | ||
| int bps; | ||
| int ret; | ||
|
|
||
| hstream->cstream = cstream; | ||
| dmab = cstream->runtime->dma_buffer_p; | ||
|
|
||
| /* Use correct format based on the used codec */ | ||
| switch (params->codec.id) { | ||
| case SND_AUDIOCODEC_PCM: | ||
| bps = snd_pcm_format_physical_width(params->codec.format); | ||
| break; | ||
| case SND_AUDIOCODEC_VORBIS: | ||
| bps = snd_pcm_format_physical_width(SNDRV_PCM_FORMAT_S16_LE); | ||
| break; | ||
| case SND_AUDIOCODEC_FLAC: | ||
| { | ||
| struct snd_dec_flac *dec_flac = ¶ms->codec.options.flac_d; | ||
|
|
||
| if (dec_flac->sample_size == 16) | ||
| bps = snd_pcm_format_physical_width(SNDRV_PCM_FORMAT_S16_LE); | ||
| else | ||
| bps = snd_pcm_format_physical_width(SNDRV_PCM_FORMAT_S32_LE); | ||
| break; | ||
| } | ||
| default: | ||
| bps = snd_pcm_format_physical_width(SNDRV_PCM_FORMAT_S32_LE); | ||
| } | ||
|
|
||
| if (bps < 0) | ||
| return bps; | ||
| bits = hda_dsp_get_bits(sdev, bps); | ||
| rate = hda_dsp_get_mult_div(sdev, params->codec.sample_rate); | ||
|
|
||
| hstream->format_val = rate | bits | (params->codec.ch_out - 1); | ||
| hstream->bufsize = cstream->runtime->buffer_size; | ||
| hstream->period_bytes = cstream->runtime->fragment_size; | ||
| hstream->no_period_wakeup = false; | ||
|
|
||
| /* params is not used so pass NULL */ | ||
| dmab = cstream->runtime->dma_buffer_p; | ||
| ret = hda_dsp_stream_hw_params(sdev, hext_stream, dmab, NULL); | ||
| if (ret < 0) { | ||
| dev_err(sdev->dev, "%s: hdac prepare failed: %d\n", __func__, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| if (hda) | ||
| platform_params->no_ipc_position = hda->no_ipc_position; | ||
|
|
||
| platform_params->stream_tag = hstream->stream_tag; | ||
|
|
||
| return 0; | ||
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_compr_hw_params, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| /* update SPIB register with appl position */ | ||
| int hda_dsp_pcm_ack(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream) | ||
| { | ||
|
|
@@ -184,6 +249,16 @@ int hda_dsp_pcm_trigger(struct snd_sof_dev *sdev, | |
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_pcm_trigger, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| int hda_dsp_compr_trigger(struct snd_sof_dev *sdev, | ||
| struct snd_compr_stream *cstream, int cmd) | ||
| { | ||
| struct hdac_stream *hstream = cstream->runtime->private_data; | ||
| struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream); | ||
|
|
||
| return hda_dsp_stream_trigger(sdev, hext_stream, cmd); | ||
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_compr_trigger, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| snd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev, | ||
| struct snd_pcm_substream *substream) | ||
| { | ||
|
|
@@ -216,6 +291,20 @@ snd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev, | |
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_pcm_pointer, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| int hda_dsp_compr_pointer(struct snd_sof_dev *sdev, struct snd_compr_stream *cstream, | ||
| struct snd_compr_tstamp64 *tstamp) | ||
| { | ||
| struct hdac_stream *hstream = cstream->runtime->private_data; | ||
|
|
||
| /* hstream->curr_pos is updated when we receive the ioc */ | ||
| tstamp->copied_total = hstream->curr_pos; | ||
|
|
||
| tstamp->byte_offset = hda_dsp_stream_get_position(hstream, cstream->direction, true); | ||
|
|
||
| return 0; | ||
|
Comment on lines
+294
to
+304
|
||
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_compr_pointer, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| int hda_dsp_pcm_open(struct snd_sof_dev *sdev, | ||
| struct snd_pcm_substream *substream) | ||
| { | ||
|
|
@@ -342,6 +431,41 @@ int hda_dsp_pcm_open(struct snd_sof_dev *sdev, | |
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_pcm_open, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| int hda_dsp_compr_open(struct snd_sof_dev *sdev, struct snd_compr_stream *cstream) | ||
| { | ||
| struct snd_soc_pcm_runtime *rtd = cstream->private_data; | ||
| struct snd_soc_component *scomp = sdev->component; | ||
| struct hdac_ext_stream *dsp_stream; | ||
| struct snd_sof_pcm *spcm; | ||
| int direction = cstream->direction; | ||
|
|
||
| spcm = snd_sof_find_spcm_dai(scomp, rtd); | ||
| if (!spcm) { | ||
| dev_err(sdev->dev, "%s: can't find PCM with DAI ID %d\n", | ||
| __func__, rtd->dai_link->id); | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| dsp_stream = hda_dsp_stream_get(sdev, direction, 0); | ||
| if (!dsp_stream) { | ||
| dev_err(sdev->dev, "%s: no stream available\n", __func__); | ||
| return -ENODEV; | ||
| } | ||
|
|
||
| /* binding compr stream to hda stream */ | ||
| cstream->runtime->private_data = &dsp_stream->hstream; | ||
|
|
||
| /* | ||
| * Reset the llp cache values (they are used for LLP compensation in | ||
| * case the counter is not reset) | ||
| */ | ||
| dsp_stream->pplcllpl = 0; | ||
| dsp_stream->pplcllpu = 0; | ||
|
|
||
| return 0; | ||
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_compr_open, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| int hda_dsp_pcm_close(struct snd_sof_dev *sdev, | ||
| struct snd_pcm_substream *substream) | ||
| { | ||
|
|
@@ -361,3 +485,20 @@ int hda_dsp_pcm_close(struct snd_sof_dev *sdev, | |
| return 0; | ||
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_pcm_close, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| int hda_dsp_compr_close(struct snd_sof_dev *sdev, struct snd_compr_stream *cstream) | ||
| { | ||
| struct hdac_stream *hstream = cstream->runtime->private_data; | ||
| int direction = cstream->direction; | ||
| int ret; | ||
|
|
||
| ret = hda_dsp_stream_put(sdev, direction, hstream->stream_tag); | ||
| if (ret) | ||
| return -ENODEV; | ||
|
|
||
| /* unbinding compress stream to hda stream */ | ||
| hstream->cstream = NULL; | ||
| cstream->runtime->private_data = NULL; | ||
| return 0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing empty linefeed before return |
||
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_compr_close, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is generic encoded audio data i.e. a fallback if not matched above