Skip to content

Commit 4c414da

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: SOF: Intel: Probe compress operations
Add HDA handlers for soc_compr_ops and snd_compr_ops which cover probe related operations. Implementation supports both connection purposes. These merely define stream setups as core flow is covered by SOF compress core. Signed-off-by: Cezary Rojewski <[email protected]> Acked-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 49d7948 commit 4c414da

File tree

6 files changed

+166
-0
lines changed

6 files changed

+166
-0
lines changed

sound/soc/sof/intel/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,15 @@ config SND_SOC_SOF_HDA_AUDIO_CODEC
305305
Say Y if you want to enable HDAudio codecs with SOF.
306306
If unsure select "N".
307307

308+
config SND_SOC_SOF_HDA_PROBES
309+
bool "SOF enable probes over HDA"
310+
depends on SND_SOC_SOF_DEBUG_PROBES
311+
help
312+
This option enables the data probing for Intel(R).
313+
Intel(R) Skylake and newer platforms.
314+
Say Y if you want to enable probes.
315+
If unsure, select "N".
316+
308317
config SND_SOC_SOF_HDA_ALWAYS_ENABLE_DMI_L1
309318
bool "SOF enable DMI Link L1"
310319
help

sound/soc/sof/intel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-trace.o \
99
hda-dsp.o hda-ipc.o hda-ctrl.o hda-pcm.o \
1010
hda-dai.o hda-bus.o \
1111
apl.o cnl.o
12+
snd-sof-intel-hda-common-$(CONFIG_SND_SOC_SOF_HDA_PROBES) += hda-compress.o
1213

1314
snd-sof-intel-hda-objs := hda-codec.o
1415

sound/soc/sof/intel/apl.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
7373
.pcm_trigger = hda_dsp_pcm_trigger,
7474
.pcm_pointer = hda_dsp_pcm_pointer,
7575

76+
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES)
77+
/* probe callbacks */
78+
.probe_assign = hda_probe_compr_assign,
79+
.probe_free = hda_probe_compr_free,
80+
.probe_set_params = hda_probe_compr_set_params,
81+
.probe_trigger = hda_probe_compr_trigger,
82+
.probe_pointer = hda_probe_compr_pointer,
83+
#endif
84+
7685
/* firmware loading */
7786
.load_firmware = snd_sof_load_firmware_raw,
7887

sound/soc/sof/intel/cnl.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,15 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
284284
.pcm_trigger = hda_dsp_pcm_trigger,
285285
.pcm_pointer = hda_dsp_pcm_pointer,
286286

287+
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES)
288+
/* probe callbacks */
289+
.probe_assign = hda_probe_compr_assign,
290+
.probe_free = hda_probe_compr_free,
291+
.probe_set_params = hda_probe_compr_set_params,
292+
.probe_trigger = hda_probe_compr_trigger,
293+
.probe_pointer = hda_probe_compr_pointer,
294+
#endif
295+
287296
/* firmware loading */
288297
.load_firmware = snd_sof_load_firmware_raw,
289298

sound/soc/sof/intel/hda-compress.c

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2+
//
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.
5+
//
6+
// Copyright(c) 2019-2020 Intel Corporation. All rights reserved.
7+
//
8+
// Author: Cezary Rojewski <[email protected]>
9+
//
10+
11+
#include <sound/hdaudio_ext.h>
12+
#include <sound/soc.h>
13+
#include "../sof-priv.h"
14+
#include "hda.h"
15+
16+
static inline struct hdac_ext_stream *
17+
hda_compr_get_stream(struct snd_compr_stream *cstream)
18+
{
19+
return cstream->runtime->private_data;
20+
}
21+
22+
int hda_probe_compr_assign(struct snd_sof_dev *sdev,
23+
struct snd_compr_stream *cstream,
24+
struct snd_soc_dai *dai)
25+
{
26+
struct hdac_ext_stream *stream;
27+
28+
stream = hda_dsp_stream_get(sdev, cstream->direction);
29+
if (!stream)
30+
return -EBUSY;
31+
32+
hdac_stream(stream)->curr_pos = 0;
33+
hdac_stream(stream)->cstream = cstream;
34+
cstream->runtime->private_data = stream;
35+
36+
return hdac_stream(stream)->stream_tag;
37+
}
38+
39+
int hda_probe_compr_free(struct snd_sof_dev *sdev,
40+
struct snd_compr_stream *cstream,
41+
struct snd_soc_dai *dai)
42+
{
43+
struct hdac_ext_stream *stream = hda_compr_get_stream(cstream);
44+
int ret;
45+
46+
ret = hda_dsp_stream_put(sdev, cstream->direction,
47+
hdac_stream(stream)->stream_tag);
48+
if (ret < 0) {
49+
dev_dbg(sdev->dev, "stream put failed: %d\n", ret);
50+
return ret;
51+
}
52+
53+
hdac_stream(stream)->cstream = NULL;
54+
cstream->runtime->private_data = NULL;
55+
56+
return 0;
57+
}
58+
59+
int hda_probe_compr_set_params(struct snd_sof_dev *sdev,
60+
struct snd_compr_stream *cstream,
61+
struct snd_compr_params *params,
62+
struct snd_soc_dai *dai)
63+
{
64+
struct hdac_ext_stream *stream = hda_compr_get_stream(cstream);
65+
struct hdac_stream *hstream = hdac_stream(stream);
66+
struct snd_dma_buffer *dmab;
67+
u32 bits, rate;
68+
int bps, ret;
69+
70+
dmab = cstream->runtime->dma_buffer_p;
71+
/* compr params do not store bit depth, default to S32_LE */
72+
bps = snd_pcm_format_physical_width(SNDRV_PCM_FORMAT_S32_LE);
73+
if (bps < 0)
74+
return bps;
75+
bits = hda_dsp_get_bits(sdev, bps);
76+
rate = hda_dsp_get_mult_div(sdev, params->codec.sample_rate);
77+
78+
hstream->format_val = rate | bits | (params->codec.ch_out - 1);
79+
hstream->bufsize = cstream->runtime->buffer_size;
80+
hstream->period_bytes = cstream->runtime->fragment_size;
81+
hstream->no_period_wakeup = 0;
82+
83+
ret = hda_dsp_stream_hw_params(sdev, stream, dmab, NULL);
84+
if (ret < 0) {
85+
dev_err(sdev->dev, "error: hdac prepare failed: %x\n", ret);
86+
return ret;
87+
}
88+
89+
return 0;
90+
}
91+
92+
int hda_probe_compr_trigger(struct snd_sof_dev *sdev,
93+
struct snd_compr_stream *cstream, int cmd,
94+
struct snd_soc_dai *dai)
95+
{
96+
struct hdac_ext_stream *stream = hda_compr_get_stream(cstream);
97+
98+
return hda_dsp_stream_trigger(sdev, stream, cmd);
99+
}
100+
101+
int hda_probe_compr_pointer(struct snd_sof_dev *sdev,
102+
struct snd_compr_stream *cstream,
103+
struct snd_compr_tstamp *tstamp,
104+
struct snd_soc_dai *dai)
105+
{
106+
struct hdac_ext_stream *stream = hda_compr_get_stream(cstream);
107+
struct snd_soc_pcm_stream *pstream;
108+
109+
pstream = &dai->driver->capture;
110+
tstamp->copied_total = hdac_stream(stream)->curr_pos;
111+
tstamp->sampling_rate = snd_pcm_rate_bit_to_rate(pstream->rates);
112+
113+
return 0;
114+
}

sound/soc/sof/intel/hda.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifndef __SOF_INTEL_HDA_H
1212
#define __SOF_INTEL_HDA_H
1313

14+
#include <sound/compress_driver.h>
1415
#include <sound/hda_codec.h>
1516
#include <sound/hdaudio_ext.h>
1617
#include "shim.h"
@@ -552,6 +553,29 @@ int hda_ipc_pcm_params(struct snd_sof_dev *sdev,
552553
struct snd_pcm_substream *substream,
553554
const struct sof_ipc_pcm_params_reply *reply);
554555

556+
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES)
557+
/*
558+
* Probe Compress Operations.
559+
*/
560+
int hda_probe_compr_assign(struct snd_sof_dev *sdev,
561+
struct snd_compr_stream *cstream,
562+
struct snd_soc_dai *dai);
563+
int hda_probe_compr_free(struct snd_sof_dev *sdev,
564+
struct snd_compr_stream *cstream,
565+
struct snd_soc_dai *dai);
566+
int hda_probe_compr_set_params(struct snd_sof_dev *sdev,
567+
struct snd_compr_stream *cstream,
568+
struct snd_compr_params *params,
569+
struct snd_soc_dai *dai);
570+
int hda_probe_compr_trigger(struct snd_sof_dev *sdev,
571+
struct snd_compr_stream *cstream, int cmd,
572+
struct snd_soc_dai *dai);
573+
int hda_probe_compr_pointer(struct snd_sof_dev *sdev,
574+
struct snd_compr_stream *cstream,
575+
struct snd_compr_tstamp *tstamp,
576+
struct snd_soc_dai *dai);
577+
#endif
578+
555579
/*
556580
* DSP IPC Operations.
557581
*/

0 commit comments

Comments
 (0)