@@ -95,6 +95,66 @@ static int pcm_convert_s32_to_u8(const struct audio_stream *source,
9595}
9696#endif /* CONFIG_PCM_CONVERTER_FORMAT_U8 && CONFIG_PCM_CONVERTER_FORMAT_S32LE */
9797
98+ #if CONFIG_PCM_CONVERTER_FORMAT_S8 && CONFIG_PCM_CONVERTER_FORMAT_S32LE
99+ static int pcm_convert_s8_to_s32 (const struct audio_stream * source ,
100+ uint32_t ioffset , struct audio_stream * sink ,
101+ uint32_t ooffset , uint32_t samples , uint32_t chmap )
102+ {
103+ int8_t * src = audio_stream_get_rptr (source );
104+ int32_t * dst = audio_stream_get_wptr (sink );
105+ uint32_t processed ;
106+ uint32_t nmax , i , n ;
107+
108+ src += ioffset ;
109+ dst += ooffset ;
110+ for (processed = 0 ; processed < samples ; processed += n ) {
111+ src = audio_stream_wrap (source , src );
112+ dst = audio_stream_wrap (sink , dst );
113+ n = samples - processed ;
114+ nmax = audio_stream_bytes_without_wrap (source , src ) >> BYTES_TO_U8_SAMPLES ;
115+ n = MIN (n , nmax );
116+ nmax = audio_stream_bytes_without_wrap (sink , dst ) >> BYTES_TO_S32_SAMPLES ;
117+ n = MIN (n , nmax );
118+ for (i = 0 ; i < n ; i ++ ) {
119+ * dst = * src << 24 ;
120+ src ++ ;
121+ dst ++ ;
122+ }
123+ }
124+
125+ return samples ;
126+ }
127+
128+ static int pcm_convert_s32_to_s8 (const struct audio_stream * source ,
129+ uint32_t ioffset , struct audio_stream * sink ,
130+ uint32_t ooffset , uint32_t samples , uint32_t chmap )
131+ {
132+ int32_t * src = audio_stream_get_rptr (source );
133+ int8_t * dst = audio_stream_get_wptr (sink );
134+ uint32_t processed ;
135+ uint32_t nmax , i , n ;
136+
137+ src += ioffset ;
138+ dst += ooffset ;
139+ for (processed = 0 ; processed < samples ; processed += n ) {
140+ src = audio_stream_wrap (source , src );
141+ dst = audio_stream_wrap (sink , dst );
142+ n = samples - processed ;
143+ nmax = audio_stream_bytes_without_wrap (source , src ) >> BYTES_TO_S32_SAMPLES ;
144+ n = MIN (n , nmax );
145+ nmax = audio_stream_bytes_without_wrap (sink , dst ) >> BYTES_TO_U8_SAMPLES ;
146+ n = MIN (n , nmax );
147+ for (i = 0 ; i < n ; i ++ ) {
148+ * dst = sat_int8 (Q_SHIFT_RND (* src , 24 , 0 ));
149+ src ++ ;
150+ dst ++ ;
151+ }
152+ }
153+
154+ return samples ;
155+ }
156+ #endif /* CONFIG_PCM_CONVERTER_FORMAT_S8 && CONFIG_PCM_CONVERTER_FORMAT_S32LE */
157+
98158#if CONFIG_PCM_CONVERTER_FORMAT_A_LAW && CONFIG_PCM_CONVERTER_FORMAT_S32LE
99159static int pcm_convert_alaw_to_s32 (const struct audio_stream * source ,
100160 uint32_t ioffset , struct audio_stream * sink ,
@@ -677,6 +737,13 @@ const struct pcm_func_map pcm_func_map[] = {
677737 { SOF_IPC_FRAME_U8 , SOF_IPC_FRAME_S32_LE , pcm_convert_u8_to_s32 },
678738 { SOF_IPC_FRAME_S32_LE , SOF_IPC_FRAME_U8 , pcm_convert_s32_to_u8 },
679739#endif /* CONFIG_PCM_CONVERTER_FORMAT_U8 && CONFIG_PCM_CONVERTER_FORMAT_S32LE */
740+ #if CONFIG_PCM_CONVERTER_FORMAT_S8
741+ { SOF_IPC_FRAME_S8 , SOF_IPC_FRAME_S8 , just_copy },
742+ #endif /* CONFIG_PCM_CONVERTER_FORMAT_S8 */
743+ #if CONFIG_PCM_CONVERTER_FORMAT_S8 && CONFIG_PCM_CONVERTER_FORMAT_S32LE
744+ { SOF_IPC_FRAME_S8 , SOF_IPC_FRAME_S32_LE , pcm_convert_s8_to_s32 },
745+ { SOF_IPC_FRAME_S32_LE , SOF_IPC_FRAME_S8 , pcm_convert_s32_to_s8 },
746+ #endif /* CONFIG_PCM_CONVERTER_FORMAT_S8 && CONFIG_PCM_CONVERTER_FORMAT_S32LE */
680747#if CONFIG_PCM_CONVERTER_FORMAT_A_LAW
681748 { SOF_IPC_FRAME_A_LAW , SOF_IPC_FRAME_A_LAW , just_copy },
682749#endif /* CONFIG_PCM_CONVERTER_FORMAT_A_LAW */
0 commit comments