1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2020 Google LLC. All rights reserved.
4  *
5  * Author: Pin-chih Lin <johnylin@google.com>
6  */
7 
8 #ifndef __USER_MULTIBAND_DRC_H__
9 #define __USER_MULTIBAND_DRC_H__
10 
11 #include <stdint.h>
12 #include <user/crossover.h>
13 #include <user/drc.h>
14 #include <user/eq.h>
15 
16 /* Maximum number of frequency band for Multiband DRC */
17 #define SOF_MULTIBAND_DRC_MAX_BANDS SOF_CROSSOVER_MAX_STREAMS
18 
19 /* Maximum number of Crossover LR4 highpass and lowpass filters */
20 #define SOF_CROSSOVER_MAX_LR4 ((SOF_CROSSOVER_MAX_STREAMS - 1) * 2)
21 
22 /* The number of biquads (and biquads in series) of (De)Emphasis Equalizer */
23 #define SOF_EMP_DEEMP_BIQUADS 2
24 
25 /* Maximum number allowed of IPC configuration blob size */
26 #define SOF_MULTIBAND_DRC_MAX_BLOB_SIZE 1024
27 
28  /* multiband_drc configuration
29   *     Multiband DRC is a single-source-single-sink compound component which
30   *     consists of 4 stages: Emphasis Equalizer, Crossover Filter (from 1-band
31   *     to 4-band), DRC (per band), and Deemphasis Equalizer of summed stream.
32   *
33   *     The following graph illustrates a 3-band Multiband DRC component:
34   *
35   *                                      low
36   *                                     o----> DRC0 ----o
37   *                                     |               |
38   *                           3-WAY     |mid            |
39   *     x(n) --> EQ EMP --> CROSSOVER --o----> DRC1 ---(+)--> EQ DEEMP --> y(n)
40   *                                     |               |
41   *                                     |high           |
42   *                                     o----> DRC2 ----o
43   *
44   *     uint32_t num_bands <= 4
45   *         Determines the number of frequency bands, the choice of n-way
46   *         Crossover, and the number of DRC components.
47   *     uint32_t enable_emp_deemp
48   *         1=enable Emphasis and Deemphasis Equalizer; 0=disable (passthrough)
49   *     struct sof_eq_iir_biquad_df2t emp_coef[2]
50   *         The coefficient data for Emphasis Equalizer, which is a cascade of 2
51   *         biquad filters.
52   *     struct sof_eq_iir_biquad_df2t deemp_coef[2]
53   *         The coefficient data for Deemphasis Equalizer, which is a cascade of
54   *         2 biquad filters.
55   *     struct sof_eq_iir_biquad_df2t crossover_coef[6]
56   *         The coefficient data for Crossover LR4 filters. Please refer
57   *         src/include/user/crossover.h for details. Zeros will be filled if
58   *         the entries are useless. For example, when 2-way crossover is used:
59   *     struct sof_drc_params drc_coef[num_bands]
60   *         The parameter data for DRC per band, the number entries of this may
61   *         vary. Please refer src/include/user/drc.h for details.
62   *
63   */
64 struct sof_multiband_drc_config {
65 	uint32_t size;
66 	uint32_t num_bands;
67 	uint32_t enable_emp_deemp;
68 
69 	/* reserved */
70 	uint32_t reserved[8];
71 
72 	/* config of emphasis eq-iir */
73 	struct sof_eq_iir_biquad_df2t emp_coef[SOF_EMP_DEEMP_BIQUADS];
74 
75 	/* config of deemphasis eq-iir */
76 	struct sof_eq_iir_biquad_df2t deemp_coef[SOF_EMP_DEEMP_BIQUADS];
77 
78 	/* config of crossover */
79 	struct sof_eq_iir_biquad_df2t crossover_coef[SOF_CROSSOVER_MAX_LR4];
80 
81 	/* config of multi-band drc */
82 	struct sof_drc_params drc_coef[];
83 };
84 
85 #endif // __USER_MULTIBAND_DRC_H__
86