• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "iniparser_wrapper.h"
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include "array.h"
16 #include "dumper.h"
17 #include "cras_expr.h"
18 
19 enum port_direction {
20 	PORT_INPUT,
21 	PORT_OUTPUT,
22 };
23 
24 enum port_type {
25 	PORT_CONTROL,
26 	PORT_AUDIO,
27 };
28 
29 #define INVALID_FLOW_ID -1
30 
31 struct port {
32 	enum port_direction direction;
33 	enum port_type type;
34 
35 	/* This is only used if there is a flow connects to this port,
36 	   -1 otherwise (i.e. the port has a constant input/output) */
37 	int flow_id;
38 
39 	/* This is only used if type is PORT_CONTROL */
40 	float init_value;
41 };
42 
43 DECLARE_ARRAY_TYPE(struct port, port_array)
44 
45 struct plugin {
46 	const char *title;
47 	const char *library; /* file name like "plugin.so" */
48 	const char *label; /* label like "Eq" */
49 	const char *purpose; /* like "playback" or "capture" */
50 	struct cras_expr_expression *disable_expr; /* the disable expression of
51 					     this plugin */
52 	port_array ports;
53 };
54 
55 struct flow {
56 	enum port_type type; /* the type of the ports this flow connects to */
57 	const char *name;
58 	struct plugin *from;
59 	struct plugin *to;
60 	int from_port;
61 	int to_port;
62 };
63 
64 DECLARE_ARRAY_TYPE(struct plugin, plugin_array)
65 DECLARE_ARRAY_TYPE(struct flow, flow_array)
66 
67 struct ini {
68 	dictionary *dict;
69 	plugin_array plugins;
70 	flow_array flows;
71 };
72 
73 /*
74  * Creates a mock ini structure equivalent to:
75  *
76  * [src]
77  * out0={tmp:0}
78  * out1={tmp:1}
79  * ...
80  *
81  * [sink]
82  * in0={tmp:0}
83  * in1={tmp:1}
84  * ...
85  *
86  * The caller of this function is responsible to free the returned
87  * ini by calling cras_dsp_ini_free().
88  */
89 struct ini *create_mock_ini(const char *purpose, unsigned int num_channels);
90 
91 /* Reads the ini file into the ini structure */
92 struct ini *cras_dsp_ini_create(const char *ini_filename);
93 /* Frees the dsp structure. */
94 void cras_dsp_ini_free(struct ini *ini);
95 /* Dumps the information in the ini structure to syslog. */
96 void cras_dsp_ini_dump(struct dumper *d, struct ini *ini);
97 
98 #ifdef __cplusplus
99 } /* extern "C" */
100 #endif
101 
102 #endif /* CRAS_DSP_INI_H_ */
103