diff options
| -rw-r--r-- | include/sound/soc.h | 14 | ||||
| -rw-r--r-- | sound/soc/soc-core.c | 21 |
2 files changed, 34 insertions, 1 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index ed9e2d7e5fdc..688fa667dee5 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
| @@ -270,7 +270,14 @@ | |||
| 270 | .get = xhandler_get, .put = xhandler_put, \ | 270 | .get = xhandler_get, .put = xhandler_put, \ |
| 271 | .private_value = (unsigned long)&(struct soc_bytes_ext) \ | 271 | .private_value = (unsigned long)&(struct soc_bytes_ext) \ |
| 272 | {.max = xcount} } | 272 | {.max = xcount} } |
| 273 | 273 | #define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \ | |
| 274 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | ||
| 275 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \ | ||
| 276 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ | ||
| 277 | .tlv.c = (snd_soc_bytes_tlv_callback), \ | ||
| 278 | .info = snd_soc_info_bytes_ext, \ | ||
| 279 | .private_value = (unsigned long)&(struct soc_bytes_ext) \ | ||
| 280 | {.max = xcount, .get = xhandler_get, .put = xhandler_put, } } | ||
| 274 | #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \ | 281 | #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \ |
| 275 | xmin, xmax, xinvert) \ | 282 | xmin, xmax, xinvert) \ |
| 276 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | 283 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| @@ -552,6 +559,8 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | |||
| 552 | struct snd_ctl_elem_value *ucontrol); | 559 | struct snd_ctl_elem_value *ucontrol); |
| 553 | int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol, | 560 | int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol, |
| 554 | struct snd_ctl_elem_info *ucontrol); | 561 | struct snd_ctl_elem_info *ucontrol); |
| 562 | int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag, | ||
| 563 | unsigned int size, unsigned int __user *tlv); | ||
| 555 | int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol, | 564 | int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol, |
| 556 | struct snd_ctl_elem_info *uinfo); | 565 | struct snd_ctl_elem_info *uinfo); |
| 557 | int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol, | 566 | int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol, |
| @@ -1119,6 +1128,9 @@ struct soc_bytes { | |||
| 1119 | 1128 | ||
| 1120 | struct soc_bytes_ext { | 1129 | struct soc_bytes_ext { |
| 1121 | int max; | 1130 | int max; |
| 1131 | /* used for TLV byte control */ | ||
| 1132 | int (*get)(unsigned int __user *bytes, unsigned int size); | ||
| 1133 | int (*put)(const unsigned int __user *bytes, unsigned int size); | ||
| 1122 | }; | 1134 | }; |
| 1123 | 1135 | ||
| 1124 | /* multi register control */ | 1136 | /* multi register control */ |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b87d7d882e6d..a9ce63f634b2 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
| @@ -3267,6 +3267,27 @@ int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol, | |||
| 3267 | } | 3267 | } |
| 3268 | EXPORT_SYMBOL_GPL(snd_soc_bytes_info_ext); | 3268 | EXPORT_SYMBOL_GPL(snd_soc_bytes_info_ext); |
| 3269 | 3269 | ||
| 3270 | int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag, | ||
| 3271 | unsigned int size, unsigned int __user *tlv) | ||
| 3272 | { | ||
| 3273 | struct soc_bytes_ext *params = (void *)kcontrol->private_value; | ||
| 3274 | unsigned int count = size < params->max ? size : params->max; | ||
| 3275 | int ret = -ENXIO; | ||
| 3276 | |||
| 3277 | switch (op_flag) { | ||
| 3278 | case SNDRV_CTL_TLV_OP_READ: | ||
| 3279 | if (params->get) | ||
| 3280 | ret = params->get(tlv, count); | ||
| 3281 | break; | ||
| 3282 | case SNDRV_CTL_TLV_OP_WRITE: | ||
| 3283 | if (params->put) | ||
| 3284 | ret = params->put(tlv, count); | ||
| 3285 | break; | ||
| 3286 | } | ||
| 3287 | return ret; | ||
| 3288 | } | ||
| 3289 | EXPORT_SYMBOL_GPL(snd_soc_bytes_tlv_callback); | ||
| 3290 | |||
| 3270 | /** | 3291 | /** |
| 3271 | * snd_soc_info_xr_sx - signed multi register info callback | 3292 | * snd_soc_info_xr_sx - signed multi register info callback |
| 3272 | * @kcontrol: mreg control | 3293 | * @kcontrol: mreg control |
