1
2
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Support for Digigram AlpX PCI-e boards
*
* Copyright (c) 2024 Digigram Digital (info@digigram.com)
*/
#ifndef _ALPX_CONTROLS_H
#define _ALPX_CONTROLS_H
#include "alpx.h"
#include "alpx_axcmem.h"
enum alpx_control_type {
ALPX_CONTROL_TYPE_AMPLIFIER = 0, /* Amplification stage*/
ALPX_CONTROL_TYPE_ANALOG_EQ, /* Analog CODEC stage*/
ALPX_CONTROL_TYPE_ROUTER, /* Router stage*/
ALPX_CONTROL_TYPE_MIXER, /* Mixer stage*/
ALPX_CONTROL_TYPE_CHOICE, /* misc controls */
ALPX_CONTROL_TYPE_FLAG, /* boolean controls */
ALPX_CONTROL_TYPE_FLAGS_EMBEDDED, /* Boolean controls embedded with others in the same register*/
ALPX_CONTROL_TYPE_GAINS_EMBEDDED, /* Amplifier controls embedded with others in the same register*/
ALPX_CONTROL_RESERVED, /* RESERVED Control, used to keep NumId if some controls are removed */
ALPX_CONTROL_TYPE_CONSTANT, /* CONSTANT Control, used for a mere constant value */
ALPX_CONTROL_TYPE_AXCMEM_REL_CHOICE, /*AXCM Relativ position Control*/
ALPX_CONTROL_TYPE_AXCMEM_REL_VALUE, /*AXCM Relativ position Control*/
ALPX_CONTROL_TYPE_TRANSLATED_CHOICE, /* Enumerated controls with translation tables for compatibility issue between Apps and FW */
};
struct alpx_control_descriptor_amplifier {
const unsigned int* gains_scale; /* Amplifier gains scale for application id cdB (snd_kcontrol_tlv_rw_t*) */
unsigned int reg_gain_min; /* min value for the register value*/
unsigned int reg_gain_max; /* max value for the register value*/
unsigned int lines_count; /* lines of this amplifier */
};
struct alpx_control_descriptor_codec {
u32 offset; /* Offset of the associated register */
const unsigned int* gains_scale; /* Amplifier gains scale for application id cdB (snd_kcontrol_tlv_rw_t*) */
unsigned int reg_gain_min; /* min value for the register value*/
unsigned int reg_gain_max; /* max value for the register value*/
unsigned int lines_count;
};
struct alpx_control_descriptor_router {
unsigned int lines_count;
const char **entries;
unsigned int entries_count;
};
struct alpx_control_descriptor_mixer {
const unsigned int* gains_scale; /* Amplifier gains scale for application id cdB (snd_kcontrol_tlv_rw_t*) */
unsigned int reg_gain_min; /* min value for the register value*/
unsigned int reg_gain_max; /* max value for the register value*/
unsigned int lines_count;
};
struct alpx_control_descriptor_choice {
u32 offset;
u32 mask;
u32 pos; /* start bit position in the register */
const char **entries;
u32 *entries_values;
unsigned int entries_count;
};
struct alpx_control_descriptor_translated_choice {
u32 offset;
u32 mask;
u32 pos; /* start bit position in the register */
const char **entries;
u32 *entries_values; /*Entries in card's context */
unsigned int entries_count;
u32* card_entries_values; /*Entries in register's context */
unsigned int card_entries_count;
};
struct alpx_control_descriptor_flag {
u32 offset;
u32 mask;
u32 pos;
};
struct alpx_control_descriptor_flags_embedded {
u32 offset;
u32 mask;
u32 pos;
unsigned int lines_count;
};
/* To be used when the amplifier controls are mixed with others in the same register*/
struct alpx_control_descriptor_gains_embedded {
const unsigned int* gains_scale; /* Amplifier gains scale for application id cdB (snd_kcontrol_tlv_rw_t*)*/
unsigned int min ;
unsigned int max;
unsigned int lines_count ;
unsigned int offset;
unsigned int mask;
unsigned int pos;
unsigned int width;
};
struct alpx_control_descriptor_constant {
u32 value;
};
struct alpx_control_descriptor_axcmem_rel_choice {
struct alpx_axcmem_loc base_loc;
struct alpx_axcmem_loc reg_loc;
u32 mask;
u32 pos;
uint32_t (*getter) (void* addr);
void (*setter) (void* addr, uint32_t value);
const char** entries;
u32* entries_values;
unsigned int entries_count;
};
struct alpx_control_descriptor_axcmem_rel_value {
struct alpx_axcmem_loc base_loc;
struct alpx_axcmem_loc reg_loc;
u32 mask;
u32 pos;
u32 min;
u32 max;
uint32_t (*getter) (void* addr);
void (*setter) (void* addr, uint32_t value);
};
/*****************************************************/
struct alpx_control_descriptor {
enum alpx_control_type type;
u32 base;
const char *prefix;
unsigned int access; /*Control access in ALSA way (se https://www.kernel.org/doc/html/v4.17/sound/kernel-api/writing-an-alsa-driver.html?highlight=sndrv_ctl_elem_access_readwrite#access-flags)*/
union {
struct alpx_control_descriptor_amplifier ampli;
struct alpx_control_descriptor_codec codec;
struct alpx_control_descriptor_router router;
struct alpx_control_descriptor_mixer mixer;
struct alpx_control_descriptor_choice choice;
struct alpx_control_descriptor_flag flag;
struct alpx_control_descriptor_flags_embedded mic_flags;
struct alpx_control_descriptor_gains_embedded mic_gains;
struct alpx_control_descriptor_constant constant;
struct alpx_control_descriptor_axcmem_rel_choice axcmem_rel_choice;
struct alpx_control_descriptor_axcmem_rel_value axcmem_rel_value;
struct alpx_control_descriptor_translated_choice translated_choice;
} data;
};
struct alpx_control_amplifier {
unsigned int gain;
unsigned int idx;
};
struct alpx_control_router {
unsigned int index;
};
struct alpx_control_mixer {
unsigned int mixer_in;
unsigned int mixer_out;
};
struct alpx_control_codec{
unsigned int idx;
};
struct alpx_control_mic {
unsigned int stored_gain_in_reg;
};
struct alpx_control {
struct alpx_control_descriptor *descriptor;
union {
struct alpx_control_amplifier ampli;
struct alpx_control_router router;
struct alpx_control_mixer mixer;
struct alpx_control_codec codec;
struct alpx_control_mic mic;
} data;
};
int alpx_controls_register(struct snd_card *card);
int alp222_mic_controls_default_config(struct alpx_device * alpx_dev);
#endif
|