Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Driver for Digigram miXart soundcards
0004  *
0005  * low level interface with interrupt handling and mail box implementation
0006  *
0007  * Copyright (c) 2003 by Digigram <alsa@digigram.com>
0008  */
0009 
0010 #ifndef __SOUND_MIXART_CORE_H
0011 #define __SOUND_MIXART_CORE_H
0012 
0013 
0014 enum mixart_message_id {
0015     MSG_CONNECTOR_GET_AUDIO_INFO         = 0x050008,
0016     MSG_CONNECTOR_GET_OUT_AUDIO_LEVEL    = 0x050009,
0017     MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL    = 0x05000A,
0018 
0019     MSG_CONSOLE_MANAGER                  = 0x070000,
0020     MSG_CONSOLE_GET_CLOCK_UID            = 0x070003,
0021 
0022     MSG_PHYSICALIO_SET_LEVEL             = 0x0F0008,
0023 
0024     MSG_STREAM_ADD_INPUT_GROUP           = 0x130000,
0025     MSG_STREAM_ADD_OUTPUT_GROUP          = 0x130001,
0026     MSG_STREAM_DELETE_GROUP              = 0x130004,
0027     MSG_STREAM_START_STREAM_GRP_PACKET   = 0x130006,
0028     MSG_STREAM_START_INPUT_STAGE_PACKET  = 0x130007,
0029     MSG_STREAM_START_OUTPUT_STAGE_PACKET = 0x130008,
0030     MSG_STREAM_STOP_STREAM_GRP_PACKET    = 0x130009,
0031     MSG_STREAM_STOP_INPUT_STAGE_PACKET   = 0x13000A,
0032     MSG_STREAM_STOP_OUTPUT_STAGE_PACKET  = 0x13000B,
0033     MSG_STREAM_SET_INPUT_STAGE_PARAM     = 0x13000F,
0034     MSG_STREAM_SET_OUTPUT_STAGE_PARAM    = 0x130010,
0035     MSG_STREAM_SET_IN_AUDIO_LEVEL        = 0x130015,
0036     MSG_STREAM_SET_OUT_STREAM_LEVEL      = 0x130017,
0037 
0038     MSG_SYSTEM_FIRST_ID                  = 0x160000,
0039     MSG_SYSTEM_ENUM_PHYSICAL_IO          = 0x16000E,
0040     MSG_SYSTEM_ENUM_PLAY_CONNECTOR       = 0x160017,
0041     MSG_SYSTEM_ENUM_RECORD_CONNECTOR     = 0x160018,
0042     MSG_SYSTEM_WAIT_SYNCHRO_CMD          = 0x16002C,
0043     MSG_SYSTEM_SEND_SYNCHRO_CMD          = 0x16002D,
0044 
0045     MSG_SERVICES_TIMER_NOTIFY            = 0x1D0404,
0046     MSG_SERVICES_REPORT_TRACES           = 0x1D0700,
0047 
0048     MSG_CLOCK_CHECK_PROPERTIES           = 0x200001,
0049     MSG_CLOCK_SET_PROPERTIES             = 0x200002,
0050 };
0051 
0052 #define MSG_DEFAULT_SIZE            512
0053 
0054 struct mixart_msg
0055 {
0056     u32          message_id;
0057     struct mixart_uid uid;
0058     void*        data;
0059     size_t       size;
0060 };
0061 
0062 /* structs used to communicate with miXart */
0063 
0064 struct mixart_enum_connector_resp
0065 {
0066     u32  error_code;
0067     u32  first_uid_offset;
0068     u32  uid_count;
0069     u32  current_uid_index;
0070     struct mixart_uid uid[MIXART_MAX_PHYS_CONNECTORS];
0071 } __attribute__((packed));
0072 
0073 
0074 /* used for following struct */
0075 #define MIXART_FLOAT_P_22_0_TO_HEX      0x41b00000  /* 22.0f */
0076 #define MIXART_FLOAT_M_20_0_TO_HEX      0xc1a00000  /* -20.0f */
0077 #define MIXART_FLOAT____0_0_TO_HEX      0x00000000  /* 0.0f */
0078 
0079 struct mixart_audio_info_req
0080 {
0081     u32 line_max_level;    /* float */
0082     u32 micro_max_level;   /* float */
0083     u32 cd_max_level;      /* float */
0084 } __attribute__((packed));
0085 
0086 struct mixart_analog_hw_info
0087 {
0088     u32 is_present;
0089     u32 hw_connection_type;
0090     u32 max_level;         /* float */
0091     u32 min_var_level;     /* float */
0092     u32 max_var_level;     /* float */
0093     u32 step_var_level;    /* float */
0094     u32 fix_gain;          /* float */
0095     u32 zero_var;          /* float */
0096 } __attribute__((packed));
0097 
0098 struct mixart_digital_hw_info
0099 {
0100     u32   hw_connection_type;
0101     u32   presence;
0102     u32   clock;
0103     u32   reserved;
0104 } __attribute__((packed));
0105 
0106 struct mixart_analog_info
0107 {
0108     u32                     type_mask;
0109     struct mixart_analog_hw_info micro_info;
0110     struct mixart_analog_hw_info line_info;
0111     struct mixart_analog_hw_info cd_info;
0112     u32                     analog_level_present;
0113 } __attribute__((packed));
0114 
0115 struct mixart_digital_info
0116 {
0117     u32 type_mask;
0118     struct mixart_digital_hw_info aes_info;
0119     struct mixart_digital_hw_info adat_info;
0120 } __attribute__((packed));
0121 
0122 struct mixart_audio_info
0123 {
0124     u32                   clock_type_mask;
0125     struct mixart_analog_info  analog_info;
0126     struct mixart_digital_info digital_info;
0127 } __attribute__((packed));
0128 
0129 struct mixart_audio_info_resp
0130 {
0131     u32                 txx_status;
0132     struct mixart_audio_info info;
0133 } __attribute__((packed));
0134 
0135 
0136 /* used for nb_bytes_max_per_sample */
0137 #define MIXART_FLOAT_P__4_0_TO_HEX      0x40800000  /* +4.0f */
0138 #define MIXART_FLOAT_P__8_0_TO_HEX      0x41000000  /* +8.0f */
0139 
0140 struct mixart_stream_info
0141 {
0142     u32 size_max_byte_frame;
0143     u32 size_max_sample_frame;
0144     u32 nb_bytes_max_per_sample;  /* float */
0145 } __attribute__((packed));
0146 
0147 /*  MSG_STREAM_ADD_INPUT_GROUP */
0148 /*  MSG_STREAM_ADD_OUTPUT_GROUP */
0149 
0150 struct mixart_streaming_group_req
0151 {
0152     u32 stream_count;
0153     u32 channel_count;
0154     u32 user_grp_number;
0155     u32 first_phys_audio;
0156     u32 latency;
0157     struct mixart_stream_info stream_info[32];
0158     struct mixart_uid connector;
0159     u32 flow_entry[32];
0160 } __attribute__((packed));
0161 
0162 struct mixart_stream_desc
0163 {
0164     struct mixart_uid stream_uid;
0165     u32          stream_desc;
0166 } __attribute__((packed));
0167 
0168 struct mixart_streaming_group
0169 {
0170     u32                  status;
0171     struct mixart_uid    group;
0172     u32                  pipe_desc;
0173     u32                  stream_count;
0174     struct mixart_stream_desc stream[32];
0175 } __attribute__((packed));
0176 
0177 /* MSG_STREAM_DELETE_GROUP */
0178 
0179 /* request : mixart_uid_t group */
0180 
0181 struct mixart_delete_group_resp
0182 {
0183     u32  status;
0184     u32  unused[2];
0185 } __attribute__((packed));
0186 
0187 
0188 /*  MSG_STREAM_START_INPUT_STAGE_PACKET  = 0x130000 + 7,
0189     MSG_STREAM_START_OUTPUT_STAGE_PACKET = 0x130000 + 8,
0190     MSG_STREAM_STOP_INPUT_STAGE_PACKET   = 0x130000 + 10,
0191     MSG_STREAM_STOP_OUTPUT_STAGE_PACKET  = 0x130000 + 11,
0192  */
0193 
0194 struct mixart_fx_couple_uid
0195 {
0196     struct mixart_uid uid_fx_code;
0197     struct mixart_uid uid_fx_data;
0198 } __attribute__((packed));
0199 
0200 struct mixart_txx_stream_desc
0201 {
0202     struct mixart_uid       uid_pipe;
0203     u32                     stream_idx;
0204     u32                     fx_number;
0205     struct mixart_fx_couple_uid  uid_fx[4];
0206 } __attribute__((packed));
0207 
0208 struct mixart_flow_info
0209 {
0210     struct mixart_txx_stream_desc  stream_desc;
0211     u32                       flow_entry;
0212     u32                       flow_phy_addr;
0213 } __attribute__((packed));
0214 
0215 struct mixart_stream_state_req
0216 {
0217     u32                 delayed;
0218     u64                 scheduler;
0219     u32                 reserved4np[3];
0220     u32                 stream_count;  /* set to 1 for instance */
0221     struct mixart_flow_info  stream_info;   /* could be an array[stream_count] */
0222 } __attribute__((packed));
0223 
0224 /*  MSG_STREAM_START_STREAM_GRP_PACKET   = 0x130000 + 6
0225     MSG_STREAM_STOP_STREAM_GRP_PACKET    = 0x130000 + 9
0226  */
0227 
0228 struct mixart_group_state_req
0229 {
0230     u32           delayed;
0231     u64           scheduler;
0232     u32           reserved4np[2];
0233     u32           pipe_count;    /* set to 1 for instance */
0234     struct mixart_uid  pipe_uid[1];   /* could be an array[pipe_count] */
0235 } __attribute__((packed));
0236 
0237 struct mixart_group_state_resp
0238 {
0239     u32           txx_status;
0240     u64           scheduler;
0241 } __attribute__((packed));
0242 
0243 
0244 
0245 /* Structures used by the MSG_SERVICES_TIMER_NOTIFY command */
0246 
0247 struct mixart_sample_pos
0248 {
0249     u32   buffer_id;
0250     u32   validity;
0251     u32   sample_pos_high_part;
0252     u32   sample_pos_low_part;
0253 } __attribute__((packed));
0254 
0255 /*
0256  * This structure is limited by the size of MSG_DEFAULT_SIZE. Instead of
0257  * having MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS many streams,
0258  * this is capped to have a total size below MSG_DEFAULT_SIZE.
0259  */
0260 #define MIXART_MAX_TIMER_NOTIFY_STREAMS             \
0261     ((MSG_DEFAULT_SIZE - sizeof(u32)) / sizeof(struct mixart_sample_pos))
0262 struct mixart_timer_notify
0263 {
0264     u32                  stream_count;
0265     struct mixart_sample_pos  streams[MIXART_MAX_TIMER_NOTIFY_STREAMS];
0266 } __attribute__((packed));
0267 
0268 
0269 /*  MSG_CONSOLE_GET_CLOCK_UID            = 0x070003,
0270  */
0271 
0272 /* request is a uid with desc = MSG_CONSOLE_MANAGER | cardindex */
0273 
0274 struct mixart_return_uid
0275 {
0276     u32 error_code;
0277     struct mixart_uid uid;
0278 } __attribute__((packed));
0279 
0280 /*  MSG_CLOCK_CHECK_PROPERTIES           = 0x200001,
0281     MSG_CLOCK_SET_PROPERTIES             = 0x200002,
0282 */
0283 
0284 enum mixart_clock_generic_type {
0285     CGT_NO_CLOCK,
0286     CGT_INTERNAL_CLOCK,
0287     CGT_PROGRAMMABLE_CLOCK,
0288     CGT_INTERNAL_ENSLAVED_CLOCK,
0289     CGT_EXTERNAL_CLOCK,
0290     CGT_CURRENT_CLOCK
0291 };
0292 
0293 enum mixart_clock_mode {
0294     CM_UNDEFINED,
0295     CM_MASTER,
0296     CM_SLAVE,
0297     CM_STANDALONE,
0298     CM_NOT_CONCERNED
0299 };
0300 
0301 
0302 struct mixart_clock_properties
0303 {
0304     u32 error_code;
0305     u32 validation_mask;
0306     u32 frequency;
0307     u32 reference_frequency;
0308     u32 clock_generic_type;
0309     u32 clock_mode;
0310     struct mixart_uid uid_clock_source;
0311     struct mixart_uid uid_event_source;
0312     u32 event_mode;
0313     u32 synchro_signal_presence;
0314     u32 format;
0315     u32 board_mask;
0316     u32 nb_callers; /* set to 1 (see below) */
0317     struct mixart_uid uid_caller[1];
0318 } __attribute__((packed));
0319 
0320 struct mixart_clock_properties_resp
0321 {
0322     u32 status;
0323     u32 clock_mode;
0324 } __attribute__((packed));
0325 
0326 
0327 /*  MSG_STREAM_SET_INPUT_STAGE_PARAM     = 0x13000F */
0328 /*  MSG_STREAM_SET_OUTPUT_STAGE_PARAM    = 0x130010 */
0329 
0330 enum mixart_coding_type {
0331     CT_NOT_DEFINED,
0332     CT_LINEAR,
0333     CT_MPEG_L1,
0334     CT_MPEG_L2,
0335     CT_MPEG_L3,
0336     CT_MPEG_L3_LSF,
0337     CT_GSM
0338 };
0339 enum mixart_sample_type {
0340     ST_NOT_DEFINED,
0341     ST_FLOATING_POINT_32BE,
0342     ST_FLOATING_POINT_32LE,
0343     ST_FLOATING_POINT_64BE,
0344     ST_FLOATING_POINT_64LE,
0345     ST_FIXED_POINT_8,
0346     ST_FIXED_POINT_16BE,
0347     ST_FIXED_POINT_16LE,
0348     ST_FIXED_POINT_24BE,
0349     ST_FIXED_POINT_24LE,
0350     ST_FIXED_POINT_32BE,
0351     ST_FIXED_POINT_32LE,
0352     ST_INTEGER_8,
0353     ST_INTEGER_16BE,
0354     ST_INTEGER_16LE,
0355     ST_INTEGER_24BE,
0356     ST_INTEGER_24LE,
0357     ST_INTEGER_32BE,
0358     ST_INTEGER_32LE
0359 };
0360 
0361 struct mixart_stream_param_desc
0362 {
0363     u32 coding_type;  /* use enum mixart_coding_type */
0364     u32 sample_type;  /* use enum mixart_sample_type */
0365 
0366     union {
0367         struct {
0368             u32 linear_endian_ness;
0369             u32 linear_bits;
0370             u32 is_signed;
0371             u32 is_float;
0372         } linear_format_info;
0373 
0374         struct {
0375             u32 mpeg_layer;
0376             u32 mpeg_mode;
0377             u32 mpeg_mode_extension;
0378             u32 mpeg_pre_emphasis;
0379             u32 mpeg_has_padding_bit;
0380             u32 mpeg_has_crc;
0381             u32 mpeg_has_extension;
0382             u32 mpeg_is_original;
0383             u32 mpeg_has_copyright;
0384         } mpeg_format_info;
0385     } format_info;
0386 
0387     u32 delayed;
0388     u64 scheduler;
0389     u32 sample_size;
0390     u32 has_header;
0391     u32 has_suffix;
0392     u32 has_bitrate;
0393     u32 samples_per_frame;
0394     u32 bytes_per_frame;
0395     u32 bytes_per_sample;
0396     u32 sampling_freq;
0397     u32 number_of_channel;
0398     u32 stream_number;
0399     u32 buffer_size;
0400     u32 differed_time;
0401     u32 reserved4np[3];
0402     u32 pipe_count;                           /* set to 1 (array size !) */
0403     u32 stream_count;                         /* set to 1 (array size !) */
0404     struct mixart_txx_stream_desc stream_desc[1];  /* only one stream per command, but this could be an array */
0405 
0406 } __attribute__((packed));
0407 
0408 
0409 /*  MSG_CONNECTOR_GET_OUT_AUDIO_LEVEL    = 0x050009,
0410  */
0411 
0412 
0413 struct mixart_get_out_audio_level
0414 {
0415     u32 txx_status;
0416     u32 digital_level;   /* float */
0417     u32 analog_level;    /* float */
0418     u32 monitor_level;   /* float */
0419     u32 mute;
0420     u32 monitor_mute1;
0421     u32 monitor_mute2;
0422 } __attribute__((packed));
0423 
0424 
0425 /*  MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL    = 0x05000A,
0426  */
0427 
0428 /* used for valid_mask below */
0429 #define MIXART_AUDIO_LEVEL_ANALOG_MASK  0x01
0430 #define MIXART_AUDIO_LEVEL_DIGITAL_MASK 0x02
0431 #define MIXART_AUDIO_LEVEL_MONITOR_MASK 0x04
0432 #define MIXART_AUDIO_LEVEL_MUTE_MASK    0x08
0433 #define MIXART_AUDIO_LEVEL_MUTE_M1_MASK 0x10
0434 #define MIXART_AUDIO_LEVEL_MUTE_M2_MASK 0x20
0435 
0436 struct mixart_set_out_audio_level
0437 {
0438     u32 delayed;
0439     u64 scheduler;
0440     u32 valid_mask1;
0441     u32 valid_mask2;
0442     u32 digital_level;   /* float */
0443     u32 analog_level;    /* float */
0444     u32 monitor_level;   /* float */
0445     u32 mute;
0446     u32 monitor_mute1;
0447     u32 monitor_mute2;
0448     u32 reserved4np;
0449 } __attribute__((packed));
0450 
0451 
0452 /*  MSG_SYSTEM_ENUM_PHYSICAL_IO          = 0x16000E,
0453  */
0454 
0455 #define MIXART_MAX_PHYS_IO  (MIXART_MAX_CARDS * 2 * 2) /* 4 * (analog+digital) * (playback+capture) */
0456 
0457 struct mixart_uid_enumeration
0458 {
0459     u32 error_code;
0460     u32 first_uid_offset;
0461     u32 nb_uid;
0462     u32 current_uid_index;
0463     struct mixart_uid uid[MIXART_MAX_PHYS_IO];
0464 } __attribute__((packed));
0465 
0466 
0467 /*  MSG_PHYSICALIO_SET_LEVEL             = 0x0F0008,
0468     MSG_PHYSICALIO_GET_LEVEL             = 0x0F000C,
0469 */
0470 
0471 struct mixart_io_channel_level
0472 {
0473     u32 analog_level;   /* float */
0474     u32 unused[2];
0475 } __attribute__((packed));
0476 
0477 struct mixart_io_level
0478 {
0479     s32 channel; /* 0=left, 1=right, -1=both, -2=both same */
0480     struct mixart_io_channel_level level[2];
0481 } __attribute__((packed));
0482 
0483 
0484 /*  MSG_STREAM_SET_IN_AUDIO_LEVEL        = 0x130015,
0485  */
0486 
0487 struct mixart_in_audio_level_info
0488 {
0489     struct mixart_uid connector;
0490     u32 valid_mask1;
0491     u32 valid_mask2;
0492     u32 digital_level;
0493     u32 analog_level;
0494 } __attribute__((packed));
0495 
0496 struct mixart_set_in_audio_level_req
0497 {
0498     u32 delayed;
0499     u64 scheduler;
0500     u32 audio_count;  /* set to <= 2 */
0501     u32 reserved4np;
0502     struct mixart_in_audio_level_info level[2];
0503 } __attribute__((packed));
0504 
0505 /* response is a 32 bit status */
0506 
0507 
0508 /*  MSG_STREAM_SET_OUT_STREAM_LEVEL      = 0x130017,
0509  */
0510 
0511 /* defines used for valid_mask1 */
0512 #define MIXART_OUT_STREAM_SET_LEVEL_LEFT_AUDIO1     0x01
0513 #define MIXART_OUT_STREAM_SET_LEVEL_LEFT_AUDIO2     0x02
0514 #define MIXART_OUT_STREAM_SET_LEVEL_RIGHT_AUDIO1    0x04
0515 #define MIXART_OUT_STREAM_SET_LEVEL_RIGHT_AUDIO2    0x08
0516 #define MIXART_OUT_STREAM_SET_LEVEL_STREAM_1        0x10
0517 #define MIXART_OUT_STREAM_SET_LEVEL_STREAM_2        0x20
0518 #define MIXART_OUT_STREAM_SET_LEVEL_MUTE_1      0x40
0519 #define MIXART_OUT_STREAM_SET_LEVEL_MUTE_2      0x80
0520 
0521 struct mixart_out_stream_level_info
0522 {
0523     u32 valid_mask1;
0524     u32 valid_mask2;
0525     u32 left_to_out1_level;
0526     u32 left_to_out2_level;
0527     u32 right_to_out1_level;
0528     u32 right_to_out2_level;
0529     u32 digital_level1;
0530     u32 digital_level2;
0531     u32 mute1;
0532     u32 mute2;
0533 } __attribute__((packed));
0534 
0535 struct mixart_set_out_stream_level
0536 {
0537     struct mixart_txx_stream_desc desc;
0538     struct mixart_out_stream_level_info out_level;
0539 } __attribute__((packed));
0540 
0541 struct mixart_set_out_stream_level_req
0542 {
0543     u32 delayed;
0544     u64 scheduler;
0545     u32 reserved4np[2];
0546     u32 nb_of_stream;  /* set to 1 */
0547     struct mixart_set_out_stream_level stream_level; /* could be an array */
0548 } __attribute__((packed));
0549 
0550 /* response to this request is a u32 status value */
0551 
0552 
0553 /* exported */
0554 void snd_mixart_init_mailbox(struct mixart_mgr *mgr);
0555 void snd_mixart_exit_mailbox(struct mixart_mgr *mgr);
0556 
0557 int  snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int max_resp_size, void *resp_data);
0558 int  snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr, struct mixart_msg *request, u32 notif_event);
0559 int  snd_mixart_send_msg_nonblock(struct mixart_mgr *mgr, struct mixart_msg *request);
0560 
0561 irqreturn_t snd_mixart_interrupt(int irq, void *dev_id);
0562 irqreturn_t snd_mixart_threaded_irq(int irq, void *dev_id);
0563 
0564 void snd_mixart_reset_board(struct mixart_mgr *mgr);
0565 
0566 #endif /* __SOUND_MIXART_CORE_H */