Commit | Line | Data |
---|---|---|
e149ca29 | 1 | // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) |
ba00ed75 LG |
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) 2018 Intel Corporation. All rights reserved. | |
7 | // | |
8 | // Authors: Liam Girdwood <liam.r.girdwood@linux.intel.com> | |
9 | // Ranjani Sridharan <ranjani.sridharan@linux.intel.com> | |
10 | // Rander Wang <rander.wang@intel.com> | |
11 | // Keyon Jie <yang.jie@linux.intel.com> | |
12 | // | |
13 | ||
14 | /* | |
15 | * Hardware interface for generic Intel audio DSP HDA IP | |
16 | */ | |
17 | ||
18 | #include <sound/hdaudio_ext.h> | |
19 | #include "../ops.h" | |
20 | #include "hda.h" | |
21 | ||
91e716b2 | 22 | static int hda_dsp_trace_prepare(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab) |
ba00ed75 LG |
23 | { |
24 | struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; | |
7d88b960 PLB |
25 | struct hdac_ext_stream *hext_stream = hda->dtrace_stream; |
26 | struct hdac_stream *hstream = &hext_stream->hstream; | |
ba00ed75 LG |
27 | int ret; |
28 | ||
29 | hstream->period_bytes = 0;/* initialize period_bytes */ | |
91e716b2 | 30 | hstream->bufsize = dmab->bytes; |
ba00ed75 | 31 | |
7d88b960 | 32 | ret = hda_dsp_stream_hw_params(sdev, hext_stream, dmab, NULL); |
ba00ed75 | 33 | if (ret < 0) |
ce1f55ba | 34 | dev_err(sdev->dev, "error: hdac prepare failed: %d\n", ret); |
ba00ed75 LG |
35 | |
36 | return ret; | |
37 | } | |
38 | ||
bab05b50 PU |
39 | int hda_dsp_trace_init(struct snd_sof_dev *sdev, |
40 | struct sof_ipc_dma_trace_params_ext *dtrace_params) | |
ba00ed75 LG |
41 | { |
42 | struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; | |
43 | int ret; | |
44 | ||
6e021076 RS |
45 | hda->dtrace_stream = hda_dsp_stream_get(sdev, SNDRV_PCM_STREAM_CAPTURE, |
46 | SOF_HDA_STREAM_DMI_L1_COMPATIBLE); | |
ba00ed75 LG |
47 | |
48 | if (!hda->dtrace_stream) { | |
49 | dev_err(sdev->dev, | |
50 | "error: no available capture stream for DMA trace\n"); | |
51 | return -ENODEV; | |
52 | } | |
53 | ||
bab05b50 | 54 | dtrace_params->stream_tag = hda->dtrace_stream->hstream.stream_tag; |
ba00ed75 LG |
55 | |
56 | /* | |
57 | * initialize capture stream, set BDL address and return corresponding | |
58 | * stream tag which will be sent to the firmware by IPC message. | |
59 | */ | |
91e716b2 | 60 | ret = hda_dsp_trace_prepare(sdev, &sdev->dmatb); |
ba00ed75 | 61 | if (ret < 0) { |
ce1f55ba | 62 | dev_err(sdev->dev, "error: hdac trace init failed: %d\n", ret); |
bab05b50 PU |
63 | hda_dsp_stream_put(sdev, SNDRV_PCM_STREAM_CAPTURE, |
64 | dtrace_params->stream_tag); | |
ba00ed75 | 65 | hda->dtrace_stream = NULL; |
bab05b50 | 66 | dtrace_params->stream_tag = 0; |
ba00ed75 LG |
67 | } |
68 | ||
69 | return ret; | |
70 | } | |
71 | ||
72 | int hda_dsp_trace_release(struct snd_sof_dev *sdev) | |
73 | { | |
74 | struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; | |
75 | struct hdac_stream *hstream; | |
76 | ||
77 | if (hda->dtrace_stream) { | |
78 | hstream = &hda->dtrace_stream->hstream; | |
79 | hda_dsp_stream_put(sdev, | |
80 | SNDRV_PCM_STREAM_CAPTURE, | |
81 | hstream->stream_tag); | |
82 | hda->dtrace_stream = NULL; | |
83 | return 0; | |
84 | } | |
85 | ||
86 | dev_dbg(sdev->dev, "DMA trace stream is not opened!\n"); | |
87 | return -ENODEV; | |
88 | } | |
89 | ||
90 | int hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd) | |
91 | { | |
92 | struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; | |
93 | ||
94 | return hda_dsp_stream_trigger(sdev, hda->dtrace_stream, cmd); | |
95 | } |