Blame view
sound/drivers/opl4/opl4_proc.c
3.45 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
/* * Functions for the OPL4 proc file * Copyright (c) 2003 by Clemens Ladisch <clemens@ladisch.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "opl4_local.h" #include <linux/vmalloc.h> |
d81a6d717 sound: Add export... |
22 |
#include <linux/export.h> |
1da177e4c Linux-2.6.12-rc2 |
23 24 25 |
#include <sound/info.h> #ifdef CONFIG_PROC_FS |
a42dd420b [ALSA] Remove xxx... |
26 |
static int snd_opl4_mem_proc_open(struct snd_info_entry *entry, |
1da177e4c Linux-2.6.12-rc2 |
27 28 |
unsigned short mode, void **file_private_data) { |
a42dd420b [ALSA] Remove xxx... |
29 |
struct snd_opl4 *opl4 = entry->private_data; |
1da177e4c Linux-2.6.12-rc2 |
30 |
|
ef9f0a42d [ALSA] semaphore ... |
31 |
mutex_lock(&opl4->access_mutex); |
1da177e4c Linux-2.6.12-rc2 |
32 |
if (opl4->memory_access) { |
ef9f0a42d [ALSA] semaphore ... |
33 |
mutex_unlock(&opl4->access_mutex); |
1da177e4c Linux-2.6.12-rc2 |
34 35 36 |
return -EBUSY; } opl4->memory_access++; |
ef9f0a42d [ALSA] semaphore ... |
37 |
mutex_unlock(&opl4->access_mutex); |
1da177e4c Linux-2.6.12-rc2 |
38 39 |
return 0; } |
a42dd420b [ALSA] Remove xxx... |
40 |
static int snd_opl4_mem_proc_release(struct snd_info_entry *entry, |
1da177e4c Linux-2.6.12-rc2 |
41 42 |
unsigned short mode, void *file_private_data) { |
a42dd420b [ALSA] Remove xxx... |
43 |
struct snd_opl4 *opl4 = entry->private_data; |
1da177e4c Linux-2.6.12-rc2 |
44 |
|
ef9f0a42d [ALSA] semaphore ... |
45 |
mutex_lock(&opl4->access_mutex); |
1da177e4c Linux-2.6.12-rc2 |
46 |
opl4->memory_access--; |
ef9f0a42d [ALSA] semaphore ... |
47 |
mutex_unlock(&opl4->access_mutex); |
1da177e4c Linux-2.6.12-rc2 |
48 49 |
return 0; } |
24e4a1211 ALSA: info - Use ... |
50 51 52 53 |
static ssize_t snd_opl4_mem_proc_read(struct snd_info_entry *entry, void *file_private_data, struct file *file, char __user *_buf, size_t count, loff_t pos) |
1da177e4c Linux-2.6.12-rc2 |
54 |
{ |
a42dd420b [ALSA] Remove xxx... |
55 |
struct snd_opl4 *opl4 = entry->private_data; |
1da177e4c Linux-2.6.12-rc2 |
56 |
char* buf; |
d97e1b782 ALSA: info - Chec... |
57 58 59 60 61 |
buf = vmalloc(count); if (!buf) return -ENOMEM; snd_opl4_read_memory(opl4, buf, pos, count); if (copy_to_user(_buf, buf, count)) { |
1da177e4c Linux-2.6.12-rc2 |
62 |
vfree(buf); |
d97e1b782 ALSA: info - Chec... |
63 |
return -EFAULT; |
1da177e4c Linux-2.6.12-rc2 |
64 |
} |
d97e1b782 ALSA: info - Chec... |
65 66 |
vfree(buf); return count; |
1da177e4c Linux-2.6.12-rc2 |
67 |
} |
24e4a1211 ALSA: info - Use ... |
68 69 70 71 |
static ssize_t snd_opl4_mem_proc_write(struct snd_info_entry *entry, void *file_private_data, struct file *file, const char __user *_buf, |
670ff6abd ALSA: opl4 - Fix ... |
72 |
size_t count, loff_t pos) |
1da177e4c Linux-2.6.12-rc2 |
73 |
{ |
a42dd420b [ALSA] Remove xxx... |
74 |
struct snd_opl4 *opl4 = entry->private_data; |
1da177e4c Linux-2.6.12-rc2 |
75 |
char *buf; |
d97e1b782 ALSA: info - Chec... |
76 77 78 79 |
buf = vmalloc(count); if (!buf) return -ENOMEM; if (copy_from_user(buf, _buf, count)) { |
1da177e4c Linux-2.6.12-rc2 |
80 |
vfree(buf); |
d97e1b782 ALSA: info - Chec... |
81 |
return -EFAULT; |
1da177e4c Linux-2.6.12-rc2 |
82 |
} |
d97e1b782 ALSA: info - Chec... |
83 84 85 |
snd_opl4_write_memory(opl4, buf, pos, count); vfree(buf); return count; |
1da177e4c Linux-2.6.12-rc2 |
86 |
} |
1da177e4c Linux-2.6.12-rc2 |
87 88 89 90 91 |
static struct snd_info_entry_ops snd_opl4_mem_proc_ops = { .open = snd_opl4_mem_proc_open, .release = snd_opl4_mem_proc_release, .read = snd_opl4_mem_proc_read, .write = snd_opl4_mem_proc_write, |
1da177e4c Linux-2.6.12-rc2 |
92 |
}; |
a42dd420b [ALSA] Remove xxx... |
93 |
int snd_opl4_create_proc(struct snd_opl4 *opl4) |
1da177e4c Linux-2.6.12-rc2 |
94 |
{ |
a42dd420b [ALSA] Remove xxx... |
95 |
struct snd_info_entry *entry; |
1da177e4c Linux-2.6.12-rc2 |
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
entry = snd_info_create_card_entry(opl4->card, "opl4-mem", opl4->card->proc_root); if (entry) { if (opl4->hardware < OPL3_HW_OPL4_ML) { /* OPL4 can access 4 MB external ROM/SRAM */ entry->mode |= S_IWUSR; entry->size = 4 * 1024 * 1024; } else { /* OPL4-ML has 1 MB internal ROM */ entry->size = 1 * 1024 * 1024; } entry->content = SNDRV_INFO_CONTENT_DATA; entry->c.ops = &snd_opl4_mem_proc_ops; entry->module = THIS_MODULE; entry->private_data = opl4; if (snd_info_register(entry) < 0) { snd_info_free_entry(entry); entry = NULL; } } opl4->proc_entry = entry; return 0; } |
a42dd420b [ALSA] Remove xxx... |
119 |
void snd_opl4_free_proc(struct snd_opl4 *opl4) |
1da177e4c Linux-2.6.12-rc2 |
120 |
{ |
746d4a02e [ALSA] Fix discon... |
121 |
snd_info_free_entry(opl4->proc_entry); |
1da177e4c Linux-2.6.12-rc2 |
122 123 124 |
} #endif /* CONFIG_PROC_FS */ |