1#ifndef __SOUND_TLV_H
2#define __SOUND_TLV_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34#include <uapi/sound/tlv.h>
35
36#define TLV_ITEM(type, ...) \
37 (type), TLV_LENGTH(__VA_ARGS__), __VA_ARGS__
38#define TLV_LENGTH(...) \
39 ((unsigned int)sizeof((const unsigned int[]) { __VA_ARGS__ }))
40
41#define TLV_CONTAINER_ITEM(...) \
42 TLV_ITEM(SNDRV_CTL_TLVT_CONTAINER, __VA_ARGS__)
43#define DECLARE_TLV_CONTAINER(name, ...) \
44 unsigned int name[] = { TLV_CONTAINER_ITEM(__VA_ARGS__) }
45
46#define TLV_DB_SCALE_MASK 0xffff
47#define TLV_DB_SCALE_MUTE 0x10000
48#define TLV_DB_SCALE_ITEM(min, step, mute) \
49 TLV_ITEM(SNDRV_CTL_TLVT_DB_SCALE, \
50 (min), \
51 ((step) & TLV_DB_SCALE_MASK) | \
52 ((mute) ? TLV_DB_SCALE_MUTE : 0))
53#define DECLARE_TLV_DB_SCALE(name, min, step, mute) \
54 unsigned int name[] = { TLV_DB_SCALE_ITEM(min, step, mute) }
55
56
57#define TLV_DB_MINMAX_ITEM(min_dB, max_dB) \
58 TLV_ITEM(SNDRV_CTL_TLVT_DB_MINMAX, (min_dB), (max_dB))
59#define TLV_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \
60 TLV_ITEM(SNDRV_CTL_TLVT_DB_MINMAX_MUTE, (min_dB), (max_dB))
61#define DECLARE_TLV_DB_MINMAX(name, min_dB, max_dB) \
62 unsigned int name[] = { TLV_DB_MINMAX_ITEM(min_dB, max_dB) }
63#define DECLARE_TLV_DB_MINMAX_MUTE(name, min_dB, max_dB) \
64 unsigned int name[] = { TLV_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) }
65
66
67#define TLV_DB_LINEAR_ITEM(min_dB, max_dB) \
68 TLV_ITEM(SNDRV_CTL_TLVT_DB_LINEAR, (min_dB), (max_dB))
69#define DECLARE_TLV_DB_LINEAR(name, min_dB, max_dB) \
70 unsigned int name[] = { TLV_DB_LINEAR_ITEM(min_dB, max_dB) }
71
72
73
74
75
76
77
78#define TLV_DB_RANGE_ITEM(...) \
79 TLV_ITEM(SNDRV_CTL_TLVT_DB_RANGE, __VA_ARGS__)
80#define DECLARE_TLV_DB_RANGE(name, ...) \
81 unsigned int name[] = { TLV_DB_RANGE_ITEM(__VA_ARGS__) }
82
83#define TLV_DB_RANGE_HEAD(num) \
84 SNDRV_CTL_TLVT_DB_RANGE, 6 * (num) * sizeof(unsigned int)
85
86#define TLV_DB_GAIN_MUTE -9999999
87
88#endif
89