forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselector.h
More file actions
154 lines (128 loc) · 4.35 KB
/
selector.h
File metadata and controls
154 lines (128 loc) · 4.35 KB
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
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2019 Intel Corporation. All rights reserved.
*
* Author: Lech Betlej <lech.betlej@linux.intel.com>
*/
/**
* \file audio/selector.h
* \brief Channel selector component header file
* \authors Lech Betlej <lech.betlej@linux.intel.com>
*/
#ifndef __SOF_AUDIO_SELECTOR_H__
#define __SOF_AUDIO_SELECTOR_H__
#include <sof/audio/module_adapter/module/generic.h>
#include <sof/trace/trace.h>
#include <ipc/stream.h>
#if CONFIG_IPC_MAJOR_4
#include <ipc4/base-config.h>
#endif
#include <user/selector.h>
#include <user/trace.h>
#include <stdint.h>
struct comp_buffer;
struct comp_dev;
#if CONFIG_IPC_MAJOR_3
/** \brief Supported channel count on input. */
#define SEL_SOURCE_2CH 2
#define SEL_SOURCE_4CH 4
/** \brief Supported channel count on output. */
#define SEL_SINK_1CH 1
#define SEL_SINK_2CH 2
#define SEL_SINK_4CH 4
#else
/** \brief Maximum supported channel count on input. */
#define SEL_SOURCE_CHANNELS_MAX 8
/** \brief Maximum supported channel count on output. */
#define SEL_SINK_CHANNELS_MAX 8
#define SEL_NUM_IN_PIN_FMTS 1
#define SEL_NUM_OUT_PIN_FMTS 1
#endif
#if CONFIG_IPC_MAJOR_4
/** \brief selector processing function interface */
typedef void (*sel_func)(struct processing_module *mod, struct input_stream_buffer *bsource,
struct output_stream_buffer *bsink, uint32_t frames);
/** \brief IPC4 configuration IDs for selector. */
enum ipc4_selector_config_id {
IPC4_SELECTOR_COEFFS_CONFIG_ID = 0, /**< Mixing coefficients config ID */
};
/** \brief IPC4 mixing coefficients configuration. */
struct ipc4_selector_coeffs_config {
uint16_t rsvd0; /**< Unused field, keeps the structure aligned with common layout */
uint16_t rsvd1; /**< Unused field, keeps the structure aligned with common layout */
/** Mixing coefficients in Q10 fixed point format */
int16_t coeffs[SEL_SINK_CHANNELS_MAX][SEL_SOURCE_CHANNELS_MAX];
};
enum ipc4_selector_init_payload_fmt {
IPC4_SEL_INIT_PAYLOAD_BASE_WITH_EXT,
IPC4_SEL_INIT_PAYLOAD_BASE_WITH_OUT_FMT,
};
struct sof_selector_ipc4_pin_config {
struct ipc4_input_pin_format in_pin;
struct ipc4_output_pin_format out_pin;
};
/*
* Base module config is not added in this structure because it is handled
* by module adapter.
*/
struct sof_selector_ipc4_config {
/*
* Windows will send the base_config + output_format payload, but Linux will
* send the base_config + base_config_ext payload, use a union to make the
* selector module be compatible for both OSes.
*/
union {
struct sof_selector_ipc4_pin_config pin_cfg;
struct ipc4_audio_format output_format;
};
enum ipc4_selector_init_payload_fmt init_payload_fmt;
};
struct sof_selector_avs_ipc4_config {
struct ipc4_base_module_cfg base_cfg;
struct ipc4_audio_format output_format;
};
#else
typedef void (*sel_func)(struct comp_dev *dev, struct audio_stream *sink,
const struct audio_stream *source, uint32_t frames);
#endif
/** \brief Selector component private data. */
struct comp_data {
#if CONFIG_IPC_MAJOR_4
struct sof_selector_ipc4_config sel_ipc4_cfg;
struct ipc4_selector_coeffs_config coeffs_config;
#endif
uint32_t source_period_bytes; /**< source number of period bytes */
uint32_t sink_period_bytes; /**< sink number of period bytes */
enum sof_ipc_frame source_format; /**< source frame format */
enum sof_ipc_frame sink_format; /**< sink frame format */
struct sof_sel_config config; /**< component configuration data */
sel_func sel_func; /**< channel selector processing function */
};
/** \brief Selector processing functions map. */
struct comp_func_map {
uint16_t source; /**< source frame format */
uint32_t out_channels; /**< number of output stream channels */
sel_func sel_func; /**< selector processing function */
};
/** \brief Map of formats with dedicated processing functions. */
extern const struct comp_func_map func_map[];
#if CONFIG_IPC_MAJOR_4
/**
* \brief Retrieves selector processing function.
* \param[in,out] mod Selector module adapter.
*/
sel_func sel_get_processing_function(struct processing_module *mod);
#ifdef UNIT_TEST
void sys_comp_module_selector_interface_init(void);
#endif
#else
/**
* \brief Retrieves selector processing function.
* \param[in,out] dev Selector base component device.
*/
sel_func sel_get_processing_function(struct comp_dev *dev);
#ifdef UNIT_TEST
void sys_comp_selector_init(void);
#endif
#endif
#endif /* __SOF_AUDIO_SELECTOR_H__ */