@@ -93,6 +93,66 @@ static int pcm_convert_s32_to_u8(const struct audio_stream *source,
9393}
9494#endif /* CONFIG_PCM_CONVERTER_FORMAT_U8 && CONFIG_PCM_CONVERTER_FORMAT_S32LE */
9595
96+ #if CONFIG_PCM_CONVERTER_FORMAT_A_LAW && CONFIG_PCM_CONVERTER_FORMAT_S32LE
97+ static int pcm_convert_alaw_to_s32 (const struct audio_stream * source ,
98+ uint32_t ioffset , struct audio_stream * sink ,
99+ uint32_t ooffset , uint32_t samples , uint32_t chmap )
100+ {
101+ uint8_t * src = audio_stream_get_rptr (source );
102+ int32_t * dst = audio_stream_get_wptr (sink );
103+ uint32_t processed ;
104+ uint32_t nmax , i , n ;
105+
106+ src += ioffset ;
107+ dst += ooffset ;
108+ for (processed = 0 ; processed < samples ; processed += n ) {
109+ src = audio_stream_wrap (source , src );
110+ dst = audio_stream_wrap (sink , dst );
111+ n = samples - processed ;
112+ nmax = audio_stream_bytes_without_wrap (source , src ) >> BYTES_TO_U8_SAMPLES ;
113+ n = MIN (n , nmax );
114+ nmax = audio_stream_bytes_without_wrap (sink , dst ) >> BYTES_TO_S32_SAMPLES ;
115+ n = MIN (n , nmax );
116+ for (i = 0 ; i < n ; i ++ ) {
117+ * dst = (INT8_MIN + * src ) << 24 ;
118+ src ++ ;
119+ dst ++ ;
120+ }
121+ }
122+
123+ return samples ;
124+ }
125+
126+ static int pcm_convert_s32_to_alaw (const struct audio_stream * source ,
127+ uint32_t ioffset , struct audio_stream * sink ,
128+ uint32_t ooffset , uint32_t samples , uint32_t chmap )
129+ {
130+ int32_t * src = audio_stream_get_rptr (source );
131+ uint8_t * dst = audio_stream_get_wptr (sink );
132+ uint32_t processed ;
133+ uint32_t nmax , i , n ;
134+
135+ src += ioffset ;
136+ dst += ooffset ;
137+ for (processed = 0 ; processed < samples ; processed += n ) {
138+ src = audio_stream_wrap (source , src );
139+ dst = audio_stream_wrap (sink , dst );
140+ n = samples - processed ;
141+ nmax = audio_stream_bytes_without_wrap (source , src ) >> BYTES_TO_S32_SAMPLES ;
142+ n = MIN (n , nmax );
143+ nmax = audio_stream_bytes_without_wrap (sink , dst ) >> BYTES_TO_U8_SAMPLES ;
144+ n = MIN (n , nmax );
145+ for (i = 0 ; i < n ; i ++ ) {
146+ * dst = sat_int8 (Q_SHIFT_RND (* src , 24 , 0 )) - INT8_MIN ;
147+ src ++ ;
148+ dst ++ ;
149+ }
150+ }
151+
152+ return samples ;
153+ }
154+ #endif /* CONFIG_PCM_CONVERTER_FORMAT_U8 && CONFIG_PCM_CONVERTER_FORMAT_S32LE */
155+
96156#if CONFIG_PCM_CONVERTER_FORMAT_S16LE && CONFIG_PCM_CONVERTER_FORMAT_S24LE
97157
98158static int pcm_convert_s16_to_s24 (const struct audio_stream * source ,
@@ -555,6 +615,13 @@ const struct pcm_func_map pcm_func_map[] = {
555615 { SOF_IPC_FRAME_U8 , SOF_IPC_FRAME_S32_LE , pcm_convert_u8_to_s32 },
556616 { SOF_IPC_FRAME_S32_LE , SOF_IPC_FRAME_U8 , pcm_convert_s32_to_u8 },
557617#endif /* CONFIG_PCM_CONVERTER_FORMAT_U8 && CONFIG_PCM_CONVERTER_FORMAT_S32LE */
618+ #if CONFIG_PCM_CONVERTER_FORMAT_A_LAW
619+ { SOF_IPC_FRAME_A_LAW , SOF_IPC_FRAME_A_LAW , just_copy },
620+ #endif /* CONFIG_PCM_CONVERTER_FORMAT_A_LAW */
621+ #if CONFIG_PCM_CONVERTER_FORMAT_A_LAW && CONFIG_PCM_CONVERTER_FORMAT_S32LE
622+ { SOF_IPC_FRAME_A_LAW , SOF_IPC_FRAME_S32_LE , pcm_convert_alaw_to_s32 },
623+ { SOF_IPC_FRAME_S32_LE , SOF_IPC_FRAME_A_LAW , pcm_convert_s32_to_alaw },
624+ #endif /* CONFIG_PCM_CONVERTER_FORMAT_A_LAW && CONFIG_PCM_CONVERTER_FORMAT_S32LE */
558625#if CONFIG_PCM_CONVERTER_FORMAT_S16LE
559626 { SOF_IPC_FRAME_S16_LE , SOF_IPC_FRAME_S16_LE , just_copy },
560627#endif /* CONFIG_PCM_CONVERTER_FORMAT_S16LE */
0 commit comments