Import 2.3.18pre1
[davej-history.git] / drivers / sound / vidc.c
blob04fcd34134e8aa7a6e7b06813ae1332af388e97a
1 /*
2 * drivers/sound/vidc.c
4 * Detection routine for the VIDC.
6 * Copyright (C) 1997 by Russell King <rmk@arm.uk.linux.org>
7 */
9 #include <linux/module.h>
10 #include <linux/kernel.h>
12 #include <asm/io.h>
13 #include <asm/dma.h>
14 #include "sound_config.h"
15 #include "soundmodule.h"
16 #include "vidc.h"
18 int vidc_busy;
20 void vidc_update_filler(int format, int channels)
22 int fillertype;
24 #define TYPE(fmt,ch) (((fmt)<<2) | ((ch)&3))
26 fillertype = TYPE(format, channels);
28 switch (fillertype)
30 default:
31 case TYPE(AFMT_U8, 1):
32 vidc_filler = vidc_fill_1x8_u;
33 break;
35 case TYPE(AFMT_U8, 2):
36 vidc_filler = vidc_fill_2x8_u;
37 break;
39 case TYPE(AFMT_S8, 1):
40 vidc_filler = vidc_fill_1x8_s;
41 break;
43 case TYPE(AFMT_S8, 2):
44 vidc_filler = vidc_fill_2x8_s;
45 break;
47 case TYPE(AFMT_S16_LE, 1):
48 vidc_filler = vidc_fill_1x16_s;
49 break;
51 case TYPE(AFMT_S16_LE, 2):
52 vidc_filler = vidc_fill_2x16_s;
53 break;
57 void attach_vidc(struct address_info *hw_config)
59 char name[32];
60 int i;
62 sprintf(name, "VIDC %d-bit sound", hw_config->card_subtype);
63 conf_printf(name, hw_config);
64 memset(dma_buf, 0, sizeof(dma_buf));
66 for (i = 0; i < 2; i++)
68 dma_buf[i] = get_free_page(GFP_KERNEL);
69 if (!dma_buf[i])
70 goto nomem;
71 dma_pbuf[i] = virt_to_phys(dma_buf[i]);
74 if (sound_alloc_dma(hw_config->dma, "VIDCsound"))
76 printk(KERN_ERR "VIDCsound: can't allocate virtual DMA channel\n");
77 return;
79 if (request_irq(hw_config->irq, vidc_sound_dma_irq, 0, "VIDCsound", &dma_start))
81 printk(KERN_ERR "VIDCsound: can't allocate DMA interrupt\n");
82 return;
85 // vidc_synth_init(hw_config);
86 vidc_audio_init(hw_config);
87 vidc_mixer_init(hw_config);
88 return;
90 nomem:
91 for (i = 0; i < 2; i++)
92 free_page(dma_buf[i]);
93 printk(KERN_ERR "VIDCsound: can't allocate required buffers\n");
96 int probe_vidc(struct address_info *hw_config)
98 hw_config->irq = IRQ_DMAS0;
99 hw_config->dma = DMA_VIRTUAL_SOUND;
100 hw_config->dma2 = -1;
101 hw_config->card_subtype = 16;
102 return 1;
105 void unload_vidc(struct address_info *hw_config)
107 int i;
109 free_irq(hw_config->irq, NULL);
110 sound_free_dma(hw_config->dma);
112 for (i = 0; i < 2; i++)
113 free_page(dma_buf[i]);
116 #ifdef MODULE
117 static struct address_info config;
119 int init_module(void)
121 if (probe_vidc(&config) == 0)
122 return -ENODEV;
123 printk("VIDC 16-bit serial sound\n");
124 SOUND_LOCK;
125 attach_vidc(&config);
126 return 0;
129 void cleanup_module(void)
131 unload_vidc(&config);
132 SOUND_LOCK_END;
135 #endif