ASoC: Intel: KMB: Enable TDM audio capture
Hello Michael Sit Wei Hong,
The patch 9c3bab3c4f15: "ASoC: Intel: KMB: Enable TDM audio capture" from Aug 11, 2020, leads to the following static checker warning:
sound/soc/intel/keembay/kmb_platform.c:518 kmb_dai_hw_params()
warn: potential ! vs ~ typo
sound/soc/intel/keembay/kmb_platform.c
502 }
503
504 config->chan_nr = params_channels(hw_params);
505
506 switch (config->chan_nr) {
507 case 8:
508 case 4:
509 /*
510 * Platform is not capable of providing clocks for
511 * multi channel audio
512 */
513 if (kmb_i2s->master)
514 return -EINVAL;
515
516 write_val = ((config->chan_nr / 2) << TDM_CHANNEL_CONFIG_BIT) |
517 (config->data_width << DATA_WIDTH_CONFIG_BIT) |
518 !MASTER_MODE | TDM_OPERATION;
^^^^^^^^^^^^MASTER_MODE is BIT(13). It's unclear what this is supposed to be. My best guess is that the ! should just be deleted.
519 520 writel(write_val, kmb_i2s->pss_base + I2S_GEN_CFG_0); 521 break; 522 case 2: 523 /* 524 * Platform is only capable of providing clocks need for 525 * 2 channel master mode 526 */ 527 if (!(kmb_i2s->master)) 528 return -EINVAL; 529 530 write_val = ((config->chan_nr / 2) << TDM_CHANNEL_CONFIG_BIT) | 531 (config->data_width << DATA_WIDTH_CONFIG_BIT) | 532 MASTER_MODE | I2S_OPERATION; 533 534 writel(write_val, kmb_i2s->pss_base + I2S_GEN_CFG_0); 535 break; 536 default: 537 dev_dbg(kmb_i2s->dev, "channel not supported\n"); 538 return -EINVAL; 539 }
regards,
dan carpenter
Quoted 31 lines · Dan Carpenter
Hello Michael Sit Wei Hong,
The patch
9c3bab3c4f15: "ASoC: Intel: KMB: Enable TDM audio capture" from Aug 11, 2020, leads to the following static checker warning:
sound/soc/intel/keembay/kmb_platform.c:518kmb_dai_hw_params()
warn: potential ! vs ~ typo
sound/soc/intel/keembay/kmb_platform.c
502 }
503
504config->chan_nr=params_channels(hw_params);
505506 switch (config->chan_nr) { 507 case 8: 508 case 4: 509 /* 510 * Platform is not capable of providing clocks for 511 * multi channel audio 512 */ 513 if (kmb_i2s->master) 514 return -EINVAL; 515 516 write_val = ((config->chan_nr / 2) << TDM_CHANNEL_CONFIG_BIT) | 517 (config->data_width << DATA_WIDTH_CONFIG_BIT) | 518 !MASTER_MODE | TDM_OPERATION; ^^^^^^^^^^^^
Quoted 2 lines
MASTER_MODEis BIT(13). It's unclear what this is supposed to be. My best guess is that the ! should just be deleted.
This ! is intentional because it is meant to be Slave mode. Would a better approach be to create another #define for slave mode?
Quoted 25 lines
519 520 writel(write_val, kmb_i2s->pss_base + I2S_GEN_CFG_0); 521 break; 522 case 2: 523 /* 524 * Platform is only capable of providing clocks need for 525 * 2 channel master mode 526 */ 527 if (!(kmb_i2s->master)) 528 return -EINVAL; 529 530 write_val = ((config->chan_nr / 2) << TDM_CHANNEL_CONFIG_BIT) | 531 (config->data_width << DATA_WIDTH_CONFIG_BIT) | 532 MASTER_MODE | I2S_OPERATION; 533 534 writel(write_val, kmb_i2s->pss_base + I2S_GEN_CFG_0); 535 break; 536 default: 537 dev_dbg(kmb_i2s->dev, "channel not supported\n"); 538 return -EINVAL; 539 }regards,
dan carpenter
Quoted 34 lines · Michael Wei Hong
Quoted 31 lines · Dan Carpenter
Hello Michael Sit Wei Hong,
The patch
9c3bab3c4f15: "ASoC: Intel: KMB: Enable TDM audio capture" from Aug 11, 2020, leads to the following static checker warning:
sound/soc/intel/keembay/kmb_platform.c:518kmb_dai_hw_params()
warn: potential ! vs ~ typo
sound/soc/intel/keembay/kmb_platform.c
502 }
503
504config->chan_nr=params_channels(hw_params);
505506 switch (config->chan_nr) { 507 case 8: 508 case 4: 509 /* 510 * Platform is not capable of providing clocks for 511 * multi channel audio 512 */ 513 if (kmb_i2s->master) 514 return -EINVAL; 515 516 write_val = ((config->chan_nr / 2) << TDM_CHANNEL_CONFIG_BIT) | 517 (config->data_width << DATA_WIDTH_CONFIG_BIT) | 518 !MASTER_MODE | TDM_OPERATION; ^^^^^^^^^^^^Quoted 2 lines
MASTER_MODEis BIT(13). It's unclear what this is supposed to be. My best guess is that the ! should just be deleted.
Quoted 1 line
This ! is intentional because it is meant to be Slave mode. Would a better approach be to create another #define for slave mode?
In my opinion, it's better to just leave it out. ORing with zero causes a different static checker warning on my unreleased checks... Is it 0 << 13? I feel like ORing with zero just makes things more confusing.
regards,
dan carpenter
Quoted 39 lines · Dan Carpenter
Quoted 34 lines · Michael Wei Hong
Quoted 33 lines
Quoted 3 lines · Dan Carpenter
Hello Michael Sit Wei Hong,
The patch
9c3bab3c4f15: "ASoC: Intel: KMB: Enable TDM audio capture" from Aug 11, 2020, leads to the following static checker warning:
sound/soc/intel/keembay/kmb_platform.c:518kmb_dai_hw_params()
warn: potential ! vs ~ typo
sound/soc/intel/keembay/kmb_platform.c
502 }
503
504config->chan_nr=params_channels(hw_params);
505506 switch (config->chan_nr) { 507 case 8: 508 case 4: 509 /* 510 * Platform is not capable of providing clocks for 511 * multi channel audio 512 */ 513 if (kmb_i2s->master) 514 return -EINVAL; 515 516 write_val = ((config->chan_nr / 2) << TDM_CHANNEL_CONFIG_BIT) | 517 (config->data_width << DATA_WIDTH_CONFIG_BIT) | 518 !MASTER_MODE | TDM_OPERATION; ^^^^^^^^^^^^
MASTER_MODEis BIT(13). It's unclear what this is supposed to be. My best guess is that the ! should just be deleted.
Quoted 6 lines
Quoted 1 line
This ! is intentional because it is meant to be Slave mode. Would a better approach be to create another #define for slave mode?
In my opinion, it's better to just leave it out. ORing with zero causes a different static checker warning on my unreleased checks... Is it 0 << 13? I feel like ORing with zero just makes things more confusing.
It is 0<<13, in the event it was previously configured to Master I would need to unset the bit
Quoted 3 lines
regards,
dan carpenter
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
506 switch (config->chan_nr) { 507 case 8: 508 case 4: 509 /* 510 * Platform is not capable of providing clocks for 511 * multi channel audio 512 */ 513 if (kmb_i2s->master) 514 return -EINVAL; 515 516 write_val = ((config->chan_nr / 2) << TDM_CHANNEL_CONFIG_BIT) | 517 (config->data_width << DATA_WIDTH_CONFIG_BIT) | 518 !MASTER_MODE | TDM_OPERATION; ^^^^^^^^^^^^
MASTER_MODEis BIT(13). It's unclear what this is supposed to be. My best guess is that the ! should just be deleted.
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
This ! is intentional because it is meant to be Slave mode. Would a better approach be to create another #define for slave mode?
In my opinion, it's better to just leave it out. ORing with zero causes a different static checker warning on my unreleased checks... Is it 0 << 13? I feel like ORing with zero just makes things more confusing.
It is 0<<13, in the event it was previously configured to Master I would need to unset the bit
You are assigning the result to write_val, so there's no memory of what was configured before?
Quoted 24 lines · Pierre-Louis Bossart
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 14 lines
506 switch (config->chan_nr) { 507 case 8: 508 case 4: 509 /* 510 * Platform is not capable of providing clocks for 511 * multi channel audio 512 */ 513 if (kmb_i2s->master) 514 return -EINVAL; 515 516 write_val = ((config->chan_nr / 2) << TDM_CHANNEL_CONFIG_BIT) | 517 (config->data_width << DATA_WIDTH_CONFIG_BIT) | 518 !MASTER_MODE | TDM_OPERATION; ^^^^^^^^^^^^Quoted 2 lines
MASTER_MODEis BIT(13). It's unclear what this is supposed to be. My best guess is that the ! should just be deleted.This ! is intentional because it is meant to be Slave mode. Would a better approach be to create another #define for slave mode?
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
In my opinion, it's better to just leave it out. ORing with zero causes a different static checker warning on my unreleased checks... Is it 0 << 13? I feel like ORing with zero just makes things more confusing.
It is 0<<13, in the event it was previously configured to Master I would need to unset the bit
You are assigning the result to
write_val, so there's no memory of what was configured before?
Yea you are right, would leaving this !MASTER_MODE out the best solution?
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 18 lines
Quoted 15 lines
506 switch (config->chan_nr) { 507 case 8: 508 case 4: 509 /* 510 * Platform is not capable of providing clocks for 511 * multi channel audio 512 */ 513 if (kmb_i2s->master) 514 return -EINVAL; 515 516 write_val = ((config->chan_nr / 2) << TDM_CHANNEL_CONFIG_BIT) | 517 (config->data_width << DATA_WIDTH_CONFIG_BIT) | 518 !MASTER_MODE | TDM_OPERATION; ^^^^^^^^^^^^Quoted 2 lines
MASTER_MODEis BIT(13). It's unclear what this is supposed to be. My best guess is that the ! should just be deleted.Quoted 1 line
This ! is intentional because it is meant to be Slave mode. Would a better approach be to create another #define for slave mode?
In my opinion, it's better to just leave it out. ORing with zero causes a different static checker warning on my unreleased checks... Is it 0 << 13? I feel like ORing with zero just makes things more confusing.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
It is 0<<13, in the event it was previously configured to Master I would need to unset the bit
You are assigning the result to
write_val, so there's no memory of what was configured before?Yea you are right, would leaving this !MASTER_MODE out the best solution?
Sounds good to me. Thanks Dan for the report!
Quoted 45 lines
-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: Wednesday, 26 August, 2020 2:23 AM
To: Sit, Michael Wei Hong <[email protected]>
Cc: Dan Carpenter <[email protected]>; alsa-devel@alsa- project.org; Sia, Jee Heng <[email protected]>
Subject: Re: [bug report] ASoC: Intel: KMB: Enable TDM audio captureQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
506 switch (config->chan_nr) { 507 case 8: 508 case 4:509 /*
510 * Platform is not capable of providing clocksfor
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
511 * multi channel audio
512 */
513 if (kmb_i2s->master)
514 return-EINVAL;
515
516write_val= ((config->chan_nr/ 2) <<
TDM_CHANNEL_CONFIG_BIT) |Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
517 (
config->data_width<<
DATA_WIDTH_CONFIG_BIT) |Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
518 !MASTER_MODE | TDM_OPERATION; ^^^^^^^^^^^^ MASTER_MODEis BIT(13). It's unclear what this is supposed to be. My best guess is that the ! should just be deleted.
This ! is intentional because it is meant to be Slave mode.
Would a better approach be to create another #define for slave mode?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
In my opinion, it's better to just leave it out. ORing with zero causes a different static checker warning on my unreleased checks... Is it
0 << 13? I feel like ORing with zero just makes things moreconfusing.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
It is 0<<13, in the event it was previously configured to Master I would need to unset the bit
Quoted 7 lines
Quoted 1 line
Quoted 1 line
You are assigning the result to
write_val, so there's no memoryof what was configured before?
Quoted 2 lines
Yea you are right, would leaving this !MASTER_MODE out the best
solution?
Sounds good to me. Thanks Dan for the report!
Tested removing the !MASTER_MODE from the write_val, it still works as expected Removing !MASTER_MODE sounds good to me. Thanks Dan for the report!