Changeset 95


Ignore:
Timestamp:
May 5, 2007, 7:18:57 PM (18 years ago)
Author:
Brendan Oakley
Message:

Moved core.h code that was in driver.h to core.h
Finished merge of driver.h and core.h to 0.9.0beta12

Location:
GPL/branches/alsa-resync1/alsa-kernel/include/sound
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/core.h

    r92 r95  
     1#ifndef __SOUND_CORE_H
     2#define __SOUND_CORE_H
     3
    14/*
    2  *  Configuration header file for compilation of the ALSA driver
     5 *  Main header file for the ALSA driver
     6 *  Copyright (c) 1994-2001 by Jaroslav Kysela <perex@suse.cz>
     7 *
     8 *
     9 *   This program is free software; you can redistribute it and/or modify
     10 *   it under the terms of the GNU General Public License as published by
     11 *   the Free Software Foundation; either version 2 of the License, or
     12 *   (at your option) any later version.
     13 *
     14 *   This program is distributed in the hope that it will be useful,
     15 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 *   GNU General Public License for more details.
     18 *
     19 *   You should have received a copy of the GNU General Public License
     20 *   along with this program; if not, write to the Free Software
     21 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     22 *
    323 */
    424
    5 #ifndef __ALSA_CORE_H__
    6 #define __ALSA_CORE_H__
    7 
    825#include <sound\config.h>
    9 
    10 #endif //__ALSA_CORE_H__
     26/* Typedef's */
     27typedef struct timeval snd_timestamp_t;
     28#ifndef TARGET_OS2
     29typedef enum sndrv_card_type snd_card_type;
     30#endif
     31
     32/* device allocation stuff */
     33
     34#define SNDRV_DEV_TYPE_RANGE_SIZE               0x1000
     35
     36typedef enum {
     37    SNDRV_DEV_TOPLEVEL =                (0*SNDRV_DEV_TYPE_RANGE_SIZE),
     38    SNDRV_DEV_CONTROL,
     39        SNDRV_DEV_LOWLEVEL_PRE,
     40        SNDRV_DEV_LOWLEVEL_NORMAL =     (1*SNDRV_DEV_TYPE_RANGE_SIZE),
     41        SNDRV_DEV_PCM,
     42        SNDRV_DEV_RAWMIDI,
     43        SNDRV_DEV_TIMER,
     44        SNDRV_DEV_SEQUENCER,
     45        SNDRV_DEV_HWDEP,
     46        SNDRV_DEV_INFO,
     47        SNDRV_DEV_BUS,
     48        SNDRV_DEV_CODEC,
     49        SNDRV_DEV_LOWLEVEL =            (2*SNDRV_DEV_TYPE_RANGE_SIZE)
     50} snd_device_type_t;
     51
     52typedef enum {
     53        SNDRV_DEV_BUILD,
     54        SNDRV_DEV_REGISTERED,
     55        SNDRV_DEV_DISCONNECTED
     56} snd_device_state_t;
     57
     58typedef enum {
     59        SNDRV_DEV_CMD_PRE = 0,
     60        SNDRV_DEV_CMD_NORMAL = 1,
     61        SNDRV_DEV_CMD_POST = 2
     62} snd_device_cmd_t;
     63
     64
     65struct snd_device;
     66
     67struct snd_device_ops {
     68        int (*dev_free)(struct snd_device *dev);
     69        int (*dev_register)(struct snd_device *dev);
     70        int (*dev_disconnect)(struct snd_device *dev);
     71        int (*dev_unregister)(struct snd_device *dev);
     72};
     73
     74struct snd_device {
     75        struct list_head list;          /* list of registered devices */
     76        struct snd_card *card;          /* card which holds this device */
     77        snd_device_state_t state;       /* state of the device */
     78        snd_device_type_t type;         /* device type */
     79        void *device_data;              /* device structure */
     80        struct snd_device_ops *ops;             /* operations */
     81};
     82
     83#define snd_device(n) list_entry(n, struct snd_device, list)
     84
     85/* various typedefs */
     86
     87typedef struct snd_info_entry snd_info_entry_t;
     88#ifdef CONFIG_SND_OSSEMUL
     89typedef struct _snd_oss_mixer snd_mixer_oss_t;
     90#endif
     91
     92/* main structure for soundcard */
     93
     94/* monitor files for graceful shutdown (hotplug) */
     95
     96struct snd_monitor_file {
     97        struct file *file;
     98        struct snd_monitor_file *next;
     99};
     100
     101struct snd_card {
     102        int number;                     /* number of soundcard (index to snd_cards) */
     103
     104        char id[16];                    /* id string of this card */
     105        char driver[16];                /* driver name */
     106        char shortname[32];             /* short name of this soundcard */
     107        char longname[80];              /* name of this soundcard */
     108        char mixername[80];             /* mixer name */
     109        char components[80];            /* card components delimited with space */
     110
     111        struct module *module;          /* top-level module */
     112
     113        void *private_data;             /* private data for soundcard */
     114        void (*private_free) (struct snd_card *card); /* callback for freeing of private data */
     115
     116        struct list_head devices;       /* devices */
     117
     118        unsigned int last_numid;        /* last used numeric ID */
     119        struct rw_semaphore controls_rwsem;     /* controls list lock */        rwlock_t control_rwlock;        /* control list lock */
     120        rwlock_t ctl_files_rwlock;      /* ctl_files list lock */
     121        int controls_count;             /* count of all controls */
     122        int user_ctl_count;             /* count of all user controls */
     123        struct list_head controls;      /* all controls for this card */
     124        struct list_head ctl_files;     /* active control files */
     125
     126        snd_info_entry_t *proc_root;    /* root for soundcard specific files */
     127        snd_info_entry_t *proc_id;      /* the card id */
     128        struct proc_dir_entry *proc_root_link;  /* number link to real id */
     129
     130        struct snd_monitor_file *files; /* all files associated to this card */
     131        struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown state */
     132        spinlock_t files_lock;          /* lock the files for this card */
     133        int shutdown;                   /* this card is going down */
     134        wait_queue_head_t shutdown_sleep;
     135        struct work_struct free_workq;  /* for free in workqueue */
     136        struct device *dev;
     137#ifdef CONFIG_PM
     138        int (*pm_suspend)(struct snd_card *card, unsigned int state);
     139        int (*pm_resume)(struct snd_card *card, unsigned int state);
     140        struct pm_dev *pm_dev;          /* for ISA */
     141        void *pm_private_data;
     142        unsigned int power_state;       /* power state */
     143        struct semaphore power_lock;    /* power lock */
     144        wait_queue_head_t power_sleep;
     145#endif
     146
     147#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
     148        snd_mixer_oss_t *mixer_oss;
     149        int mixer_oss_change_count;
     150#endif
     151};
     152
     153#ifdef CONFIG_PM
     154static inline void snd_power_lock(struct snd_card *card)
     155{
     156        down(&card->power_lock);
     157}
     158
     159static inline void snd_power_unlock(struct snd_card *card)
     160{
     161        up(&card->power_lock);
     162}
     163
     164int snd_power_wait(struct snd_card *card, unsigned int power_state, struct file *file);
     165
     166static inline unsigned int snd_power_get_state(struct snd_card *card)
     167{
     168        return card->power_state;
     169}
     170
     171static inline void snd_power_change_state(struct snd_card *card, unsigned int state)
     172{
     173        card->power_state = state;
     174        wake_up(&card->power_sleep);
     175}
     176int snd_card_set_pm_callback(struct snd_card *card,
     177                             int (*suspend)(struct snd_card *, unsigned int),
     178                             int (*resume)(struct snd_card *, unsigned int),
     179                             void *private_data);
     180int snd_card_set_isa_pm_callback(struct snd_card *card,
     181                                 int (*suspend)(struct snd_card *, unsigned int),
     182                                 int (*resume)(struct snd_card *, unsigned int),
     183                                 void *private_data);
     184#ifndef SND_PCI_PM_CALLBACKS
     185int snd_card_pci_suspend(struct pci_dev *dev, u32 state);
     186int snd_card_pci_resume(struct pci_dev *dev);
     187#define SND_PCI_PM_CALLBACKS \
     188    snd_card_pci_suspend, \
     189    snd_card_pci_resume
     190#endif
     191#else
     192#define snd_power_lock(card) do { ; } while (0)
     193#define snd_power_unlock(card) do { ; } while (0)
     194#define snd_power_wait(card) do { ; } while (0)
     195#define snd_power_get_state(card) SNDRV_CTL_POWER_D0
     196#define snd_power_change_state(card, state) do { ; } while (0)
     197#define snd_card_set_pm_callback(card,suspend,resume,data) -EINVAL
     198#define snd_card_set_isa_pm_callback(card,suspend,resume,data) -EINVAL
     199#define SND_PCI_PM_CALLBACKS
     200#endif
     201
     202/* device.c */
     203
     204struct _snd_minor {
     205        struct list_head list;          /* list of all minors per card */
     206        int number;                     /* minor number */
     207        int device;                     /* device number */
     208        const char *comment;            /* for /proc/asound/devices */
     209        snd_info_entry_t *dev;          /* for /proc/asound/dev */
     210        struct file_operations *f_ops;  /* file operations */
     211        char name[1];
     212};
     213
     214/* sound.c */
     215
     216extern int snd_ecards_limit;
     217extern int snd_device_mode;
     218extern int snd_device_gid;
     219extern int snd_device_uid;
     220
     221void snd_request_card(int card);
     222
     223int snd_register_device(int type, struct snd_card *card, int dev, snd_minor_t *reg, const char *name);
     224int snd_unregister_device(int type, struct snd_card *card, int dev);
     225
     226#ifdef CONFIG_SND_OSSEMUL
     227int snd_register_oss_device(int type, struct snd_card *card, int dev, snd_minor_t *reg, const char *name);
     228int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
     229#endif
     230
     231int snd_minor_info_init(void);
     232int snd_minor_info_done(void);
     233
     234/* sound_oss.c */
     235
     236#ifdef CONFIG_SND_OSSEMUL
     237
     238int snd_minor_info_oss_init(void);
     239int snd_minor_info_oss_done(void);
     240
     241int snd_oss_init_module(void);
     242void snd_oss_cleanup_module(void);
     243
     244#endif
     245
     246/* memory.c */
     247
     248#ifdef CONFIG_SND_DEBUG_MEMORY
     249void snd_memory_init(void);
     250void snd_memory_done(void);
     251int snd_memory_info_init(void);
     252int snd_memory_info_done(void);
     253void *snd_hidden_kmalloc(size_t size, int flags);
     254void *snd_hidden_kcalloc(size_t n, size_t size, int flags);
     255void snd_hidden_kfree(const void *obj);
     256void *snd_hidden_vmalloc(unsigned long size);
     257void snd_hidden_vfree(void *obj);
     258char *snd_hidden_kstrdup(const char *s, int flags);
     259#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
     260#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
     261#define kfree(obj) snd_hidden_kfree(obj)
     262#define kfree_nocheck(obj) snd_wrapper_kfree(obj)
     263#define vmalloc(size) snd_hidden_vmalloc(size)
     264#define vfree(obj) snd_hidden_vfree(obj)
     265#define kstrdup(s, flags)  snd_hidden_kstrdup(s, flags)
     266#else
     267#define kfree_nocheck(obj) kfree(obj)
     268#endif
     269
     270char *snd_hidden_kstrdup(const char *s, int flags);
     271#define kstrdup(s, flags)  snd_hidden_kstrdup(s, flags)
     272
     273char *snd_kmalloc_strdup(const char *string, int flags);
     274int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
     275int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
     276
     277void *kzalloc(size_t size, unsigned int flags);
     278
     279/* init.c */
     280
     281extern int snd_cards_count;
     282extern struct snd_card *snd_cards[SNDRV_CARDS];
     283extern rwlock_t snd_card_rwlock;
     284#ifdef CONFIG_SND_OSSEMUL
     285extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
     286#endif
     287
     288struct snd_card *snd_card_new(int idx, const char *id,
     289                         struct module *module, int extra_size);
     290int snd_card_free(struct snd_card *card);
     291int snd_card_register(struct snd_card *card);
     292int snd_card_info_init(void);
     293int snd_card_info_done(void);
     294int snd_component_add(struct snd_card *card, const char *component);
     295int snd_card_file_add(struct snd_card *card, struct file *file);
     296int snd_card_file_remove(struct snd_card *card, struct file *file);
     297
     298/* device.c */
     299
     300int snd_device_new(struct snd_card *card, snd_device_type_t type,
     301                   void *device_data, struct snd_device_ops *ops);
     302int snd_device_register(struct snd_card *card, void *device_data);
     303int snd_device_register_all(struct snd_card *card);
     304int snd_device_free(struct snd_card *card, void *device_data);
     305int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd);
     306
     307/* isadma.c */
     308
     309#define DMA_MODE_NO_ENABLE      0x0100
     310
     311void snd_dma_program(unsigned long dma, unsigned long addr, unsigned int size, unsigned short mode);
     312void snd_dma_disable(unsigned long dma);
     313unsigned int snd_dma_residue(unsigned long dma);
     314
     315/* misc.c */
     316
     317int snd_task_name(struct task_struct *task, char *name, size_t size);
     318#ifdef CONFIG_SND_VERBOSE_PRINTK
     319int snd_verbose_printk(const char *file, int line, const char *format);
     320#endif
     321
     322/* --- */
     323
     324#define snd_printk(format, args...) do { \
     325        printk(snd_verbose_printk(__FILE__, __LINE__, format) ? format + 3 : format, ##args); \
     326} while (0)
     327#else
     328#define snd_printk(format, args...) do { \
     329        printk(format, ##args); \
     330} while (0)
     331#endif
     332
     333#ifdef CONFIG_SND_DEBUG
     334
     335#define __ASTRING__(x) #x
     336
     337#define snd_printd(format, args...) snd_printk(format, ##args)
     338#define snd_assert(expr, args...) do {\
     339        if (!(expr)) {\
     340                snd_printk("BUG? (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\
     341                args;\
     342        }\
     343} while (0)
     344#define snd_runtime_check(expr, args...) do {\
     345        if (!(expr)) {\
     346                snd_printk("ERROR (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\
     347                args;\
     348        }\
     349} while (0)
     350
     351#else /* !CONFIG_SND_DEBUG */
     352
     353#define snd_printd(format, args...)     /* nothing */
     354#define snd_assert(expr, args...)       /* nothing */
     355#define snd_runtime_check(expr, args...) do { if (!(expr)) { args; } } while (0)
     356
     357#endif /* CONFIG_SND_DEBUG */
     358
     359#ifdef CONFIG_SND_DEBUG_DETECT
     360#define snd_printdd(format, args...) snd_printk(format, ##args)
     361#else
     362#define snd_printdd(format, args...) /* nothing */
     363#endif
     364
     365#define snd_BUG() snd_assert(0, )
     366
     367
     368#ifdef DEBUG
     369#define snd_BUG() _asm int 3;
     370#else
     371#define snd_BUG()
     372#endif
     373
     374static inline void snd_timestamp_now(struct timespec *tstamp, int timespec)
     375{
     376        struct timeval val;
     377        /* FIXME: use a linear time source */
     378        do_gettimeofday(&val);
     379        tstamp->tv_sec = val.tv_sec;
     380        tstamp->tv_nsec = val.tv_usec;
     381        if (timespec)
     382                tstamp->tv_nsec *= 1000L;
     383}
     384
     385#define snd_timestamp_zero(tstamp) do { (tstamp)->tv_sec = 0; (tstamp)->tv_usec = 0; } while (0)
     386#define snd_timestamp_null(tstamp) ((tstamp)->tv_sec == 0 && (tstamp)->tv_usec ==0)
     387
     388#define SNDRV_OSS_VERSION         ((3<<16)|(8<<8)|(1<<4)|(0))   /* 3.8.1a */
     389
     390/* kcalloc */
     391#ifndef CONFIG_HAVE_KCALLOC
     392#ifndef CONFIG_SND_DEBUG_MEMORY
     393void *snd_compat_kcalloc(size_t n, size_t size, int gfp_flags);
     394#define kcalloc(n,s,f) snd_compat_kcalloc(n,s,f)
     395#endif
     396#endif
     397
     398#define __builtin_expect(x, expected_value) (x)
     399#define likely(x)       __builtin_expect((x),1)
     400#define unlikely(x)     __builtin_expect((x),0)
     401
     402typedef u32 /*__bitwise*/ pm_message_t;
     403
     404#ifndef __devexit_p
     405#define __devexit_p(x) x
     406#endif
     407
     408#define printk_ratelimit()      1
     409
     410typedef unsigned gfp_t;
     411
     412#ifndef cpu_relax
     413#define cpu_relax()
     414#endif
     415
     416static inline int snd_pci_enable_msi(struct pci_dev *dev) { return -1; }
     417#undef pci_enable_msi
     418#define pci_enable_msi(dev) snd_pci_enable_msi(dev)
     419#undef pci_disable_msi
     420#define pci_disable_msi(dev)
     421
     422#undef pci_intx
     423#define pci_intx(pci,x)
     424
     425#endif /* __SOUND_CORE_H */
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/driver.h

    r94 r95  
    150150
    151151/*
    152  *  ==========================================================================
     152 * Temporary hack, until linux/init.h is fixed.
    153153 */
    154154
    155 /* device allocation stuff */
    156 
    157 #define SNDRV_DEV_TYPE_RANGE_SIZE               0x1000
    158 
    159 typedef enum {
    160     SNDRV_DEV_TOPLEVEL =                (0*SNDRV_DEV_TYPE_RANGE_SIZE),
    161     SNDRV_DEV_CONTROL,
    162         SNDRV_DEV_LOWLEVEL_PRE,
    163         SNDRV_DEV_LOWLEVEL_NORMAL =     (1*SNDRV_DEV_TYPE_RANGE_SIZE),
    164         SNDRV_DEV_PCM,
    165         SNDRV_DEV_RAWMIDI,
    166         SNDRV_DEV_TIMER,
    167         SNDRV_DEV_SEQUENCER,
    168         SNDRV_DEV_HWDEP,
    169         SNDRV_DEV_INFO,
    170         SNDRV_DEV_BUS,
    171         SNDRV_DEV_CODEC,
    172         SNDRV_DEV_LOWLEVEL =            (2*SNDRV_DEV_TYPE_RANGE_SIZE)
    173 } snd_device_type_t;
    174 
    175 typedef enum {
    176         SNDRV_DEV_BUILD,
    177         SNDRV_DEV_REGISTERED,
    178         SNDRV_DEV_DISCONNECTED
    179 } snd_device_state_t;
    180 
    181 typedef enum {
    182         SNDRV_DEV_CMD_PRE = 0,
    183         SNDRV_DEV_CMD_NORMAL = 1,
    184         SNDRV_DEV_CMD_POST = 2
    185 } snd_device_cmd_t;
    186 
    187 
    188 struct snd_device;
    189 
    190 struct snd_device_ops {
    191         int (*dev_free)(struct snd_device *dev);
    192         int (*dev_register)(struct snd_device *dev);
    193         int (*dev_disconnect)(struct snd_device *dev);
    194         int (*dev_unregister)(struct snd_device *dev);
    195 };
    196 
    197 struct snd_device {
    198         struct list_head list;          /* list of registered devices */
    199         struct snd_card *card;          /* card which holds this device */
    200         snd_device_state_t state;       /* state of the device */
    201         snd_device_type_t type;         /* device type */
    202         void *device_data;              /* device structure */
    203         struct snd_device_ops *ops;             /* operations */
    204 };
    205 
    206 #define snd_device(n) list_entry(n, struct snd_device, list)
    207 
    208 /* various typedefs */
    209 
    210 typedef struct snd_info_entry snd_info_entry_t;
    211 #ifdef CONFIG_SND_OSSEMUL
    212 typedef struct _snd_oss_mixer snd_mixer_oss_t;
    213 #endif
    214 
    215 /* main structure for soundcard */
    216 
    217 /* monitor files for graceful shutdown (hotplug) */
    218 
    219 struct snd_monitor_file {
    220         struct file *file;
    221         struct snd_monitor_file *next;
    222 };
    223 
    224 struct snd_card {
    225         int number;                     /* number of soundcard (index to snd_cards) */
    226 
    227         char id[16];                    /* id string of this card */
    228         char driver[16];                /* driver name */
    229         char shortname[32];             /* short name of this soundcard */
    230         char longname[80];              /* name of this soundcard */
    231         char mixername[80];             /* mixer name */
    232         char components[80];            /* card components delimited with space */
    233 
    234         struct module *module;          /* top-level module */
    235 
    236         void *private_data;             /* private data for soundcard */
    237         void (*private_free) (struct snd_card *card); /* callback for freeing of private data */
    238 
    239         struct list_head devices;       /* devices */
    240 
    241         unsigned int last_numid;        /* last used numeric ID */
    242         struct rw_semaphore controls_rwsem;     /* controls list lock */        rwlock_t control_rwlock;        /* control list lock */
    243         rwlock_t ctl_files_rwlock;      /* ctl_files list lock */
    244         int controls_count;             /* count of all controls */
    245         int user_ctl_count;             /* count of all user controls */
    246         struct list_head controls;      /* all controls for this card */
    247         struct list_head ctl_files;     /* active control files */
    248 
    249         snd_info_entry_t *proc_root;    /* root for soundcard specific files */
    250         snd_info_entry_t *proc_id;      /* the card id */
    251         struct proc_dir_entry *proc_root_link;  /* number link to real id */
    252 
    253         struct snd_monitor_file *files; /* all files associated to this card */
    254         struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown state */
    255         spinlock_t files_lock;          /* lock the files for this card */
    256         int shutdown;                   /* this card is going down */
    257         wait_queue_head_t shutdown_sleep;
    258         struct work_struct free_workq;  /* for free in workqueue */
    259         struct device *dev;
    260 #ifdef CONFIG_PM
    261         int (*pm_suspend)(struct snd_card *card, unsigned int state);
    262         int (*pm_resume)(struct snd_card *card, unsigned int state);
    263         struct pm_dev *pm_dev;          /* for ISA */
    264         void *pm_private_data;
    265         unsigned int power_state;       /* power state */
    266         struct semaphore power_lock;    /* power lock */
    267         wait_queue_head_t power_sleep;
    268 #endif
    269 
    270 #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
    271         snd_mixer_oss_t *mixer_oss;
    272         int mixer_oss_change_count;
    273 #endif
    274 };
    275 
    276 #ifdef CONFIG_PM
    277 static inline void snd_power_lock(struct snd_card *card)
    278 {
    279         down(&card->power_lock);
    280 }
    281 
    282 static inline void snd_power_unlock(struct snd_card *card)
    283 {
    284         up(&card->power_lock);
    285 }
    286 
    287 int snd_power_wait(struct snd_card *card, unsigned int power_state, struct file *file);
    288 
    289 static inline unsigned int snd_power_get_state(struct snd_card *card)
    290 {
    291         return card->power_state;
    292 }
    293 
    294 static inline void snd_power_change_state(struct snd_card *card, unsigned int state)
    295 {
    296         card->power_state = state;
    297         wake_up(&card->power_sleep);
    298 }
    299 int snd_card_set_pm_callback(struct snd_card *card,
    300                              int (*suspend)(struct snd_card *, unsigned int),
    301                              int (*resume)(struct snd_card *, unsigned int),
    302                              void *private_data);
    303 int snd_card_set_isa_pm_callback(struct snd_card *card,
    304                                  int (*suspend)(struct snd_card *, unsigned int),
    305                                  int (*resume)(struct snd_card *, unsigned int),
    306                                  void *private_data);
    307 #ifndef SND_PCI_PM_CALLBACKS
    308 int snd_card_pci_suspend(struct pci_dev *dev, u32 state);
    309 int snd_card_pci_resume(struct pci_dev *dev);
    310 #define SND_PCI_PM_CALLBACKS \
    311     snd_card_pci_suspend, \
    312     snd_card_pci_resume
    313 #endif
    314 #else
    315 #define snd_power_lock(card) do { ; } while (0)
    316 #define snd_power_unlock(card) do { ; } while (0)
    317 #define snd_power_wait(card) do { ; } while (0)
    318 #define snd_power_get_state(card) SNDRV_CTL_POWER_D0
    319 #define snd_power_change_state(card, state) do { ; } while (0)
    320 #define snd_card_set_pm_callback(card,suspend,resume,data) -EINVAL
    321 #define snd_card_set_isa_pm_callback(card,suspend,resume,data) -EINVAL
    322 #define SND_PCI_PM_CALLBACKS
    323 #endif
    324 
    325 /* device.c */
    326 
    327 struct _snd_minor {
    328         struct list_head list;          /* list of all minors per card */
    329         int number;                     /* minor number */
    330         int device;                     /* device number */
    331         const char *comment;            /* for /proc/asound/devices */
    332         snd_info_entry_t *dev;          /* for /proc/asound/dev */
    333         struct file_operations *f_ops;  /* file operations */
    334         char name[1];
    335 };
    336 
    337 /* sound.c */
    338 
    339 extern int snd_ecards_limit;
    340 extern int snd_device_mode;
    341 extern int snd_device_gid;
    342 extern int snd_device_uid;
    343 
    344 void snd_request_card(int card);
    345 
    346 int snd_register_device(int type, struct snd_card *card, int dev, snd_minor_t *reg, const char *name);
    347 int snd_unregister_device(int type, struct snd_card *card, int dev);
    348 
    349 #ifdef CONFIG_SND_OSSEMUL
    350 int snd_register_oss_device(int type, struct snd_card *card, int dev, snd_minor_t *reg, const char *name);
    351 int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
    352 #endif
    353 
    354 int snd_minor_info_init(void);
    355 int snd_minor_info_done(void);
    356 
    357 /* sound_oss.c */
    358 
    359 #ifdef CONFIG_SND_OSSEMUL
    360 
    361 int snd_minor_info_oss_init(void);
    362 int snd_minor_info_oss_done(void);
    363 
    364 int snd_oss_init_module(void);
    365 void snd_oss_cleanup_module(void);
    366 
    367 #endif
    368 
    369 /* memory.c */
    370 
    371 #ifdef CONFIG_SND_DEBUG_MEMORY
    372 void snd_memory_init(void);
    373 void snd_memory_done(void);
    374 int snd_memory_info_init(void);
    375 int snd_memory_info_done(void);
    376 void *snd_hidden_kmalloc(size_t size, int flags);
    377 void *snd_hidden_kcalloc(size_t n, size_t size, int flags);
    378 void snd_hidden_kfree(const void *obj);
    379 void *snd_hidden_vmalloc(unsigned long size);
    380 void snd_hidden_vfree(void *obj);
    381 char *snd_hidden_kstrdup(const char *s, int flags);
    382 #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
    383 #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
    384 #define kfree(obj) snd_hidden_kfree(obj)
    385 #define vmalloc(size) snd_hidden_vmalloc(size)
    386 #define vfree(obj) snd_hidden_vfree(obj)
    387 #define kstrdup(s, flags)  snd_hidden_kstrdup(s, flags)
    388 #endif
    389 
    390 char *snd_hidden_kstrdup(const char *s, int flags);
    391 #define kstrdup(s, flags)  snd_hidden_kstrdup(s, flags)
    392 
    393 char *snd_kmalloc_strdup(const char *string, int flags);
    394 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
    395 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
    396 
    397 void *kzalloc(size_t size, unsigned int flags);
    398 
    399 /* init.c */
    400 
    401 extern int snd_cards_count;
    402 extern struct snd_card *snd_cards[SNDRV_CARDS];
    403 extern rwlock_t snd_card_rwlock;
    404 #ifdef CONFIG_SND_OSSEMUL
    405 extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
    406 #endif
    407 
    408 struct snd_card *snd_card_new(int idx, const char *id,
    409                          struct module *module, int extra_size);
    410 int snd_card_free(struct snd_card *card);
    411 int snd_card_register(struct snd_card *card);
    412 int snd_card_info_init(void);
    413 int snd_card_info_done(void);
    414 int snd_component_add(struct snd_card *card, const char *component);
    415 int snd_card_file_add(struct snd_card *card, struct file *file);
    416 int snd_card_file_remove(struct snd_card *card, struct file *file);
    417 
    418 /* device.c */
    419 
    420 int snd_device_new(struct snd_card *card, snd_device_type_t type,
    421                    void *device_data, struct snd_device_ops *ops);
    422 int snd_device_register(struct snd_card *card, void *device_data);
    423 int snd_device_register_all(struct snd_card *card);
    424 int snd_device_free(struct snd_card *card, void *device_data);
    425 int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd);
    426 
    427 /* isadma.c */
    428 
    429 #define DMA_MODE_NO_ENABLE      0x0100
    430 
    431 void snd_dma_program(unsigned long dma, const void *buf, unsigned int size, unsigned short mode);
    432 void snd_dma_disable(unsigned long dma);
    433 unsigned int snd_dma_residue(unsigned long dma);
    434 
    435 /* misc.c */
    436 
    437 int snd_task_name(struct task_struct *task, char *name, size_t size);
    438 
    439 /* --- */
    440 
    441 #define snd_printk(format, args...) do { \
    442         printk("ALSA %s:%d: ", __FILE__, __LINE__); \
    443         printk(format, ##args); \
    444 } while (0)
    445 
    446 #ifdef CONFIG_SND_DEBUG
    447 
    448 #define snd_printd(format, args...) snd_printk(format, ##args)
    449 #define snd_assert(expr, args...) do {\
    450         if (!(expr)) {\
    451                 snd_printk("BUG? (%s) (called from %p)\n", __STRING(expr), __builtin_return_address(0));\
    452                 args;\
    453         }\
    454 } while (0)
    455 #define snd_runtime_check(expr, args...) do {\
    456         if (!(expr)) {\
    457                 snd_printk("ERROR (%s) (called from %p)\n", __STRING(expr), __builtin_return_address(0));\
    458                 args;\
    459         }\
    460 } while (0)
    461 
    462 #else /* !CONFIG_SND_DEBUG */
    463 
    464 #define snd_printd(format, args...)     /* nothing */
    465 #define snd_assert(expr, args...)       /* nothing */
    466 #define snd_runtime_check(expr, args...) do { if (!(expr)) { args; } } while (0)
    467 
    468 #endif /* CONFIG_SND_DEBUG */
    469 
    470 #ifdef CONFIG_SND_DEBUG_DETECT
    471 #define snd_printdd(format, args...) snd_printk(format, ##args)
    472 #else
    473 #define snd_printdd(format, args...) /* nothing */
    474 #endif
    475 
    476 #define snd_BUG() snd_assert(0, )
    477 
    478 
    479 #ifdef DEBUG
    480 #define snd_BUG() _asm int 3;
    481 #else
    482 #define snd_BUG()
    483 #endif
    484 
    485 static inline void snd_timestamp_now(struct timespec *tstamp, int timespec)
    486 {
    487         struct timeval val;
    488         /* FIXME: use a linear time source */
    489         do_gettimeofday(&val);
    490         tstamp->tv_sec = val.tv_sec;
    491         tstamp->tv_nsec = val.tv_usec;
    492         if (timespec)
    493                 tstamp->tv_nsec *= 1000L;
    494 }
    495 
    496 #define snd_timestamp_zero(tstamp) do { (tstamp)->tv_sec = 0; (tstamp)->tv_usec = 0; } while (0)
    497 #define snd_timestamp_null(tstamp) ((tstamp)->tv_sec == 0 && (tstamp)->tv_usec ==0)
    498 
    499 #define SNDRV_OSS_VERSION         ((3<<16)|(8<<8)|(1<<4)|(0))   /* 3.8.1a */
    500 
    501 /* kcalloc */
    502 #ifndef CONFIG_HAVE_KCALLOC
    503 #ifndef CONFIG_SND_DEBUG_MEMORY
    504 void *snd_compat_kcalloc(size_t n, size_t size, int gfp_flags);
    505 #define kcalloc(n,s,f) snd_compat_kcalloc(n,s,f)
    506 #endif
    507 #endif
    508 
    509 #define __builtin_expect(x, expected_value) (x)
    510 #define likely(x)       __builtin_expect((x),1)
    511 #define unlikely(x)     __builtin_expect((x),0)
    512 
    513 typedef u32 /*__bitwise*/ pm_message_t;
    514 
     155#include <linux/init.h>
    515156#ifndef __devexit_p
    516157#define __devexit_p(x) x
    517158#endif
    518159
    519 #define printk_ratelimit()      1
    520 
    521 typedef unsigned gfp_t;
    522 
    523 #ifndef cpu_relax
    524 #define cpu_relax()
    525 #endif
    526 
    527 static inline int snd_pci_enable_msi(struct pci_dev *dev) { return -1; }
    528 #undef pci_enable_msi
    529 #define pci_enable_msi(dev) snd_pci_enable_msi(dev)
    530 #undef pci_disable_msi
    531 #define pci_disable_msi(dev)
    532 
    533 #undef pci_intx
    534 #define pci_intx(pci,x)
    535 
    536 
    537 #endif                          /* __DRIVER_H */
     160#endif /* __SOUND_DRIVER_H */
Note: See TracChangeset for help on using the changeset viewer.