Skip to content

Commit d56fed2

Browse files
committed
ASoC: SOF: ipc4-pcm: Make the timestamp info usable outside of ipc4-pcm.c
The support for compressed stream will also need to have access to the same information which is used for delay reporting for DAI data progression tracking. Make the necessary struct and functions to be available and premare them to be called without a valid substream. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 21a4e7f commit d56fed2

2 files changed

Lines changed: 40 additions & 31 deletions

File tree

sound/soc/sof/ipc4-pcm.c

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,6 @@
1515
#include "ipc4-topology.h"
1616
#include "ipc4-fw-reg.h"
1717

18-
/**
19-
* struct sof_ipc4_timestamp_info - IPC4 timestamp info
20-
* @host_copier: the host copier of the pcm stream
21-
* @dai_copier: the dai copier of the pcm stream
22-
* @stream_start_offset: reported by fw in memory window (converted to
23-
* frames at host_copier sampling rate)
24-
* @stream_end_offset: reported by fw in memory window (converted to
25-
* frames at host_copier sampling rate)
26-
* @llp_offset: llp offset in memory window
27-
* @delay: Calculated and stored in pointer callback. The stored value is
28-
* returned in the delay callback. Expressed in frames at host copier
29-
* sampling rate.
30-
*/
31-
struct sof_ipc4_timestamp_info {
32-
struct sof_ipc4_copier *host_copier;
33-
struct sof_ipc4_copier *dai_copier;
34-
u64 stream_start_offset;
35-
u64 stream_end_offset;
36-
u32 llp_offset;
37-
38-
snd_pcm_sframes_t delay;
39-
};
40-
4118
/**
4219
* struct sof_ipc4_pcm_stream_priv - IPC4 specific private data
4320
* @time_info: pointer to time info struct if it is supported, otherwise NULL
@@ -61,7 +38,7 @@ struct sof_ipc4_pcm_stream_priv {
6138

6239
#define DELAY_MAX (DELAY_BOUNDARY >> 1)
6340

64-
static inline struct sof_ipc4_timestamp_info *
41+
struct sof_ipc4_timestamp_info *
6542
sof_ipc4_sps_to_time_info(struct snd_sof_pcm_stream *sps)
6643
{
6744
struct sof_ipc4_pcm_stream_priv *stream_priv = sps->private;
@@ -964,7 +941,7 @@ static int sof_ipc4_pcm_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm
964941
return 0;
965942
}
966943

967-
static void sof_ipc4_build_time_info(struct snd_sof_dev *sdev, struct snd_sof_pcm_stream *sps)
944+
void sof_ipc4_build_time_info(struct snd_sof_dev *sdev, struct snd_sof_pcm_stream *sps)
968945
{
969946
struct sof_ipc4_copier *host_copier = NULL;
970947
struct sof_ipc4_copier *dai_copier = NULL;
@@ -1062,7 +1039,7 @@ static int sof_ipc4_pcm_hw_params(struct snd_soc_component *component,
10621039
return 0;
10631040
}
10641041

1065-
static u64 sof_ipc4_frames_dai_to_host(struct sof_ipc4_timestamp_info *time_info, u64 value)
1042+
u64 sof_ipc4_frames_dai_to_host(struct sof_ipc4_timestamp_info *time_info, u64 value)
10661043
{
10671044
u64 dai_rate, host_rate;
10681045

@@ -1091,10 +1068,10 @@ static u64 sof_ipc4_frames_dai_to_host(struct sof_ipc4_timestamp_info *time_info
10911068
return value;
10921069
}
10931070

1094-
static int sof_ipc4_get_stream_start_offset(struct snd_sof_dev *sdev,
1095-
struct snd_pcm_substream *substream,
1096-
struct snd_sof_pcm_stream *sps,
1097-
struct sof_ipc4_timestamp_info *time_info)
1071+
int sof_ipc4_get_stream_start_offset(struct snd_sof_dev *sdev,
1072+
struct snd_pcm_substream *substream,
1073+
struct snd_sof_pcm_stream *sps,
1074+
struct sof_ipc4_timestamp_info *time_info)
10981075
{
10991076
struct sof_ipc4_copier *host_copier = time_info->host_copier;
11001077
struct sof_ipc4_copier *dai_copier = time_info->dai_copier;
@@ -1108,7 +1085,8 @@ static int sof_ipc4_get_stream_start_offset(struct snd_sof_dev *sdev,
11081085

11091086
if (host_copier->data.gtw_cfg.node_id == SOF_IPC4_INVALID_NODE_ID) {
11101087
return -EINVAL;
1111-
} else if (host_copier->data.gtw_cfg.node_id == SOF_IPC4_CHAIN_DMA_NODE_ID) {
1088+
} else if (substream &&
1089+
host_copier->data.gtw_cfg.node_id == SOF_IPC4_CHAIN_DMA_NODE_ID) {
11121090
/*
11131091
* While the firmware does not support time_info reporting for
11141092
* streams using ChainDMA, it is granted that ChainDMA can only

sound/soc/sof/ipc4-priv.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,29 @@ struct sof_ipc4_fw_data {
9898
struct mutex pipeline_state_mutex; /* protect pipeline triggers, ref counts and states */
9999
};
100100

101+
/**
102+
* struct sof_ipc4_timestamp_info - IPC4 timestamp info
103+
* @host_copier: the host copier of the pcm stream
104+
* @dai_copier: the dai copier of the pcm stream
105+
* @stream_start_offset: reported by fw in memory window (converted to
106+
* frames at host_copier sampling rate)
107+
* @stream_end_offset: reported by fw in memory window (converted to
108+
* frames at host_copier sampling rate)
109+
* @llp_offset: llp offset in memory window
110+
* @delay: Calculated and stored in pointer callback. The stored value is
111+
* returned in the delay callback. Expressed in frames at host copier
112+
* sampling rate.
113+
*/
114+
struct sof_ipc4_timestamp_info {
115+
struct sof_ipc4_copier *host_copier;
116+
struct sof_ipc4_copier *dai_copier;
117+
u64 stream_start_offset;
118+
u64 stream_end_offset;
119+
u32 llp_offset;
120+
121+
snd_pcm_sframes_t delay;
122+
};
123+
101124
extern const struct sof_ipc_fw_loader_ops ipc4_loader_ops;
102125
extern const struct sof_ipc_tplg_ops ipc4_tplg_ops;
103126
extern const struct sof_ipc_tplg_control_ops tplg_ipc4_control_ops;
@@ -129,4 +152,12 @@ void sof_ipc4_mic_privacy_state_change(struct snd_sof_dev *sdev, bool state);
129152
enum sof_ipc4_pipeline_state;
130153
const char *sof_ipc4_pipeline_state_str(enum sof_ipc4_pipeline_state state);
131154

155+
struct sof_ipc4_timestamp_info *sof_ipc4_sps_to_time_info(struct snd_sof_pcm_stream *sps);
156+
void sof_ipc4_build_time_info(struct snd_sof_dev *sdev, struct snd_sof_pcm_stream *sps);
157+
int sof_ipc4_get_stream_start_offset(struct snd_sof_dev *sdev,
158+
struct snd_pcm_substream *substream,
159+
struct snd_sof_pcm_stream *sps,
160+
struct sof_ipc4_timestamp_info *time_info);
161+
u64 sof_ipc4_frames_dai_to_host(struct sof_ipc4_timestamp_info *time_info, u64 value);
162+
132163
#endif

0 commit comments

Comments
 (0)