Lines Matching refs:opl4

19 static inline void snd_opl4_wait(struct snd_opl4 *opl4)  in snd_opl4_wait()  argument
22 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0) in snd_opl4_wait()
26 void snd_opl4_write(struct snd_opl4 *opl4, u8 reg, u8 value) in snd_opl4_write() argument
28 snd_opl4_wait(opl4); in snd_opl4_write()
29 outb(reg, opl4->pcm_port); in snd_opl4_write()
31 snd_opl4_wait(opl4); in snd_opl4_write()
32 outb(value, opl4->pcm_port + 1); in snd_opl4_write()
37 u8 snd_opl4_read(struct snd_opl4 *opl4, u8 reg) in snd_opl4_read() argument
39 snd_opl4_wait(opl4); in snd_opl4_read()
40 outb(reg, opl4->pcm_port); in snd_opl4_read()
42 snd_opl4_wait(opl4); in snd_opl4_read()
43 return inb(opl4->pcm_port + 1); in snd_opl4_read()
48 void snd_opl4_read_memory(struct snd_opl4 *opl4, char *buf, int offset, int size) in snd_opl4_read_memory() argument
53 spin_lock_irqsave(&opl4->reg_lock, flags); in snd_opl4_read_memory()
55 memcfg = snd_opl4_read(opl4, OPL4_REG_MEMORY_CONFIGURATION); in snd_opl4_read_memory()
56 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg | OPL4_MODE_BIT); in snd_opl4_read_memory()
58 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_HIGH, offset >> 16); in snd_opl4_read_memory()
59 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_MID, offset >> 8); in snd_opl4_read_memory()
60 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_LOW, offset); in snd_opl4_read_memory()
62 snd_opl4_wait(opl4); in snd_opl4_read_memory()
63 outb(OPL4_REG_MEMORY_DATA, opl4->pcm_port); in snd_opl4_read_memory()
64 snd_opl4_wait(opl4); in snd_opl4_read_memory()
65 insb(opl4->pcm_port + 1, buf, size); in snd_opl4_read_memory()
67 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg); in snd_opl4_read_memory()
69 spin_unlock_irqrestore(&opl4->reg_lock, flags); in snd_opl4_read_memory()
74 void snd_opl4_write_memory(struct snd_opl4 *opl4, const char *buf, int offset, int size) in snd_opl4_write_memory() argument
79 spin_lock_irqsave(&opl4->reg_lock, flags); in snd_opl4_write_memory()
81 memcfg = snd_opl4_read(opl4, OPL4_REG_MEMORY_CONFIGURATION); in snd_opl4_write_memory()
82 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg | OPL4_MODE_BIT); in snd_opl4_write_memory()
84 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_HIGH, offset >> 16); in snd_opl4_write_memory()
85 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_MID, offset >> 8); in snd_opl4_write_memory()
86 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_LOW, offset); in snd_opl4_write_memory()
88 snd_opl4_wait(opl4); in snd_opl4_write_memory()
89 outb(OPL4_REG_MEMORY_DATA, opl4->pcm_port); in snd_opl4_write_memory()
90 snd_opl4_wait(opl4); in snd_opl4_write_memory()
91 outsb(opl4->pcm_port + 1, buf, size); in snd_opl4_write_memory()
93 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg); in snd_opl4_write_memory()
95 spin_unlock_irqrestore(&opl4->reg_lock, flags); in snd_opl4_write_memory()
100 static void snd_opl4_enable_opl4(struct snd_opl4 *opl4) in snd_opl4_enable_opl4() argument
102 outb(OPL3_REG_MODE, opl4->fm_port + 2); in snd_opl4_enable_opl4()
103 inb(opl4->fm_port); in snd_opl4_enable_opl4()
104 inb(opl4->fm_port); in snd_opl4_enable_opl4()
105 outb(OPL3_OPL3_ENABLE | OPL3_OPL4_ENABLE, opl4->fm_port + 3); in snd_opl4_enable_opl4()
106 inb(opl4->fm_port); in snd_opl4_enable_opl4()
107 inb(opl4->fm_port); in snd_opl4_enable_opl4()
110 static int snd_opl4_detect(struct snd_opl4 *opl4) in snd_opl4_detect() argument
114 snd_opl4_enable_opl4(opl4); in snd_opl4_detect()
116 id1 = snd_opl4_read(opl4, OPL4_REG_MEMORY_CONFIGURATION); in snd_opl4_detect()
120 opl4->hardware = OPL3_HW_OPL4; in snd_opl4_detect()
123 opl4->hardware = OPL3_HW_OPL4_ML; in snd_opl4_detect()
129 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_FM, 0x00); in snd_opl4_detect()
130 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_PCM, 0xff); in snd_opl4_detect()
131 id1 = snd_opl4_read(opl4, OPL4_REG_MIX_CONTROL_FM); in snd_opl4_detect()
132 id2 = snd_opl4_read(opl4, OPL4_REG_MIX_CONTROL_PCM); in snd_opl4_detect()
137 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_FM, 0x3f); in snd_opl4_detect()
138 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_PCM, 0x3f); in snd_opl4_detect()
139 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, 0x00); in snd_opl4_detect()
146 struct snd_opl4 *opl4 = seq_dev->private_data; in snd_opl4_seq_dev_free() local
147 opl4->seq_dev = NULL; in snd_opl4_seq_dev_free()
150 static int snd_opl4_create_seq_dev(struct snd_opl4 *opl4, int seq_device) in snd_opl4_create_seq_dev() argument
152 opl4->seq_dev_num = seq_device; in snd_opl4_create_seq_dev()
153 if (snd_seq_device_new(opl4->card, seq_device, SNDRV_SEQ_DEV_ID_OPL4, in snd_opl4_create_seq_dev()
154 sizeof(struct snd_opl4 *), &opl4->seq_dev) >= 0) { in snd_opl4_create_seq_dev()
155 strcpy(opl4->seq_dev->name, "OPL4 Wavetable"); in snd_opl4_create_seq_dev()
156 *(struct snd_opl4 **)SNDRV_SEQ_DEVICE_ARGPTR(opl4->seq_dev) = opl4; in snd_opl4_create_seq_dev()
157 opl4->seq_dev->private_data = opl4; in snd_opl4_create_seq_dev()
158 opl4->seq_dev->private_free = snd_opl4_seq_dev_free; in snd_opl4_create_seq_dev()
164 static void snd_opl4_free(struct snd_opl4 *opl4) in snd_opl4_free() argument
166 snd_opl4_free_proc(opl4); in snd_opl4_free()
167 release_and_free_resource(opl4->res_fm_port); in snd_opl4_free()
168 release_and_free_resource(opl4->res_pcm_port); in snd_opl4_free()
169 kfree(opl4); in snd_opl4_free()
174 struct snd_opl4 *opl4 = device->device_data; in snd_opl4_dev_free() local
175 snd_opl4_free(opl4); in snd_opl4_dev_free()
184 struct snd_opl4 *opl4; in snd_opl4_create() local
196 opl4 = kzalloc(sizeof(*opl4), GFP_KERNEL); in snd_opl4_create()
197 if (!opl4) in snd_opl4_create()
200 opl4->res_fm_port = request_region(fm_port, 8, "OPL4 FM"); in snd_opl4_create()
201 opl4->res_pcm_port = request_region(pcm_port, 8, "OPL4 PCM/MIX"); in snd_opl4_create()
202 if (!opl4->res_fm_port || !opl4->res_pcm_port) { in snd_opl4_create()
204 snd_opl4_free(opl4); in snd_opl4_create()
208 opl4->card = card; in snd_opl4_create()
209 opl4->fm_port = fm_port; in snd_opl4_create()
210 opl4->pcm_port = pcm_port; in snd_opl4_create()
211 spin_lock_init(&opl4->reg_lock); in snd_opl4_create()
212 mutex_init(&opl4->access_mutex); in snd_opl4_create()
214 err = snd_opl4_detect(opl4); in snd_opl4_create()
216 snd_opl4_free(opl4); in snd_opl4_create()
221 err = snd_device_new(card, SNDRV_DEV_CODEC, opl4, &ops); in snd_opl4_create()
223 snd_opl4_free(opl4); in snd_opl4_create()
227 err = snd_opl3_create(card, fm_port, fm_port + 2, opl4->hardware, 1, &opl3); in snd_opl4_create()
229 snd_device_free(card, opl4); in snd_opl4_create()
234 snd_opl4_enable_opl4(opl4); in snd_opl4_create()
236 snd_opl4_create_mixer(opl4); in snd_opl4_create()
237 snd_opl4_create_proc(opl4); in snd_opl4_create()
240 opl4->seq_client = -1; in snd_opl4_create()
241 if (opl4->hardware < OPL3_HW_OPL4_ML) in snd_opl4_create()
242 snd_opl4_create_seq_dev(opl4, seq_device); in snd_opl4_create()
248 *ropl4 = opl4; in snd_opl4_create()