]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
1da177e4 LT |
2 | #ifndef __PCM_PLUGIN_H |
3 | #define __PCM_PLUGIN_H | |
4 | ||
5 | /* | |
6 | * Digital Audio (Plugin interface) abstract layer | |
c1017a4c | 7 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz> |
1da177e4 LT |
8 | */ |
9 | ||
21a3479a JK |
10 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS |
11 | ||
1da177e4 LT |
12 | #define snd_pcm_plug_stream(plug) ((plug)->stream) |
13 | ||
6ac77bc1 | 14 | enum snd_pcm_plugin_action { |
1da177e4 LT |
15 | INIT = 0, |
16 | PREPARE = 1, | |
6ac77bc1 | 17 | }; |
1da177e4 | 18 | |
6ac77bc1 | 19 | struct snd_pcm_channel_area { |
1da177e4 LT |
20 | void *addr; /* base address of channel samples */ |
21 | unsigned int first; /* offset to first sample in bits */ | |
22 | unsigned int step; /* samples distance in bits */ | |
6ac77bc1 | 23 | }; |
1da177e4 | 24 | |
6ac77bc1 | 25 | struct snd_pcm_plugin_channel { |
1da177e4 | 26 | void *aptr; /* pointer to the allocated area */ |
6ac77bc1 | 27 | struct snd_pcm_channel_area area; |
1da177e4 LT |
28 | snd_pcm_uframes_t frames; /* allocated frames */ |
29 | unsigned int enabled:1; /* channel need to be processed */ | |
30 | unsigned int wanted:1; /* channel is wanted */ | |
6ac77bc1 | 31 | }; |
1da177e4 | 32 | |
6ac77bc1 | 33 | struct snd_pcm_plugin_format { |
fea952e5 | 34 | snd_pcm_format_t format; |
1da177e4 LT |
35 | unsigned int rate; |
36 | unsigned int channels; | |
6ac77bc1 | 37 | }; |
1da177e4 | 38 | |
6ac77bc1 | 39 | struct snd_pcm_plugin { |
1da177e4 LT |
40 | const char *name; /* plug-in name */ |
41 | int stream; | |
6ac77bc1 TI |
42 | struct snd_pcm_plugin_format src_format; /* source format */ |
43 | struct snd_pcm_plugin_format dst_format; /* destination format */ | |
1da177e4 LT |
44 | int src_width; /* sample width in bits */ |
45 | int dst_width; /* sample width in bits */ | |
fea952e5 | 46 | snd_pcm_access_t access; |
6ac77bc1 TI |
47 | snd_pcm_sframes_t (*src_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t dst_frames); |
48 | snd_pcm_sframes_t (*dst_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t src_frames); | |
49 | snd_pcm_sframes_t (*client_channels)(struct snd_pcm_plugin *plugin, | |
50 | snd_pcm_uframes_t frames, | |
51 | struct snd_pcm_plugin_channel **channels); | |
6ac77bc1 TI |
52 | snd_pcm_sframes_t (*transfer)(struct snd_pcm_plugin *plugin, |
53 | const struct snd_pcm_plugin_channel *src_channels, | |
54 | struct snd_pcm_plugin_channel *dst_channels, | |
55 | snd_pcm_uframes_t frames); | |
56 | int (*action)(struct snd_pcm_plugin *plugin, | |
57 | enum snd_pcm_plugin_action action, | |
1da177e4 | 58 | unsigned long data); |
6ac77bc1 TI |
59 | struct snd_pcm_plugin *prev; |
60 | struct snd_pcm_plugin *next; | |
61 | struct snd_pcm_substream *plug; | |
1da177e4 | 62 | void *private_data; |
6ac77bc1 | 63 | void (*private_free)(struct snd_pcm_plugin *plugin); |
1da177e4 LT |
64 | char *buf; |
65 | snd_pcm_uframes_t buf_frames; | |
6ac77bc1 | 66 | struct snd_pcm_plugin_channel *buf_channels; |
1da177e4 LT |
67 | char extra_data[0]; |
68 | }; | |
69 | ||
6ac77bc1 | 70 | int snd_pcm_plugin_build(struct snd_pcm_substream *handle, |
1da177e4 | 71 | const char *name, |
6ac77bc1 TI |
72 | struct snd_pcm_plugin_format *src_format, |
73 | struct snd_pcm_plugin_format *dst_format, | |
1da177e4 | 74 | size_t extra, |
6ac77bc1 TI |
75 | struct snd_pcm_plugin **ret); |
76 | int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin); | |
77 | int snd_pcm_plugin_clear(struct snd_pcm_plugin **first); | |
78 | int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames); | |
79 | snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size); | |
80 | snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size); | |
1da177e4 LT |
81 | |
82 | #define FULL ROUTE_PLUGIN_RESOLUTION | |
83 | #define HALF ROUTE_PLUGIN_RESOLUTION / 2 | |
6ac77bc1 TI |
84 | |
85 | int snd_pcm_plugin_build_io(struct snd_pcm_substream *handle, | |
86 | struct snd_pcm_hw_params *params, | |
87 | struct snd_pcm_plugin **r_plugin); | |
88 | int snd_pcm_plugin_build_linear(struct snd_pcm_substream *handle, | |
89 | struct snd_pcm_plugin_format *src_format, | |
90 | struct snd_pcm_plugin_format *dst_format, | |
91 | struct snd_pcm_plugin **r_plugin); | |
92 | int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *handle, | |
93 | struct snd_pcm_plugin_format *src_format, | |
94 | struct snd_pcm_plugin_format *dst_format, | |
95 | struct snd_pcm_plugin **r_plugin); | |
96 | int snd_pcm_plugin_build_rate(struct snd_pcm_substream *handle, | |
97 | struct snd_pcm_plugin_format *src_format, | |
98 | struct snd_pcm_plugin_format *dst_format, | |
99 | struct snd_pcm_plugin **r_plugin); | |
100 | int snd_pcm_plugin_build_route(struct snd_pcm_substream *handle, | |
101 | struct snd_pcm_plugin_format *src_format, | |
102 | struct snd_pcm_plugin_format *dst_format, | |
6ac77bc1 TI |
103 | struct snd_pcm_plugin **r_plugin); |
104 | int snd_pcm_plugin_build_copy(struct snd_pcm_substream *handle, | |
105 | struct snd_pcm_plugin_format *src_format, | |
106 | struct snd_pcm_plugin_format *dst_format, | |
107 | struct snd_pcm_plugin **r_plugin); | |
108 | ||
109 | int snd_pcm_plug_format_plugins(struct snd_pcm_substream *substream, | |
110 | struct snd_pcm_hw_params *params, | |
111 | struct snd_pcm_hw_params *slave_params); | |
112 | ||
fea952e5 | 113 | snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format, |
e76bf3c4 | 114 | const struct snd_mask *format_mask); |
6ac77bc1 TI |
115 | |
116 | int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin); | |
117 | ||
118 | snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *handle, | |
119 | struct snd_pcm_plugin_channel *src_channels, | |
120 | snd_pcm_uframes_t size); | |
121 | snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *handle, | |
122 | struct snd_pcm_plugin_channel *dst_channels_final, | |
123 | snd_pcm_uframes_t size); | |
124 | ||
125 | snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *handle, | |
126 | char *buf, snd_pcm_uframes_t count, | |
127 | struct snd_pcm_plugin_channel **channels); | |
128 | ||
129 | snd_pcm_sframes_t snd_pcm_plugin_client_channels(struct snd_pcm_plugin *plugin, | |
130 | snd_pcm_uframes_t frames, | |
131 | struct snd_pcm_plugin_channel **channels); | |
132 | ||
133 | int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_channel, | |
134 | size_t dst_offset, | |
fea952e5 | 135 | size_t samples, snd_pcm_format_t format); |
6ac77bc1 TI |
136 | int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel, |
137 | size_t src_offset, | |
138 | const struct snd_pcm_channel_area *dst_channel, | |
139 | size_t dst_offset, | |
fea952e5 | 140 | size_t samples, snd_pcm_format_t format); |
1da177e4 | 141 | |
6ac77bc1 TI |
142 | void *snd_pcm_plug_buf_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t size); |
143 | void snd_pcm_plug_buf_unlock(struct snd_pcm_substream *plug, void *ptr); | |
144 | snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, | |
145 | const char *ptr, snd_pcm_uframes_t size, | |
146 | int in_kernel); | |
147 | snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, | |
148 | char *ptr, snd_pcm_uframes_t size, int in_kernel); | |
149 | snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream, | |
fed5794f | 150 | void **bufs, snd_pcm_uframes_t frames); |
6ac77bc1 | 151 | snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream, |
fed5794f | 152 | void **bufs, snd_pcm_uframes_t frames); |
1da177e4 | 153 | |
21a3479a JK |
154 | #else |
155 | ||
156 | static inline snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size) { return drv_size; } | |
157 | static inline snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size) { return clt_size; } | |
dcab5fb7 | 158 | static inline int snd_pcm_plug_slave_format(int format, const struct snd_mask *format_mask) { return format; } |
21a3479a JK |
159 | |
160 | #endif | |
161 | ||
1da177e4 | 162 | #ifdef PLUGIN_DEBUG |
006de267 | 163 | #define pdprintf(fmt, args...) printk(KERN_DEBUG "plugin: " fmt, ##args) |
1da177e4 | 164 | #else |
006de267 | 165 | #define pdprintf(fmt, args...) |
1da177e4 LT |
166 | #endif |
167 | ||
168 | #endif /* __PCM_PLUGIN_H */ |