ASoC: Intel: avs: 16 channels support
Subsystems (5)
Cezary Rojewski
maintainercover ASoC: Intel: avs: 16 channels support
Relatively small delta-wise patchset which raises max channels supported from 8 to 16. The existing limitation is software-based, not hardware based. The hardware, as per HDAudio specification, section 1.2.2, (relevant register at SDnFMT, section 3.3.41) supports the configurations for years. The avs-driver becomes the first consumer of that configuration on the Linux kernel side.
Set starts off with update to string_helpers so that functionality added with parse_int_array_user() can be utilized in kernel-kernel interactions.
Follow up is rasing the cap on HDAudio-library side. The format selection procedure found in the library is good-to-go as is.
Everything that follows these two patches is avs-driver specific:
- raise channels_max for every DAI-driver template
- provide i2s_test module parameter for testing purposes. When combined with I2S loopback card, allows to test 16ch on most Intel hardware post Broadwell era
- adjust TDM masks to reflect the 8 -> 16 channels change
Amadeusz Sławiński (5):
ASoC: Intel: avs: Rename AVS_CHANNELS_MAX define
ASoC: Intel: avs: Allow to specify custom configurations with i2s_test
ASoC: Intel: avs: Assign unique ID to platform devices
ASoC: Intel: avs: Iterate over correct number of TDMs
ASoC: Intel: avs: Support 16 TDMs in dynamic assignment
Cezary Rojewski (3):
lib/string_helpers: Introduce parse_int_array()
ALSA: hda: Allow for 16 channels configuration
ASoC: Intel: avs: Allow for 16 channels configuration
include/linux/string_helpers.h | 1 + lib/string_helpers.c | 39 +++---- sound/hda/hdac_device.c | 2 +- sound/soc/intel/avs/board_selection.c | 144 ++++++++++++++------------ sound/soc/intel/avs/messages.h | 5 +- sound/soc/intel/avs/path.c | 2 +- sound/soc/intel/avs/pcm.c | 10 +- sound/soc/intel/avs/topology.c | 4 +- sound/soc/intel/avs/topology.h | 2 +- 9 files changed, 110 insertions(+), 99 deletions(-)
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 1/8 lib/string_helpers: Introduce parse_int_array()
Existing parse_inte_array_user() works with __user buffers only. Separate array parsing from __user bits so the functionality can be utilized with kernel buffers too.
--- include/linux/string_helpers.h | 1 + lib/string_helpers.c | 39 ++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 18 deletions(-)
include/linux/string_helpers.h +1 -0
@@ -31,6 +31,7 @@ enum string_size_units {int string_get_size (u64 size,u64 blk_size,const enum string_size_units units,char *buf,int len); +int parse_int_array (const char *buf,size_t count,int **array);int parse_int_array_user (const char __user *from,size_t count,int **array);#define UNESCAPE_SPACE BIT(0)
lib/string_helpers.c +21 -18
@@ -138,6 +138,25 @@ int string_get_size(u64 size, u64 blk_size, const enum string_size_units units, }EXPORT_SYMBOL (string_get_size); +int parse_int_array (const char *buf,size_t count,int **array) +{ +int *ints, nints; + +get_options (buf,0 , &nints); +if (!nints) +return -ENOENT ; + + ints =kcalloc (nints +1 ,sizeof (*ints),GFP_KERNEL ); +if (!ints) +return -ENOMEM ; + +get_options (buf, nints +1 , ints); + *array = ints; + +return 0 ; +} +EXPORT_SYMBOL (parse_int_array); +/** * parse_int_array_user - Split string into a sequence of integers * @from: The user space buffer to read from
@@ -153,30 +172,14 @@ EXPORT_SYMBOL(string_get_size);*/ int parse_int_array_user (const char __user *from,size_t count,int **array) { -int *ints, nints;char *buf; -int ret =0 ; +int ret; buf =memdup_user_nul (from, count);if (IS_ERR (buf))return PTR_ERR (buf); -get_options (buf,0 , &nints); -if (!nints) { - ret = -ENOENT ; - goto free_buf; - } - - ints =kcalloc (nints +1 ,sizeof (*ints),GFP_KERNEL ); -if (!ints) { - ret = -ENOMEM ; - goto free_buf; - } - -get_options (buf, nints +1 , ints); - *array = ints; - -free_buf: + ret =parse_int_array (buf, count, array);kfree (buf);return ret; }
Signature · 1 line
2.25.1
Re: [PATCH 1/8] lib/string_helpers: Introduce parse_int_array()
Quoted 3 lines · Cezary Rojewski
Existing
parse_inte_array_user()works with__userbuffers only. Separate array parsing from__userbits so the functionality can be utilized with kernel buffers too.
But do we have a user for this? I believe we don't accept code without a user.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 1/8] lib/string_helpers: Introduce parse_int_array()
Quoted 8 lines · Andy Shevchenko
Quoted 3 lines · Cezary Rojewski
Existing
parse_inte_array_user()works with__userbuffers only. Separate array parsing from__userbits so the functionality can be utilized with kernel buffers too.Reviewed-by Andy Shevchenko <[email protected]>But do we have a user for this? I believe we don't accept code without a user.
Okay, this patch 1 out of 8... Next time Cc people at least to the cover letter where it will be visible.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Cezary Rojewski
maintainerRe: [PATCH 1/8] lib/string_helpers: Introduce parse_int_array()
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Cezary Rojewski
Existing
parse_inte_array_user()works with__userbuffers only. Separate array parsing from__userbits so the functionality can be utilized with kernel buffers too.
Quoted 7 lines
Quoted 3 lines
Reviewed-by Andy Shevchenko <[email protected]>But do we have a user for this? I believe we don't accept code without a user.
Okay, this patch 1 out of 8... Next time Cc people at least to the cover letter where it will be visible.
My apologies.
The idea was to add the Cc: tag so you are always pinged when something happens to the string_helper change while simultaneously adding --cc=Andy when doing git send-email for the entire series. I did forget about the latter :(
Cezary Rojewski
maintainerPATCH 2/8 ALSA: hda: Allow for 16 channels configuration
In reply to Cezary RojewskiAs per HDAudio specification, up to 16 channels are supported. Reflect that in the code.
--- sound/hda/hdac_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/hda/hdac_device.c +1 -1
@@ -801,7 +801,7 @@ unsigned int snd_hdac_stream_format(unsigned int channels, unsigned int bits, unif (!rate_bits[i].hz)return 0 ; -if (channels ==0 || channels >8 ) +if (channels ==0 || channels >16 )return 0 ; val |= channels -1 ;
Signature · 1 line
2.25.1
Mark Brown
maintainerRe: [PATCH 2/8] ALSA: hda: Allow for 16 channels configuration
Quoted 2 lines · Cezary Rojewski
As per HDAudio specification, up to 16 channels are supported. Reflect that in the code.
Takashi, is this OK to merge via ASoC?
Cezary Rojewski
maintainerPATCH 3/8 ASoC: Intel: avs: Rename AVS_CHANNELS_MAX define
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
It is used for coefficient table in updown mixer module, which supports maximum of 8 channels. However it does not represent HW capability.
--- sound/soc/intel/avs/messages.h | 4 ++-- sound/soc/intel/avs/path.c | 2 +- sound/soc/intel/avs/topology.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/intel/avs/messages.h +2 -2
@@ -697,7 +697,7 @@ enum avs_sample_type { AVS_SAMPLE_TYPE_FLOAT = 4, }; -#define AVS_CHANNELS_MAX 8 +#define AVS_COEFF_CHANNELS_MAX 8#define AVS_ALL_CHANNELS_MASK UINT_MAXstruct avs_audio_format {
@@ -846,7 +846,7 @@ struct avs_updown_mixer_cfg {struct avs_modcfg_base base;u32 out_channel_config;u32 coefficients_select; -s32 coefficients[AVS_CHANNELS_MAX ]; +s32 coefficients[AVS_COEFF_CHANNELS_MAX ];u32 channel_map; } __packed;static_assert (sizeof (struct avs_updown_mixer_cfg ) ==84 );
sound/soc/intel/avs/path.c +1 -1
@@ -452,7 +452,7 @@ static int avs_updown_mix_create(struct avs_dev *adev, struct avs_path_module *m cfg.base.audio_fmt = *t->in_fmt; cfg.out_channel_config = t->cfg_ext->updown_mix.out_channel_config; cfg.coefficients_select = t->cfg_ext->updown_mix.coefficients_select; -for (i =0 ; i <AVS_CHANNELS_MAX ; i++) +for (i =0 ; i <AVS_COEFF_CHANNELS_MAX ; i++) cfg.coefficients[i] = t->cfg_ext->updown_mix.coefficients[i]; cfg.channel_map = t->cfg_ext->updown_mix.channel_map;
sound/soc/intel/avs/topology.h +1 -1
@@ -87,7 +87,7 @@ struct avs_tplg_modcfg_ext {struct {u32 out_channel_config;u32 coefficients_select; -s32 coefficients[AVS_CHANNELS_MAX ]; +s32 coefficients[AVS_COEFF_CHANNELS_MAX ];u32 channel_map; } updown_mix;struct {
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 4/8 ASoC: Intel: avs: Allow for 16 channels configuration
In reply to Cezary RojewskiAdd define representing maximum number of channels that are allowed by HDAudio standard and as such supported by HW - 16 channels. With that done, reflect the max in BE DAIs capabilities.
--- sound/soc/intel/avs/messages.h | 1 + sound/soc/intel/avs/pcm.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-)
sound/soc/intel/avs/messages.h +1 -0
@@ -699,6 +699,7 @@ enum avs_sample_type {#define AVS_COEFF_CHANNELS_MAX 8#define AVS_ALL_CHANNELS_MASK UINT_MAX +#define AVS_CHANNELS_MAX 16struct avs_audio_format {u32 sampling_freq;
sound/soc/intel/avs/pcm.c +4 -4
@@ -1337,7 +1337,7 @@ static const struct snd_soc_dai_driver i2s_dai_template = { .ops = &avs_dai_nonhda_be_ops, .playback = { .channels_min = 1, - .channels_max = 8, + .channels_max = AVS_CHANNELS_MAX, .rates =SNDRV_PCM_RATE_8000_192000 |SNDRV_PCM_RATE_12000 | SNDRV_PCM_RATE_24000 |
@@ -1350,7 +1350,7 @@ static const struct snd_soc_dai_driver i2s_dai_template = { }, .capture = { .channels_min = 1, - .channels_max = 8, + .channels_max = AVS_CHANNELS_MAX, .rates =SNDRV_PCM_RATE_8000_192000 |SNDRV_PCM_RATE_12000 | SNDRV_PCM_RATE_24000 |
@@ -1431,7 +1431,7 @@ static const struct snd_soc_dai_driver hda_cpu_dai = { .ops = &avs_dai_hda_be_ops, .playback = { .channels_min = 1, - .channels_max = 8, + .channels_max = AVS_CHANNELS_MAX, .rates = SNDRV_PCM_RATE_8000_192000, .formats =SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
@@ -1441,7 +1441,7 @@ static const struct snd_soc_dai_driver hda_cpu_dai = { }, .capture = { .channels_min = 1, - .channels_max = 8, + .channels_max = AVS_CHANNELS_MAX, .rates = SNDRV_PCM_RATE_8000_192000, .formats =SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 5/8 ASoC: Intel: avs: Allow to specify custom configurations with i2s_test
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
Change 'i2s_test' module option from enable-flag to string allowing to specify which SSP port and in what TDM configuration should be enabled.
--- sound/soc/intel/avs/board_selection.c | 134 +++++++++++++------------- 1 file changed, 68 insertions(+), 66 deletions(-)
sound/soc/intel/avs/board_selection.c +68 -66
@@ -17,10 +17,11 @@#include <sound/soc-acpi.h> #include <sound/soc-component.h> #include "avs.h" +#include "utils.h" -static bool i2s_test; -module_param (i2s_test, bool,0444 ); -MODULE_PARM_DESC (i2s_test,"Probe I2S test-board and skip all other I2S boards" ); +static char *i2s_test; +module_param (i2s_test, charp,0444 ); +MODULE_PARM_DESC (i2s_test,"Use I2S test-board instead of ACPI, i2s_test=ssp0tdm,ssp1tdm,... 0 to ignore port" );static const struct dmi_system_id kbl_dmi_table[] = { {
@@ -324,52 +325,6 @@ static struct snd_soc_acpi_mach avs_mbl_i2s_machines[] = { {} }; -static struct snd_soc_acpi_mach avs_test_i2s_machines[] = { - { - .drv_name ="avs_i2s_test" , - .mach_params = { - .i2s_link_mask =AVS_SSP (0 ), - }, - .tplg_filename ="i2s-test-tplg.bin" , - }, - { - .drv_name ="avs_i2s_test" , - .mach_params = { - .i2s_link_mask =AVS_SSP (1 ), - }, - .tplg_filename ="i2s-test-tplg.bin" , - }, - { - .drv_name ="avs_i2s_test" , - .mach_params = { - .i2s_link_mask =AVS_SSP (2 ), - }, - .tplg_filename ="i2s-test-tplg.bin" , - }, - { - .drv_name ="avs_i2s_test" , - .mach_params = { - .i2s_link_mask =AVS_SSP (3 ), - }, - .tplg_filename ="i2s-test-tplg.bin" , - }, - { - .drv_name ="avs_i2s_test" , - .mach_params = { - .i2s_link_mask =AVS_SSP (4 ), - }, - .tplg_filename ="i2s-test-tplg.bin" , - }, - { - .drv_name ="avs_i2s_test" , - .mach_params = { - .i2s_link_mask =AVS_SSP (5 ), - }, - .tplg_filename ="i2s-test-tplg.bin" , - }, -/* no NULL terminator, as we depend on ARRAY SIZE due to .id == NULL */ -}; -struct avs_acpi_boards {int id;struct snd_soc_acpi_mach *machs;
@@ -529,6 +484,68 @@ static int avs_register_i2s_board(struct avs_dev *adev, struct snd_soc_acpi_machreturn 0 ; } +static int avs_register_i2s_test_board (struct avs_dev *adev,int ssp_port,int tdm_slot) +{ +struct snd_soc_acpi_mach *mach; +int tdm_mask =BIT (tdm_slot); +unsigned long *tdm_cfg; +char *tplg_name; +int ret; + + mach =devm_kzalloc (adev->dev,sizeof (*mach),GFP_KERNEL ); + tdm_cfg =devm_kcalloc (adev->dev, ssp_port +1 ,sizeof (unsigned long ),GFP_KERNEL ); + tplg_name =devm_kasprintf (adev->dev,GFP_KERNEL ,AVS_STRING_FMT ("i2s" ,"-test-tplg.bin" , + ssp_port, tdm_slot)); +if (!mach || !tdm_cfg || !tplg_name) +return -ENOMEM ; + + mach->drv_name ="avs_i2s_test" ; + mach->mach_params.i2s_link_mask =AVS_SSP (ssp_port); + tdm_cfg[ssp_port] = tdm_mask; + mach->pdata = tdm_cfg; + mach->tplg_filename = tplg_name; + + ret =avs_register_i2s_board (adev, mach); +if (ret <0 ) { +dev_warn (adev->dev,"register i2s %s failed: %d\n" , mach->drv_name, ret); +return ret; + } + +return 0 ; +} + +static int avs_register_i2s_test_boards (struct avs_dev *adev) +{ +int max_ssps = adev->hw_cfg.i2s_caps.ctrl_count; +int ssp_port, tdm_slot, ret; +unsigned long tdm_slots; +u32 *array, num_elems; + + ret =parse_int_array (i2s_test,strlen (i2s_test), (int **)&array); +if (ret <0 ) { +dev_err (adev->dev,"failed to parse i2s_test parameter\n" ); +return ret; + } + + num_elems = *array; +if (num_elems > max_ssps) { +dev_err (adev->dev,"board supports only %d SSP, %d specified\n" , + max_ssps, num_elems); +return -EINVAL ; + } + +for (ssp_port =0 ; ssp_port < num_elems; ssp_port++) { + tdm_slots = array[1 + ssp_port]; +for_each_set_bit (tdm_slot, &tdm_slots,16 ) { + ret =avs_register_i2s_test_board (adev, ssp_port, tdm_slot); +if (ret) +return ret; + } + } + +return 0 ; +} +static int avs_register_i2s_boards (struct avs_dev *adev) {const struct avs_acpi_boards *boards;
@@ -540,23 +557,8 @@ static int avs_register_i2s_boards(struct avs_dev *adev)return 0 ; } -if (i2s_test) { -int i, num_ssps; - - num_ssps = adev->hw_cfg.i2s_caps.ctrl_count; -/* constrain just in case FW says there can be more SSPs than possible */ - num_ssps =min_t (int,ARRAY_SIZE (avs_test_i2s_machines), num_ssps); - - mach = avs_test_i2s_machines; - -for (i =0 ; i < num_ssps; i++) { - ret =avs_register_i2s_board (adev, &mach[i]); -if (ret <0 ) -dev_warn (adev->dev,"register i2s %s failed: %d\n" , mach->drv_name, - ret); - } -return 0 ; - } +if (i2s_test) +return avs_register_i2s_test_boards (adev); boards =avs_get_i2s_boards (adev);if (!boards) {
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 6/8 ASoC: Intel: avs: Assign unique ID to platform devices
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
When creating machine boards there are two types, per endpoint or compound board. For compound board we can just use I2S mask as its ID, however, per endpoint can also be separated per TDM, which causes problem because two boards would have same I2S mask. Shift it and add the value of TDM to generate a unique ID.
--- sound/soc/intel/avs/board_selection.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/intel/avs/board_selection.c +7 -3
@@ -448,6 +448,7 @@ static int avs_register_i2s_board(struct avs_dev *adev, struct snd_soc_acpi_machint num_ssps;char *name;int ret; +int uid; num_ssps = adev->hw_cfg.i2s_caps.ctrl_count;if (fls (mach->mach_params.i2s_link_mask) > num_ssps) {
@@ -457,8 +458,11 @@ static int avs_register_i2s_board(struct avs_dev *adev, struct snd_soc_acpi_machreturn -ENODEV ; } - name =devm_kasprintf (adev->dev,GFP_KERNEL ,"%s.%d-platform" , mach->drv_name, - mach->mach_params.i2s_link_mask); + uid = mach->mach_params.i2s_link_mask; +if (avs_mach_singular_ssp (mach)) + uid = (uid <<AVS_CHANNELS_MAX ) +avs_mach_ssp_tdm (mach,avs_mach_ssp_port (mach)); + + name =devm_kasprintf (adev->dev,GFP_KERNEL ,"%s.%d-platform" , mach->drv_name, uid);if (!name)return -ENOMEM ;
@@ -468,7 +472,7 @@ static int avs_register_i2s_board(struct avs_dev *adev, struct snd_soc_acpi_mach mach->mach_params.platform = name; - board =platform_device_register_data (NULL , mach->drv_name, mach->mach_params.i2s_link_mask, + board =platform_device_register_data (NULL , mach->drv_name, uid, (const void *)mach,sizeof (*mach));if (IS_ERR (board)) {dev_err (adev->dev,"ssp board register failed\n" );
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 7/8 ASoC: Intel: avs: Iterate over correct number of TDMs
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
When handling TDMs, don't iterate over number of SSP ports, but over possible number of TDMs.
--- sound/soc/intel/avs/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/avs/pcm.c +1 -1
@@ -1406,7 +1406,7 @@ int avs_i2s_platform_register(struct avs_dev *adev, const char *name, unsigned l goto plat_register;for_each_set_bit (i, &port_mask, ssp_count) { -for_each_set_bit (j, &tdms[i], ssp_count) { +for_each_set_bit (j, &tdms[i],AVS_CHANNELS_MAX ) {memcpy (dai, &i2s_dai_template,sizeof (*dai)); dai->name =
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 8/8 ASoC: Intel: avs: Support 16 TDMs in dynamic assignment
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
When assigning new widget name there needs to be enough place in buffer to assign name.
--- sound/soc/intel/avs/topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/intel/avs/topology.c +2 -2
@@ -1668,8 +1668,8 @@ static int avs_widget_load(struct snd_soc_component *comp, int index,/* See parse_link_formatted_string() for dynamic naming when(s). */ if (avs_mach_singular_tdm (mach, ssp_port)) { -/* size is based on possible %d -> SSP:TDM, where SSP and TDM < 10 + '\0' */ -size_t size =strlen (dw->name) +2 ; +/* size is based on possible %d -> SSP:TDM, where SSP and TDM < 16 + '\0' */ +size_t size =strlen (dw->name) +3 ;char *buf; tdm_slot =avs_mach_ssp_tdm (mach, ssp_port);
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 8 lines · Cezary Rojewski
Relatively small delta-wise patchset which raises max channels supported from 8 to 16. The existing limitation is software-based, not hardware based. The hardware, as per HDAudio specification, section 1.2.2, (relevant register at SDnFMT, section 3.3.41) supports the configurations for years. The avs-driver becomes the first consumer of that configuration on the Linux kernel side.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/8] lib/string_helpers: Introduce parse_int_array()
commit: 83b9ae77f06607d19f7d3dcc6008742051137b27
[2/8] ALSA: hda: Allow for 16 channels configuration
commit: e6b9c7f5a32b3bde4e24ee74c0d4f954ce086272
[3/8] ASoC: Intel: avs: Rename AVS_CHANNELS_MAX define
commit: 87bcb08710160bde5712ca0d24c505074b7dfafa
[4/8] ASoC: Intel: avs: Allow for 16 channels configuration
commit: d360b713727db0093fe9a8cf475d1d536075c12f
[5/8] ASoC: Intel: avs: Allow to specify custom configurations with i2s_test
commit: 7d859189de13f06fdc511761c745f3b302bed7b6
[6/8] ASoC: Intel: avs: Assign unique ID to platform devices
commit: 79138dbff53ab0e9891ebdfce8d7b298c3783cd1
[7/8] ASoC: Intel: avs: Iterate over correct number of TDMs
commit: 6a68cbe09e9a7dc9f53857510bee1bc34bdbbfd9
[8/8] ASoC: Intel: avs: Support 16 TDMs in dynamic assignment
commit: 8d18e67abbdf380cd1cfd2c313aac625092d7777All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark