aboutsummaryrefslogtreecommitdiffstats
path: root/sound/mips/au1x00.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/mips/au1x00.c')
-rw-r--r--sound/mips/au1x00.c148
1 files changed, 74 insertions, 74 deletions
diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
index a8f9a3b6e73d..f150cced9fc1 100644
--- a/sound/mips/au1x00.c
+++ b/sound/mips/au1x00.c
@@ -63,16 +63,14 @@ MODULE_SUPPORTED_DEVICE("{{AMD,Au1000 AC'97}}");
63#define READ_WAIT 2 63#define READ_WAIT 2
64#define RW_DONE 3 64#define RW_DONE 3
65 65
66typedef struct au1000_period au1000_period_t;
67struct au1000_period 66struct au1000_period
68{ 67{
69 u32 start; 68 u32 start;
70 u32 relative_end; /*realtive to start of buffer*/ 69 u32 relative_end; /*realtive to start of buffer*/
71 au1000_period_t * next; 70 struct au1000_period * next;
72}; 71};
73 72
74/*Au1000 AC97 Port Control Reisters*/ 73/*Au1000 AC97 Port Control Reisters*/
75typedef struct au1000_ac97_reg au1000_ac97_reg_t;
76struct au1000_ac97_reg { 74struct au1000_ac97_reg {
77 u32 volatile config; 75 u32 volatile config;
78 u32 volatile status; 76 u32 volatile status;
@@ -81,31 +79,30 @@ struct au1000_ac97_reg {
81 u32 volatile cntrl; 79 u32 volatile cntrl;
82}; 80};
83 81
84typedef struct audio_stream audio_stream_t;
85struct audio_stream { 82struct audio_stream {
86 snd_pcm_substream_t * substream; 83 struct snd_pcm_substream *substream;
87 int dma; 84 int dma;
88 spinlock_t dma_lock; 85 spinlock_t dma_lock;
89 au1000_period_t * buffer; 86 struct au1000_period * buffer;
90 unsigned int period_size; 87 unsigned int period_size;
91 unsigned int periods; 88 unsigned int periods;
92}; 89};
93 90
94typedef struct snd_card_au1000 { 91struct snd_au1000 {
95 snd_card_t *card; 92 struct snd_card *card;
96 au1000_ac97_reg_t volatile *ac97_ioport; 93 struct au1000_ac97_reg volatile *ac97_ioport;
97 94
98 struct resource *ac97_res_port; 95 struct resource *ac97_res_port;
99 spinlock_t ac97_lock; 96 spinlock_t ac97_lock;
100 ac97_t *ac97; 97 struct snd_ac97 *ac97;
101 98
102 snd_pcm_t *pcm; 99 struct snd_pcm *pcm;
103 audio_stream_t *stream[2]; /* playback & capture */ 100 struct audio_stream *stream[2]; /* playback & capture */
104} au1000_t; 101};
105 102
106/*--------------------------- Local Functions --------------------------------*/ 103/*--------------------------- Local Functions --------------------------------*/
107static void 104static void
108au1000_set_ac97_xmit_slots(au1000_t *au1000, long xmit_slots) 105au1000_set_ac97_xmit_slots(struct snd_au1000 *au1000, long xmit_slots)
109{ 106{
110 u32 volatile ac97_config; 107 u32 volatile ac97_config;
111 108
@@ -118,7 +115,7 @@ au1000_set_ac97_xmit_slots(au1000_t *au1000, long xmit_slots)
118} 115}
119 116
120static void 117static void
121au1000_set_ac97_recv_slots(au1000_t *au1000, long recv_slots) 118au1000_set_ac97_recv_slots(struct snd_au1000 *au1000, long recv_slots)
122{ 119{
123 u32 volatile ac97_config; 120 u32 volatile ac97_config;
124 121
@@ -132,10 +129,10 @@ au1000_set_ac97_recv_slots(au1000_t *au1000, long recv_slots)
132 129
133 130
134static void 131static void
135au1000_release_dma_link(audio_stream_t *stream) 132au1000_release_dma_link(struct audio_stream *stream)
136{ 133{
137 au1000_period_t * pointer; 134 struct au1000_period * pointer;
138 au1000_period_t * pointer_next; 135 struct au1000_period * pointer_next;
139 136
140 stream->period_size = 0; 137 stream->period_size = 0;
141 stream->periods = 0; 138 stream->periods = 0;
@@ -151,11 +148,11 @@ au1000_release_dma_link(audio_stream_t *stream)
151} 148}
152 149
153static int 150static int
154au1000_setup_dma_link(audio_stream_t *stream, unsigned int period_bytes, 151au1000_setup_dma_link(struct audio_stream *stream, unsigned int period_bytes,
155 unsigned int periods) 152 unsigned int periods)
156{ 153{
157 snd_pcm_substream_t *substream = stream->substream; 154 struct snd_pcm_substream *substream = stream->substream;
158 snd_pcm_runtime_t *runtime = substream->runtime; 155 struct snd_pcm_runtime *runtime = substream->runtime;
159 unsigned long dma_start; 156 unsigned long dma_start;
160 int i; 157 int i;
161 158
@@ -170,7 +167,7 @@ au1000_setup_dma_link(audio_stream_t *stream, unsigned int period_bytes,
170 stream->period_size = period_bytes; 167 stream->period_size = period_bytes;
171 stream->periods = periods; 168 stream->periods = periods;
172 169
173 stream->buffer = kmalloc(sizeof(au1000_period_t), GFP_KERNEL); 170 stream->buffer = kmalloc(sizeof(struct au1000_period), GFP_KERNEL);
174 if (! stream->buffer) 171 if (! stream->buffer)
175 return -ENOMEM; 172 return -ENOMEM;
176 pointer = stream->buffer; 173 pointer = stream->buffer;
@@ -191,14 +188,14 @@ au1000_setup_dma_link(audio_stream_t *stream, unsigned int period_bytes,
191} 188}
192 189
193static void 190static void
194au1000_dma_stop(audio_stream_t *stream) 191au1000_dma_stop(struct audio_stream *stream)
195{ 192{
196 snd_assert(stream->buffer, return); 193 snd_assert(stream->buffer, return);
197 disable_dma(stream->dma); 194 disable_dma(stream->dma);
198} 195}
199 196
200static void 197static void
201au1000_dma_start(audio_stream_t *stream) 198au1000_dma_start(struct audio_stream *stream)
202{ 199{
203 snd_assert(stream->buffer, return); 200 snd_assert(stream->buffer, return);
204 201
@@ -223,8 +220,8 @@ au1000_dma_start(audio_stream_t *stream)
223static irqreturn_t 220static irqreturn_t
224au1000_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs) 221au1000_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs)
225{ 222{
226 audio_stream_t *stream = (audio_stream_t *) dev_id; 223 struct audio_stream *stream = (struct audio_stream *) dev_id;
227 snd_pcm_substream_t *substream = stream->substream; 224 struct snd_pcm_substream *substream = stream->substream;
228 225
229 spin_lock(&stream->dma_lock); 226 spin_lock(&stream->dma_lock);
230 switch (get_dma_buffer_done(stream->dma)) { 227 switch (get_dma_buffer_done(stream->dma)) {
@@ -258,13 +255,13 @@ au1000_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs)
258/*-------------------------- PCM Audio Streams -------------------------------*/ 255/*-------------------------- PCM Audio Streams -------------------------------*/
259 256
260static unsigned int rates[] = {8000, 11025, 16000, 22050}; 257static unsigned int rates[] = {8000, 11025, 16000, 22050};
261static snd_pcm_hw_constraint_list_t hw_constraints_rates = { 258static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
262 .count = sizeof(rates) / sizeof(rates[0]), 259 .count = sizeof(rates) / sizeof(rates[0]),
263 .list = rates, 260 .list = rates,
264 .mask = 0, 261 .mask = 0,
265}; 262};
266 263
267static snd_pcm_hardware_t snd_au1000_hw = 264static struct snd_pcm_hardware snd_au1000_hw =
268{ 265{
269 .info = (SNDRV_PCM_INFO_INTERLEAVED | \ 266 .info = (SNDRV_PCM_INFO_INTERLEAVED | \
270 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID), 267 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID),
@@ -284,9 +281,9 @@ static snd_pcm_hardware_t snd_au1000_hw =
284}; 281};
285 282
286static int 283static int
287snd_au1000_playback_open(snd_pcm_substream_t * substream) 284snd_au1000_playback_open(struct snd_pcm_substream *substream)
288{ 285{
289 au1000_t *au1000 = substream->pcm->private_data; 286 struct snd_au1000 *au1000 = substream->pcm->private_data;
290 287
291 au1000->stream[PLAYBACK]->substream = substream; 288 au1000->stream[PLAYBACK]->substream = substream;
292 au1000->stream[PLAYBACK]->buffer = NULL; 289 au1000->stream[PLAYBACK]->buffer = NULL;
@@ -297,9 +294,9 @@ snd_au1000_playback_open(snd_pcm_substream_t * substream)
297} 294}
298 295
299static int 296static int
300snd_au1000_capture_open(snd_pcm_substream_t * substream) 297snd_au1000_capture_open(struct snd_pcm_substream *substream)
301{ 298{
302 au1000_t *au1000 = substream->pcm->private_data; 299 struct snd_au1000 *au1000 = substream->pcm->private_data;
303 300
304 au1000->stream[CAPTURE]->substream = substream; 301 au1000->stream[CAPTURE]->substream = substream;
305 au1000->stream[CAPTURE]->buffer = NULL; 302 au1000->stream[CAPTURE]->buffer = NULL;
@@ -307,32 +304,31 @@ snd_au1000_capture_open(snd_pcm_substream_t * substream)
307 substream->runtime->hw = snd_au1000_hw; 304 substream->runtime->hw = snd_au1000_hw;
308 return (snd_pcm_hw_constraint_list(substream->runtime, 0, 305 return (snd_pcm_hw_constraint_list(substream->runtime, 0,
309 SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates) < 0); 306 SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates) < 0);
310
311} 307}
312 308
313static int 309static int
314snd_au1000_playback_close(snd_pcm_substream_t * substream) 310snd_au1000_playback_close(struct snd_pcm_substream *substream)
315{ 311{
316 au1000_t *au1000 = substream->pcm->private_data; 312 struct snd_au1000 *au1000 = substream->pcm->private_data;
317 313
318 au1000->stream[PLAYBACK]->substream = NULL; 314 au1000->stream[PLAYBACK]->substream = NULL;
319 return 0; 315 return 0;
320} 316}
321 317
322static int 318static int
323snd_au1000_capture_close(snd_pcm_substream_t * substream) 319snd_au1000_capture_close(struct snd_pcm_substream *substream)
324{ 320{
325 au1000_t *au1000 = substream->pcm->private_data; 321 struct snd_au1000 *au1000 = substream->pcm->private_data;
326 322
327 au1000->stream[CAPTURE]->substream = NULL; 323 au1000->stream[CAPTURE]->substream = NULL;
328 return 0; 324 return 0;
329} 325}
330 326
331static int 327static int
332snd_au1000_hw_params(snd_pcm_substream_t * substream, 328snd_au1000_hw_params(struct snd_pcm_substream *substream,
333 snd_pcm_hw_params_t * hw_params) 329 struct snd_pcm_hw_params *hw_params)
334{ 330{
335 audio_stream_t *stream = substream->private_data; 331 struct audio_stream *stream = substream->private_data;
336 int err; 332 int err;
337 333
338 err = snd_pcm_lib_malloc_pages(substream, 334 err = snd_pcm_lib_malloc_pages(substream,
@@ -345,18 +341,18 @@ snd_au1000_hw_params(snd_pcm_substream_t * substream,
345} 341}
346 342
347static int 343static int
348snd_au1000_hw_free(snd_pcm_substream_t * substream) 344snd_au1000_hw_free(struct snd_pcm_substream *substream)
349{ 345{
350 audio_stream_t *stream = substream->private_data; 346 struct audio_stream *stream = substream->private_data;
351 au1000_release_dma_link(stream); 347 au1000_release_dma_link(stream);
352 return snd_pcm_lib_free_pages(substream); 348 return snd_pcm_lib_free_pages(substream);
353} 349}
354 350
355static int 351static int
356snd_au1000_playback_prepare(snd_pcm_substream_t * substream) 352snd_au1000_playback_prepare(struct snd_pcm_substream *substream)
357{ 353{
358 au1000_t *au1000 = substream->pcm->private_data; 354 struct snd_au1000 *au1000 = substream->pcm->private_data;
359 snd_pcm_runtime_t *runtime = substream->runtime; 355 struct snd_pcm_runtime *runtime = substream->runtime;
360 356
361 if (runtime->channels == 1) 357 if (runtime->channels == 1)
362 au1000_set_ac97_xmit_slots(au1000, AC97_SLOT_4); 358 au1000_set_ac97_xmit_slots(au1000, AC97_SLOT_4);
@@ -367,10 +363,10 @@ snd_au1000_playback_prepare(snd_pcm_substream_t * substream)
367} 363}
368 364
369static int 365static int
370snd_au1000_capture_prepare(snd_pcm_substream_t * substream) 366snd_au1000_capture_prepare(struct snd_pcm_substream *substream)
371{ 367{
372 au1000_t *au1000 = substream->pcm->private_data; 368 struct snd_au1000 *au1000 = substream->pcm->private_data;
373 snd_pcm_runtime_t *runtime = substream->runtime; 369 struct snd_pcm_runtime *runtime = substream->runtime;
374 370
375 if (runtime->channels == 1) 371 if (runtime->channels == 1)
376 au1000_set_ac97_recv_slots(au1000, AC97_SLOT_4); 372 au1000_set_ac97_recv_slots(au1000, AC97_SLOT_4);
@@ -381,9 +377,9 @@ snd_au1000_capture_prepare(snd_pcm_substream_t * substream)
381} 377}
382 378
383static int 379static int
384snd_au1000_trigger(snd_pcm_substream_t * substream, int cmd) 380snd_au1000_trigger(struct snd_pcm_substream *substream, int cmd)
385{ 381{
386 audio_stream_t *stream = substream->private_data; 382 struct audio_stream *stream = substream->private_data;
387 int err = 0; 383 int err = 0;
388 384
389 spin_lock(&stream->dma_lock); 385 spin_lock(&stream->dma_lock);
@@ -403,10 +399,10 @@ snd_au1000_trigger(snd_pcm_substream_t * substream, int cmd)
403} 399}
404 400
405static snd_pcm_uframes_t 401static snd_pcm_uframes_t
406snd_au1000_pointer(snd_pcm_substream_t * substream) 402snd_au1000_pointer(struct snd_pcm_substream *substream)
407{ 403{
408 audio_stream_t *stream = substream->private_data; 404 struct audio_stream *stream = substream->private_data;
409 snd_pcm_runtime_t *runtime = substream->runtime; 405 struct snd_pcm_runtime *runtime = substream->runtime;
410 long location; 406 long location;
411 407
412 spin_lock(&stream->dma_lock); 408 spin_lock(&stream->dma_lock);
@@ -418,7 +414,7 @@ snd_au1000_pointer(snd_pcm_substream_t * substream)
418 return bytes_to_frames(runtime,location); 414 return bytes_to_frames(runtime,location);
419} 415}
420 416
421static snd_pcm_ops_t snd_card_au1000_playback_ops = { 417static struct snd_pcm_ops snd_card_au1000_playback_ops = {
422 .open = snd_au1000_playback_open, 418 .open = snd_au1000_playback_open,
423 .close = snd_au1000_playback_close, 419 .close = snd_au1000_playback_close,
424 .ioctl = snd_pcm_lib_ioctl, 420 .ioctl = snd_pcm_lib_ioctl,
@@ -429,7 +425,7 @@ static snd_pcm_ops_t snd_card_au1000_playback_ops = {
429 .pointer = snd_au1000_pointer, 425 .pointer = snd_au1000_pointer,
430}; 426};
431 427
432static snd_pcm_ops_t snd_card_au1000_capture_ops = { 428static struct snd_pcm_ops snd_card_au1000_capture_ops = {
433 .open = snd_au1000_capture_open, 429 .open = snd_au1000_capture_open,
434 .close = snd_au1000_capture_close, 430 .close = snd_au1000_capture_close,
435 .ioctl = snd_pcm_lib_ioctl, 431 .ioctl = snd_pcm_lib_ioctl,
@@ -441,9 +437,9 @@ static snd_pcm_ops_t snd_card_au1000_capture_ops = {
441}; 437};
442 438
443static int __devinit 439static int __devinit
444snd_au1000_pcm_new(void) 440snd_au1000_pcm_new(struct snd_au1000 *au1000)
445{ 441{
446 snd_pcm_t *pcm; 442 struct snd_pcm *pcm;
447 int err; 443 int err;
448 unsigned long flags; 444 unsigned long flags;
449 445
@@ -492,9 +488,9 @@ snd_au1000_pcm_new(void)
492/*-------------------------- AC97 CODEC Control ------------------------------*/ 488/*-------------------------- AC97 CODEC Control ------------------------------*/
493 489
494static unsigned short 490static unsigned short
495snd_au1000_ac97_read(ac97_t *ac97, unsigned short reg) 491snd_au1000_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
496{ 492{
497 au1000_t *au1000 = ac97->private_data; 493 struct snd_au1000 *au1000 = ac97->private_data;
498 u32 volatile cmd; 494 u32 volatile cmd;
499 u16 volatile data; 495 u16 volatile data;
500 int i; 496 int i;
@@ -530,9 +526,9 @@ get the interupt driven case to work efficiently */
530 526
531 527
532static void 528static void
533snd_au1000_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) 529snd_au1000_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val)
534{ 530{
535 au1000_t *au1000 = ac97->private_data; 531 struct snd_au1000 *au1000 = ac97->private_data;
536 u32 cmd; 532 u32 cmd;
537 int i; 533 int i;
538 534
@@ -553,18 +549,22 @@ get the interupt driven case to work efficiently */
553} 549}
554 550
555static int __devinit 551static int __devinit
556snd_au1000_ac97_new(au1000_t *au1000) 552snd_au1000_ac97_new(struct snd_au1000 *au1000)
557{ 553{
558 int err; 554 int err;
559 ac97_bus_t bus, *pbus; 555 struct snd_ac97_bus *pbus;
560 ac97_t ac97; 556 struct snd_ac97_template ac97;
557 static struct snd_ac97_bus_ops ops = {
558 .write = snd_au1000_ac97_write,
559 .read = snd_au1000_ac97_read,
560 };
561 561
562 if ((au1000->ac97_res_port = request_region(AC97C_CONFIG, 562 if ((au1000->ac97_res_port = request_region(AC97C_CONFIG,
563 sizeof(au1000_ac97_reg_t), "Au1x00 AC97")) == NULL) { 563 sizeof(struct au1000_ac97_reg), "Au1x00 AC97")) == NULL) {
564 snd_printk(KERN_ERR "ALSA AC97: can't grap AC97 port\n"); 564 snd_printk(KERN_ERR "ALSA AC97: can't grap AC97 port\n");
565 return -EBUSY; 565 return -EBUSY;
566 } 566 }
567 au1000->ac97_ioport = (au1000_ac97_reg_t *) au1000->ac97_res_port->start; 567 au1000->ac97_ioport = (struct au1000_ac97_reg *) au1000->ac97_res_port->start;
568 568
569 spin_lock_init(&au1000->ac97_lock); 569 spin_lock_init(&au1000->ac97_lock);
570 570
@@ -599,9 +599,9 @@ snd_au1000_ac97_new(au1000_t *au1000)
599/*------------------------------ Setup / Destroy ----------------------------*/ 599/*------------------------------ Setup / Destroy ----------------------------*/
600 600
601void 601void
602snd_au1000_free(snd_card_t *card) 602snd_au1000_free(struct snd_card *card)
603{ 603{
604 au1000_t *au1000 = card->private_data; 604 struct snd_au1000 *au1000 = card->private_data;
605 605
606 if (au1000->ac97_res_port) { 606 if (au1000->ac97_res_port) {
607 /* put internal AC97 block into reset */ 607 /* put internal AC97 block into reset */
@@ -621,16 +621,16 @@ snd_au1000_free(snd_card_t *card)
621} 621}
622 622
623 623
624static snd_card_t *au1000_card; 624static struct snd_card *au1000_card;
625 625
626static int __init 626static int __init
627au1000_init(void) 627au1000_init(void)
628{ 628{
629 int err; 629 int err;
630 snd_card_t *card; 630 struct snd_card *card;
631 au1000_t *au1000; 631 struct snd_au1000 *au1000;
632 632
633 card = snd_card_new(-1, "AC97", THIS_MODULE, sizeof(au1000_t)); 633 card = snd_card_new(-1, "AC97", THIS_MODULE, sizeof(struct snd_au1000));
634 if (card == NULL) 634 if (card == NULL)
635 return -ENOMEM; 635 return -ENOMEM;
636 636
@@ -641,8 +641,8 @@ au1000_init(void)
641 au1000->stream[PLAYBACK]->dma = -1; 641 au1000->stream[PLAYBACK]->dma = -1;
642 au1000->stream[CAPTURE]->dma = -1; 642 au1000->stream[CAPTURE]->dma = -1;
643 au1000->ac97_res_port = NULL; 643 au1000->ac97_res_port = NULL;
644 au1000->stream[PLAYBACK] = kmalloc(sizeof(audio_stream_t), GFP_KERNEL); 644 au1000->stream[PLAYBACK] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL);
645 au1000->stream[CAPTURE] = kmalloc(sizeof(audio_stream_t), GFP_KERNEL); 645 au1000->stream[CAPTURE] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL);
646 if (au1000->stream[PLAYBACK] == NULL || 646 if (au1000->stream[PLAYBACK] == NULL ||
647 au1000->stream[CAPTURE] == NULL) { 647 au1000->stream[CAPTURE] == NULL) {
648 snd_card_free(card); 648 snd_card_free(card);