• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/sound/drivers/opl4/

Lines Matching refs:opl4

30 static void inline snd_opl4_wait(struct snd_opl4 *opl4)
33 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
37 void snd_opl4_write(struct snd_opl4 *opl4, u8 reg, u8 value)
39 snd_opl4_wait(opl4);
40 outb(reg, opl4->pcm_port);
42 snd_opl4_wait(opl4);
43 outb(value, opl4->pcm_port + 1);
48 u8 snd_opl4_read(struct snd_opl4 *opl4, u8 reg)
50 snd_opl4_wait(opl4);
51 outb(reg, opl4->pcm_port);
53 snd_opl4_wait(opl4);
54 return inb(opl4->pcm_port + 1);
59 void snd_opl4_read_memory(struct snd_opl4 *opl4, char *buf, int offset, int size)
64 spin_lock_irqsave(&opl4->reg_lock, flags);
66 memcfg = snd_opl4_read(opl4, OPL4_REG_MEMORY_CONFIGURATION);
67 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg | OPL4_MODE_BIT);
69 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_HIGH, offset >> 16);
70 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_MID, offset >> 8);
71 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_LOW, offset);
73 snd_opl4_wait(opl4);
74 outb(OPL4_REG_MEMORY_DATA, opl4->pcm_port);
75 snd_opl4_wait(opl4);
76 insb(opl4->pcm_port + 1, buf, size);
78 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg);
80 spin_unlock_irqrestore(&opl4->reg_lock, flags);
85 void snd_opl4_write_memory(struct snd_opl4 *opl4, const char *buf, int offset, int size)
90 spin_lock_irqsave(&opl4->reg_lock, flags);
92 memcfg = snd_opl4_read(opl4, OPL4_REG_MEMORY_CONFIGURATION);
93 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg | OPL4_MODE_BIT);
95 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_HIGH, offset >> 16);
96 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_MID, offset >> 8);
97 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_LOW, offset);
99 snd_opl4_wait(opl4);
100 outb(OPL4_REG_MEMORY_DATA, opl4->pcm_port);
101 snd_opl4_wait(opl4);
102 outsb(opl4->pcm_port + 1, buf, size);
104 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg);
106 spin_unlock_irqrestore(&opl4->reg_lock, flags);
111 static void snd_opl4_enable_opl4(struct snd_opl4 *opl4)
113 outb(OPL3_REG_MODE, opl4->fm_port + 2);
114 inb(opl4->fm_port);
115 inb(opl4->fm_port);
116 outb(OPL3_OPL3_ENABLE | OPL3_OPL4_ENABLE, opl4->fm_port + 3);
117 inb(opl4->fm_port);
118 inb(opl4->fm_port);
121 static int snd_opl4_detect(struct snd_opl4 *opl4)
125 snd_opl4_enable_opl4(opl4);
127 id1 = snd_opl4_read(opl4, OPL4_REG_MEMORY_CONFIGURATION);
131 opl4->hardware = OPL3_HW_OPL4;
134 opl4->hardware = OPL3_HW_OPL4_ML;
140 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_FM, 0x00);
141 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_PCM, 0xff);
142 id1 = snd_opl4_read(opl4, OPL4_REG_MIX_CONTROL_FM);
143 id2 = snd_opl4_read(opl4, OPL4_REG_MIX_CONTROL_PCM);
148 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_FM, 0x3f);
149 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_PCM, 0x3f);
150 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, 0x00);
158 struct snd_opl4 *opl4 = seq_dev->private_data;
159 opl4->seq_dev = NULL;
162 static int snd_opl4_create_seq_dev(struct snd_opl4 *opl4, int seq_device)
164 opl4->seq_dev_num = seq_device;
165 if (snd_seq_device_new(opl4->card, seq_device, SNDRV_SEQ_DEV_ID_OPL4,
166 sizeof(struct snd_opl4 *), &opl4->seq_dev) >= 0) {
167 strcpy(opl4->seq_dev->name, "OPL4 Wavetable");
168 *(struct snd_opl4 **)SNDRV_SEQ_DEVICE_ARGPTR(opl4->seq_dev) = opl4;
169 opl4->seq_dev->private_data = opl4;
170 opl4->seq_dev->private_free = snd_opl4_seq_dev_free;
176 static void snd_opl4_free(struct snd_opl4 *opl4)
179 snd_opl4_free_proc(opl4);
181 release_and_free_resource(opl4->res_fm_port);
182 release_and_free_resource(opl4->res_pcm_port);
183 kfree(opl4);
188 struct snd_opl4 *opl4 = device->device_data;
189 snd_opl4_free(opl4);
198 struct snd_opl4 *opl4;
210 opl4 = kzalloc(sizeof(*opl4), GFP_KERNEL);
211 if (!opl4)
214 opl4->res_fm_port = request_region(fm_port, 8, "OPL4 FM");
215 opl4->res_pcm_port = request_region(pcm_port, 8, "OPL4 PCM/MIX");
216 if (!opl4->res_fm_port || !opl4->res_pcm_port) {
217 snd_printk(KERN_ERR "opl4: can't grab ports 0x%lx, 0x%lx\n", fm_port, pcm_port);
218 snd_opl4_free(opl4);
222 opl4->card = card;
223 opl4->fm_port = fm_port;
224 opl4->pcm_port = pcm_port;
225 spin_lock_init(&opl4->reg_lock);
226 mutex_init(&opl4->access_mutex);
228 err = snd_opl4_detect(opl4);
230 snd_opl4_free(opl4);
235 err = snd_device_new(card, SNDRV_DEV_CODEC, opl4, &ops);
237 snd_opl4_free(opl4);
241 err = snd_opl3_create(card, fm_port, fm_port + 2, opl4->hardware, 1, &opl3);
243 snd_device_free(card, opl4);
247 /* opl3 initialization disabled opl4, so reenable */
248 snd_opl4_enable_opl4(opl4);
250 snd_opl4_create_mixer(opl4);
252 snd_opl4_create_proc(opl4);
257 opl4->seq_client = -1;
258 if (opl4->hardware < OPL3_HW_OPL4_ML)
259 snd_opl4_create_seq_dev(opl4, seq_device);
265 *ropl4 = opl4;