2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/time.h>
23 #include <sound/core.h>
24 #include <sound/gus.h>
25 #include <sound/info.h>
28 static int snd_gus_dram_poke(struct snd_gus_card *gus, char __user *_buffer,
29 unsigned int address, unsigned int size)
32 unsigned int size1, size2;
33 char buffer[256], *pbuffer;
36 size1 = size > sizeof(buffer) ? sizeof(buffer) : size;
37 if (copy_from_user(buffer, _buffer, size1))
40 spin_lock_irqsave(&gus->reg_lock, flags);
41 snd_gf1_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, 0x01);
42 snd_gf1_dram_addr(gus, address);
43 outsb(GUSP(gus, DRAM), buffer, size1);
44 spin_unlock_irqrestore(&gus->reg_lock, flags);
50 snd_gf1_poke(gus, address++, *pbuffer++);
59 int snd_gus_dram_write(struct snd_gus_card *gus, char __user *buffer,
60 unsigned int address, unsigned int size)
62 return snd_gus_dram_poke(gus, buffer, address, size);
65 static int snd_gus_dram_peek(struct snd_gus_card *gus, char __user *_buffer,
66 unsigned int address, unsigned int size,
70 unsigned int size1, size2;
71 char buffer[256], *pbuffer;
74 size1 = size > sizeof(buffer) ? sizeof(buffer) : size;
76 spin_lock_irqsave(&gus->reg_lock, flags);
77 snd_gf1_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, rom ? 0x03 : 0x01);
78 snd_gf1_dram_addr(gus, address);
79 insb(GUSP(gus, DRAM), buffer, size1);
80 snd_gf1_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, 0x01);
81 spin_unlock_irqrestore(&gus->reg_lock, flags);
87 *pbuffer++ = snd_gf1_peek(gus, address++);
89 if (copy_to_user(_buffer, buffer, size1))
97 int snd_gus_dram_read(struct snd_gus_card *gus, char __user *buffer,
98 unsigned int address, unsigned int size,
101 return snd_gus_dram_peek(gus, buffer, address, size, rom);