[alsa-devel] usage of SOC_ENUM_SINGLE
Hi
I am trying to add an output control which is basically a switch between headset and earpiece. The H/W register for this asks me to write 0x40 for EP and 0x3 for enabling Headset
So I did this:
static const char *headset_switch_text[] = { "Earpiece", "HeadSet" };
static const struct snd_kcontrol_new intel_msic_snd_controls[] = { SOC_ENUM_SINGLE(OUTEN, 0x43, 0x40, headset_switch_text), };
Would this be the right thing, I am interpreting that 0x40 will be written for earpiece in above and 0x3 for headset
~Vinod
On Fri, Nov 26, 2010 at 03:48:49PM +0530, Koul, Vinod wrote:
static const struct snd_kcontrol_new intel_msic_snd_controls[] = { SOC_ENUM_SINGLE(OUTEN, 0x43, 0x40, headset_switch_text), };
Would this be the right thing, I am interpreting that 0x40 will be written for earpiece in above and 0x3 for headset
No, that will cause you to have an enumeration with 0x40 elements starting at bit 0x43 in the register. You're looking for a SOC_VALUE_ENUM, not a SOC_ENUM - SOC_ENUM covers contiguous ranges of values in the enumeration.
Note also that you should namespace the #defines for your register names.
On Fri, Nov 26, 2010 at 05:22:35PM +0530, Mark Brown wrote:
On Fri, Nov 26, 2010 at 03:48:49PM +0530, Koul, Vinod wrote:
static const struct snd_kcontrol_new intel_msic_snd_controls[] = { SOC_ENUM_SINGLE(OUTEN, 0x43, 0x40, headset_switch_text), };
Would this be the right thing, I am interpreting that 0x40 will be written
for
earpiece in above and 0x3 for headset
No, that will cause you to have an enumeration with 0x40 elements starting at bit 0x43 in the register. You're looking for a SOC_VALUE_ENUM, not a SOC_ENUM - SOC_ENUM covers contiguous ranges of values in the enumeration.
Thanks Mark, So this should do, right?
SOC_VALUE_ENUM_SINGLE(MSIC_OUTEN, 0, 0x43, ARRAY_SIZE(headset_switch_text), headset_switch_text, headset_switch_values)
With, static const char *headset_switch_values[] = { "0x40", "0x03" };
I am interpreting that for earpiece 0x40 will be written to this register and for headset 0x03 to register offset MSIC_OUTEN with mask value of 0x43 (not changing other bits in this register).
I am interpreting xmask as a mask value that will be applied while changing this value, so that other bits are not changes
Note also that you should namespace the #defines for your register names.
Yup, added MSIC_ to register defines
Thanks Vinod
On Fri, Nov 26, 2010 at 08:15:11PM +0530, Koul, Vinod wrote:
So this should do, right?
SOC_VALUE_ENUM_SINGLE(MSIC_OUTEN, 0, 0x43, ARRAY_SIZE(headset_switch_text), headset_switch_text, headset_switch_values)
With, static const char *headset_switch_values[] = { "0x40", "0x03" };
No, that's not going to work and I'd be astonished if it compiled cleanly. You need to pass the *values* you want to set - look at the uses of this in exiting CODEC drivers for examples of how to use this.
participants (2)
-
Koul, Vinod
-
Mark Brown