|
@@ -1213,7 +1213,6 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
|
|
memcpy(&template, _template, sizeof(template));
|
|
memcpy(&template, _template, sizeof(template));
|
|
if (long_name)
|
|
if (long_name)
|
|
template.name = long_name;
|
|
template.name = long_name;
|
|
- template.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
|
|
|
|
template.index = 0;
|
|
template.index = 0;
|
|
|
|
|
|
return snd_ctl_new1(&template, data);
|
|
return snd_ctl_new1(&template, data);
|
|
@@ -1348,13 +1347,16 @@ EXPORT_SYMBOL_GPL(snd_soc_info_enum_ext);
|
|
int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
|
|
int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_info *uinfo)
|
|
struct snd_ctl_elem_info *uinfo)
|
|
{
|
|
{
|
|
- int mask = kcontrol->private_value;
|
|
|
|
|
|
+ int max = kcontrol->private_value;
|
|
|
|
+
|
|
|
|
+ if (max == 1)
|
|
|
|
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
|
|
|
|
+ else
|
|
|
|
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
|
|
- uinfo->type =
|
|
|
|
- mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = 1;
|
|
uinfo->count = 1;
|
|
uinfo->value.integer.min = 0;
|
|
uinfo->value.integer.min = 0;
|
|
- uinfo->value.integer.max = mask;
|
|
|
|
|
|
+ uinfo->value.integer.max = max;
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext);
|
|
EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext);
|
|
@@ -1371,15 +1373,18 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw_ext);
|
|
int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
|
|
int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_info *uinfo)
|
|
struct snd_ctl_elem_info *uinfo)
|
|
{
|
|
{
|
|
- int mask = (kcontrol->private_value >> 16) & 0xff;
|
|
|
|
|
|
+ int max = (kcontrol->private_value >> 16) & 0xff;
|
|
int shift = (kcontrol->private_value >> 8) & 0x0f;
|
|
int shift = (kcontrol->private_value >> 8) & 0x0f;
|
|
int rshift = (kcontrol->private_value >> 12) & 0x0f;
|
|
int rshift = (kcontrol->private_value >> 12) & 0x0f;
|
|
|
|
|
|
- uinfo->type =
|
|
|
|
- mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
|
|
+ if (max == 1)
|
|
|
|
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
|
|
|
|
+ else
|
|
|
|
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
+
|
|
uinfo->count = shift == rshift ? 1 : 2;
|
|
uinfo->count = shift == rshift ? 1 : 2;
|
|
uinfo->value.integer.min = 0;
|
|
uinfo->value.integer.min = 0;
|
|
- uinfo->value.integer.max = mask;
|
|
|
|
|
|
+ uinfo->value.integer.max = max;
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
|
|
EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
|
|
@@ -1400,7 +1405,8 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
|
|
int reg = kcontrol->private_value & 0xff;
|
|
int reg = kcontrol->private_value & 0xff;
|
|
int shift = (kcontrol->private_value >> 8) & 0x0f;
|
|
int shift = (kcontrol->private_value >> 8) & 0x0f;
|
|
int rshift = (kcontrol->private_value >> 12) & 0x0f;
|
|
int rshift = (kcontrol->private_value >> 12) & 0x0f;
|
|
- int mask = (kcontrol->private_value >> 16) & 0xff;
|
|
|
|
|
|
+ int max = (kcontrol->private_value >> 16) & 0xff;
|
|
|
|
+ int mask = (1 << fls(max)) - 1;
|
|
int invert = (kcontrol->private_value >> 24) & 0x01;
|
|
int invert = (kcontrol->private_value >> 24) & 0x01;
|
|
|
|
|
|
ucontrol->value.integer.value[0] =
|
|
ucontrol->value.integer.value[0] =
|
|
@@ -1410,10 +1416,10 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
|
|
(snd_soc_read(codec, reg) >> rshift) & mask;
|
|
(snd_soc_read(codec, reg) >> rshift) & mask;
|
|
if (invert) {
|
|
if (invert) {
|
|
ucontrol->value.integer.value[0] =
|
|
ucontrol->value.integer.value[0] =
|
|
- mask - ucontrol->value.integer.value[0];
|
|
|
|
|
|
+ max - ucontrol->value.integer.value[0];
|
|
if (shift != rshift)
|
|
if (shift != rshift)
|
|
ucontrol->value.integer.value[1] =
|
|
ucontrol->value.integer.value[1] =
|
|
- mask - ucontrol->value.integer.value[1];
|
|
|
|
|
|
+ max - ucontrol->value.integer.value[1];
|
|
}
|
|
}
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -1436,25 +1442,24 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
|
|
int reg = kcontrol->private_value & 0xff;
|
|
int reg = kcontrol->private_value & 0xff;
|
|
int shift = (kcontrol->private_value >> 8) & 0x0f;
|
|
int shift = (kcontrol->private_value >> 8) & 0x0f;
|
|
int rshift = (kcontrol->private_value >> 12) & 0x0f;
|
|
int rshift = (kcontrol->private_value >> 12) & 0x0f;
|
|
- int mask = (kcontrol->private_value >> 16) & 0xff;
|
|
|
|
|
|
+ int max = (kcontrol->private_value >> 16) & 0xff;
|
|
|
|
+ int mask = (1 << fls(max)) - 1;
|
|
int invert = (kcontrol->private_value >> 24) & 0x01;
|
|
int invert = (kcontrol->private_value >> 24) & 0x01;
|
|
- int err;
|
|
|
|
unsigned short val, val2, val_mask;
|
|
unsigned short val, val2, val_mask;
|
|
|
|
|
|
val = (ucontrol->value.integer.value[0] & mask);
|
|
val = (ucontrol->value.integer.value[0] & mask);
|
|
if (invert)
|
|
if (invert)
|
|
- val = mask - val;
|
|
|
|
|
|
+ val = max - val;
|
|
val_mask = mask << shift;
|
|
val_mask = mask << shift;
|
|
val = val << shift;
|
|
val = val << shift;
|
|
if (shift != rshift) {
|
|
if (shift != rshift) {
|
|
val2 = (ucontrol->value.integer.value[1] & mask);
|
|
val2 = (ucontrol->value.integer.value[1] & mask);
|
|
if (invert)
|
|
if (invert)
|
|
- val2 = mask - val2;
|
|
|
|
|
|
+ val2 = max - val2;
|
|
val_mask |= mask << rshift;
|
|
val_mask |= mask << rshift;
|
|
val |= val2 << rshift;
|
|
val |= val2 << rshift;
|
|
}
|
|
}
|
|
- err = snd_soc_update_bits(codec, reg, val_mask, val);
|
|
|
|
- return err;
|
|
|
|
|
|
+ return snd_soc_update_bits(codec, reg, val_mask, val);
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
|
|
EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
|
|
|
|
|
|
@@ -1471,13 +1476,16 @@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
|
|
int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
|
|
int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_info *uinfo)
|
|
struct snd_ctl_elem_info *uinfo)
|
|
{
|
|
{
|
|
- int mask = (kcontrol->private_value >> 12) & 0xff;
|
|
|
|
|
|
+ int max = (kcontrol->private_value >> 12) & 0xff;
|
|
|
|
+
|
|
|
|
+ if (max == 1)
|
|
|
|
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
|
|
|
|
+ else
|
|
|
|
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
|
|
- uinfo->type =
|
|
|
|
- mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = 2;
|
|
uinfo->count = 2;
|
|
uinfo->value.integer.min = 0;
|
|
uinfo->value.integer.min = 0;
|
|
- uinfo->value.integer.max = mask;
|
|
|
|
|
|
+ uinfo->value.integer.max = max;
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r);
|
|
EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r);
|
|
@@ -1498,7 +1506,8 @@ int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
|
|
int reg = kcontrol->private_value & 0xff;
|
|
int reg = kcontrol->private_value & 0xff;
|
|
int reg2 = (kcontrol->private_value >> 24) & 0xff;
|
|
int reg2 = (kcontrol->private_value >> 24) & 0xff;
|
|
int shift = (kcontrol->private_value >> 8) & 0x0f;
|
|
int shift = (kcontrol->private_value >> 8) & 0x0f;
|
|
- int mask = (kcontrol->private_value >> 12) & 0xff;
|
|
|
|
|
|
+ int max = (kcontrol->private_value >> 12) & 0xff;
|
|
|
|
+ int mask = (1<<fls(max))-1;
|
|
int invert = (kcontrol->private_value >> 20) & 0x01;
|
|
int invert = (kcontrol->private_value >> 20) & 0x01;
|
|
|
|
|
|
ucontrol->value.integer.value[0] =
|
|
ucontrol->value.integer.value[0] =
|
|
@@ -1507,9 +1516,9 @@ int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
|
|
(snd_soc_read(codec, reg2) >> shift) & mask;
|
|
(snd_soc_read(codec, reg2) >> shift) & mask;
|
|
if (invert) {
|
|
if (invert) {
|
|
ucontrol->value.integer.value[0] =
|
|
ucontrol->value.integer.value[0] =
|
|
- mask - ucontrol->value.integer.value[0];
|
|
|
|
|
|
+ max - ucontrol->value.integer.value[0];
|
|
ucontrol->value.integer.value[1] =
|
|
ucontrol->value.integer.value[1] =
|
|
- mask - ucontrol->value.integer.value[1];
|
|
|
|
|
|
+ max - ucontrol->value.integer.value[1];
|
|
}
|
|
}
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -1532,7 +1541,8 @@ int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
|
|
int reg = kcontrol->private_value & 0xff;
|
|
int reg = kcontrol->private_value & 0xff;
|
|
int reg2 = (kcontrol->private_value >> 24) & 0xff;
|
|
int reg2 = (kcontrol->private_value >> 24) & 0xff;
|
|
int shift = (kcontrol->private_value >> 8) & 0x0f;
|
|
int shift = (kcontrol->private_value >> 8) & 0x0f;
|
|
- int mask = (kcontrol->private_value >> 12) & 0xff;
|
|
|
|
|
|
+ int max = (kcontrol->private_value >> 12) & 0xff;
|
|
|
|
+ int mask = (1 << fls(max)) - 1;
|
|
int invert = (kcontrol->private_value >> 20) & 0x01;
|
|
int invert = (kcontrol->private_value >> 20) & 0x01;
|
|
int err;
|
|
int err;
|
|
unsigned short val, val2, val_mask;
|
|
unsigned short val, val2, val_mask;
|
|
@@ -1542,8 +1552,8 @@ int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
|
|
val2 = (ucontrol->value.integer.value[1] & mask);
|
|
val2 = (ucontrol->value.integer.value[1] & mask);
|
|
|
|
|
|
if (invert) {
|
|
if (invert) {
|
|
- val = mask - val;
|
|
|
|
- val2 = mask - val2;
|
|
|
|
|
|
+ val = max - val;
|
|
|
|
+ val2 = max - val2;
|
|
}
|
|
}
|
|
|
|
|
|
val = val << shift;
|
|
val = val << shift;
|