Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 293400
b: refs/heads/master
c: 71d0851
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown committed Feb 21, 2012
1 parent e7ec785 commit 4c729b7
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2b4bdee2920fb3894f9116f76343f8b31f9e4da8
refs/heads/master: 71d08516b80638a69d5efea4e8cb832c053f9dd9
18 changes: 18 additions & 0 deletions trunk/include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@
.rreg = xreg_right, .shift = xshift, \
.min = xmin, .max = xmax} }

#define SND_SOC_BYTES(xname, xbase, xregs) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
.info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
.put = snd_soc_bytes_put, .private_value = \
((unsigned long)&(struct soc_bytes) \
{.base = xbase, .num_regs = xregs }) }

/*
* Simplified versions of above macros, declaring a struct and calculating
Expand Down Expand Up @@ -413,6 +419,13 @@ int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo);
int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);


/**
* struct snd_soc_reg_access - Describes whether a given register is
Expand Down Expand Up @@ -888,6 +901,11 @@ struct soc_mixer_control {
unsigned int reg, rreg, shift, rshift, invert;
};

struct soc_bytes {
int base;
int num_regs;
};

/* enumerated kcontrol */
struct soc_enum {
unsigned short reg;
Expand Down
49 changes: 49 additions & 0 deletions trunk/sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2736,6 +2736,55 @@ int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
}
EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r_sx);

int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct soc_bytes *params = (void *)kcontrol->private_value;

uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
uinfo->count = params->num_regs * codec->val_bytes;

return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_bytes_info);

int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct soc_bytes *params = (void *)kcontrol->private_value;
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
int ret;

if (codec->using_regmap)
ret = regmap_raw_read(codec->control_data, params->base,
ucontrol->value.bytes.data,
params->num_regs * codec->val_bytes);
else
ret = -EINVAL;

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_bytes_get);

int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct soc_bytes *params = (void *)kcontrol->private_value;
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
int ret;

if (codec->using_regmap)
ret = regmap_raw_write(codec->control_data, params->base,
ucontrol->value.bytes.data,
params->num_regs * codec->val_bytes);
else
ret = -EINVAL;

return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_bytes_put);

/**
* snd_soc_dai_set_sysclk - configure DAI system or master clock.
* @dai: DAI
Expand Down

0 comments on commit 4c729b7

Please sign in to comment.