1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef __SOUND_PCXHR_H
24#define __SOUND_PCXHR_H
25
26#include <linux/interrupt.h>
27#include <linux/mutex.h>
28#include <sound/pcm.h>
29
30#define PCXHR_DRIVER_VERSION 0x000906
31#define PCXHR_DRIVER_VERSION_STRING "0.9.6"
32
33
34#define PCXHR_MAX_CARDS 6
35#define PCXHR_PLAYBACK_STREAMS 4
36
37#define PCXHR_GRANULARITY 96
38
39#define PCXHR_GRANULARITY_MIN 96
40
41#define PCXHR_GRANULARITY_HR22 192
42
43struct snd_pcxhr;
44struct pcxhr_mgr;
45
46struct pcxhr_stream;
47struct pcxhr_pipe;
48
49enum pcxhr_clock_type {
50 PCXHR_CLOCK_TYPE_INTERNAL = 0,
51 PCXHR_CLOCK_TYPE_WORD_CLOCK,
52 PCXHR_CLOCK_TYPE_AES_SYNC,
53 PCXHR_CLOCK_TYPE_AES_1,
54 PCXHR_CLOCK_TYPE_AES_2,
55 PCXHR_CLOCK_TYPE_AES_3,
56 PCXHR_CLOCK_TYPE_AES_4,
57 PCXHR_CLOCK_TYPE_MAX = PCXHR_CLOCK_TYPE_AES_4,
58 HR22_CLOCK_TYPE_INTERNAL = PCXHR_CLOCK_TYPE_INTERNAL,
59 HR22_CLOCK_TYPE_AES_SYNC,
60 HR22_CLOCK_TYPE_AES_1,
61 HR22_CLOCK_TYPE_MAX = HR22_CLOCK_TYPE_AES_1,
62};
63
64struct pcxhr_mgr {
65 unsigned int num_cards;
66 struct snd_pcxhr *chip[PCXHR_MAX_CARDS];
67
68 struct pci_dev *pci;
69
70 int irq;
71
72 int granularity;
73
74
75 unsigned long port[3];
76
77
78 char shortname[32];
79 char longname[96];
80
81
82 struct tasklet_struct msg_taskq;
83 struct pcxhr_rmh *prmh;
84
85 struct tasklet_struct trigger_taskq;
86
87 spinlock_t lock;
88 spinlock_t msg_lock;
89
90 struct mutex setup_mutex;
91 struct mutex mixer_mutex;
92
93
94 unsigned int dsp_loaded;
95 unsigned int dsp_version;
96 int playback_chips;
97 int capture_chips;
98 int fw_file_set;
99 int firmware_num;
100 unsigned int is_hr_stereo:1;
101 unsigned int board_has_aes1:1;
102 unsigned int board_has_analog:1;
103 unsigned int board_has_mic:1;
104 unsigned int board_aes_in_192k:1;
105 unsigned int mono_capture:1;
106 unsigned int capture_ltc:1;
107
108 struct snd_dma_buffer hostport;
109
110 enum pcxhr_clock_type use_clock_type;
111 enum pcxhr_clock_type cur_clock_type;
112 int sample_rate;
113 int ref_count_rate;
114 int timer_toggle;
115 int dsp_time_last;
116 int dsp_time_err;
117 unsigned int src_it_dsp;
118 unsigned int io_num_reg_cont;
119 unsigned int codec_speed;
120 unsigned int sample_rate_real;
121 int last_reg_stat;
122 int async_err_stream_xrun;
123 int async_err_pipe_xrun;
124 int async_err_other_last;
125
126 unsigned char xlx_cfg;
127 unsigned char xlx_selmic;
128 unsigned char dsp_reset;
129};
130
131
132enum pcxhr_stream_status {
133 PCXHR_STREAM_STATUS_FREE,
134 PCXHR_STREAM_STATUS_OPEN,
135 PCXHR_STREAM_STATUS_SCHEDULE_RUN,
136 PCXHR_STREAM_STATUS_STARTED,
137 PCXHR_STREAM_STATUS_RUNNING,
138 PCXHR_STREAM_STATUS_SCHEDULE_STOP,
139 PCXHR_STREAM_STATUS_STOPPED,
140 PCXHR_STREAM_STATUS_PAUSED
141};
142
143struct pcxhr_stream {
144 struct snd_pcm_substream *substream;
145 snd_pcm_format_t format;
146 struct pcxhr_pipe *pipe;
147
148 enum pcxhr_stream_status status;
149
150 u_int64_t timer_abs_periods;
151 u_int32_t timer_period_frag;
152 u_int32_t timer_buf_periods;
153 int timer_is_synced;
154
155 int channels;
156};
157
158
159enum pcxhr_pipe_status {
160 PCXHR_PIPE_UNDEFINED,
161 PCXHR_PIPE_DEFINED
162};
163
164struct pcxhr_pipe {
165 enum pcxhr_pipe_status status;
166 int is_capture;
167 int first_audio;
168};
169
170
171struct snd_pcxhr {
172 struct snd_card *card;
173 struct pcxhr_mgr *mgr;
174 int chip_idx;
175
176 struct snd_pcm *pcm;
177
178 struct pcxhr_pipe playback_pipe;
179 struct pcxhr_pipe capture_pipe[2];
180
181 struct pcxhr_stream playback_stream[PCXHR_PLAYBACK_STREAMS];
182 struct pcxhr_stream capture_stream[2];
183 int nb_streams_play;
184 int nb_streams_capt;
185
186 int analog_playback_active[2];
187 int analog_playback_volume[2];
188 int analog_capture_volume[2];
189 int digital_playback_active[PCXHR_PLAYBACK_STREAMS][2];
190 int digital_playback_volume[PCXHR_PLAYBACK_STREAMS][2];
191 int digital_capture_volume[2];
192 int monitoring_active[2];
193 int monitoring_volume[2];
194 int audio_capture_source;
195 int mic_volume;
196 int mic_boost;
197 int mic_active;
198 int analog_capture_active;
199 int phantom_power;
200
201 unsigned char aes_bits[5];
202};
203
204struct pcxhr_hostport
205{
206 char purgebuffer[6];
207 char reserved[2];
208};
209
210
211int pcxhr_create_pcm(struct snd_pcxhr *chip);
212int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate);
213int pcxhr_get_external_clock(struct pcxhr_mgr *mgr,
214 enum pcxhr_clock_type clock_type,
215 int *sample_rate);
216
217#endif
218