diff options
-rw-r--r-- | include/sound/soc.h | 18 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 49 |
2 files changed, 67 insertions, 0 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index 1e16d6e3f2a8..3e9cae001eab 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -185,6 +185,12 @@ | |||
185 | .rreg = xreg_right, .shift = xshift, \ | 185 | .rreg = xreg_right, .shift = xshift, \ |
186 | .min = xmin, .max = xmax} } | 186 | .min = xmin, .max = xmax} } |
187 | 187 | ||
188 | #define SND_SOC_BYTES(xname, xbase, xregs) \ | ||
189 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | ||
190 | .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \ | ||
191 | .put = snd_soc_bytes_put, .private_value = \ | ||
192 | ((unsigned long)&(struct soc_bytes) \ | ||
193 | {.base = xbase, .num_regs = xregs }) } | ||
188 | 194 | ||
189 | /* | 195 | /* |
190 | * Simplified versions of above macros, declaring a struct and calculating | 196 | * Simplified versions of above macros, declaring a struct and calculating |
@@ -413,6 +419,13 @@ int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol, | |||
413 | struct snd_ctl_elem_value *ucontrol); | 419 | struct snd_ctl_elem_value *ucontrol); |
414 | int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol, | 420 | int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol, |
415 | struct snd_ctl_elem_value *ucontrol); | 421 | struct snd_ctl_elem_value *ucontrol); |
422 | int snd_soc_bytes_info(struct snd_kcontrol *kcontrol, | ||
423 | struct snd_ctl_elem_info *uinfo); | ||
424 | int snd_soc_bytes_get(struct snd_kcontrol *kcontrol, | ||
425 | struct snd_ctl_elem_value *ucontrol); | ||
426 | int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | ||
427 | struct snd_ctl_elem_value *ucontrol); | ||
428 | |||
416 | 429 | ||
417 | /** | 430 | /** |
418 | * struct snd_soc_reg_access - Describes whether a given register is | 431 | * struct snd_soc_reg_access - Describes whether a given register is |
@@ -888,6 +901,11 @@ struct soc_mixer_control { | |||
888 | unsigned int reg, rreg, shift, rshift, invert; | 901 | unsigned int reg, rreg, shift, rshift, invert; |
889 | }; | 902 | }; |
890 | 903 | ||
904 | struct soc_bytes { | ||
905 | int base; | ||
906 | int num_regs; | ||
907 | }; | ||
908 | |||
891 | /* enumerated kcontrol */ | 909 | /* enumerated kcontrol */ |
892 | struct soc_enum { | 910 | struct soc_enum { |
893 | unsigned short reg; | 911 | unsigned short reg; |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3ca70594e242..a9786ab70504 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -2736,6 +2736,55 @@ int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol, | |||
2736 | } | 2736 | } |
2737 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r_sx); | 2737 | EXPORT_SYMBOL_GPL(snd_soc_put_volsw_2r_sx); |
2738 | 2738 | ||
2739 | int snd_soc_bytes_info(struct snd_kcontrol *kcontrol, | ||
2740 | struct snd_ctl_elem_info *uinfo) | ||
2741 | { | ||
2742 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2743 | struct soc_bytes *params = (void *)kcontrol->private_value; | ||
2744 | |||
2745 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; | ||
2746 | uinfo->count = params->num_regs * codec->val_bytes; | ||
2747 | |||
2748 | return 0; | ||
2749 | } | ||
2750 | EXPORT_SYMBOL_GPL(snd_soc_bytes_info); | ||
2751 | |||
2752 | int snd_soc_bytes_get(struct snd_kcontrol *kcontrol, | ||
2753 | struct snd_ctl_elem_value *ucontrol) | ||
2754 | { | ||
2755 | struct soc_bytes *params = (void *)kcontrol->private_value; | ||
2756 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2757 | int ret; | ||
2758 | |||
2759 | if (codec->using_regmap) | ||
2760 | ret = regmap_raw_read(codec->control_data, params->base, | ||
2761 | ucontrol->value.bytes.data, | ||
2762 | params->num_regs * codec->val_bytes); | ||
2763 | else | ||
2764 | ret = -EINVAL; | ||
2765 | |||
2766 | return ret; | ||
2767 | } | ||
2768 | EXPORT_SYMBOL_GPL(snd_soc_bytes_get); | ||
2769 | |||
2770 | int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | ||
2771 | struct snd_ctl_elem_value *ucontrol) | ||
2772 | { | ||
2773 | struct soc_bytes *params = (void *)kcontrol->private_value; | ||
2774 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2775 | int ret; | ||
2776 | |||
2777 | if (codec->using_regmap) | ||
2778 | ret = regmap_raw_write(codec->control_data, params->base, | ||
2779 | ucontrol->value.bytes.data, | ||
2780 | params->num_regs * codec->val_bytes); | ||
2781 | else | ||
2782 | ret = -EINVAL; | ||
2783 | |||
2784 | return ret; | ||
2785 | } | ||
2786 | EXPORT_SYMBOL_GPL(snd_soc_bytes_put); | ||
2787 | |||
2739 | /** | 2788 | /** |
2740 | * snd_soc_dai_set_sysclk - configure DAI system or master clock. | 2789 | * snd_soc_dai_set_sysclk - configure DAI system or master clock. |
2741 | * @dai: DAI | 2790 | * @dai: DAI |