40 #include <linux/slab.h>
41 #include <linux/module.h>
57 #define AC97_SLOT_3 0x01
58 #define AC97_SLOT_4 0x02
59 #define AC97_SLOT_6 0x08
60 #define AC97_CMD_IRQ 31
105 au1000_set_ac97_xmit_slots(
struct snd_au1000 *au1000,
long xmit_slots)
107 u32 volatile ac97_config;
118 au1000_set_ac97_recv_slots(
struct snd_au1000 *au1000,
long recv_slots)
120 u32 volatile ac97_config;
143 pointer_next = pointer->
next;
145 pointer = pointer_next;
146 }
while (pointer != stream->
buffer);
151 au1000_setup_dma_link(
struct audio_stream *stream,
unsigned int period_bytes,
152 unsigned int periods)
166 au1000_release_dma_link(stream);
175 for (i = 0; i < periods; i++) {
176 pointer->
start = (
u32)(dma_start + (i * period_bytes));
178 if (i < periods - 1) {
180 if (! pointer->
next) {
181 au1000_release_dma_link(stream);
184 pointer = pointer->
next;
205 init_dma(stream->
dma);
206 if (get_dma_active_buffer(stream->
dma) == 0) {
207 clear_dma_done0(stream->
dma);
208 set_dma_addr0(stream->
dma, stream->
buffer->start);
210 set_dma_addr1(stream->
dma, stream->
buffer->next->start);
213 clear_dma_done1(stream->
dma);
214 set_dma_addr1(stream->
dma, stream->
buffer->start);
216 set_dma_addr0(stream->
dma, stream->
buffer->next->start);
219 enable_dma_buffers(stream->
dma);
220 start_dma(stream->
dma);
224 au1000_dma_interrupt(
int irq,
void *
dev_id)
230 switch (get_dma_buffer_done(stream->
dma)) {
233 clear_dma_done0(stream->
dma);
234 set_dma_addr0(stream->
dma, stream->
buffer->next->start);
236 enable_dma_buffer0(stream->
dma);
240 clear_dma_done1(stream->
dma);
241 set_dma_addr1(stream->
dma, stream->
buffer->next->start);
243 enable_dma_buffer1(stream->
dma);
247 au1000_dma_stop(stream);
248 au1000_dma_start(stream);
260 static unsigned int rates[] = {8000, 11025, 16000, 22050};
278 .buffer_bytes_max = 128*1024,
279 .period_bytes_min = 32,
280 .period_bytes_max = 16*1024,
294 substream->
runtime->hw = snd_au1000_hw;
307 substream->
runtime->hw = snd_au1000_hw;
341 return au1000_setup_dma_link(stream,
342 params_period_bytes(hw_params),
350 au1000_release_dma_link(stream);
391 au1000_dma_start(stream);
394 au1000_dma_stop(stream);
417 return bytes_to_frames(runtime,location);
420 static struct snd_pcm_ops snd_card_au1000_playback_ops = {
421 .open = snd_au1000_playback_open,
422 .close = snd_au1000_playback_close,
424 .hw_params = snd_au1000_hw_params,
425 .hw_free = snd_au1000_hw_free,
426 .prepare = snd_au1000_playback_prepare,
427 .trigger = snd_au1000_trigger,
428 .pointer = snd_au1000_pointer,
431 static struct snd_pcm_ops snd_card_au1000_capture_ops = {
432 .open = snd_au1000_capture_open,
433 .close = snd_au1000_capture_close,
435 .hw_params = snd_au1000_hw_params,
436 .hw_free = snd_au1000_hw_free,
437 .prepare = snd_au1000_capture_prepare,
438 .trigger = snd_au1000_trigger,
439 .pointer = snd_au1000_pointer,
449 if ((err =
snd_pcm_new(au1000->
card,
"AU1000 AC97 PCM", 0, 1, 1, &pcm)) < 0)
456 &snd_card_au1000_playback_ops);
458 &snd_card_au1000_capture_ops);
469 "AC97 TX", au1000_dma_interrupt, 0,
475 "AC97 RX", au1000_dma_interrupt, 0,
493 static unsigned short
494 snd_au1000_ac97_read(
struct snd_ac97 *ac97,
unsigned short reg)
504 for (i = 0; i < 0x5000; i++)
515 for (i = 0; i < 0x5000; i++)
533 snd_au1000_ac97_write(
struct snd_ac97 *ac97,
unsigned short reg,
unsigned short val)
542 for (i = 0; i < 0x5000; i++)
556 snd_au1000_ac97_new(
struct snd_au1000 *au1000)
562 .write = snd_au1000_ac97_write,
563 .read = snd_au1000_ac97_read,
567 0x100000,
"Au1x00 AC97")) ==
NULL) {
596 memset(&ac97, 0,
sizeof(ac97));
632 static struct snd_card *au1000_card;
665 if ((err = snd_au1000_ac97_new(au1000)) < 0 ) {
670 if ((err = snd_au1000_pcm_new(au1000)) < 0) {
689 static void __exit au1000_exit(
void)