X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=include%2Fsound%2Fcore.h;h=6954836487ed3407e217a3d005057ee77a8ad7c1;hb=308ba3ece7db82e8b8d32d6962e4d12e09c5aa41;hp=67b0a7e764e776fd3a30bb809a3000aede25588d;hpb=6983b7240cd229787c3ee00e663ea94ea649d96a;p=safe%2Fjmp%2Flinux-2.6 diff --git a/include/sound/core.h b/include/sound/core.h index 67b0a7e..6954836 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -3,7 +3,7 @@ /* * Main header file for the ALSA driver - * Copyright (c) 1994-2001 by Jaroslav Kysela + * Copyright (c) 1994-2001 by Jaroslav Kysela * * * This program is free software; you can redistribute it and/or modify @@ -23,10 +23,10 @@ */ #include /* wake_up() */ -#include /* struct semaphore */ +#include /* struct mutex */ #include /* struct rw_semaphore */ -#include /* struct workqueue_struct */ #include /* pm_message_t */ +#include /* forward declarations */ #ifdef CONFIG_PCI @@ -71,7 +71,6 @@ struct snd_device_ops { int (*dev_free)(struct snd_device *dev); int (*dev_register)(struct snd_device *dev); int (*dev_disconnect)(struct snd_device *dev); - int (*dev_unregister)(struct snd_device *dev); }; struct snd_device { @@ -90,10 +89,10 @@ struct snd_device { struct snd_monitor_file { struct file *file; struct snd_monitor_file *next; + const struct file_operations *disconnected_f_op; + struct list_head shutdown_list; }; -struct snd_shutdown_f_ops; /* define it later in init.c */ - /* main structure for soundcard */ struct snd_card { @@ -131,13 +130,16 @@ struct snd_card { state */ spinlock_t files_lock; /* lock the files for this card */ int shutdown; /* this card is going down */ + int free_on_last_close; /* free in context of file_release */ wait_queue_head_t shutdown_sleep; - struct work_struct free_workq; /* for free in workqueue */ - struct device *dev; + struct device *dev; /* device assigned to this card */ +#ifndef CONFIG_SYSFS_DEPRECATED + struct device *card_dev; /* cardX object for sysfs */ +#endif #ifdef CONFIG_PM unsigned int power_state; /* power state */ - struct semaphore power_lock; /* power lock */ + struct mutex power_lock; /* power lock */ wait_queue_head_t power_sleep; #endif @@ -150,12 +152,12 @@ struct snd_card { #ifdef CONFIG_PM static inline void snd_power_lock(struct snd_card *card) { - down(&card->power_lock); + mutex_lock(&card->power_lock); } static inline void snd_power_unlock(struct snd_card *card) { - up(&card->power_lock); + mutex_unlock(&card->power_lock); } static inline unsigned int snd_power_get_state(struct snd_card *card) @@ -170,13 +172,13 @@ static inline void snd_power_change_state(struct snd_card *card, unsigned int st } /* init.c */ -int snd_power_wait(struct snd_card *card, unsigned int power_state, struct file *file); +int snd_power_wait(struct snd_card *card, unsigned int power_state); #else /* ! CONFIG_PM */ #define snd_power_lock(card) do { (void)(card); } while (0) #define snd_power_unlock(card) do { (void)(card); } while (0) -static inline int snd_power_wait(struct snd_card *card, unsigned int state, struct file *file) { return 0; } +static inline int snd_power_wait(struct snd_card *card, unsigned int state) { return 0; } #define snd_power_get_state(card) SNDRV_CTL_POWER_D0 #define snd_power_change_state(card, state) do { (void)(card); } while (0) @@ -186,26 +188,74 @@ struct snd_minor { int type; /* SNDRV_DEVICE_TYPE_XXX */ int card; /* card number */ int device; /* device number */ - struct file_operations *f_ops; /* file operations */ - char name[0]; /* device name (keep at the end of - structure) */ + const struct file_operations *f_ops; /* file operations */ + void *private_data; /* private data for f_ops->open */ + struct device *dev; /* device for sysfs */ }; +/* return a device pointer linked to each sound device as a parent */ +static inline struct device *snd_card_get_device_link(struct snd_card *card) +{ +#ifdef CONFIG_SYSFS_DEPRECATED + return card ? card->dev : NULL; +#else + return card ? card->card_dev : NULL; +#endif +} + /* sound.c */ extern int snd_major; extern int snd_ecards_limit; +extern struct class *sound_class; void snd_request_card(int card); -int snd_register_device(int type, struct snd_card *card, int dev, - struct file_operations *f_ops, const char *name); +int snd_register_device_for_dev(int type, struct snd_card *card, + int dev, + const struct file_operations *f_ops, + void *private_data, + const char *name, + struct device *device); + +/** + * snd_register_device - Register the ALSA device file for the card + * @type: the device type, SNDRV_DEVICE_TYPE_XXX + * @card: the card instance + * @dev: the device index + * @f_ops: the file operations + * @private_data: user pointer for f_ops->open() + * @name: the device file name + * + * Registers an ALSA device file for the given card. + * The operators have to be set in reg parameter. + * + * This function uses the card's device pointer to link to the + * correct &struct device. + * + * Returns zero if successful, or a negative error code on failure. + */ +static inline int snd_register_device(int type, struct snd_card *card, int dev, + const struct file_operations *f_ops, + void *private_data, + const char *name) +{ + return snd_register_device_for_dev(type, card, dev, f_ops, + private_data, name, + snd_card_get_device_link(card)); +} + int snd_unregister_device(int type, struct snd_card *card, int dev); +void *snd_lookup_minor_data(unsigned int minor, int type); +int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev, + struct device_attribute *attr); #ifdef CONFIG_SND_OSSEMUL int snd_register_oss_device(int type, struct snd_card *card, int dev, - struct file_operations *f_ops, const char *name); + const struct file_operations *f_ops, void *private_data, + const char *name); int snd_unregister_oss_device(int type, struct snd_card *card, int dev); +void *snd_lookup_oss_minor_data(unsigned int minor, int type); #endif int snd_minor_info_init(void); @@ -228,9 +278,8 @@ int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size /* init.c */ -extern unsigned int snd_cards_lock; extern struct snd_card *snd_cards[SNDRV_CARDS]; -extern rwlock_t snd_card_rwlock; +int snd_card_locked(int card); #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) #define SND_MIXER_OSS_NOTIFY_REGISTER 0 #define SND_MIXER_OSS_NOTIFY_DISCONNECT 1 @@ -242,7 +291,7 @@ struct snd_card *snd_card_new(int idx, const char *id, struct module *module, int extra_size); int snd_card_disconnect(struct snd_card *card); int snd_card_free(struct snd_card *card); -int snd_card_free_in_thread(struct snd_card *card); +int snd_card_free_when_closed(struct snd_card *card); int snd_card_register(struct snd_card *card); int snd_card_info_init(void); int snd_card_info_done(void); @@ -312,7 +361,7 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) #ifdef CONFIG_SND_VERBOSE_PRINTK /** * snd_printd - debug printk - * @format: format string + * @fmt: format string * * Compiled only when Works like snd_printk() for debugging purpose. * Ignored when CONFIG_SND_DEBUG is not set. @@ -326,7 +375,6 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) /** * snd_assert - run-time assertion macro * @expr: expression - * @args...: the action * * This macro checks the expression in run-time and invokes the commands * given in the rest arguments if the assertion is failed. @@ -379,6 +427,29 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) #endif #endif -#include "typedefs.h" +/* PCI quirk list helper */ +struct snd_pci_quirk { + unsigned short subvendor; /* PCI subvendor ID */ + unsigned short subdevice; /* PCI subdevice ID */ + int value; /* value */ +#ifdef CONFIG_SND_DEBUG_DETECT + const char *name; /* name of the device (optional) */ +#endif +}; + +#define _SND_PCI_QUIRK_ID(vend,dev) \ + .subvendor = (vend), .subdevice = (dev) +#define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)} +#ifdef CONFIG_SND_DEBUG_DETECT +#define SND_PCI_QUIRK(vend,dev,xname,val) \ + {_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)} +#else +#define SND_PCI_QUIRK(vend,dev,xname,val) \ + {_SND_PCI_QUIRK_ID(vend, dev), .value = (val)} +#endif + +const struct snd_pci_quirk * +snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list); + #endif /* __SOUND_CORE_H */