2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 * pcm_lib.h - lib declare head file
12 #define __LITTLE_ENDIAN
13 #define LIMITED_FORMATS
16 #ifdef __LITTLE_ENDIAN
17 #define SNDRV_LITTLE_ENDIAN
20 #define SNDRV_BIG_ENDIAN
22 #error "Unsupported endian..."
26 typedef unsigned long snd_pcm_uframes_t
;
27 typedef signed long snd_pcm_sframes_t
;
30 SNDRV_PCM_STREAM_PLAYBACK
= 0,
31 SNDRV_PCM_STREAM_CAPTURE
,
32 SNDRV_PCM_STREAM_LAST
= SNDRV_PCM_STREAM_CAPTURE
,
35 typedef int snd_pcm_state_t
;
36 #define /*SNDRV_*/SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */
37 #define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1) /* stream has a setup */
38 #define SNDRV_PCM_STATE_PREPARED ((__force snd_pcm_state_t) 2) /* stream is ready to start */
39 #define SNDRV_PCM_STATE_RUNNING ((__force snd_pcm_state_t) 3) /* stream is running */
40 #define SNDRV_PCM_STATE_XRUN ((__force snd_pcm_state_t) 4) /* stream reached an xrun */
41 #define SNDRV_PCM_STATE_DRAINING ((__force snd_pcm_state_t) 5) /* stream is draining */
42 #define SNDRV_PCM_STATE_PAUSED ((__force snd_pcm_state_t) 6) /* stream is paused */
43 #define SNDRV_PCM_STATE_SUSPENDED ((__force snd_pcm_state_t) 7) /* hardware is suspended */
44 #define SNDRV_PCM_STATE_DISCONNECTED ((__force snd_pcm_state_t) 8) /* hardware is disconnected */
45 #define SNDRV_PCM_STATE_LAST SNDRV_PCM_STATE_DISCONNECTED
47 typedef int snd_pcm_access_t
;
48 #define SNDRV_PCM_ACCESS_INTERLEAVED ((__force snd_pcm_access_t) 0) /* interleaved ,only support this accesse */
49 #define SNDRV_PCM_ACCESS_NONINTERLEAVED ((__force snd_pcm_access_t) 1) /* noninterleaved */
50 #define SNDRV_PCM_ACCESS_COMPLEX ((__force snd_pcm_access_t) 2) /* complex */
51 #define SNDRV_PCM_ACCESS_LAST SNDRV_PCM_ACCESS_COMPLEX
54 typedef int snd_pcm_format_t
;
55 #define SNDRV_PCM_FORMAT_S8 ((__force snd_pcm_format_t) 0)
56 #define SNDRV_PCM_FORMAT_U8 ((__force snd_pcm_format_t) 1)
57 #define SNDRV_PCM_FORMAT_S16_LE ((__force snd_pcm_format_t) 2)
58 #define SNDRV_PCM_FORMAT_S16_BE ((__force snd_pcm_format_t) 3)
59 #define SNDRV_PCM_FORMAT_U16_LE ((__force snd_pcm_format_t) 4)
60 #define SNDRV_PCM_FORMAT_U16_BE ((__force snd_pcm_format_t) 5)
61 #define SNDRV_PCM_FORMAT_S24_LE ((__force snd_pcm_format_t) 6) /* low three bytes */
62 #define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7) /* low three bytes */
63 #define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8) /* low three bytes */
64 #define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9) /* low three bytes */
65 #define SNDRV_PCM_FORMAT_S32_LE ((__force snd_pcm_format_t) 10)
66 #define SNDRV_PCM_FORMAT_S32_BE ((__force snd_pcm_format_t) 11)
67 #define SNDRV_PCM_FORMAT_U32_LE ((__force snd_pcm_format_t) 12)
68 #define SNDRV_PCM_FORMAT_U32_BE ((__force snd_pcm_format_t) 13)
70 #define SNDRV_PCM_FORMAT_FLOAT_LE ((__force snd_pcm_format_t) 14) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
71 #define SNDRV_PCM_FORMAT_FLOAT_BE ((__force snd_pcm_format_t) 15) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
72 #define SNDRV_PCM_FORMAT_FLOAT64_LE ((__force snd_pcm_format_t) 16) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
73 #define SNDRV_PCM_FORMAT_FLOAT64_BE ((__force snd_pcm_format_t) 17) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
75 #define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 14) /* in three bytes */
76 #define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 15) /* in three bytes */
77 #define SNDRV_PCM_FORMAT_U24_3LE ((__force snd_pcm_format_t) 16) /* in three bytes */
78 #define SNDRV_PCM_FORMAT_U24_3BE ((__force snd_pcm_format_t) 17) /* in three bytes */
80 #define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE ((__force snd_pcm_format_t) 18) /* IEC-958 subframe, Little Endian */
81 #define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE ((__force snd_pcm_format_t) 19) /* IEC-958 subframe, Big Endian */
82 #define SNDRV_PCM_FORMAT_MU_LAW ((__force snd_pcm_format_t) 20)
83 #define SNDRV_PCM_FORMAT_A_LAW ((__force snd_pcm_format_t) 21)
84 #define SNDRV_PCM_FORMAT_IMA_ADPCM ((__force snd_pcm_format_t) 22)
85 #define SNDRV_PCM_FORMAT_MPEG ((__force snd_pcm_format_t) 23)
86 #define SNDRV_PCM_FORMAT_GSM ((__force snd_pcm_format_t) 24)
87 #define SNDRV_PCM_FORMAT_SPECIAL ((__force snd_pcm_format_t) 31)
89 #define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 32) /* in three bytes */
90 #define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 33) /* in three bytes */
91 #define SNDRV_PCM_FORMAT_U24_3LE ((__force snd_pcm_format_t) 34) /* in three bytes */
92 #define SNDRV_PCM_FORMAT_U24_3BE ((__force snd_pcm_format_t) 35) /* in three bytes */
94 #define SNDRV_PCM_FORMAT_FLOAT_LE ((__force snd_pcm_format_t) 32) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
95 #define SNDRV_PCM_FORMAT_FLOAT_BE ((__force snd_pcm_format_t) 33) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
96 #define SNDRV_PCM_FORMAT_FLOAT64_LE ((__force snd_pcm_format_t) 34) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
97 #define SNDRV_PCM_FORMAT_FLOAT64_BE ((__force snd_pcm_format_t) 35) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
99 #define SNDRV_PCM_FORMAT_S20_3LE ((__force snd_pcm_format_t) 36) /* in three bytes */
100 #define SNDRV_PCM_FORMAT_S20_3BE ((__force snd_pcm_format_t) 37) /* in three bytes */
101 #define SNDRV_PCM_FORMAT_U20_3LE ((__force snd_pcm_format_t) 38) /* in three bytes */
102 #define SNDRV_PCM_FORMAT_U20_3BE ((__force snd_pcm_format_t) 39) /* in three bytes */
103 #define SNDRV_PCM_FORMAT_S18_3LE ((__force snd_pcm_format_t) 40) /* in three bytes */
104 #define SNDRV_PCM_FORMAT_S18_3BE ((__force snd_pcm_format_t) 41) /* in three bytes */
105 #define SNDRV_PCM_FORMAT_U18_3LE ((__force snd_pcm_format_t) 42) /* in three bytes */
106 #define SNDRV_PCM_FORMAT_U18_3BE ((__force snd_pcm_format_t) 43) /* in three bytes */
107 #define SNDRV_PCM_FORMAT_G723_24 ((__force snd_pcm_format_t) 44) /* 8 samples in 3 bytes */
108 #define SNDRV_PCM_FORMAT_G723_24_1B ((__force snd_pcm_format_t) 45) /* 1 sample in 1 byte */
109 #define SNDRV_PCM_FORMAT_G723_40 ((__force snd_pcm_format_t) 46) /* 8 Samples in 5 bytes */
110 #define SNDRV_PCM_FORMAT_G723_40_1B ((__force snd_pcm_format_t) 47) /* 1 sample in 1 byte */
111 #ifndef LIMITED_FORMATS
112 #define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_G723_40_1B
115 #define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_U32_BE
117 #define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_U24_3BE
121 #ifdef SNDRV_LITTLE_ENDIAN
122 #define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE
123 #define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_LE
124 #define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_LE
125 #define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_LE
126 #define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_LE
127 #define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_LE
128 #define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_LE
129 #define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_LE
130 #define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE
132 #ifdef SNDRV_BIG_ENDIAN
133 #define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_BE
134 #define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_BE
135 #define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_BE
136 #define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_BE
137 #define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_BE
138 #define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_BE
139 #define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_BE
140 #define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_BE
141 #define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE
145 #define SNDRV_MASK_BITS 64 /* we use so far 64bits only */
146 #define SNDRV_MASK_SIZE (SNDRV_MASK_BITS / 32)
147 #define MASK_OFS(i) ((i) >> 5)
148 #define MASK_BIT(i) (1U << ((i) & 31))
150 struct snd_pcm_params
{
151 snd_pcm_access_t access
; /* access mode */
152 //unsigned int fifo_bits;
154 snd_pcm_format_t format
; /* SNDRV_PCM_FORMAT_* */
155 unsigned int rate
; /* rate in Hz ,sample rate */
156 unsigned int channels
; /* channels */
157 snd_pcm_uframes_t period_size
; /* interrput period ( sample unit ) */
158 unsigned int periods
; /* periods */
159 /* snd_pcm_uframes_t buffer_size; */
160 unsigned int buffer_bytes
;
162 snd_pcm_uframes_t start_threshold
; /* min hw_avail frames for automatic start */
163 snd_pcm_uframes_t stop_threshold
; /* min avail frames for automatic stop */
164 snd_pcm_uframes_t silence_threshold
; /* min distance from noise for silence filling */
165 snd_pcm_uframes_t silence_size
; /* silence block size */
166 /* snd_pcm_uframes_t boundary;*/ /* pointers wrap point */
172 #define THRESHOLD_BOUNDARY 0xFFFFFFFF
174 extern unsigned int sys_dma_inited
; /* set by other driver that already inited dma */
176 /* declare function */
177 int pcm_format_width(snd_pcm_format_t format
);
178 int pcm_format_physical_width(snd_pcm_format_t format
);
179 int pcm_format_little_endian(snd_pcm_format_t format
);
181 /* extern function */
182 size_t u_audio_playback(void * handle
, void *buf
, size_t count
);
183 snd_pcm_sframes_t
snd_pcm_lib_write(void * handle
, unsigned long data
, snd_pcm_uframes_t size
,int nonblock
);
184 int snd_pcm_params(void * handle
, struct snd_pcm_params
*params
);
185 int pcm_stream_init(void ** handle
, unsigned int direction
,struct snd_pcm_params
*params
);
186 void pcm_stream_deinit(void * handle
);
187 int pcm_stream_rate(void * handle
);
188 int snd_pcm_get_avail_rate(void * handle
);
189 snd_pcm_sframes_t
snd_pcm_lib_read(void * handle
, unsigned long data
,
190 snd_pcm_uframes_t size
,int nonblock
);
192 #endif // __PCM_LIB_H__