blob: 8899affe91558ba2e0f054ef1f48006436a5b1b0 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#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>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010/*
11 * registered device information
12 */
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014struct snd_seq_device {
15 /* device info */
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010016 struct snd_card *card; /* sound card */
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 int device; /* device number */
Takashi Iwaiaf03c242015-02-12 13:40:50 +010018 const char *id; /* driver id */
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 char name[80]; /* device name */
20 int argsize; /* size of the argument */
21 void *driver_data; /* private data for driver */
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 void *private_data; /* private data for the caller */
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010023 void (*private_free)(struct snd_seq_device *device);
Takashi Iwai7c37ae52015-02-12 10:51:59 +010024 struct device dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025};
26
Takashi Iwai7c37ae52015-02-12 10:51:59 +010027#define to_seq_dev(_dev) \
28 container_of(_dev, struct snd_seq_device, dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Takashi Iwai05662202015-02-12 13:43:22 +010030/* sequencer driver */
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032/* driver operators
Takashi Iwai05662202015-02-12 13:43:22 +010033 * probe:
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 * 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 *
Takashi Iwai05662202015-02-12 13:43:22 +010041 * remove:
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 * Release the private data.
43 * Typically, call snd_device_free(dev->card, dev->driver_data)
44 */
Takashi Iwai05662202015-02-12 13:43:22 +010045struct snd_seq_driver {
46 struct device_driver driver;
47 char *id;
48 int argsize;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049};
50
Takashi Iwai05662202015-02-12 13:43:22 +010051#define to_seq_drv(_drv) \
52 container_of(_drv, struct snd_seq_driver, driver)
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054/*
55 * prototypes
56 */
Takashi Iwai72496ed2015-02-11 22:39:51 +010057#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -070058void snd_seq_device_load_drivers(void);
Takashi Iwai72496ed2015-02-11 22:39:51 +010059#else
60#define snd_seq_device_load_drivers()
61#endif
Takashi Iwaiaf03c242015-02-12 13:40:50 +010062int snd_seq_device_new(struct snd_card *card, int device, const char *id,
63 int argsize, struct snd_seq_device **result);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Takashi Iwaic7e0b5b2005-11-17 14:04:02 +010065#define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device))
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Takashi Iwai05662202015-02-12 13:43:22 +010067int __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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#endif /* __SOUND_SEQ_DEVICE_H */