1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2 3 #ifndef __UAPI_SOUND_TLV_H 4 #define __UAPI_SOUND_TLV_H 5 6 #define SNDRV_CTL_TLVT_CONTAINER 0 /* one level down - group of TLVs */ 7 #define SNDRV_CTL_TLVT_DB_SCALE 1 /* dB scale */ 8 #define SNDRV_CTL_TLVT_DB_LINEAR 2 /* linear volume */ 9 #define SNDRV_CTL_TLVT_DB_RANGE 3 /* dB range container */ 10 #define SNDRV_CTL_TLVT_DB_MINMAX 4 /* dB scale with min/max */ 11 #define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */ 12 13 /* 14 * channel-mapping TLV items 15 * TLV length must match with num_channels 16 */ 17 #define SNDRV_CTL_TLVT_CHMAP_FIXED 0x101 /* fixed channel position */ 18 #define SNDRV_CTL_TLVT_CHMAP_VAR 0x102 /* channels freely swappable */ 19 #define SNDRV_CTL_TLVT_CHMAP_PAIRED 0x103 /* pair-wise swappable */ 20 21 #define SNDRV_CTL_TLVT_FCP_CHANNEL_LABELS 0x110 /* channel labels */ 22 23 /* 24 * TLV structure is right behind the struct snd_ctl_tlv: 25 * unsigned int type - see SNDRV_CTL_TLVT_* 26 * unsigned int length 27 * .... data aligned to sizeof(unsigned int), use 28 * block_length = (length + (sizeof(unsigned int) - 1)) & 29 * ~(sizeof(unsigned int) - 1)) .... 30 */ 31 #define SNDRV_CTL_TLVD_ITEM(type, ...) \ 32 (type), SNDRV_CTL_TLVD_LENGTH(__VA_ARGS__), __VA_ARGS__ 33 #define SNDRV_CTL_TLVD_LENGTH(...) \ 34 ((unsigned int)sizeof((const unsigned int[]) { __VA_ARGS__ })) 35 36 /* Accessor offsets for TLV data items */ 37 #define SNDRV_CTL_TLVO_TYPE 0 38 #define SNDRV_CTL_TLVO_LEN 1 39 40 #define SNDRV_CTL_TLVD_CONTAINER_ITEM(...) \ 41 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_CONTAINER, __VA_ARGS__) 42 #define SNDRV_CTL_TLVD_DECLARE_CONTAINER(name, ...) \ 43 unsigned int name[] = { \ 44 SNDRV_CTL_TLVD_CONTAINER_ITEM(__VA_ARGS__) \ 45 } 46 47 #define SNDRV_CTL_TLVD_DB_SCALE_MASK 0xffff 48 #define SNDRV_CTL_TLVD_DB_SCALE_MUTE 0x10000 49 #define SNDRV_CTL_TLVD_DB_SCALE_ITEM(min, step, mute) \ 50 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_SCALE, \ 51 (min), \ 52 ((step) & SNDRV_CTL_TLVD_DB_SCALE_MASK) | \ 53 ((mute) ? SNDRV_CTL_TLVD_DB_SCALE_MUTE : 0)) 54 #define SNDRV_CTL_TLVD_DECLARE_DB_SCALE(name, min, step, mute) \ 55 unsigned int name[] = { \ 56 SNDRV_CTL_TLVD_DB_SCALE_ITEM(min, step, mute) \ 57 } 58 59 /* Accessor offsets for min, mute and step items in dB scale type TLV */ 60 #define SNDRV_CTL_TLVO_DB_SCALE_MIN 2 61 #define SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP 3 62 63 /* dB scale specified with min/max values instead of step */ 64 #define SNDRV_CTL_TLVD_DB_MINMAX_ITEM(min_dB, max_dB) \ 65 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_MINMAX, (min_dB), (max_dB)) 66 #define SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \ 67 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_MINMAX_MUTE, (min_dB), (max_dB)) 68 #define SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(name, min_dB, max_dB) \ 69 unsigned int name[] = { \ 70 SNDRV_CTL_TLVD_DB_MINMAX_ITEM(min_dB, max_dB) \ 71 } 72 #define SNDRV_CTL_TLVD_DECLARE_DB_MINMAX_MUTE(name, min_dB, max_dB) \ 73 unsigned int name[] = { \ 74 SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \ 75 } 76 77 /* Accessor offsets for min, max items in db-minmax types of TLV. */ 78 #define SNDRV_CTL_TLVO_DB_MINMAX_MIN 2 79 #define SNDRV_CTL_TLVO_DB_MINMAX_MAX 3 80 81 /* linear volume between min_dB and max_dB (.01dB unit) */ 82 #define SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \ 83 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_LINEAR, (min_dB), (max_dB)) 84 #define SNDRV_CTL_TLVD_DECLARE_DB_LINEAR(name, min_dB, max_dB) \ 85 unsigned int name[] = { \ 86 SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \ 87 } 88 89 /* Accessor offsets for min, max items in db-linear type of TLV. */ 90 #define SNDRV_CTL_TLVO_DB_LINEAR_MIN 2 91 #define SNDRV_CTL_TLVO_DB_LINEAR_MAX 3 92 93 /* dB range container: 94 * Items in dB range container must be ordered by their values and by their 95 * dB values. This implies that larger values must correspond with larger 96 * dB values (which is also required for all other mixer controls). 97 */ 98 /* Each item is: <min> <max> <TLV> */ 99 #define SNDRV_CTL_TLVD_DB_RANGE_ITEM(...) \ 100 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_RANGE, __VA_ARGS__) 101 #define SNDRV_CTL_TLVD_DECLARE_DB_RANGE(name, ...) \ 102 unsigned int name[] = { \ 103 SNDRV_CTL_TLVD_DB_RANGE_ITEM(__VA_ARGS__) \ 104 } 105 106 #define SNDRV_CTL_TLVD_DB_GAIN_MUTE -9999999 107 108 #endif 109