pcxhr.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * Driver for Digigram pcxhr soundcards
  3. *
  4. * main header file
  5. *
  6. * Copyright (c) 2004 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_PCXHR_H
  23. #define __SOUND_PCXHR_H
  24. #include <linux/interrupt.h>
  25. #include <linux/mutex.h>
  26. #include <sound/pcm.h>
  27. #define PCXHR_DRIVER_VERSION 0x000906 /* 0.9.6 */
  28. #define PCXHR_DRIVER_VERSION_STRING "0.9.6" /* 0.9.6 */
  29. #define PCXHR_MAX_CARDS 6
  30. #define PCXHR_PLAYBACK_STREAMS 4
  31. #define PCXHR_GRANULARITY 96 /* min 96 and multiple of 48 */
  32. /* transfer granularity of pipes and the dsp time (MBOX4) */
  33. #define PCXHR_GRANULARITY_MIN 96
  34. /* TODO : granularity could be 64 or 128 */
  35. #define PCXHR_GRANULARITY_HR22 192 /* granularity for stereo cards */
  36. struct snd_pcxhr;
  37. struct pcxhr_mgr;
  38. struct pcxhr_stream;
  39. struct pcxhr_pipe;
  40. enum pcxhr_clock_type {
  41. PCXHR_CLOCK_TYPE_INTERNAL = 0,
  42. PCXHR_CLOCK_TYPE_WORD_CLOCK,
  43. PCXHR_CLOCK_TYPE_AES_SYNC,
  44. PCXHR_CLOCK_TYPE_AES_1,
  45. PCXHR_CLOCK_TYPE_AES_2,
  46. PCXHR_CLOCK_TYPE_AES_3,
  47. PCXHR_CLOCK_TYPE_AES_4,
  48. PCXHR_CLOCK_TYPE_MAX = PCXHR_CLOCK_TYPE_AES_4,
  49. HR22_CLOCK_TYPE_INTERNAL = PCXHR_CLOCK_TYPE_INTERNAL,
  50. HR22_CLOCK_TYPE_AES_SYNC,
  51. HR22_CLOCK_TYPE_AES_1,
  52. HR22_CLOCK_TYPE_MAX = HR22_CLOCK_TYPE_AES_1,
  53. };
  54. struct pcxhr_mgr {
  55. unsigned int num_cards;
  56. struct snd_pcxhr *chip[PCXHR_MAX_CARDS];
  57. struct pci_dev *pci;
  58. int irq;
  59. int granularity;
  60. /* card access with 1 mem bar and 2 io bar's */
  61. unsigned long port[3];
  62. /* share the name */
  63. char name[40]; /* name of this soundcard */
  64. struct pcxhr_rmh *prmh;
  65. struct mutex lock; /* interrupt lock */
  66. struct mutex msg_lock; /* message lock */
  67. struct mutex setup_mutex; /* mutex used in hw_params, open and close */
  68. struct mutex mixer_mutex; /* mutex for mixer */
  69. /* hardware interface */
  70. unsigned int dsp_loaded; /* bit flags of loaded dsp indices */
  71. unsigned int dsp_version; /* read from embedded once firmware is loaded */
  72. int playback_chips;
  73. int capture_chips;
  74. int fw_file_set;
  75. int firmware_num;
  76. unsigned int is_hr_stereo:1;
  77. unsigned int board_has_aes1:1; /* if 1 board has AES1 plug and SRC */
  78. unsigned int board_has_analog:1; /* if 0 the board is digital only */
  79. unsigned int board_has_mic:1; /* if 1 the board has microphone input */
  80. unsigned int board_aes_in_192k:1;/* if 1 the aes input plugs do support 192kHz */
  81. unsigned int mono_capture:1; /* if 1 the board does mono capture */
  82. unsigned int capture_ltc:1; /* if 1 the board captures LTC input */
  83. struct snd_dma_buffer hostport;
  84. enum pcxhr_clock_type use_clock_type; /* clock type selected by mixer */
  85. enum pcxhr_clock_type cur_clock_type; /* current clock type synced */
  86. int sample_rate;
  87. int ref_count_rate;
  88. int timer_toggle; /* timer interrupt toggles between the two values 0x200 and 0x300 */
  89. int dsp_time_last; /* the last dsp time (read by interrupt) */
  90. int dsp_time_err; /* dsp time errors */
  91. unsigned int src_it_dsp; /* dsp interrupt source */
  92. unsigned int io_num_reg_cont; /* backup of IO_NUM_REG_CONT */
  93. unsigned int codec_speed; /* speed mode of the codecs */
  94. unsigned int sample_rate_real; /* current real sample rate */
  95. int last_reg_stat;
  96. int async_err_stream_xrun;
  97. int async_err_pipe_xrun;
  98. int async_err_other_last;
  99. unsigned char xlx_cfg; /* copy of PCXHR_XLX_CFG register */
  100. unsigned char xlx_selmic; /* copy of PCXHR_XLX_SELMIC register */
  101. unsigned char dsp_reset; /* copy of PCXHR_DSP_RESET register */
  102. };
  103. enum pcxhr_stream_status {
  104. PCXHR_STREAM_STATUS_FREE,
  105. PCXHR_STREAM_STATUS_OPEN,
  106. PCXHR_STREAM_STATUS_SCHEDULE_RUN,
  107. PCXHR_STREAM_STATUS_STARTED,
  108. PCXHR_STREAM_STATUS_RUNNING,
  109. PCXHR_STREAM_STATUS_SCHEDULE_STOP,
  110. PCXHR_STREAM_STATUS_STOPPED,
  111. PCXHR_STREAM_STATUS_PAUSED
  112. };
  113. struct pcxhr_stream {
  114. struct snd_pcm_substream *substream;
  115. snd_pcm_format_t format;
  116. struct pcxhr_pipe *pipe;
  117. enum pcxhr_stream_status status; /* free, open, running, draining, pause */
  118. u_int64_t timer_abs_periods; /* timer: samples elapsed since TRIGGER_START (multiple of period_size) */
  119. u_int32_t timer_period_frag; /* timer: samples elapsed since last call to snd_pcm_period_elapsed (0..period_size) */
  120. u_int32_t timer_buf_periods; /* nb of periods in the buffer that have already elapsed */
  121. int timer_is_synced; /* if(0) : timer needs to be resynced with real hardware pointer */
  122. int channels;
  123. };
  124. enum pcxhr_pipe_status {
  125. PCXHR_PIPE_UNDEFINED,
  126. PCXHR_PIPE_DEFINED
  127. };
  128. struct pcxhr_pipe {
  129. enum pcxhr_pipe_status status;
  130. int is_capture; /* this is a capture pipe */
  131. int first_audio; /* first audio num */
  132. };
  133. struct snd_pcxhr {
  134. struct snd_card *card;
  135. struct pcxhr_mgr *mgr;
  136. int chip_idx; /* zero based */
  137. struct snd_pcm *pcm; /* PCM */
  138. struct pcxhr_pipe playback_pipe; /* 1 stereo pipe only */
  139. struct pcxhr_pipe capture_pipe[2]; /* 1 stereo or 2 mono pipes */
  140. struct pcxhr_stream playback_stream[PCXHR_PLAYBACK_STREAMS];
  141. struct pcxhr_stream capture_stream[2]; /* 1 stereo or 2 mono streams */
  142. int nb_streams_play;
  143. int nb_streams_capt;
  144. int analog_playback_active[2]; /* Mixer : Master Playback !mute */
  145. int analog_playback_volume[2]; /* Mixer : Master Playback Volume */
  146. int analog_capture_volume[2]; /* Mixer : Master Capture Volume */
  147. int digital_playback_active[PCXHR_PLAYBACK_STREAMS][2];
  148. int digital_playback_volume[PCXHR_PLAYBACK_STREAMS][2];
  149. int digital_capture_volume[2]; /* Mixer : Digital Capture Volume */
  150. int monitoring_active[2]; /* Mixer : Monitoring Active */
  151. int monitoring_volume[2]; /* Mixer : Monitoring Volume */
  152. int audio_capture_source; /* Mixer : Audio Capture Source */
  153. int mic_volume; /* used by cards with MIC only */
  154. int mic_boost; /* used by cards with MIC only */
  155. int mic_active; /* used by cards with MIC only */
  156. int analog_capture_active; /* used by cards with MIC only */
  157. int phantom_power; /* used by cards with MIC only */
  158. unsigned char aes_bits[5]; /* Mixer : IEC958_AES bits */
  159. };
  160. struct pcxhr_hostport
  161. {
  162. char purgebuffer[6];
  163. char reserved[2];
  164. };
  165. /* exported */
  166. int pcxhr_create_pcm(struct snd_pcxhr *chip);
  167. int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate);
  168. int pcxhr_get_external_clock(struct pcxhr_mgr *mgr,
  169. enum pcxhr_clock_type clock_type,
  170. int *sample_rate);
  171. #endif /* __SOUND_PCXHR_H */