ext4: Convert s_r_blocks_count and s_free_blocks_count
[safe/jmp/linux-2.6] / include / sound / core.h
index 3093e3d..6954836 100644 (file)
@@ -3,7 +3,7 @@
 
 /*
  *  Main header file for the ALSA driver
- *  Copyright (c) 1994-2001 by Jaroslav Kysela <perex@suse.cz>
+ *  Copyright (c) 1994-2001 by Jaroslav Kysela <perex@perex.cz>
  *
  *
  *   This program is free software; you can redistribute it and/or modify
  */
 
 #include <linux/sched.h>               /* wake_up() */
-#include <asm/semaphore.h>             /* struct semaphore */
+#include <linux/mutex.h>               /* struct mutex */
 #include <linux/rwsem.h>               /* struct rw_semaphore */
-#include <linux/workqueue.h>           /* struct workqueue_struct */
 #include <linux/pm.h>                  /* pm_message_t */
+#include <linux/device.h>
 
 /* 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,28 +188,71 @@ struct snd_minor {
        int type;                       /* SNDRV_DEVICE_TYPE_XXX */
        int card;                       /* card number */
        int device;                     /* device number */
-       struct file_operations *f_ops;  /* file operations */
+       const struct file_operations *f_ops;    /* file operations */
        void *private_data;             /* private data for f_ops->open */
-       char name[0];                   /* device name (keep at the end of
-                                                               structure) */
+       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, void *private_data,
-                       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, void *private_data,
+                           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);
@@ -233,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
@@ -247,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);
@@ -383,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 */