* [PATCH 2/6] ESI W192M : Update eeprom structure to C99 standard [not found] <1426641991-3694-1-git-send-email-me> @ 2015-03-18 1:26 ` klem.dev 2015-03-18 1:26 ` [PATCH 3/6] ESI W192M : Enable midi i/o of port envy24 chip as available klem.dev ` (3 subsequent siblings) 4 siblings, 0 replies; 12+ messages in thread From: klem.dev @ 2015-03-18 1:26 UTC (permalink / raw) To: patch; +Cc: Clément Guedez, alsa-devel From: Clément Guedez <klem.dev@gmail.com> Update eeprom structure to C99 standard to be compliant with change in alsa. It's just a notation change, no configuration change. Signed-off-by: Clément Guedez <klem.dev@gmail.com> diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index f65ac19..6e1026e 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -485,19 +485,19 @@ static int wtm_init(struct snd_ice1712 *ice) static unsigned char wtm_eeprom[] = { - 0x47, /*SYSCONF: clock 192KHz, 4ADC, 8DAC */ - 0x80, /* ACLINK : I2S */ - 0xf8, /* I2S: vol; 96k, 24bit, 192k */ - 0xc1 /*SPDIF: out-en, spidf ext out*/, - 0x9f, /* GPIO_DIR */ - 0xff, /* GPIO_DIR1 */ - 0x7f, /* GPIO_DIR2 */ - 0x9f, /* GPIO_MASK */ - 0xff, /* GPIO_MASK1 */ - 0x7f, /* GPIO_MASK2 */ - 0x16, /* GPIO_STATE */ - 0x80, /* GPIO_STATE1 */ - 0x00, /* GPIO_STATE2 */ + [ICE_EEP2_SYSCONF] = 0x47, /*SYSCONF: clock 192KHz, 4ADC, 8DAC */ + [ICE_EEP2_ACLINK] = 0x80, /* ACLINK : I2S */ + [ICE_EEP2_I2S] = 0xf8, /* I2S: vol; 96k, 24bit, 192k */ + [ICE_EEP2_SPDIF] = 0xc1, /*SPDIF: out-en, spidf ext out*/ + [ICE_EEP2_GPIO_DIR] = 0x9f, + [ICE_EEP2_GPIO_DIR1] = 0xff, + [ICE_EEP2_GPIO_DIR2] = 0x7f, + [ICE_EEP2_GPIO_MASK] = 0x9f, + [ICE_EEP2_GPIO_MASK1] = 0xff, + [ICE_EEP2_GPIO_MASK2] = 0x7f, + [ICE_EEP2_GPIO_STATE] = 0x16, + [ICE_EEP2_GPIO_STATE1] = 0x80, + [ICE_EEP2_GPIO_STATE2] = 0x00, }; -- 2.1.4 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/6] ESI W192M : Enable midi i/o of port envy24 chip as available [not found] <1426641991-3694-1-git-send-email-me> 2015-03-18 1:26 ` [PATCH 2/6] ESI W192M : Update eeprom structure to C99 standard klem.dev @ 2015-03-18 1:26 ` klem.dev 2015-03-18 1:26 ` [PATCH 4/6] ESI W192M : Add TLV support for control value in dB scale klem.dev ` (2 subsequent siblings) 4 siblings, 0 replies; 12+ messages in thread From: klem.dev @ 2015-03-18 1:26 UTC (permalink / raw) To: patch; +Cc: Clément Guedez, alsa-devel From: Clément Guedez <klem.dev@gmail.com> Enable midi i/o port of envy24 chip as their are available on ESI W192M soundcard. Signed-off-by: Clément Guedez <klem.dev@gmail.com> diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index 6e1026e..59483b4 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -485,7 +485,8 @@ static int wtm_init(struct snd_ice1712 *ice) static unsigned char wtm_eeprom[] = { - [ICE_EEP2_SYSCONF] = 0x47, /*SYSCONF: clock 192KHz, 4ADC, 8DAC */ + [ICE_EEP2_SYSCONF] = 0x67, /*SYSCONF: clock 192KHz, mpu401, + 4ADC, 8DAC */ [ICE_EEP2_ACLINK] = 0x80, /* ACLINK : I2S */ [ICE_EEP2_I2S] = 0xf8, /* I2S: vol; 96k, 24bit, 192k */ [ICE_EEP2_SPDIF] = 0xc1, /*SPDIF: out-en, spidf ext out*/ -- 2.1.4 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/6] ESI W192M : Add TLV support for control value in dB scale [not found] <1426641991-3694-1-git-send-email-me> 2015-03-18 1:26 ` [PATCH 2/6] ESI W192M : Update eeprom structure to C99 standard klem.dev 2015-03-18 1:26 ` [PATCH 3/6] ESI W192M : Enable midi i/o of port envy24 chip as available klem.dev @ 2015-03-18 1:26 ` klem.dev 2015-03-18 1:26 ` [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state klem.dev 2015-03-18 1:26 ` [PATCH 6/6] ESI W192M : Add sampling rate control of the ADC/DAC klem.dev 4 siblings, 0 replies; 12+ messages in thread From: klem.dev @ 2015-03-18 1:26 UTC (permalink / raw) To: patch; +Cc: Clément Guedez, alsa-devel From: Clément Guedez <klem.dev@gmail.com> Add TLV support to control volume using dB scale for input and ouput on ESI W192M. Signed-off-by: Clément Guedez <klem.dev@gmail.com> diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index 59483b4..c7ffafa 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -29,6 +29,7 @@ #include <linux/interrupt.h> #include <linux/init.h> #include <sound/core.h> +#include <sound/tlv.h> #include "ice1712.h" #include "envy24ht.h" @@ -380,17 +381,25 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol, return change; } + +/*Limits value in dB for fader*/ +static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0); +static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0); + /* * Control tabs */ static struct snd_kcontrol_new stac9640_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | + SNDRV_CTL_ELEM_ACCESS_TLV_READ), .name = "Master Playback Switch", .info = stac9460_dac_mute_info, .get = stac9460_dac_mute_get, .put = stac9460_dac_mute_put, - .private_value = 1 + .private_value = 1, + .tlv = { .p = db_scale_dac } }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -419,11 +428,15 @@ static struct snd_kcontrol_new stac9640_controls[] = { }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | + SNDRV_CTL_ELEM_ACCESS_TLV_READ), + .name = "DAC Volume", .count = 8, .info = stac9460_dac_vol_info, .get = stac9460_dac_vol_get, .put = stac9460_dac_vol_put, + .tlv = { .p = db_scale_dac } }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -435,12 +448,15 @@ static struct snd_kcontrol_new stac9640_controls[] = { }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | + SNDRV_CTL_ELEM_ACCESS_TLV_READ), + .name = "ADC Volume", .count = 2, .info = stac9460_adc_vol_info, .get = stac9460_adc_vol_get, .put = stac9460_adc_vol_put, - + .tlv = { .p = db_scale_adc } } }; -- 2.1.4 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state [not found] <1426641991-3694-1-git-send-email-me> ` (2 preceding siblings ...) 2015-03-18 1:26 ` [PATCH 4/6] ESI W192M : Add TLV support for control value in dB scale klem.dev @ 2015-03-18 1:26 ` klem.dev 2015-03-18 1:26 ` [PATCH 6/6] ESI W192M : Add sampling rate control of the ADC/DAC klem.dev 4 siblings, 0 replies; 12+ messages in thread From: klem.dev @ 2015-03-18 1:26 UTC (permalink / raw) To: patch; +Cc: Clément Guedez, alsa-devel From: Clément Guedez <klem.dev@gmail.com> Add text Line in/Mic for selecting input gain state in mixer for ESI W192M. Signed-off-by: Clément Guedez <klem.dev@gmail.com> diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index c7ffafa..6d3412f 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -339,8 +339,14 @@ static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol, /* * MIC / LINE switch fonction */ +static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static const char * const texts[2] = { "Line In", "Mic" }; + + return snd_ctl_enum_info(uinfo, 1, 2, texts); +} -#define stac9460_mic_sw_info snd_ctl_boolean_mono_info static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -354,7 +360,7 @@ static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); - ucontrol->value.integer.value[0] = ~val>>7 & 0x1; + ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1; return 0; } @@ -370,7 +376,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol, old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); - new = (~ucontrol->value.integer.value[0] << 7 & 0x80) | (old & ~0x80); + new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80); change = (new != old); if (change) { if (id == 0) @@ -411,7 +417,7 @@ static struct snd_kcontrol_new stac9640_controls[] = { }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "MIC/Line switch", + .name = "MIC/Line Input Enum", .count = 2, .info = stac9460_mic_sw_info, .get = stac9460_mic_sw_get, -- 2.1.4 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/6] ESI W192M : Add sampling rate control of the ADC/DAC [not found] <1426641991-3694-1-git-send-email-me> ` (3 preceding siblings ...) 2015-03-18 1:26 ` [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state klem.dev @ 2015-03-18 1:26 ` klem.dev 4 siblings, 0 replies; 12+ messages in thread From: klem.dev @ 2015-03-18 1:26 UTC (permalink / raw) To: patch; +Cc: Clément Guedez, alsa-devel From: Clément Guedez <klem.dev@gmail.com> Add sampling rate control for ADC/DAC for ESI W192M. Allow to switch between 48K/96K/192K sampling rate. All DAC need to be mute when changing samplerate. Signed-off-by: Clément Guedez <klem.dev@gmail.com> diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index 6d3412f..9906119 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -30,12 +30,18 @@ #include <linux/init.h> #include <sound/core.h> #include <sound/tlv.h> +#include <linux/slab.h> #include "ice1712.h" #include "envy24ht.h" #include "wtm.h" #include "stac946x.h" +struct wtm_spec { + /* rate change needs atomic mute/unmute of all dacs*/ + struct mutex mute_mutex; +}; + /* * 2*ADC 6*DAC no1 ringbuffer r/w on i2c bus @@ -69,15 +75,65 @@ static inline unsigned char stac9460_2_get(struct snd_ice1712 *ice, int reg) /* * DAC mute control */ +static void stac9460_dac_mute_all(struct snd_ice1712 *ice, unsigned char mute, + unsigned short int *change_mask) +{ + unsigned char new, old; + int id, idx, change; + + /*stac9460 1*/ + for (id = 0; id < 7; id++) { + if (*change_mask & (0x01 << id)) { + if (id == 0) + idx = STAC946X_MASTER_VOLUME; + else + idx = STAC946X_LF_VOLUME - 1 + id; + old = stac9460_get(ice, idx); + new = (~mute << 7 & 0x80) | (old & ~0x80); + change = (new != old); + if (change) { + stac9460_put(ice, idx, new); + *change_mask = *change_mask | (0x01 << id); + } else { + *change_mask = *change_mask & ~(0x01 << id); + } + } + } + + /*stac9460 2*/ + for (id = 0; id < 3; id++) { + if (*change_mask & (0x01 << (id + 7))) { + if (id == 0) + idx = STAC946X_MASTER_VOLUME; + else + idx = STAC946X_LF_VOLUME - 1 + id; + old = stac9460_2_get(ice, idx); + new = (~mute << 7 & 0x80) | (old & ~0x80); + change = (new != old); + if (change) { + stac9460_2_put(ice, idx, new); + *change_mask = *change_mask | (0x01 << id); + } else { + *change_mask = *change_mask & ~(0x01 << id); + } + } + } +} + + + #define stac9460_dac_mute_info snd_ctl_boolean_mono_info static int stac9460_dac_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); + struct wtm_spec *spec = ice->spec; unsigned char val; int idx, id; + mutex_lock(&spec->mute_mutex); + if (kcontrol->private_value) { idx = STAC946X_MASTER_VOLUME; id = 0; @@ -90,6 +146,8 @@ static int stac9460_dac_mute_get(struct snd_kcontrol *kcontrol, else val = stac9460_2_get(ice, idx - 6); ucontrol->value.integer.value[0] = (~val >> 7) & 0x1; + + mutex_unlock(&spec->mute_mutex); return 0; } @@ -388,6 +446,44 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol, } +/* + * Handler for setting correct codec rate - called when rate change is detected + */ +static void stac9460_set_rate_val(struct snd_ice1712 *ice, unsigned int rate) +{ + unsigned char old, new; + unsigned short int changed; + struct wtm_spec *spec = ice->spec; + + if (rate == 0) /* no hint - S/PDIF input is master, simply return */ + return; + else if (rate <= 48000) + new = 0x08; /* 256x, base rate mode */ + else if (rate <= 96000) + new = 0x11; /* 256x, mid rate mode */ + else + new = 0x12; /* 128x, high rate mode */ + + old = stac9460_get(ice, STAC946X_MASTER_CLOCKING); + if (old == new) + return; + /* change detected, setting master clock, muting first */ + /* due to possible conflicts with mute controls - mutexing */ + mutex_lock(&spec->mute_mutex); + /* we have to remember current mute status for each DAC */ + changed = 0xFFFF; + stac9460_dac_mute_all(ice, 0, &changed); + /*printk(KERN_DEBUG "Rate change: %d, new MC: 0x%02x\n", rate, new);*/ + stac9460_put(ice, STAC946X_MASTER_CLOCKING, new); + stac9460_2_put(ice, STAC946X_MASTER_CLOCKING, new); + udelay(10); + /* unmuting - only originally unmuted dacs - + * i.e. those changed when muting */ + stac9460_dac_mute_all(ice, 1, &changed); + mutex_unlock(&spec->mute_mutex); +} + + /*Limits value in dB for fader*/ static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0); static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0); @@ -487,21 +583,32 @@ static int wtm_init(struct snd_ice1712 *ice) { static unsigned short stac_inits_wtm[] = { STAC946X_RESET, 0, + STAC946X_MASTER_CLOCKING, 0x11, (unsigned short)-1 }; unsigned short *p; + struct wtm_spec *spec; /*WTM 192M*/ ice->num_total_dacs = 8; ice->num_total_adcs = 4; ice->force_rdma1 = 1; + /*init mutex for dac mute conflict*/ + spec = kzalloc(sizeof(*spec), GFP_KERNEL); + if (!spec) + return -ENOMEM; + ice->spec = spec; + mutex_init(&spec->mute_mutex); + + /*initialize codec*/ p = stac_inits_wtm; for (; *p != (unsigned short)-1; p += 2) { stac9460_put(ice, p[0], p[1]); stac9460_2_put(ice, p[0], p[1]); } + ice->gpio.set_pro_rate = stac9460_set_rate_val; return 0; } -- 2.1.4 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 12+ messages in thread
[parent not found: <1426465255-19005-1-git-send-email-me>]
* [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state [not found] <1426465255-19005-1-git-send-email-me> @ 2015-03-16 0:20 ` klem.dev 2015-03-16 7:51 ` Takashi Iwai 0 siblings, 1 reply; 12+ messages in thread From: klem.dev @ 2015-03-16 0:20 UTC (permalink / raw) To: patch; +Cc: Clément Guedez, alsa-devel From: Clément Guedez <klem.dev@gmail.com> Add text Line in/Mic for selecting input gain state in mixer for ESI W192M. Signed-off-by: Clément Guedez <klem.dev@gmail.com> diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index c7ffafa..a6e7afa 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -339,8 +339,14 @@ static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol, /* * MIC / LINE switch fonction */ +static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static const char * const texts[2] = { "Line In", "Mic" }; + + return snd_ctl_enum_info(uinfo, 1, 2, texts); +} -#define stac9460_mic_sw_info snd_ctl_boolean_mono_info static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -354,7 +360,7 @@ static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); - ucontrol->value.integer.value[0] = ~val>>7 & 0x1; + ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1; return 0; } @@ -370,7 +376,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol, old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); - new = (~ucontrol->value.integer.value[0] << 7 & 0x80) | (old & ~0x80); + new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80); change = (new != old); if (change) { if (id == 0) -- 2.1.4 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state 2015-03-16 0:20 ` [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state klem.dev @ 2015-03-16 7:51 ` Takashi Iwai 2015-03-16 14:54 ` Clément Guedez 0 siblings, 1 reply; 12+ messages in thread From: Takashi Iwai @ 2015-03-16 7:51 UTC (permalink / raw) To: klem.dev; +Cc: alsa-devel At Mon, 16 Mar 2015 01:20:54 +0100, klem.dev@gmail.com wrote: > > From: Clément Guedez <klem.dev@gmail.com> > > Add text Line in/Mic for selecting input gain state in mixer for ESI W192M. What I meant is to change control name "Line Switch" to a different suffix (oh, anyway there is a typo in the original code, it's written as "switch", not "Switch"...) The type of control element is identified by a string name rule in some levels. When a control is named as "XXX Switch", it's taken as a boolean control. For enum control, we usually take "Enum" suffix so that alsa-lib simple mixer interface can recognize it as an enumerated control. (Hm, it's not mentioned in Documentation/sound/alsa/ControlNames.txt. An update is needed...) Takashi > > Signed-off-by: Clément Guedez <klem.dev@gmail.com> > > diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c > index c7ffafa..a6e7afa 100644 > --- a/sound/pci/ice1712/wtm.c > +++ b/sound/pci/ice1712/wtm.c > @@ -339,8 +339,14 @@ static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol, > /* > * MIC / LINE switch fonction > */ > +static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_info *uinfo) > +{ > + static const char * const texts[2] = { "Line In", "Mic" }; > + > + return snd_ctl_enum_info(uinfo, 1, 2, texts); > +} > > -#define stac9460_mic_sw_info snd_ctl_boolean_mono_info > > static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, > struct snd_ctl_elem_value *ucontrol) > @@ -354,7 +360,7 @@ static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, > val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); > else > val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); > - ucontrol->value.integer.value[0] = ~val>>7 & 0x1; > + ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1; > return 0; > } > > @@ -370,7 +376,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol, > old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); > else > old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); > - new = (~ucontrol->value.integer.value[0] << 7 & 0x80) | (old & ~0x80); > + new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80); > change = (new != old); > if (change) { > if (id == 0) > -- > 2.1.4 > _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state 2015-03-16 7:51 ` Takashi Iwai @ 2015-03-16 14:54 ` Clément Guedez 2015-03-16 14:55 ` Takashi Iwai 0 siblings, 1 reply; 12+ messages in thread From: Clément Guedez @ 2015-03-16 14:54 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel Ok, I was not aware of this mechanism. In fact this is a boolean control to activate the input gain amplifier for microphone signal or to deactivate it for standard line signal. I use the enum to have choice value more explicit than on/off or true/false, for the end user. Also there will never be more value than those two. So I chould change the control name to "Mic/Line Input Enum" and keep the enum for values, more than name it "Input Gain Switch" and use boolean ? Thanks 2015-03-16 8:51 GMT+01:00 Takashi Iwai <tiwai@suse.de>: > At Mon, 16 Mar 2015 01:20:54 +0100, > klem.dev@gmail.com wrote: > > > > From: Clément Guedez <klem.dev@gmail.com> > > > > Add text Line in/Mic for selecting input gain state in mixer for ESI > W192M. > > What I meant is to change control name "Line Switch" to a different > suffix (oh, anyway there is a typo in the original code, it's written > as "switch", not "Switch"...) > > The type of control element is identified by a string name rule in > some levels. When a control is named as "XXX Switch", it's taken as a > boolean control. For enum control, we usually take "Enum" suffix so > that alsa-lib simple mixer interface can recognize it as an enumerated > control. > > (Hm, it's not mentioned in Documentation/sound/alsa/ControlNames.txt. > An update is needed...) > > > Takashi > > > > > Signed-off-by: Clément Guedez <klem.dev@gmail.com> > > > > diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c > > index c7ffafa..a6e7afa 100644 > > --- a/sound/pci/ice1712/wtm.c > > +++ b/sound/pci/ice1712/wtm.c > > @@ -339,8 +339,14 @@ static int stac9460_adc_vol_put(struct snd_kcontrol > *kcontrol, > > /* > > * MIC / LINE switch fonction > > */ > > +static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol, > > + struct snd_ctl_elem_info *uinfo) > > +{ > > + static const char * const texts[2] = { "Line In", "Mic" }; > > + > > + return snd_ctl_enum_info(uinfo, 1, 2, texts); > > +} > > > > -#define stac9460_mic_sw_info snd_ctl_boolean_mono_info > > > > static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, > > struct snd_ctl_elem_value *ucontrol) > > @@ -354,7 +360,7 @@ static int stac9460_mic_sw_get(struct snd_kcontrol > *kcontrol, > > val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); > > else > > val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); > > - ucontrol->value.integer.value[0] = ~val>>7 & 0x1; > > + ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1; > > return 0; > > } > > > > @@ -370,7 +376,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol > *kcontrol, > > old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); > > else > > old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); > > - new = (~ucontrol->value.integer.value[0] << 7 & 0x80) | (old & > ~0x80); > > + new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & > ~0x80); > > change = (new != old); > > if (change) { > > if (id == 0) > > -- > > 2.1.4 > > > _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state 2015-03-16 14:54 ` Clément Guedez @ 2015-03-16 14:55 ` Takashi Iwai 0 siblings, 0 replies; 12+ messages in thread From: Takashi Iwai @ 2015-03-16 14:55 UTC (permalink / raw) To: Clément Guedez; +Cc: alsa-devel At Mon, 16 Mar 2015 15:54:43 +0100, Clément Guedez wrote: > > Ok, I was not aware of this mechanism. > > In fact this is a boolean control to activate the input gain amplifier for > microphone signal or to deactivate it for standard line signal. > I use the enum to have choice value more explicit than on/off or > true/false, for the end user. > Also there will never be more value than those two. > > So I chould change the control name to "Mic/Line Input Enum" and keep the > enum for values, more than name it "Input Gain Switch" and use boolean ? Right. Takashi _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <1426300302-20542-1-git-send-email-me>]
* [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state [not found] <1426300302-20542-1-git-send-email-me> @ 2015-03-14 2:31 ` klem.dev 2015-03-14 8:10 ` Takashi Iwai 0 siblings, 1 reply; 12+ messages in thread From: klem.dev @ 2015-03-14 2:31 UTC (permalink / raw) To: patch; +Cc: Clément Guedez, alsa-devel From: Clément Guedez <klem.dev@gmail.com> Add text Line in/Mic for selecting input gain state in mixer for ESI W192M. Signed-off-by: Clément Guedez <klem.dev@gmail.com> diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index 3af9daf..497ff1a 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -339,8 +339,23 @@ static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol, /* * MIC / LINE switch fonction */ +static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static char *texts[2] = { "Line In", "Mic" }; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 2; + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) + uinfo->value.enumerated.item = uinfo->value.enumerated.items + - 1; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + + return 0; +} -#define stac9460_mic_sw_info snd_ctl_boolean_mono_info static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -354,7 +369,7 @@ static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); - ucontrol->value.integer.value[0] = ~val>>7 & 0x1; + ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1; return 0; } @@ -370,7 +385,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol, old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); else old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); - new = (~ucontrol->value.integer.value[0] << 7 & 0x80) | (old & ~0x80); + new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80); change = (new != old); if (change) { if (id == 0) -- 2.1.4 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state 2015-03-14 2:31 ` klem.dev @ 2015-03-14 8:10 ` Takashi Iwai 2015-03-14 13:45 ` Clément Guedez 0 siblings, 1 reply; 12+ messages in thread From: Takashi Iwai @ 2015-03-14 8:10 UTC (permalink / raw) To: klem.dev; +Cc: alsa-devel At Sat, 14 Mar 2015 03:31:41 +0100, klem.dev@gmail.com wrote: > > From: Clément Guedez <klem.dev@gmail.com> > > Add text Line in/Mic for selecting input gain state in mixer for ESI W192M. > > Signed-off-by: Clément Guedez <klem.dev@gmail.com> > > diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c > index 3af9daf..497ff1a 100644 > --- a/sound/pci/ice1712/wtm.c > +++ b/sound/pci/ice1712/wtm.c > @@ -339,8 +339,23 @@ static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol, > /* > * MIC / LINE switch fonction > */ > +static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_info *uinfo) > +{ > + static char *texts[2] = { "Line In", "Mic" }; > + > + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; > + uinfo->count = 1; > + uinfo->value.enumerated.items = 2; > + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) > + uinfo->value.enumerated.item = uinfo->value.enumerated.items > + - 1; > + strcpy(uinfo->value.enumerated.name, > + texts[uinfo->value.enumerated.item]); > + > + return 0; You can use snd_ctl_enum_info() helper. Also, if you change from a switch to an enum, fix the control name suffix, too. Takashi > +} > > -#define stac9460_mic_sw_info snd_ctl_boolean_mono_info > > static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, > struct snd_ctl_elem_value *ucontrol) > @@ -354,7 +369,7 @@ static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, > val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); > else > val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); > - ucontrol->value.integer.value[0] = ~val>>7 & 0x1; > + ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1; > return 0; > } > > @@ -370,7 +385,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol, > old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); > else > old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); > - new = (~ucontrol->value.integer.value[0] << 7 & 0x80) | (old & ~0x80); > + new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80); > change = (new != old); > if (change) { > if (id == 0) > -- > 2.1.4 > _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state 2015-03-14 8:10 ` Takashi Iwai @ 2015-03-14 13:45 ` Clément Guedez 0 siblings, 0 replies; 12+ messages in thread From: Clément Guedez @ 2015-03-14 13:45 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel Hi, I had a look on the snd_ctl_enum_info function, it will be better with it for sure. Excuse me, but what do you mean by the control name suffix ? After correcting those, I will send the whole patchset. Thanks 2015-03-14 9:10 GMT+01:00 Takashi Iwai <tiwai@suse.de>: > At Sat, 14 Mar 2015 03:31:41 +0100, > klem.dev@gmail.com wrote: > > > > From: Clément Guedez <klem.dev@gmail.com> > > > > Add text Line in/Mic for selecting input gain state in mixer for ESI > W192M. > > > > Signed-off-by: Clément Guedez <klem.dev@gmail.com> > > > > diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c > > index 3af9daf..497ff1a 100644 > > --- a/sound/pci/ice1712/wtm.c > > +++ b/sound/pci/ice1712/wtm.c > > @@ -339,8 +339,23 @@ static int stac9460_adc_vol_put(struct snd_kcontrol > *kcontrol, > > /* > > * MIC / LINE switch fonction > > */ > > +static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol, > > + struct snd_ctl_elem_info *uinfo) > > +{ > > + static char *texts[2] = { "Line In", "Mic" }; > > + > > + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; > > + uinfo->count = 1; > > + uinfo->value.enumerated.items = 2; > > + if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) > > + uinfo->value.enumerated.item = > uinfo->value.enumerated.items > > + - 1; > > + strcpy(uinfo->value.enumerated.name, > > + texts[uinfo->value.enumerated.item]); > > + > > + return 0; > > You can use snd_ctl_enum_info() helper. > > Also, if you change from a switch to an enum, fix the control name > suffix, too. > > > Takashi > > > > +} > > > > -#define stac9460_mic_sw_info snd_ctl_boolean_mono_info > > > > static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol, > > struct snd_ctl_elem_value *ucontrol) > > @@ -354,7 +369,7 @@ static int stac9460_mic_sw_get(struct snd_kcontrol > *kcontrol, > > val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); > > else > > val = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); > > - ucontrol->value.integer.value[0] = ~val>>7 & 0x1; > > + ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1; > > return 0; > > } > > > > @@ -370,7 +385,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol > *kcontrol, > > old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE); > > else > > old = stac9460_2_get(ice, STAC946X_GENERAL_PURPOSE); > > - new = (~ucontrol->value.integer.value[0] << 7 & 0x80) | (old & > ~0x80); > > + new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & > ~0x80); > > change = (new != old); > > if (change) { > > if (id == 0) > > -- > > 2.1.4 > > > _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-03-18 1:26 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1426641991-3694-1-git-send-email-me>
2015-03-18 1:26 ` [PATCH 2/6] ESI W192M : Update eeprom structure to C99 standard klem.dev
2015-03-18 1:26 ` [PATCH 3/6] ESI W192M : Enable midi i/o of port envy24 chip as available klem.dev
2015-03-18 1:26 ` [PATCH 4/6] ESI W192M : Add TLV support for control value in dB scale klem.dev
2015-03-18 1:26 ` [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state klem.dev
2015-03-18 1:26 ` [PATCH 6/6] ESI W192M : Add sampling rate control of the ADC/DAC klem.dev
[not found] <1426465255-19005-1-git-send-email-me>
2015-03-16 0:20 ` [PATCH 5/6] ESI W192M : Add text Line in/Mic for selecting input gain state klem.dev
2015-03-16 7:51 ` Takashi Iwai
2015-03-16 14:54 ` Clément Guedez
2015-03-16 14:55 ` Takashi Iwai
[not found] <1426300302-20542-1-git-send-email-me>
2015-03-14 2:31 ` klem.dev
2015-03-14 8:10 ` Takashi Iwai
2015-03-14 13:45 ` Clément Guedez
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.