aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/cs5535audio/cs5535audio_pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/cs5535audio/cs5535audio_pcm.c')
-rw-r--r--sound/pci/cs5535audio/cs5535audio_pcm.c128
1 files changed, 64 insertions, 64 deletions
diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c
index d32b23f202cd..60bb82b2ff47 100644
--- a/sound/pci/cs5535audio/cs5535audio_pcm.c
+++ b/sound/pci/cs5535audio/cs5535audio_pcm.c
@@ -35,7 +35,7 @@
35#include <sound/ac97_codec.h> 35#include <sound/ac97_codec.h>
36#include "cs5535audio.h" 36#include "cs5535audio.h"
37 37
38static snd_pcm_hardware_t snd_cs5535audio_playback = 38static struct snd_pcm_hardware snd_cs5535audio_playback =
39{ 39{
40 .info = ( 40 .info = (
41 SNDRV_PCM_INFO_MMAP | 41 SNDRV_PCM_INFO_MMAP |
@@ -64,7 +64,7 @@ static snd_pcm_hardware_t snd_cs5535audio_playback =
64 .fifo_size = 0, 64 .fifo_size = 0,
65}; 65};
66 66
67static snd_pcm_hardware_t snd_cs5535audio_capture = 67static struct snd_pcm_hardware snd_cs5535audio_capture =
68{ 68{
69 .info = ( 69 .info = (
70 SNDRV_PCM_INFO_MMAP | 70 SNDRV_PCM_INFO_MMAP |
@@ -92,11 +92,11 @@ static snd_pcm_hardware_t snd_cs5535audio_capture =
92 .fifo_size = 0, 92 .fifo_size = 0,
93}; 93};
94 94
95static int snd_cs5535audio_playback_open(snd_pcm_substream_t *substream) 95static int snd_cs5535audio_playback_open(struct snd_pcm_substream *substream)
96{ 96{
97 int err; 97 int err;
98 cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); 98 struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
99 snd_pcm_runtime_t *runtime = substream->runtime; 99 struct snd_pcm_runtime *runtime = substream->runtime;
100 100
101 runtime->hw = snd_cs5535audio_playback; 101 runtime->hw = snd_cs5535audio_playback;
102 cs5535au->playback_substream = substream; 102 cs5535au->playback_substream = substream;
@@ -109,23 +109,23 @@ static int snd_cs5535audio_playback_open(snd_pcm_substream_t *substream)
109 return 0; 109 return 0;
110} 110}
111 111
112static int snd_cs5535audio_playback_close(snd_pcm_substream_t *substream) 112static int snd_cs5535audio_playback_close(struct snd_pcm_substream *substream)
113{ 113{
114 return 0; 114 return 0;
115} 115}
116 116
117#define CS5535AUDIO_DESC_LIST_SIZE \ 117#define CS5535AUDIO_DESC_LIST_SIZE \
118 PAGE_ALIGN(CS5535AUDIO_MAX_DESCRIPTORS * sizeof(cs5535audio_dma_desc_t)) 118 PAGE_ALIGN(CS5535AUDIO_MAX_DESCRIPTORS * sizeof(struct cs5535audio_dma_desc))
119 119
120static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au, 120static int cs5535audio_build_dma_packets(struct cs5535audio *cs5535au,
121 cs5535audio_dma_t *dma, 121 struct cs5535audio_dma *dma,
122 snd_pcm_substream_t *substream, 122 struct snd_pcm_substream *substream,
123 unsigned int periods, 123 unsigned int periods,
124 unsigned int period_bytes) 124 unsigned int period_bytes)
125{ 125{
126 unsigned int i; 126 unsigned int i;
127 u32 addr, desc_addr, jmpprd_addr; 127 u32 addr, desc_addr, jmpprd_addr;
128 cs5535audio_dma_desc_t *lastdesc; 128 struct cs5535audio_dma_desc *lastdesc;
129 129
130 if (periods > CS5535AUDIO_MAX_DESCRIPTORS) 130 if (periods > CS5535AUDIO_MAX_DESCRIPTORS)
131 return -ENOMEM; 131 return -ENOMEM;
@@ -147,21 +147,21 @@ static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au,
147 addr = (u32) substream->runtime->dma_addr; 147 addr = (u32) substream->runtime->dma_addr;
148 desc_addr = (u32) dma->desc_buf.addr; 148 desc_addr = (u32) dma->desc_buf.addr;
149 for (i = 0; i < periods; i++) { 149 for (i = 0; i < periods; i++) {
150 cs5535audio_dma_desc_t *desc = 150 struct cs5535audio_dma_desc *desc =
151 &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[i]; 151 &((struct cs5535audio_dma_desc *) dma->desc_buf.area)[i];
152 desc->addr = cpu_to_le32(addr); 152 desc->addr = cpu_to_le32(addr);
153 desc->size = cpu_to_le32(period_bytes); 153 desc->size = cpu_to_le32(period_bytes);
154 desc->ctlreserved = cpu_to_le32(PRD_EOP); 154 desc->ctlreserved = cpu_to_le32(PRD_EOP);
155 desc_addr += sizeof(cs5535audio_dma_desc_t); 155 desc_addr += sizeof(struct cs5535audio_dma_desc);
156 addr += period_bytes; 156 addr += period_bytes;
157 } 157 }
158 /* we reserved one dummy descriptor at the end to do the PRD jump */ 158 /* we reserved one dummy descriptor at the end to do the PRD jump */
159 lastdesc = &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[periods]; 159 lastdesc = &((struct cs5535audio_dma_desc *) dma->desc_buf.area)[periods];
160 lastdesc->addr = cpu_to_le32((u32) dma->desc_buf.addr); 160 lastdesc->addr = cpu_to_le32((u32) dma->desc_buf.addr);
161 lastdesc->size = 0; 161 lastdesc->size = 0;
162 lastdesc->ctlreserved = cpu_to_le32(PRD_JMP); 162 lastdesc->ctlreserved = cpu_to_le32(PRD_JMP);
163 jmpprd_addr = cpu_to_le32(lastdesc->addr + 163 jmpprd_addr = cpu_to_le32(lastdesc->addr +
164 (sizeof(cs5535audio_dma_desc_t)*periods)); 164 (sizeof(struct cs5535audio_dma_desc)*periods));
165 165
166 dma->period_bytes = period_bytes; 166 dma->period_bytes = period_bytes;
167 dma->periods = periods; 167 dma->periods = periods;
@@ -172,71 +172,71 @@ static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au,
172 return 0; 172 return 0;
173} 173}
174 174
175static void cs5535audio_playback_enable_dma(cs5535audio_t *cs5535au) 175static void cs5535audio_playback_enable_dma(struct cs5535audio *cs5535au)
176{ 176{
177 cs_writeb(cs5535au, ACC_BM0_CMD, BM_CTL_EN); 177 cs_writeb(cs5535au, ACC_BM0_CMD, BM_CTL_EN);
178} 178}
179 179
180static void cs5535audio_playback_disable_dma(cs5535audio_t *cs5535au) 180static void cs5535audio_playback_disable_dma(struct cs5535audio *cs5535au)
181{ 181{
182 cs_writeb(cs5535au, ACC_BM0_CMD, 0); 182 cs_writeb(cs5535au, ACC_BM0_CMD, 0);
183} 183}
184 184
185static void cs5535audio_playback_pause_dma(cs5535audio_t *cs5535au) 185static void cs5535audio_playback_pause_dma(struct cs5535audio *cs5535au)
186{ 186{
187 cs_writeb(cs5535au, ACC_BM0_CMD, BM_CTL_PAUSE); 187 cs_writeb(cs5535au, ACC_BM0_CMD, BM_CTL_PAUSE);
188} 188}
189 189
190static void cs5535audio_playback_setup_prd(cs5535audio_t *cs5535au, 190static void cs5535audio_playback_setup_prd(struct cs5535audio *cs5535au,
191 u32 prd_addr) 191 u32 prd_addr)
192{ 192{
193 cs_writel(cs5535au, ACC_BM0_PRD, prd_addr); 193 cs_writel(cs5535au, ACC_BM0_PRD, prd_addr);
194} 194}
195 195
196static u32 cs5535audio_playback_read_dma_pntr(cs5535audio_t *cs5535au) 196static u32 cs5535audio_playback_read_dma_pntr(struct cs5535audio *cs5535au)
197{ 197{
198 return cs_readl(cs5535au, ACC_BM0_PNTR); 198 return cs_readl(cs5535au, ACC_BM0_PNTR);
199} 199}
200 200
201static void cs5535audio_capture_enable_dma(cs5535audio_t *cs5535au) 201static void cs5535audio_capture_enable_dma(struct cs5535audio *cs5535au)
202{ 202{
203 cs_writeb(cs5535au, ACC_BM1_CMD, BM_CTL_EN); 203 cs_writeb(cs5535au, ACC_BM1_CMD, BM_CTL_EN);
204} 204}
205 205
206static void cs5535audio_capture_disable_dma(cs5535audio_t *cs5535au) 206static void cs5535audio_capture_disable_dma(struct cs5535audio *cs5535au)
207{ 207{
208 cs_writeb(cs5535au, ACC_BM1_CMD, 0); 208 cs_writeb(cs5535au, ACC_BM1_CMD, 0);
209} 209}
210 210
211static void cs5535audio_capture_pause_dma(cs5535audio_t *cs5535au) 211static void cs5535audio_capture_pause_dma(struct cs5535audio *cs5535au)
212{ 212{
213 cs_writeb(cs5535au, ACC_BM1_CMD, BM_CTL_PAUSE); 213 cs_writeb(cs5535au, ACC_BM1_CMD, BM_CTL_PAUSE);
214} 214}
215 215
216static void cs5535audio_capture_setup_prd(cs5535audio_t *cs5535au, 216static void cs5535audio_capture_setup_prd(struct cs5535audio *cs5535au,
217 u32 prd_addr) 217 u32 prd_addr)
218{ 218{
219 cs_writel(cs5535au, ACC_BM1_PRD, prd_addr); 219 cs_writel(cs5535au, ACC_BM1_PRD, prd_addr);
220} 220}
221 221
222static u32 cs5535audio_capture_read_dma_pntr(cs5535audio_t *cs5535au) 222static u32 cs5535audio_capture_read_dma_pntr(struct cs5535audio *cs5535au)
223{ 223{
224 return cs_readl(cs5535au, ACC_BM1_PNTR); 224 return cs_readl(cs5535au, ACC_BM1_PNTR);
225} 225}
226 226
227static void cs5535audio_clear_dma_packets(cs5535audio_t *cs5535au, 227static void cs5535audio_clear_dma_packets(struct cs5535audio *cs5535au,
228 cs5535audio_dma_t *dma, 228 struct cs5535audio_dma *dma,
229 snd_pcm_substream_t *substream) 229 struct snd_pcm_substream *substream)
230{ 230{
231 snd_dma_free_pages(&dma->desc_buf); 231 snd_dma_free_pages(&dma->desc_buf);
232 dma->desc_buf.area = NULL; 232 dma->desc_buf.area = NULL;
233} 233}
234 234
235static int snd_cs5535audio_hw_params(snd_pcm_substream_t *substream, 235static int snd_cs5535audio_hw_params(struct snd_pcm_substream *substream,
236 snd_pcm_hw_params_t *hw_params) 236 struct snd_pcm_hw_params *hw_params)
237{ 237{
238 cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); 238 struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
239 cs5535audio_dma_t *dma = substream->runtime->private_data; 239 struct cs5535audio_dma *dma = substream->runtime->private_data;
240 int err; 240 int err;
241 241
242 err = snd_pcm_lib_malloc_pages(substream, 242 err = snd_pcm_lib_malloc_pages(substream,
@@ -247,31 +247,31 @@ static int snd_cs5535audio_hw_params(snd_pcm_substream_t *substream,
247 dma->buf_bytes = params_buffer_bytes(hw_params); 247 dma->buf_bytes = params_buffer_bytes(hw_params);
248 248
249 err = cs5535audio_build_dma_packets(cs5535au, dma, substream, 249 err = cs5535audio_build_dma_packets(cs5535au, dma, substream,
250 params_periods(hw_params), 250 params_periods(hw_params),
251 params_period_bytes(hw_params)); 251 params_period_bytes(hw_params));
252 return err; 252 return err;
253} 253}
254 254
255static int snd_cs5535audio_hw_free(snd_pcm_substream_t *substream) 255static int snd_cs5535audio_hw_free(struct snd_pcm_substream *substream)
256{ 256{
257 cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); 257 struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
258 cs5535audio_dma_t *dma = substream->runtime->private_data; 258 struct cs5535audio_dma *dma = substream->runtime->private_data;
259 259
260 cs5535audio_clear_dma_packets(cs5535au, dma, substream); 260 cs5535audio_clear_dma_packets(cs5535au, dma, substream);
261 return snd_pcm_lib_free_pages(substream); 261 return snd_pcm_lib_free_pages(substream);
262} 262}
263 263
264static int snd_cs5535audio_playback_prepare(snd_pcm_substream_t *substream) 264static int snd_cs5535audio_playback_prepare(struct snd_pcm_substream *substream)
265{ 265{
266 cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); 266 struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
267 return snd_ac97_set_rate(cs5535au->ac97, AC97_PCM_FRONT_DAC_RATE, 267 return snd_ac97_set_rate(cs5535au->ac97, AC97_PCM_FRONT_DAC_RATE,
268 substream->runtime->rate); 268 substream->runtime->rate);
269} 269}
270 270
271static int snd_cs5535audio_trigger(snd_pcm_substream_t *substream, int cmd) 271static int snd_cs5535audio_trigger(struct snd_pcm_substream *substream, int cmd)
272{ 272{
273 cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); 273 struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
274 cs5535audio_dma_t *dma = substream->runtime->private_data; 274 struct cs5535audio_dma *dma = substream->runtime->private_data;
275 int err = 0; 275 int err = 0;
276 276
277 spin_lock(&cs5535au->reg_lock); 277 spin_lock(&cs5535au->reg_lock);
@@ -297,12 +297,12 @@ static int snd_cs5535audio_trigger(snd_pcm_substream_t *substream, int cmd)
297 return err; 297 return err;
298} 298}
299 299
300static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(snd_pcm_substream_t 300static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(struct snd_pcm_substream
301 *substream) 301 *substream)
302{ 302{
303 cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); 303 struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
304 u32 curdma; 304 u32 curdma;
305 cs5535audio_dma_t *dma; 305 struct cs5535audio_dma *dma;
306 306
307 dma = substream->runtime->private_data; 307 dma = substream->runtime->private_data;
308 curdma = dma->ops->read_dma_pntr(cs5535au); 308 curdma = dma->ops->read_dma_pntr(cs5535au);
@@ -320,11 +320,11 @@ static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(snd_pcm_substream_t
320 return bytes_to_frames(substream->runtime, curdma); 320 return bytes_to_frames(substream->runtime, curdma);
321} 321}
322 322
323static int snd_cs5535audio_capture_open(snd_pcm_substream_t *substream) 323static int snd_cs5535audio_capture_open(struct snd_pcm_substream *substream)
324{ 324{
325 int err; 325 int err;
326 cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); 326 struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
327 snd_pcm_runtime_t *runtime = substream->runtime; 327 struct snd_pcm_runtime *runtime = substream->runtime;
328 328
329 runtime->hw = snd_cs5535audio_capture; 329 runtime->hw = snd_cs5535audio_capture;
330 cs5535au->capture_substream = substream; 330 cs5535au->capture_substream = substream;
@@ -336,19 +336,19 @@ static int snd_cs5535audio_capture_open(snd_pcm_substream_t *substream)
336 return 0; 336 return 0;
337} 337}
338 338
339static int snd_cs5535audio_capture_close(snd_pcm_substream_t *substream) 339static int snd_cs5535audio_capture_close(struct snd_pcm_substream *substream)
340{ 340{
341 return 0; 341 return 0;
342} 342}
343 343
344static int snd_cs5535audio_capture_prepare(snd_pcm_substream_t *substream) 344static int snd_cs5535audio_capture_prepare(struct snd_pcm_substream *substream)
345{ 345{
346 cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); 346 struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
347 return snd_ac97_set_rate(cs5535au->ac97, AC97_PCM_LR_ADC_RATE, 347 return snd_ac97_set_rate(cs5535au->ac97, AC97_PCM_LR_ADC_RATE,
348 substream->runtime->rate); 348 substream->runtime->rate);
349} 349}
350 350
351static snd_pcm_ops_t snd_cs5535audio_playback_ops = { 351static struct snd_pcm_ops snd_cs5535audio_playback_ops = {
352 .open = snd_cs5535audio_playback_open, 352 .open = snd_cs5535audio_playback_open,
353 .close = snd_cs5535audio_playback_close, 353 .close = snd_cs5535audio_playback_close,
354 .ioctl = snd_pcm_lib_ioctl, 354 .ioctl = snd_pcm_lib_ioctl,
@@ -359,7 +359,7 @@ static snd_pcm_ops_t snd_cs5535audio_playback_ops = {
359 .pointer = snd_cs5535audio_pcm_pointer, 359 .pointer = snd_cs5535audio_pcm_pointer,
360}; 360};
361 361
362static snd_pcm_ops_t snd_cs5535audio_capture_ops = { 362static struct snd_pcm_ops snd_cs5535audio_capture_ops = {
363 .open = snd_cs5535audio_capture_open, 363 .open = snd_cs5535audio_capture_open,
364 .close = snd_cs5535audio_capture_close, 364 .close = snd_cs5535audio_capture_close,
365 .ioctl = snd_pcm_lib_ioctl, 365 .ioctl = snd_pcm_lib_ioctl,
@@ -370,7 +370,7 @@ static snd_pcm_ops_t snd_cs5535audio_capture_ops = {
370 .pointer = snd_cs5535audio_pcm_pointer, 370 .pointer = snd_cs5535audio_pcm_pointer,
371}; 371};
372 372
373static cs5535audio_dma_ops_t snd_cs5535audio_playback_dma_ops = { 373static struct cs5535audio_dma_ops snd_cs5535audio_playback_dma_ops = {
374 .type = CS5535AUDIO_DMA_PLAYBACK, 374 .type = CS5535AUDIO_DMA_PLAYBACK,
375 .enable_dma = cs5535audio_playback_enable_dma, 375 .enable_dma = cs5535audio_playback_enable_dma,
376 .disable_dma = cs5535audio_playback_disable_dma, 376 .disable_dma = cs5535audio_playback_disable_dma,
@@ -379,7 +379,7 @@ static cs5535audio_dma_ops_t snd_cs5535audio_playback_dma_ops = {
379 .read_dma_pntr = cs5535audio_playback_read_dma_pntr, 379 .read_dma_pntr = cs5535audio_playback_read_dma_pntr,
380}; 380};
381 381
382static cs5535audio_dma_ops_t snd_cs5535audio_capture_dma_ops = { 382static struct cs5535audio_dma_ops snd_cs5535audio_capture_dma_ops = {
383 .type = CS5535AUDIO_DMA_CAPTURE, 383 .type = CS5535AUDIO_DMA_CAPTURE,
384 .enable_dma = cs5535audio_capture_enable_dma, 384 .enable_dma = cs5535audio_capture_enable_dma,
385 .disable_dma = cs5535audio_capture_disable_dma, 385 .disable_dma = cs5535audio_capture_disable_dma,
@@ -388,9 +388,9 @@ static cs5535audio_dma_ops_t snd_cs5535audio_capture_dma_ops = {
388 .read_dma_pntr = cs5535audio_capture_read_dma_pntr, 388 .read_dma_pntr = cs5535audio_capture_read_dma_pntr,
389}; 389};
390 390
391int __devinit snd_cs5535audio_pcm(cs5535audio_t *cs5535au) 391int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535au)
392{ 392{
393 snd_pcm_t *pcm; 393 struct snd_pcm *pcm;
394 int err; 394 int err;
395 395
396 err = snd_pcm_new(cs5535au->card, "CS5535 Audio", 0, 1, 1, &pcm); 396 err = snd_pcm_new(cs5535au->card, "CS5535 Audio", 0, 1, 1, &pcm);