xref: /linux/include/sound/tlv.h (revision c1017a4c)
142750b04SJaroslav Kysela #ifndef __SOUND_TLV_H
242750b04SJaroslav Kysela #define __SOUND_TLV_H
342750b04SJaroslav Kysela 
442750b04SJaroslav Kysela /*
542750b04SJaroslav Kysela  *  Advanced Linux Sound Architecture - ALSA - Driver
6*c1017a4cSJaroslav Kysela  *  Copyright (c) 2006 by Jaroslav Kysela <perex@perex.cz>
742750b04SJaroslav Kysela  *
842750b04SJaroslav Kysela  *
942750b04SJaroslav Kysela  *   This program is free software; you can redistribute it and/or modify
1042750b04SJaroslav Kysela  *   it under the terms of the GNU General Public License as published by
1142750b04SJaroslav Kysela  *   the Free Software Foundation; either version 2 of the License, or
1242750b04SJaroslav Kysela  *   (at your option) any later version.
1342750b04SJaroslav Kysela  *
1442750b04SJaroslav Kysela  *   This program is distributed in the hope that it will be useful,
1542750b04SJaroslav Kysela  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
1642750b04SJaroslav Kysela  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1742750b04SJaroslav Kysela  *   GNU General Public License for more details.
1842750b04SJaroslav Kysela  *
1942750b04SJaroslav Kysela  *   You should have received a copy of the GNU General Public License
2042750b04SJaroslav Kysela  *   along with this program; if not, write to the Free Software
2142750b04SJaroslav Kysela  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
2242750b04SJaroslav Kysela  *
2342750b04SJaroslav Kysela  */
2442750b04SJaroslav Kysela 
2542750b04SJaroslav Kysela /*
2642750b04SJaroslav Kysela  * TLV structure is right behind the struct snd_ctl_tlv:
2742750b04SJaroslav Kysela  *   unsigned int type  	- see SNDRV_CTL_TLVT_*
2842750b04SJaroslav Kysela  *   unsigned int length
2942750b04SJaroslav Kysela  *   .... data aligned to sizeof(unsigned int), use
3042750b04SJaroslav Kysela  *        block_length = (length + (sizeof(unsigned int) - 1)) &
3142750b04SJaroslav Kysela  *                       ~(sizeof(unsigned int) - 1)) ....
3242750b04SJaroslav Kysela  */
3342750b04SJaroslav Kysela 
3442750b04SJaroslav Kysela #define SNDRV_CTL_TLVT_CONTAINER 0	/* one level down - group of TLVs */
3542750b04SJaroslav Kysela #define SNDRV_CTL_TLVT_DB_SCALE	1       /* dB scale */
36063a40d9STakashi Iwai #define SNDRV_CTL_TLVT_DB_LINEAR 2	/* linear volume */
3755a29af5STakashi Iwai #define SNDRV_CTL_TLVT_DB_RANGE 3	/* dB range container */
3842750b04SJaroslav Kysela 
3955a29af5STakashi Iwai #define TLV_DB_SCALE_ITEM(min, step, mute)			\
4042750b04SJaroslav Kysela 	SNDRV_CTL_TLVT_DB_SCALE, 2 * sizeof(unsigned int),	\
4155a29af5STakashi Iwai 	(min), ((step) & 0xffff) | ((mute) ? 0x10000 : 0)
4255a29af5STakashi Iwai #define DECLARE_TLV_DB_SCALE(name, min, step, mute) \
4355a29af5STakashi Iwai 	unsigned int name[] = { TLV_DB_SCALE_ITEM(min, step, mute) }
4442750b04SJaroslav Kysela 
45063a40d9STakashi Iwai /* linear volume between min_dB and max_dB (.01dB unit) */
4655a29af5STakashi Iwai #define TLV_DB_LINEAR_ITEM(min_dB, max_dB)		    \
47063a40d9STakashi Iwai 	SNDRV_CTL_TLVT_DB_LINEAR, 2 * sizeof(unsigned int), \
4855a29af5STakashi Iwai 	(min_dB), (max_dB)
4955a29af5STakashi Iwai #define DECLARE_TLV_DB_LINEAR(name, min_dB, max_dB)	\
5055a29af5STakashi Iwai 	unsigned int name[] = { TLV_DB_LINEAR_ITEM(min_dB, max_dB) }
5155a29af5STakashi Iwai 
5255a29af5STakashi Iwai /* dB range container */
5355a29af5STakashi Iwai /* Each item is: <min> <max> <TLV> */
5455a29af5STakashi Iwai /* The below assumes that each item TLV is 4 words like DB_SCALE or LINEAR */
5555a29af5STakashi Iwai #define TLV_DB_RANGE_HEAD(num)			\
5655a29af5STakashi Iwai 	SNDRV_CTL_TLVT_DB_RANGE, 6 * (num) * sizeof(unsigned int)
57063a40d9STakashi Iwai 
58063a40d9STakashi Iwai #define TLV_DB_GAIN_MUTE	-9999999
59063a40d9STakashi Iwai 
6042750b04SJaroslav Kysela #endif /* __SOUND_TLV_H */
61