1 // SPDX-License-Identifier: MIT
3 * Copyright (C) 2019 NVIDIA Corporation
8 #include <sound/hda_verbs.h>
12 void tegra_hda_parse_format(unsigned int format
, struct tegra_hda_format
*fmt
)
14 unsigned int mul
, div
, bits
, channels
;
16 if (format
& AC_FMT_TYPE_NON_PCM
)
21 if (format
& AC_FMT_BASE_44K
)
22 fmt
->sample_rate
= 44100;
24 fmt
->sample_rate
= 48000;
26 mul
= (format
& AC_FMT_MULT_MASK
) >> AC_FMT_MULT_SHIFT
;
27 div
= (format
& AC_FMT_DIV_MASK
) >> AC_FMT_DIV_SHIFT
;
29 fmt
->sample_rate
*= (mul
+ 1) / (div
+ 1);
31 switch (format
& AC_FMT_BITS_MASK
) {
53 bits
= (format
& AC_FMT_BITS_MASK
) >> AC_FMT_BITS_SHIFT
;
54 WARN(1, "invalid number of bits: %#x\n", bits
);
59 channels
= (format
& AC_FMT_CHAN_MASK
) >> AC_FMT_CHAN_SHIFT
;
61 /* channels are encoded as n - 1 */
62 fmt
->channels
= channels
+ 1;