blob: 281df3b3f969dff59c14a9622c93b748d80ad981 [file] [log] [blame]
Seppo Ingalsuoc46d66d2017-09-25 14:09:13 +03001/*
2 * Copyright (c) 2017, Intel Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the Intel Corporation nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
29 */
30
31#ifndef EQ_H
32#define EQ_H
33
34/* FIR EQ type */
35
36/* Component will reject non-matching configuration. The version number need
37 * to be incremented with any ABI changes in function fir_cmd().
38 */
39#define SOF_EQ_FIR_ABI_VERSION 1
40
41#define SOF_EQ_FIR_MAX_SIZE 4096 /* Max size allowed for coef data in bytes */
42
43/*
44 * eq_fir_configuration data structure contains this information
45 * uint16_t channels_in_config
46 * This describes the number of channels in this EQ config data. It
47 * can be different from PLATFORM_MAX_CHANNELS.
48 * uint16_t number_of_responses
49 * 0=no responses, 1=one response defined, 2=two responses defined, etc.
50 * int16_t data[]
51 * assign_response[STREAM_MAX_CHANNELS]
52 * -1 = not defined, 0 = use first response, 1 = use 2nd response, etc.
53 * E.g. {0, 0, 0, 0, -1, -1, -1, -1} would apply to channels 0-3 the
54 * same first defined response and leave channels 4-7 unequalized.
55 * coef_data[]
56 * Repeated data { filter_length, input_shift, output_shift, h[] }
57 * for every EQ response defined where vector h has filter_length
58 * number of coefficients. Coefficients in h[] are in Q1.15 format.
59 * E.g. 16384 (Q1.15) = 0.5. The shifts are number of right shifts.
60 */
61
62struct sof_eq_fir_config {
63 uint16_t channels_in_config;
64 uint16_t number_of_responses;
65 int16_t data[];
66};
67
68/* IIR EQ type */
69
70/* Component will reject non-matching configuration. The version number need
71 * to be incremented with any ABI changes in function fir_cmd().
72 */
73#define SOF_EQ_FIR_ABI_VERSION 1
74
75#define SOF_EQ_IIR_MAX_SIZE 1024 /* Max size allowed for coef data in bytes */
76
77/* eq_iir_configuration
78 * uint32_t channels_in_config
79 * This describes the number of channels in this EQ config data. It
80 * can be different from PLATFORM_MAX_CHANNELS.
81 * uint32_t number_of_responses_defined
82 * 0=no responses, 1=one response defined, 2=two responses defined, etc.
83 * int32_t data[]
84 * Data consist of two parts. First is the response assign vector that
85 * has length of channels_in_config. The latter part is coefficient
86 * data.
87 * uint32_t assign_response[channels_in_config]
88 * -1 = not defined, 0 = use first response, 1 = use 2nd, etc.
89 * E.g. {0, 0, 0, 0, -1, -1, -1, -1} would apply to channels 0-3 the
90 * same first defined response and leave channels 4-7 unequalized.
91 * coefficient_data[]
92 * <1st EQ>
93 * uint32_t num_biquads
94 * uint32_t num_biquads_in_series
95 * <1st biquad>
96 * int32_t coef_a2 Q2.30 format
97 * int32_t coef_a1 Q2.30 format
98 * int32_t coef_b2 Q2.30 format
99 * int32_t coef_b1 Q2.30 format
100 * int32_t coef_b0 Q2.30 format
101 * int32_t output_shift number of shifts right, shift left is negative
102 * int32_t output_gain Q2.14 format
103 * <2nd biquad>
104 * ...
105 * <2nd EQ>
106 *
107 * Note: A flat response biquad can be made with a section set to
108 * b0 = 1.0, gain = 1.0, and other parameters set to 0
109 * {0, 0, 0, 0, 1073741824, 0, 16484}
110 */
111
112struct sof_eq_iir_config {
113 uint32_t channels_in_config;
114 uint32_t number_of_responses;
115 int32_t data[];
116};
117
118#endif /* EQ_H */