ALSA/ASoC: hda: Address format selection limitations and ambiguity
Subsystems (4)
Cezary Rojewski
maintainercover ALSA/ASoC: hda: Address format selection limitations and ambiguity
Patchset aims to address format selection restrictions present currently in the HDAudio library. Formats which we are concerned about are 20 and 24 valid bits per sample within 32 bit depth container. One may identify them as S20_LE and S24_LE except that those, according to comments found in include/uapi/sound/asound.h, are for LSB-aligned scenarios. HDAudio streams expect MSB-aligned data, no matter if we are speaking of HOST (SDxFMT) or LINK (PPLCxFMT) side - chapter 4.5.1 of the public HDAudio specification. In short, S20_LE and S24_LE are invalid options.
Right now, given the implementation of snd_hdac_query_supported_pcm() within sound/hda/hdac_device.c, even if a codec responds with: "I support all possible formats specified within HDAudio specification", there will be no option to open a 20/32 or 24/32 stream. The kernel will force the stream to be opened using the highest available bit depth.
After discussing subject initially with Jaroslav and Takashi, suggestion was made to utilize 'subformat' option to address the problem. The eye-opening discussion begun much earlier though, in 2019 [1].
Paired with PRs for alsa-utils [2] and alsa-lib [3].
Flow of changes:
The very first patch adds MSBITS subformat options to allow for granular 20/32, 24/32 and 32/32 format selection. The next three make sure subformat is actually honored during runtime. Most of that code is based on format-related API.
Follow up is upgrade to the hda stream-format interface - several functions are added to make the granular format selection simple in the HDAudio world. Core of the implementation is based on the existing snd_hdac_calc_stream_format(). The next ten patches are straightforward switch from one interface to another with cleanup of now-unsed function as a finishing touch.
Last but not least - the avs-driver, on which the problem analyzed and debugged, is updated to no longer acknowledge S24_LE as a valid format option.
Results with skylake-driver and snd_hda_intel show status quo on our RVPs. PR filed on SOF github shows promissing results too [4].
Changes in v1:
- fixed UBSAN due to missing snd_pcm_subformat_names[] entries for new subformats
- as HDMI stream capabilities are assigned on PCM open, patch 16/17 has been updated to ignore such codecs for now. A separate patchset will take care of this case
- params_bps() reworded to snd_pcm_hw_params_bps()
- fixed compilation issues in sof-driver, patch 13/17
[1]: https://lore.kernel.org/alsa-devel/[email protected]/
[2]: https://github.com/alsa-project/alsa-utils/pull/228
[3]: https://github.com/alsa-project/alsa-lib/pull/342
[4]: https://github.com/thesofproject/linux/pull/4539
Cezary Rojewski (17):
ALSA: pcm: Introduce MSBITS subformat interface
ALSA: pcm: Honor subformat when configuring substream
ALSA: hda: Honor subformat when querying PCMs
ASoC: pcm: Honor subformat when configuring runtime
ALSA: hda: Upgrade stream-format infrastructure
ALSA: hda: Switch to new stream-format interface
ALSA: hda/hdmi: Switch to new stream-format interface
ALSA: hda/ca0132: Switch to new stream-format interface
ASoC: codecs: hda: Switch to new stream-format interface
ASoC: codecs: hdac_hda: Switch to new stream-format interface
ASoC: codecs: hdac_hdmi: Switch to new stream-format interface
ASoC: Intel Skylake: Switch to new stream-format interface
ASoC: SOF: Intel: Switch to new stream-format interface
ASoC: Intel: avs: Switch to new stream-format interface
ALSA: hda: Drop snd_hdac_calc_stream_format()
ASoC: Intel: avs: Kill S24_LE in HDAudio streaming
ASoC: Intel: avs: Unhardcode HDAudio BE DAI drivers description
include/sound/hda_codec.h | 5 +- include/sound/hdaudio.h | 12 +-- include/sound/pcm.h | 8 ++ include/sound/pcm_params.h | 2 + include/sound/soc.h | 1 + include/uapi/sound/asound.h | 5 +- sound/core/pcm.c | 3 + sound/core/pcm_lib.c | 30 ++++++ sound/core/pcm_misc.c | 23 +++++ sound/core/pcm_native.c | 5 +- sound/hda/hdac_device.c | 153 +++++++++++++++++++++--------- sound/pci/hda/hda_codec.c | 2 + sound/pci/hda/hda_controller.c | 10 +- sound/pci/hda/patch_ca0132.c | 3 +- sound/pci/hda/patch_hdmi.c | 6 +- sound/soc/codecs/hda-dai.c | 6 +- sound/soc/codecs/hda.c | 2 + sound/soc/codecs/hdac_hda.c | 8 +- sound/soc/codecs/hdac_hdmi.c | 10 +- sound/soc/intel/avs/loader.c | 4 +- sound/soc/intel/avs/path.c | 2 +- sound/soc/intel/avs/pcm.c | 50 ++++++++-- sound/soc/intel/avs/probes.c | 3 +- sound/soc/intel/avs/topology.c | 9 +- sound/soc/intel/skylake/skl-pcm.c | 11 ++- sound/soc/soc-pcm.c | 17 ++++ sound/soc/sof/intel/hda-dai-ops.c | 20 ++-- tools/include/uapi/sound/asound.h | 5 +- 28 files changed, 310 insertions(+), 105 deletions(-)
base-commit: e69dadf638e625a950b2b91591a47c9ae32a9d5e
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 1/17 ALSA: pcm: Introduce MSBITS subformat interface
Improve granularity of format selection for S32/U32 formats by adding constants representing 20, 24 and 32 most significant bits.
To make it easy for drivers to utilize those constants, introduce snd_pcm_subformat_width() and snd_pcm_hw_params_bps(). While the former is self-explanatory, the latter returns the bit-per-sample value based on format, subformat and msbits characteristics of the provided hw_params.
--- include/sound/pcm.h | 8 ++++++++ include/sound/pcm_params.h | 2 ++ include/uapi/sound/asound.h | 5 ++++- sound/core/pcm.c | 3 +++ sound/core/pcm_lib.c | 30 ++++++++++++++++++++++++++++++ sound/core/pcm_misc.c | 23 +++++++++++++++++++++++ tools/include/uapi/sound/asound.h | 5 ++++- 7 files changed, 74 insertions(+), 2 deletions(-)
include/sound/pcm.h +8 -0
@@ -31,6 +31,7 @@struct snd_pcm_hardware {unsigned int info;/* SNDRV_PCM_INFO_* */ u64 formats;/* SNDRV_PCM_FMTBIT_* */ +u64 subformats;/* SNDRV_PCM_SUBFMTBIT_* */ unsigned int rates;/* SNDRV_PCM_RATE_* */ unsigned int rate_min;/* min rate */ unsigned int rate_max;/* max rate */
@@ -219,6 +220,12 @@ struct snd_pcm_ops {#define SNDRV_PCM_FMTBIT_U20 SNDRV_PCM_FMTBIT_U20_BE#endif +#define _SNDRV_PCM_SUBFMTBIT (fmt) BIT((__force int)SNDRV_PCM_SUBFORMAT_##fmt) +#define SNDRV_PCM_SUBFMTBIT_STD _SNDRV_PCM_SUBFMTBIT(STD) +#define SNDRV_PCM_SUBFMTBIT_MSBITS_20 _SNDRV_PCM_SUBFMTBIT(MSBITS_20) +#define SNDRV_PCM_SUBFMTBIT_MSBITS_24 _SNDRV_PCM_SUBFMTBIT(MSBITS_24) +#define SNDRV_PCM_SUBFMTBIT_MSBITS_32 _SNDRV_PCM_SUBFMTBIT(MSBITS_32) +struct snd_pcm_file {struct snd_pcm_substream *substream;int no_compat_mmap;
@@ -1130,6 +1137,7 @@ int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */ssize_t snd_pcm_format_size (snd_pcm_format_t format,size_t samples);const unsigned char *snd_pcm_format_silence_64 (snd_pcm_format_t format);int snd_pcm_format_set_silence (snd_pcm_format_t format,void *buf,unsigned int frames); +int snd_pcm_subformat_width (snd_pcm_subformat_t subformat);void snd_pcm_set_ops (struct snd_pcm * pcm,int direction,const struct snd_pcm_ops *ops);
include/sound/pcm_params.h +2 -0
@@ -362,6 +362,8 @@ static inline int params_physical_width(const struct snd_pcm_hw_params *p)return snd_pcm_format_physical_width (params_format (p)); } +int snd_pcm_hw_params_bps (const struct snd_pcm_hw_params *p); +static inline void params_set_format (struct snd_pcm_hw_params *p,snd_pcm_format_t fmt) {
include/uapi/sound/asound.h +4 -1
@@ -267,7 +267,10 @@ typedef int __bitwise snd_pcm_format_t;typedef int __bitwise snd_pcm_subformat_t ;#define SNDRV_PCM_SUBFORMAT_STD ((__force snd_pcm_subformat_t) 0) -#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD +#define SNDRV_PCM_SUBFORMAT_MSBITS_20 ((__force snd_pcm_subformat_t) 1) +#define SNDRV_PCM_SUBFORMAT_MSBITS_24 ((__force snd_pcm_subformat_t) 2) +#define SNDRV_PCM_SUBFORMAT_MSBITS_32 ((__force snd_pcm_subformat_t) 3) +#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_MSBITS_32#define SNDRV_PCM_INFO_MMAP 0x00000001/* hardware supports mmap */ #define SNDRV_PCM_INFO_MMAP_VALID 0x00000002/* period data are valid during transfer */
sound/core/pcm.c +3 -0
@@ -265,6 +265,9 @@ static const char * const snd_pcm_access_names[] = {static const char *const snd_pcm_subformat_names[] = {SUBFORMAT (STD ), +SUBFORMAT (MSBITS_20 ), +SUBFORMAT (MSBITS_24 ), +SUBFORMAT (MSBITS_32 ), };static const char *const snd_pcm_tstamp_mode_names[] = {
sound/core/pcm_lib.c +30 -0
@@ -1706,6 +1706,36 @@ int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm, }EXPORT_SYMBOL (snd_pcm_hw_param_last); +/** +* snd_pcm_hw_params_bps - Get the number of bits per the sample. +* @p: hardware parameters +* +* Return: The number of bits per sample based on the format, +* subformat and msbits the specified hw params has. +*/ +int snd_pcm_hw_params_bps (const struct snd_pcm_hw_params *p) +{ +snd_pcm_subformat_t subformat =params_subformat (p); +snd_pcm_format_t format =params_format (p); +int width; + +switch (format) { +case SNDRV_PCM_FORMAT_S32_LE : +case SNDRV_PCM_FORMAT_U32_LE : +case SNDRV_PCM_FORMAT_S32_BE : +case SNDRV_PCM_FORMAT_U32_BE : + width =snd_pcm_subformat_width (subformat); +if (width) +return width; +if (p->msbits) +return (int )p->msbits; + fallthrough; +default : +return snd_pcm_format_width (format); + } +} +EXPORT_SYMBOL (snd_pcm_hw_params_bps); +static int snd_pcm_lib_ioctl_reset (struct snd_pcm_substream *substream,void *arg) {
sound/core/pcm_misc.c +23 -0
@@ -482,6 +482,29 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int }EXPORT_SYMBOL (snd_pcm_format_set_silence); +/** +* snd_pcm_subformat_width - return the bit-width of the subformat +* @subformat: the subformat to check +* +* Return: The bit-width of the subformat, or a negative error code +* otherwise. +*/ +int snd_pcm_subformat_width (snd_pcm_subformat_t subformat) +{ +switch (subformat) { +case SNDRV_PCM_SUBFORMAT_MSBITS_20 : +return 20 ; +case SNDRV_PCM_SUBFORMAT_MSBITS_24 : +return 24 ; +case SNDRV_PCM_SUBFORMAT_MSBITS_32 : +return 32 ; +case SNDRV_PCM_SUBFORMAT_STD : +default : +return 0 ; + } +} +EXPORT_SYMBOL (snd_pcm_subformat_width); +/** * snd_pcm_hw_limit_rates - determine rate_min/rate_max fields * @hw: the pcm hw instance
tools/include/uapi/sound/asound.h +4 -1
@@ -267,7 +267,10 @@ typedef int __bitwise snd_pcm_format_t;typedef int __bitwise snd_pcm_subformat_t ;#define SNDRV_PCM_SUBFORMAT_STD ((__force snd_pcm_subformat_t) 0) -#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD +#define SNDRV_PCM_SUBFORMAT_MSBITS_20 ((__force snd_pcm_subformat_t) 1) +#define SNDRV_PCM_SUBFORMAT_MSBITS_24 ((__force snd_pcm_subformat_t) 2) +#define SNDRV_PCM_SUBFORMAT_MSBITS_32 ((__force snd_pcm_subformat_t) 3) +#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_MSBITS_32#define SNDRV_PCM_INFO_MMAP 0x00000001/* hardware supports mmap */ #define SNDRV_PCM_INFO_MMAP_VALID 0x00000002/* period data are valid during transfer */
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 2/17 ALSA: pcm: Honor subformat when configuring substream
In reply to Cezary RojewskiSubstream value is currently hardcoded to SNDRV_PCM_SUBFORMAT_STD. Update the constraint procedure so that subformat selection is not ignored.
--- sound/core/pcm_native.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/core/pcm_native.c +3 -2
@@ -2614,6 +2614,8 @@ static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream)int err;unsigned int mask =0 ; +/* All PCMs support at least the default STD subformat. */ + hw->subformats |=PARAM_MASK_BIT (SNDRV_PCM_SUBFORMAT_STD );if (hw->info &SNDRV_PCM_INFO_INTERLEAVED ) mask |=PARAM_MASK_BIT (SNDRV_PCM_ACCESS_RW_INTERLEAVED );if (hw->info &SNDRV_PCM_INFO_NONINTERLEAVED )
@@ -2634,8 +2636,7 @@ static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream)if (err <0 )return err; - err =snd_pcm_hw_constraint_mask (runtime,SNDRV_PCM_HW_PARAM_SUBFORMAT , -PARAM_MASK_BIT (SNDRV_PCM_SUBFORMAT_STD )); + err =snd_pcm_hw_constraint_mask (runtime,SNDRV_PCM_HW_PARAM_SUBFORMAT , hw->subformats);if (err <0 )return err;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 3/17 ALSA: hda: Honor subformat when querying PCMs
In reply to Cezary RojewskiUpdate mechanism for querying supported PCMs to allow for granular format selection when container size is 32 bits. Currently always the highest bit depth is selected, regardless of how many actual formats codec in question supports.
--- include/sound/hda_codec.h | 5 +++-- include/sound/hdaudio.h | 2 +- sound/hda/hdac_device.c | 42 ++++++++++++++++++++---------------- sound/pci/hda/hda_codec.c | 2 ++ sound/pci/hda/patch_hdmi.c | 1 + sound/soc/codecs/hdac_hdmi.c | 3 ++- 6 files changed, 32 insertions(+), 23 deletions(-)
include/sound/hda_codec.h +3 -2
@@ -141,6 +141,7 @@ struct hda_pcm_stream {hda_nid_t nid;/* default NID to query rates/formats/bps, or set up */ u32 rates;/* supported rates */ u64 formats;/* supported formats (SNDRV_PCM_FMTBIT_) */ +u64 subformats;/* supported subformats (SNDRV_PCM_SUBFMTBIT_) */ unsigned int maxbps;/* supported max. bit per sample */ const struct snd_pcm_chmap_elem *chmap;/* chmap to override */ struct hda_pcm_ops ops;
@@ -448,8 +449,8 @@ void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid,#define snd_hda_codec_cleanup_stream (codec, nid) \ __snd_hda_codec_cleanup_stream(codec, nid, 0) -#define snd_hda_query_supported_pcm (codec, nid, ratesp, fmtsp, bpsp) \ - snd_hdac_query_supported_pcm(&(codec)->core, nid, ratesp, fmtsp, bpsp) +#define snd_hda_query_supported_pcm (codec, nid, ratesp, fmtsp, subfmtp, bpsp) \ + snd_hdac_query_supported_pcm(&(codec)->core, nid, ratesp, fmtsp, subfmtp, bpsp)#define snd_hda_is_supported_format (codec, nid, fmt) \ snd_hdac_is_supported_format(&(codec)->core, nid, fmt)
include/sound/hdaudio.h +1 -1
@@ -146,7 +146,7 @@ unsigned int snd_hdac_calc_stream_format(unsigned int rate,unsigned int maxbps, unsigned short spdif_ctls);int snd_hdac_query_supported_pcm (struct hdac_device *codec,hda_nid_t nid, -u32 *ratesp,u64 *formatsp,unsigned int *bpsp); +u32 *ratesp,u64 *formatsp,u64 *subformatsp,unsigned int *bpsp);bool snd_hdac_is_supported_format (struct hdac_device *codec,hda_nid_t nid,unsigned int format);
sound/hda/hdac_device.c +23 -19
76 lines not on this page · raw message
sound/pci/hda/hda_codec.c +2 -0
@@ -3165,6 +3165,7 @@ static int set_pcm_default_values(struct hda_codec *codec, err =snd_hda_query_supported_pcm (codec, info->nid, info->rates ?NULL : &info->rates, info->formats ?NULL : &info->formats, + info->subformats ?NULL : &info->subformats, info->maxbps ?NULL : &info->maxbps);if (err <0 )return err;
@@ -3759,6 +3760,7 @@ int snd_hda_multi_out_analog_open(struct hda_codec *codec,snd_hda_query_supported_pcm (codec, mout->dig_out_nid, &mout->spdif_rates, &mout->spdif_formats, +NULL , &mout->spdif_maxbps); }mutex_lock (&codec->spdif_mutex);
sound/pci/hda/patch_hdmi.c +1 -0
@@ -1977,6 +1977,7 @@ static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) err =snd_hda_query_supported_pcm (codec, cvt_nid, &per_cvt->rates, &per_cvt->formats, +NULL , &per_cvt->maxbps);if (err <0 )return err;
sound/soc/codecs/hdac_hdmi.c +2 -1
@@ -670,6 +670,7 @@ hdac_hdmi_query_cvt_params(struct hdac_device *hdev, struct hdac_hdmi_cvt *cvt) err =snd_hdac_query_supported_pcm (hdev, cvt->nid, &cvt->params.rates, &cvt->params.formats, +NULL , &cvt->params.maxbps);if (err <0 ) dev_err(&hdev->dev,
@@ -1577,7 +1578,7 @@ static int hdac_hdmi_create_dais(struct hdac_device *hdev,list_for_each_entry (cvt, &hdmi->cvt_list, head) { ret =snd_hdac_query_supported_pcm (hdev, cvt->nid, - &rates, &formats, &bps); + &rates, &formats,NULL , &bps);if (ret)return ret;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 4/17 ASoC: pcm: Honor subformat when configuring runtime
In reply to Cezary RojewskiSubformat options are ignored when setting up hardware parameters and assigning PCM stream capabilities. Account for them to allow for granular format selection.
--- include/sound/soc.h | 1 + sound/soc/soc-pcm.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
include/sound/soc.h +1 -0
@@ -619,6 +619,7 @@ enum snd_soc_trigger_order {struct snd_soc_pcm_stream {const char *stream_name;u64 formats;/* SNDRV_PCM_FMTBIT_* */ +u64 subformats;/* SNDRV_PCM_SUBFMTBIT_* */ unsigned int rates;/* SNDRV_PCM_RATE_* */ unsigned int rate_min;/* min rate */ unsigned int rate_max;/* max rate */
sound/soc/soc-pcm.c +17 -0
@@ -526,6 +526,7 @@ static void soc_pcm_hw_init(struct snd_pcm_hardware *hw) hw->channels_min =0 ; hw->channels_max =UINT_MAX ; hw->formats =ULLONG_MAX ; + hw->subformats =ULLONG_MAX ; } static void soc_pcm_hw_update_rate(struct snd_pcm_hardware *hw,
@@ -554,6 +555,12 @@ static void soc_pcm_hw_update_format(struct snd_pcm_hardware *hw, hw->formats &= p->formats; } +static void soc_pcm_hw_update_subformat (struct snd_pcm_hardware *hw, +struct snd_soc_pcm_stream *p) +{ + hw->subformats &= p->subformats; +} +/** * snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream * @rtd: ASoC PCM runtime
@@ -592,6 +599,7 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,soc_pcm_hw_update_chan (hw, cpu_stream);soc_pcm_hw_update_rate (hw, cpu_stream);soc_pcm_hw_update_format (hw, cpu_stream); +soc_pcm_hw_update_subformat (hw, cpu_stream); } cpu_chan_min = hw->channels_min; cpu_chan_max = hw->channels_max;
@@ -613,6 +621,7 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd,soc_pcm_hw_update_chan (hw, codec_stream);soc_pcm_hw_update_rate (hw, codec_stream);soc_pcm_hw_update_format (hw, codec_stream); +soc_pcm_hw_update_subformat (hw, codec_stream); }/* Verify both a valid CPU DAI and a valid CODEC DAI were found */
@@ -637,6 +646,7 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream) {struct snd_pcm_hardware *hw = &substream->runtime->hw;struct snd_soc_pcm_runtime *rtd =asoc_substream_to_rtd (substream); +u64 subformats = hw->subformats;u64 formats = hw->formats;/*
@@ -648,6 +658,8 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)if (formats) hw->formats &= formats; +if (subformats) + hw->subformats &= subformats; }static int soc_pcm_components_open (struct snd_pcm_substream *substream)
@@ -1676,6 +1688,7 @@ static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream)struct snd_pcm_hardware *hw = &runtime->hw;struct snd_soc_dai *dai;int stream = substream->stream; +u64 subformats = hw->subformats;u64 formats = hw->formats;int i;
@@ -1683,6 +1696,8 @@ static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream)if (formats) hw->formats &= formats; +if (subformats) + hw->subformats &= subformats;for_each_rtd_cpu_dais (fe, i, dai) {struct snd_soc_pcm_stream *cpu_stream;
@@ -1699,6 +1714,7 @@ static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream)soc_pcm_hw_update_rate (hw, cpu_stream);soc_pcm_hw_update_chan (hw, cpu_stream);soc_pcm_hw_update_format (hw, cpu_stream); +soc_pcm_hw_update_subformat (hw, cpu_stream); } }
@@ -1736,6 +1752,7 @@ static void dpcm_runtime_setup_be_format(struct snd_pcm_substream *substream) codec_stream =snd_soc_dai_get_pcm_stream (dai, stream);soc_pcm_hw_update_format (hw, codec_stream); +soc_pcm_hw_update_subformat (hw, codec_stream); } } }
Signature · 1 line
2.25.1
Re: [PATCH 04/17] ASoC: pcm: Honor subformat when configuring runtime
Quoted 3 lines · Cezary Rojewski
Subformat options are ignored when setting up hardware parameters and assigning PCM stream capabilities. Account for them to allow for granular format selection.
Cezary Rojewski
maintainerPATCH 5/17 ALSA: hda: Upgrade stream-format infrastructure
In reply to Cezary RojewskiIntroduce a set of functions that facilite SDxFMT-related calculations in atomic manner:
snd_hdac_format_normalize() - format converter. S20_LE, S24_LE and their unsigned and BE friends are invalid from HDAudio perspective but still can be specified as function argument due to compatibility reasons.
snd_hdac_stream_format_bps() - obtain just the bits-per-sample value. Does not ignore subformat and msbits parameters.
snd_hdac_stream_format() and snd_hdac_spdif_stream_format() - obtain the SDxFMT value given the audio format parameters. The former is stripped away of spdif-related information. Useful for users that do not care about them.
--- include/sound/hdaudio.h | 5 ++ sound/hda/hdac_device.c | 124 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+)
include/sound/hdaudio.h +5 -0
@@ -140,6 +140,11 @@ int snd_hdac_get_connections(struct hdac_device *codec, hda_nid_t nid, hda_nid_t *conn_list, int max_conns);int snd_hdac_get_sub_nodes (struct hdac_device *codec,hda_nid_t nid,hda_nid_t *start_id); +unsigned int snd_hdac_stream_format_bps (snd_pcm_format_t format,snd_pcm_subformat_t subformat, +unsigned int maxbps); +unsigned int snd_hdac_stream_format (unsigned int channels,unsigned int bps,unsigned int rate); +unsigned int snd_hdac_spdif_stream_format (unsigned int channels,unsigned int bps, +unsigned int rate,unsigned short spdif_ctls); unsigned int snd_hdac_calc_stream_format(unsigned int rate, unsigned int channels, snd_pcm_format_t format,
sound/hda/hdac_device.c +124 -0
136 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 6/17 ALSA: hda: Switch to new stream-format interface
In reply to Cezary RojewskiTo provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
--- sound/pci/hda/hda_controller.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
sound/pci/hda/hda_controller.c +4 -6
@@ -151,7 +151,7 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)struct azx_dev *azx_dev =get_azx_dev (substream);struct hda_pcm_stream *hinfo =to_hda_pcm_stream (substream);struct snd_pcm_runtime *runtime = substream->runtime; -unsigned int format_val, stream_tag; +unsigned int format_val, stream_tag, bps;int err;struct hda_spdif_out *spdif =snd_hda_spdif_out_of_nid (apcm->codec, hinfo->nid);
@@ -165,11 +165,9 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) }snd_hdac_stream_reset (azx_stream (azx_dev)); - format_val =snd_hdac_calc_stream_format (runtime->rate, - runtime->channels, - runtime->format, - hinfo->maxbps, - ctls); + bps =snd_hdac_stream_format_bps (runtime->format,SNDRV_PCM_SUBFORMAT_STD , hinfo->maxbps); + + format_val =snd_hdac_spdif_stream_format (runtime->channels, bps, runtime->rate, ctls);if (!format_val) { dev_err(chip->card->dev, "invalid format_val, rate=%d, ch=%d, format=%d\n",
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 7/17 ALSA: hda/hdmi: Switch to new stream-format interface
In reply to Cezary RojewskiTo provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
--- sound/pci/hda/patch_hdmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
sound/pci/hda/patch_hdmi.c +2 -3
@@ -1655,7 +1655,6 @@ static void hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,#define I915_SILENT_RATE 48000#define I915_SILENT_CHANNELS 2 -#define I915_SILENT_FORMAT SNDRV_PCM_FORMAT_S16_LE#define I915_SILENT_FORMAT_BITS 16#define I915_SILENT_FMT_MASK 0xf
@@ -1668,8 +1667,8 @@ static void silent_stream_enable_i915(struct hda_codec *codec, per_pin->dev_id, I915_SILENT_RATE);/* trigger silent stream generation in hw */ - format =snd_hdac_calc_stream_format (I915_SILENT_RATE ,I915_SILENT_CHANNELS , -I915_SILENT_FORMAT ,I915_SILENT_FORMAT_BITS ,0 ); + format =snd_hdac_stream_format (I915_SILENT_CHANNELS ,I915_SILENT_FORMAT_BITS , +I915_SILENT_RATE );snd_hda_codec_setup_stream (codec, per_pin->cvt_nid,I915_SILENT_FMT_MASK ,I915_SILENT_FMT_MASK , format);usleep_range (100 ,200 );
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 8/17 ALSA: hda/ca0132: Switch to new stream-format interface
In reply to Cezary RojewskiTo provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
--- sound/pci/hda/patch_ca0132.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/pci/hda/patch_ca0132.c +1 -2
@@ -3022,8 +3022,7 @@ static int dma_convert_to_hda_format(struct hda_codec *codec, {unsigned int format_val; - format_val =snd_hdac_calc_stream_format (sample_rate, - channels,SNDRV_PCM_FORMAT_S32_LE ,32 ,0 ); + format_val =snd_hdac_stream_format (channels,32 , sample_rate);if (hda_format) *hda_format = (unsigned short )format_val;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 9/17 ASoC: codecs: hda: Switch to new stream-format interface
In reply to Cezary RojewskiTo provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
While at it, complete PCM stream initialization with subformat options.
--- sound/soc/codecs/hda-dai.c | 6 ++++-- sound/soc/codecs/hda.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-)
sound/soc/codecs/hda-dai.c +4 -2
@@ -76,13 +76,15 @@ static int hda_codec_dai_prepare(struct snd_pcm_substream *substream, struct sndstruct hdac_stream *stream;struct hda_codec *codec;unsigned int format; +unsigned int bps;int ret; codec =dev_to_hda_codec (dai->dev); stream = substream->runtime->private_data; stream_info =snd_soc_dai_get_dma_data (dai, substream); - format =snd_hdac_calc_stream_format (runtime->rate, runtime->channels, runtime->format, - runtime->sample_bits,0 ); + + bps =snd_hdac_stream_format_bps (runtime->format, runtime->subformat, stream_info->maxbps); + format =snd_hdac_stream_format (runtime->channels, bps, runtime->rate); ret =snd_hda_codec_prepare (codec, stream_info, stream->stream_tag, format, substream);if (ret <0 ) {
sound/soc/codecs/hda.c +2 -0
@@ -52,6 +52,7 @@ static int hda_codec_create_dais(struct hda_codec *codec, int pcm_count, stream->channels_max = pcm->stream[dir].channels_max; stream->rates = pcm->stream[dir].rates; stream->formats = pcm->stream[dir].formats; + stream->subformats = pcm->stream[dir].subformats; stream->sig_bits = pcm->stream[dir].maxbps; capture_dais:
@@ -71,6 +72,7 @@ static int hda_codec_create_dais(struct hda_codec *codec, int pcm_count, stream->channels_max = pcm->stream[dir].channels_max; stream->rates = pcm->stream[dir].rates; stream->formats = pcm->stream[dir].formats; + stream->subformats = pcm->stream[dir].subformats; stream->sig_bits = pcm->stream[dir].maxbps; }
Signature · 1 line
2.25.1
Re: [PATCH 09/17] ASoC: codecs: hda: Switch to new stream-format interface
Quoted 2 lines · Cezary Rojewski
To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
Cezary Rojewski
maintainerPATCH 10/17 ASoC: codecs: hdac_hda: Switch to new stream-format interface
In reply to Cezary RojewskiTo provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
--- sound/soc/codecs/hdac_hda.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
sound/soc/codecs/hdac_hda.c +3 -5
@@ -207,18 +207,16 @@ static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,struct hdac_hda_priv *hda_pvt;unsigned int format_val;unsigned int maxbps; +unsigned int bps;if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) maxbps = dai->driver->playback.sig_bits;else maxbps = dai->driver->capture.sig_bits; + bps =snd_hdac_stream_format_bps (params_format (params),SNDRV_PCM_SUBFORMAT_STD , maxbps); hda_pvt =snd_soc_component_get_drvdata (component); - format_val =snd_hdac_calc_stream_format (params_rate (params), -params_channels (params), -params_format (params), - maxbps, -0 ); + format_val =snd_hdac_stream_format (params_channels (params), bps,params_rate (params));if (!format_val) { dev_err(dai->dev, "invalid format_val, rate=%d, ch=%d, format=%d, maxbps=%d\n",
Signature · 1 line
2.25.1
Re: [PATCH 10/17] ASoC: codecs: hdac_hda: Switch to new stream-format interface
Quoted 2 lines · Cezary Rojewski
To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
Cezary Rojewski
maintainerPATCH 11/17 ASoC: codecs: hdac_hdmi: Switch to new stream-format interface
In reply to Cezary RojewskiTo provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
--- sound/soc/codecs/hdac_hdmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/soc/codecs/hdac_hdmi.c +4 -3
@@ -468,13 +468,14 @@ static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream,struct hdac_hdmi_priv *hdmi =snd_soc_dai_get_drvdata (dai);struct hdac_hdmi_dai_port_map *dai_map;struct hdac_hdmi_pcm *pcm; +unsigned int bps;int format; dai_map = &hdmi->dai_map[dai->id]; - format =snd_hdac_calc_stream_format (params_rate (hparams), -params_channels (hparams),params_format (hparams), - dai->driver->playback.sig_bits,0 ); + bps =snd_hdac_stream_format_bps (params_format (hparams),SNDRV_PCM_SUBFORMAT_STD , + dai->driver->playback.sig_bits); + format =snd_hdac_stream_format (params_channels (hparams), bps,params_rate (hparams)); pcm =hdac_hdmi_get_pcm_from_cvt (hdmi, dai_map->cvt);if (!pcm)
Signature · 1 line
2.25.1
Re: [PATCH 11/17] ASoC: codecs: hdac_hdmi: Switch to new stream-format interface
Quoted 2 lines · Cezary Rojewski
To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
Cezary Rojewski
maintainerPATCH 12/17 ASoC: Intel Skylake: Switch to new stream-format interface
In reply to Cezary RojewskiTo provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
--- sound/soc/intel/skylake/skl-pcm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
sound/soc/intel/skylake/skl-pcm.c +7 -4
@@ -128,6 +128,7 @@ int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params)unsigned int format_val;struct hdac_stream *hstream;struct hdac_ext_stream *stream; +unsigned int bps;int err; hstream = snd_hdac_get_stream(bus, params->stream,
@@ -138,8 +139,8 @@ int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params) stream =stream_to_hdac_ext_stream (hstream);snd_hdac_ext_stream_decouple (bus, stream, true); - format_val =snd_hdac_calc_stream_format (params->s_freq, - params->ch, params->format, params->host_bps,0 ); + bps =snd_hdac_stream_format_bps (params->format,SNDRV_PCM_SUBFORMAT_STD , params->host_bps); + format_val =snd_hdac_stream_format (params->ch, bps, params->s_freq);dev_dbg (dev,"format_val=%d, rate=%d, ch=%d, format=%d\n" , format_val, params->s_freq, params->ch, params->format);
@@ -177,6 +178,7 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params)struct hdac_ext_stream *stream;struct hdac_ext_link *link;unsigned char stream_tag; +unsigned int bps; hstream =snd_hdac_get_stream (bus, params->stream, params->link_dma_id +1 );
@@ -185,8 +187,9 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params) stream =stream_to_hdac_ext_stream (hstream);snd_hdac_ext_stream_decouple (bus, stream, true); - format_val =snd_hdac_calc_stream_format (params->s_freq, params->ch, - params->format, params->link_bps,0 ); + + bps =snd_hdac_stream_format_bps (params->format,SNDRV_PCM_SUBFORMAT_STD , params->link_bps); + format_val =snd_hdac_stream_format (params->ch, bps, params->s_freq);dev_dbg (dev,"format_val=%d, rate=%d, ch=%d, format=%d\n" , format_val, params->s_freq, params->ch, params->format);
Signature · 1 line
2.25.1
Re: [PATCH 12/17] ASoC: Intel Skylake: Switch to new stream-format interface
Quoted 2 lines · Cezary Rojewski
To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
Cezary Rojewski
maintainerPATCH 13/17 ASoC: SOF: Intel: Switch to new stream-format interface
In reply to Cezary RojewskiTo provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
--- sound/soc/sof/intel/hda-dai-ops.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
sound/soc/sof/intel/hda-dai-ops.c +10 -10
@@ -213,9 +213,10 @@ static unsigned int hda_calc_stream_format(struct snd_sof_dev *sdev, link_bps = codec_dai->driver->playback.sig_bits; else link_bps = codec_dai->driver->capture.sig_bits; + link_bps =snd_hdac_stream_format_bps (params_format (params),SNDRV_PCM_SUBFORMAT_STD , + link_bps); - format_val =snd_hdac_calc_stream_format (params_rate (params),params_channels (params), -params_format (params), link_bps,0 ); + format_val =snd_hdac_stream_format (params_channels (params), link_bps,params_rate (params));dev_dbg (sdev->dev,"format_val=%#x, rate=%d, ch=%d, format=%d\n" , format_val,params_rate (params),params_channels (params),params_format (params));
@@ -238,11 +239,11 @@ static unsigned int generic_calc_stream_format(struct snd_sof_dev *sdev, struct snd_pcm_hw_params *params) {unsigned int format_val; +unsigned int bps; - format_val =snd_hdac_calc_stream_format (params_rate (params),params_channels (params), -params_format (params), -params_physical_width (params), -0 ); + bps =snd_hdac_stream_format_bps (params_format (params),SNDRV_PCM_SUBFORMAT_STD , +params_physical_width (params)); + format_val =snd_hdac_stream_format (params_channels (params), bps,params_rate (params));dev_dbg (sdev->dev,"format_val=%#x, rate=%d, ch=%d, format=%d\n" , format_val,params_rate (params),params_channels (params),params_format (params));
@@ -258,6 +259,7 @@ static unsigned int dmic_calc_stream_format(struct snd_sof_dev *sdev,snd_pcm_format_t format;unsigned int channels;unsigned int width; +unsigned int bps; channels =params_channels (params); format =params_format (params);
@@ -269,10 +271,8 @@ static unsigned int dmic_calc_stream_format(struct snd_sof_dev *sdev, width =32 ; } - format_val =snd_hdac_calc_stream_format (params_rate (params), channels, - format, - width, -0 ); + bps =snd_hdac_stream_format_bps (format,SNDRV_PCM_SUBFORMAT_STD , width); + format_val =snd_hdac_stream_format (channels, bps,params_rate (params));dev_dbg (sdev->dev,"format_val=%#x, rate=%d, ch=%d, format=%d\n" , format_val,params_rate (params), channels, format);
Signature · 1 line
2.25.1
Re: [PATCH 13/17] ASoC: SOF: Intel: Switch to new stream-format interface
Quoted 2 lines · Cezary Rojewski
To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
Cezary Rojewski
maintainerPATCH 14/17 ASoC: Intel: avs: Switch to new stream-format interface
In reply to Cezary RojewskiTo provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
--- sound/soc/intel/avs/loader.c | 4 ++-- sound/soc/intel/avs/path.c | 2 +- sound/soc/intel/avs/pcm.c | 19 ++++++++++++++----- sound/soc/intel/avs/probes.c | 3 +-- 4 files changed, 18 insertions(+), 10 deletions(-)
sound/soc/intel/avs/loader.c +2 -2
@@ -371,7 +371,7 @@ int avs_hda_load_basefw(struct avs_dev *adev, struct firmware *fw) hstream =hdac_stream (estream);/* code loading performed with default format */ - sdfmt =snd_hdac_calc_stream_format (48000 ,1 ,SNDRV_PCM_FORMAT_S32_LE ,32 ,0 ); + sdfmt =snd_hdac_stream_format (1 ,32 ,48000 ); ret =snd_hdac_dsp_prepare (hstream, sdfmt, fw->size, &dmab);if (ret <0 ) goto release_stream;
@@ -438,7 +438,7 @@ int avs_hda_load_library(struct avs_dev *adev, struct firmware *lib, u32 id) stream =hdac_stream (estream);/* code loading performed with default format */ - sdfmt =snd_hdac_calc_stream_format (48000 ,1 ,SNDRV_PCM_FORMAT_S32_LE ,32 ,0 ); + sdfmt =snd_hdac_stream_format (1 ,32 ,48000 ); ret =snd_hdac_dsp_prepare (stream, sdfmt, lib->size, &dmab);if (ret <0 ) goto release_stream;
sound/soc/intel/avs/path.c +1 -1
@@ -87,7 +87,7 @@ static bool avs_test_hw_params(struct snd_pcm_hw_params *params,return (params_rate (params) == fmt->sampling_freq &¶ms_channels (params) == fmt->num_channels &¶ms_physical_width (params) == fmt->bit_depth && -params_width (params) == fmt->valid_bit_depth); +snd_pcm_hw_params_bps (params) == fmt->valid_bit_depth); } static struct avs_tplg_path *
sound/soc/intel/avs/pcm.c +14 -5
@@ -335,20 +335,25 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn {struct snd_soc_pcm_runtime *rtd =asoc_substream_to_rtd (substream);struct snd_pcm_runtime *runtime = substream->runtime; -struct hdac_ext_stream *link_stream = runtime->private_data; +struct snd_soc_pcm_stream *stream_info; +struct hdac_ext_stream *link_stream;struct hdac_ext_link *link;struct hda_codec *codec;struct hdac_bus *bus;unsigned int format_val; +unsigned int bps;int ret; + link_stream = runtime->private_data;if (link_stream->link_prepared)return 0 ; codec =dev_to_hda_codec (asoc_rtd_to_codec (rtd,0 )->dev); bus = &codec->bus->core; - format_val =snd_hdac_calc_stream_format (runtime->rate, runtime->channels, runtime->format, - runtime->sample_bits,0 ); + stream_info =snd_soc_dai_get_pcm_stream (dai, substream->stream); + bps =snd_hdac_stream_format_bps (runtime->format, runtime->subformat, + stream_info->sig_bits); + format_val =snd_hdac_stream_format (runtime->channels, bps, runtime->rate);snd_hdac_ext_stream_decouple (bus, link_stream, true);snd_hdac_ext_stream_reset (link_stream);
@@ -601,11 +606,13 @@ static int avs_dai_fe_hw_free(struct snd_pcm_substream *substream, struct snd_sostatic int avs_dai_fe_prepare (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) {struct snd_pcm_runtime *runtime = substream->runtime; +struct snd_soc_pcm_stream *stream_info;struct avs_dma_data *data;struct avs_dev *adev =to_avs_dev (dai->dev);struct hdac_ext_stream *host_stream;struct hdac_bus *bus;unsigned int format_val; +unsigned int bps;int ret; data =snd_soc_dai_get_dma_data (dai, substream);
@@ -618,8 +625,10 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_sosnd_hdac_ext_stream_decouple (bus, data->host_stream, true);snd_hdac_stream_reset (hdac_stream (host_stream)); - format_val =snd_hdac_calc_stream_format (runtime->rate, runtime->channels, runtime->format, - runtime->sample_bits,0 ); + stream_info =snd_soc_dai_get_pcm_stream (dai, substream->stream); + bps =snd_hdac_stream_format_bps (runtime->format, runtime->subformat, + stream_info->sig_bits); + format_val =snd_hdac_stream_format (runtime->channels, bps, runtime->rate); ret =snd_hdac_stream_set_params (hdac_stream (host_stream), format_val);if (ret <0 )
sound/soc/intel/avs/probes.c +1 -2
@@ -140,8 +140,7 @@ static int avs_probe_compr_set_params(struct snd_compr_stream *cstream, bps =snd_pcm_format_physical_width (format);if (bps <0 )return bps; - format_val =snd_hdac_calc_stream_format (params->codec.sample_rate, params->codec.ch_out, - format, bps,0 ); + format_val =snd_hdac_stream_format (params->codec.ch_out, bps, params->codec.sample_rate); ret =snd_hdac_stream_set_params (hdac_stream (host_stream), format_val);if (ret <0 )return ret;
Signature · 1 line
2.25.1
Re: [PATCH 14/17] ASoC: Intel: avs: Switch to new stream-format interface
Quoted 2 lines · Cezary Rojewski
To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism.
Cezary Rojewski
maintainerPATCH 15/17 ALSA: hda: Drop snd_hdac_calc_stream_format()
In reply to Cezary RojewskiThere are no users of the function.
--- include/sound/hdaudio.h | 5 ---- sound/hda/hdac_device.c | 61 ----------------------------------------- 2 files changed, 66 deletions(-)
include/sound/hdaudio.h +0 -5
@@ -145,11 +145,6 @@ unsigned int snd_hdac_stream_format_bps(snd_pcm_format_t format, snd_pcm_subformunsigned int snd_hdac_stream_format (unsigned int channels,unsigned int bps,unsigned int rate);unsigned int snd_hdac_spdif_stream_format (unsigned int channels,unsigned int bps,unsigned int rate,unsigned short spdif_ctls); -unsigned int snd_hdac_calc_stream_format (unsigned int rate, -unsigned int channels, -snd_pcm_format_t format, -unsigned int maxbps, -unsigned short spdif_ctls);int snd_hdac_query_supported_pcm (struct hdac_device *codec,hda_nid_t nid,u32 *ratesp,u64 *formatsp,u64 *subformatsp,unsigned int *bpsp); bool snd_hdac_is_supported_format(struct hdac_device *codec, hda_nid_t nid,
sound/hda/hdac_device.c +0 -61
67 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 16/17 ASoC: Intel: avs: Kill S24_LE in HDAudio streaming
In reply to Cezary RojewskiEliminate all occurrences of S24_LE within the HDAudio related pcm code, both HOST and LINK side. Replace those with MSBITS subformats to allow for granular selection when S32_LE is the format of choice.
--- sound/soc/intel/avs/pcm.c | 12 +++++++++--- sound/soc/intel/avs/topology.c | 9 ++++++++- 2 files changed, 17 insertions(+), 4 deletions(-)
sound/soc/intel/avs/pcm.c +9 -3
@@ -1055,8 +1055,10 @@ static const struct snd_pcm_hardware avs_pcm_hardware = {SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, .formats =SNDRV_PCM_FMTBIT_S16_LE | -SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + .subformats =SNDRV_PCM_SUBFMTBIT_MSBITS_20 | +SNDRV_PCM_SUBFMTBIT_MSBITS_24 | + SNDRV_PCM_SUBFMTBIT_MSBITS_32, .buffer_bytes_max = AZX_MAX_BUF_SIZE, .period_bytes_min = 128, .period_bytes_max = AZX_MAX_BUF_SIZE / 2,
@@ -1286,16 +1288,20 @@ static const struct snd_soc_dai_driver hda_cpu_dai = { .channels_max = 8, .rates = SNDRV_PCM_RATE_8000_192000, .formats =SNDRV_PCM_FMTBIT_S16_LE | -SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + .subformats =SNDRV_PCM_SUBFMTBIT_MSBITS_20 | +SNDRV_PCM_SUBFMTBIT_MSBITS_24 | + SNDRV_PCM_SUBFMTBIT_MSBITS_32, }, .capture = { .channels_min = 1, .channels_max = 8, .rates = SNDRV_PCM_RATE_8000_192000, .formats =SNDRV_PCM_FMTBIT_S16_LE | -SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + .subformats =SNDRV_PCM_SUBFMTBIT_MSBITS_20 | +SNDRV_PCM_SUBFMTBIT_MSBITS_24 | + SNDRV_PCM_SUBFMTBIT_MSBITS_32, }, };
sound/soc/intel/avs/topology.c +8 -1
@@ -1456,8 +1456,15 @@ static int avs_dai_load(struct snd_soc_component *comp, int index, struct snd_soc_dai_driver *dai_drv, struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai) { - if (pcm) + u64 subformats = SNDRV_PCM_SUBFMTBIT_MSBITS_20 | +SNDRV_PCM_SUBFMTBIT_MSBITS_24 ; + +if (pcm) { dai_drv->ops = &avs_dai_fe_ops; + dai_drv->capture.subformats |= subformats; + dai_drv->playback.subformats |= subformats; + } +return 0 ; }
Signature · 1 line
2.25.1
Re: [PATCH 16/17] ASoC: Intel: avs: Kill S24_LE in HDAudio streaming
Quoted 3 lines · Cezary Rojewski
Eliminate all occurrences of
S24_LEwithin the HDAudio related pcm code, both HOST and LINK side. Replace those with MSBITS subformats to allow for granular selection whenS32_LEis the format of choice.
Cezary Rojewski
maintainerPATCH 17/17 ASoC: Intel: avs: Unhardcode HDAudio BE DAI drivers description
In reply to Cezary RojewskiTo not expose more than in fact is supported by the codec, update CPU DAI initialization procedure to rely on codec capabilities instead of hardcoding them. This includes subformat which is currently ignored.
As capabilities for HDMI streams are initialized on PCM open, leave it as is for now.
--- sound/soc/intel/avs/pcm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
sound/soc/intel/avs/pcm.c +19 -0
@@ -17,6 +17,7 @@#include "avs.h" #include "path.h" #include "topology.h" +#include "../../codecs/hda.h" struct avs_dma_data {struct avs_tplg_path_template *template;
@@ -1378,6 +1379,15 @@ static int avs_component_hda_probe(struct snd_soc_component *component) ret = -ENOMEM ; goto exit; } + +if (!hda_codec_is_display (codec)) { + dais[i].playback.formats = pcm->stream[0 ].formats; + dais[i].playback.subformats = pcm->stream[0 ].subformats; + dais[i].playback.rates = pcm->stream[0 ].rates; + dais[i].playback.channels_min = pcm->stream[0 ].channels_min; + dais[i].playback.channels_max = pcm->stream[0 ].channels_max; + dais[i].playback.sig_bits = pcm->stream[0 ].maxbps; + } }if (pcm->stream[1 ].substreams) {
@@ -1388,6 +1398,15 @@ static int avs_component_hda_probe(struct snd_soc_component *component) ret = -ENOMEM ; goto exit; } + +if (!hda_codec_is_display (codec)) { + dais[i].capture.formats = pcm->stream[1 ].formats; + dais[i].capture.subformats = pcm->stream[1 ].subformats; + dais[i].capture.rates = pcm->stream[1 ].rates; + dais[i].capture.channels_min = pcm->stream[1 ].channels_min; + dais[i].capture.channels_max = pcm->stream[1 ].channels_max; + dais[i].capture.sig_bits = pcm->stream[1 ].maxbps; + } } dai =snd_soc_register_dai (component, &dais[i], false);
Signature · 1 line
2.25.1
Re: [PATCH 17/17] ASoC: Intel: avs: Unhardcode HDAudio BE DAI drivers description
Quoted 3 lines · Cezary Rojewski
To not expose more than in fact is supported by the codec, update CPU DAI initialization procedure to rely on codec capabilities instead of hardcoding them. This includes subformat which is currently ignored.