@@ -37,6 +37,22 @@ struct sof_ipc4_timestamp_info {
37
37
snd_pcm_sframes_t delay ;
38
38
};
39
39
40
+ /**
41
+ * struct sof_ipc4_pcm_stream_priv - IPC4 specific private data
42
+ * @time_info: pointer to time info struct if it is supported, otherwise NULL
43
+ */
44
+ struct sof_ipc4_pcm_stream_priv {
45
+ struct sof_ipc4_timestamp_info * time_info ;
46
+ };
47
+
48
+ static inline struct sof_ipc4_timestamp_info *
49
+ sof_ipc4_sps_to_time_info (struct snd_sof_pcm_stream * sps )
50
+ {
51
+ struct sof_ipc4_pcm_stream_priv * stream_priv = sps -> private ;
52
+
53
+ return stream_priv -> time_info ;
54
+ }
55
+
40
56
static int sof_ipc4_set_multi_pipeline_state (struct snd_sof_dev * sdev , u32 state ,
41
57
struct ipc4_pipeline_set_state_data * trigger_list )
42
58
{
@@ -452,7 +468,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
452
468
* Invalidate the stream_start_offset to make sure that it is
453
469
* going to be updated if the stream resumes
454
470
*/
455
- time_info = spcm -> stream [substream -> stream ]. private ;
471
+ time_info = sof_ipc4_sps_to_time_info ( & spcm -> stream [substream -> stream ]) ;
456
472
if (time_info )
457
473
time_info -> stream_start_offset = SOF_IPC4_INVALID_STREAM_POSITION ;
458
474
@@ -706,12 +722,16 @@ static int sof_ipc4_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
706
722
static void sof_ipc4_pcm_free (struct snd_sof_dev * sdev , struct snd_sof_pcm * spcm )
707
723
{
708
724
struct snd_sof_pcm_stream_pipeline_list * pipeline_list ;
725
+ struct sof_ipc4_pcm_stream_priv * stream_priv ;
709
726
int stream ;
710
727
711
728
for_each_pcm_streams (stream ) {
712
729
pipeline_list = & spcm -> stream [stream ].pipeline_list ;
713
730
kfree (pipeline_list -> pipelines );
714
731
pipeline_list -> pipelines = NULL ;
732
+
733
+ stream_priv = spcm -> stream [stream ].private ;
734
+ kfree (stream_priv -> time_info );
715
735
kfree (spcm -> stream [stream ].private );
716
736
spcm -> stream [stream ].private = NULL ;
717
737
}
@@ -721,6 +741,7 @@ static int sof_ipc4_pcm_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm
721
741
{
722
742
struct snd_sof_pcm_stream_pipeline_list * pipeline_list ;
723
743
struct sof_ipc4_fw_data * ipc4_data = sdev -> private ;
744
+ struct sof_ipc4_pcm_stream_priv * stream_priv ;
724
745
struct sof_ipc4_timestamp_info * time_info ;
725
746
bool support_info = true;
726
747
u32 abi_version ;
@@ -749,6 +770,14 @@ static int sof_ipc4_pcm_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm
749
770
return - ENOMEM ;
750
771
}
751
772
773
+ stream_priv = kzalloc (sizeof (* stream_priv ), GFP_KERNEL );
774
+ if (!stream_priv ) {
775
+ sof_ipc4_pcm_free (sdev , spcm );
776
+ return - ENOMEM ;
777
+ }
778
+
779
+ spcm -> stream [stream ].private = stream_priv ;
780
+
752
781
if (!support_info )
753
782
continue ;
754
783
@@ -758,7 +787,7 @@ static int sof_ipc4_pcm_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm
758
787
return - ENOMEM ;
759
788
}
760
789
761
- spcm -> stream [ stream ]. private = time_info ;
790
+ stream_priv -> time_info = time_info ;
762
791
}
763
792
764
793
return 0 ;
@@ -795,7 +824,7 @@ static void sof_ipc4_build_time_info(struct snd_sof_dev *sdev, struct snd_sof_pc
795
824
return ;
796
825
}
797
826
798
- time_info = sps -> private ;
827
+ time_info = sof_ipc4_sps_to_time_info ( sps ) ;
799
828
time_info -> host_copier = host_copier ;
800
829
time_info -> dai_copier = dai_copier ;
801
830
time_info -> llp_offset = offsetof(struct sof_ipc4_fw_registers ,
@@ -849,7 +878,7 @@ static int sof_ipc4_pcm_hw_params(struct snd_soc_component *component,
849
878
if (!spcm )
850
879
return - EINVAL ;
851
880
852
- time_info = spcm -> stream [substream -> stream ]. private ;
881
+ time_info = sof_ipc4_sps_to_time_info ( & spcm -> stream [substream -> stream ]) ;
853
882
/* delay calculation is not supported by current fw_reg ABI */
854
883
if (!time_info )
855
884
return 0 ;
@@ -928,7 +957,7 @@ static int sof_ipc4_pcm_pointer(struct snd_soc_component *component,
928
957
return - EOPNOTSUPP ;
929
958
930
959
sps = & spcm -> stream [substream -> stream ];
931
- time_info = sps -> private ;
960
+ time_info = sof_ipc4_sps_to_time_info ( sps ) ;
932
961
if (!time_info )
933
962
return - EOPNOTSUPP ;
934
963
@@ -1030,15 +1059,13 @@ static snd_pcm_sframes_t sof_ipc4_pcm_delay(struct snd_soc_component *component,
1030
1059
{
1031
1060
struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
1032
1061
struct sof_ipc4_timestamp_info * time_info ;
1033
- struct snd_sof_pcm_stream * sps ;
1034
1062
struct snd_sof_pcm * spcm ;
1035
1063
1036
1064
spcm = snd_sof_find_spcm_dai (component , rtd );
1037
1065
if (!spcm )
1038
1066
return 0 ;
1039
1067
1040
- sps = & spcm -> stream [substream -> stream ];
1041
- time_info = sps -> private ;
1068
+ time_info = sof_ipc4_sps_to_time_info (& spcm -> stream [substream -> stream ]);
1042
1069
/*
1043
1070
* Report the stored delay value calculated in the pointer callback.
1044
1071
* In the unlikely event that the calculation was skipped/aborted, the
0 commit comments