* [PATCH RFT] ASoC: ak4642: Fix up max_register setting
@ 2015-06-28 2:46 Axel Lin
2015-06-30 10:46 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Axel Lin @ 2015-06-28 2:46 UTC (permalink / raw)
To: Mark Brown
Cc: alsa-devel, Lars-Peter Clausen, Liam Girdwood, Kuninori Morimoto
The max_register setting for ak4642, ak4643 and ak4648 are wrong, fix it.
According to the datasheet:
the maximum valid register for ak4642 is 0x1f
the maximum valid register for ak4643 is 0x24
the maximum valid register for ak4648 is 0x27
The default settings for ak4642 and ak4643 are the same for 0x0 ~ 0x1f
registers, so it's fine to use the same reg_default table with different
num_reg_defaults setting.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
Hi,
I don't have this h/w to test.
I'd appreciate if someone can review and test this patch.
Thanks,
Axel
sound/soc/codecs/ak4642.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 7c0f6552..7f27345 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -64,12 +64,15 @@
#define FIL1_0 0x1c
#define FIL1_1 0x1d
#define FIL1_2 0x1e
-#define FIL1_3 0x1f
+#define FIL1_3 0x1f /* The maximum valid register for ak4642 */
#define PW_MGMT4 0x20
#define MD_CTL5 0x21
#define LO_MS 0x22
#define HP_MS 0x23
-#define SPK_MS 0x24
+#define SPK_MS 0x24 /* The maximum valid register for ak4643 */
+#define EQ_FBEQAB 0x25
+#define EQ_FBEQCD 0x26
+#define EQ_FBEQE 0x27 /* The maximum valid register for ak4648 */
/* PW_MGMT1*/
#define PMVCM (1 << 6) /* VCOM Power Management */
@@ -535,17 +538,25 @@ static struct snd_soc_codec_driver soc_codec_dev_ak4642 = {
static const struct regmap_config ak4642_regmap = {
.reg_bits = 8,
.val_bits = 8,
- .max_register = ARRAY_SIZE(ak4642_reg) + 1,
+ .max_register = FIL1_3,
.reg_defaults = ak4642_reg,
- .num_reg_defaults = ARRAY_SIZE(ak4642_reg),
+ .num_reg_defaults = FIL1_3 + 1,
+};
+
+static const struct regmap_config ak4643_regmap = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = SPK_MS,
+ .reg_defaults = ak4642_reg,
+ .num_reg_defaults = SPK_MS + 1,
};
static const struct regmap_config ak4648_regmap = {
.reg_bits = 8,
.val_bits = 8,
- .max_register = ARRAY_SIZE(ak4648_reg) + 1,
+ .max_register = EQ_FBEQE,
.reg_defaults = ak4648_reg,
- .num_reg_defaults = ARRAY_SIZE(ak4648_reg),
+ .num_reg_defaults = EQ_FBEQE + 1,
};
static const struct ak4642_drvdata ak4642_drvdata = {
@@ -553,7 +564,7 @@ static const struct ak4642_drvdata ak4642_drvdata = {
};
static const struct ak4642_drvdata ak4643_drvdata = {
- .regmap_config = &ak4642_regmap,
+ .regmap_config = &ak4643_regmap,
};
static const struct ak4642_drvdata ak4648_drvdata = {
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH RFT] ASoC: ak4642: Fix up max_register setting
2015-06-28 2:46 [PATCH RFT] ASoC: ak4642: Fix up max_register setting Axel Lin
@ 2015-06-30 10:46 ` Mark Brown
2015-06-30 11:25 ` Axel Lin
0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2015-06-30 10:46 UTC (permalink / raw)
To: Axel Lin; +Cc: alsa-devel, Lars-Peter Clausen, Liam Girdwood, Kuninori Morimoto
[-- Attachment #1.1: Type: text/plain, Size: 507 bytes --]
On Sun, Jun 28, 2015 at 10:46:51AM +0800, Axel Lin wrote:
> static const struct regmap_config ak4642_regmap = {
> .reg_bits = 8,
> .val_bits = 8,
> - .max_register = ARRAY_SIZE(ak4642_reg) + 1,
> + .max_register = FIL1_3,
> .reg_defaults = ak4642_reg,
> - .num_reg_defaults = ARRAY_SIZE(ak4642_reg),
> + .num_reg_defaults = FIL1_3 + 1,
This change is incorrect, the number of register defaults must match the
size of the array of register defaults being passed in. Why are you
changing this?
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFT] ASoC: ak4642: Fix up max_register setting
2015-06-30 10:46 ` Mark Brown
@ 2015-06-30 11:25 ` Axel Lin
2015-06-30 15:18 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Axel Lin @ 2015-06-30 11:25 UTC (permalink / raw)
To: Mark Brown
Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen, Liam Girdwood,
Kuninori Morimoto
2015-06-30 18:46 GMT+08:00 Mark Brown <broonie@kernel.org>:
> On Sun, Jun 28, 2015 at 10:46:51AM +0800, Axel Lin wrote:
>
>> static const struct regmap_config ak4642_regmap = {
>> .reg_bits = 8,
>> .val_bits = 8,
>> - .max_register = ARRAY_SIZE(ak4642_reg) + 1,
>> + .max_register = FIL1_3,
>> .reg_defaults = ak4642_reg,
>> - .num_reg_defaults = ARRAY_SIZE(ak4642_reg),
>> + .num_reg_defaults = FIL1_3 + 1,
>
> This change is incorrect, the number of register defaults must match the
> size of the array of register defaults being passed in. Why are you
> changing this?
Because I reuse the same reg_default for ak4642 and ak4643.
According to the datasheet:
For ak4642, the valid registers are 0x0 ~ 0x1f (FIL1_3)
For ak4643, the valid registers are 0x0 ~ 0x24 (SPK_MS)
The default registers for 0x0 ~ 0x1f are the same for ak4642 and ak4643.
That is why this patch set .num_reg_defaults = FIL1_3 + 1 for ak4642.
Or do you prefer having separate reg_default for ak4642 and ak4643?
(Then it can use ARRAY_SIZE() here.)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RFT] ASoC: ak4642: Fix up max_register setting
2015-06-30 11:25 ` Axel Lin
@ 2015-06-30 15:18 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2015-06-30 15:18 UTC (permalink / raw)
To: Axel Lin
Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen, Liam Girdwood,
Kuninori Morimoto
[-- Attachment #1.1: Type: text/plain, Size: 1327 bytes --]
On Tue, Jun 30, 2015 at 07:25:57PM +0800, Axel Lin wrote:
> 2015-06-30 18:46 GMT+08:00 Mark Brown <broonie@kernel.org>:
> >> static const struct regmap_config ak4642_regmap = {
> >> .reg_bits = 8,
> >> .val_bits = 8,
> >> - .max_register = ARRAY_SIZE(ak4642_reg) + 1,
> >> + .max_register = FIL1_3,
> >> .reg_defaults = ak4642_reg,
> >> - .num_reg_defaults = ARRAY_SIZE(ak4642_reg),
> >> + .num_reg_defaults = FIL1_3 + 1,
> > This change is incorrect, the number of register defaults must match the
> > size of the array of register defaults being passed in. Why are you
> > changing this?
> Because I reuse the same reg_default for ak4642 and ak4643.
> According to the datasheet:
> For ak4642, the valid registers are 0x0 ~ 0x1f (FIL1_3)
> For ak4643, the valid registers are 0x0 ~ 0x24 (SPK_MS)
> The default registers for 0x0 ~ 0x1f are the same for ak4642 and ak4643.
Ah, I see. That definitely deserves a comment since it's very unusual -
possibly also with a BUILD_BUG_ON() for the define being less than
ARRAY_SIZE().
> Or do you prefer having separate reg_default for ak4642 and ak4643?
> (Then it can use ARRAY_SIZE() here.)
No, what you're doing is OK but really ought to have comments so it's
clearer.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-30 15:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-28 2:46 [PATCH RFT] ASoC: ak4642: Fix up max_register setting Axel Lin
2015-06-30 10:46 ` Mark Brown
2015-06-30 11:25 ` Axel Lin
2015-06-30 15:18 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.