Blame include/sound/tlv.h

Packit 4a16fb
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
Packit 4a16fb
/*
Packit 4a16fb
 *   This program is free software; you can redistribute it and/or modify
Packit 4a16fb
 *   it under the terms of the GNU General Public License as published by
Packit 4a16fb
 *   the Free Software Foundation; either version 2 of the License, or
Packit 4a16fb
 *   (at your option) any later version.
Packit 4a16fb
 *
Packit 4a16fb
 *   This program is distributed in the hope that it will be useful,
Packit 4a16fb
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 4a16fb
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 4a16fb
 *   GNU General Public License for more details.
Packit 4a16fb
 */
Packit 4a16fb
Packit 4a16fb
#ifndef __UAPI_SOUND_TLV_H
Packit 4a16fb
#define __UAPI_SOUND_TLV_H
Packit 4a16fb
Packit 4a16fb
#define SNDRV_CTL_TLVT_CONTAINER 0	/* one level down - group of TLVs */
Packit 4a16fb
#define SNDRV_CTL_TLVT_DB_SCALE	1       /* dB scale */
Packit 4a16fb
#define SNDRV_CTL_TLVT_DB_LINEAR 2	/* linear volume */
Packit 4a16fb
#define SNDRV_CTL_TLVT_DB_RANGE 3	/* dB range container */
Packit 4a16fb
#define SNDRV_CTL_TLVT_DB_MINMAX 4	/* dB scale with min/max */
Packit 4a16fb
#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5	/* dB scale with min/max with mute */
Packit 4a16fb
Packit 4a16fb
/*
Packit 4a16fb
 * channel-mapping TLV items
Packit 4a16fb
 *  TLV length must match with num_channels
Packit 4a16fb
 */
Packit 4a16fb
#define SNDRV_CTL_TLVT_CHMAP_FIXED	0x101	/* fixed channel position */
Packit 4a16fb
#define SNDRV_CTL_TLVT_CHMAP_VAR	0x102	/* channels freely swappable */
Packit 4a16fb
#define SNDRV_CTL_TLVT_CHMAP_PAIRED	0x103	/* pair-wise swappable */
Packit 4a16fb
Packit 4a16fb
/*
Packit 4a16fb
 * TLV structure is right behind the struct snd_ctl_tlv:
Packit 4a16fb
 *   unsigned int type  	- see SNDRV_CTL_TLVT_*
Packit 4a16fb
 *   unsigned int length
Packit 4a16fb
 *   .... data aligned to sizeof(unsigned int), use
Packit 4a16fb
 *        block_length = (length + (sizeof(unsigned int) - 1)) &
Packit 4a16fb
 *                       ~(sizeof(unsigned int) - 1)) ....
Packit 4a16fb
 */
Packit 4a16fb
#define SNDRV_CTL_TLVD_ITEM(type, ...) \
Packit 4a16fb
	(type), SNDRV_CTL_TLVD_LENGTH(__VA_ARGS__), __VA_ARGS__
Packit 4a16fb
#define SNDRV_CTL_TLVD_LENGTH(...) \
Packit 4a16fb
	((unsigned int)sizeof((const unsigned int[]) { __VA_ARGS__ }))
Packit 4a16fb
Packit 4a16fb
/* Accessor offsets for TLV data items */
Packit 4a16fb
#define SNDRV_CTL_TLVO_TYPE		0
Packit 4a16fb
#define SNDRV_CTL_TLVO_LEN		1
Packit 4a16fb
Packit 4a16fb
#define SNDRV_CTL_TLVD_CONTAINER_ITEM(...) \
Packit 4a16fb
	SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_CONTAINER, __VA_ARGS__)
Packit 4a16fb
#define SNDRV_CTL_TLVD_DECLARE_CONTAINER(name, ...) \
Packit 4a16fb
	unsigned int name[] = { \
Packit 4a16fb
		SNDRV_CTL_TLVD_CONTAINER_ITEM(__VA_ARGS__) \
Packit 4a16fb
	}
Packit 4a16fb
Packit 4a16fb
#define SNDRV_CTL_TLVD_DB_SCALE_MASK	0xffff
Packit 4a16fb
#define SNDRV_CTL_TLVD_DB_SCALE_MUTE	0x10000
Packit 4a16fb
#define SNDRV_CTL_TLVD_DB_SCALE_ITEM(min, step, mute) \
Packit 4a16fb
	SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_SCALE, \
Packit 4a16fb
			    (min), \
Packit 4a16fb
			    ((step) & SNDRV_CTL_TLVD_DB_SCALE_MASK) | \
Packit 4a16fb
			     ((mute) ? SNDRV_CTL_TLVD_DB_SCALE_MUTE : 0))
Packit 4a16fb
#define SNDRV_CTL_TLVD_DECLARE_DB_SCALE(name, min, step, mute) \
Packit 4a16fb
	unsigned int name[] = { \
Packit 4a16fb
		SNDRV_CTL_TLVD_DB_SCALE_ITEM(min, step, mute) \
Packit 4a16fb
	}
Packit 4a16fb
Packit 4a16fb
/* Accessor offsets for min, mute and step items in dB scale type TLV */
Packit 4a16fb
#define SNDRV_CTL_TLVO_DB_SCALE_MIN		2
Packit 4a16fb
#define SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP	3
Packit 4a16fb
Packit 4a16fb
/* dB scale specified with min/max values instead of step */
Packit 4a16fb
#define SNDRV_CTL_TLVD_DB_MINMAX_ITEM(min_dB, max_dB) \
Packit 4a16fb
	SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_MINMAX, (min_dB), (max_dB))
Packit 4a16fb
#define SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \
Packit 4a16fb
	SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_MINMAX_MUTE, (min_dB), (max_dB))
Packit 4a16fb
#define SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(name, min_dB, max_dB) \
Packit 4a16fb
	unsigned int name[] = { \
Packit 4a16fb
		SNDRV_CTL_TLVD_DB_MINMAX_ITEM(min_dB, max_dB) \
Packit 4a16fb
	}
Packit 4a16fb
#define SNDRV_CTL_TLVD_DECLARE_DB_MINMAX_MUTE(name, min_dB, max_dB) \
Packit 4a16fb
	unsigned int name[] = { \
Packit 4a16fb
		SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \
Packit 4a16fb
	}
Packit 4a16fb
Packit 4a16fb
/* Accessor offsets for min, max items in db-minmax types of TLV. */
Packit 4a16fb
#define SNDRV_CTL_TLVO_DB_MINMAX_MIN	2
Packit 4a16fb
#define SNDRV_CTL_TLVO_DB_MINMAX_MAX	3
Packit 4a16fb
Packit 4a16fb
/* linear volume between min_dB and max_dB (.01dB unit) */
Packit 4a16fb
#define SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \
Packit 4a16fb
	SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_LINEAR, (min_dB), (max_dB))
Packit 4a16fb
#define SNDRV_CTL_TLVD_DECLARE_DB_LINEAR(name, min_dB, max_dB) \
Packit 4a16fb
	unsigned int name[] = { \
Packit 4a16fb
		SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \
Packit 4a16fb
	}
Packit 4a16fb
Packit 4a16fb
/* Accessor offsets for min, max items in db-linear type of TLV. */
Packit 4a16fb
#define SNDRV_CTL_TLVO_DB_LINEAR_MIN	2
Packit 4a16fb
#define SNDRV_CTL_TLVO_DB_LINEAR_MAX	3
Packit 4a16fb
Packit 4a16fb
/* dB range container:
Packit 4a16fb
 * Items in dB range container must be ordered by their values and by their
Packit 4a16fb
 * dB values. This implies that larger values must correspond with larger
Packit 4a16fb
 * dB values (which is also required for all other mixer controls).
Packit 4a16fb
 */
Packit 4a16fb
/* Each item is: <min> <max> <TLV> */
Packit 4a16fb
#define SNDRV_CTL_TLVD_DB_RANGE_ITEM(...) \
Packit 4a16fb
	SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_RANGE, __VA_ARGS__)
Packit 4a16fb
#define SNDRV_CTL_TLVD_DECLARE_DB_RANGE(name, ...) \
Packit 4a16fb
	unsigned int name[] = { \
Packit 4a16fb
		SNDRV_CTL_TLVD_DB_RANGE_ITEM(__VA_ARGS__) \
Packit 4a16fb
	}
Packit 4a16fb
Packit 4a16fb
#define SNDRV_CTL_TLVD_DB_GAIN_MUTE	-9999999
Packit 4a16fb
Packit 4a16fb
#endif