ALSA: pcm: Introduce MSBITS subformat API extension
Jaroslav Kysela
maintainerRFC PATCH 1/1 ALSA: pcm: Introduce MSBITS subformat API extension
Improve granularity of format selection for linear formats by adding constants representing MAX, 20, 24 most significant bits.
The MAX means the maximum number of significant bits which can the physical format hold. For 32-bit formats, MAX is related to 32 bits. For 8-bit formats, MAX is related to 8 bits etc.
The drivers may use snd_pcm_hw_constraint_subformats with a simple format -> subformats table.
--- include/sound/pcm.h | 17 +++++++++ include/uapi/sound/asound.h | 7 ++-- sound/core/pcm_lib.c | 59 +++++++++++++++++++++++++++++++ sound/core/pcm_native.c | 18 +++++++--- tools/include/uapi/sound/asound.h | 7 ++-- 5 files changed, 100 insertions(+), 8 deletions(-)
include/sound/pcm.h +17 -0
@@ -217,6 +217,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_MAX _SNDRV_PCM_SUBFMTBIT(MSBITS_MAX) +#define SNDRV_PCM_SUBFMTBIT_MSBITS_20 _SNDRV_PCM_SUBFMTBIT(MSBITS_20) +#define SNDRV_PCM_SUBFMTBIT_MSBITS_24 _SNDRV_PCM_SUBFMTBIT(MSBITS_24) +struct snd_pcm_file {struct snd_pcm_substream *substream;int no_compat_mmap;
@@ -290,6 +296,13 @@ struct snd_pcm_hw_constraint_ranges {unsigned int mask; }; +#define SNDRV_PCM_FORMAT_CONSTRAINT_END (~0) + +struct snd_pcm_hw_constraint_subformat { +snd_pcm_format_t format;/* SNDRV_PCM_FORMAT_* */ +u32 subformats;/* SNDRV_PCM_SUBFMTBIT_* */ +}; +/* * userspace-provided audio timestamp config to kernel, * structure is for internal use only and filled with dedicated unpack routine
@@ -375,6 +388,7 @@ struct snd_pcm_runtime {unsigned int rate_num;unsigned int rate_den; unsigned int no_period_wakeup: 1; + unsigned int subformat_constraint: 1;/* -- SW params; see struct snd_pcm_sw_params for comments -- */ int tstamp_mode;
@@ -1068,6 +1082,9 @@ int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime,unsigned int cond, snd_pcm_hw_param_t var, const struct snd_pcm_hw_constraint_ratdens *r); +int snd_pcm_hw_constraint_subformats (struct snd_pcm_runtime *runtime, +unsigned int cond, +struct snd_pcm_hw_constraint_subformat *subformats); int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, unsigned int cond, unsigned int width,
include/uapi/sound/asound.h +5 -2
@@ -142,7 +142,7 @@ struct snd_hwdep_dsp_image {* * *****************************************************************************/ -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 15) +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 16)typedef unsigned long snd_pcm_uframes_t ;typedef signed long snd_pcm_sframes_t ;
@@ -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_MAX ((__force snd_pcm_subformat_t) 1) +#define SNDRV_PCM_SUBFORMAT_MSBITS_20 ((__force snd_pcm_subformat_t) 2) +#define SNDRV_PCM_SUBFORMAT_MSBITS_24 ((__force snd_pcm_subformat_t) 3) +#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_MSBITS_24#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_lib.c +59 -0
65 lines not on this page · raw message
sound/core/pcm_native.c +14 -4
@@ -479,6 +479,7 @@ static int fixup_unreferenced_params(struct snd_pcm_substream *substream, {const struct snd_interval *i;const struct snd_mask *m; +struct snd_mask *m_rw;int err;if (!params->msbits) {
@@ -487,6 +488,14 @@ static int fixup_unreferenced_params(struct snd_pcm_substream *substream, params->msbits =snd_interval_value (i); } +if (params->msbits) { + m =hw_param_mask_c (params,SNDRV_PCM_HW_PARAM_FORMAT ); +if (snd_mask_single (m) &&snd_pcm_format_width (snd_mask_min (m)) != params->msbits) { + m_rw =hw_param_mask (params,SNDRV_PCM_HW_PARAM_SUBFORMAT ); +snd_mask_reset (m_rw, (__force unsigned )SNDRV_PCM_SUBFORMAT_MSBITS_MAX ); + } + } +if (!params->rate_den) { i =hw_param_interval_c (params,SNDRV_PCM_HW_PARAM_RATE );if (snd_interval_single (i)) {
@@ -2634,10 +2643,11 @@ 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 )); -if (err <0 ) -return err; +if (!runtime->subformat_constraint) { + err =snd_pcm_hw_constraint_subformats (runtime,0 ,NULL ); +if (err <0 ) +return err; + } err =snd_pcm_hw_constraint_minmax (runtime,SNDRV_PCM_HW_PARAM_CHANNELS , hw->channels_min, hw->channels_max);
tools/include/uapi/sound/asound.h +5 -2
@@ -142,7 +142,7 @@ struct snd_hwdep_dsp_image {* * *****************************************************************************/ -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 15) +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 16)typedef unsigned long snd_pcm_uframes_t ;typedef signed long snd_pcm_sframes_t ;
@@ -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_MAX ((__force snd_pcm_subformat_t) 1) +#define SNDRV_PCM_SUBFORMAT_MSBITS_20 ((__force snd_pcm_subformat_t) 2) +#define SNDRV_PCM_SUBFORMAT_MSBITS_24 ((__force snd_pcm_subformat_t) 3) +#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_MSBITS_24#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.41.0
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Jaroslav,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on tiwai-sound/for-linus linus/master v6.6-rc1 next-20230912] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jaroslav-Kysela/ALSA-pcm-Introduce-MSBITS-subformat-API-extension/20230913-003409 base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next patch link: https://lore.kernel.org/r/20230912162526.7138-1-perex%40perex.cz patch subject: [RFC PATCH] ALSA: pcm: Introduce MSBITS subformat API extension config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230913/[email protected]/config) compiler: m68k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> sound/core/pcm_lib.c:1451: warning: Excess function parameter 'nmemd' description in 'snd_pcm_hw_constraint_subformats'
vim +1451 sound/core/pcm_lib.c
1434
1435 /**
1436 * snd_pcm_hw_constraint_subformats - add a hw constraint subformats rule
1437 * @runtime: PCM runtime instance
1438 * @cond: condition bits
1439 * @subformats: array with struct snd_pcm_subformat elements
1440 * @nmemd: size of array with struct snd_pcm_subformat elements
1441 *
1442 * This constraint will set relation between format and subformats.
1443 * The STD and MAX subformats are handled automatically. If the driver
1444 * does not set this constraint, only STD and MAX subformats are handled.
1445 *
1446 * Return: Zero if successful, or a negative error code on failure.
1447 */
1448 int snd_pcm_hw_constraint_subformats(struct snd_pcm_runtime *runtime,
1449 unsigned int cond,
1450 struct snd_pcm_hw_constraint_subformat *subformats)
> 1451 {
1452 int ret;
1453
1454 ret = snd_pcm_hw_rule_add(runtime, cond, -1,
1455 snd_pcm_hw_rule_subformats,
1456 (void*) subformats,
1457 SNDRV_PCM_HW_PARAM_SUBFORMAT,
1458 SNDRV_PCM_HW_PARAM_FORMAT, -1); 1459 if (ret < 0)
1460 return ret;
1461 runtime->subformat_constraint = 1;
1462 return 0;
1463 }
1464 EXPORT_SYMBOL(snd_pcm_hw_constraint_subformats);
1465
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Jaroslav,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on tiwai-sound/for-linus linus/master v6.6-rc1 next-20230913] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jaroslav-Kysela/ALSA-pcm-Introduce-MSBITS-subformat-API-extension/20230913-003409 base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next patch link: https://lore.kernel.org/r/20230912162526.7138-1-perex%40perex.cz patch subject: [RFC PATCH] ALSA: pcm: Introduce MSBITS subformat API extension config: i386-randconfig-063-20230913 (https://download.01.org/0day-ci/archive/20230913/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230913/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> sound/core/pcm_native.c:493:76: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected restricted snd_pcm_format_t [usertype] format @@ got unsigned int @@
sound/core/pcm_native.c:493:76: sparse: expected restricted snd_pcm_format_t [usertype] format
sound/core/pcm_native.c:493:76: sparse: got unsigned int
sound/core/pcm_native.c:95:1: sparse: sparse: context imbalance in 'snd_pcm_group_lock' - different lock contexts for basic block sound/core/pcm_native.c:96:1: sparse: sparse: context imbalance in 'snd_pcm_group_unlock' - unexpected unlock sound/core/pcm_native.c:97:1: sparse: sparse: context imbalance in 'snd_pcm_group_lock_irq' - different lock contexts for basic block sound/core/pcm_native.c:98:1: sparse: sparse: context imbalance in 'snd_pcm_group_unlock_irq' - unexpected unlock sound/core/pcm_native.c:145:9: sparse: sparse: context imbalance in 'snd_pcm_stream_lock_nested' - different lock contexts for basic block sound/core/pcm_native.c:171:9: sparse: sparse: context imbalance in '_snd_pcm_stream_lock_irqsave' - different lock contexts for basic block sound/core/pcm_native.c:184:9: sparse: sparse: context imbalance in '_snd_pcm_stream_lock_irqsave_nested' - different lock contexts for basic block sound/core/pcm_native.c:201:39: sparse: sparse: context imbalance in 'snd_pcm_stream_unlock_irqrestore' - unexpected unlock sound/core/pcm_native.c:1270:44: sparse: sparse: context imbalance in 'snd_pcm_action_group' - unexpected unlock sound/core/pcm_native.c:1340:37: sparse: sparse: context imbalance in 'snd_pcm_stream_group_ref' - different lock contexts for basic block
--
>> sound/core/pcm_lib.c:1419:43: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int val @@ got restricted snd_pcm_format_t [assigned] [usertype] k @@ sound/core/pcm_lib.c:1419:43: sparse: expected unsigned int val sound/core/pcm_lib.c:1419:43: sparse: got restricted snd_pcm_format_t [assigned] [usertype] k >> sound/core/pcm_lib.c:1422:50: sparse: sparse: restricted snd_pcm_format_t degrades to integer
vim +493 sound/core/pcm_native.c
476
477 static int fixup_unreferenced_params(struct snd_pcm_substream *substream,
478 struct snd_pcm_hw_params *params)
479 {
480 const struct snd_interval *i;
481 const struct snd_mask *m;
482 struct snd_mask *m_rw;
483 int err;
484
485 if (!params->msbits) {
486 i = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS);
487 if (snd_interval_single(i))
488 params->msbits = snd_interval_value(i);
489 }
490
491 if (params->msbits) {
492 m = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT);
> 493 if (snd_mask_single(m) && snd_pcm_format_width(snd_mask_min(m)) != params->msbits) { 494 m_rw = hw_param_mask(params, SNDRV_PCM_HW_PARAM_SUBFORMAT);
495 snd_mask_reset(m_rw, (__force unsigned)SNDRV_PCM_SUBFORMAT_MSBITS_MAX);
496 }
497 }
498
499 if (!params->rate_den) {
500 i = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_RATE);
501 if (snd_interval_single(i)) {
502 params->rate_num = snd_interval_value(i);
503 params->rate_den = 1;
504 }
505 }
506
507 if (!params->fifo_size) {
508 m = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT);
509 i = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS);
510 if (snd_mask_single(m) && snd_interval_single(i)) {
511 err = snd_pcm_ops_ioctl(substream,
512 SNDRV_PCM_IOCTL1_FIFO_SIZE,
513 params);
514 if (err < 0)
515 return err;
516 }
517 }
518
519 if (!params->info) {
520 params->info = substream->runtime->hw.info;
521 params->info &= ~(SNDRV_PCM_INFO_FIFO_IN_FRAMES |
522 SNDRV_PCM_INFO_DRAIN_TRIGGER);
523 if (!hw_support_mmap(substream))
524 params->info &= ~(SNDRV_PCM_INFO_MMAP |
525 SNDRV_PCM_INFO_MMAP_VALID);
526 }
527
528 return 0;
529 }
530
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 9 lines · Jaroslav Kysela
Improve granularity of format selection for linear formats by adding constants representing MAX, 20, 24 most significant bits.
The MAX means the maximum number of significant bits which can the physical format hold. For 32-bit formats, MAX is related to 32 bits. For 8-bit formats, MAX is related to 8 bits etc.
The drivers may use
snd_pcm_hw_constraint_subformatswith a simple format -> subformats table.
The code looks good overall. I have few comments and nitpicks regarding readability - comes from person who recently was digging through hw_rule and related code and found themselves lost. Examples such as this patch are good how-to references in hw_rule world.
-
The message lacks reference to the original patchset. I'd suggest to have it here. Either that or incorporate it directly into the patchset. And I must admit I'm a bit surprised by the lack of few CCs when compared to the original subject.
Quoted 28 lines
Cc Cezary Rojewski <[email protected]>Signed-off-by Jaroslav Kysela <[email protected]>--- include/sound/pcm.h | 17 +++++++++ include/uapi/sound/asound.h | 7 ++-- sound/core/pcm_lib.c | 59 +++++++++++++++++++++++++++++++ sound/core/pcm_native.c | 18 +++++++--- tools/include/uapi/sound/asound.h | 7 ++-- 5 files changed, 100 insertions(+), 8 deletions(-)include/sound/pcm.h +6
-0@@ -217,6 +217,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_MAX _SNDRV_PCM_SUBFMTBIT(MSBITS_MAX) +#define SNDRV_PCM_SUBFMTBIT_MSBITS_20 _SNDRV_PCM_SUBFMTBIT(MSBITS_20) +#define SNDRV_PCM_SUBFMTBIT_MSBITS_24 _SNDRV_PCM_SUBFMTBIT(MSBITS_24) +struct snd_pcm_file {struct snd_pcm_substream *substream;int no_compat_mmap;
include/sound/pcm.h struct snd_pcm_hw_constraint_ranges { · line 303
Quoted 8 lines
include/sound/pcm.h +5
-0@@ -290,6 +296,13 @@ struct snd_pcm_hw_constraint_ranges {unsigned int mask; }; +#define SNDRV_PCM_FORMAT_CONSTRAINT_END (~0) + +struct snd_pcm_hw_constraint_subformat { +snd_pcm_format_t format;/* SNDRV_PCM_FORMAT_* */ +u32 subformats;/* SNDRV_PCM_SUBFMTBIT_* */
From what I know, we are dealing with u64 masks here. Why u32 here?
Quoted 23 lines
include/sound/pcm.h +6
-0+}; +/* * userspace-provided audio timestamp config to kernel, * structure is for internal use only and filled with dedicated unpack routine @@ -375,6 +388,7 @@ struct snd_pcm_runtime {unsigned int rate_num;unsigned int rate_den; unsigned int no_period_wakeup: 1; + unsigned int subformat_constraint: 1;/* -- SW params; see struct snd_pcm_sw_params for comments -- */ int tstamp_mode;@@ -1068,6 +1082,9 @@ int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime,unsigned int cond, snd_pcm_hw_param_t var, const struct snd_pcm_hw_constraint_ratdens *r); +int snd_pcm_hw_constraint_subformats (struct snd_pcm_runtime *runtime, +unsigned int cond, +struct snd_pcm_hw_constraint_subformat *subformats); int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, unsigned int cond, unsigned int width,
...
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1410
Quoted 12 lines
sound/core/pcm_lib.c +4
-0@@ -1404,6 +1404,65 @@ int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, }EXPORT_SYMBOL (snd_pcm_hw_constraint_ratdens); +static int snd_pcm_hw_rule_subformats (struct snd_pcm_hw_params *params, +struct snd_pcm_hw_rule *rule) +{ +const struct snd_pcm_hw_constraint_subformat *sf;
What's 'sf'? I'd suggest to be more descriptive here.
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1411
Quoted 1 line
sound/core/pcm_lib.c +1
-0+snd_pcm_format_t k;
Internally I was utilizing 'f' as that's what macro expects in its declaration. s/k/f/
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1414
Quoted 3 lines
sound/core/pcm_lib.c +3
-0+struct snd_mask m; +struct snd_mask *fmask =hw_param_mask (params,SNDRV_PCM_HW_PARAM_FORMAT ); +struct snd_mask *mask =hw_param_mask (params,SNDRV_PCM_HW_PARAM_SUBFORMAT );
So, the reason I opted for 'subformat_mask' and 'format_mask' is that otherwise reader is crowded with ambiguous 'mask' and its relatives. I'd
avoid shortcuts when multiple variables touch the same subject.
s/fmask/format_mask/
s/mask/subformat_mask/
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1417
Quoted 3 lines
sound/core/pcm_lib.c +3
-0+snd_mask_none (&m); +snd_mask_set (&m, (__force unsigned )SNDRV_PCM_SUBFORMAT_STD ); +bool found;
Suggestion is to add newline before declaration and execution blocks. Also, why not reserve-christmass-tree model? There quite a few variables here.
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1420
Quoted 3 lines
sound/core/pcm_lib.c +3
-0+pcm_for_each_format (k) { +if (!snd_mask_test (fmask, k)) +continue ;
Similarly here. A newline would effectively separate conditional for-loop from the actual execution block.
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1429
Quoted 9 lines
sound/core/pcm_lib.c +9
-0+ found = false; +for (sf = rule->private; sf && sf->format !=SNDRV_PCM_FORMAT_CONSTRAINT_END ; sf++) { +if (sf->format != k) +continue ; + found = true; + m.bits[0 ] |= sf->subformats; +break ; + } +if (!found &&snd_pcm_format_linear (k))
For my own education, why checking if format is linear is essential here? Perhaps a comment?
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1442
Quoted 13 lines
sound/core/pcm_lib.c +13
-0+snd_mask_set (&m, (__force unsigned )SNDRV_PCM_SUBFORMAT_MSBITS_MAX ); + } +return snd_mask_refine (mask, &m); +} + +/** +* snd_pcm_hw_constraint_subformats - add a hw constraint subformats rule +* @runtime: PCM runtime instance +* @cond: condition bits +* @subformats: array with struct snd_pcm_subformat elements +* @nmemd: size of array with struct snd_pcm_subformat elements +* +* This constraint will set relation between format and subformats.
I do not believe 'This constaint' brings any value. Reader is already aware of it. Starting from the 'Set' part brings the same value with fewer words.
Quoted 31 lines
sound/core/pcm_lib.c +23
-0+* The STD and MAX subformats are handled automatically. If the driver +* does not set this constraint, only STD and MAX subformats are handled. +* +* Return: Zero if successful, or a negative error code on failure. +*/ +int snd_pcm_hw_constraint_subformats (struct snd_pcm_runtime *runtime, +unsigned int cond, +struct snd_pcm_hw_constraint_subformat *subformats) +{ +int ret; + + ret =snd_pcm_hw_rule_add (runtime, cond,-1 , + snd_pcm_hw_rule_subformats, + (void *) subformats, +SNDRV_PCM_HW_PARAM_SUBFORMAT , +SNDRV_PCM_HW_PARAM_FORMAT ,-1 ); +if (ret <0 ) +return ret; + runtime->subformat_constraint =1 ; +return 0 ; +} +EXPORT_SYMBOL (snd_pcm_hw_constraint_subformats); +static int snd_pcm_hw_rule_msbits (struct snd_pcm_hw_params *params,struct snd_pcm_hw_rule *rule) {sound/core/pcm_native.c +0
-0
sound/core/pcm_native.c static int fixup_unreferenced_params(struct snd_pcm_substream *substream, · line 482
Quoted 4 lines
sound/core/pcm_native.c +1
-0@@ -479,6 +479,7 @@ static int fixup_unreferenced_params(struct snd_pcm_substream *substream, {const struct snd_interval *i;const struct snd_mask *m; +struct snd_mask *m_rw;
Two masks named 'm' and 'm_rw' is confusing in my opinion. The 'm_rw' is used only in subformat case so the name could be more descriptive.
Quoted 19 lines
sound/core/pcm_native.c +8
-0int err;if (!params->msbits) {@@ -487,6 +488,14 @@ static int fixup_unreferenced_params(struct snd_pcm_substream *substream, params->msbits =snd_interval_value (i); } +if (params->msbits) { + m =hw_param_mask_c (params,SNDRV_PCM_HW_PARAM_FORMAT ); +if (snd_mask_single (m) &&snd_pcm_format_width (snd_mask_min (m)) != params->msbits) { + m_rw =hw_param_mask (params,SNDRV_PCM_HW_PARAM_SUBFORMAT ); +snd_mask_reset (m_rw, (__force unsigned )SNDRV_PCM_SUBFORMAT_MSBITS_MAX ); + } + } +if (!params->rate_den) { i =hw_param_interval_c (params,SNDRV_PCM_HW_PARAM_RATE );if (snd_interval_single (i)) {
sound/core/pcm_native.c static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) · line 2646
Quoted 8 lines
sound/core/pcm_native.c +1
-4@@ -2634,10 +2643,11 @@ 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 )); -if (err <0 ) -return err; +if (!runtime->subformat_constraint) {
I'd try to avoid another special-bit in the runtime space. But I might be wrong here and it's unavoidable. Let me ask though, why cannot we do the constraint unconditionally?
Quoted 7 lines
sound/core/pcm_native.c +4
-0+ err =snd_pcm_hw_constraint_subformats (runtime,0 ,NULL ); +if (err <0 ) +return err; + } err =snd_pcm_hw_constraint_minmax (runtime,SNDRV_PCM_HW_PARAM_CHANNELS , hw->channels_min, hw->channels_max);
Jaroslav Kysela
maintainerQuoted 5 lines · Cezary Rojewski
include/sound/pcm.h struct snd_pcm_hw_constraint_ranges { · line 303
Quoted 3 lines
include/sound/pcm.h +3
-0+struct snd_pcm_hw_constraint_subformat { +snd_pcm_format_t format;/* SNDRV_PCM_FORMAT_* */ +u32 subformats;/* SNDRV_PCM_SUBFMTBIT_* */ From what I know, we are dealing with u64 masks here. Why u32 here?
It's not true. See the removed code which calls snd_pcm_hw_constraint_mask() for SNDRV_PCM_HW_PARAM_SUBFORMAT. Only the format is handled for 64 bits and the handling of other bits is purely optional, because masks can handle up to 256 bits:
#define SNDRV_MASK_MAX 256
struct snd_mask {
__u32 bits[(SNDRV_MASK_MAX+31)/32];
};Because we used only few bits for SUBFORMAT, the 32 bit code is enough. We can expand this latter without any impact to the user space interface.
Quoted 6 lines
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1410
Quoted 4 lines
sound/core/pcm_lib.c +4
-0+static int snd_pcm_hw_rule_subformats (struct snd_pcm_hw_params *params, +struct snd_pcm_hw_rule *rule) +{ +const struct snd_pcm_hw_constraint_subformat *sf;What's 'sf'? I'd suggest to be more descriptive here.
SubFormat. The larger name will not make the for loop more readable. The function is small, so reader is not lost.
Quoted 4 lines
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1411
Quoted 1 line
sound/core/pcm_lib.c +1
-0+snd_pcm_format_t k;Internally I was utilizing 'f' as that's what macro expects in its declaration. s/k/f/
Copied from pcm_native.c - snd_pcm_hw_rule_format().
Quoted 10 lines
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1414
Quoted 3 lines
sound/core/pcm_lib.c +3
-0+struct snd_mask m; +struct snd_mask *fmask =hw_param_mask (params,SNDRV_PCM_HW_PARAM_FORMAT ); +struct snd_mask *mask =hw_param_mask (params,SNDRV_PCM_HW_PARAM_SUBFORMAT );So, the reason I opted for '
subformat_mask' and 'format_mask' is that otherwise reader is crowded with ambiguous 'mask' and its relatives. I'd
avoid shortcuts when multiple variables touch the same subject.s/fmask/format_mask/
s/mask/subformat_mask/
Too long, the function is small.
Quoted 7 lines
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1417
Quoted 3 lines
sound/core/pcm_lib.c +3
-0+snd_mask_none (&m); +snd_mask_set (&m, (__force unsigned )SNDRV_PCM_SUBFORMAT_STD ); +bool found;Suggestion is to add newline before declaration and execution blocks. Also, why not reserve-christmass-tree model? There quite a few variables here.
Yes it should be shuffled.
Quoted 6 lines
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1420
Quoted 3 lines
sound/core/pcm_lib.c +3
-0+pcm_for_each_format (k) { +if (!snd_mask_test (fmask, k)) +continue ;Similarly here. A newline would effectively separate conditional for-loop from the actual execution block.
It's questionable.
Quoted 4 lines
Quoted 4 lines
sound/core/pcm_lib.c +4
-0+ found = false; +for (sf = rule->private; sf && sf->format !=SNDRV_PCM_FORMAT_CONSTRAINT_END ; sf++) { +if (sf->format != k) +continue ;
Quoted 8 lines
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1429
Quoted 5 lines
sound/core/pcm_lib.c +5
-0+ found = true; + m.bits[0 ] |= sf->subformats; +break ; + } +if (!found &&snd_pcm_format_linear (k))For my own education, why checking if format is linear is essential here? Perhaps a comment?
Subformat MSBITS are valid only for linear formats, aren't? It does not make sense to set MAX for other formats.
Quoted 9 lines
Quoted 9 lines
sound/core/pcm_lib.c +9
-0+snd_mask_set (&m, (__force unsigned )SNDRV_PCM_SUBFORMAT_MSBITS_MAX ); + } +return snd_mask_refine (mask, &m); +} + +/** +* snd_pcm_hw_constraint_subformats - add a hw constraint subformats rule +* @runtime: PCM runtime instance +* @cond: condition bits
Quoted 8 lines
Quoted 4 lines
+ * @subformats: array with struct
snd_pcm_subformatelements
+ * @nmemd: size of array with structsnd_pcm_subformatelements
+ *
+ * This constraint will set relation between format and subformats.I do not believe 'This constaint' brings any value. Reader is already aware of it. Starting from the 'Set' part brings the same value with fewer words.
Copied from snd_pcm_hw_constraint_msbits function.
Quoted 9 lines
Quoted 9 lines
+ * The STD and MAX subformats are handled automatically. If the driver
+ * does not set this constraint, only STD and MAX subformats are handled.
+ *
+ * Return: Zero if successful, or a negative error code on failure.
+ */sound/core/pcm_lib.c +4
-0+int snd_pcm_hw_constraint_subformats (struct snd_pcm_runtime *runtime, +unsigned int cond, +struct snd_pcm_hw_constraint_subformat *subformats) +{
...
Quoted 9 lines
sound/core/pcm_native.c static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) · line 2646
Quoted 5 lines
sound/core/pcm_native.c +1
-4- err =snd_pcm_hw_constraint_mask (runtime,SNDRV_PCM_HW_PARAM_SUBFORMAT , -PARAM_MASK_BIT (SNDRV_PCM_SUBFORMAT_STD )); -if (err <0 ) -return err; +if (!runtime->subformat_constraint) {I'd try to avoid another special-bit in the runtime space. But I might be wrong here and it's unavoidable. Let me ask though, why cannot we do the constraint unconditionally?
This is for a special case when the drivers do not set snd_pcm_hw_constraint_subformats (all current drivers). In this case, the default is to handle STD and MAX subformat bits.
This constraint should be applied only one time. So this prevents to install it twice.
I'll send v2 to address some things from this discussion and kernel test robot.
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Quoted 10 lines · Jaroslav Kysela
Quoted 5 lines · Cezary Rojewski
Quoted 3 lines
+struct
snd_pcm_hw_constraint_subformat{
+snd_pcm_format_tformat; /* SNDRV_PCM_FORMAT_* */ + u32 subformats; /* SNDRV_PCM_SUBFMTBIT_* */From what I know, we are dealing with u64 masks here. Why u32 here?
It's not true. See the removed code which calls
snd_pcm_hw_constraint_mask()forSNDRV_PCM_HW_PARAM_SUBFORMAT. Only the format is handled for 64 bits and the handling of other bits is purely optional, because masks can handle up to 256 bits:
Quoted 7 lines
#define SNDRV_MASK_MAX 256
struct
snd_mask{
__u32bits[(SNDRV_MASK_MAX+31)/32];
};Because we used only few bits for SUBFORMAT, the 32 bit code is enough. We can expand this latter without any impact to the user space interface.
Thanks for explaining. I must admit that this "balance" is confusing though - up to 256 bits are supported, yet depending on the use-case, size is lowered for optimization reasons.
Quoted 8 lines
Quoted 6 lines
sound/core/pcm_lib.c int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, · line 1410
Quoted 4 lines
sound/core/pcm_lib.c +4
-0+static int snd_pcm_hw_rule_subformats (struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) +{ + const struct snd_pcm_hw_constraint_subformat *sf;What's 'sf'? I'd suggest to be more descriptive here.
SubFormat. The larger name will not make the for loop more readable. The function is small, so reader is not lost.
Decided to do a "mix" of shortcuts and explicitness - fmask for format-mask, sfmask for subformat-mask and sf for cursor variable.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
+
snd_pcm_format_tk;Internally I was utilizing 'f' as that's what macro expects in its declaration. s/k/f/
Copied from
pcm_native.c-snd_pcm_hw_rule_format().
I understand but this is not a technical argument. It's clearly more informative and cohesive to utilize 'f' in place of 'k'. The aforementioned function should be updated in the future too.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
+ struct
snd_maskm;
+ structsnd_mask*fmask =hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
+ structsnd_mask*mask =hw_param_mask(params, SNDRV_PCM_HW_PARAM_SUBFORMAT);
Quoted 8 lines
Quoted 6 lines
So, the reason I opted for '
subformat_mask' and 'format_mask' is that otherwise reader is crowded with ambiguous 'mask' and its relatives. I'd avoid shortcuts when multiple variables touch the same subject.s/fmask/format_mask/
s/mask/subformat_mask/Too long, the function is small.
As mentioned above, decided to do a mix instead of ignoring completely. I value readability much, and I believe many on the list value it too. The combination of m+mask+fmask is confusing at best.
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
+
snd_mask_none(&m);
+snd_mask_set(&m, (__force unsigned)SNDRV_PCM_SUBFORMAT_STD); + bool found;Suggestion is to add newline before declaration and execution blocks. Also, why not reserve-christmass-tree model? There quite a few variables here.
Yes it should be shuffled.
Ack and addressed in the v2 series.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
+
pcm_for_each_format(k){
+ if (!snd_mask_test(fmask, k))
+ continue;Similarly here. A newline would effectively separate conditional for-loop from the actual execution block.
It's questionable.
A so-called blob of text should be avoided. This is not a trivial part of the code. Least we can do is flesh it out a bit plus provide a more self-explanatory variable names.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
+ found = false;
+ for (sf =rule->private; sf &&sf->format!=SNDRV_PCM_FORMAT_CONSTRAINT_END; sf++) {
+ if (sf->format!= k)
+ continue;
+ found = true;
+ m.bits[0] |=sf->subformats;
+ break;
+ }
+ if (!found &&snd_pcm_format_linear(k))
Quoted 4 lines
Quoted 2 lines
For my own education, why checking if format is linear is essential here? Perhaps a comment?
Subformat MSBITS are valid only for linear formats, aren't? It does not make sense to set MAX for other formats.
I cannot deduce any comment-to-add from this, so opted-out of adding any comment.
Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
+ snd_mask_set(&m, (
__force
unsigned)SNDRV_PCM_SUBFORMAT_MSBITS_MAX);
+ }
+ returnsnd_mask_refine(mask, &m);sound/core/pcm_lib.c +4
-0+} + +/** +* snd_pcm_hw_constraint_subformats - add a hw constraint subformats rule
+ * @runtime: PCM runtime instance
+ * @cond: condition bitsQuoted 8 lines
Quoted 4 lines
+ * @subformats: array with struct
snd_pcm_subformatelements
+ * @nmemd: size of array with structsnd_pcm_subformatelements
+ *
+ * This constraint will set relation between format and subformats.I do not believe 'This constaint' brings any value. Reader is already aware of it. Starting from the 'Set' part brings the same value with fewer words.
Quoted 1 line
Copied from
snd_pcm_hw_constraint_msbitsfunction.
Again, I do understand the origin of this, but this is not a technical argument - if something can be improved even when copying, we should do so.
Quoted 21 lines
Quoted 11 lines
Quoted 11 lines
+ * The STD and MAX subformats are handled automatically. If the driver
+ * does not set this constraint, only STD and MAX subformats are handled.
+ *
+ * Return: Zero if successful, or a negative error code on failure.
+ */
+int snd_pcm_hw_constraint_subformats(structsnd_pcm_runtime*runtime, + unsigned int cond,
+ structsnd_pcm_hw_constraint_subformat*subformats)
+{...
Quoted 7 lines
Quoted 6 lines
- err = snd_pcm_hw_constraint_mask(runtime,
SNDRV_PCM_HW_PARAM_SUBFORMAT,
-PARAM_MASK_BIT(SNDRV_PCM_SUBFORMAT_STD)); - if (err < 0)
- return err;
+ if (!runtime->subformat_constraint) {
Quoted 7 lines
Quoted 3 lines
I'd try to avoid another special-bit in the runtime space. But I might be wrong here and it's unavoidable. Let me ask though, why cannot we do the constraint unconditionally?
This is for a special case when the drivers do not set
snd_pcm_hw_constraint_subformats(all current drivers). In this case, the default is to handle STD and MAX subformat bits.This constraint should be applied only one time. So this prevents to install it twice.
I believe we could avoid special-case approach. Have a copy/intersection helpers in place and utilize iterations-with-sentinel-entry. Provided such in v2 of my series.
Quoted 1 line
I'll send v2 to address some things from this discussion and kernel test robot.
Jaroslav Kysela
maintainerQuoted 10 lines · Cezary Rojewski
Quoted 10 lines
Quoted 5 lines
Quoted 1 line
+ if (!runtime->subformat_constraint) {
I'd try to avoid another special-bit in the runtime space. But I might be wrong here and it's unavoidable. Let me ask though, why cannot we do the constraint unconditionally?
This is for a special case when the drivers do not set
snd_pcm_hw_constraint_subformats(all current drivers). In this case, the default is to handle STD and MAX subformat bits.
Quoted 6 lines
Quoted 2 lines
This constraint should be applied only one time. So this prevents to install it twice.
I believe we could avoid special-case approach. Have a copy/intersection helpers in place and utilize iterations-with-sentinel-entry. Provided such in v2 of my series.
I don't think that it's required to carry the format->subformat map in struct snd_pcm_hardware. Only few drivers will use it, so the separate constraint is fine. Also, you can remove a lot of your added code to the pcm_misc and ASoC core (copy, masking, allocating) when the affected drivers install the map using the constraint call.
Few points:
1) PCM API interface changes should be separate, you mixing unused helpers and separating vital functionality for drivers
2) if you copy 90% of my code, I don't think that Suggested-by: tag is fine
Could you do your work on top of my patch?
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Quoted 1 line · Jaroslav Kysela
On 18. 09. 23 15:55, Cezary Rojewski wrote:
...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
This is for a special case when the drivers do not set
snd_pcm_hw_constraint_subformats(all current drivers). In this case, the default is to handle STD and MAX subformat bits.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
This constraint should be applied only one time. So this prevents to install it twice.
I believe we could avoid special-case approach. Have a copy/intersection helpers in place and utilize iterations-with-sentinel-entry. Provided such in v2 of my series.
I don't think that it's required to carry the
format->subformatmap in structsnd_pcm_hardware. Only few drivers will use it, so the separate constraint is fine. Also, you can remove a lot of your added code to thepcm_miscand ASoC core (copy, masking, allocating) when the affected drivers install the map using the constraint call.
I believe the question isn't how few or how many, but are there users or not. The answer to that question is: there are users of the subformat feature.
Adding an array of subformats to the snd_pcm_hardware makes things explicit, example being sound/soc/intel/avs/pcm.c. That's a win from maintenance point of view. Another thing is that we could utilize subformat to drop msbits entirely in the future. To summarize, to make subformat a first class citizen, we should avoid special-casing anything related to it.
Quoted 3 lines
Few points:
1) PCM API interface changes should be separate, you mixing unused helpers and separating vital functionality for drivers
What I could do is shuffle the code a bit e.g.: let snd_pcm_hw_copy() be introduced along the ASoC changes. Frankly that was the initial approach (forgotten to update the commit message of 04/17 so it still talks about code that's no longer part of the commit).
Quoted 3 lines
2) if you copy 90% of my code, I don't think that Suggested-by: tag is fine
Could you do your work on top of my patch?
I'm afraid this isn't a fair claim. The feature is driven by validation and this has been conducted be me or my folks entirely. Given the scarce guidance provided in [1] I still provided a valid WIP in [2] and expected to iterate over it given the feedback. Closing the discussion by taking a single patch away from the series and re-authoring it is not a welcoming way to do a review. Perhaps Co-developed-by: then?
Please note that the code differs. I do believe that splitting the API and the constrains into separate patches is a better approach from maintenance point of view. Proposed readability improvements have also been applied in v2. For reasons provided in previous paragraphs, I chose to avoid the chicken-bit and treat subformat constraints in generic fashion. Also, validation shows that without updating snd_pcm_subformat_names[] in pcm.c the code ends with UBSAN during runtime. I've already addressed that, even in v1.
I'm happy to continue the technical discussion as there are still points to discuss. Let's do so in v2 of the series [3].
Kind regards,
Czarek
[1]: https://lore.kernel.org/alsa-devel/[email protected]/
[2]: https://lore.kernel.org/alsa-devel/[email protected]/
[3]: https://lore.kernel.org/alsa-devel/[email protected]/
Jaroslav Kysela
maintainerQuoted 26 lines · Cezary Rojewski
Quoted 1 line · Jaroslav Kysela
On 18. 09. 23 15:55, Cezary Rojewski wrote:
...
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
This is for a special case when the drivers do not set
snd_pcm_hw_constraint_subformats(all current drivers). In this case, the default is to handle STD and MAX subformat bits.This constraint should be applied only one time. So this prevents to install it twice.
I believe we could avoid special-case approach. Have a copy/intersection helpers in place and utilize iterations-with-sentinel-entry. Provided such in v2 of my series.
Quoted 5 lines
I don't think that it's required to carry the
format->subformatmap in structsnd_pcm_hardware. Only few drivers will use it, so the separate constraint is fine. Also, you can remove a lot of your added code to thepcm_miscand ASoC core (copy, masking, allocating) when the affected drivers install the map using the constraint call.I believe the question isn't how few or how many, but are there users or not. The answer to that question is: there are users of the subformat feature.
Quoted 6 lines
Adding an array of subformats to the
snd_pcm_hardwaremakes things explicit, example beingsound/soc/intel/avs/pcm.c. That's a win from maintenance point of view. Another thing is that we could utilize subformat to drop msbits entirely in the future. To summarize, to make subformat a first class citizen, we should avoid special-casing anything related to it.
I would argue that the snd_pcm_hardware is just a static template which is refined by constraints (runtime) anyway. The new constraint which is called directly in the PCM open callback means really minimal changes in the core code and ASoC core code. We can implement more robust way on demand in future when we have a better picture for the subformat mask usage.
Quoted 9 lines
Quoted 4 lines
Few points:
1) PCM API interface changes should be separate, you mixing unused helpers and separating vital functionality for drivers
What I could do is shuffle the code a bit e.g.: let
snd_pcm_hw_copy()be introduced along the ASoC changes. Frankly that was the initial approach (forgotten to update the commit message of 04/17 so it still talks about code that's no longer part of the commit).
The first patch should cover the vital code which is required for the subformat extension in the PCM core code. When we have this base, you can work on other things.
Quoted 10 lines
Quoted 3 lines
2) if you copy 90% of my code, I don't think that Suggested-by: tag is fine
Could you do your work on top of my patch?
I'm afraid this isn't a fair claim. The feature is driven by validation and this has been conducted be me or my folks entirely. Given the scarce guidance provided in [1] I still provided a valid WIP in [2] and expected to iterate over it given the feedback. Closing the discussion by taking a single patch away from the series and re-authoring it is not a welcoming way to do a review. Perhaps Co-developed-by: then?
I don't follow you. My patch can be also changed - I've not heard any review except cosmetic changes. I am just telling you that the patch is a good base for all other changes. I think that the best way is to finish the base extension in sound/core at first without any helpers and so on and then work on other parts.
Quoted 3 lines
Please note that the code differs. I do believe that splitting the API and the constrains into separate patches is a better approach from maintenance point of view.
It does not make sense to extend API without constraints. The splitting does not help here.
Quoted 4 lines
Proposed readability improvements have also
been applied in v2. For reasons provided in previous paragraphs, I chose > to avoid the chicken-bit and treat subformat constraints in generic fashion. Also, validation shows that without updating
snd_pcm_subformat_names[] inpcm.cthe code ends with UBSAN during
Yes, I missed that. I can put it to my v3 when we agree on the constraints.
Quoted 4 lines
runtime. I've already addressed that, even in v1.
I'm happy to continue the technical discussion as there are still points to discuss. Let's do so in v2 of the series [3].
Unfortunately, you are not working with the technical discussion anyway. Changing comments adding empty lines, renaming variables to make you happy is not a nice way to co-operate with others and then act as the author of the CODE (not comments) is really bad. Everyone has own coding style and you're forcing your opinion.
Also, I though about {} end-of-array mark (remove SNDRV_PCM_FORMAT_CONSTRAINT_END), but I found that I prefer to have the possibility to skip the MSBITS_MAX settings for the given format. It may make sense in a situation when the MSBITS configuration is too rare to be added as the API bit.
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Quoted 1 line · Jaroslav Kysela
On 19. 09. 23 11:28, Cezary Rojewski wrote:
...
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
2) if you copy 90% of my code, I don't think that Suggested-by: tag is fine
Could you do your work on top of my patch?
Quoted 8 lines
Quoted 6 lines
I'm afraid this isn't a fair claim. The feature is driven by validation and this has been conducted be me or my folks entirely. Given the scarce guidance provided in [1] I still provided a valid WIP in [2] and expected to iterate over it given the feedback. Closing the discussion by taking a single patch away from the series and re-authoring it is not a welcoming way to do a review. Perhaps Co-developed-by: then?
I don't follow you. My patch can be also changed - I've not heard any review except cosmetic changes. I am just telling you that the patch is a good base for all other changes. I think that the best way is to finish the base extension in
sound/coreat first without any helpers and so on and then work on other parts.
(save)
Quoted 11 lines
Quoted 3 lines
Please note that the code differs. I do believe that splitting the API and the constrains into separate patches is a better approach from maintenance point of view.
It does not make sense to extend API without constraints. The splitting does not help here.
Quoted 4 lines
Proposed readability improvements have also
been applied in v2. For reasons provided in previous paragraphs, I chose > to avoid the chicken-bit and treat subformat constraints in generic fashion. Also, validation shows that without updating
snd_pcm_subformat_names[] inpcm.cthe code ends with UBSAN during
Quoted 8 lines
Yes, I missed that. I can put it to my v3 when we agree on the constraints.
Quoted 4 lines
runtime. I've already addressed that, even in v1.
I'm happy to continue the technical discussion as there are still points to discuss. Let's do so in v2 of the series [3].
Unfortunately, you are not working with the technical discussion anyway. Changing comments adding empty lines, renaming variables to make you happy is not a nice way to co-operate with others and then act as the author of the CODE (not comments) is really bad. Everyone has own coding style and you're forcing your opinion.
We have a different view on the subject. Readability shall be treated on the same level as performance is. It should not be marginalized.
When taking a look at RFC series [1] and the WIP [2] there's a clear resemblance to the code here. I believe the differences between this and v2 [3] are also being skipped over. And as stated previously, closing the review by separating a patch from the series and sending it without any references to the original series and modifying the CC list is not nice.
What I propose is: leave the MSBITS-introduction and MSBITS-constraints patches split. Have my authorship for the former and yours for the latter with relevant Co-developed-by: tags added in both of them. Is this proposal acceptable from your perspective?
Kind regards,
Czarek
[1]: https://lore.kernel.org/alsa-devel/[email protected]/
[2]: https://lore.kernel.org/alsa-devel/[email protected]/
[3]: https://lore.kernel.org/alsa-devel/[email protected]/
Quoted 1 line
Also, I though about {} end-of-array mark (remove
SNDRV_PCM_FORMAT_CONSTRAINT_END), but I found that I prefer to have the possibility to skip theMSBITS_MAXsettings for the given format. It may make sense in a situation when the MSBITS configuration is too rare to be added as the API bit.