Skip to content

Commit 9c50bec

Browse files
committed
copier: check gateway type for converter function
Adjust sample type based on hw feature. It only affects s24/c32 patterns since the valid 24bits sample can be in LSB or MSB part of 32 bits container. We don't support other patterns like s16/c32 now since they are rarely used by gateway and can be added if they are used. Signed-off-by: Rander Wang <rander.wang@intel.com>
1 parent 6f1ef82 commit 9c50bec

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

src/audio/copier/copier_generic.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,46 @@ pcm_converter_func get_converter_func(const struct ipc4_audio_format *in_fmt,
280280
enum ipc4_direction_type dir)
281281
{
282282
enum sof_ipc_frame in, in_valid, out, out_valid;
283+
enum ipc4_sample_type in_type;
284+
enum ipc4_sample_type out_type;
285+
286+
in_type = in_fmt->s_type;
287+
out_type = out_fmt->s_type;
288+
289+
/* Different gateway has different sample layout requirement
290+
* (1) hda host gateway: 24 bit sample will be in lsb bits
291+
* (2) hda link gateway: 24le sample should be converted to msb 24bits format
292+
* (3) alh gateway: all data format layout should be in msb format in 32bit container,
293+
* .e.g. 24le stream should be convert to msb 24bits one
294+
*
295+
* valid sample format of S16_LE or S32_LE are not affected by sample type
296+
*/
297+
switch (type) {
298+
case ipc4_gtw_host:
299+
if (dir == ipc4_playback && in_fmt->depth == 32 &&
300+
in_fmt->valid_bit_depth == 24)
301+
in_type = IPC4_TYPE_LSB_INTEGER;
302+
else if (dir == ipc4_capture && out_fmt->depth == 32 &&
303+
out_fmt->valid_bit_depth == 24)
304+
out_type = IPC4_TYPE_LSB_INTEGER;
305+
break;
306+
case ipc4_gtw_alh:
307+
case ipc4_gtw_link:
308+
if (dir == ipc4_playback && out_fmt->depth == 32 &&
309+
out_fmt->valid_bit_depth == 24)
310+
out_type = IPC4_TYPE_MSB_INTEGER;
311+
else if (dir == ipc4_capture && in_fmt->depth == 32 &&
312+
in_fmt->valid_bit_depth == 24)
313+
in_type = IPC4_TYPE_MSB_INTEGER;
314+
break;
315+
default:
316+
break;
317+
}
283318

284319
audio_stream_fmt_conversion(in_fmt->depth, in_fmt->valid_bit_depth, &in, &in_valid,
285-
in_fmt->s_type);
320+
in_type);
286321
audio_stream_fmt_conversion(out_fmt->depth, out_fmt->valid_bit_depth, &out, &out_valid,
287-
out_fmt->s_type);
322+
out_type);
288323

289324
/* check container & sample size */
290325
if (use_no_container_convert_function(in, in_valid, out, out_valid))

0 commit comments

Comments
 (0)