summaryrefslogtreecommitdiffstats
path: root/include/sound/compress_driver.h
blob: c0abcdc1147083f9faa8a036357a5468429ff00a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
 *  compress_driver.h - compress offload driver definations
 *
 *  Copyright (C) 2011 Intel Corporation
 *  Authors:	Vinod Koul <vinod.koul@linux.intel.com>
 *		Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
 *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 */
#ifndef __COMPRESS_DRIVER_H
#define __COMPRESS_DRIVER_H

#include <linux/types.h>
#include <linux/sched.h>
#include <sound/core.h>
#include <sound/compress_offload.h>
#include <sound/asound.h>
#include <sound/pcm.h>

struct snd_compr_ops;

/**
 * struct snd_compr_runtime: runtime stream description
 * @state: stream state
 * @ops: pointer to DSP callbacks
 * @buffer: pointer to kernel buffer, valid only when not in mmap mode or
 *	DSP doesn't implement copy
 * @buffer_size: size of the above buffer
 * @fragment_size: size of buffer fragment in bytes
 * @fragments: number of such fragments
 * @total_bytes_available: cumulative number of bytes made available in
 *	the ring buffer
 * @total_bytes_transferred: cumulative bytes transferred by offload DSP
 * @sleep: poll sleep
 * @private_data: driver private data pointer
 */
struct snd_compr_runtime {
	snd_pcm_state_t state;
	struct snd_compr_ops *ops;
	void *buffer;
	u64 buffer_size;
	u32 fragment_size;
	u32 fragments;
	u64 total_bytes_available;
	u64 total_bytes_transferred;
	wait_queue_head_t sleep;
	void *private_data;
};

/**
 * struct snd_compr_stream: compressed stream
 * @name: device name
 * @ops: pointer to DSP callbacks
 * @runtime: pointer to runtime structure
 * @device: device pointer
 * @direction: stream direction, playback/recording
 * @metadata_set: metadata set flag, true when set
 * @next_track: has userspace signal next track transition, true when set
 * @private_data: pointer to DSP private data
 */
struct snd_compr_stream {
	const char *name;
	struct snd_compr_ops *ops;
	struct snd_compr_runtime *runtime;
	struct snd_compr *device;
	enum snd_compr_direction direction;
	bool metadata_set;
	bool next_track;
	void *private_data;
};

/**
 * struct snd_compr_ops: compressed path DSP operations
 * @open: Open the compressed stream
 * This callback is mandatory and shall keep dsp ready to receive the stream
 * parameter
 * @free: Close the compressed stream, mandatory
 * @set_params: Sets the compressed stream parameters, mandatory
 * This can be called in during stream creation only to set codec params
 * and the stream properties
 * @get_params: retrieve the codec parameters, mandatory
 * @set_metadata: Set the metadata values for a stream
 * @get_metadata: retrieves the requested metadata values from stream
 * @trigger: Trigger operations like start, pause, resume, drain, stop.
 * This callback is mandatory
 * @pointer: Retrieve current h/w pointer information. Mandatory
 * @copy: Copy the compressed data to/from userspace, Optional
 * Can't be implemented if DSP supports mmap
 * @mmap: DSP mmap method to mmap DSP memory
 * @ack: Ack for DSP when data is written to audio buffer, Optional
 * Not valid if copy is implemented
 * @get_caps: Retrieve DSP capabilities, mandatory
 * @get_codec_caps: Retrieve capabilities for a specific codec, mandatory
 */
struct snd_compr_ops {
	int (*open)(struct snd_compr_stream *stream);
	int (*free)(struct snd_compr_stream *stream);
	int (*set_params)(struct snd_compr_stream *stream,
			struct snd_compr_params *params);
	int (*get_params)(struct snd_compr_stream *stream,
			struct snd_codec *params);
	int (*set_metadata)(struct snd_compr_stream *stream,
			struct snd_compr_metadata *metadata);
	int (*get_metadata)(struct snd_compr_stream *stream,
			struct snd_compr_metadata *metadata);
	int (*trigger)(struct snd_compr_stream *stream, int cmd);
	int (*pointer)(struct snd_compr_stream *stream,
			struct snd_compr_tstamp *tstamp);
	int (*copy)(struct snd_compr_stream *stream, char __user *buf,
		       size_t count);
	int (*mmap)(struct snd_compr_stream *stream,
			struct vm_area_struct *vma);
	int (*ack)(struct snd_compr_stream *stream, size_t bytes);
	int (*get_caps) (struct snd_compr_stream *stream,
			struct snd_compr_caps *caps);
	int (*get_codec_caps) (struct snd_compr_stream *stream,
			struct snd_compr_codec_caps *codec);
};

/**
 * struct snd_compr: Compressed device
 * @name: DSP device name
 * @dev: associated device instance
 * @ops: pointer to DSP callbacks
 * @private_data: pointer to DSP pvt data
 * @card: sound card pointer
 * @direction: Playback or capture direction
 * @lock: device lock
 * @device: device id
 */
struct snd_compr {
	const char *name;
	struct device dev;
	struct snd_compr_ops *ops;
	void *private_data;
	struct snd_card *card;
	unsigned int direction;
	struct mutex lock;
	int device;
#ifdef CONFIG_SND_VERBOSE_PROCFS
	char id[64];
	struct snd_info_entry *proc_root;
	struct snd_info_entry *proc_info_entry;
#endif
};

/* compress device register APIs */
int snd_compress_register(struct snd_compr *device);
int snd_compress_deregister(struct snd_compr *device);
int snd_compress_new(struct snd_card *card, int device,
			int type, const char *id, struct snd_compr *compr);

/* dsp driver callback apis
 * For playback: driver should call snd_compress_fragment_elapsed() to let the
 * framework know that a fragment has been consumed from the ring buffer
 *
 * For recording: we want to know when a frame is available or when
 * at least one frame is available so snd_compress_frame_elapsed()
 * callback should be called when a encodeded frame is available
 */
static inline void snd_compr_fragment_elapsed(struct snd_compr_stream *stream)
{
	wake_up(&stream->runtime->sleep);
}

static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
{
	if (snd_BUG_ON(!stream))
		return;

	stream->runtime->state = SNDRV_PCM_STATE_SETUP;
	wake_up(&stream->runtime->sleep);
}

#endif
t'>
1da177e4c3f4




d0217ac04ca6 ^

c2ec175c39f6 ^
d065bd810b6d ^
318b275fbca1 ^
37b23e0525d3 ^
45cac65b0fcd ^
d0217ac04ca6 ^
6bd9cd50c830 ^
d0217ac04ca6 ^
83c54070ee1a ^

54cb8821de07 ^
d0217ac04ca6 ^
0b173bc4daa8 ^
54cb8821de07 ^
d0217ac04ca6 ^





83c54070ee1a ^
d0217ac04ca6 ^
83c54070ee1a ^
d0217ac04ca6 ^
54cb8821de07 ^
1da177e4c3f4








d0217ac04ca6 ^
9637a5efd4fb ^


c2ec175c39f6 ^
28b2ee20c7cb ^





1da177e4c3f4
a6020ed75940 ^






1da177e4c3f4
a6020ed75940 ^










1da177e4c3f4

7b2259b3e53f ^

1da177e4c3f4
0b173bc4daa8 ^


1da177e4c3f4




349aef0bc4c7 ^

4c21e2f2441d ^
b12c4ad14ee0 ^


95e344124805 ^
b12c4ad14ee0 ^




95e344124805 ^
b12c4ad14ee0 ^

1da177e4c3f4




71e3aac0724f ^
1da177e4c3f4











1da177e4c3f4


da6052f7b33a ^
1da177e4c3f4
7c8ee9a86340 ^

725d704ecaca ^
8dc04efbfb3c ^
7c8ee9a86340 ^
1da177e4c3f4

7c8ee9a86340 ^

1da177e4c3f4
7c8ee9a86340 ^

8dc04efbfb3c ^
7c8ee9a86340 ^
1da177e4c3f4
53df8fdc15fb ^

48667e7a43c1 ^
b3bdda02aa54 ^

48667e7a43c1 ^
0738c4bb8f2a ^





9e2779fa281c ^

0738c4bb8f2a ^
9e2779fa281c ^


0738c4bb8f2a ^

8ca3ed87db06 ^
0738c4bb8f2a ^
81ac3ad9061d ^


934831d060cc ^
81ac3ad9061d ^



9e2779fa281c ^
e9da73d67729 ^


5bf5f03c2719 ^
e9da73d67729 ^






5bf5f03c2719 ^
e9da73d67729 ^






















d85f33855c30 ^

6d7779538f76 ^
d85f33855c30 ^



70b50f94f164 ^














4c21e2f2441d ^
1da177e4c3f4
d85f33855c30 ^
1da177e4c3f4

b35a35b556f5 ^










70b50f94f164 ^

1da177e4c3f4

70b50f94f164 ^


918070634448 ^

70b50f94f164 ^
918070634448 ^
70b50f94f164 ^
1da177e4c3f4


b49af68ff9fc ^





7835e98b2e3c ^








5f24ce5fd34c ^


ef2b4b95a63a ^




5f24ce5fd34c ^
ef2b4b95a63a ^

5f24ce5fd34c ^

ef2b4b95a63a ^
5f24ce5fd34c ^




ef2b4b95a63a ^
5f24ce5fd34c ^







1da177e4c3f4
1d7ea7324ae7 ^
1da177e4c3f4
8dfcc9ba27e2 ^
748446bb6b5a ^
8dfcc9ba27e2 ^
1da177e4c3f4
33f2ef89f8e1 ^
















d85f33855c30 ^

6d7779538f76 ^
d85f33855c30 ^



37c2ac7872a9 ^













d85f33855c30 ^




3dece370ecc7 ^
33f2ef89f8e1 ^
14fd403f2146 ^










3dece370ecc7 ^
14fd403f2146 ^

1da177e4c3f4





7e871b6c8f1f ^

da6052f7b33a ^
1da177e4c3f4
da6052f7b33a ^




1da177e4c3f4
da6052f7b33a ^








1da177e4c3f4


da6052f7b33a ^



1da177e4c3f4
da6052f7b33a ^


1da177e4c3f4
da6052f7b33a ^


1da177e4c3f4
da6052f7b33a ^


1da177e4c3f4
da6052f7b33a ^



1da177e4c3f4
da6052f7b33a ^
1da177e4c3f4

da6052f7b33a ^



1da177e4c3f4




1da177e4c3f4
348f8b6c4837 ^
d41dee369bff ^










308c05e35e35 ^


d41dee369bff ^
308c05e35e35 ^
d41dee369bff ^






9223b4190fa1 ^
d41dee369bff ^

308c05e35e35 ^


d41dee369bff ^



07808b74e7da ^
d41dee369bff ^






89689ae7f959 ^


d41dee369bff ^
348f8b6c4837 ^
25985edcedea ^
348f8b6c4837 ^


d41dee369bff ^


348f8b6c4837 ^
bce54bbfde07 ^

89689ae7f959 ^
bd8029b66069 ^

d41dee369bff ^
89689ae7f959 ^
bd8029b66069 ^

89689ae7f959 ^

bd8029b66069 ^
348f8b6c4837 ^
9223b4190fa1 ^

348f8b6c4837 ^

d41dee369bff ^


89689ae7f959 ^
348f8b6c4837 ^
33dd4e0ec911 ^
1da177e4c3f4
348f8b6c4837 ^
1da177e4c3f4
1da177e4c3f4
89689ae7f959 ^







cb2b95e1c6b5 ^

89689ae7f959 ^
348f8b6c4837 ^

25ba77c141db ^
89fa30242fac ^
d5f541ed6e31 ^




89fa30242fac ^

89689ae7f959 ^
33dd4e0ec911 ^
89689ae7f959 ^
33dd4e0ec911 ^
d41dee369bff ^
89689ae7f959 ^
d41dee369bff ^
89689ae7f959 ^

57e0a0309160 ^





























33dd4e0ec911 ^
89689ae7f959 ^



308c05e35e35 ^
bf4e8902ee50 ^





aa462abe8aaf ^
d41dee369bff ^


308c05e35e35 ^
d41dee369bff ^
2f1b6248682f ^
348f8b6c4837 ^



2f1b6248682f ^
348f8b6c4837 ^



1da177e4c3f4
89689ae7f959 ^
2f1b6248682f ^
d41dee369bff ^
1da177e4c3f4
348f8b6c4837 ^

bf4e8902ee50 ^
d41dee369bff ^
bf4e8902ee50 ^
1da177e4c3f4

f6ac2354d791 ^




33dd4e0ec911 ^
1da177e4c3f4
aa462abe8aaf ^
1da177e4c3f4















f99187947382 ^
1da177e4c3f4












3ca7b3c5b64d ^







1da177e4c3f4





3ca7b3c5b64d ^

1da177e4c3f4





b5fab14e5d87 ^
1da177e4c3f4

e20e87795834 ^
1da177e4c3f4



3ca7b3c5b64d ^





f981c5950fa8 ^










1da177e4c3f4











4c21e2f2441d ^
1da177e4c3f4


f981c5950fa8 ^













1da177e4c3f4
1da177e4c3f4







1da177e4c3f4



d0217ac04ca6 ^
83c54070ee1a ^
d0217ac04ca6 ^
83c54070ee1a ^



aa50d3a7aa81 ^

f33ea7f404e5 ^
83c54070ee1a ^

d065bd810b6d ^
1da177e4c3f4
aa50d3a7aa81 ^







d0217ac04ca6 ^
1c0fe6e3bda0 ^




1da177e4c3f4

ddd588b5dd55 ^
7bf02ea22c6c ^
ddd588b5dd55 ^



7bf02ea22c6c ^

1da177e4c3f4
1da177e4c3f4

e8edc6e03a5c ^
1da177e4c3f4










1da177e4c3f4

7e675137a8e1 ^


c627f9cc046c ^

14f5ff5df37a ^
1da177e4c3f4
4f74d2c8e827 ^

e6473092bd91 ^





033193275b3f ^


e6473092bd91 ^

5dc37642cbce ^
c27fe4c8942d ^

e6473092bd91 ^



2165009bdf63 ^




116354d177ba ^

2165009bdf63 ^

e6473092bd91 ^

2165009bdf63 ^

42b7772812d1 ^
3bf5ee95648c ^
1da177e4c3f4

1da177e4c3f4

3b6748e2dd69 ^

d87fe6607c31 ^

28b2ee20c7cb ^

1da177e4c3f4






25d9e2d15286 ^
2c27c65ed069 ^
623e3db9f9b7 ^
750b4987b0cd ^
257187362123 ^
83f786680aec ^

7ee1dd3fee22 ^
83c54070ee1a ^
d06063cc221f ^
5c723ba5b788 ^

7ee1dd3fee22 ^


d06063cc221f ^
7ee1dd3fee22 ^




5c723ba5b788 ^







7ee1dd3fee22 ^
f33ea7f404e5 ^
1da177e4c3f4

5ddd36b9c598 ^

1da177e4c3f4
0014bd990e69 ^



d2bf6be8ab63 ^
9d73777e5009 ^
d2bf6be8ab63 ^


18022c5d8627 ^



f3e8fccd06d2 ^
1da177e4c3f4
cf9a2ae8d499 ^


1da177e4c3f4
767193253bba ^
1da177e4c3f4

e3a7cca1ef4c ^
f629d1c9bd0d ^
b3c975286896 ^
1da177e4c3f4


39aa3cb3e825 ^
a09a79f66874 ^
39aa3cb3e825 ^



a09a79f66874 ^





















b76437579d13 ^


b6a2fea39318 ^

38a76013ad80 ^

1da177e4c3f4


7da4d641c58d ^

4b10e7d562c9 ^
b6a2fea39318 ^


1da177e4c3f4
21cc199baa81 ^
465a454f254e ^



d559db086ff5 ^


d559db086ff5 ^

69c978232aaa ^








172703b08cd0 ^
69c978232aaa ^

d559db086ff5 ^


172703b08cd0 ^
d559db086ff5 ^



172703b08cd0 ^
d559db086ff5 ^



172703b08cd0 ^
d559db086ff5 ^

d559db086ff5 ^