2019-05-27 06:55:05 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifndef __PCM_PLUGIN_H
|
|
|
|
#define __PCM_PLUGIN_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Digital Audio (Plugin interface) abstract layer
|
2007-10-15 07:50:19 +00:00
|
|
|
* Copyright (c) by Jaroslav Kysela <perex@perex.cz>
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
2006-01-13 08:12:11 +00:00
|
|
|
#ifdef CONFIG_SND_PCM_OSS_PLUGINS
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define snd_pcm_plug_stream(plug) ((plug)->stream)
|
|
|
|
|
2005-11-17 13:01:49 +00:00
|
|
|
enum snd_pcm_plugin_action {
|
2005-04-16 22:20:36 +00:00
|
|
|
INIT = 0,
|
|
|
|
PREPARE = 1,
|
2005-11-17 13:01:49 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-17 13:01:49 +00:00
|
|
|
struct snd_pcm_channel_area {
|
2005-04-16 22:20:36 +00:00
|
|
|
void *addr; /* base address of channel samples */
|
|
|
|
unsigned int first; /* offset to first sample in bits */
|
|
|
|
unsigned int step; /* samples distance in bits */
|
2005-11-17 13:01:49 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-17 13:01:49 +00:00
|
|
|
struct snd_pcm_plugin_channel {
|
2005-04-16 22:20:36 +00:00
|
|
|
void *aptr; /* pointer to the allocated area */
|
2005-11-17 13:01:49 +00:00
|
|
|
struct snd_pcm_channel_area area;
|
2005-04-16 22:20:36 +00:00
|
|
|
snd_pcm_uframes_t frames; /* allocated frames */
|
|
|
|
unsigned int enabled:1; /* channel need to be processed */
|
|
|
|
unsigned int wanted:1; /* channel is wanted */
|
2005-11-17 13:01:49 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-17 13:01:49 +00:00
|
|
|
struct snd_pcm_plugin_format {
|
2011-02-14 10:00:47 +00:00
|
|
|
snd_pcm_format_t format;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned int rate;
|
|
|
|
unsigned int channels;
|
2005-11-17 13:01:49 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-17 13:01:49 +00:00
|
|
|
struct snd_pcm_plugin {
|
2005-04-16 22:20:36 +00:00
|
|
|
const char *name; /* plug-in name */
|
|
|
|
int stream;
|
2005-11-17 13:01:49 +00:00
|
|
|
struct snd_pcm_plugin_format src_format; /* source format */
|
|
|
|
struct snd_pcm_plugin_format dst_format; /* destination format */
|
2005-04-16 22:20:36 +00:00
|
|
|
int src_width; /* sample width in bits */
|
|
|
|
int dst_width; /* sample width in bits */
|
2011-02-14 10:00:47 +00:00
|
|
|
snd_pcm_access_t access;
|
2005-11-17 13:01:49 +00:00
|
|
|
snd_pcm_sframes_t (*src_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t dst_frames);
|
|
|
|
snd_pcm_sframes_t (*dst_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t src_frames);
|
|
|
|
snd_pcm_sframes_t (*client_channels)(struct snd_pcm_plugin *plugin,
|
|
|
|
snd_pcm_uframes_t frames,
|
|
|
|
struct snd_pcm_plugin_channel **channels);
|
|
|
|
snd_pcm_sframes_t (*transfer)(struct snd_pcm_plugin *plugin,
|
|
|
|
const struct snd_pcm_plugin_channel *src_channels,
|
|
|
|
struct snd_pcm_plugin_channel *dst_channels,
|
|
|
|
snd_pcm_uframes_t frames);
|
|
|
|
int (*action)(struct snd_pcm_plugin *plugin,
|
|
|
|
enum snd_pcm_plugin_action action,
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned long data);
|
2005-11-17 13:01:49 +00:00
|
|
|
struct snd_pcm_plugin *prev;
|
|
|
|
struct snd_pcm_plugin *next;
|
|
|
|
struct snd_pcm_substream *plug;
|
2005-04-16 22:20:36 +00:00
|
|
|
void *private_data;
|
2005-11-17 13:01:49 +00:00
|
|
|
void (*private_free)(struct snd_pcm_plugin *plugin);
|
2005-04-16 22:20:36 +00:00
|
|
|
char *buf;
|
|
|
|
snd_pcm_uframes_t buf_frames;
|
2005-11-17 13:01:49 +00:00
|
|
|
struct snd_pcm_plugin_channel *buf_channels;
|
2005-04-16 22:20:36 +00:00
|
|
|
char extra_data[0];
|
|
|
|
};
|
|
|
|
|
2005-11-17 13:01:49 +00:00
|
|
|
int snd_pcm_plugin_build(struct snd_pcm_substream *handle,
|
2005-04-16 22:20:36 +00:00
|
|
|
const char *name,
|
2005-11-17 13:01:49 +00:00
|
|
|
struct snd_pcm_plugin_format *src_format,
|
|
|
|
struct snd_pcm_plugin_format *dst_format,
|
2005-04-16 22:20:36 +00:00
|
|
|
size_t extra,
|
2005-11-17 13:01:49 +00:00
|
|
|
struct snd_pcm_plugin **ret);
|
|
|
|
int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin);
|
|
|
|
int snd_pcm_plugin_clear(struct snd_pcm_plugin **first);
|
|
|
|
int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames);
|
|
|
|
snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size);
|
|
|
|
snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define FULL ROUTE_PLUGIN_RESOLUTION
|
|
|
|
#define HALF ROUTE_PLUGIN_RESOLUTION / 2
|
2005-11-17 13:01:49 +00:00
|
|
|
|
|
|
|
int snd_pcm_plugin_build_io(struct snd_pcm_substream *handle,
|
|
|
|
struct snd_pcm_hw_params *params,
|
|
|
|
struct snd_pcm_plugin **r_plugin);
|
|
|
|
int snd_pcm_plugin_build_linear(struct snd_pcm_substream *handle,
|
|
|
|
struct snd_pcm_plugin_format *src_format,
|
|
|
|
struct snd_pcm_plugin_format *dst_format,
|
|
|
|
struct snd_pcm_plugin **r_plugin);
|
|
|
|
int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *handle,
|
|
|
|
struct snd_pcm_plugin_format *src_format,
|
|
|
|
struct snd_pcm_plugin_format *dst_format,
|
|
|
|
struct snd_pcm_plugin **r_plugin);
|
|
|
|
int snd_pcm_plugin_build_rate(struct snd_pcm_substream *handle,
|
|
|
|
struct snd_pcm_plugin_format *src_format,
|
|
|
|
struct snd_pcm_plugin_format *dst_format,
|
|
|
|
struct snd_pcm_plugin **r_plugin);
|
|
|
|
int snd_pcm_plugin_build_route(struct snd_pcm_substream *handle,
|
|
|
|
struct snd_pcm_plugin_format *src_format,
|
|
|
|
struct snd_pcm_plugin_format *dst_format,
|
|
|
|
struct snd_pcm_plugin **r_plugin);
|
|
|
|
int snd_pcm_plugin_build_copy(struct snd_pcm_substream *handle,
|
|
|
|
struct snd_pcm_plugin_format *src_format,
|
|
|
|
struct snd_pcm_plugin_format *dst_format,
|
|
|
|
struct snd_pcm_plugin **r_plugin);
|
|
|
|
|
|
|
|
int snd_pcm_plug_format_plugins(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *params,
|
|
|
|
struct snd_pcm_hw_params *slave_params);
|
|
|
|
|
2011-02-14 10:00:47 +00:00
|
|
|
snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format,
|
2017-05-16 23:48:19 +00:00
|
|
|
const struct snd_mask *format_mask);
|
2005-11-17 13:01:49 +00:00
|
|
|
|
|
|
|
int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin);
|
|
|
|
|
|
|
|
snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *handle,
|
|
|
|
struct snd_pcm_plugin_channel *src_channels,
|
|
|
|
snd_pcm_uframes_t size);
|
|
|
|
snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *handle,
|
|
|
|
struct snd_pcm_plugin_channel *dst_channels_final,
|
|
|
|
snd_pcm_uframes_t size);
|
|
|
|
|
|
|
|
snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *handle,
|
|
|
|
char *buf, snd_pcm_uframes_t count,
|
|
|
|
struct snd_pcm_plugin_channel **channels);
|
|
|
|
|
|
|
|
snd_pcm_sframes_t snd_pcm_plugin_client_channels(struct snd_pcm_plugin *plugin,
|
|
|
|
snd_pcm_uframes_t frames,
|
|
|
|
struct snd_pcm_plugin_channel **channels);
|
|
|
|
|
|
|
|
int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_channel,
|
|
|
|
size_t dst_offset,
|
2011-02-14 10:00:47 +00:00
|
|
|
size_t samples, snd_pcm_format_t format);
|
2005-11-17 13:01:49 +00:00
|
|
|
int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel,
|
|
|
|
size_t src_offset,
|
|
|
|
const struct snd_pcm_channel_area *dst_channel,
|
|
|
|
size_t dst_offset,
|
2011-02-14 10:00:47 +00:00
|
|
|
size_t samples, snd_pcm_format_t format);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-17 13:01:49 +00:00
|
|
|
void *snd_pcm_plug_buf_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t size);
|
|
|
|
void snd_pcm_plug_buf_unlock(struct snd_pcm_substream *plug, void *ptr);
|
|
|
|
snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream,
|
|
|
|
const char *ptr, snd_pcm_uframes_t size,
|
|
|
|
int in_kernel);
|
|
|
|
snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream,
|
|
|
|
char *ptr, snd_pcm_uframes_t size, int in_kernel);
|
|
|
|
snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream,
|
2017-05-21 17:08:57 +00:00
|
|
|
void **bufs, snd_pcm_uframes_t frames);
|
2005-11-17 13:01:49 +00:00
|
|
|
snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream,
|
2017-05-21 17:08:57 +00:00
|
|
|
void **bufs, snd_pcm_uframes_t frames);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-01-13 08:12:11 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
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; }
|
|
|
|
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; }
|
2017-05-18 13:35:55 +00:00
|
|
|
static inline int snd_pcm_plug_slave_format(int format, const struct snd_mask *format_mask) { return format; }
|
2006-01-13 08:12:11 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef PLUGIN_DEBUG
|
2009-02-05 14:51:04 +00:00
|
|
|
#define pdprintf(fmt, args...) printk(KERN_DEBUG "plugin: " fmt, ##args)
|
2005-04-16 22:20:36 +00:00
|
|
|
#else
|
2009-02-05 14:51:04 +00:00
|
|
|
#define pdprintf(fmt, args...)
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __PCM_PLUGIN_H */
|