^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __SOUND_SEQ_DEVICE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __SOUND_SEQ_DEVICE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * ALSA sequencer device management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (c) 1999 by Takashi Iwai <tiwai@suse.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * registered device information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct snd_seq_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /* device info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct snd_card *card; /* sound card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) int device; /* device number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) const char *id; /* driver id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) char name[80]; /* device name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int argsize; /* size of the argument */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) void *driver_data; /* private data for driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) void *private_data; /* private data for the caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) void (*private_free)(struct snd_seq_device *device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct device dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define to_seq_dev(_dev) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) container_of(_dev, struct snd_seq_device, dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* sequencer driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /* driver operators
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * probe:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * Initialize the device with given parameters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * Typically,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * 1. call snd_hwdep_new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * 2. allocate private data and initialize it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * 3. call snd_hwdep_register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * 4. store the instance to dev->driver_data pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * remove:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * Release the private data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * Typically, call snd_device_free(dev->card, dev->driver_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct snd_seq_driver {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct device_driver driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) char *id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int argsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define to_seq_drv(_drv) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) container_of(_drv, struct snd_seq_driver, driver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * prototypes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #ifdef CONFIG_MODULES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) void snd_seq_device_load_drivers(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define snd_seq_device_load_drivers()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int snd_seq_device_new(struct snd_card *card, int device, const char *id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int argsize, struct snd_seq_device **result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int __must_check __snd_seq_driver_register(struct snd_seq_driver *drv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct module *mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define snd_seq_driver_register(drv) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) __snd_seq_driver_register(drv, THIS_MODULE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) void snd_seq_driver_unregister(struct snd_seq_driver *drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define module_snd_seq_driver(drv) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) module_driver(drv, snd_seq_driver_register, snd_seq_driver_unregister)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * id strings for generic devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define SNDRV_SEQ_DEV_ID_MIDISYNTH "seq-midi"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define SNDRV_SEQ_DEV_ID_OPL3 "opl3-synth"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #endif /* __SOUND_SEQ_DEVICE_H */