1 /* 2 * Driver for Digigram miXart soundcards 3 * 4 * low level interface with interrupt handling and mail box implementation 5 * 6 * Copyright (c) 2003 by Digigram <alsa@digigram.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 */ 22 23 #ifndef __SOUND_MIXART_CORE_H 24 #define __SOUND_MIXART_CORE_H 25 26 27 enum mixart_message_id { 28 MSG_CONNECTOR_GET_AUDIO_INFO = 0x050008, 29 MSG_CONNECTOR_GET_OUT_AUDIO_LEVEL = 0x050009, 30 MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL = 0x05000A, 31 32 MSG_CONSOLE_MANAGER = 0x070000, 33 MSG_CONSOLE_GET_CLOCK_UID = 0x070003, 34 35 MSG_PHYSICALIO_SET_LEVEL = 0x0F0008, 36 37 MSG_STREAM_ADD_INPUT_GROUP = 0x130000, 38 MSG_STREAM_ADD_OUTPUT_GROUP = 0x130001, 39 MSG_STREAM_DELETE_GROUP = 0x130004, 40 MSG_STREAM_START_STREAM_GRP_PACKET = 0x130006, 41 MSG_STREAM_START_INPUT_STAGE_PACKET = 0x130007, 42 MSG_STREAM_START_OUTPUT_STAGE_PACKET = 0x130008, 43 MSG_STREAM_STOP_STREAM_GRP_PACKET = 0x130009, 44 MSG_STREAM_STOP_INPUT_STAGE_PACKET = 0x13000A, 45 MSG_STREAM_STOP_OUTPUT_STAGE_PACKET = 0x13000B, 46 MSG_STREAM_SET_INPUT_STAGE_PARAM = 0x13000F, 47 MSG_STREAM_SET_OUTPUT_STAGE_PARAM = 0x130010, 48 MSG_STREAM_SET_IN_AUDIO_LEVEL = 0x130015, 49 MSG_STREAM_SET_OUT_STREAM_LEVEL = 0x130017, 50 51 MSG_SYSTEM_FIRST_ID = 0x160000, 52 MSG_SYSTEM_ENUM_PHYSICAL_IO = 0x16000E, 53 MSG_SYSTEM_ENUM_PLAY_CONNECTOR = 0x160017, 54 MSG_SYSTEM_ENUM_RECORD_CONNECTOR = 0x160018, 55 MSG_SYSTEM_WAIT_SYNCHRO_CMD = 0x16002C, 56 MSG_SYSTEM_SEND_SYNCHRO_CMD = 0x16002D, 57 58 MSG_SERVICES_TIMER_NOTIFY = 0x1D0404, 59 MSG_SERVICES_REPORT_TRACES = 0x1D0700, 60 61 MSG_CLOCK_CHECK_PROPERTIES = 0x200001, 62 MSG_CLOCK_SET_PROPERTIES = 0x200002, 63 }; 64 65 66 typedef struct mixart_msg mixart_msg_t; 67 struct mixart_msg 68 { 69 u32 message_id; 70 mixart_uid_t uid; 71 void* data; 72 size_t size; 73 }; 74 75 /* structs used to communicate with miXart */ 76 77 typedef struct mixart_enum_connector_resp mixart_enum_connector_resp_t; 78 struct mixart_enum_connector_resp 79 { 80 u32 error_code; 81 u32 first_uid_offset; 82 u32 uid_count; 83 u32 current_uid_index; 84 mixart_uid_t uid[MIXART_MAX_PHYS_CONNECTORS]; 85 } __attribute__((packed)); 86 87 88 /* used for following struct */ 89 #define MIXART_FLOAT_P_22_0_TO_HEX 0x41b00000 /* 22.0f */ 90 #define MIXART_FLOAT_M_20_0_TO_HEX 0xc1a00000 /* -20.0f */ 91 #define MIXART_FLOAT____0_0_TO_HEX 0x00000000 /* 0.0f */ 92 93 typedef struct mixart_audio_info_req mixart_audio_info_req_t; 94 struct mixart_audio_info_req 95 { 96 u32 line_max_level; /* float */ 97 u32 micro_max_level; /* float */ 98 u32 cd_max_level; /* float */ 99 } __attribute__((packed)); 100 101 typedef struct mixart_analog_hw_info mixart_analog_hw_info_t; 102 struct mixart_analog_hw_info 103 { 104 u32 is_present; 105 u32 hw_connection_type; 106 u32 max_level; /* float */ 107 u32 min_var_level; /* float */ 108 u32 max_var_level; /* float */ 109 u32 step_var_level; /* float */ 110 u32 fix_gain; /* float */ 111 u32 zero_var; /* float */ 112 } __attribute__((packed)); 113 114 typedef struct mixart_digital_hw_info mixart_digital_hw_info_t; 115 struct mixart_digital_hw_info 116 { 117 u32 hw_connection_type; 118 u32 presence; 119 u32 clock; 120 u32 reserved; 121 } __attribute__((packed)); 122 123 typedef struct mixart_analog_info mixart_analog_info_t; 124 struct mixart_analog_info 125 { 126 u32 type_mask; 127 mixart_analog_hw_info_t micro_info; 128 mixart_analog_hw_info_t line_info; 129 mixart_analog_hw_info_t cd_info; 130 u32 analog_level_present; 131 } __attribute__((packed)); 132 133 typedef struct mixart_digital_info mixart_digital_info_t; 134 struct mixart_digital_info 135 { 136 u32 type_mask; 137 mixart_digital_hw_info_t aes_info; 138 mixart_digital_hw_info_t adat_info; 139 } __attribute__((packed)); 140 141 typedef struct mixart_audio_info mixart_audio_info_t; 142 struct mixart_audio_info 143 { 144 u32 clock_type_mask; 145 mixart_analog_info_t analog_info; 146 mixart_digital_info_t digital_info; 147 } __attribute__((packed)); 148 149 typedef struct mixart_audio_info_resp mixart_audio_info_resp_t; 150 struct mixart_audio_info_resp 151 { 152 u32 txx_status; 153 mixart_audio_info_t info; 154 } __attribute__((packed)); 155 156 157 /* used for nb_bytes_max_per_sample */ 158 #define MIXART_FLOAT_P__4_0_TO_HEX 0x40800000 /* +4.0f */ 159 #define MIXART_FLOAT_P__8_0_TO_HEX 0x41000000 /* +8.0f */ 160 161 typedef struct mixart_stream_info mixart_stream_info_t; 162 struct mixart_stream_info 163 { 164 u32 size_max_byte_frame; 165 u32 size_max_sample_frame; 166 u32 nb_bytes_max_per_sample; /* float */ 167 } __attribute__((packed)); 168 169 /* MSG_STREAM_ADD_INPUT_GROUP */ 170 /* MSG_STREAM_ADD_OUTPUT_GROUP */ 171 172 typedef struct mixart_streaming_group_req mixart_streaming_group_req_t; 173 struct mixart_streaming_group_req 174 { 175 u32 stream_count; 176 u32 channel_count; 177 u32 user_grp_number; 178 u32 first_phys_audio; 179 u32 latency; 180 mixart_stream_info_t stream_info[32]; 181 mixart_uid_t connector; 182 u32 flow_entry[32]; 183 } __attribute__((packed)); 184 185 typedef struct mixart_stream_desc mixart_stream_desc_t; 186 struct mixart_stream_desc 187 { 188 mixart_uid_t stream_uid; 189 u32 stream_desc; 190 } __attribute__((packed)); 191 192 typedef struct mixart_streaming_group mixart_streaming_group_t; 193 struct mixart_streaming_group 194 { 195 u32 status; 196 mixart_uid_t group; 197 u32 pipe_desc; 198 u32 stream_count; 199 mixart_stream_desc_t stream[32]; 200 } __attribute__((packed)); 201 202 /* MSG_STREAM_DELETE_GROUP */ 203 204 /* request : mixart_uid_t group */ 205 206 typedef struct mixart_delete_group_resp mixart_delete_group_resp_t; 207 struct mixart_delete_group_resp 208 { 209 u32 status; 210 u32 unused[2]; 211 } __attribute__((packed)); 212 213 214 /* MSG_STREAM_START_INPUT_STAGE_PACKET = 0x130000 + 7, 215 MSG_STREAM_START_OUTPUT_STAGE_PACKET = 0x130000 + 8, 216 MSG_STREAM_STOP_INPUT_STAGE_PACKET = 0x130000 + 10, 217 MSG_STREAM_STOP_OUTPUT_STAGE_PACKET = 0x130000 + 11, 218 */ 219 220 typedef struct mixart_fx_couple_uid mixart_fx_couple_uid_t; 221 struct mixart_fx_couple_uid 222 { 223 mixart_uid_t uid_fx_code; 224 mixart_uid_t uid_fx_data; 225 } __attribute__((packed)); 226 227 typedef struct mixart_txx_stream_desc mixart_txx_stream_desc_t; 228 struct mixart_txx_stream_desc 229 { 230 mixart_uid_t uid_pipe; 231 u32 stream_idx; 232 u32 fx_number; 233 mixart_fx_couple_uid_t uid_fx[4]; 234 } __attribute__((packed)); 235 236 typedef struct mixart_flow_info mixart_flow_info_t; 237 struct mixart_flow_info 238 { 239 mixart_txx_stream_desc_t stream_desc; 240 u32 flow_entry; 241 u32 flow_phy_addr; 242 } __attribute__((packed)); 243 244 typedef struct mixart_stream_state_req mixart_stream_state_req_t; 245 struct mixart_stream_state_req 246 { 247 u32 delayed; 248 u64 scheduler; 249 u32 reserved4np[3]; 250 u32 stream_count; /* set to 1 for instance */ 251 mixart_flow_info_t stream_info; /* could be an array[stream_count] */ 252 } __attribute__((packed)); 253 254 /* MSG_STREAM_START_STREAM_GRP_PACKET = 0x130000 + 6 255 MSG_STREAM_STOP_STREAM_GRP_PACKET = 0x130000 + 9 256 */ 257 258 typedef struct mixart_group_state_req mixart_group_state_req_t; 259 struct mixart_group_state_req 260 { 261 u32 delayed; 262 u64 scheduler; 263 u32 reserved4np[2]; 264 u32 pipe_count; /* set to 1 for instance */ 265 mixart_uid_t pipe_uid[1]; /* could be an array[pipe_count] */ 266 } __attribute__((packed)); 267 268 typedef struct mixart_group_state_resp mixart_group_state_resp_t; 269 struct mixart_group_state_resp 270 { 271 u32 txx_status; 272 u64 scheduler; 273 } __attribute__((packed)); 274 275 276 277 /* Structures used by the MSG_SERVICES_TIMER_NOTIFY command */ 278 279 typedef struct mixart_sample_pos mixart_sample_pos_t; 280 struct mixart_sample_pos 281 { 282 u32 buffer_id; 283 u32 validity; 284 u32 sample_pos_high_part; 285 u32 sample_pos_low_part; 286 } __attribute__((packed)); 287 288 typedef struct mixart_timer_notify mixart_timer_notify_t; 289 struct mixart_timer_notify 290 { 291 u32 stream_count; 292 mixart_sample_pos_t streams[MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS]; 293 } __attribute__((packed)); 294 295 296 /* MSG_CONSOLE_GET_CLOCK_UID = 0x070003, 297 */ 298 299 /* request is a uid with desc = MSG_CONSOLE_MANAGER | cardindex */ 300 301 typedef struct mixart_return_uid mixart_return_uid_t; 302 struct mixart_return_uid 303 { 304 u32 error_code; 305 mixart_uid_t uid; 306 } __attribute__((packed)); 307 308 /* MSG_CLOCK_CHECK_PROPERTIES = 0x200001, 309 MSG_CLOCK_SET_PROPERTIES = 0x200002, 310 */ 311 312 enum mixart_clock_generic_type { 313 CGT_NO_CLOCK, 314 CGT_INTERNAL_CLOCK, 315 CGT_PROGRAMMABLE_CLOCK, 316 CGT_INTERNAL_ENSLAVED_CLOCK, 317 CGT_EXTERNAL_CLOCK, 318 CGT_CURRENT_CLOCK 319 }; 320 321 enum mixart_clock_mode { 322 CM_UNDEFINED, 323 CM_MASTER, 324 CM_SLAVE, 325 CM_STANDALONE, 326 CM_NOT_CONCERNED 327 }; 328 329 330 typedef struct mixart_clock_properties mixart_clock_properties_t; 331 struct mixart_clock_properties 332 { 333 u32 error_code; 334 u32 validation_mask; 335 u32 frequency; 336 u32 reference_frequency; 337 u32 clock_generic_type; 338 u32 clock_mode; 339 mixart_uid_t uid_clock_source; 340 mixart_uid_t uid_event_source; 341 u32 event_mode; 342 u32 synchro_signal_presence; 343 u32 format; 344 u32 board_mask; 345 u32 nb_callers; /* set to 1 (see below) */ 346 mixart_uid_t uid_caller[1]; 347 } __attribute__((packed)); 348 349 typedef struct mixart_clock_properties_resp mixart_clock_properties_resp_t; 350 struct mixart_clock_properties_resp 351 { 352 u32 status; 353 u32 clock_mode; 354 } __attribute__((packed)); 355 356 357 /* MSG_STREAM_SET_INPUT_STAGE_PARAM = 0x13000F */ 358 /* MSG_STREAM_SET_OUTPUT_STAGE_PARAM = 0x130010 */ 359 360 enum mixart_coding_type { 361 CT_NOT_DEFINED, 362 CT_LINEAR, 363 CT_MPEG_L1, 364 CT_MPEG_L2, 365 CT_MPEG_L3, 366 CT_MPEG_L3_LSF, 367 CT_GSM 368 }; 369 enum mixart_sample_type { 370 ST_NOT_DEFINED, 371 ST_FLOATING_POINT_32BE, 372 ST_FLOATING_POINT_32LE, 373 ST_FLOATING_POINT_64BE, 374 ST_FLOATING_POINT_64LE, 375 ST_FIXED_POINT_8, 376 ST_FIXED_POINT_16BE, 377 ST_FIXED_POINT_16LE, 378 ST_FIXED_POINT_24BE, 379 ST_FIXED_POINT_24LE, 380 ST_FIXED_POINT_32BE, 381 ST_FIXED_POINT_32LE, 382 ST_INTEGER_8, 383 ST_INTEGER_16BE, 384 ST_INTEGER_16LE, 385 ST_INTEGER_24BE, 386 ST_INTEGER_24LE, 387 ST_INTEGER_32BE, 388 ST_INTEGER_32LE 389 }; 390 391 typedef struct mixart_stream_param_desc mixart_stream_param_desc_t; 392 struct mixart_stream_param_desc 393 { 394 u32 coding_type; /* use enum mixart_coding_type */ 395 u32 sample_type; /* use enum mixart_sample_type */ 396 397 union { 398 struct { 399 u32 linear_endian_ness; 400 u32 linear_bits; 401 u32 is_signed; 402 u32 is_float; 403 } linear_format_info; 404 405 struct { 406 u32 mpeg_layer; 407 u32 mpeg_mode; 408 u32 mpeg_mode_extension; 409 u32 mpeg_pre_emphasis; 410 u32 mpeg_has_padding_bit; 411 u32 mpeg_has_crc; 412 u32 mpeg_has_extension; 413 u32 mpeg_is_original; 414 u32 mpeg_has_copyright; 415 } mpeg_format_info; 416 } format_info; 417 418 u32 delayed; 419 u64 scheduler; 420 u32 sample_size; 421 u32 has_header; 422 u32 has_suffix; 423 u32 has_bitrate; 424 u32 samples_per_frame; 425 u32 bytes_per_frame; 426 u32 bytes_per_sample; 427 u32 sampling_freq; 428 u32 number_of_channel; 429 u32 stream_number; 430 u32 buffer_size; 431 u32 differed_time; 432 u32 reserved4np[3]; 433 u32 pipe_count; /* set to 1 (array size !) */ 434 u32 stream_count; /* set to 1 (array size !) */ 435 mixart_txx_stream_desc_t stream_desc[1]; /* only one stream per command, but this could be an array */ 436 437 } __attribute__((packed)); 438 439 440 /* MSG_CONNECTOR_GET_OUT_AUDIO_LEVEL = 0x050009, 441 */ 442 443 444 typedef struct mixart_get_out_audio_level mixart_get_out_audio_level_t; 445 struct mixart_get_out_audio_level 446 { 447 u32 txx_status; 448 u32 digital_level; /* float */ 449 u32 analog_level; /* float */ 450 u32 monitor_level; /* float */ 451 u32 mute; 452 u32 monitor_mute1; 453 u32 monitor_mute2; 454 } __attribute__((packed)); 455 456 457 /* MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL = 0x05000A, 458 */ 459 460 /* used for valid_mask below */ 461 #define MIXART_AUDIO_LEVEL_ANALOG_MASK 0x01 462 #define MIXART_AUDIO_LEVEL_DIGITAL_MASK 0x02 463 #define MIXART_AUDIO_LEVEL_MONITOR_MASK 0x04 464 #define MIXART_AUDIO_LEVEL_MUTE_MASK 0x08 465 #define MIXART_AUDIO_LEVEL_MUTE_M1_MASK 0x10 466 #define MIXART_AUDIO_LEVEL_MUTE_M2_MASK 0x20 467 468 typedef struct mixart_set_out_audio_level mixart_set_out_audio_level_t; 469 struct mixart_set_out_audio_level 470 { 471 u32 delayed; 472 u64 scheduler; 473 u32 valid_mask1; 474 u32 valid_mask2; 475 u32 digital_level; /* float */ 476 u32 analog_level; /* float */ 477 u32 monitor_level; /* float */ 478 u32 mute; 479 u32 monitor_mute1; 480 u32 monitor_mute2; 481 u32 reserved4np; 482 } __attribute__((packed)); 483 484 485 /* MSG_SYSTEM_ENUM_PHYSICAL_IO = 0x16000E, 486 */ 487 488 #define MIXART_MAX_PHYS_IO (MIXART_MAX_CARDS * 2 * 2) /* 4 * (analog+digital) * (playback+capture) */ 489 490 typedef struct mixart_uid_enumeration mixart_uid_enumeration_t; 491 struct mixart_uid_enumeration 492 { 493 u32 error_code; 494 u32 first_uid_offset; 495 u32 nb_uid; 496 u32 current_uid_index; 497 mixart_uid_t uid[MIXART_MAX_PHYS_IO]; 498 } __attribute__((packed)); 499 500 501 /* MSG_PHYSICALIO_SET_LEVEL = 0x0F0008, 502 MSG_PHYSICALIO_GET_LEVEL = 0x0F000C, 503 */ 504 505 typedef struct mixart_io_channel_level mixart_io_channel_level_t; 506 struct mixart_io_channel_level 507 { 508 u32 analog_level; /* float */ 509 u32 unused[2]; 510 } __attribute__((packed)); 511 512 typedef struct mixart_io_level mixart_io_level_t; 513 struct mixart_io_level 514 { 515 s32 channel; /* 0=left, 1=right, -1=both, -2=both same */ 516 mixart_io_channel_level_t level[2]; 517 } __attribute__((packed)); 518 519 520 /* MSG_STREAM_SET_IN_AUDIO_LEVEL = 0x130015, 521 */ 522 523 typedef struct mixart_in_audio_level_info mixart_in_audio_level_info_t; 524 struct mixart_in_audio_level_info 525 { 526 mixart_uid_t connector; 527 u32 valid_mask1; 528 u32 valid_mask2; 529 u32 digital_level; 530 u32 analog_level; 531 } __attribute__((packed)); 532 533 typedef struct mixart_set_in_audio_level_req mixart_set_in_audio_level_req_t; 534 struct mixart_set_in_audio_level_req 535 { 536 u32 delayed; 537 u64 scheduler; 538 u32 audio_count; /* set to <= 2 */ 539 u32 reserved4np; 540 mixart_in_audio_level_info_t level[2]; 541 } __attribute__((packed)); 542 543 /* response is a 32 bit status */ 544 545 546 /* MSG_STREAM_SET_OUT_STREAM_LEVEL = 0x130017, 547 */ 548 549 /* defines used for valid_mask1 */ 550 #define MIXART_OUT_STREAM_SET_LEVEL_LEFT_AUDIO1 0x01 551 #define MIXART_OUT_STREAM_SET_LEVEL_LEFT_AUDIO2 0x02 552 #define MIXART_OUT_STREAM_SET_LEVEL_RIGHT_AUDIO1 0x04 553 #define MIXART_OUT_STREAM_SET_LEVEL_RIGHT_AUDIO2 0x08 554 #define MIXART_OUT_STREAM_SET_LEVEL_STREAM_1 0x10 555 #define MIXART_OUT_STREAM_SET_LEVEL_STREAM_2 0x20 556 #define MIXART_OUT_STREAM_SET_LEVEL_MUTE_1 0x40 557 #define MIXART_OUT_STREAM_SET_LEVEL_MUTE_2 0x80 558 559 typedef struct mixart_out_stream_level_info mixart_out_stream_level_info_t; 560 struct mixart_out_stream_level_info 561 { 562 u32 valid_mask1; 563 u32 valid_mask2; 564 u32 left_to_out1_level; 565 u32 left_to_out2_level; 566 u32 right_to_out1_level; 567 u32 right_to_out2_level; 568 u32 digital_level1; 569 u32 digital_level2; 570 u32 mute1; 571 u32 mute2; 572 } __attribute__((packed)); 573 574 typedef struct mixart_set_out_stream_level mixart_set_out_stream_level_t; 575 struct mixart_set_out_stream_level 576 { 577 mixart_txx_stream_desc_t desc; 578 mixart_out_stream_level_info_t out_level; 579 } __attribute__((packed)); 580 581 typedef struct mixart_set_out_stream_level_req mixart_set_out_stream_level_req_t; 582 struct mixart_set_out_stream_level_req 583 { 584 u32 delayed; 585 u64 scheduler; 586 u32 reserved4np[2]; 587 u32 nb_of_stream; /* set to 1 */ 588 mixart_set_out_stream_level_t stream_level; /* could be an array */ 589 } __attribute__((packed)); 590 591 /* response to this request is a u32 status value */ 592 593 594 /* exported */ 595 void snd_mixart_init_mailbox(mixart_mgr_t *mgr); 596 void snd_mixart_exit_mailbox(mixart_mgr_t *mgr); 597 598 int snd_mixart_send_msg(mixart_mgr_t *mgr, mixart_msg_t *request, int max_resp_size, void *resp_data); 599 int snd_mixart_send_msg_wait_notif(mixart_mgr_t *mgr, mixart_msg_t *request, u32 notif_event); 600 int snd_mixart_send_msg_nonblock(mixart_mgr_t *mgr, mixart_msg_t *request); 601 602 irqreturn_t snd_mixart_interrupt(int irq, void *dev_id, struct pt_regs *regs); 603 void snd_mixart_msg_tasklet( unsigned long arg); 604 605 void snd_mixart_reset_board(mixart_mgr_t *mgr); 606 607 #endif /* __SOUND_MIXART_CORE_H */ 608