mixart.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Driver for Digigram miXart soundcards
  4. *
  5. * main header file
  6. *
  7. * Copyright (c) 2003 by Digigram <[email protected]>
  8. */
  9. #ifndef __SOUND_MIXART_H
  10. #define __SOUND_MIXART_H
  11. #include <linux/interrupt.h>
  12. #include <linux/mutex.h>
  13. #include <sound/pcm.h>
  14. #define MIXART_DRIVER_VERSION 0x000100 /* 0.1.0 */
  15. /*
  16. */
  17. struct mixart_uid {
  18. u32 object_id;
  19. u32 desc;
  20. };
  21. struct mem_area {
  22. unsigned long phys;
  23. void __iomem *virt;
  24. struct resource *res;
  25. };
  26. struct mixart_route {
  27. unsigned char connected;
  28. unsigned char phase_inv;
  29. int volume;
  30. };
  31. /* firmware status codes */
  32. #define MIXART_MOTHERBOARD_XLX_INDEX 0
  33. #define MIXART_MOTHERBOARD_ELF_INDEX 1
  34. #define MIXART_AESEBUBOARD_XLX_INDEX 2
  35. #define MIXART_HARDW_FILES_MAX_INDEX 3 /* xilinx, elf, AESEBU xilinx */
  36. #define MIXART_MAX_CARDS 4
  37. #define MSG_FIFO_SIZE 16
  38. #define MIXART_MAX_PHYS_CONNECTORS (MIXART_MAX_CARDS * 2 * 2) /* 4 * stereo * (analog+digital) */
  39. struct mixart_mgr {
  40. unsigned int num_cards;
  41. struct snd_mixart *chip[MIXART_MAX_CARDS];
  42. struct pci_dev *pci;
  43. int irq;
  44. /* memory-maps */
  45. struct mem_area mem[2];
  46. /* one and only blocking message or notification may be pending */
  47. u32 pending_event;
  48. wait_queue_head_t msg_sleep;
  49. /* messages fifo */
  50. u32 msg_fifo[MSG_FIFO_SIZE];
  51. int msg_fifo_readptr;
  52. int msg_fifo_writeptr;
  53. atomic_t msg_processed; /* number of messages to be processed in irq thread */
  54. struct mutex lock; /* interrupt lock */
  55. struct mutex msg_lock; /* mailbox lock */
  56. struct mutex setup_mutex; /* mutex used in hw_params, open and close */
  57. /* hardware interface */
  58. unsigned int dsp_loaded; /* bit flags of loaded dsp indices */
  59. unsigned int board_type; /* read from embedded once elf file is loaded, 250 = miXart8, 251 = with AES, 252 = with Cobranet */
  60. struct snd_dma_buffer flowinfo;
  61. struct snd_dma_buffer bufferinfo;
  62. struct mixart_uid uid_console_manager;
  63. int sample_rate;
  64. int ref_count_rate;
  65. struct mutex mixer_mutex; /* mutex for mixer */
  66. };
  67. #define MIXART_STREAM_STATUS_FREE 0
  68. #define MIXART_STREAM_STATUS_OPEN 1
  69. #define MIXART_STREAM_STATUS_RUNNING 2
  70. #define MIXART_STREAM_STATUS_DRAINING 3
  71. #define MIXART_STREAM_STATUS_PAUSE 4
  72. #define MIXART_PLAYBACK_STREAMS 4
  73. #define MIXART_CAPTURE_STREAMS 1
  74. #define MIXART_PCM_ANALOG 0
  75. #define MIXART_PCM_DIGITAL 1
  76. #define MIXART_PCM_TOTAL 2
  77. #define MIXART_MAX_STREAM_PER_CARD (MIXART_PCM_TOTAL * (MIXART_PLAYBACK_STREAMS + MIXART_CAPTURE_STREAMS) )
  78. #define MIXART_NOTIFY_CARD_MASK 0xF000
  79. #define MIXART_NOTIFY_CARD_OFFSET 12
  80. #define MIXART_NOTIFY_PCM_MASK 0x0F00
  81. #define MIXART_NOTIFY_PCM_OFFSET 8
  82. #define MIXART_NOTIFY_CAPT_MASK 0x0080
  83. #define MIXART_NOTIFY_SUBS_MASK 0x007F
  84. struct mixart_stream {
  85. struct snd_pcm_substream *substream;
  86. struct mixart_pipe *pipe;
  87. int pcm_number;
  88. int status; /* nothing, running, draining */
  89. u64 abs_period_elapsed; /* last absolute stream position where period_elapsed was called (multiple of runtime->period_size) */
  90. u32 buf_periods; /* periods counter in the buffer (< runtime->periods) */
  91. u32 buf_period_frag; /* defines with buf_period_pos the exact position in the buffer (< runtime->period_size) */
  92. int channels;
  93. };
  94. enum mixart_pipe_status {
  95. PIPE_UNDEFINED,
  96. PIPE_STOPPED,
  97. PIPE_RUNNING,
  98. PIPE_CLOCK_SET
  99. };
  100. struct mixart_pipe {
  101. struct mixart_uid group_uid; /* id of the pipe, as returned by embedded */
  102. int stream_count;
  103. struct mixart_uid uid_left_connector; /* UID's for the audio connectors */
  104. struct mixart_uid uid_right_connector;
  105. enum mixart_pipe_status status;
  106. int references; /* number of subs openned */
  107. int monitoring; /* pipe used for monitoring issue */
  108. };
  109. struct snd_mixart {
  110. struct snd_card *card;
  111. struct mixart_mgr *mgr;
  112. int chip_idx; /* zero based */
  113. struct snd_hwdep *hwdep; /* DSP loader, only for the first card */
  114. struct snd_pcm *pcm; /* PCM analog i/o */
  115. struct snd_pcm *pcm_dig; /* PCM digital i/o */
  116. /* allocate stereo pipe for instance */
  117. struct mixart_pipe pipe_in_ana;
  118. struct mixart_pipe pipe_out_ana;
  119. /* if AES/EBU daughter board is available, additional pipes possible on pcm_dig */
  120. struct mixart_pipe pipe_in_dig;
  121. struct mixart_pipe pipe_out_dig;
  122. struct mixart_stream playback_stream[MIXART_PCM_TOTAL][MIXART_PLAYBACK_STREAMS]; /* 0 = pcm, 1 = pcm_dig */
  123. struct mixart_stream capture_stream[MIXART_PCM_TOTAL]; /* 0 = pcm, 1 = pcm_dig */
  124. /* UID's for the physical io's */
  125. struct mixart_uid uid_out_analog_physio;
  126. struct mixart_uid uid_in_analog_physio;
  127. int analog_playback_active[2]; /* Mixer : Master Playback active (!mute) */
  128. int analog_playback_volume[2]; /* Mixer : Master Playback Volume */
  129. int analog_capture_volume[2]; /* Mixer : Master Capture Volume */
  130. int digital_playback_active[2*MIXART_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Active [(analog+AES output)*streams][stereo]*/
  131. int digital_playback_volume[2*MIXART_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Volume [(analog+AES output)*streams][stereo]*/
  132. int digital_capture_volume[2][2]; /* Mixer : Digital Capture Volume [analog+AES output][stereo] */
  133. int monitoring_active[2]; /* Mixer : Monitoring Active */
  134. int monitoring_volume[2]; /* Mixer : Monitoring Volume */
  135. };
  136. struct mixart_bufferinfo
  137. {
  138. u32 buffer_address;
  139. u32 reserved[5];
  140. u32 available_length;
  141. u32 buffer_id;
  142. };
  143. struct mixart_flowinfo
  144. {
  145. u32 bufferinfo_array_phy_address;
  146. u32 reserved[11];
  147. u32 bufferinfo_count;
  148. u32 capture;
  149. };
  150. /* exported */
  151. int snd_mixart_create_pcm(struct snd_mixart * chip);
  152. struct mixart_pipe *snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture, int monitoring);
  153. int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr, struct mixart_pipe *pipe, int monitoring);
  154. #endif /* __SOUND_MIXART_H */