2 * Functions for the OPL4 proc file
3 * Copyright (c) 2003 by Clemens Ladisch <clemens@ladisch.de>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "opl4_local.h"
21 #include <linux/vmalloc.h>
22 #include <sound/info.h>
26 static int snd_opl4_mem_proc_open(struct snd_info_entry
*entry
,
27 unsigned short mode
, void **file_private_data
)
29 struct snd_opl4
*opl4
= entry
->private_data
;
31 mutex_lock(&opl4
->access_mutex
);
32 if (opl4
->memory_access
) {
33 mutex_unlock(&opl4
->access_mutex
);
36 opl4
->memory_access
++;
37 mutex_unlock(&opl4
->access_mutex
);
41 static int snd_opl4_mem_proc_release(struct snd_info_entry
*entry
,
42 unsigned short mode
, void *file_private_data
)
44 struct snd_opl4
*opl4
= entry
->private_data
;
46 mutex_lock(&opl4
->access_mutex
);
47 opl4
->memory_access
--;
48 mutex_unlock(&opl4
->access_mutex
);
52 static ssize_t
snd_opl4_mem_proc_read(struct snd_info_entry
*entry
,
53 void *file_private_data
,
54 struct file
*file
, char __user
*_buf
,
55 size_t count
, loff_t pos
)
57 struct snd_opl4
*opl4
= entry
->private_data
;
63 snd_opl4_read_memory(opl4
, buf
, pos
, count
);
64 if (copy_to_user(_buf
, buf
, count
)) {
72 static ssize_t
snd_opl4_mem_proc_write(struct snd_info_entry
*entry
,
73 void *file_private_data
,
75 const char __user
*_buf
,
76 size_t count
, loff_t pos
)
78 struct snd_opl4
*opl4
= entry
->private_data
;
84 if (copy_from_user(buf
, _buf
, count
)) {
88 snd_opl4_write_memory(opl4
, buf
, pos
, count
);
93 static struct snd_info_entry_ops snd_opl4_mem_proc_ops
= {
94 .open
= snd_opl4_mem_proc_open
,
95 .release
= snd_opl4_mem_proc_release
,
96 .read
= snd_opl4_mem_proc_read
,
97 .write
= snd_opl4_mem_proc_write
,
100 int snd_opl4_create_proc(struct snd_opl4
*opl4
)
102 struct snd_info_entry
*entry
;
104 entry
= snd_info_create_card_entry(opl4
->card
, "opl4-mem", opl4
->card
->proc_root
);
106 if (opl4
->hardware
< OPL3_HW_OPL4_ML
) {
107 /* OPL4 can access 4 MB external ROM/SRAM */
108 entry
->mode
|= S_IWUSR
;
109 entry
->size
= 4 * 1024 * 1024;
111 /* OPL4-ML has 1 MB internal ROM */
112 entry
->size
= 1 * 1024 * 1024;
114 entry
->content
= SNDRV_INFO_CONTENT_DATA
;
115 entry
->c
.ops
= &snd_opl4_mem_proc_ops
;
116 entry
->module
= THIS_MODULE
;
117 entry
->private_data
= opl4
;
118 if (snd_info_register(entry
) < 0) {
119 snd_info_free_entry(entry
);
123 opl4
->proc_entry
= entry
;
127 void snd_opl4_free_proc(struct snd_opl4
*opl4
)
129 snd_info_free_entry(opl4
->proc_entry
);
132 #endif /* CONFIG_PROC_FS */