Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | /* |
| 11 | * registered device information |
| 12 | */ |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | struct snd_seq_device { |
| 15 | /* device info */ |
Takashi Iwai | c7e0b5b | 2005-11-17 14:04:02 +0100 | [diff] [blame] | 16 | struct snd_card *card; /* sound card */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | int device; /* device number */ |
Takashi Iwai | af03c24 | 2015-02-12 13:40:50 +0100 | [diff] [blame] | 18 | const char *id; /* driver id */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | char name[80]; /* device name */ |
| 20 | int argsize; /* size of the argument */ |
| 21 | void *driver_data; /* private data for driver */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | void *private_data; /* private data for the caller */ |
Takashi Iwai | c7e0b5b | 2005-11-17 14:04:02 +0100 | [diff] [blame] | 23 | void (*private_free)(struct snd_seq_device *device); |
Takashi Iwai | 7c37ae5 | 2015-02-12 10:51:59 +0100 | [diff] [blame] | 24 | struct device dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | }; |
| 26 | |
Takashi Iwai | 7c37ae5 | 2015-02-12 10:51:59 +0100 | [diff] [blame] | 27 | #define to_seq_dev(_dev) \ |
| 28 | container_of(_dev, struct snd_seq_device, dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Takashi Iwai | 0566220 | 2015-02-12 13:43:22 +0100 | [diff] [blame] | 30 | /* sequencer driver */ |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | /* driver operators |
Takashi Iwai | 0566220 | 2015-02-12 13:43:22 +0100 | [diff] [blame] | 33 | * probe: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Takashi Iwai | 0566220 | 2015-02-12 13:43:22 +0100 | [diff] [blame] | 41 | * remove: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | * Release the private data. |
| 43 | * Typically, call snd_device_free(dev->card, dev->driver_data) |
| 44 | */ |
Takashi Iwai | 0566220 | 2015-02-12 13:43:22 +0100 | [diff] [blame] | 45 | struct snd_seq_driver { |
| 46 | struct device_driver driver; |
| 47 | char *id; |
| 48 | int argsize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Takashi Iwai | 0566220 | 2015-02-12 13:43:22 +0100 | [diff] [blame] | 51 | #define to_seq_drv(_drv) \ |
| 52 | container_of(_drv, struct snd_seq_driver, driver) |
| 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | /* |
| 55 | * prototypes |
| 56 | */ |
Takashi Iwai | 72496ed | 2015-02-11 22:39:51 +0100 | [diff] [blame] | 57 | #ifdef CONFIG_MODULES |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | void snd_seq_device_load_drivers(void); |
Takashi Iwai | 72496ed | 2015-02-11 22:39:51 +0100 | [diff] [blame] | 59 | #else |
| 60 | #define snd_seq_device_load_drivers() |
| 61 | #endif |
Takashi Iwai | af03c24 | 2015-02-12 13:40:50 +0100 | [diff] [blame] | 62 | int snd_seq_device_new(struct snd_card *card, int device, const char *id, |
| 63 | int argsize, struct snd_seq_device **result); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Takashi Iwai | c7e0b5b | 2005-11-17 14:04:02 +0100 | [diff] [blame] | 65 | #define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
Takashi Iwai | 0566220 | 2015-02-12 13:43:22 +0100 | [diff] [blame] | 67 | int __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) |
| 71 | void 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #endif /* __SOUND_SEQ_DEVICE_H */ |