bci: some more code for testing
[pandora-kernel.git] / sound / oss / omap-audio.h
1 /*
2  * linux/sound/oss/omap-audio.h
3  *
4  * Common audio handling for the OMAP processors
5  *
6  * Copyright (C) 2004 Texas Instruments, Inc.
7  *
8  * Copyright (C) 2000, 2001 Nicolas Pitre <nico@cam.org>
9  *
10  * This package is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17  *
18  *  History
19  *  -------
20  *  2004/08/12 Nishanth Menon - Modified to integrate Audio requirements on 1610,1710 platforms
21  *
22  *  2004/04/04 Nishanth menon - Added hooks for power management
23  *
24  *  2005/12/10 Dirk Behme     - Added L/R Channel Interchange fix as proposed by Ajaya Babu
25  */
26
27 #ifndef __OMAP_AUDIO_H
28 #define __OMAP_AUDIO_H
29
30 /* Requires dma.h */
31 #include <mach/dma.h>
32
33 /*
34  * Buffer Management
35  */
36 typedef struct {
37         int offset;             /* current offset */
38         char *data;             /* points to actual buffer */
39         dma_addr_t dma_addr;    /* physical buffer address */
40         int dma_ref;            /* DMA refcount */
41         int master;             /* owner for buffer allocation, contain size when true */
42 } audio_buf_t;
43
44 /*
45  * Structure describing the data stream related information
46  */
47 typedef struct {
48         char *id;               /* identification string */
49         audio_buf_t *buffers;   /* pointer to audio buffer structures */
50         u_int usr_head;         /* user fragment index */
51         u_int dma_head;         /* DMA fragment index to go */
52         u_int dma_tail;         /* DMA fragment index to complete */
53         u_int fragsize;         /* fragment i.e. buffer size */
54         u_int nbfrags;          /* nbr of fragments i.e. buffers */
55         u_int pending_frags;    /* Fragments sent to DMA */
56         int dma_dev;            /* device identifier for DMA */
57
58 #ifdef OMAP_DMA_CHAINING_SUPPORT
59         lch_chain *dma_chain;
60         dma_regs_t *dma_regs;   /* points to our DMA registers */
61 #else
62         char started;           /* to store if the chain was started or not */
63         int dma_q_head;         /* DMA Channel Q Head */
64         int dma_q_tail;         /* DMA Channel Q Tail */
65         char dma_q_count;       /* DMA Channel Q Count */
66         char in_use;            /*  Is this is use? */
67         int *lch;               /*  Chain of channels this stream is linked to */
68 #endif
69         int input_or_output;    /* Direction of this data stream */
70         int bytecount;          /* nbr of processed bytes */
71         int fragcount;          /* nbr of fragment transitions */
72         struct completion wfc;  /* wait for "nbfrags" fragment completion */
73         wait_queue_head_t wq;   /* for poll */
74         int dma_spinref;        /* DMA is spinning */
75         unsigned mapped:1;      /* mmap()'ed buffers */
76         unsigned active:1;      /* actually in progress */
77         unsigned stopped:1;     /* might be active but stopped */
78         unsigned spin_idle:1;   /* have DMA spin on zeros when idle */
79         unsigned linked:1;      /* dma channels linked */
80         int (*hw_start)(void);  /* interface to start HW interface, e.g. McBSP */
81         int (*hw_stop)(void);   /* interface to stop HW interface, e.g. McBSP */
82 } audio_stream_t;
83
84 /*
85  * State structure for one instance
86  */
87 typedef struct {
88         struct module *owner;   /* Codec module ID */
89         audio_stream_t *output_stream;
90         audio_stream_t *input_stream;
91         unsigned rd_ref:1;      /* open reference for recording */
92         unsigned wr_ref:1;      /* open reference for playback */
93         unsigned need_tx_for_rx:1; /* if data must be sent while receiving */
94         void *data;
95         void (*hw_init) (void *);
96         void (*hw_shutdown) (void *);
97         int (*client_ioctl) (struct inode *, struct file *, uint, ulong);
98         int (*hw_probe) (void);
99         void (*hw_remove) (void);
100         void (*hw_cleanup) (void);
101         int (*hw_suspend) (void);
102         int (*hw_resume) (void);
103         struct pm_dev *pm_dev;
104         struct mutex mutex;     /* to protect against races in attach() */
105 } audio_state_t;
106
107 #ifdef AUDIO_PM
108 void audio_ldm_suspend(void *data);
109
110 void audio_ldm_resume(void *data);
111
112 #endif
113
114 /* Register a Codec using this function */
115 extern int audio_register_codec(audio_state_t * codec_state);
116 /* Un-Register a Codec using this function */
117 extern int audio_unregister_codec(audio_state_t * codec_state);
118 /* Function to provide fops of omap audio driver */
119 extern struct file_operations *audio_get_fops(void);
120 /* Function to initialize the device info for audio driver */
121 extern int audio_dev_init(void);
122 /* Function to un-initialize the device info for audio driver */
123 void audio_dev_uninit(void);
124
125 #endif                          /* End of #ifndef __OMAP_AUDIO_H */