]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - sound/oss/omap-audio.h
Add OMAP audio driver
[linux-2.6-omap-h63xx.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
25 #ifndef __OMAP_AUDIO_H
26 #define __OMAP_AUDIO_H
27
28 /* Requires dma.h */
29 #include <asm/arch/dma.h>
30
31 /*
32  * Buffer Management
33  */
34 typedef struct {
35         int offset;             /* current offset */
36         char *data;             /* points to actual buffer */
37         dma_addr_t dma_addr;    /* physical buffer address */
38         int dma_ref;            /* DMA refcount */
39         int master;             /* owner for buffer allocation, contain size when true */
40 } audio_buf_t;
41
42 /*
43  * Structure describing the data stream related information
44  */
45 typedef struct {
46         char *id;               /* identification string */
47         audio_buf_t *buffers;   /* pointer to audio buffer structures */
48         u_int usr_head;         /* user fragment index */
49         u_int dma_head;         /* DMA fragment index to go */
50         u_int dma_tail;         /* DMA fragment index to complete */
51         u_int fragsize;         /* fragment i.e. buffer size */
52         u_int nbfrags;          /* nbr of fragments i.e. buffers */
53         u_int pending_frags;    /* Fragments sent to DMA */
54         int dma_dev;            /* device identifier for DMA */
55
56 #ifdef OMAP_DMA_CHAINING_SUPPORT
57         lch_chain *dma_chain;
58         dma_regs_t *dma_regs;   /* points to our DMA registers */
59 #else
60         char started;           /* to store if the chain was started or not */
61         int dma_q_head;         /* DMA Channel Q Head */
62         int dma_q_tail;         /* DMA Channel Q Tail */
63         char dma_q_count;       /* DMA Channel Q Count */
64         char in_use;            /*  Is this is use? */
65         int *lch;               /*  Chain of channels this stream is linked to */
66 #endif
67         int input_or_output;    /* Direction of this data stream */
68         int bytecount;          /* nbr of processed bytes */
69         int fragcount;          /* nbr of fragment transitions */
70         struct semaphore sem;   /* account for fragment usage */
71         wait_queue_head_t wq;   /* for poll */
72         int dma_spinref;        /* DMA is spinning */
73         unsigned mapped:1;      /* mmap()'ed buffers */
74         unsigned active:1;      /* actually in progress */
75         unsigned stopped:1;     /* might be active but stopped */
76         unsigned spin_idle:1;   /* have DMA spin on zeros when idle */
77         unsigned linked:1;      /* dma channels linked */
78 } audio_stream_t;
79
80 /*
81  * State structure for one instance
82  */
83 typedef struct {
84         struct module *owner;   /* Codec module ID */
85         audio_stream_t *output_stream;
86         audio_stream_t *input_stream;
87         unsigned rd_ref:1;      /* open reference for recording */
88         unsigned wr_ref:1;      /* open reference for playback */
89         unsigned need_tx_for_rx:1; /* if data must be sent while receiving */
90         void *data;
91         void (*hw_init) (void *);
92         void (*hw_shutdown) (void *);
93         int (*client_ioctl) (struct inode *, struct file *, uint, ulong);
94         int (*hw_probe) (void);
95         void (*hw_remove) (void);
96         void (*hw_cleanup) (void);
97         int (*hw_suspend) (void);
98         int (*hw_resume) (void);
99         struct pm_dev *pm_dev;
100         struct semaphore sem;   /* to protect against races in attach() */
101 } audio_state_t;
102
103 #ifdef AUDIO_PM
104 void audio_ldm_suspend(void *data);
105
106 void audio_ldm_resume(void *data);
107
108 #endif
109
110 /* Register a Codec using this function */
111 extern int audio_register_codec(audio_state_t * codec_state);
112 /* Un-Register a Codec using this function */
113 extern int audio_unregister_codec(audio_state_t * codec_state);
114 /* Function to provide fops of omap audio driver */
115 extern struct file_operations *audio_get_fops(void);
116 /* Function to initialize the device info for audio driver */
117 extern int audio_dev_init(void);
118 /* Function to un-initialize the device info for audio driver */
119 void audio_dev_uninit(void);
120
121 #endif                          /* End of #ifndef __OMAP_AUDIO_H */