pcxhr.h 6.1 KB

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