mixart_core.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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. #ifndef __SOUND_MIXART_CORE_H
  23. #define __SOUND_MIXART_CORE_H
  24. enum mixart_message_id {
  25. MSG_CONNECTOR_GET_AUDIO_INFO = 0x050008,
  26. MSG_CONNECTOR_GET_OUT_AUDIO_LEVEL = 0x050009,
  27. MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL = 0x05000A,
  28. MSG_CONSOLE_MANAGER = 0x070000,
  29. MSG_CONSOLE_GET_CLOCK_UID = 0x070003,
  30. MSG_PHYSICALIO_SET_LEVEL = 0x0F0008,
  31. MSG_STREAM_ADD_INPUT_GROUP = 0x130000,
  32. MSG_STREAM_ADD_OUTPUT_GROUP = 0x130001,
  33. MSG_STREAM_DELETE_GROUP = 0x130004,
  34. MSG_STREAM_START_STREAM_GRP_PACKET = 0x130006,
  35. MSG_STREAM_START_INPUT_STAGE_PACKET = 0x130007,
  36. MSG_STREAM_START_OUTPUT_STAGE_PACKET = 0x130008,
  37. MSG_STREAM_STOP_STREAM_GRP_PACKET = 0x130009,
  38. MSG_STREAM_STOP_INPUT_STAGE_PACKET = 0x13000A,
  39. MSG_STREAM_STOP_OUTPUT_STAGE_PACKET = 0x13000B,
  40. MSG_STREAM_SET_INPUT_STAGE_PARAM = 0x13000F,
  41. MSG_STREAM_SET_OUTPUT_STAGE_PARAM = 0x130010,
  42. MSG_STREAM_SET_IN_AUDIO_LEVEL = 0x130015,
  43. MSG_STREAM_SET_OUT_STREAM_LEVEL = 0x130017,
  44. MSG_SYSTEM_FIRST_ID = 0x160000,
  45. MSG_SYSTEM_ENUM_PHYSICAL_IO = 0x16000E,
  46. MSG_SYSTEM_ENUM_PLAY_CONNECTOR = 0x160017,
  47. MSG_SYSTEM_ENUM_RECORD_CONNECTOR = 0x160018,
  48. MSG_SYSTEM_WAIT_SYNCHRO_CMD = 0x16002C,
  49. MSG_SYSTEM_SEND_SYNCHRO_CMD = 0x16002D,
  50. MSG_SERVICES_TIMER_NOTIFY = 0x1D0404,
  51. MSG_SERVICES_REPORT_TRACES = 0x1D0700,
  52. MSG_CLOCK_CHECK_PROPERTIES = 0x200001,
  53. MSG_CLOCK_SET_PROPERTIES = 0x200002,
  54. };
  55. struct mixart_msg
  56. {
  57. u32 message_id;
  58. struct mixart_uid uid;
  59. void* data;
  60. size_t size;
  61. };
  62. /* structs used to communicate with miXart */
  63. struct mixart_enum_connector_resp
  64. {
  65. u32 error_code;
  66. u32 first_uid_offset;
  67. u32 uid_count;
  68. u32 current_uid_index;
  69. struct mixart_uid uid[MIXART_MAX_PHYS_CONNECTORS];
  70. } __attribute__((packed));
  71. /* used for following struct */
  72. #define MIXART_FLOAT_P_22_0_TO_HEX 0x41b00000 /* 22.0f */
  73. #define MIXART_FLOAT_M_20_0_TO_HEX 0xc1a00000 /* -20.0f */
  74. #define MIXART_FLOAT____0_0_TO_HEX 0x00000000 /* 0.0f */
  75. struct mixart_audio_info_req
  76. {
  77. u32 line_max_level; /* float */
  78. u32 micro_max_level; /* float */
  79. u32 cd_max_level; /* float */
  80. } __attribute__((packed));
  81. struct mixart_analog_hw_info
  82. {
  83. u32 is_present;
  84. u32 hw_connection_type;
  85. u32 max_level; /* float */
  86. u32 min_var_level; /* float */
  87. u32 max_var_level; /* float */
  88. u32 step_var_level; /* float */
  89. u32 fix_gain; /* float */
  90. u32 zero_var; /* float */
  91. } __attribute__((packed));
  92. struct mixart_digital_hw_info
  93. {
  94. u32 hw_connection_type;
  95. u32 presence;
  96. u32 clock;
  97. u32 reserved;
  98. } __attribute__((packed));
  99. struct mixart_analog_info
  100. {
  101. u32 type_mask;
  102. struct mixart_analog_hw_info micro_info;
  103. struct mixart_analog_hw_info line_info;
  104. struct mixart_analog_hw_info cd_info;
  105. u32 analog_level_present;
  106. } __attribute__((packed));
  107. struct mixart_digital_info
  108. {
  109. u32 type_mask;
  110. struct mixart_digital_hw_info aes_info;
  111. struct mixart_digital_hw_info adat_info;
  112. } __attribute__((packed));
  113. struct mixart_audio_info
  114. {
  115. u32 clock_type_mask;
  116. struct mixart_analog_info analog_info;
  117. struct mixart_digital_info digital_info;
  118. } __attribute__((packed));
  119. struct mixart_audio_info_resp
  120. {
  121. u32 txx_status;
  122. struct mixart_audio_info info;
  123. } __attribute__((packed));
  124. /* used for nb_bytes_max_per_sample */
  125. #define MIXART_FLOAT_P__4_0_TO_HEX 0x40800000 /* +4.0f */
  126. #define MIXART_FLOAT_P__8_0_TO_HEX 0x41000000 /* +8.0f */
  127. struct mixart_stream_info
  128. {
  129. u32 size_max_byte_frame;
  130. u32 size_max_sample_frame;
  131. u32 nb_bytes_max_per_sample; /* float */
  132. } __attribute__((packed));
  133. /* MSG_STREAM_ADD_INPUT_GROUP */
  134. /* MSG_STREAM_ADD_OUTPUT_GROUP */
  135. struct mixart_streaming_group_req
  136. {
  137. u32 stream_count;
  138. u32 channel_count;
  139. u32 user_grp_number;
  140. u32 first_phys_audio;
  141. u32 latency;
  142. struct mixart_stream_info stream_info[32];
  143. struct mixart_uid connector;
  144. u32 flow_entry[32];
  145. } __attribute__((packed));
  146. struct mixart_stream_desc
  147. {
  148. struct mixart_uid stream_uid;
  149. u32 stream_desc;
  150. } __attribute__((packed));
  151. struct mixart_streaming_group
  152. {
  153. u32 status;
  154. struct mixart_uid group;
  155. u32 pipe_desc;
  156. u32 stream_count;
  157. struct mixart_stream_desc stream[32];
  158. } __attribute__((packed));
  159. /* MSG_STREAM_DELETE_GROUP */
  160. /* request : mixart_uid_t group */
  161. struct mixart_delete_group_resp
  162. {
  163. u32 status;
  164. u32 unused[2];
  165. } __attribute__((packed));
  166. /* MSG_STREAM_START_INPUT_STAGE_PACKET = 0x130000 + 7,
  167. MSG_STREAM_START_OUTPUT_STAGE_PACKET = 0x130000 + 8,
  168. MSG_STREAM_STOP_INPUT_STAGE_PACKET = 0x130000 + 10,
  169. MSG_STREAM_STOP_OUTPUT_STAGE_PACKET = 0x130000 + 11,
  170. */
  171. struct mixart_fx_couple_uid
  172. {
  173. struct mixart_uid uid_fx_code;
  174. struct mixart_uid uid_fx_data;
  175. } __attribute__((packed));
  176. struct mixart_txx_stream_desc
  177. {
  178. struct mixart_uid uid_pipe;
  179. u32 stream_idx;
  180. u32 fx_number;
  181. struct mixart_fx_couple_uid uid_fx[4];
  182. } __attribute__((packed));
  183. struct mixart_flow_info
  184. {
  185. struct mixart_txx_stream_desc stream_desc;
  186. u32 flow_entry;
  187. u32 flow_phy_addr;
  188. } __attribute__((packed));
  189. struct mixart_stream_state_req
  190. {
  191. u32 delayed;
  192. u64 scheduler;
  193. u32 reserved4np[3];
  194. u32 stream_count; /* set to 1 for instance */
  195. struct mixart_flow_info stream_info; /* could be an array[stream_count] */
  196. } __attribute__((packed));
  197. /* MSG_STREAM_START_STREAM_GRP_PACKET = 0x130000 + 6
  198. MSG_STREAM_STOP_STREAM_GRP_PACKET = 0x130000 + 9
  199. */
  200. struct mixart_group_state_req
  201. {
  202. u32 delayed;
  203. u64 scheduler;
  204. u32 reserved4np[2];
  205. u32 pipe_count; /* set to 1 for instance */
  206. struct mixart_uid pipe_uid[1]; /* could be an array[pipe_count] */
  207. } __attribute__((packed));
  208. struct mixart_group_state_resp
  209. {
  210. u32 txx_status;
  211. u64 scheduler;
  212. } __attribute__((packed));
  213. /* Structures used by the MSG_SERVICES_TIMER_NOTIFY command */
  214. struct mixart_sample_pos
  215. {
  216. u32 buffer_id;
  217. u32 validity;
  218. u32 sample_pos_high_part;
  219. u32 sample_pos_low_part;
  220. } __attribute__((packed));
  221. struct mixart_timer_notify
  222. {
  223. u32 stream_count;
  224. struct mixart_sample_pos streams[MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS];
  225. } __attribute__((packed));
  226. /* MSG_CONSOLE_GET_CLOCK_UID = 0x070003,
  227. */
  228. /* request is a uid with desc = MSG_CONSOLE_MANAGER | cardindex */
  229. struct mixart_return_uid
  230. {
  231. u32 error_code;
  232. struct mixart_uid uid;
  233. } __attribute__((packed));
  234. /* MSG_CLOCK_CHECK_PROPERTIES = 0x200001,
  235. MSG_CLOCK_SET_PROPERTIES = 0x200002,
  236. */
  237. enum mixart_clock_generic_type {
  238. CGT_NO_CLOCK,
  239. CGT_INTERNAL_CLOCK,
  240. CGT_PROGRAMMABLE_CLOCK,
  241. CGT_INTERNAL_ENSLAVED_CLOCK,
  242. CGT_EXTERNAL_CLOCK,
  243. CGT_CURRENT_CLOCK
  244. };
  245. enum mixart_clock_mode {
  246. CM_UNDEFINED,
  247. CM_MASTER,
  248. CM_SLAVE,
  249. CM_STANDALONE,
  250. CM_NOT_CONCERNED
  251. };
  252. struct mixart_clock_properties
  253. {
  254. u32 error_code;
  255. u32 validation_mask;
  256. u32 frequency;
  257. u32 reference_frequency;
  258. u32 clock_generic_type;
  259. u32 clock_mode;
  260. struct mixart_uid uid_clock_source;
  261. struct mixart_uid uid_event_source;
  262. u32 event_mode;
  263. u32 synchro_signal_presence;
  264. u32 format;
  265. u32 board_mask;
  266. u32 nb_callers; /* set to 1 (see below) */
  267. struct mixart_uid uid_caller[1];
  268. } __attribute__((packed));
  269. struct mixart_clock_properties_resp
  270. {
  271. u32 status;
  272. u32 clock_mode;
  273. } __attribute__((packed));
  274. /* MSG_STREAM_SET_INPUT_STAGE_PARAM = 0x13000F */
  275. /* MSG_STREAM_SET_OUTPUT_STAGE_PARAM = 0x130010 */
  276. enum mixart_coding_type {
  277. CT_NOT_DEFINED,
  278. CT_LINEAR,
  279. CT_MPEG_L1,
  280. CT_MPEG_L2,
  281. CT_MPEG_L3,
  282. CT_MPEG_L3_LSF,
  283. CT_GSM
  284. };
  285. enum mixart_sample_type {
  286. ST_NOT_DEFINED,
  287. ST_FLOATING_POINT_32BE,
  288. ST_FLOATING_POINT_32LE,
  289. ST_FLOATING_POINT_64BE,
  290. ST_FLOATING_POINT_64LE,
  291. ST_FIXED_POINT_8,
  292. ST_FIXED_POINT_16BE,
  293. ST_FIXED_POINT_16LE,
  294. ST_FIXED_POINT_24BE,
  295. ST_FIXED_POINT_24LE,
  296. ST_FIXED_POINT_32BE,
  297. ST_FIXED_POINT_32LE,
  298. ST_INTEGER_8,
  299. ST_INTEGER_16BE,
  300. ST_INTEGER_16LE,
  301. ST_INTEGER_24BE,
  302. ST_INTEGER_24LE,
  303. ST_INTEGER_32BE,
  304. ST_INTEGER_32LE
  305. };
  306. struct mixart_stream_param_desc
  307. {
  308. u32 coding_type; /* use enum mixart_coding_type */
  309. u32 sample_type; /* use enum mixart_sample_type */
  310. union {
  311. struct {
  312. u32 linear_endian_ness;
  313. u32 linear_bits;
  314. u32 is_signed;
  315. u32 is_float;
  316. } linear_format_info;
  317. struct {
  318. u32 mpeg_layer;
  319. u32 mpeg_mode;
  320. u32 mpeg_mode_extension;
  321. u32 mpeg_pre_emphasis;
  322. u32 mpeg_has_padding_bit;
  323. u32 mpeg_has_crc;
  324. u32 mpeg_has_extension;
  325. u32 mpeg_is_original;
  326. u32 mpeg_has_copyright;
  327. } mpeg_format_info;
  328. } format_info;
  329. u32 delayed;
  330. u64 scheduler;
  331. u32 sample_size;
  332. u32 has_header;
  333. u32 has_suffix;
  334. u32 has_bitrate;
  335. u32 samples_per_frame;
  336. u32 bytes_per_frame;
  337. u32 bytes_per_sample;
  338. u32 sampling_freq;
  339. u32 number_of_channel;
  340. u32 stream_number;
  341. u32 buffer_size;
  342. u32 differed_time;
  343. u32 reserved4np[3];
  344. u32 pipe_count; /* set to 1 (array size !) */
  345. u32 stream_count; /* set to 1 (array size !) */
  346. struct mixart_txx_stream_desc stream_desc[1]; /* only one stream per command, but this could be an array */
  347. } __attribute__((packed));
  348. /* MSG_CONNECTOR_GET_OUT_AUDIO_LEVEL = 0x050009,
  349. */
  350. struct mixart_get_out_audio_level
  351. {
  352. u32 txx_status;
  353. u32 digital_level; /* float */
  354. u32 analog_level; /* float */
  355. u32 monitor_level; /* float */
  356. u32 mute;
  357. u32 monitor_mute1;
  358. u32 monitor_mute2;
  359. } __attribute__((packed));
  360. /* MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL = 0x05000A,
  361. */
  362. /* used for valid_mask below */
  363. #define MIXART_AUDIO_LEVEL_ANALOG_MASK 0x01
  364. #define MIXART_AUDIO_LEVEL_DIGITAL_MASK 0x02
  365. #define MIXART_AUDIO_LEVEL_MONITOR_MASK 0x04
  366. #define MIXART_AUDIO_LEVEL_MUTE_MASK 0x08
  367. #define MIXART_AUDIO_LEVEL_MUTE_M1_MASK 0x10
  368. #define MIXART_AUDIO_LEVEL_MUTE_M2_MASK 0x20
  369. struct mixart_set_out_audio_level
  370. {
  371. u32 delayed;
  372. u64 scheduler;
  373. u32 valid_mask1;
  374. u32 valid_mask2;
  375. u32 digital_level; /* float */
  376. u32 analog_level; /* float */
  377. u32 monitor_level; /* float */
  378. u32 mute;
  379. u32 monitor_mute1;
  380. u32 monitor_mute2;
  381. u32 reserved4np;
  382. } __attribute__((packed));
  383. /* MSG_SYSTEM_ENUM_PHYSICAL_IO = 0x16000E,
  384. */
  385. #define MIXART_MAX_PHYS_IO (MIXART_MAX_CARDS * 2 * 2) /* 4 * (analog+digital) * (playback+capture) */
  386. struct mixart_uid_enumeration
  387. {
  388. u32 error_code;
  389. u32 first_uid_offset;
  390. u32 nb_uid;
  391. u32 current_uid_index;
  392. struct mixart_uid uid[MIXART_MAX_PHYS_IO];
  393. } __attribute__((packed));
  394. /* MSG_PHYSICALIO_SET_LEVEL = 0x0F0008,
  395. MSG_PHYSICALIO_GET_LEVEL = 0x0F000C,
  396. */
  397. struct mixart_io_channel_level
  398. {
  399. u32 analog_level; /* float */
  400. u32 unused[2];
  401. } __attribute__((packed));
  402. struct mixart_io_level
  403. {
  404. s32 channel; /* 0=left, 1=right, -1=both, -2=both same */
  405. struct mixart_io_channel_level level[2];
  406. } __attribute__((packed));
  407. /* MSG_STREAM_SET_IN_AUDIO_LEVEL = 0x130015,
  408. */
  409. struct mixart_in_audio_level_info
  410. {
  411. struct mixart_uid connector;
  412. u32 valid_mask1;
  413. u32 valid_mask2;
  414. u32 digital_level;
  415. u32 analog_level;
  416. } __attribute__((packed));
  417. struct mixart_set_in_audio_level_req
  418. {
  419. u32 delayed;
  420. u64 scheduler;
  421. u32 audio_count; /* set to <= 2 */
  422. u32 reserved4np;
  423. struct mixart_in_audio_level_info level[2];
  424. } __attribute__((packed));
  425. /* response is a 32 bit status */
  426. /* MSG_STREAM_SET_OUT_STREAM_LEVEL = 0x130017,
  427. */
  428. /* defines used for valid_mask1 */
  429. #define MIXART_OUT_STREAM_SET_LEVEL_LEFT_AUDIO1 0x01
  430. #define MIXART_OUT_STREAM_SET_LEVEL_LEFT_AUDIO2 0x02
  431. #define MIXART_OUT_STREAM_SET_LEVEL_RIGHT_AUDIO1 0x04
  432. #define MIXART_OUT_STREAM_SET_LEVEL_RIGHT_AUDIO2 0x08
  433. #define MIXART_OUT_STREAM_SET_LEVEL_STREAM_1 0x10
  434. #define MIXART_OUT_STREAM_SET_LEVEL_STREAM_2 0x20
  435. #define MIXART_OUT_STREAM_SET_LEVEL_MUTE_1 0x40
  436. #define MIXART_OUT_STREAM_SET_LEVEL_MUTE_2 0x80
  437. struct mixart_out_stream_level_info
  438. {
  439. u32 valid_mask1;
  440. u32 valid_mask2;
  441. u32 left_to_out1_level;
  442. u32 left_to_out2_level;
  443. u32 right_to_out1_level;
  444. u32 right_to_out2_level;
  445. u32 digital_level1;
  446. u32 digital_level2;
  447. u32 mute1;
  448. u32 mute2;
  449. } __attribute__((packed));
  450. struct mixart_set_out_stream_level
  451. {
  452. struct mixart_txx_stream_desc desc;
  453. struct mixart_out_stream_level_info out_level;
  454. } __attribute__((packed));
  455. struct mixart_set_out_stream_level_req
  456. {
  457. u32 delayed;
  458. u64 scheduler;
  459. u32 reserved4np[2];
  460. u32 nb_of_stream; /* set to 1 */
  461. struct mixart_set_out_stream_level stream_level; /* could be an array */
  462. } __attribute__((packed));
  463. /* response to this request is a u32 status value */
  464. /* exported */
  465. void snd_mixart_init_mailbox(struct mixart_mgr *mgr);
  466. void snd_mixart_exit_mailbox(struct mixart_mgr *mgr);
  467. int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int max_resp_size, void *resp_data);
  468. int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr, struct mixart_msg *request, u32 notif_event);
  469. int snd_mixart_send_msg_nonblock(struct mixart_mgr *mgr, struct mixart_msg *request);
  470. irqreturn_t snd_mixart_interrupt(int irq, void *dev_id);
  471. irqreturn_t snd_mixart_threaded_irq(int irq, void *dev_id);
  472. void snd_mixart_reset_board(struct mixart_mgr *mgr);
  473. #endif /* __SOUND_MIXART_CORE_H */