1 /* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 #ifndef CRAS_DSP_INI_H_
7 #define CRAS_DSP_INI_H_
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #include "iniparser.h"
14 
15 #include "array.h"
16 #include "cras_expr.h"
17 
18 enum port_direction {
19 	PORT_INPUT,
20 	PORT_OUTPUT,
21 };
22 
23 enum port_type {
24 	PORT_CONTROL,
25 	PORT_AUDIO,
26 };
27 
28 #define INVALID_FLOW_ID -1
29 
30 struct port {
31 	enum port_direction direction;
32 	enum port_type type;
33 
34 	/* This is only used if there is a flow connects to this port,
35 	   -1 otherwise (i.e. the port has a constant input/output) */
36 	int flow_id;
37 
38 	/* This is only used if type is PORT_CONTROL */
39 	float init_value;
40 };
41 
42 DECLARE_ARRAY_TYPE(struct port, port_array)
43 
44 struct plugin {
45 	const char *title;
46 	const char *library;  /* file name like "plugin.so" */
47 	const char *label;    /* label like "Eq" */
48 	const char *purpose;  /* like "playback" or "capture" */
49 	struct cras_expr_expression *disable_expr;  /* the disable expression of
50 					     this plugin */
51 	port_array ports;
52 };
53 
54 struct flow {
55 	enum port_type type;  /* the type of the ports this flow connects to */
56 	const char *name;
57 	struct plugin *from;
58 	struct plugin *to;
59 	int from_port;
60 	int to_port;
61 };
62 
63 DECLARE_ARRAY_TYPE(struct plugin, plugin_array)
64 DECLARE_ARRAY_TYPE(struct flow, flow_array)
65 
66 struct ini {
67 	dictionary *dict;
68 	plugin_array plugins;
69 	flow_array flows;
70 };
71 
72 /* Reads the ini file into the ini structure */
73 struct ini *cras_dsp_ini_create(const char *ini_filename);
74 /* Frees the dsp structure. */
75 void cras_dsp_ini_free(struct ini *ini);
76 
77 #ifdef __cplusplus
78 } /* extern "C" */
79 #endif
80 
81 #endif /* CRAS_DSP_INI_H_ */
82