xref: /linux/include/sound/seq_device.h (revision 7c37ae5c625aaa4836466cfaea829a3199dfc571)
11da177e4SLinus Torvalds #ifndef __SOUND_SEQ_DEVICE_H
21da177e4SLinus Torvalds #define __SOUND_SEQ_DEVICE_H
31da177e4SLinus Torvalds 
41da177e4SLinus Torvalds /*
51da177e4SLinus Torvalds  *  ALSA sequencer device management
61da177e4SLinus Torvalds  *  Copyright (c) 1999 by Takashi Iwai <tiwai@suse.de>
71da177e4SLinus Torvalds  *
81da177e4SLinus Torvalds  *   This program is free software; you can redistribute it and/or modify
91da177e4SLinus Torvalds  *   it under the terms of the GNU General Public License as published by
101da177e4SLinus Torvalds  *   the Free Software Foundation; either version 2 of the License, or
111da177e4SLinus Torvalds  *   (at your option) any later version.
121da177e4SLinus Torvalds  *
131da177e4SLinus Torvalds  *   This program is distributed in the hope that it will be useful,
141da177e4SLinus Torvalds  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
151da177e4SLinus Torvalds  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
161da177e4SLinus Torvalds  *   GNU General Public License for more details.
171da177e4SLinus Torvalds  *
181da177e4SLinus Torvalds  *   You should have received a copy of the GNU General Public License
191da177e4SLinus Torvalds  *   along with this program; if not, write to the Free Software
201da177e4SLinus Torvalds  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
211da177e4SLinus Torvalds  *
221da177e4SLinus Torvalds  */
231da177e4SLinus Torvalds 
241da177e4SLinus Torvalds /*
251da177e4SLinus Torvalds  * registered device information
261da177e4SLinus Torvalds  */
271da177e4SLinus Torvalds 
281da177e4SLinus Torvalds #define ID_LEN	32
291da177e4SLinus Torvalds 
301da177e4SLinus Torvalds /* status flag */
311da177e4SLinus Torvalds #define SNDRV_SEQ_DEVICE_FREE		0
321da177e4SLinus Torvalds #define SNDRV_SEQ_DEVICE_REGISTERED	1
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds struct snd_seq_device {
351da177e4SLinus Torvalds 	/* device info */
36c7e0b5bfSTakashi Iwai 	struct snd_card *card;	/* sound card */
371da177e4SLinus Torvalds 	int device;		/* device number */
381da177e4SLinus Torvalds 	char id[ID_LEN];	/* driver id */
391da177e4SLinus Torvalds 	char name[80];		/* device name */
401da177e4SLinus Torvalds 	int argsize;		/* size of the argument */
411da177e4SLinus Torvalds 	void *driver_data;	/* private data for driver */
421da177e4SLinus Torvalds 	int status;		/* flag - read only */
431da177e4SLinus Torvalds 	void *private_data;	/* private data for the caller */
44c7e0b5bfSTakashi Iwai 	void (*private_free)(struct snd_seq_device *device);
451da177e4SLinus Torvalds 	struct list_head list;	/* link to next device */
46*7c37ae5cSTakashi Iwai 	struct device dev;
471da177e4SLinus Torvalds };
481da177e4SLinus Torvalds 
49*7c37ae5cSTakashi Iwai #define to_seq_dev(_dev) \
50*7c37ae5cSTakashi Iwai 	container_of(_dev, struct snd_seq_device, dev)
511da177e4SLinus Torvalds 
521da177e4SLinus Torvalds /* driver operators
531da177e4SLinus Torvalds  * init_device:
541da177e4SLinus Torvalds  *	Initialize the device with given parameters.
551da177e4SLinus Torvalds  *	Typically,
561da177e4SLinus Torvalds  *		1. call snd_hwdep_new
571da177e4SLinus Torvalds  *		2. allocate private data and initialize it
581da177e4SLinus Torvalds  *		3. call snd_hwdep_register
591da177e4SLinus Torvalds  *		4. store the instance to dev->driver_data pointer.
601da177e4SLinus Torvalds  *
611da177e4SLinus Torvalds  * free_device:
621da177e4SLinus Torvalds  *	Release the private data.
631da177e4SLinus Torvalds  *	Typically, call snd_device_free(dev->card, dev->driver_data)
641da177e4SLinus Torvalds  */
651da177e4SLinus Torvalds struct snd_seq_dev_ops {
66c7e0b5bfSTakashi Iwai 	int (*init_device)(struct snd_seq_device *dev);
67c7e0b5bfSTakashi Iwai 	int (*free_device)(struct snd_seq_device *dev);
681da177e4SLinus Torvalds };
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds /*
711da177e4SLinus Torvalds  * prototypes
721da177e4SLinus Torvalds  */
7372496edcSTakashi Iwai #ifdef CONFIG_MODULES
741da177e4SLinus Torvalds void snd_seq_device_load_drivers(void);
7572496edcSTakashi Iwai #else
7672496edcSTakashi Iwai #define snd_seq_device_load_drivers()
7772496edcSTakashi Iwai #endif
78c7e0b5bfSTakashi Iwai int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, struct snd_seq_device **result);
79c7e0b5bfSTakashi Iwai int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, int argsize);
801da177e4SLinus Torvalds int snd_seq_device_unregister_driver(char *id);
811da177e4SLinus Torvalds 
82c7e0b5bfSTakashi Iwai #define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device))
831da177e4SLinus Torvalds 
841da177e4SLinus Torvalds 
851da177e4SLinus Torvalds /*
861da177e4SLinus Torvalds  * id strings for generic devices
871da177e4SLinus Torvalds  */
881da177e4SLinus Torvalds #define SNDRV_SEQ_DEV_ID_MIDISYNTH	"seq-midi"
891da177e4SLinus Torvalds #define SNDRV_SEQ_DEV_ID_OPL3		"opl3-synth"
901da177e4SLinus Torvalds 
911da177e4SLinus Torvalds #endif /* __SOUND_SEQ_DEVICE_H */
92