Commit cff1701b authored by Komal Shah's avatar Komal Shah Committed by Tony Lindgren

ARM: OMAP: aic23-alsa-mixer cleanup. No code change

- whitespace cleanups
- Follow 80 line rule, still few places are left.
Signed-off-by: default avatarKomal Shah <komal_shah802003@yahoo.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent e35f9ba0
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
* *
* History: * History:
* *
* 2005-08-02 INdT Kernel Team - Alsa mixer driver for omap osk. Creation of new * 2005-08-02 INdT Kernel Team - Alsa mixer driver for omap osk.
* file omap-alsa-mixer.c. Initial version * Creation of new file omap-alsa-mixer.c.
* with aic23 codec for osk5912 * Initial version with aic23 codec for osk5912
*/ */
#include <sound/driver.h> #include <sound/driver.h>
...@@ -149,21 +149,25 @@ static int snd_omap_info_bool(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * ui ...@@ -149,21 +149,25 @@ static int snd_omap_info_bool(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * ui
return 0; return 0;
} }
static int snd_omap_get_bool(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) static int snd_omap_get_bool(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{ {
int mic_index = (kcontrol->private_value >> 8) & 0x03; int mic_index = (kcontrol->private_value >> 8) & 0x03;
u16 mask = (kcontrol->private_value >> 12) & 0xff; u16 mask = (kcontrol->private_value >> 12) & 0xff;
int invert = (kcontrol->private_value >> 10) & 0x03; int invert = (kcontrol->private_value >> 10) & 0x03;
if (invert) if (invert)
ucontrol->value.integer.value[0] = (omap_regs[mic_index].l_reg & mask) ? 0 : 1; ucontrol->value.integer.value[0] =
(omap_regs[mic_index].l_reg & mask) ? 0 : 1;
else else
ucontrol->value.integer.value[0] = (omap_regs[mic_index].l_reg & mask) ? 1 : 0; ucontrol->value.integer.value[0] =
(omap_regs[mic_index].l_reg & mask) ? 1 : 0;
return 0; return 0;
} }
static int snd_omap_put_bool(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) static int snd_omap_put_bool(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{ {
int mic_index = (kcontrol->private_value >> 8) & 0x03; int mic_index = (kcontrol->private_value >> 8) & 0x03;
u16 mask = (kcontrol->private_value >> 12) & 0xff; u16 mask = (kcontrol->private_value >> 12) & 0xff;
...@@ -192,7 +196,8 @@ static int snd_omap_put_bool(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * u ...@@ -192,7 +196,8 @@ static int snd_omap_put_bool(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * u
/* Begin Mux Functions */ /* Begin Mux Functions */
static int snd_omap_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) static int snd_omap_info_mux(snd_kcontrol_t *kcontrol,
snd_ctl_elem_info_t * uinfo)
{ {
/* Mic = 0 /* Mic = 0
* Line = 1 */ * Line = 1 */
...@@ -205,22 +210,26 @@ static int snd_omap_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uin ...@@ -205,22 +210,26 @@ static int snd_omap_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uin
if (uinfo->value.enumerated.item > 1) if (uinfo->value.enumerated.item > 1)
uinfo->value.enumerated.item = 1; uinfo->value.enumerated.item = 1;
strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); strcpy(uinfo->value.enumerated.name,
texts[uinfo->value.enumerated.item]);
return 0; return 0;
} }
static int snd_omap_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) static int snd_omap_get_mux(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{ {
u16 mask = (kcontrol->private_value >> 10) & 0xff; u16 mask = (kcontrol->private_value >> 10) & 0xff;
int mux_index = (kcontrol->private_value >> 8) & 0x03; int mux_index = (kcontrol->private_value >> 8) & 0x03;
ucontrol->value.enumerated.item[0] = (omap_regs[mux_index].l_reg & mask) ? 0 /* Mic */ : 1 /* Line */; ucontrol->value.enumerated.item[0] =
(omap_regs[mux_index].l_reg & mask) ? 0 /* Mic */ : 1 /* Line */;
return 0; return 0;
} }
static int snd_omap_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) static int snd_omap_put_mux(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{ {
u16 reg = kcontrol->private_value & 0xff; u16 reg = kcontrol->private_value & 0xff;
u16 mask = (kcontrol->private_value >> 10) & 0xff; u16 mask = (kcontrol->private_value >> 10) & 0xff;
...@@ -242,12 +251,14 @@ static int snd_omap_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * uc ...@@ -242,12 +251,14 @@ static int snd_omap_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * uc
/* Begin Single Functions */ /* Begin Single Functions */
static int snd_omap_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) static int snd_omap_info_single(snd_kcontrol_t *kcontrol,
snd_ctl_elem_info_t * uinfo)
{ {
int mask = (kcontrol->private_value >> 18) & 0xff; int mask = (kcontrol->private_value >> 18) & 0xff;
int reg_val = (kcontrol->private_value >> 8) & 0xff; int reg_val = (kcontrol->private_value >> 8) & 0xff;
uinfo->type = mask ? SNDRV_CTL_ELEM_TYPE_INTEGER : SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->type = mask ? SNDRV_CTL_ELEM_TYPE_INTEGER :
SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1; uinfo->count = 1;
uinfo->value.integer.min = 0; uinfo->value.integer.min = 0;
uinfo->value.integer.max = reg_val-1; uinfo->value.integer.max = reg_val-1;
...@@ -255,7 +266,8 @@ static int snd_omap_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * ...@@ -255,7 +266,8 @@ static int snd_omap_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
return 0; return 0;
} }
static int snd_omap_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) static int snd_omap_get_single(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{ {
u16 reg_val = (kcontrol->private_value >> 8) & 0xff; u16 reg_val = (kcontrol->private_value >> 8) & 0xff;
...@@ -264,7 +276,8 @@ static int snd_omap_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ...@@ -264,7 +276,8 @@ static int snd_omap_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
return 0; return 0;
} }
static int snd_omap_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) static int snd_omap_put_single(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{ {
u16 reg_index = (kcontrol->private_value >> 16) & 0x03; u16 reg_index = (kcontrol->private_value >> 16) & 0x03;
u16 mask = (kcontrol->private_value >> 18) & 0x1ff; u16 mask = (kcontrol->private_value >> 18) & 0x1ff;
...@@ -274,18 +287,19 @@ static int snd_omap_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ...@@ -274,18 +287,19 @@ static int snd_omap_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
int changed = 0; int changed = 0;
/* Volume */ /* Volume */
if ((omap_regs[reg_index].l_reg != (ucontrol->value.integer.value[0] & mask))) if ((omap_regs[reg_index].l_reg !=
{ (ucontrol->value.integer.value[0] & mask))) {
changed = 1; changed = 1;
omap_regs[reg_index].l_reg &= ~mask; omap_regs[reg_index].l_reg &= ~mask;
omap_regs[reg_index].l_reg |= snd_sidetone[ucontrol->value.integer.value[0]]; omap_regs[reg_index].l_reg |=
snd_sidetone[ucontrol->value.integer.value[0]];
snd_sidetone[reg_val] = ucontrol->value.integer.value[0]; snd_sidetone[reg_val] = ucontrol->value.integer.value[0];
SND_OMAP_WRITE(reg, omap_regs[reg_index].l_reg); SND_OMAP_WRITE(reg, omap_regs[reg_index].l_reg);
} } else {
else
changed = 0; changed = 0;
}
return changed; return changed;
} }
...@@ -294,13 +308,15 @@ static int snd_omap_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ...@@ -294,13 +308,15 @@ static int snd_omap_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
/* Begin Double Functions */ /* Begin Double Functions */
static int snd_omap_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) static int snd_omap_info_double(snd_kcontrol_t *kcontrol,
snd_ctl_elem_info_t * uinfo)
{ {
/* mask == 0 : Switch /* mask == 0 : Switch
* mask != 0 : Volume */ * mask != 0 : Volume */
int mask = (kcontrol->private_value >> 18) & 0xff; int mask = (kcontrol->private_value >> 18) & 0xff;
uinfo->type = mask ? SNDRV_CTL_ELEM_TYPE_INTEGER : SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->type = mask ? SNDRV_CTL_ELEM_TYPE_INTEGER :
SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = mask ? 2 : 1; uinfo->count = mask ? 2 : 1;
uinfo->value.integer.min = 0; uinfo->value.integer.min = 0;
uinfo->value.integer.max = mask ? mask : 1; uinfo->value.integer.max = mask ? mask : 1;
...@@ -315,11 +331,10 @@ static int snd_omap_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ...@@ -315,11 +331,10 @@ static int snd_omap_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
int mask = (kcontrol->private_value >> 18) & 0xff; int mask = (kcontrol->private_value >> 18) & 0xff;
int vol_index = (kcontrol->private_value >> 16) & 0x03; int vol_index = (kcontrol->private_value >> 16) & 0x03;
if (!mask) if (!mask) {
/* Switch */ /* Switch */
ucontrol->value.integer.value[0] = omap_regs[vol_index].sw; ucontrol->value.integer.value[0] = omap_regs[vol_index].sw;
else } else {
{
/* Volume */ /* Volume */
ucontrol->value.integer.value[0] = omap_regs[vol_index].l_reg; ucontrol->value.integer.value[0] = omap_regs[vol_index].l_reg;
ucontrol->value.integer.value[1] = omap_regs[vol_index].r_reg; ucontrol->value.integer.value[1] = omap_regs[vol_index].r_reg;
...@@ -339,44 +354,39 @@ static int snd_omap_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ...@@ -339,44 +354,39 @@ static int snd_omap_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *
int changed = 0; int changed = 0;
if (!mask) if (!mask) {
{
/* Switch */ /* Switch */
if (!ucontrol->value.integer.value[0]) if (!ucontrol->value.integer.value[0]) {
{
SND_OMAP_WRITE(left_reg, 0x00); SND_OMAP_WRITE(left_reg, 0x00);
SND_OMAP_WRITE(right_reg, 0x00); SND_OMAP_WRITE(right_reg, 0x00);
} } else {
else
{
SND_OMAP_WRITE(left_reg, omap_regs[vol_index].l_reg); SND_OMAP_WRITE(left_reg, omap_regs[vol_index].l_reg);
SND_OMAP_WRITE(right_reg, omap_regs[vol_index].r_reg); SND_OMAP_WRITE(right_reg, omap_regs[vol_index].r_reg);
} }
changed = 1; changed = 1;
omap_regs[vol_index].sw = ucontrol->value.integer.value[0]; omap_regs[vol_index].sw = ucontrol->value.integer.value[0];
} } else {
else
{
/* Volume */ /* Volume */
if ((omap_regs[vol_index].l_reg != (ucontrol->value.integer.value[0] & mask)) || if ((omap_regs[vol_index].l_reg != (ucontrol->value.integer.value[0] & mask)) ||
(omap_regs[vol_index].r_reg != (ucontrol->value.integer.value[1] & mask))) (omap_regs[vol_index].r_reg != (ucontrol->value.integer.value[1] & mask))) {
{
changed = 1; changed = 1;
omap_regs[vol_index].l_reg &= ~mask; omap_regs[vol_index].l_reg &= ~mask;
omap_regs[vol_index].r_reg &= ~mask; omap_regs[vol_index].r_reg &= ~mask;
omap_regs[vol_index].l_reg |= (ucontrol->value.integer.value[0] & mask); omap_regs[vol_index].l_reg |=
omap_regs[vol_index].r_reg |= (ucontrol->value.integer.value[1] & mask); (ucontrol->value.integer.value[0] & mask);
if (omap_regs[vol_index].sw) omap_regs[vol_index].r_reg |=
{ (ucontrol->value.integer.value[1] & mask);
if (omap_regs[vol_index].sw) {
/* write to registers only if sw is actived */ /* write to registers only if sw is actived */
SND_OMAP_WRITE(left_reg, omap_regs[vol_index].l_reg); SND_OMAP_WRITE(left_reg, omap_regs[vol_index].l_reg);
SND_OMAP_WRITE(right_reg, omap_regs[vol_index].r_reg); SND_OMAP_WRITE(right_reg, omap_regs[vol_index].r_reg);
} }
} }
else else {
changed = 0; changed = 0;
} }
}
return changed; return changed;
} }
...@@ -477,7 +487,8 @@ int snd_omap_mixer(struct snd_card_omap_codec *chip) ...@@ -477,7 +487,8 @@ int snd_omap_mixer(struct snd_card_omap_codec *chip)
/* Registering alsa mixer controls */ /* Registering alsa mixer controls */
for (idx = 0; idx < ARRAY_SIZE(snd_omap_controls); idx++) for (idx = 0; idx < ARRAY_SIZE(snd_omap_controls); idx++)
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_omap_controls[idx], chip))) < 0) if ((err = snd_ctl_add(card,
snd_ctl_new1(&snd_omap_controls[idx], chip))) < 0)
return err; return err;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment