1c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
2c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * BSD LICENSE
3c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
4c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * Copyright (c) 2011-2012, Intel Corporation
5c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * All rights reserved.
6c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
7c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * Redistribution and use in source and binary forms, with or without
8c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * modification, are permitted provided that the following conditions are met:
9c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
10c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * Redistributions of source code must retain the above copyright notice,
11c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * this list of conditions and the following disclaimer.
12c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * Redistributions in binary form must reproduce the above copyright notice,
13c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * this list of conditions and the following disclaimer in the documentation
14c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * and/or other materials provided with the distribution.
15c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * Neither the name of Intel Corporation nor the names of its contributors
16c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * may be used to endorse or promote products derived from this software
17c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * without specific prior written permission.
18c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
19c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * THE POSSIBILITY OF SUCH DAMAGE.
30c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
31c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * LGPL LICENSE
32c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
33c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * tinycompress library for compress audio offload in alsa
34c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * Copyright (c) 2011-2012, Intel Corporation.
35c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
36c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
37c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * This program is free software; you can redistribute it and/or modify it
38c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * under the terms and conditions of the GNU Lesser General Public License,
39c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * version 2.1, as published by the Free Software Foundation.
40c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
41c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * This program is distributed in the hope it will be useful, but WITHOUT
42c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
44c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * License for more details.
45c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
46c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * You should have received a copy of the GNU Lesser General Public License
47c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * along with this program; if not, write to
48c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * the Free Software Foundation, Inc.,
49c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
50c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
51c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
52c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
53c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#ifndef __TINYCOMPRESS_H
54c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define __TINYCOMPRESS_H
55c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
56c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#if defined(__cplusplus)
57c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentextern "C" {
58c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#endif
59c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
60c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * struct compr_config: config structure, needs to be filled by app
61c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * If fragment_size or fragments are zero, this means "don't care"
62c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * and tinycompress will choose values that the driver supports
63c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
64c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @fragment_size: size of fragment requested, in bytes
65c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @fragments: number of fragments
66c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @codec: codec type and parameters requested
67c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
68c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentstruct compr_config {
69c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent	__u32 fragment_size;
70c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent	__u32 fragments;
71c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent	struct snd_codec *codec;
72c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent};
73c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
74c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentstruct compr_gapless_mdata {
75c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent	__u32 encoder_delay;
76c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent	__u32 encoder_padding;
77c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent};
78c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
79f0c407825741bcb94952e4264efce66dee378411Eric Laurent#define COMPRESS_OUT        0x20000000
80c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define COMPRESS_IN         0x10000000
81c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
82c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentstruct compress;
83c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentstruct snd_compr_tstamp;
84c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
85c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
86c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_open: open a new compress stream
87c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * returns the valid struct compress on success, NULL on failure
88c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * If config does not specify a requested fragment size, on return
89c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * it will be updated with the size and number of fragments that
90c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * were configured
91c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
92c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @card: sound card number
93c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @device: device number
94c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @flags: device flags can be COMPRESS_OUT or COMPRESS_IN
95c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @config: stream config requested. Returns actual fragment config
96c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
97c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentstruct compress *compress_open(unsigned int card, unsigned int device,
98c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent		unsigned int flags, struct compr_config *config);
99c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
100c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
101c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_close: close the compress stream
102c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
103c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream to be closed
104c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
105c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentvoid compress_close(struct compress *compress);
106c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
107c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
108c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_get_hpointer: get the hw timestamp
109c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return 0 on success, negative on error
110c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
111c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream on which query is made
112c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @avail: buffer availble for write/read, in bytes
113c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @tstamp: hw time
114c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
115c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_get_hpointer(struct compress *compress,
116c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent		unsigned int *avail, struct timespec *tstamp);
117c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
118c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
119c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
120c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_get_tstamp: get the raw hw timestamp
121c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return 0 on success, negative on error
122c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
123c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream on which query is made
124c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @samples: number of decoded samples played
125c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @sampling_rate: sampling rate of decoded samples
126c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
127c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_get_tstamp(struct compress *compress,
128c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent		unsigned long *samples, unsigned int *sampling_rate);
129c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
130c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
131c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_write: write data to the compress stream
132c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return bytes written on success, negative on error
13379c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * By default this is a blocking call and will not return
13479c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * until all bytes have been written or there was a
13579c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * write error.
13679c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * If non-blocking mode has been enabled with compress_nonblock(),
13779c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * this function will write all bytes that can be written without
13879c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * blocking and will then return the number of bytes successfully
13979c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * written. If the return value is not an error and is < size
14079c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * the caller can use compress_wait() to block until the driver
14179c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * is ready for more data.
142c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
143c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream to be written to
144c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @buf: pointer to data
145c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @size: number of bytes to be written
146c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
147c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_write(struct compress *compress, const void *buf, unsigned int size);
148c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
149c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
150c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_read: read data from the compress stream
151c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return bytes read on success, negative on error
15279c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * By default this is a blocking call and will block until
15379c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * size bytes have been written or there was a read error.
15479c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * If non-blocking mode was enabled using compress_nonblock()
15579c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * the behaviour will change to read only as many bytes as
15679c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * are currently available (if no bytes are available it
15779c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * will return immediately). The caller can then use
15879c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent * compress_wait() to block until more bytes are available.
159c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
160c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream from where data is to be read
161c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @buf: pointer to data buffer
162c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @size: size of given buffer
163c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
164c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_read(struct compress *compress, void *buf, unsigned int size);
165c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
166c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
167c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_start: start the compress stream
168c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return 0 on success, negative on error
169c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
170c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream to be started
171c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
172c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_start(struct compress *compress);
173c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
174c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
175c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_stop: stop the compress stream
176c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return 0 on success, negative on error
177c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
178c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream to be stopped
179c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
180c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_stop(struct compress *compress);
181c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
182c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
183c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_pause: pause the compress stream
184c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return 0 on success, negative on error
185c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
186c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream to be paused
187c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
188c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_pause(struct compress *compress);
189c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
190c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
191c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_resume: resume the compress stream
192c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return 0 on success, negative on error
193c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
194c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream to be resumed
195c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
196c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_resume(struct compress *compress);
197c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
198c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
199c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_drain: drain the compress stream
200c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return 0 on success, negative on error
201c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
202c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream to be drain
203c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
204c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_drain(struct compress *compress);
205c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
206c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
207c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_next_track: set the next track for stream
208c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
209c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return 0 on success, negative on error
210c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
211c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream to be transistioned to next track
212c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
213c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_next_track(struct compress *compress);
214c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
215c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
216c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_partial_drain: drain will return after the last frame is decoded
217c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * by DSP and will play the , All the data written into compressed
218c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * ring buffer is decoded
219c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
220c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return 0 on success, negative on error
221c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
222c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream to be drain
223c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
224c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_partial_drain(struct compress *compress);
225c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
226c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
227c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_set_gapless_metadata: set gapless metadata of a compress strem
228c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
229c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * return 0 on success, negative on error
230c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
231c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @compress: compress stream for which metadata has to set
232c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @mdata: metadata encoder delay and  padding
233c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
234c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
235c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint compress_set_gapless_metadata(struct compress *compress,
236c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent			struct compr_gapless_mdata *mdata);
237c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
238c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
239c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * is_codec_supported:check if the given codec is supported
240c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * returns true when supported, false if not
241c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent *
242c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @card: sound card number
243c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @device: device number
244c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @flags: stream flags
245c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * @codec: codec type and parameters to be checked
246c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
247c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentbool is_codec_supported(unsigned int card, unsigned int device,
248c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent	       unsigned int flags, struct snd_codec *codec);
249c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
250c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
251c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * compress_set_max_poll_wait: set the maximum time tinycompress
252c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * will wait for driver to signal a poll(). Interval is in
253c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * milliseconds.
254c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * Pass interval of -1 to disable timeout and make poll() wait
255c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * until driver signals.
256c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * If this function is not used the timeout defaults to 20 seconds.
257c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
258c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentvoid compress_set_max_poll_wait(struct compress *compress, int milliseconds);
259c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
26079c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent/* Enable or disable non-blocking mode for write and read */
26179c370788bfeac8e2951cc35844fb96f15f28159Eric Laurentvoid compress_nonblock(struct compress *compress, int nonblock);
26279c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent
26379c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent/* Wait for ring buffer to ready for next read or write */
26479c370788bfeac8e2951cc35844fb96f15f28159Eric Laurentint compress_wait(struct compress *compress, int timeout_ms);
26579c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent
266c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint is_compress_running(struct compress *compress);
267c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
268c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentint is_compress_ready(struct compress *compress);
269c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
270c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/* Returns a human readable reason for the last error */
271c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurentconst char *compress_get_error(struct compress *compress);
272c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent/*
273c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * since the SNDRV_PCM_RATE_* is not availble anywhere in userspace
274c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * and we have used these to define the sampling rate, we need to define
275c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent * then here
276c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent */
277c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_5512		(1<<0)		/* 5512Hz */
278c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_8000		(1<<1)		/* 8000Hz */
279c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_11025		(1<<2)		/* 11025Hz */
280c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_16000		(1<<3)		/* 16000Hz */
281c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_22050		(1<<4)		/* 22050Hz */
282c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_32000		(1<<5)		/* 32000Hz */
283c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_44100		(1<<6)		/* 44100Hz */
284c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_48000		(1<<7)		/* 48000Hz */
285c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_64000		(1<<8)		/* 64000Hz */
286c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_88200		(1<<9)		/* 88200Hz */
287c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_96000		(1<<10)		/* 96000Hz */
288c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_176400		(1<<11)		/* 176400Hz */
289c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#define SNDRV_PCM_RATE_192000		(1<<12)		/* 192000Hz */
290c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent
29179c370788bfeac8e2951cc35844fb96f15f28159Eric Laurent/* utility functions */
29279c370788bfeac8e2951cc35844fb96f15f28159Eric Laurentunsigned int compress_get_alsa_rate(unsigned int rate);
29325a4b4b5c7451702a164c98ef502e41cc03e1e1fHaynes Mathew George
29425a4b4b5c7451702a164c98ef502e41cc03e1e1fHaynes Mathew George
29525a4b4b5c7451702a164c98ef502e41cc03e1e1fHaynes Mathew George#if defined(__cplusplus)
29625a4b4b5c7451702a164c98ef502e41cc03e1e1fHaynes Mathew George}
29725a4b4b5c7451702a164c98ef502e41cc03e1e1fHaynes Mathew George#endif
29825a4b4b5c7451702a164c98ef502e41cc03e1e1fHaynes Mathew George
299c902d7fb4e0f2b086030f384ce217679775ca2d4Eric Laurent#endif
300