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