Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 261315
b: refs/heads/master
c: 43131a2
h: refs/heads/master
i:
  261313: 77c45db
  261311: 3cb7d57
v: v3
  • Loading branch information
Mauro Carvalho Chehab committed Jul 27, 2011
1 parent f15fdb2 commit 6fe1013
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 850d24a5a861238f583f59cd39de4dfe5142a4c9
refs/heads/master: 43131a2ca6afbd8dcc940d5ad4b4b1c3d89a658b
87 changes: 73 additions & 14 deletions trunk/drivers/media/video/em28xx/em28xx-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,6 @@ static int em28xx_vol_info(struct snd_kcontrol *kcontrol,
return 0;
}

/* FIXME: should also add mute controls for each */

static int em28xx_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value)
{
Expand All @@ -463,7 +461,7 @@ static int em28xx_vol_put(struct snd_kcontrol *kcontrol,
if (rc < 0)
goto err;

val |= rc & 0x8080; /* Preserve the mute flags */
val |= rc & 0x8000; /* Preserve the mute flag */

rc = em28xx_write_ac97(dev, kcontrol->private_value, val);

Expand All @@ -490,33 +488,94 @@ static int em28xx_vol_get(struct snd_kcontrol *kcontrol,
return 0;
}

static int em28xx_vol_put_mute(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value)
{
struct em28xx *dev = snd_kcontrol_chip(kcontrol);
u16 val = value->value.integer.value[0];
int rc;

mutex_lock(&dev->lock);
rc = em28xx_read_ac97(dev, kcontrol->private_value);
if (rc < 0)
goto err;

if (val)
rc |= 0x8000;
else
rc &= 0x7f7f;

rc = em28xx_write_ac97(dev, kcontrol->private_value, rc);

err:
mutex_unlock(&dev->lock);
return rc;
}

static int em28xx_vol_get_mute(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *value)
{
struct em28xx *dev = snd_kcontrol_chip(kcontrol);
int val;

mutex_lock(&dev->lock);
val = em28xx_read_ac97(dev, kcontrol->private_value);
mutex_unlock(&dev->lock);
if (val < 0)
return val;

if (val & 0x8000)
value->value.integer.value[0] = 1;
else
value->value.integer.value[0] = 0;

return 0;
}

static const DECLARE_TLV_DB_SCALE(em28xx_db_scale, -3450, 150, 0);

static int em28xx_cvol_new(struct snd_card *card, struct em28xx *dev,
char *name, int id)
{
int err;
char ctl_name[44];
struct snd_kcontrol *kctl;
struct snd_kcontrol_new tmp = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = name,
.info = em28xx_vol_info,
.get = em28xx_vol_get,
.put = em28xx_vol_put,
.private_value = id,
.tlv.p = em28xx_db_scale,
};

struct snd_kcontrol_new tmp;

memset (&tmp, 0, sizeof(tmp));
tmp.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
tmp.private_value = id,
tmp.name = ctl_name,

/* Add Mute Control */
sprintf(ctl_name, "%s Switch", name);
tmp.get = em28xx_vol_get_mute;
tmp.put = em28xx_vol_put_mute;
tmp.info = snd_ctl_boolean_mono_info;
kctl = snd_ctl_new1(&tmp, dev);
err = snd_ctl_add(card, kctl);
if (err < 0)
return err;

memset (&tmp, 0, sizeof(tmp));
tmp.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
tmp.private_value = id,
tmp.name = ctl_name,

/* Add Volume Control */
sprintf(ctl_name, "%s Volume", name);
tmp.get = em28xx_vol_get;
tmp.put = em28xx_vol_put;
tmp.info = em28xx_vol_info;
tmp.tlv.p = em28xx_db_scale,
kctl = snd_ctl_new1(&tmp, dev);
err = snd_ctl_add(card, kctl);
if (err < 0)
return err;

return 0;
}


/*
* register/unregister code and data
*/
Expand Down

0 comments on commit 6fe1013

Please sign in to comment.