source: GPL/trunk/alsa-kernel/include/uapi/sound/tlv.h

Last change on this file was 772, checked in by David Azarewicz, 6 months ago

Merge in changes from 6.6-LTS branch.
Fixed additional 25+ problems.

File size: 4.5 KB
Line 
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/*
22 * TLV structure is right behind the struct snd_ctl_tlv:
23 * unsigned int type - see SNDRV_CTL_TLVT_*
24 * unsigned int length
25 * .... data aligned to sizeof(unsigned int), use
26 * block_length = (length + (sizeof(unsigned int) - 1)) &
27 * ~(sizeof(unsigned int) - 1)) ....
28 */
29#define SNDRV_CTL_TLVD_ITEM(type, ...) \
30 (type), SNDRV_CTL_TLVD_LENGTH(__VA_ARGS__), __VA_ARGS__
31#define SNDRV_CTL_TLVD_LENGTH(...) \
32 ((unsigned int)sizeof((const unsigned int[]) { __VA_ARGS__ }))
33
34/* Accessor offsets for TLV data items */
35#define SNDRV_CTL_TLVO_TYPE 0
36#define SNDRV_CTL_TLVO_LEN 1
37
38#define SNDRV_CTL_TLVD_CONTAINER_ITEM(...) \
39 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_CONTAINER, __VA_ARGS__)
40#define SNDRV_CTL_TLVD_DECLARE_CONTAINER(name, ...) \
41 unsigned int name[] = { \
42 SNDRV_CTL_TLVD_CONTAINER_ITEM(__VA_ARGS__) \
43 }
44
45#define SNDRV_CTL_TLVD_DB_SCALE_MASK 0xffff
46#define SNDRV_CTL_TLVD_DB_SCALE_MUTE 0x10000
47//check tlv.h.rej
48#ifndef TARGET_OS2
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#else
55//linux 3.2.0 version
56#define SNDRV_CTL_TLVD_DB_SCALE_ITEM(min, step, mute) \
57 SNDRV_CTL_TLVT_DB_SCALE, 2 * sizeof(unsigned int), \
58 (min), ((step) & TLV_DB_SCALE_MASK) | ((mute) ? TLV_DB_SCALE_MUTE : 0)
59#endif
60
61#define SNDRV_CTL_TLVD_DECLARE_DB_SCALE(name, min, step, mute) \
62 unsigned int name[] = { \
63 SNDRV_CTL_TLVD_DB_SCALE_ITEM(min, step, mute) \
64 }
65
66/* Accessor offsets for min, mute and step items in dB scale type TLV */
67#define SNDRV_CTL_TLVO_DB_SCALE_MIN 2
68#define SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP 3
69
70/* dB scale specified with min/max values instead of step */
71#define SNDRV_CTL_TLVD_DB_MINMAX_ITEM(min_dB, max_dB) \
72 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_MINMAX, (min_dB), (max_dB))
73#define SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \
74 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_MINMAX_MUTE, (min_dB), (max_dB))
75#define SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(name, min_dB, max_dB) \
76 unsigned int name[] = { \
77 SNDRV_CTL_TLVD_DB_MINMAX_ITEM(min_dB, max_dB) \
78 }
79#define SNDRV_CTL_TLVD_DECLARE_DB_MINMAX_MUTE(name, min_dB, max_dB) \
80 unsigned int name[] = { \
81 SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \
82 }
83
84/* Accessor offsets for min, max items in db-minmax types of TLV. */
85#define SNDRV_CTL_TLVO_DB_MINMAX_MIN 2
86#define SNDRV_CTL_TLVO_DB_MINMAX_MAX 3
87
88/* linear volume between min_dB and max_dB (.01dB unit) */
89
90#ifndef TARGET_OS2
91#define SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \
92 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_LINEAR, (min_dB), (max_dB))
93#else
94//linux 3.2.0 version
95#define SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \
96 SNDRV_CTL_TLVT_DB_LINEAR, 2 * sizeof(unsigned int), \
97 (min_dB), (max_dB)
98#endif
99#define SNDRV_CTL_TLVD_DECLARE_DB_LINEAR(name, min_dB, max_dB) \
100 unsigned int name[] = { \
101 SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \
102 }
103
104/* Accessor offsets for min, max items in db-linear type of TLV. */
105#define SNDRV_CTL_TLVO_DB_LINEAR_MIN 2
106#define SNDRV_CTL_TLVO_DB_LINEAR_MAX 3
107
108/* dB range container:
109 * Items in dB range container must be ordered by their values and by their
110 * dB values. This implies that larger values must correspond with larger
111 * dB values (which is also required for all other mixer controls).
112 */
113/* Each item is: <min> <max> <TLV> */
114#define SNDRV_CTL_TLVD_DB_RANGE_ITEM(...) \
115 SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_RANGE, __VA_ARGS__)
116#define SNDRV_CTL_TLVD_DECLARE_DB_RANGE(name, ...) \
117 unsigned int name[] = { \
118 SNDRV_CTL_TLVD_DB_RANGE_ITEM(__VA_ARGS__) \
119 }
120
121#define SNDRV_CTL_TLVD_DB_GAIN_MUTE -9999999
122
123#endif
Note: See TracBrowser for help on using the repository browser.