~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/isa/gus/gus_dram.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  4  *  DRAM access routines
  5  */
  6 
  7 #include <linux/time.h>
  8 #include <sound/core.h>
  9 #include <sound/gus.h>
 10 #include <sound/info.h>
 11 
 12 
 13 static int snd_gus_dram_poke(struct snd_gus_card *gus, char __user *_buffer,
 14                              unsigned int address, unsigned int size)
 15 {
 16         unsigned long flags;
 17         unsigned int size1, size2;
 18         char buffer[256], *pbuffer;
 19 
 20         while (size > 0) {
 21                 size1 = size > sizeof(buffer) ? sizeof(buffer) : size;
 22                 if (copy_from_user(buffer, _buffer, size1))
 23                         return -EFAULT;
 24                 if (gus->interwave) {
 25                         spin_lock_irqsave(&gus->reg_lock, flags);
 26                         snd_gf1_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, 0x01);
 27                         snd_gf1_dram_addr(gus, address);
 28                         outsb(GUSP(gus, DRAM), buffer, size1);
 29                         spin_unlock_irqrestore(&gus->reg_lock, flags);
 30                         address += size1;
 31                 } else {
 32                         pbuffer = buffer;
 33                         size2 = size1;
 34                         while (size2--)
 35                                 snd_gf1_poke(gus, address++, *pbuffer++);
 36                 }
 37                 size -= size1;
 38                 _buffer += size1;
 39         }
 40         return 0;
 41 }
 42 
 43 
 44 int snd_gus_dram_write(struct snd_gus_card *gus, char __user *buffer,
 45                        unsigned int address, unsigned int size)
 46 {
 47         return snd_gus_dram_poke(gus, buffer, address, size);
 48 }
 49 
 50 static int snd_gus_dram_peek(struct snd_gus_card *gus, char __user *_buffer,
 51                              unsigned int address, unsigned int size,
 52                              int rom)
 53 {
 54         unsigned long flags;
 55         unsigned int size1, size2;
 56         char buffer[256], *pbuffer;
 57 
 58         while (size > 0) {
 59                 size1 = size > sizeof(buffer) ? sizeof(buffer) : size;
 60                 if (gus->interwave) {
 61                         spin_lock_irqsave(&gus->reg_lock, flags);
 62                         snd_gf1_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, rom ? 0x03 : 0x01);
 63                         snd_gf1_dram_addr(gus, address);
 64                         insb(GUSP(gus, DRAM), buffer, size1);
 65                         snd_gf1_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, 0x01);
 66                         spin_unlock_irqrestore(&gus->reg_lock, flags);
 67                         address += size1;
 68                 } else {
 69                         pbuffer = buffer;
 70                         size2 = size1;
 71                         while (size2--)
 72                                 *pbuffer++ = snd_gf1_peek(gus, address++);
 73                 }
 74                 if (copy_to_user(_buffer, buffer, size1))
 75                         return -EFAULT;
 76                 size -= size1;
 77                 _buffer += size1;
 78         }
 79         return 0;
 80 }
 81 
 82 int snd_gus_dram_read(struct snd_gus_card *gus, char __user *buffer,
 83                       unsigned int address, unsigned int size,
 84                       int rom)
 85 {
 86         return snd_gus_dram_peek(gus, buffer, address, size, rom);
 87 }
 88 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php