Loading...
1#ifndef __SOUND_SEQ_DEVICE_H
2#define __SOUND_SEQ_DEVICE_H
3
4/*
5 * ALSA sequencer device management
6 * Copyright (c) 1999 by Takashi Iwai <tiwai@suse.de>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24/*
25 * registered device information
26 */
27
28#define ID_LEN 32
29
30/* status flag */
31#define SNDRV_SEQ_DEVICE_FREE 0
32#define SNDRV_SEQ_DEVICE_REGISTERED 1
33
34struct snd_seq_device {
35 /* device info */
36 struct snd_card *card; /* sound card */
37 int device; /* device number */
38 char id[ID_LEN]; /* driver id */
39 char name[80]; /* device name */
40 int argsize; /* size of the argument */
41 void *driver_data; /* private data for driver */
42 int status; /* flag - read only */
43 void *private_data; /* private data for the caller */
44 void (*private_free)(struct snd_seq_device *device);
45 struct list_head list; /* link to next device */
46};
47
48
49/* driver operators
50 * init_device:
51 * Initialize the device with given parameters.
52 * Typically,
53 * 1. call snd_hwdep_new
54 * 2. allocate private data and initialize it
55 * 3. call snd_hwdep_register
56 * 4. store the instance to dev->driver_data pointer.
57 *
58 * free_device:
59 * Release the private data.
60 * Typically, call snd_device_free(dev->card, dev->driver_data)
61 */
62struct snd_seq_dev_ops {
63 int (*init_device)(struct snd_seq_device *dev);
64 int (*free_device)(struct snd_seq_device *dev);
65};
66
67/*
68 * prototypes
69 */
70void snd_seq_device_load_drivers(void);
71int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, struct snd_seq_device **result);
72int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, int argsize);
73int snd_seq_device_unregister_driver(char *id);
74
75#define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device))
76
77
78/*
79 * id strings for generic devices
80 */
81#define SNDRV_SEQ_DEV_ID_MIDISYNTH "seq-midi"
82#define SNDRV_SEQ_DEV_ID_OPL3 "opl3-synth"
83
84#endif /* __SOUND_SEQ_DEVICE_H */
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2#ifndef __SOUND_SEQ_DEVICE_H
3#define __SOUND_SEQ_DEVICE_H
4
5/*
6 * ALSA sequencer device management
7 * Copyright (c) 1999 by Takashi Iwai <tiwai@suse.de>
8 */
9
10/*
11 * registered device information
12 */
13
14struct snd_seq_device {
15 /* device info */
16 struct snd_card *card; /* sound card */
17 int device; /* device number */
18 const char *id; /* driver id */
19 char name[80]; /* device name */
20 int argsize; /* size of the argument */
21 void *driver_data; /* private data for driver */
22 void *private_data; /* private data for the caller */
23 void (*private_free)(struct snd_seq_device *device);
24 struct device dev;
25};
26
27#define to_seq_dev(_dev) \
28 container_of(_dev, struct snd_seq_device, dev)
29
30/* sequencer driver */
31
32/* driver operators
33 * probe:
34 * Initialize the device with given parameters.
35 * Typically,
36 * 1. call snd_hwdep_new
37 * 2. allocate private data and initialize it
38 * 3. call snd_hwdep_register
39 * 4. store the instance to dev->driver_data pointer.
40 *
41 * remove:
42 * Release the private data.
43 * Typically, call snd_device_free(dev->card, dev->driver_data)
44 */
45struct snd_seq_driver {
46 struct device_driver driver;
47 char *id;
48 int argsize;
49};
50
51#define to_seq_drv(_drv) \
52 container_of(_drv, struct snd_seq_driver, driver)
53
54/*
55 * prototypes
56 */
57#ifdef CONFIG_MODULES
58void snd_seq_device_load_drivers(void);
59#else
60#define snd_seq_device_load_drivers()
61#endif
62int snd_seq_device_new(struct snd_card *card, int device, const char *id,
63 int argsize, struct snd_seq_device **result);
64
65#define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device))
66
67int __must_check __snd_seq_driver_register(struct snd_seq_driver *drv,
68 struct module *mod);
69#define snd_seq_driver_register(drv) \
70 __snd_seq_driver_register(drv, THIS_MODULE)
71void snd_seq_driver_unregister(struct snd_seq_driver *drv);
72
73#define module_snd_seq_driver(drv) \
74 module_driver(drv, snd_seq_driver_register, snd_seq_driver_unregister)
75
76/*
77 * id strings for generic devices
78 */
79#define SNDRV_SEQ_DEV_ID_MIDISYNTH "seq-midi"
80#define SNDRV_SEQ_DEV_ID_OPL3 "opl3-synth"
81
82#endif /* __SOUND_SEQ_DEVICE_H */