1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Driver for Digigram miXart soundcards
5 * low level interface with interrupt handling and mail box implementation
7 * Copyright (c) 2003 by Digigram <alsa@digigram.com>
10 #ifndef __SOUND_MIXART_CORE_H
11 #define __SOUND_MIXART_CORE_H
14 enum mixart_message_id {
15 MSG_CONNECTOR_GET_AUDIO_INFO = 0x050008,
16 MSG_CONNECTOR_GET_OUT_AUDIO_LEVEL = 0x050009,
17 MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL = 0x05000A,
19 MSG_CONSOLE_MANAGER = 0x070000,
20 MSG_CONSOLE_GET_CLOCK_UID = 0x070003,
22 MSG_PHYSICALIO_SET_LEVEL = 0x0F0008,
24 MSG_STREAM_ADD_INPUT_GROUP = 0x130000,
25 MSG_STREAM_ADD_OUTPUT_GROUP = 0x130001,
26 MSG_STREAM_DELETE_GROUP = 0x130004,
27 MSG_STREAM_START_STREAM_GRP_PACKET = 0x130006,
28 MSG_STREAM_START_INPUT_STAGE_PACKET = 0x130007,
29 MSG_STREAM_START_OUTPUT_STAGE_PACKET = 0x130008,
30 MSG_STREAM_STOP_STREAM_GRP_PACKET = 0x130009,
31 MSG_STREAM_STOP_INPUT_STAGE_PACKET = 0x13000A,
32 MSG_STREAM_STOP_OUTPUT_STAGE_PACKET = 0x13000B,
33 MSG_STREAM_SET_INPUT_STAGE_PARAM = 0x13000F,
34 MSG_STREAM_SET_OUTPUT_STAGE_PARAM = 0x130010,
35 MSG_STREAM_SET_IN_AUDIO_LEVEL = 0x130015,
36 MSG_STREAM_SET_OUT_STREAM_LEVEL = 0x130017,
38 MSG_SYSTEM_FIRST_ID = 0x160000,
39 MSG_SYSTEM_ENUM_PHYSICAL_IO = 0x16000E,
40 MSG_SYSTEM_ENUM_PLAY_CONNECTOR = 0x160017,
41 MSG_SYSTEM_ENUM_RECORD_CONNECTOR = 0x160018,
42 MSG_SYSTEM_WAIT_SYNCHRO_CMD = 0x16002C,
43 MSG_SYSTEM_SEND_SYNCHRO_CMD = 0x16002D,
45 MSG_SERVICES_TIMER_NOTIFY = 0x1D0404,
46 MSG_SERVICES_REPORT_TRACES = 0x1D0700,
48 MSG_CLOCK_CHECK_PROPERTIES = 0x200001,
49 MSG_CLOCK_SET_PROPERTIES = 0x200002,
56 struct mixart_uid uid;
61 /* structs used to communicate with miXart */
63 struct mixart_enum_connector_resp
68 u32 current_uid_index;
69 struct mixart_uid uid[MIXART_MAX_PHYS_CONNECTORS];
70 } __attribute__((packed));
73 /* used for following struct */
74 #define MIXART_FLOAT_P_22_0_TO_HEX 0x41b00000 /* 22.0f */
75 #define MIXART_FLOAT_M_20_0_TO_HEX 0xc1a00000 /* -20.0f */
76 #define MIXART_FLOAT____0_0_TO_HEX 0x00000000 /* 0.0f */
78 struct mixart_audio_info_req
80 u32 line_max_level; /* float */
81 u32 micro_max_level; /* float */
82 u32 cd_max_level; /* float */
83 } __attribute__((packed));
85 struct mixart_analog_hw_info
88 u32 hw_connection_type;
89 u32 max_level; /* float */
90 u32 min_var_level; /* float */
91 u32 max_var_level; /* float */
92 u32 step_var_level; /* float */
93 u32 fix_gain; /* float */
94 u32 zero_var; /* float */
95 } __attribute__((packed));
97 struct mixart_digital_hw_info
99 u32 hw_connection_type;
103 } __attribute__((packed));
105 struct mixart_analog_info
108 struct mixart_analog_hw_info micro_info;
109 struct mixart_analog_hw_info line_info;
110 struct mixart_analog_hw_info cd_info;
111 u32 analog_level_present;
112 } __attribute__((packed));
114 struct mixart_digital_info
117 struct mixart_digital_hw_info aes_info;
118 struct mixart_digital_hw_info adat_info;
119 } __attribute__((packed));
121 struct mixart_audio_info
124 struct mixart_analog_info analog_info;
125 struct mixart_digital_info digital_info;
126 } __attribute__((packed));
128 struct mixart_audio_info_resp
131 struct mixart_audio_info info;
132 } __attribute__((packed));
135 /* used for nb_bytes_max_per_sample */
136 #define MIXART_FLOAT_P__4_0_TO_HEX 0x40800000 /* +4.0f */
137 #define MIXART_FLOAT_P__8_0_TO_HEX 0x41000000 /* +8.0f */
139 struct mixart_stream_info
141 u32 size_max_byte_frame;
142 u32 size_max_sample_frame;
143 u32 nb_bytes_max_per_sample; /* float */
144 } __attribute__((packed));
146 /* MSG_STREAM_ADD_INPUT_GROUP */
147 /* MSG_STREAM_ADD_OUTPUT_GROUP */
149 struct mixart_streaming_group_req
154 u32 first_phys_audio;
156 struct mixart_stream_info stream_info[32];
157 struct mixart_uid connector;
159 } __attribute__((packed));
161 struct mixart_stream_desc
163 struct mixart_uid stream_uid;
165 } __attribute__((packed));
167 struct mixart_streaming_group
170 struct mixart_uid group;
173 struct mixart_stream_desc stream[32];
174 } __attribute__((packed));
176 /* MSG_STREAM_DELETE_GROUP */
178 /* request : mixart_uid_t group */
180 struct mixart_delete_group_resp
184 } __attribute__((packed));
187 /* MSG_STREAM_START_INPUT_STAGE_PACKET = 0x130000 + 7,
188 MSG_STREAM_START_OUTPUT_STAGE_PACKET = 0x130000 + 8,
189 MSG_STREAM_STOP_INPUT_STAGE_PACKET = 0x130000 + 10,
190 MSG_STREAM_STOP_OUTPUT_STAGE_PACKET = 0x130000 + 11,
193 struct mixart_fx_couple_uid
195 struct mixart_uid uid_fx_code;
196 struct mixart_uid uid_fx_data;
197 } __attribute__((packed));
199 struct mixart_txx_stream_desc
201 struct mixart_uid uid_pipe;
204 struct mixart_fx_couple_uid uid_fx[4];
205 } __attribute__((packed));
207 struct mixart_flow_info
209 struct mixart_txx_stream_desc stream_desc;
212 } __attribute__((packed));
214 struct mixart_stream_state_req
219 u32 stream_count; /* set to 1 for instance */
220 struct mixart_flow_info stream_info; /* could be an array[stream_count] */
221 } __attribute__((packed));
223 /* MSG_STREAM_START_STREAM_GRP_PACKET = 0x130000 + 6
224 MSG_STREAM_STOP_STREAM_GRP_PACKET = 0x130000 + 9
227 struct mixart_group_state_req
232 u32 pipe_count; /* set to 1 for instance */
233 struct mixart_uid pipe_uid[1]; /* could be an array[pipe_count] */
234 } __attribute__((packed));
236 struct mixart_group_state_resp
240 } __attribute__((packed));
244 /* Structures used by the MSG_SERVICES_TIMER_NOTIFY command */
246 struct mixart_sample_pos
250 u32 sample_pos_high_part;
251 u32 sample_pos_low_part;
252 } __attribute__((packed));
254 struct mixart_timer_notify
257 struct mixart_sample_pos streams[MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS];
258 } __attribute__((packed));
261 /* MSG_CONSOLE_GET_CLOCK_UID = 0x070003,
264 /* request is a uid with desc = MSG_CONSOLE_MANAGER | cardindex */
266 struct mixart_return_uid
269 struct mixart_uid uid;
270 } __attribute__((packed));
272 /* MSG_CLOCK_CHECK_PROPERTIES = 0x200001,
273 MSG_CLOCK_SET_PROPERTIES = 0x200002,
276 enum mixart_clock_generic_type {
279 CGT_PROGRAMMABLE_CLOCK,
280 CGT_INTERNAL_ENSLAVED_CLOCK,
285 enum mixart_clock_mode {
294 struct mixart_clock_properties
299 u32 reference_frequency;
300 u32 clock_generic_type;
302 struct mixart_uid uid_clock_source;
303 struct mixart_uid uid_event_source;
305 u32 synchro_signal_presence;
308 u32 nb_callers; /* set to 1 (see below) */
309 struct mixart_uid uid_caller[1];
310 } __attribute__((packed));
312 struct mixart_clock_properties_resp
316 } __attribute__((packed));
319 /* MSG_STREAM_SET_INPUT_STAGE_PARAM = 0x13000F */
320 /* MSG_STREAM_SET_OUTPUT_STAGE_PARAM = 0x130010 */
322 enum mixart_coding_type {
331 enum mixart_sample_type {
333 ST_FLOATING_POINT_32BE,
334 ST_FLOATING_POINT_32LE,
335 ST_FLOATING_POINT_64BE,
336 ST_FLOATING_POINT_64LE,
353 struct mixart_stream_param_desc
355 u32 coding_type; /* use enum mixart_coding_type */
356 u32 sample_type; /* use enum mixart_sample_type */
360 u32 linear_endian_ness;
364 } linear_format_info;
369 u32 mpeg_mode_extension;
370 u32 mpeg_pre_emphasis;
371 u32 mpeg_has_padding_bit;
373 u32 mpeg_has_extension;
374 u32 mpeg_is_original;
375 u32 mpeg_has_copyright;
385 u32 samples_per_frame;
387 u32 bytes_per_sample;
389 u32 number_of_channel;
394 u32 pipe_count; /* set to 1 (array size !) */
395 u32 stream_count; /* set to 1 (array size !) */
396 struct mixart_txx_stream_desc stream_desc[1]; /* only one stream per command, but this could be an array */
398 } __attribute__((packed));
401 /* MSG_CONNECTOR_GET_OUT_AUDIO_LEVEL = 0x050009,
405 struct mixart_get_out_audio_level
408 u32 digital_level; /* float */
409 u32 analog_level; /* float */
410 u32 monitor_level; /* float */
414 } __attribute__((packed));
417 /* MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL = 0x05000A,
420 /* used for valid_mask below */
421 #define MIXART_AUDIO_LEVEL_ANALOG_MASK 0x01
422 #define MIXART_AUDIO_LEVEL_DIGITAL_MASK 0x02
423 #define MIXART_AUDIO_LEVEL_MONITOR_MASK 0x04
424 #define MIXART_AUDIO_LEVEL_MUTE_MASK 0x08
425 #define MIXART_AUDIO_LEVEL_MUTE_M1_MASK 0x10
426 #define MIXART_AUDIO_LEVEL_MUTE_M2_MASK 0x20
428 struct mixart_set_out_audio_level
434 u32 digital_level; /* float */
435 u32 analog_level; /* float */
436 u32 monitor_level; /* float */
441 } __attribute__((packed));
444 /* MSG_SYSTEM_ENUM_PHYSICAL_IO = 0x16000E,
447 #define MIXART_MAX_PHYS_IO (MIXART_MAX_CARDS * 2 * 2) /* 4 * (analog+digital) * (playback+capture) */
449 struct mixart_uid_enumeration
452 u32 first_uid_offset;
454 u32 current_uid_index;
455 struct mixart_uid uid[MIXART_MAX_PHYS_IO];
456 } __attribute__((packed));
459 /* MSG_PHYSICALIO_SET_LEVEL = 0x0F0008,
460 MSG_PHYSICALIO_GET_LEVEL = 0x0F000C,
463 struct mixart_io_channel_level
465 u32 analog_level; /* float */
467 } __attribute__((packed));
469 struct mixart_io_level
471 s32 channel; /* 0=left, 1=right, -1=both, -2=both same */
472 struct mixart_io_channel_level level[2];
473 } __attribute__((packed));
476 /* MSG_STREAM_SET_IN_AUDIO_LEVEL = 0x130015,
479 struct mixart_in_audio_level_info
481 struct mixart_uid connector;
486 } __attribute__((packed));
488 struct mixart_set_in_audio_level_req
492 u32 audio_count; /* set to <= 2 */
494 struct mixart_in_audio_level_info level[2];
495 } __attribute__((packed));
497 /* response is a 32 bit status */
500 /* MSG_STREAM_SET_OUT_STREAM_LEVEL = 0x130017,
503 /* defines used for valid_mask1 */
504 #define MIXART_OUT_STREAM_SET_LEVEL_LEFT_AUDIO1 0x01
505 #define MIXART_OUT_STREAM_SET_LEVEL_LEFT_AUDIO2 0x02
506 #define MIXART_OUT_STREAM_SET_LEVEL_RIGHT_AUDIO1 0x04
507 #define MIXART_OUT_STREAM_SET_LEVEL_RIGHT_AUDIO2 0x08
508 #define MIXART_OUT_STREAM_SET_LEVEL_STREAM_1 0x10
509 #define MIXART_OUT_STREAM_SET_LEVEL_STREAM_2 0x20
510 #define MIXART_OUT_STREAM_SET_LEVEL_MUTE_1 0x40
511 #define MIXART_OUT_STREAM_SET_LEVEL_MUTE_2 0x80
513 struct mixart_out_stream_level_info
517 u32 left_to_out1_level;
518 u32 left_to_out2_level;
519 u32 right_to_out1_level;
520 u32 right_to_out2_level;
525 } __attribute__((packed));
527 struct mixart_set_out_stream_level
529 struct mixart_txx_stream_desc desc;
530 struct mixart_out_stream_level_info out_level;
531 } __attribute__((packed));
533 struct mixart_set_out_stream_level_req
538 u32 nb_of_stream; /* set to 1 */
539 struct mixart_set_out_stream_level stream_level; /* could be an array */
540 } __attribute__((packed));
542 /* response to this request is a u32 status value */
546 void snd_mixart_init_mailbox(struct mixart_mgr *mgr);
547 void snd_mixart_exit_mailbox(struct mixart_mgr *mgr);
549 int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int max_resp_size, void *resp_data);
550 int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr, struct mixart_msg *request, u32 notif_event);
551 int snd_mixart_send_msg_nonblock(struct mixart_mgr *mgr, struct mixart_msg *request);
553 irqreturn_t snd_mixart_interrupt(int irq, void *dev_id);
554 irqreturn_t snd_mixart_threaded_irq(int irq, void *dev_id);
556 void snd_mixart_reset_board(struct mixart_mgr *mgr);
558 #endif /* __SOUND_MIXART_CORE_H */