Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/sound/core/oss/pcm_plugin.h
26424 views
1
/* SPDX-License-Identifier: GPL-2.0-or-later */
2
#ifndef __PCM_PLUGIN_H
3
#define __PCM_PLUGIN_H
4
5
/*
6
* Digital Audio (Plugin interface) abstract layer
7
* Copyright (c) by Jaroslav Kysela <[email protected]>
8
*/
9
10
#ifdef CONFIG_SND_PCM_OSS_PLUGINS
11
12
#define snd_pcm_plug_stream(plug) ((plug)->stream)
13
14
enum snd_pcm_plugin_action {
15
INIT = 0,
16
PREPARE = 1,
17
};
18
19
struct snd_pcm_channel_area {
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 */
23
};
24
25
struct snd_pcm_plugin_channel {
26
void *aptr; /* pointer to the allocated area */
27
struct snd_pcm_channel_area area;
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 */
31
};
32
33
struct snd_pcm_plugin_format {
34
snd_pcm_format_t format;
35
unsigned int rate;
36
unsigned int channels;
37
};
38
39
struct snd_pcm_plugin {
40
const char *name; /* plug-in name */
41
int stream;
42
struct snd_pcm_plugin_format src_format; /* source format */
43
struct snd_pcm_plugin_format dst_format; /* destination format */
44
int src_width; /* sample width in bits */
45
int dst_width; /* sample width in bits */
46
snd_pcm_access_t access;
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);
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,
58
unsigned long data);
59
struct snd_pcm_plugin *prev;
60
struct snd_pcm_plugin *next;
61
struct snd_pcm_substream *plug;
62
void *private_data;
63
void (*private_free)(struct snd_pcm_plugin *plugin);
64
char *buf;
65
snd_pcm_uframes_t buf_frames;
66
struct snd_pcm_plugin_channel *buf_channels;
67
char extra_data[];
68
};
69
70
int snd_pcm_plugin_build(struct snd_pcm_substream *handle,
71
const char *name,
72
struct snd_pcm_plugin_format *src_format,
73
struct snd_pcm_plugin_format *dst_format,
74
size_t extra,
75
struct snd_pcm_plugin **ret);
76
int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin);
77
int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames);
78
snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size);
79
snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size);
80
81
#define FULL ROUTE_PLUGIN_RESOLUTION
82
#define HALF ROUTE_PLUGIN_RESOLUTION / 2
83
84
int snd_pcm_plugin_build_io(struct snd_pcm_substream *handle,
85
struct snd_pcm_hw_params *params,
86
struct snd_pcm_plugin **r_plugin);
87
int snd_pcm_plugin_build_linear(struct snd_pcm_substream *handle,
88
struct snd_pcm_plugin_format *src_format,
89
struct snd_pcm_plugin_format *dst_format,
90
struct snd_pcm_plugin **r_plugin);
91
int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *handle,
92
struct snd_pcm_plugin_format *src_format,
93
struct snd_pcm_plugin_format *dst_format,
94
struct snd_pcm_plugin **r_plugin);
95
int snd_pcm_plugin_build_rate(struct snd_pcm_substream *handle,
96
struct snd_pcm_plugin_format *src_format,
97
struct snd_pcm_plugin_format *dst_format,
98
struct snd_pcm_plugin **r_plugin);
99
int snd_pcm_plugin_build_route(struct snd_pcm_substream *handle,
100
struct snd_pcm_plugin_format *src_format,
101
struct snd_pcm_plugin_format *dst_format,
102
struct snd_pcm_plugin **r_plugin);
103
int snd_pcm_plugin_build_copy(struct snd_pcm_substream *handle,
104
struct snd_pcm_plugin_format *src_format,
105
struct snd_pcm_plugin_format *dst_format,
106
struct snd_pcm_plugin **r_plugin);
107
108
int snd_pcm_plug_format_plugins(struct snd_pcm_substream *substream,
109
struct snd_pcm_hw_params *params,
110
struct snd_pcm_hw_params *slave_params);
111
112
snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format,
113
const struct snd_mask *format_mask);
114
115
int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin);
116
117
snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *handle,
118
struct snd_pcm_plugin_channel *src_channels,
119
snd_pcm_uframes_t size);
120
snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *handle,
121
struct snd_pcm_plugin_channel *dst_channels_final,
122
snd_pcm_uframes_t size);
123
124
snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *handle,
125
char *buf, snd_pcm_uframes_t count,
126
struct snd_pcm_plugin_channel **channels);
127
128
snd_pcm_sframes_t snd_pcm_plugin_client_channels(struct snd_pcm_plugin *plugin,
129
snd_pcm_uframes_t frames,
130
struct snd_pcm_plugin_channel **channels);
131
132
int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_channel,
133
size_t dst_offset,
134
size_t samples, snd_pcm_format_t format);
135
int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel,
136
size_t src_offset,
137
const struct snd_pcm_channel_area *dst_channel,
138
size_t dst_offset,
139
size_t samples, snd_pcm_format_t format);
140
141
#else
142
143
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; }
144
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; }
145
static inline int snd_pcm_plug_slave_format(int format, const struct snd_mask *format_mask) { return format; }
146
147
#endif
148
149
snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream,
150
const char *ptr, snd_pcm_uframes_t size,
151
int in_kernel);
152
snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream,
153
char *ptr, snd_pcm_uframes_t size, int in_kernel);
154
snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream,
155
void **bufs, snd_pcm_uframes_t frames);
156
snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream,
157
void **bufs, snd_pcm_uframes_t frames);
158
159
#ifdef PLUGIN_DEBUG
160
#define pdprintf(fmt, args...) pr_debug("plugin: " fmt, ##args)
161
#else
162
#define pdprintf(fmt, args...)
163
#endif
164
165
#endif /* __PCM_PLUGIN_H */
166
167