• Home
  • Raw
  • Download

Lines Matching refs:opl4

32 static void inline snd_opl4_wait(struct snd_opl4 *opl4)  in snd_opl4_wait()  argument
35 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0) in snd_opl4_wait()
39 void snd_opl4_write(struct snd_opl4 *opl4, u8 reg, u8 value) in snd_opl4_write() argument
41 snd_opl4_wait(opl4); in snd_opl4_write()
42 outb(reg, opl4->pcm_port); in snd_opl4_write()
44 snd_opl4_wait(opl4); in snd_opl4_write()
45 outb(value, opl4->pcm_port + 1); in snd_opl4_write()
50 u8 snd_opl4_read(struct snd_opl4 *opl4, u8 reg) in snd_opl4_read() argument
52 snd_opl4_wait(opl4); in snd_opl4_read()
53 outb(reg, opl4->pcm_port); in snd_opl4_read()
55 snd_opl4_wait(opl4); in snd_opl4_read()
56 return inb(opl4->pcm_port + 1); in snd_opl4_read()
61 void snd_opl4_read_memory(struct snd_opl4 *opl4, char *buf, int offset, int size) in snd_opl4_read_memory() argument
66 spin_lock_irqsave(&opl4->reg_lock, flags); in snd_opl4_read_memory()
68 memcfg = snd_opl4_read(opl4, OPL4_REG_MEMORY_CONFIGURATION); in snd_opl4_read_memory()
69 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg | OPL4_MODE_BIT); in snd_opl4_read_memory()
71 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_HIGH, offset >> 16); in snd_opl4_read_memory()
72 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_MID, offset >> 8); in snd_opl4_read_memory()
73 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_LOW, offset); in snd_opl4_read_memory()
75 snd_opl4_wait(opl4); in snd_opl4_read_memory()
76 outb(OPL4_REG_MEMORY_DATA, opl4->pcm_port); in snd_opl4_read_memory()
77 snd_opl4_wait(opl4); in snd_opl4_read_memory()
78 insb(opl4->pcm_port + 1, buf, size); in snd_opl4_read_memory()
80 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg); in snd_opl4_read_memory()
82 spin_unlock_irqrestore(&opl4->reg_lock, flags); in snd_opl4_read_memory()
87 void snd_opl4_write_memory(struct snd_opl4 *opl4, const char *buf, int offset, int size) in snd_opl4_write_memory() argument
92 spin_lock_irqsave(&opl4->reg_lock, flags); in snd_opl4_write_memory()
94 memcfg = snd_opl4_read(opl4, OPL4_REG_MEMORY_CONFIGURATION); in snd_opl4_write_memory()
95 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg | OPL4_MODE_BIT); in snd_opl4_write_memory()
97 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_HIGH, offset >> 16); in snd_opl4_write_memory()
98 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_MID, offset >> 8); in snd_opl4_write_memory()
99 snd_opl4_write(opl4, OPL4_REG_MEMORY_ADDRESS_LOW, offset); in snd_opl4_write_memory()
101 snd_opl4_wait(opl4); in snd_opl4_write_memory()
102 outb(OPL4_REG_MEMORY_DATA, opl4->pcm_port); in snd_opl4_write_memory()
103 snd_opl4_wait(opl4); in snd_opl4_write_memory()
104 outsb(opl4->pcm_port + 1, buf, size); in snd_opl4_write_memory()
106 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, memcfg); in snd_opl4_write_memory()
108 spin_unlock_irqrestore(&opl4->reg_lock, flags); in snd_opl4_write_memory()
113 static void snd_opl4_enable_opl4(struct snd_opl4 *opl4) in snd_opl4_enable_opl4() argument
115 outb(OPL3_REG_MODE, opl4->fm_port + 2); in snd_opl4_enable_opl4()
116 inb(opl4->fm_port); in snd_opl4_enable_opl4()
117 inb(opl4->fm_port); in snd_opl4_enable_opl4()
118 outb(OPL3_OPL3_ENABLE | OPL3_OPL4_ENABLE, opl4->fm_port + 3); in snd_opl4_enable_opl4()
119 inb(opl4->fm_port); in snd_opl4_enable_opl4()
120 inb(opl4->fm_port); in snd_opl4_enable_opl4()
123 static int snd_opl4_detect(struct snd_opl4 *opl4) in snd_opl4_detect() argument
127 snd_opl4_enable_opl4(opl4); in snd_opl4_detect()
129 id1 = snd_opl4_read(opl4, OPL4_REG_MEMORY_CONFIGURATION); in snd_opl4_detect()
133 opl4->hardware = OPL3_HW_OPL4; in snd_opl4_detect()
136 opl4->hardware = OPL3_HW_OPL4_ML; in snd_opl4_detect()
142 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_FM, 0x00); in snd_opl4_detect()
143 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_PCM, 0xff); in snd_opl4_detect()
144 id1 = snd_opl4_read(opl4, OPL4_REG_MIX_CONTROL_FM); in snd_opl4_detect()
145 id2 = snd_opl4_read(opl4, OPL4_REG_MIX_CONTROL_PCM); in snd_opl4_detect()
150 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_FM, 0x3f); in snd_opl4_detect()
151 snd_opl4_write(opl4, OPL4_REG_MIX_CONTROL_PCM, 0x3f); in snd_opl4_detect()
152 snd_opl4_write(opl4, OPL4_REG_MEMORY_CONFIGURATION, 0x00); in snd_opl4_detect()
159 struct snd_opl4 *opl4 = seq_dev->private_data; in snd_opl4_seq_dev_free() local
160 opl4->seq_dev = NULL; in snd_opl4_seq_dev_free()
163 static int snd_opl4_create_seq_dev(struct snd_opl4 *opl4, int seq_device) in snd_opl4_create_seq_dev() argument
165 opl4->seq_dev_num = seq_device; in snd_opl4_create_seq_dev()
166 if (snd_seq_device_new(opl4->card, seq_device, SNDRV_SEQ_DEV_ID_OPL4, in snd_opl4_create_seq_dev()
167 sizeof(struct snd_opl4 *), &opl4->seq_dev) >= 0) { in snd_opl4_create_seq_dev()
168 strcpy(opl4->seq_dev->name, "OPL4 Wavetable"); in snd_opl4_create_seq_dev()
169 *(struct snd_opl4 **)SNDRV_SEQ_DEVICE_ARGPTR(opl4->seq_dev) = opl4; in snd_opl4_create_seq_dev()
170 opl4->seq_dev->private_data = opl4; in snd_opl4_create_seq_dev()
171 opl4->seq_dev->private_free = snd_opl4_seq_dev_free; in snd_opl4_create_seq_dev()
177 static void snd_opl4_free(struct snd_opl4 *opl4) in snd_opl4_free() argument
179 snd_opl4_free_proc(opl4); in snd_opl4_free()
180 release_and_free_resource(opl4->res_fm_port); in snd_opl4_free()
181 release_and_free_resource(opl4->res_pcm_port); in snd_opl4_free()
182 kfree(opl4); in snd_opl4_free()
187 struct snd_opl4 *opl4 = device->device_data; in snd_opl4_dev_free() local
188 snd_opl4_free(opl4); in snd_opl4_dev_free()
197 struct snd_opl4 *opl4; in snd_opl4_create() local
209 opl4 = kzalloc(sizeof(*opl4), GFP_KERNEL); in snd_opl4_create()
210 if (!opl4) in snd_opl4_create()
213 opl4->res_fm_port = request_region(fm_port, 8, "OPL4 FM"); in snd_opl4_create()
214 opl4->res_pcm_port = request_region(pcm_port, 8, "OPL4 PCM/MIX"); in snd_opl4_create()
215 if (!opl4->res_fm_port || !opl4->res_pcm_port) { in snd_opl4_create()
217 snd_opl4_free(opl4); in snd_opl4_create()
221 opl4->card = card; in snd_opl4_create()
222 opl4->fm_port = fm_port; in snd_opl4_create()
223 opl4->pcm_port = pcm_port; in snd_opl4_create()
224 spin_lock_init(&opl4->reg_lock); in snd_opl4_create()
225 mutex_init(&opl4->access_mutex); in snd_opl4_create()
227 err = snd_opl4_detect(opl4); in snd_opl4_create()
229 snd_opl4_free(opl4); in snd_opl4_create()
234 err = snd_device_new(card, SNDRV_DEV_CODEC, opl4, &ops); in snd_opl4_create()
236 snd_opl4_free(opl4); in snd_opl4_create()
240 err = snd_opl3_create(card, fm_port, fm_port + 2, opl4->hardware, 1, &opl3); in snd_opl4_create()
242 snd_device_free(card, opl4); in snd_opl4_create()
247 snd_opl4_enable_opl4(opl4); in snd_opl4_create()
249 snd_opl4_create_mixer(opl4); in snd_opl4_create()
250 snd_opl4_create_proc(opl4); in snd_opl4_create()
253 opl4->seq_client = -1; in snd_opl4_create()
254 if (opl4->hardware < OPL3_HW_OPL4_ML) in snd_opl4_create()
255 snd_opl4_create_seq_dev(opl4, seq_device); in snd_opl4_create()
261 *ropl4 = opl4; in snd_opl4_create()