This source file includes following definitions.
- install_pnp_sounddrv
- cs4232_pnp
- pnp_activate
- sound_pnp_init
- sound_pnp_disconnect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #include "sound_config.h"
30
31 #if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_PNP)
32
33 #include <linux/pnp.h>
34
35 static struct pnp_sounddev *pnp_devs[20] =
36 {
37 NULL
38 };
39
40 static int max_pnpdevs = 20;
41 static int nr_pnpdevs = 0;
42 static int pnp_sig = 0;
43
44 void
45 install_pnp_sounddrv (struct pnp_sounddev *drv)
46 {
47 if (nr_pnpdevs < max_pnpdevs)
48 {
49 pnp_devs[nr_pnpdevs++] = drv;
50 }
51 else
52 printk ("Sound: More than 20 PnP drivers defined\n");
53 }
54
55 void
56 cs4232_pnp (void *parm)
57 {
58 struct pnp_dev *dev = (struct pnp_dev *) parm;
59 char *name;
60
61 int portmask = 0x00, irqmask = 0x01, dmamask = 0x03;
62 int opl3_driver, wss_driver;
63
64 printk ("CS4232 driver waking up\n");
65
66 if (dev->card && dev->card->name)
67 name = dev->card->name;
68 else
69 name = "PnP WSS";
70
71 if ((wss_driver = sndtable_identify_card ("AD1848")))
72 portmask |= 0x01;
73 else
74 printk ("Sound: MSS/WSS device detected but no driver enabled\n");
75
76 if ((opl3_driver = sndtable_identify_card ("OPL3")))
77 portmask |= 0x02;
78 else
79 printk ("Sound: OPL3/4 device detected but no driver enabled\n");
80
81 printk ("WSS driver %d, OPL3 driver %d\n", wss_driver, opl3_driver);
82
83 if (!portmask)
84 return;
85
86 if (!pnp_allocate_device (pnp_sig, dev, portmask, irqmask, dmamask, 0x00))
87 printk ("Device activation failed\n");
88 else
89 {
90 struct address_info hw_config;
91 int wss_base, opl3_base;
92 int irq;
93 int dma1, dma2;
94
95 printk ("Device activation OK\n");
96 wss_base = pnp_get_port (dev, 0);
97 opl3_base = pnp_get_port (dev, 1);
98 irq = pnp_get_irq (dev, 0);
99 dma1 = pnp_get_dma (dev, 0);
100 dma2 = pnp_get_dma (dev, 1);
101
102 printk ("I/O0 %03x\n", wss_base);
103 printk ("I/O1 %03x\n", opl3_base);
104 printk ("IRQ %d\n", irq);
105 printk ("DMA0 %d\n", dma1);
106 printk ("DMA1 %d\n", dma2);
107
108 if (opl3_base && opl3_driver)
109 {
110 hw_config.io_base = opl3_base;
111 hw_config.irq = 0;
112 hw_config.dma = -1;
113 hw_config.dma2 = -1;
114 hw_config.always_detect = 0;
115 hw_config.name = "";
116 hw_config.driver_use_1 = 0;
117 hw_config.driver_use_2 = 0;
118 hw_config.osp = NULL;
119
120 if (sndtable_probe (opl3_driver, &hw_config))
121 sndtable_init_card (opl3_driver, &hw_config);
122
123 }
124
125 if (wss_base && wss_driver)
126 {
127 hw_config.io_base = wss_base;
128 hw_config.irq = irq;
129 hw_config.dma = dma1;
130 hw_config.dma2 = (dma2 == NO_DMA) ? dma1 : dma2;
131 hw_config.always_detect = 0;
132 hw_config.name = name;
133 hw_config.driver_use_1 = 0;
134 hw_config.driver_use_2 = 0;
135 hw_config.osp = NULL;
136
137 if (sndtable_probe (wss_driver, &hw_config))
138 sndtable_init_card (wss_driver, &hw_config);
139
140 }
141 }
142 }
143
144 static int
145 pnp_activate (int id, struct pnp_dev *dev)
146 {
147 int i;
148
149 for (i = 0; i < nr_pnpdevs; i++)
150 if (pnp_devs[i]->id == id)
151 {
152
153 printk ("PnP dev: %08x, %s\n", id,
154 pnp_devid2asc (id));
155
156 pnp_devs[i]->setup ((void *) dev);
157 return 1;
158 }
159
160 return 0;
161 }
162
163 void
164 sound_pnp_init (void)
165 {
166 static struct pnp_sounddev cs4232_dev =
167 {PNP_DEVID ('C', 'S', 'C', 0x0000), cs4232_pnp, "CS4232"};
168
169 struct pnp_dev *dev;
170
171 install_pnp_sounddrv (&cs4232_dev);
172
173 dev = NULL;
174
175 if ((pnp_sig = pnp_connect ("sound")) == -1)
176 {
177 printk ("Sound: Can't connect to kernel PnP services.\n");
178 return;
179 }
180
181 while ((dev = pnp_get_next_device (pnp_sig, dev)) != NULL)
182 {
183 if (!pnp_activate (dev->key, dev))
184 {
185
186
187 int i;
188
189 for (i = 0; i < dev->ncompat; i++)
190 if (pnp_activate (dev->compat_keys[i], dev))
191 break;
192 }
193 }
194 }
195
196 void
197 sound_pnp_disconnect (void)
198 {
199 pnp_disconnect (pnp_sig);
200 }
201 #endif