18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci#ifndef __SOUND_SEQ_DEVICE_H
38c2ecf20Sopenharmony_ci#define __SOUND_SEQ_DEVICE_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/*
68c2ecf20Sopenharmony_ci *  ALSA sequencer device management
78c2ecf20Sopenharmony_ci *  Copyright (c) 1999 by Takashi Iwai <tiwai@suse.de>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/*
118c2ecf20Sopenharmony_ci * registered device information
128c2ecf20Sopenharmony_ci */
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistruct snd_seq_device {
158c2ecf20Sopenharmony_ci	/* device info */
168c2ecf20Sopenharmony_ci	struct snd_card *card;	/* sound card */
178c2ecf20Sopenharmony_ci	int device;		/* device number */
188c2ecf20Sopenharmony_ci	const char *id;		/* driver id */
198c2ecf20Sopenharmony_ci	char name[80];		/* device name */
208c2ecf20Sopenharmony_ci	int argsize;		/* size of the argument */
218c2ecf20Sopenharmony_ci	void *driver_data;	/* private data for driver */
228c2ecf20Sopenharmony_ci	void *private_data;	/* private data for the caller */
238c2ecf20Sopenharmony_ci	void (*private_free)(struct snd_seq_device *device);
248c2ecf20Sopenharmony_ci	struct device dev;
258c2ecf20Sopenharmony_ci};
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define to_seq_dev(_dev) \
288c2ecf20Sopenharmony_ci	container_of(_dev, struct snd_seq_device, dev)
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/* sequencer driver */
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* driver operators
338c2ecf20Sopenharmony_ci * probe:
348c2ecf20Sopenharmony_ci *	Initialize the device with given parameters.
358c2ecf20Sopenharmony_ci *	Typically,
368c2ecf20Sopenharmony_ci *		1. call snd_hwdep_new
378c2ecf20Sopenharmony_ci *		2. allocate private data and initialize it
388c2ecf20Sopenharmony_ci *		3. call snd_hwdep_register
398c2ecf20Sopenharmony_ci *		4. store the instance to dev->driver_data pointer.
408c2ecf20Sopenharmony_ci *
418c2ecf20Sopenharmony_ci * remove:
428c2ecf20Sopenharmony_ci *	Release the private data.
438c2ecf20Sopenharmony_ci *	Typically, call snd_device_free(dev->card, dev->driver_data)
448c2ecf20Sopenharmony_ci */
458c2ecf20Sopenharmony_cistruct snd_seq_driver {
468c2ecf20Sopenharmony_ci	struct device_driver driver;
478c2ecf20Sopenharmony_ci	char *id;
488c2ecf20Sopenharmony_ci	int argsize;
498c2ecf20Sopenharmony_ci};
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define to_seq_drv(_drv) \
528c2ecf20Sopenharmony_ci	container_of(_drv, struct snd_seq_driver, driver)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/*
558c2ecf20Sopenharmony_ci * prototypes
568c2ecf20Sopenharmony_ci */
578c2ecf20Sopenharmony_ci#ifdef CONFIG_MODULES
588c2ecf20Sopenharmony_civoid snd_seq_device_load_drivers(void);
598c2ecf20Sopenharmony_ci#else
608c2ecf20Sopenharmony_ci#define snd_seq_device_load_drivers()
618c2ecf20Sopenharmony_ci#endif
628c2ecf20Sopenharmony_ciint snd_seq_device_new(struct snd_card *card, int device, const char *id,
638c2ecf20Sopenharmony_ci		       int argsize, struct snd_seq_device **result);
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device))
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ciint __must_check __snd_seq_driver_register(struct snd_seq_driver *drv,
688c2ecf20Sopenharmony_ci					   struct module *mod);
698c2ecf20Sopenharmony_ci#define snd_seq_driver_register(drv) \
708c2ecf20Sopenharmony_ci	__snd_seq_driver_register(drv, THIS_MODULE)
718c2ecf20Sopenharmony_civoid snd_seq_driver_unregister(struct snd_seq_driver *drv);
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define module_snd_seq_driver(drv) \
748c2ecf20Sopenharmony_ci	module_driver(drv, snd_seq_driver_register, snd_seq_driver_unregister)
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/*
778c2ecf20Sopenharmony_ci * id strings for generic devices
788c2ecf20Sopenharmony_ci */
798c2ecf20Sopenharmony_ci#define SNDRV_SEQ_DEV_ID_MIDISYNTH	"seq-midi"
808c2ecf20Sopenharmony_ci#define SNDRV_SEQ_DEV_ID_OPL3		"opl3-synth"
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci#endif /* __SOUND_SEQ_DEVICE_H */
83