mixart.h 6.7 KB

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