ASoC: DAPM: Add support for multi register mux
PATCH 1/1 ASoC: DAPM: Add support for multi register mux
Modify soc_enum struct to handle pointers for reg and mask. Add dapm get and put APIs for multi register mux with one hot encoding.
--- include/sound/soc-dapm.h | 10 ++++ include/sound/soc.h | 22 +++++-- sound/soc/soc-core.c | 12 ++-- sound/soc/soc-dapm.c | 143 +++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 162 insertions(+), 25 deletions(-)
include/sound/soc-dapm.h +10 -0
@@ -305,6 +305,12 @@ struct device; .get = snd_soc_dapm_get_enum_double, \ .put = snd_soc_dapm_put_enum_double, \ .private_value = (unsigned long)&xenum } +#define SOC_DAPM_ENUM_WIDE (xname, xenum) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_info_enum_double, \ + .get = snd_soc_dapm_get_enum_wide, \ + .put = snd_soc_dapm_put_enum_wide, \ + .private_value = (unsigned long)&xenum }#define SOC_DAPM_ENUM_VIRT (xname, xenum) \ SOC_DAPM_ENUM(xname, xenum)#define SOC_DAPM_ENUM_EXT (xname, xenum, xget, xput) \
@@ -378,6 +384,10 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);int snd_soc_dapm_put_enum_double (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); +int snd_soc_dapm_get_enum_wide (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol); +int snd_soc_dapm_put_enum_wide (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol);int snd_soc_dapm_info_pin_switch (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo); int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
include/sound/soc.h +16 -6
@@ -177,18 +177,23 @@ {.reg = xreg, .min = xmin, .max = xmax, \ .platform_max = xmax} }#define SOC_ENUM_DOUBLE (xreg, xshift_l, xshift_r, xitems, xtexts) \ -{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ +{ .reg = &(int){(xreg)}, .shift_l = xshift_l, .shift_r = xshift_r, \ .items = xitems, .texts = xtexts, \ - .mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0} + .mask = &(unsigned int){(xitems ? roundup_pow_of_two(xitems) - 1 : 0)}, \ + .num_regs = 1 }#define SOC_ENUM_SINGLE (xreg, xshift, xitems, xtexts) \ SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)#define SOC_ENUM_SINGLE_EXT (xitems, xtexts) \ { .items = xitems, .texts = xtexts }#define SOC_VALUE_ENUM_DOUBLE (xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \ -{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ - .mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues} +{ .reg = &(int){(xreg)}, .shift_l = xshift_l, .shift_r = xshift_r, \ + .mask = &(unsigned int){(xmask)}, .items = xitems, .texts = xtexts, \ + .values = xvalues, .num_regs = 1 }#define SOC_VALUE_ENUM_SINGLE (xreg, xshift, xmask, xnitmes, xtexts, xvalues) \ SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xnitmes, xtexts, xvalues) +#define SOC_VALUE_ENUM_WIDE (xregs, xmasks, xnum_regs, xitems, xtexts, xvalues) \ +{ .reg = xregs, .mask = xmasks, .num_regs = xnum_regs, \ + .items = xitems, .texts = xtexts, .values = xvalues, .reg_width = 32 }#define SOC_ENUM_SINGLE_VIRT (xitems, xtexts) \ SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)#define SOC_ENUM (xname, xenum) \
@@ -293,6 +298,9 @@#define SOC_VALUE_ENUM_DOUBLE_DECL (name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \ const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \ ARRAY_SIZE(xtexts), xtexts, xvalues) +#define SOC_VALUE_ENUM_WIDE_DECL (name, xregs, xmasks, xnum_regs, xtexts, xvalues) \ + const struct soc_enum name = SOC_VALUE_ENUM_WIDE(xregs, xmasks, xnum_regs, \ + ARRAY_SIZE(xtexts), xtexts, xvalues)#define SOC_VALUE_ENUM_SINGLE_DECL (name, xreg, xshift, xmask, xtexts, xvalues) \ SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)#define SOC_ENUM_SINGLE_VIRT_DECL (name, xtexts) \
@@ -1098,13 +1106,15 @@ struct soc_mreg_control {/* enumerated kcontrol */ struct soc_enum { -int reg; +int *reg;unsigned char shift_l;unsigned char shift_r;unsigned int items; -unsigned int mask; +unsigned int *mask;const char *const *texts;const unsigned int *values; +unsigned int reg_width; +unsigned int num_regs; };/**
sound/soc/soc-core.c +6 -6
@@ -2601,12 +2601,12 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,unsigned int val, item;unsigned int reg_val; - reg_val =snd_soc_read (codec, e->reg); - val = (reg_val >> e->shift_l) & e->mask; + reg_val =snd_soc_read (codec, e->reg[0 ]); + val = (reg_val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val); ucontrol->value.enumerated.item[0 ] = item;if (e->shift_l != e->shift_r) { - val = (reg_val >> e->shift_l) & e->mask; + val = (reg_val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val); ucontrol->value.enumerated.item[1 ] = item; }
@@ -2636,15 +2636,15 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,if (item[0 ] >= e->items)return -EINVAL ; val =snd_soc_enum_item_to_val (e, item[0 ]) << e->shift_l; - mask = e->mask << e->shift_l; + mask = e->mask[0 ] << e->shift_l;if (e->shift_l != e->shift_r) {if (item[1 ] >= e->items)return -EINVAL ; val |=snd_soc_enum_item_to_val (e, item[1 ]) << e->shift_r; - mask |= e->mask << e->shift_r; + mask |= e->mask[0 ] << e->shift_r; } -return snd_soc_update_bits_locked (codec, e->reg, mask, val); +return snd_soc_update_bits_locked (codec, e->reg[0 ], mask, val); }EXPORT_SYMBOL_GPL (snd_soc_put_enum_double);
sound/soc/soc-dapm.c +130 -13
185 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 5 lines · Arun Shamanna Lakshmi
Modify
soc_enumstruct to handle pointers for reg and mask. Add dapm get and put APIs for multi register mux with one hot encoding.Signed-off-by Arun Shamanna Lakshmi <[email protected]>Signed-off-by Songhee Baek <[email protected]>
Looks in my opinion much better than the previous version :) Just a few minor issues, comments inline
Quoted 12 lines
--- include/sound/soc-dapm.h | 10 ++++ include/sound/soc.h | 22 +++++-- sound/soc/soc-core.c | 12 ++-- sound/soc/soc-dapm.c | 143 +++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 162 insertions(+), 25 deletions(-)include/sound/soc-dapm.h +0
-0
include/sound/soc-dapm.h struct device; · line 308
Quoted 4 lines
include/sound/soc-dapm.h +1
-0@@ -305,6 +305,12 @@ struct device; .get = snd_soc_dapm_get_enum_double, \ .put = snd_soc_dapm_put_enum_double, \ .private_value = (unsigned long)&xenum } +#define SOC_DAPM_ENUM_WIDE (xname, xenum) \
maybe just call it ENUM_ONEHOT, since it doesn't actually have to be more than one register.
[...]
Quoted 44 lines
sound/soc/soc-core.c +6
-6@@ -2601,12 +2601,12 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,unsigned int val, item;unsigned int reg_val; - reg_val =snd_soc_read (codec, e->reg); - val = (reg_val >> e->shift_l) & e->mask; + reg_val =snd_soc_read (codec, e->reg[0 ]); + val = (reg_val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val); ucontrol->value.enumerated.item[0 ] = item;if (e->shift_l != e->shift_r) { - val = (reg_val >> e->shift_l) & e->mask; + val = (reg_val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val); ucontrol->value.enumerated.item[1 ] = item; }@@ -2636,15 +2636,15 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,if (item[0 ] >= e->items)return -EINVAL ; val =snd_soc_enum_item_to_val (e, item[0 ]) << e->shift_l; - mask = e->mask << e->shift_l; + mask = e->mask[0 ] << e->shift_l;if (e->shift_l != e->shift_r) {if (item[1 ] >= e->items)return -EINVAL ; val |=snd_soc_enum_item_to_val (e, item[1 ]) << e->shift_r; - mask |= e->mask << e->shift_r; + mask |= e->mask[0 ] << e->shift_r; } -return snd_soc_update_bits_locked (codec, e->reg, mask, val); +return snd_soc_update_bits_locked (codec, e->reg[0 ], mask, val); }EXPORT_SYMBOL_GPL (snd_soc_put_enum_double);sound/soc/soc-dapm.c +0
-0
sound/soc/soc-dapm.c static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, · line 520
Quoted 10 lines
sound/soc/soc-dapm.c +3
-3@@ -514,9 +514,9 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,unsigned int val, item;int i; -if (e->reg !=SND_SOC_NOPM ) { -soc_widget_read (dest, e->reg, &val); - val = (val >> e->shift_l) & e->mask; +if (e->reg[0 ] !=SND_SOC_NOPM ) { +soc_widget_read (dest, e->reg[0 ], &val); + val = (val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val);
This probably should handle the new enum type as well. You'll probably need some kind of flag in the struct to distinguish between the two enum types.
Quoted 2 lines
sound/soc/soc-dapm.c +0
-0}else {/* since a virtual mux has no backing registers to
[...]
Quoted 2 lines
/**
+ *snd_soc_dapm_get_enum_wide- dapm semi enumerated multiple registers
What's a semi-enumerated register?
Quoted 16 lines
+ * mixer get callback
+ * @kcontrol: mixer control
+ * @ucontrol: control element information
+ *
+ * Callback to get the value of a dapm semi enumerated multiple register mixer
+ * control.
+ *
+ * semi enumerated multiple registers mixer:
+ * the mixer has multiple registers to set the enumerated items. The enumerated
+ * items are referred as values.
+ * Can be used for handling bit field coded enumeration for example.
+ *
+ * Returns 0 for success.
+ */sound/soc/soc-dapm.c +2
-0+int snd_soc_dapm_get_enum_wide (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol)
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3013
Quoted 10 lines
sound/soc/soc-dapm.c +10
-0+{ +struct snd_soc_codec *codec =snd_soc_dapm_kcontrol_codec (kcontrol); +struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; +unsigned int reg_val, val, bit_pos =0 , reg_idx; + +for (reg_idx =0 ; reg_idx < e->num_regs; reg_idx++) { + reg_val =snd_soc_read (codec, e->reg[reg_idx]); + val = reg_val & e->mask[reg_idx]; +if (val !=0 ) { + bit_pos =ffs (val) + (e->reg_width * reg_idx);
Should be __ffs. __ffs returns the bits zero-indexed and ffs one-indexed. That will work better for cases where there is not additional value table necessary, since it means bit 1 maps to value 0.
Quoted 9 lines
sound/soc/soc-dapm.c +9
-0+break ; + } + } + + ucontrol->value.enumerated.item[0 ] = +snd_soc_enum_val_to_item (e, bit_pos); + +return 0 ; +}
[...]
Quoted 10 lines
sound/soc/soc-dapm.c +10
-0+int snd_soc_dapm_put_enum_wide (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_codec *codec =snd_soc_dapm_kcontrol_codec (kcontrol); +struct snd_soc_card *card = codec->card; +struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; +unsigned int *item = ucontrol->value.enumerated.item; +unsigned int change =0 , reg_idx =0 , value, bit_pos; +struct snd_soc_dapm_update update; +int ret =0 , reg_val =0 , i;
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3060
Quoted 10 lines
sound/soc/soc-dapm.c +10
-0+ +if (item[0 ] >= e->items) +return -EINVAL ; + + value =snd_soc_enum_item_to_val (e, item[0 ]); + +if (value) { +/* get the register index and value to set */ + reg_idx = (value -1 ) / e->reg_width; + bit_pos = (value -1 ) % e->reg_width;
Changing the ffs to __ffs also means you can drop the ' - 1' here.
Also e->reg_width should be (codec->val_bytes * 8) and reg_width field should be dropped from the enum struct.
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3073
Quoted 13 lines
sound/soc/soc-dapm.c +13
-0+ reg_val =BIT (bit_pos); + } + +for (i =0 ; i < e->num_regs; i++) { +if (i == reg_idx) { + change =snd_soc_test_bits (codec, e->reg[i], + e->mask[i], reg_val); + + }else { +/* accumulate the change to update the DAPM path +when none is selected */ + change +=snd_soc_test_bits (codec, e->reg[i], + e->mask[i],0 );
change |=
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3076
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ +/* clear the register when not selected */ +snd_soc_write (codec, e->reg[i],0 );
I think this should happen as part of the DAPM update sequence like you had earlier. Some special care should probably be take to make sure that you de-select the previous mux input before selecting the new one if the new one is in a different register than the previous one.
Quoted 5 lines
sound/soc/soc-dapm.c +5
-0+ } + } + +mutex_lock_nested (&card->dapm_mutex,SND_SOC_DAPM_CLASS_RUNTIME ); +
[...]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 12:48 AM
To: Arun Shamanna Lakshmi
Cc: [email protected]; [email protected];
Quoted 6 lines
[email protected]; [email protected]; alsa- [email protected]; [email protected]; Songhee Baek
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxQuoted 1 line · Arun Shamanna Lakshmi
Modify
soc_enumstruct to handle pointers for reg and mask. Add
dapm
Quoted 54 lines
Quoted 4 lines
get and put APIs for multi register mux with one hot encoding.
Signed-off-by Arun Shamanna Lakshmi <[email protected]>Signed-off-by Songhee Baek <[email protected]>Looks in my opinion much better than the previous version :) Just a few minor issues, comments inline
Quoted 5 lines
--- include/sound/soc-dapm.h | 10 ++++ include/sound/soc.h | 22 +++++-- sound/soc/soc-core.c | 12 ++-- sound/soc/soc-dapm.c | 143+++++++++++++++++++++++++++++++++++++++++-----
include/sound/soc-dapm.h
Quoted 3 lines
4 files changed, 162 insertions(+), 25 deletions(-)include/sound/soc-dapm.h +0
-0index
include/sound/soc-dapm.h struct device; · line 308
Quoted 8 lines
ef78f56..983b0ab 100644
include/sound/soc-dapm.h +1
-0@@ -305,6 +305,12 @@ struct device; .get = snd_soc_dapm_get_enum_double, \ .put = snd_soc_dapm_put_enum_double, \ .private_value = (unsigned long)&xenum } +#define SOC_DAPM_ENUM_WIDE (xname, xenum) \maybe just call it
ENUM_ONEHOT, since it doesn't actually have to be more than one register.[...]
sound/soc/soc-core.c int snd_soc_get_enum_double(struct
Quoted 5 lines
sound/soc/soc-core.c index renamed from sound/soc/soc-core.c +0
-0cd52d52..aba0094 100644
sound/soc/soc-core.c +0
-0@@ -2601,12 +2601,12 @@ int snd_soc_get_enum_double(struct
snd_kcontrol*kcontrol,sound/soc/soc-core.c int snd_soc_put_enum_double(struct
Quoted 16 lines
sound/soc/soc-core.c +3
-3unsigned int val, item;unsigned int reg_val; - reg_val =snd_soc_read (codec, e->reg); - val = (reg_val >> e->shift_l) & e->mask; + reg_val =snd_soc_read (codec, e->reg[0 ]); + val = (reg_val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val); ucontrol->value.enumerated.item[0 ] = item;if (e->shift_l != e->shift_r) { - val = (reg_val >> e->shift_l) & e->mask; + val = (reg_val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val); ucontrol->value.enumerated.item[1 ] = item; }@@ -2636,15 +2636,15 @@ int snd_soc_put_enum_double(struct
snd_kcontrol*kcontrol,
Quoted 9 lines
sound/soc/soc-core.c int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 9 lines
sound/soc/soc-core.c +1
-1if (item[0 ] >= e->items)return -EINVAL ; val =snd_soc_enum_item_to_val (e, item[0 ]) << e->shift_l; - mask = e->mask << e->shift_l; + mask = e->mask[0 ] << e->shift_l;if (e->shift_l != e->shift_r) {if (item[1 ] >= e->items)return -EINVAL ; val |= snd_soc_enum_item_to_val(e, item[1]) << e-
shift_r;
Quoted 18 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 14 lines
sound/soc/soc-core.c +2
-2- mask |= e->mask << e->shift_r; + mask |= e->mask[0 ] << e->shift_r; } -return snd_soc_update_bits_locked (codec, e->reg, mask, val); +return snd_soc_update_bits_locked (codec, e->reg[0 ], mask, val); }EXPORT_SYMBOL_GPL (snd_soc_put_enum_double);sound/soc/soc-dapm.c index renamed from sound/soc/soc-dapm.c +0
-0c8a780d..4d2b35c 100644
sound/soc/soc-dapm.c +0
-0@@ -514,9 +514,9 @@ static int dapm_connect_mux(struct
snd_soc_dapm_context*dapm,Quoted 3 lines
sound/soc/soc-dapm.c +0
-0unsigned int val, item;int i;
Quoted 11 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, · line 520
Quoted 7 lines
sound/soc/soc-dapm.c +3
-3-if (e->reg !=SND_SOC_NOPM ) { -soc_widget_read (dest, e->reg, &val); - val = (val >> e->shift_l) & e->mask; +if (e->reg[0 ] !=SND_SOC_NOPM ) { +soc_widget_read (dest, e->reg[0 ], &val); + val = (val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val);This probably should handle the new enum type as well. You'll probably need some kind of flag in the struct to distinguish between the two enum types.
Any suggestion on the flag name ?
Quoted 99 lines
Quoted 3 lines
sound/soc/soc-dapm.c +0
-0}else {/* since a virtual mux has no backing registers to [...]
Quoted 3 lines
/**
+ *snd_soc_dapm_get_enum_wide- dapm semi enumerated multiple
+ registersWhat's a semi-enumerated register?
Quoted 9 lines
+ * mixer get callback
+ * @kcontrol: mixer control
+ * @ucontrol: control element information
+ *
+ * Callback to get the value of a dapm semi enumerated multiplesound/soc/soc-dapm.c +4
-0+registermixer + * control. + * + * semi enumerated multiple registers mixer:sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 10 lines
sound/soc/soc-dapm.c +10
-0+* the mixer has multiple registers to set the enumerated items. +The enumerated +* items are referred as values. +* Can be used for handling bit field coded enumeration for example. +* +* Returns 0 for success. +*/ +int snd_soc_dapm_get_enum_wide (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) { + struct snd_soc_codec *codec =
snd_soc_dapm_kcontrol_codec(kcontrol);sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3013
Quoted 9 lines
sound/soc/soc-dapm.c +1
-0+ struct soc_enum *e = (struct soc_enum *)kcontrol-
private_value;sound/soc/soc-dapm.c +7
-0+unsigned int reg_val, val, bit_pos =0 , reg_idx; + +for (reg_idx =0 ; reg_idx < e->num_regs; reg_idx++) { + reg_val =snd_soc_read (codec, e->reg[reg_idx]); + val = reg_val & e->mask[reg_idx]; +if (val !=0 ) { + bit_pos =ffs (val) + (e->reg_width * reg_idx);Should be
__ffs.__ffsreturns the bits zero-indexed and ffs one-indexed. That will work better for cases where there is not additional value table necessary, since it means bit 1 maps to value 0.Quoted 9 lines
sound/soc/soc-dapm.c +9
-0+break ; + } + } + + ucontrol->value.enumerated.item[0 ] = +snd_soc_enum_val_to_item (e, bit_pos); + +return 0 ; +}[...]
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+int snd_soc_dapm_put_enum_wide (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) { + struct snd_soc_codec *codec =
snd_soc_dapm_kcontrol_codec(kcontrol);Quoted 7 lines
sound/soc/soc-dapm.c +2
-0+struct snd_soc_card *card = codec->card; + struct soc_enum *e = (struct soc_enum *)kcontrol-
private_value;sound/soc/soc-dapm.c +4
-0+unsigned int *item = ucontrol->value.enumerated.item; +unsigned int change =0 , reg_idx =0 , value, bit_pos; +struct snd_soc_dapm_update update; +int ret =0 , reg_val =0 , i;sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3060
Quoted 10 lines
sound/soc/soc-dapm.c +10
-0+ +if (item[0 ] >= e->items) +return -EINVAL ; + + value =snd_soc_enum_item_to_val (e, item[0 ]); + +if (value) { +/* get the register index and value to set */ + reg_idx = (value -1 ) / e->reg_width; + bit_pos = (value -1 ) % e->reg_width;Changing the ffs to
__ffsalso means you can drop the ' - 1' here.Also
e->reg_widthshould be (codec->val_bytes* 8) andreg_widthfield should be dropped from the enum struct.sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 7 lines
sound/soc/soc-dapm.c +7
-0+ reg_val =BIT (bit_pos); + } + +for (i =0 ; i < e->num_regs; i++) { +if (i == reg_idx) { + change = snd_soc_test_bits(codec, e->reg[i], + e->mask[i],
reg_val);sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ + }else { +/* accumulate the change to update the DAPM path
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3073
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+when none is selected */ + change +=snd_soc_test_bits (codec, e->reg[i], + e->mask[i],0 );change |=
Quoted 8 lines
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3076
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ +/* clear the register when not selected */ +snd_soc_write (codec, e->reg[i],0 );I think this should happen as part of the DAPM update sequence like you had earlier. Some special care should probably be take to make sure that you de-select the previous mux input before selecting the new one if the new one is in a different register than the previous one.
I am not sure I follow this part. We are clearing the 'not selected' registers before we set the one we want. Do you want us to loop the logic of soc_dapm_mux_update_power for each register ? or do you want to change the dapm_update structure so that it takes all the regs, masks, and values together ?
Quoted 8 lines
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 5 lines
sound/soc/soc-dapm.c +4
-0+ } + } + + mutex_lock_nested(&card->dapm_mutex,
SND_SOC_DAPM_CLASS_RUNTIME);Quoted 1 line
+
[...]
On 04/01/2014 08:26 PM, Arun Shamanna Lakshmi wrote:
[...]
Quoted 21 lines
Quoted 9 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 5 lines
sound/soc/soc-dapm.c index renamed from sound/soc/soc-dapm.c +0
-0c8a780d..4d2b35c 100644
sound/soc/soc-dapm.c +0
-0@@ -514,9 +514,9 @@ static int dapm_connect_mux(struct
snd_soc_dapm_context*dapm,Quoted 3 lines
sound/soc/soc-dapm.c +0
-0unsigned int val, item;int i;Quoted 11 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, · line 520
Quoted 7 lines
sound/soc/soc-dapm.c +3
-3-if (e->reg !=SND_SOC_NOPM ) { -soc_widget_read (dest, e->reg, &val); - val = (val >> e->shift_l) & e->mask; +if (e->reg[0 ] !=SND_SOC_NOPM ) { +soc_widget_read (dest, e->reg[0 ], &val); + val = (val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val);This probably should handle the new enum type as well. You'll probably need some kind of flag in the struct to distinguish between the two enum types.
Quoted 2 lines
Any suggestion on the flag name ?
How about 'onehot'?
[...]
Quoted 27 lines
Quoted 18 lines
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 7 lines
sound/soc/soc-dapm.c +7
-0+ reg_val =BIT (bit_pos); + } + +for (i =0 ; i < e->num_regs; i++) { +if (i == reg_idx) { + change = snd_soc_test_bits(codec, e->reg[i], + e->mask[i],
reg_val);sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ + }else { +/* accumulate the change to update the DAPM path
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3073
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+when none is selected */ + change +=snd_soc_test_bits (codec, e->reg[i], + e->mask[i],0 );change |=
Quoted 8 lines
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3076
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ +/* clear the register when not selected */ +snd_soc_write (codec, e->reg[i],0 );I think this should happen as part of the DAPM update sequence like you had earlier. Some special care should probably be take to make sure that you de-select the previous mux input before selecting the new one if the new one is in a different register than the previous one.
Quoted 5 lines
I am not sure I follow this part. We are clearing the 'not selected' registers before we set the one we want. Do you want us to loop the logic of
soc_dapm_mux_update_powerfor each register ? or do you want to change thedapm_updatestructure so that it takes all the regs, masks, and values together ?
The idea with the dapm_update struct is that the register updates are done in the middle of the power-down and power-up sequence. So yes, change the dapm_update struct to be able to hold all register updates and do all register updates in dapm_widget_update. I think an earlier version of your patch already had this.
Quoted 71 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:00 PM
To: Arun Shamanna Lakshmi
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Songhee Baek
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxOn 04/01/2014 08:26 PM, Arun Shamanna Lakshmi wrote:
[...]Quoted 21 lines
Quoted 9 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 5 lines
sound/soc/soc-dapm.c index renamed from sound/soc/soc-dapm.c +0
-0c8a780d..4d2b35c 100644
sound/soc/soc-dapm.c +0
-0@@ -514,9 +514,9 @@ static int dapm_connect_mux(struct
snd_soc_dapm_context*dapm,Quoted 3 lines
sound/soc/soc-dapm.c +0
-0unsigned int val, item;int i;Quoted 11 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, · line 520
Quoted 7 lines
sound/soc/soc-dapm.c +3
-3-if (e->reg !=SND_SOC_NOPM ) { -soc_widget_read (dest, e->reg, &val); - val = (val >> e->shift_l) & e->mask; +if (e->reg[0 ] !=SND_SOC_NOPM ) { +soc_widget_read (dest, e->reg[0 ], &val); + val = (val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val);This probably should handle the new enum type as well. You'll probably need some kind of flag in the struct to distinguish between the two enum types.
Quoted 2 lines
Any suggestion on the flag name ?
How about 'onehot'?
[...]
Quoted 27 lines
Quoted 18 lines
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 7 lines
sound/soc/soc-dapm.c +7
-0+ reg_val =BIT (bit_pos); + } + +for (i =0 ; i < e->num_regs; i++) { +if (i == reg_idx) { + change = snd_soc_test_bits(codec, e->reg[i], + e->mask[i],
reg_val);sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ + }else { +/* accumulate the change to update the DAPM path
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3073
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+when none is selected */ + change +=snd_soc_test_bits (codec, e->reg[i], + e->mask[i],0 );change |=
Quoted 8 lines
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3076
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ +/* clear the register when not selected */ +snd_soc_write (codec, e->reg[i],0 );I think this should happen as part of the DAPM update sequence like you had earlier. Some special care should probably be take to make sure that you de-select the previous mux input before selecting the new one if the new one is in a different register than the previous one.
Quoted 5 lines
I am not sure I follow this part. We are clearing the 'not selected' registers before we set the one we want. Do you want us to loop the logic of
soc_dapm_mux_update_powerfor each register ? or do you want to change thedapm_updatestructure so that it takes all the regs, masks, and values together ?
Quoted 5 lines
The idea with the
dapm_updatestruct is that the register updates are done in the middle of the power-down and power-up sequence. So yes, change thedapm_updatestruct to be able to hold all register updates and do all register updates indapm_widget_update. I think an earlier version of your patch already had this.
Is the change similar to as shown below?
for (reg_idx = 0; reg_idx < e->num_regs; reg_idx++) {
val = e->values[item * e->num_regs + reg_idx];
ret = snd_soc_update_bits_locked(codec, e->reg[reg_idx],
e->mask[reg_idx], val);
if (ret)
return ret;
}During updating of the register's value, the above change can create non-zero value in two different registers (very short transition) as Mark mentioned for that change so we need to clear register first before writing the desired value in the register.
Should we add the clearing all registers and write the mux value in desired register in the update function?
Quoted 87 lines · Songhee Baek
Quoted 71 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:00 PM
To: Arun Shamanna Lakshmi
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; Songhee Baek
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxOn 04/01/2014 08:26 PM, Arun Shamanna Lakshmi wrote:
[...]Quoted 21 lines
Quoted 9 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 5 lines
sound/soc/soc-dapm.c index renamed from sound/soc/soc-dapm.c +0
-0c8a780d..4d2b35c 100644
sound/soc/soc-dapm.c +0
-0@@ -514,9 +514,9 @@ static int dapm_connect_mux(struct
snd_soc_dapm_context*dapm,Quoted 3 lines
sound/soc/soc-dapm.c +0
-0unsigned int val, item;int i;Quoted 11 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, · line 520
Quoted 7 lines
sound/soc/soc-dapm.c +3
-3-if (e->reg !=SND_SOC_NOPM ) { -soc_widget_read (dest, e->reg, &val); - val = (val >> e->shift_l) & e->mask; +if (e->reg[0 ] !=SND_SOC_NOPM ) { +soc_widget_read (dest, e->reg[0 ], &val); + val = (val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val);This probably should handle the new enum type as well. You'll probably need some kind of flag in the struct to distinguish between the two enum types.
Quoted 2 lines
Any suggestion on the flag name ?
How about 'onehot'?
[...]
Quoted 27 lines
Quoted 18 lines
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 7 lines
sound/soc/soc-dapm.c +7
-0+ reg_val =BIT (bit_pos); + } + +for (i =0 ; i < e->num_regs; i++) { +if (i == reg_idx) { + change = snd_soc_test_bits(codec, e->reg[i], + e->mask[i],
reg_val);sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ + }else { +/* accumulate the change to update the DAPM path
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3073
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+when none is selected */ + change +=snd_soc_test_bits (codec, e->reg[i], + e->mask[i],0 );change |=
Quoted 8 lines
sound/soc/soc-dapm.c int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, · line 3076
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ +/* clear the register when not selected */ +snd_soc_write (codec, e->reg[i],0 );I think this should happen as part of the DAPM update sequence like you had earlier. Some special care should probably be take to make sure that you de-select the previous mux input before selecting the new one if the new one is in a different register than the previous one.
Quoted 5 lines
I am not sure I follow this part. We are clearing the 'not selected' registers before we set the one we want. Do you want us to loop the logic of
soc_dapm_mux_update_powerfor each register ? or do you want to change thedapm_updatestructure so that it takes all the regs, masks, and values together ?Quoted 5 lines
The idea with the
dapm_updatestruct is that the register updates are done in the middle of the power-down and power-up sequence. So yes, change thedapm_updatestruct to be able to hold all register updates and do all register updates indapm_widget_update. I think an earlier version of your patch already had this.Is the change similar to as shown below?
for (reg_idx = 0; reg_idx < e->num_regs; reg_idx++) { val = e->values[item * e->num_regs + reg_idx]; ret = snd_soc_update_bits_locked(codec, e->reg[reg_idx], e->mask[reg_idx], val); if (ret) return ret; }
Quoted 8 lines
During updating of the register's value, the above change can create non-zero value in two different registers (very short transition) as Mark mentioned for that change so we need to clear register first before writing the desired value in the register.
Should we add the clearing all registers and write the mux value in desired register in the update function?
In dapm_update_widget() you have this line:
ret = soc_widget_update_bits(w, update->reg, update->mask, update->val);
That needs to be done for every register update. When you setup the update struct you need to make sure that the register clears come before the register set.
E.g. if you have register 0x3, 0x4, 0x5 and you select a bit in register 0x4 it should look like this.
update->reg[0] = 0x3;
update->val[0] = 0x0;
update->reg[1] = 0x5;
update->val[1] = 0x0;
update->reg[2] = 0x4;
update->val[2] = 0x8;
When you set a bit in register 0x3 it should look like this:
update->reg[0] = 0x4;
update->val[0] = 0x0;
update->reg[1] = 0x5;
update->val[1] = 0x0;
update->reg[2] = 0x3;
update->val[2] = 0x1;
So basically the write operation goes into update->reg[e->num_regs-1] the clear operations go into the other slots before that.
- Lars
Quoted 139 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:47 PM
To: Songhee Baek
Cc: Arun Shamanna Lakshmi; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; alsa- [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxQuoted 5 lines · Songhee Baek
Quoted 5 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:00 PM
To: Arun Shamanna Lakshmi
Cc: [email protected]; [email protected];Quoted 41 lines
Quoted 41 lines
[email protected]; [email protected]; [email protected]; linux- [email protected]; Songhee Baek
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxOn 04/01/2014 08:26 PM, Arun Shamanna Lakshmi wrote:
[...]Quoted 21 lines
Quoted 9 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 5 lines
sound/soc/soc-dapm.c index renamed from sound/soc/soc-dapm.c +0
-0c8a780d..4d2b35c 100644
sound/soc/soc-dapm.c +0
-0@@ -514,9 +514,9 @@ static int dapm_connect_mux(struct
snd_soc_dapm_context*dapm,Quoted 3 lines
sound/soc/soc-dapm.c +0
-0unsigned int val, item;int i;Quoted 11 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct · line 520
Quoted 7 lines
sound/soc/soc-dapm.c +3
-3-if (e->reg !=SND_SOC_NOPM ) { -soc_widget_read (dest, e->reg, &val); - val = (val >> e->shift_l) & e->mask; +if (e->reg[0 ] !=SND_SOC_NOPM ) { +soc_widget_read (dest, e->reg[0 ], &val); + val = (val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val);This probably should handle the new enum type as well. You'll probably need some kind of flag in the struct to distinguish between the two enum types.
Quoted 2 lines
Any suggestion on the flag name ?
How about 'onehot'?
[...]
Quoted 8 lines
Quoted 8 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 7 lines
sound/soc/soc-dapm.c +7
-0+ reg_val =BIT (bit_pos); + } + +for (i =0 ; i < e->num_regs; i++) { +if (i == reg_idx) { + change = snd_soc_test_bits(codec, e->reg[i], + e->mask[i],
reg_val);Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ + }else { +/* accumulate the change to update the DAPM
Quoted 39 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
path
sound/soc/soc-dapm.c
Quoted 2 lines
sound/soc/soc-dapm.c +2
-0+when none is selected */ + change += snd_soc_test_bits(codec, e-reg[i],
Quoted 19 lines
Quoted 13 lines
Quoted 4 lines
sound/soc/soc-dapm.c
Quoted 1 line
sound/soc/soc-dapm.c +1
-0+ e->mask[i], 0);change |=
Quoted 8 lines
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ +/* clear the register when not selected */ +snd_soc_write (codec, e->reg[i],0 );I think this should happen as part of the DAPM update sequence like you had earlier. Some special care should probably be take to make sure that you de-select the previous mux input before selecting the new one if the new one is in a different register than the previous one.
Quoted 5 lines
I am not sure I follow this part. We are clearing the 'not selected' registers before we set the one we want. Do you want us to loop the logic of
soc_dapm_mux_update_powerfor each register ? or do you want to change thedapm_updatestructure so that it takes all the regs, masks, and values together ?Quoted 5 lines
The idea with the
dapm_updatestruct is that the register updates are done in the middle of the power-down and power-up sequence. So yes, change thedapm_updatestruct to be able to hold all register updates and do all register updates indapm_widget_update. I think an earlier version of your patch already had this.Is the change similar to as shown below?
for (reg_idx = 0; reg_idx < e->num_regs; reg_idx++) { val = e->values[item * e->num_regs + reg_idx]; ret = snd_soc_update_bits_locked(codec, e->reg[reg_idx], e->mask[reg_idx], val); if (ret) return ret; }Quoted 8 lines
During updating of the register's value, the above change can create non-zero value in two different registers (very short transition) as Mark mentioned for that change so we need to clear register first before writing the desired value in the register.
Should we add the clearing all registers and write the mux value in desired register in the update function?
In
dapm_update_widget()you have this line:ret = soc_widget_update_bits(w,
update->reg,update->mask, update-Quoted 1 line
val);
That needs to be done for every register update. When you setup the update struct you need to make sure that the register clears come before the register set.
E.g. if you have register
0x3,0x4,0x5and you select a bit in register0x4it should look like this.update->reg[0] =
0x3;
update->val[0] =0x0;
update->reg[1] =0x5;
update->val[1] =0x0;
update->reg[2] =0x4;
update->val[2] =0x8;When you set a bit in register
0x3it should look like this:update->reg[0] =
0x4;
update->val[0] =0x0;
update->reg[1] =0x5;
update->val[1] =0x0;
update->reg[2] =0x3;
update->val[2] =0x1;
Quoted 2 lines
So basically the write operation goes into update->reg[e->num_regs-1] the clear operations go into the other slots before that.
Does update reg/val array have the writing sequence, is it correct? And can I assume that update struct has reg/val/mask arrays not pointers?
Quoted 2 lines
- Lars
Quoted 139 lines · Songhee Baek
Quoted 139 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:47 PM
To: Songhee Baek
Cc: Arun Shamanna Lakshmi; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; alsa- [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxQuoted 5 lines · Songhee Baek
Quoted 5 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:00 PM
To: Arun Shamanna Lakshmi
Cc: [email protected]; [email protected];Quoted 41 lines
Quoted 41 lines
[email protected]; [email protected]; [email protected]; linux- [email protected]; Songhee Baek
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxOn 04/01/2014 08:26 PM, Arun Shamanna Lakshmi wrote:
[...]Quoted 21 lines
Quoted 9 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 5 lines
sound/soc/soc-dapm.c index renamed from sound/soc/soc-dapm.c +0
-0c8a780d..4d2b35c 100644
sound/soc/soc-dapm.c +0
-0@@ -514,9 +514,9 @@ static int dapm_connect_mux(struct
snd_soc_dapm_context*dapm,Quoted 3 lines
sound/soc/soc-dapm.c +0
-0unsigned int val, item;int i;Quoted 11 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct · line 520
Quoted 7 lines
sound/soc/soc-dapm.c +3
-3-if (e->reg !=SND_SOC_NOPM ) { -soc_widget_read (dest, e->reg, &val); - val = (val >> e->shift_l) & e->mask; +if (e->reg[0 ] !=SND_SOC_NOPM ) { +soc_widget_read (dest, e->reg[0 ], &val); + val = (val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val);This probably should handle the new enum type as well. You'll probably need some kind of flag in the struct to distinguish between the two enum types.
Quoted 2 lines
Any suggestion on the flag name ?
How about 'onehot'?
[...]
Quoted 8 lines
Quoted 8 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 7 lines
sound/soc/soc-dapm.c +7
-0+ reg_val =BIT (bit_pos); + } + +for (i =0 ; i < e->num_regs; i++) { +if (i == reg_idx) { + change = snd_soc_test_bits(codec, e->reg[i], + e->mask[i],
reg_val);Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ + }else { +/* accumulate the change to update the DAPM
Quoted 39 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
path
sound/soc/soc-dapm.c
Quoted 2 lines
sound/soc/soc-dapm.c +2
-0+when none is selected */ + change += snd_soc_test_bits(codec, e-reg[i],
Quoted 19 lines
Quoted 13 lines
Quoted 4 lines
sound/soc/soc-dapm.c
Quoted 1 line
sound/soc/soc-dapm.c +1
-0+ e->mask[i], 0);change |=
Quoted 8 lines
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ +/* clear the register when not selected */ +snd_soc_write (codec, e->reg[i],0 );I think this should happen as part of the DAPM update sequence like you had earlier. Some special care should probably be take to make sure that you de-select the previous mux input before selecting the new one if the new one is in a different register than the previous one.
Quoted 5 lines
I am not sure I follow this part. We are clearing the 'not selected' registers before we set the one we want. Do you want us to loop the logic of
soc_dapm_mux_update_powerfor each register ? or do you want to change thedapm_updatestructure so that it takes all the regs, masks, and values together ?Quoted 5 lines
The idea with the
dapm_updatestruct is that the register updates are done in the middle of the power-down and power-up sequence. So yes, change thedapm_updatestruct to be able to hold all register updates and do all register updates indapm_widget_update. I think an earlier version of your patch already had this.Is the change similar to as shown below?
for (reg_idx = 0; reg_idx < e->num_regs; reg_idx++) { val = e->values[item * e->num_regs + reg_idx]; ret = snd_soc_update_bits_locked(codec, e->reg[reg_idx], e->mask[reg_idx], val); if (ret) return ret; }Quoted 8 lines
During updating of the register's value, the above change can create non-zero value in two different registers (very short transition) as Mark mentioned for that change so we need to clear register first before writing the desired value in the register.
Should we add the clearing all registers and write the mux value in desired register in the update function?
In
dapm_update_widget()you have this line:ret = soc_widget_update_bits(w, update->reg, update->mask, update-Quoted 1 line
val);
That needs to be done for every register update. When you setup the update struct you need to make sure that the register clears come before the register set.
E.g. if you have register
0x3,0x4,0x5and you select a bit in register0x4it should look like this.update->reg[0] =
0x3;
update->val[0] =0x0;
update->reg[1] =0x5;
update->val[1] =0x0;
update->reg[2] =0x4;
update->val[2] =0x8;When you set a bit in register
0x3it should look like this:update->reg[0] =
0x4;
update->val[0] =0x0;
update->reg[1] =0x5;
update->val[1] =0x0;
update->reg[2] =0x3;
update->val[2] =0x1;
Quoted 5 lines
Quoted 2 lines
So basically the write operation goes into update->reg[e->num_regs-1] the clear operations go into the other slots before that.
Does update reg/val array have the writing sequence, is it correct? And can I assume that update struct has reg/val/mask arrays not pointers?
Right now the update struct does not have support for multiple register writes. That's up to you to implement this. I guess making it an array for now should be fine. But you need to add some safety checks to make sure that num_regs is not larger or equal to the array size.
Quoted 154 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Wednesday, April 02, 2014 12:02 AM
To: Songhee Baek
Cc: Arun Shamanna Lakshmi; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; alsa- [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxQuoted 71 lines · Songhee Baek
Quoted 71 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:47 PM
To: Songhee Baek
Cc: Arun Shamanna Lakshmi; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; alsa- [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxQuoted 5 lines · Songhee Baek
Quoted 5 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:00 PM
To: Arun Shamanna Lakshmi
Cc: [email protected]; [email protected];Quoted 41 lines
Quoted 41 lines
[email protected]; [email protected]; [email protected]; linux- [email protected]; Songhee Baek
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxOn 04/01/2014 08:26 PM, Arun Shamanna Lakshmi wrote:
[...]Quoted 21 lines
Quoted 9 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 5 lines
sound/soc/soc-dapm.c index renamed from sound/soc/soc-dapm.c +0
-0c8a780d..4d2b35c 100644
sound/soc/soc-dapm.c +0
-0@@ -514,9 +514,9 @@ static int dapm_connect_mux(struct
snd_soc_dapm_context*dapm,Quoted 3 lines
sound/soc/soc-dapm.c +0
-0unsigned int val, item;int i;Quoted 11 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct · line 520
Quoted 7 lines
sound/soc/soc-dapm.c +3
-3-if (e->reg !=SND_SOC_NOPM ) { -soc_widget_read (dest, e->reg, &val); - val = (val >> e->shift_l) & e->mask; +if (e->reg[0 ] !=SND_SOC_NOPM ) { +soc_widget_read (dest, e->reg[0 ], &val); + val = (val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val);This probably should handle the new enum type as well. You'll probably need some kind of flag in the struct to distinguish between the two enum types.
Quoted 2 lines
Any suggestion on the flag name ?
How about 'onehot'?
[...]
Quoted 8 lines
Quoted 8 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 7 lines
sound/soc/soc-dapm.c +7
-0+ reg_val =BIT (bit_pos); + } + +for (i =0 ; i < e->num_regs; i++) { +if (i == reg_idx) { + change = snd_soc_test_bits(codec, e->reg[i], + e->mask[i],
reg_val);Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ + }else { +/* accumulate the change to update the DAPM
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
path
sound/soc/soc-dapm.c
Quoted 2 lines
sound/soc/soc-dapm.c +2
-0+when none is selected */ + change += snd_soc_test_bits(codec, e-reg[i],
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
sound/soc/soc-dapm.c
Quoted 1 line
sound/soc/soc-dapm.c +1
-0+ e->mask[i], 0);change |=
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ +/* clear the register when not selected */ +snd_soc_write (codec, e->reg[i],0 );I think this should happen as part of the DAPM update sequence like you had earlier. Some special care should probably be take to make sure that you de-select the previous mux input before selecting the new one if the new one is in a different register than
the previous one.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
I am not sure I follow this part. We are clearing the 'not selected' registers before we set the one we want. Do you want us to loop the logic of
soc_dapm_mux_update_powerfor each register ? or do you want to change thedapm_updatestructure so that it takes all the regs, masks, and values together ?The idea with the
dapm_updatestruct is that the register updates are done in the middle of the power-down and power-up sequence.So
Quoted 54 lines
Quoted 53 lines
Quoted 14 lines
Quoted 3 lines
yes, change the
dapm_updatestruct to be able to hold all register updates and do all register updates indapm_widget_update. I think an earlier version of your patch already had this.Is the change similar to as shown below?
for (reg_idx = 0; reg_idx < e->num_regs; reg_idx++) { val = e->values[item * e->num_regs + reg_idx]; ret = snd_soc_update_bits_locked(codec, e->reg[reg_idx], e->mask[reg_idx], val); if (ret) return ret; }Quoted 8 lines
During updating of the register's value, the above change can create non-zero value in two different registers (very short transition) as Mark mentioned for that change so we need to clear register first before writing the desired value in the register.
Should we add the clearing all registers and write the mux value in desired register in the update function?
In
dapm_update_widget()you have this line:ret = soc_widget_update_bits(w, update->reg, update->mask, update-Quoted 1 line
val);
That needs to be done for every register update. When you setup the update struct you need to make sure that the register clears come before the register set.
E.g. if you have register
0x3,0x4,0x5and you select a bit in register0x4it should look like this.update->reg[0] =
0x3;
update->val[0] =0x0;
update->reg[1] =0x5;
update->val[1] =0x0;
update->reg[2] =0x4;
update->val[2] =0x8;When you set a bit in register
0x3it should look like this:update->reg[0] =
0x4;
update->val[0] =0x0;
update->reg[1] =0x5;
update->val[1] =0x0;
update->reg[2] =0x3;
update->val[2] =0x1;So basically the write operation goes into update->reg[e->num_regs-1] the clear operations go into the other slots before that.
Quoted 7 lines
Quoted 2 lines
Does update reg/val array have the writing sequence, is it correct? And can I assume that update struct has reg/val/mask arrays not pointers?
Right now the update struct does not have support for multiple register writes. That's up to you to implement this. I guess making it an array for now should be fine. But you need to add some safety checks to make sure that
num_regsis not larger or equal to the array size.
Thank you for the clarification. We will add this in dapm update struct.
Quoted 154 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Wednesday, April 02, 2014 12:02 AM
To: Songhee Baek
Cc: Arun Shamanna Lakshmi; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; alsa- [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxQuoted 71 lines · Songhee Baek
Quoted 71 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:47 PM
To: Songhee Baek
Cc: Arun Shamanna Lakshmi; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; alsa- [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxQuoted 5 lines · Songhee Baek
Quoted 5 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:00 PM
To: Arun Shamanna Lakshmi
Cc: [email protected]; [email protected];Quoted 41 lines
Quoted 41 lines
[email protected]; [email protected]; [email protected]; linux- [email protected]; Songhee Baek
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxOn 04/01/2014 08:26 PM, Arun Shamanna Lakshmi wrote:
[...]Quoted 21 lines
Quoted 9 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 5 lines
sound/soc/soc-dapm.c index renamed from sound/soc/soc-dapm.c +0
-0c8a780d..4d2b35c 100644
sound/soc/soc-dapm.c +0
-0@@ -514,9 +514,9 @@ static int dapm_connect_mux(struct
snd_soc_dapm_context*dapm,Quoted 3 lines
sound/soc/soc-dapm.c +0
-0unsigned int val, item;int i;Quoted 11 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct · line 520
Quoted 7 lines
sound/soc/soc-dapm.c +3
-3-if (e->reg !=SND_SOC_NOPM ) { -soc_widget_read (dest, e->reg, &val); - val = (val >> e->shift_l) & e->mask; +if (e->reg[0 ] !=SND_SOC_NOPM ) { +soc_widget_read (dest, e->reg[0 ], &val); + val = (val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val);This probably should handle the new enum type as well. You'll probably need some kind of flag in the struct to distinguish between the two enum types.
Quoted 2 lines
Any suggestion on the flag name ?
How about 'onehot'?
[...]
Quoted 8 lines
Quoted 8 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 7 lines
sound/soc/soc-dapm.c +7
-0+ reg_val =BIT (bit_pos); + } + +for (i =0 ; i < e->num_regs; i++) { +if (i == reg_idx) { + change = snd_soc_test_bits(codec, e->reg[i], + e->mask[i],
reg_val);Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ + }else { +/* accumulate the change to update the DAPM
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
path
sound/soc/soc-dapm.c
Quoted 2 lines
sound/soc/soc-dapm.c +2
-0+when none is selected */ + change += snd_soc_test_bits(codec, e-reg[i],
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
sound/soc/soc-dapm.c
Quoted 1 line
sound/soc/soc-dapm.c +1
-0+ e->mask[i], 0);change |=
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ +/* clear the register when not selected */ +snd_soc_write (codec, e->reg[i],0 );I think this should happen as part of the DAPM update sequence like you had earlier. Some special care should probably be take to make sure that you de-select the previous mux input before selecting the new one if the new one is in a different register than
the previous one.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
I am not sure I follow this part. We are clearing the 'not selected' registers before we set the one we want. Do you want us to loop the logic of
soc_dapm_mux_update_powerfor each register ? or do you want to change thedapm_updatestructure so that it takes all the regs, masks, and values together ?The idea with the
dapm_updatestruct is that the register updates are done in the middle of the power-down and power-up sequence.So
Quoted 54 lines
Quoted 53 lines
Quoted 14 lines
Quoted 3 lines
yes, change the
dapm_updatestruct to be able to hold all register updates and do all register updates indapm_widget_update. I think an earlier version of your patch already had this.Is the change similar to as shown below?
for (reg_idx = 0; reg_idx < e->num_regs; reg_idx++) { val = e->values[item * e->num_regs + reg_idx]; ret = snd_soc_update_bits_locked(codec, e->reg[reg_idx], e->mask[reg_idx], val); if (ret) return ret; }Quoted 8 lines
During updating of the register's value, the above change can create non-zero value in two different registers (very short transition) as Mark mentioned for that change so we need to clear register first before writing the desired value in the register.
Should we add the clearing all registers and write the mux value in desired register in the update function?
In
dapm_update_widget()you have this line:ret = soc_widget_update_bits(w, update->reg, update->mask, update-Quoted 1 line
val);
That needs to be done for every register update. When you setup the update struct you need to make sure that the register clears come before the register set.
E.g. if you have register
0x3,0x4,0x5and you select a bit in register0x4it should look like this.update->reg[0] =
0x3;
update->val[0] =0x0;
update->reg[1] =0x5;
update->val[1] =0x0;
update->reg[2] =0x4;
update->val[2] =0x8;When you set a bit in register
0x3it should look like this:update->reg[0] =
0x4;
update->val[0] =0x0;
update->reg[1] =0x5;
update->val[1] =0x0;
update->reg[2] =0x3;
update->val[2] =0x1;So basically the write operation goes into update->reg[e->num_regs-1] the clear operations go into the other slots before that.
Quoted 7 lines
Quoted 2 lines
Does update reg/val array have the writing sequence, is it correct? And can I assume that update struct has reg/val/mask arrays not pointers?
Right now the update struct does not have support for multiple register writes. That's up to you to implement this. I guess making it an array for now should be fine. But you need to add some safety checks to make sure that
num_regsis not larger or equal to the array size.
I think that the dapm update struct needs to have reg[2]/val[2]/mask[2]. Because the mux is one-hot coded, only one register has a non-zero value. So reg[0] will contain the register to be clear and reg[2] has selected register to be set.
How about your opinion for this?
Quoted 162 lines · Songhee Baek
Quoted 154 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Wednesday, April 02, 2014 12:02 AM
To: Songhee Baek
Cc: Arun Shamanna Lakshmi; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; alsa- [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxQuoted 71 lines · Songhee Baek
Quoted 71 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:47 PM
To: Songhee Baek
Cc: Arun Shamanna Lakshmi; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; alsa- [email protected]; [email protected]
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxQuoted 5 lines · Songhee Baek
Quoted 5 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Tuesday, April 01, 2014 11:00 PM
To: Arun Shamanna Lakshmi
Cc: [email protected]; [email protected];Quoted 41 lines
Quoted 41 lines
[email protected]; [email protected]; [email protected]; linux- [email protected]; Songhee Baek
Subject: Re: [PATCH] ASoC: DAPM: Add support for multi register muxOn 04/01/2014 08:26 PM, Arun Shamanna Lakshmi wrote:
[...]Quoted 21 lines
Quoted 9 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 5 lines
sound/soc/soc-dapm.c index renamed from sound/soc/soc-dapm.c +0
-0c8a780d..4d2b35c 100644
sound/soc/soc-dapm.c +0
-0@@ -514,9 +514,9 @@ static int dapm_connect_mux(struct
snd_soc_dapm_context*dapm,Quoted 3 lines
sound/soc/soc-dapm.c +0
-0unsigned int val, item;int i;Quoted 11 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct · line 520
Quoted 7 lines
sound/soc/soc-dapm.c +3
-3-if (e->reg !=SND_SOC_NOPM ) { -soc_widget_read (dest, e->reg, &val); - val = (val >> e->shift_l) & e->mask; +if (e->reg[0 ] !=SND_SOC_NOPM ) { +soc_widget_read (dest, e->reg[0 ], &val); + val = (val >> e->shift_l) & e->mask[0 ]; item =snd_soc_enum_val_to_item (e, val);This probably should handle the new enum type as well. You'll probably need some kind of flag in the struct to distinguish between the two enum types.
Quoted 2 lines
Any suggestion on the flag name ?
How about 'onehot'?
[...]
Quoted 8 lines
Quoted 8 lines
sound/soc/soc-dapm.c static int dapm_connect_mux(struct
Quoted 7 lines
sound/soc/soc-dapm.c +7
-0+ reg_val =BIT (bit_pos); + } + +for (i =0 ; i < e->num_regs; i++) { +if (i == reg_idx) { + change = snd_soc_test_bits(codec, e->reg[i], + e->mask[i],
reg_val);Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ + }else { +/* accumulate the change to update the DAPM
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
path
sound/soc/soc-dapm.c
Quoted 2 lines
sound/soc/soc-dapm.c +2
-0+when none is selected */ + change += snd_soc_test_bits(codec, e-reg[i],
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
sound/soc/soc-dapm.c
Quoted 1 line
sound/soc/soc-dapm.c +1
-0+ e->mask[i], 0);change |=
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
sound/soc/soc-dapm.c
Quoted 3 lines
sound/soc/soc-dapm.c +3
-0+ +/* clear the register when not selected */ +snd_soc_write (codec, e->reg[i],0 );I think this should happen as part of the DAPM update sequence like you had earlier. Some special care should probably be take to make sure that you de-select the previous mux input before selecting the new one if the new one is in a different register than
the previous one.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
I am not sure I follow this part. We are clearing the 'not selected' registers before we set the one we want. Do you want us to loop the logic of
soc_dapm_mux_update_powerfor each register ? or do you want to change thedapm_updatestructure so that it takes all the regs, masks, and values together ?The idea with the
dapm_updatestruct is that the register updates are done in the middle of the power-down and power-up sequence.So
Quoted 54 lines
Quoted 53 lines
Quoted 14 lines
Quoted 3 lines
yes, change the
dapm_updatestruct to be able to hold all register updates and do all register updates indapm_widget_update. I think an earlier version of your patch already had this.Is the change similar to as shown below?
for (reg_idx = 0; reg_idx < e->num_regs; reg_idx++) { val = e->values[item * e->num_regs + reg_idx]; ret = snd_soc_update_bits_locked(codec, e->reg[reg_idx], e->mask[reg_idx], val); if (ret) return ret; }Quoted 8 lines
During updating of the register's value, the above change can create non-zero value in two different registers (very short transition) as Mark mentioned for that change so we need to clear register first before writing the desired value in the register.
Should we add the clearing all registers and write the mux value in desired register in the update function?
In
dapm_update_widget()you have this line:ret = soc_widget_update_bits(w, update->reg, update->mask, update-Quoted 1 line
val);
That needs to be done for every register update. When you setup the update struct you need to make sure that the register clears come before the register set.
E.g. if you have register
0x3,0x4,0x5and you select a bit in register0x4it should look like this.update->reg[0] =
0x3;
update->val[0] =0x0;
update->reg[1] =0x5;
update->val[1] =0x0;
update->reg[2] =0x4;
update->val[2] =0x8;When you set a bit in register
0x3it should look like this:update->reg[0] =
0x4;
update->val[0] =0x0;
update->reg[1] =0x5;
update->val[1] =0x0;
update->reg[2] =0x3;
update->val[2] =0x1;So basically the write operation goes into update->reg[e->num_regs-1] the clear operations go into the other slots before that.
Quoted 7 lines
Quoted 2 lines
Does update reg/val array have the writing sequence, is it correct? And can I assume that update struct has reg/val/mask arrays not pointers?
Right now the update struct does not have support for multiple register writes. That's up to you to implement this. I guess making it an array for now should be fine. But you need to add some safety checks to make sure that
num_regsis not larger or equal to the array size.
Quoted 5 lines
I think that the dapm update struct needs to have reg[2]/val[2]/mask[2]. Because the mux is one-hot coded, only one register has a non-zero value. So reg[0] will contain the register to be clear and reg[2] has selected register to be set.
How about your opinion for this?
Should work (in theory).
- Lars