24 #include <linux/slab.h>
25 #include <linux/time.h>
27 #include <linux/module.h>
41 static int snd_hwdep_free(
struct snd_hwdep *hwdep);
52 if (hwdep->card == card && hwdep->device == device)
61 return hw->
ops.llseek(hw, file, offset, orig);
65 static ssize_t snd_hwdep_read(
struct file * file,
char __user *
buf,
66 size_t count, loff_t *offset)
70 return hw->
ops.read(hw, buf, count, offset);
74 static ssize_t snd_hwdep_write(
struct file * file,
const char __user *buf,
75 size_t count, loff_t *offset)
79 return hw->
ops.write(hw, buf, count, offset);
83 static int snd_hwdep_open(
struct inode *
inode,
struct file * file)
85 int major = imajor(inode);
93 #ifdef CONFIG_SND_OSSEMUL
95 hw = snd_lookup_oss_minor_data(iminor(inode),
96 SNDRV_OSS_DEVICE_TYPE_DMFM);
103 if (!try_module_get(hw->
card->module)) {
108 init_waitqueue_entry(&wait,
current);
120 err = hw->
ops.open(hw, file);
134 if (hw->
card->shutdown) {
151 hw->
ops.release(hw, file);
156 module_put(hw->
card->module);
161 static int snd_hwdep_release(
struct inode *inode,
struct file * file)
169 err = hw->
ops.release(hw, file);
180 static unsigned int snd_hwdep_poll(
struct file * file,
poll_table * wait)
184 return hw->
ops.poll(hw, file, wait);
209 if (! hw->
ops.dsp_status)
213 if ((err = hw->
ops.dsp_status(hw, &
info)) < 0)
220 static int snd_hwdep_dsp_load(
struct snd_hwdep *hw,
226 if (! hw->
ops.dsp_load)
236 err = hw->
ops.dsp_load(hw, &
info);
243 static long snd_hwdep_ioctl(
struct file * file,
unsigned int cmd,
256 return snd_hwdep_dsp_load(hw, argp);
259 return hw->
ops.ioctl(hw, file, cmd, arg);
263 static int snd_hwdep_mmap(
struct file * file,
struct vm_area_struct * vma)
267 return hw->
ops.mmap(hw, file, vma);
271 static int snd_hwdep_control_ioctl(
struct snd_card *card,
273 unsigned int cmd,
unsigned long arg)
280 if (
get_user(device, (
int __user *)arg))
292 if (snd_hwdep_search(card, device))
299 if (
put_user(device, (
int __user *)arg))
312 hwdep = snd_hwdep_search(card, device);
327 #define snd_hwdep_ioctl_compat NULL
337 .llseek = snd_hwdep_llseek,
338 .read = snd_hwdep_read,
339 .write = snd_hwdep_write,
340 .open = snd_hwdep_open,
341 .release = snd_hwdep_release,
342 .poll = snd_hwdep_poll,
343 .unlocked_ioctl = snd_hwdep_ioctl,
345 .mmap = snd_hwdep_mmap,
368 .dev_register = snd_hwdep_dev_register,
369 .dev_disconnect = snd_hwdep_dev_disconnect,
385 #ifdef CONFIG_SND_OSSEMUL
386 hwdep->oss_type = -1;
389 snd_hwdep_free(hwdep);
399 static int snd_hwdep_free(
struct snd_hwdep *hwdep)
409 static int snd_hwdep_dev_free(
struct snd_device *device)
412 return snd_hwdep_free(hwdep);
415 static int snd_hwdep_dev_register(
struct snd_device *device)
422 if (snd_hwdep_search(hwdep->
card, hwdep->
device)) {
430 &snd_hwdep_f_ops, hwdep, name)) < 0) {
437 #ifdef CONFIG_SND_OSSEMUL
439 if (hwdep->oss_type >= 0) {
440 if ((hwdep->oss_type == SNDRV_OSS_DEVICE_TYPE_DMFM) && (hwdep->
device != 0)) {
443 if (snd_register_oss_device(hwdep->oss_type,
445 &snd_hwdep_f_ops, hwdep,
446 hwdep->oss_dev) < 0) {
458 static int snd_hwdep_dev_disconnect(
struct snd_device *device)
465 if (snd_hwdep_search(hwdep->
card, hwdep->
device) != hwdep) {
471 #ifdef CONFIG_SND_OSSEMUL
473 snd_unregister_oss_device(hwdep->oss_type, hwdep->
card, hwdep->
device);
476 list_del_init(&hwdep->
list);
482 #ifdef CONFIG_PROC_FS
494 snd_iprintf(buffer, "%02
i-%02
i: %
s\
n",
495 hwdep->card->number, hwdep->device, hwdep->name);
505 if ((entry = snd_info_create_module_entry(
THIS_MODULE,
"hwdep", NULL)) != NULL) {
506 entry->
c.
text.read = snd_hwdep_proc_read;
507 if (snd_info_register(entry) < 0) {
508 snd_info_free_entry(entry);
512 snd_hwdep_proc_entry =
entry;
517 snd_info_free_entry(snd_hwdep_proc_entry);
520 #define snd_hwdep_proc_init()
521 #define snd_hwdep_proc_done()
529 static int __init alsa_hwdep_init(
void)
537 static void __exit alsa_hwdep_exit(
void)