Skip to content

Commit 6b85309

Browse files
committed
ASoC: SOF: Intel: add hda_dsp_stream_pair_get/put helpers
Currently, hda_dsp_stream_get/put are used to get/put the host dma. However, we may want to use a hda stream that both host and link dma are available. Add helper to find the hda stream and reserve/release it. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent 45e07ee commit 6b85309

2 files changed

Lines changed: 41 additions & 3 deletions

File tree

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

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
210210
}
211211

212212
/* get next unused stream */
213-
struct hdac_ext_stream *
214-
hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags)
213+
static struct hdac_ext_stream *
214+
_hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags, bool pair)
215215
{
216216
const struct sof_intel_dsp_desc *chip_info = get_chip_info(sdev->pdata);
217217
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
@@ -233,7 +233,14 @@ hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags)
233233
if (hda_stream->host_reserved)
234234
continue;
235235

236+
if (pair && hext_stream->link_locked)
237+
continue;
238+
236239
s->opened = true;
240+
241+
if (pair)
242+
hext_stream->link_locked = true;
243+
237244
break;
238245
}
239246
}
@@ -264,14 +271,27 @@ hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags)
264271
return hext_stream;
265272
}
266273

274+
struct hdac_ext_stream *
275+
hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags)
276+
{
277+
return _hda_dsp_stream_get(sdev, direction, flags, false);
278+
}
279+
280+
struct hdac_ext_stream *
281+
hda_dsp_stream_pair_get(struct snd_sof_dev *sdev, int direction, u32 flags)
282+
{
283+
return _hda_dsp_stream_get(sdev, direction, flags, true);
284+
}
285+
267286
/* free a stream */
268-
int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag)
287+
static int _hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag, bool pair)
269288
{
270289
const struct sof_intel_dsp_desc *chip_info = get_chip_info(sdev->pdata);
271290
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
272291
struct hdac_bus *bus = sof_to_bus(sdev);
273292
struct sof_intel_hda_stream *hda_stream;
274293
struct hdac_ext_stream *hext_stream;
294+
struct hdac_ext_stream *link_stream;
275295
struct hdac_stream *s;
276296
bool dmi_l1_enable = true;
277297
bool found = false;
@@ -292,6 +312,8 @@ int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag)
292312
if (s->direction == direction && s->stream_tag == stream_tag) {
293313
s->opened = false;
294314
found = true;
315+
if (pair)
316+
link_stream = hext_stream;
295317
} else if (!(hda_stream->flags & SOF_HDA_STREAM_DMI_L1_COMPATIBLE)) {
296318
dmi_l1_enable = false;
297319
}
@@ -312,9 +334,22 @@ int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag)
312334
return -ENODEV;
313335
}
314336

337+
if (pair)
338+
snd_hdac_ext_stream_release(link_stream, HDAC_EXT_STREAM_TYPE_LINK);
339+
315340
return 0;
316341
}
317342

343+
int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag)
344+
{
345+
return _hda_dsp_stream_put(sdev, direction, stream_tag, false);
346+
}
347+
348+
int hda_dsp_stream_pair_put(struct snd_sof_dev *sdev, int direction, int stream_tag)
349+
{
350+
return _hda_dsp_stream_put(sdev, direction, stream_tag, true);
351+
}
352+
318353
static int hda_dsp_stream_reset(struct snd_sof_dev *sdev, struct hdac_stream *hstream)
319354
{
320355
int sd_offset = SOF_STREAM_SD_OFFSET(hstream);

sound/soc/sof/intel/hda.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,10 @@ u64 hda_dsp_get_stream_ldp(struct snd_sof_dev *sdev,
694694

695695
struct hdac_ext_stream *
696696
hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags);
697+
struct hdac_ext_stream *
698+
hda_dsp_stream_pair_get(struct snd_sof_dev *sdev, int direction, u32 flags);
697699
int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag);
700+
int hda_dsp_stream_pair_put(struct snd_sof_dev *sdev, int direction, int stream_tag);
698701
int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
699702
struct hdac_ext_stream *hext_stream,
700703
int enable, u32 size);

0 commit comments

Comments
 (0)