Home | History | Annotate | Download | only in server
      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 "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 /* Reads the ini file into the ini structure */
     74 struct ini *cras_dsp_ini_create(const char *ini_filename);
     75 /* Frees the dsp structure. */
     76 void cras_dsp_ini_free(struct ini *ini);
     77 /* Dumps the information in the ini structure to syslog. */
     78 void cras_dsp_ini_dump(struct dumper *d, struct ini *ini);
     79 
     80 #ifdef __cplusplus
     81 } /* extern "C" */
     82 #endif
     83 
     84 #endif /* CRAS_DSP_INI_H_ */
     85