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