mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-25 14:13:01 -04:00
[ALSA] Control API - TLV implementation for additional information like dB scale
This patch implements a TLV mechanism to transfer an additional information like dB scale to the user space. The types might be extended in future. Acked-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
This commit is contained in:
parent
3eeab61aa3
commit
42750b04c5
5 changed files with 96 additions and 3 deletions
|
|
@ -688,7 +688,7 @@ struct snd_timer_tread {
|
|||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 3)
|
||||
#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 4)
|
||||
|
||||
struct snd_ctl_card_info {
|
||||
int card; /* card number */
|
||||
|
|
@ -818,6 +818,12 @@ struct snd_ctl_elem_value {
|
|||
unsigned char reserved[128-sizeof(struct timespec)];
|
||||
};
|
||||
|
||||
struct snd_ctl_tlv {
|
||||
unsigned int numid; /* control element numeric identification */
|
||||
unsigned int length; /* in bytes aligned to 4 */
|
||||
unsigned int tlv[0]; /* first TLV */
|
||||
};
|
||||
|
||||
enum {
|
||||
SNDRV_CTL_IOCTL_PVERSION = _IOR('U', 0x00, int),
|
||||
SNDRV_CTL_IOCTL_CARD_INFO = _IOR('U', 0x01, struct snd_ctl_card_info),
|
||||
|
|
@ -831,6 +837,7 @@ enum {
|
|||
SNDRV_CTL_IOCTL_ELEM_ADD = _IOWR('U', 0x17, struct snd_ctl_elem_info),
|
||||
SNDRV_CTL_IOCTL_ELEM_REPLACE = _IOWR('U', 0x18, struct snd_ctl_elem_info),
|
||||
SNDRV_CTL_IOCTL_ELEM_REMOVE = _IOWR('U', 0x19, struct snd_ctl_elem_id),
|
||||
SNDRV_CTL_IOCTL_TLV_READ = _IOWR('U', 0x1a, struct snd_ctl_tlv),
|
||||
SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE = _IOWR('U', 0x20, int),
|
||||
SNDRV_CTL_IOCTL_HWDEP_INFO = _IOR('U', 0x21, struct snd_hwdep_info),
|
||||
SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE = _IOR('U', 0x30, int),
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ struct snd_kcontrol_new {
|
|||
snd_kcontrol_info_t *info;
|
||||
snd_kcontrol_get_t *get;
|
||||
snd_kcontrol_put_t *put;
|
||||
unsigned int *tlv;
|
||||
unsigned long private_value;
|
||||
};
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ struct snd_kcontrol {
|
|||
snd_kcontrol_info_t *info;
|
||||
snd_kcontrol_get_t *get;
|
||||
snd_kcontrol_put_t *put;
|
||||
unsigned int *tlv;
|
||||
unsigned long private_value;
|
||||
void *private_data;
|
||||
void (*private_free)(struct snd_kcontrol *kcontrol);
|
||||
|
|
|
|||
43
include/sound/tlv.h
Normal file
43
include/sound/tlv.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef __SOUND_TLV_H
|
||||
#define __SOUND_TLV_H
|
||||
|
||||
/*
|
||||
* Advanced Linux Sound Architecture - ALSA - Driver
|
||||
* Copyright (c) 2006 by Jaroslav Kysela <perex@suse.cz>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* TLV structure is right behind the struct snd_ctl_tlv:
|
||||
* unsigned int type - see SNDRV_CTL_TLVT_*
|
||||
* unsigned int length
|
||||
* .... data aligned to sizeof(unsigned int), use
|
||||
* block_length = (length + (sizeof(unsigned int) - 1)) &
|
||||
* ~(sizeof(unsigned int) - 1)) ....
|
||||
*/
|
||||
|
||||
#define SNDRV_CTL_TLVT_CONTAINER 0 /* one level down - group of TLVs */
|
||||
#define SNDRV_CTL_TLVT_DB_SCALE 1 /* dB scale */
|
||||
|
||||
#define DECLARE_TLV_DB_SCALE(name, min, step, mute) \
|
||||
unsigned int name[] = { \
|
||||
SNDRV_CTL_TLVT_DB_SCALE, 2 * sizeof(unsigned int), \
|
||||
(min), ((step) & 0xffff) | ((mute) ? 0x10000 : 0) \
|
||||
}
|
||||
|
||||
#endif /* __SOUND_TLV_H */
|
||||
Loading…
Reference in a new issue