• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  This library is free software; you can redistribute it and/or
3  *  modify it under the terms of the GNU Lesser General Public
4  *  License as published by the Free Software Foundation; either
5  *  version 2 of the License, or (at your option) any later version.
6  *
7  *  This library is distributed in the hope that it will be useful,
8  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  *  Lesser General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License
13  *  along with this program; if not, write to the Free Software
14  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */
16 
17 #ifndef __PRE_PROCESSOR_H
18 #define __PRE_PROCESSOR_H
19 
20 #include <stdarg.h>
21 #include <stdbool.h>
22 #include <string.h>
23 #include "topology.h"
24 
25 #define DEBUG_MAX_LENGTH	256
26 #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a)[0])
27 
28 #define MAX_CONFIGS_IN_TEMPLATE	32
29 
30 struct config_template_items {
31 	char *int_config_ids[MAX_CONFIGS_IN_TEMPLATE];
32 	char *string_config_ids[MAX_CONFIGS_IN_TEMPLATE];
33 	char *compound_config_ids[MAX_CONFIGS_IN_TEMPLATE];
34 };
35 
36 typedef int (*build_func)(struct tplg_pre_processor *tplg_pp, snd_config_t *obj,
37 			  snd_config_t *parent);
38 
39 typedef int (*update_auto_attr_func)(struct tplg_pre_processor *tplg_pp,
40 			  snd_config_t *obj, snd_config_t *parent);
41 
42 struct build_function_map {
43 	char *class_type;
44 	char *class_name;
45 	char *section_name;
46 	build_func builder;
47 	update_auto_attr_func auto_attr_updater;
48 	const struct config_template_items *template_items;
49 };
50 
51 extern const struct build_function_map object_build_map[];
52 
53 /* debug helpers */
54 void tplg_pp_debug(char *fmt, ...);
55 void tplg_pp_config_debug(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg);
56 
57 /* object build helpers */
58 int tplg_build_object_from_template(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
59 				    snd_config_t **wtop, snd_config_t *top_config,
60 				    bool skip_name);
61 int tplg_build_tlv_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
62 			      snd_config_t *parent);
63 int tplg_build_scale_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
64 			      snd_config_t *parent);
65 int tplg_build_ops_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
66 			      snd_config_t *parent);
67 int tplg_build_channel_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
68 			      snd_config_t *parent);
69 int tplg_build_mixer_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
70 			      snd_config_t *parent);
71 int tplg_build_bytes_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
72 			      snd_config_t *parent);
73 int tplg_build_enum_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
74 			     snd_config_t *parent);
75 int tplg_build_text_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
76 			   snd_config_t *parent);
77 int tplg_build_dapm_route_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
78 			      snd_config_t *parent);
79 int tplg_build_hw_cfg_object(struct tplg_pre_processor *tplg_pp,
80 			       snd_config_t *obj_cfg, snd_config_t *parent);
81 int tplg_build_fe_dai_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
82 			      snd_config_t *parent);
83 int tplg_build_base_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
84 			   snd_config_t *parent, bool skip_name);
85 int tplg_build_pcm_caps_object(struct tplg_pre_processor *tplg_pp,
86 			       snd_config_t *obj_cfg, snd_config_t *parent);
87 int tplg_parent_update(struct tplg_pre_processor *tplg_pp, snd_config_t *parent,
88 			  const char *section_name, const char *item_name);
89 int tplg_add_object_data(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
90 			 snd_config_t *top, const char *array_name);
91 
92 /* object helpers */
93 int tplg_pre_process_objects(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg,
94 			     snd_config_t *parent);
95 snd_config_t *tplg_object_get_instance_config(struct tplg_pre_processor *tplg_pp,
96 					snd_config_t *class_type);
97 const char *tplg_object_get_name(struct tplg_pre_processor *tplg_pp,
98 				 snd_config_t *object);
99 snd_config_t *tplg_object_get_section(struct tplg_pre_processor *tplg_pp, snd_config_t *class);
100 
101 /* class helpers */
102 snd_config_t *tplg_class_lookup(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg);
103 snd_config_t *tplg_class_find_attribute_by_name(struct tplg_pre_processor *tplg_pp,
104 						snd_config_t *class, const char *name);
105 bool tplg_class_is_attribute_mandatory(const char *attr, snd_config_t *class_cfg);
106 bool tplg_class_is_attribute_immutable(const char *attr, snd_config_t *class_cfg);
107 bool tplg_class_is_attribute_unique(const char *attr, snd_config_t *class_cfg);
108 const char *tplg_class_get_unique_attribute_name(struct tplg_pre_processor *tplg_pp,
109 						 snd_config_t *class);
110 snd_config_type_t tplg_class_get_attribute_type(struct tplg_pre_processor *tplg_pp,
111 						snd_config_t *attr);
112 const char *tplg_class_get_attribute_token_ref(struct tplg_pre_processor *tplg_pp,
113 					       snd_config_t *class, const char *attr_name);
114 long tplg_class_attribute_valid_tuple_value(struct tplg_pre_processor *tplg_pp,
115 					    snd_config_t *class, snd_config_t *attr);
116 
117 /* config helpers */
118 snd_config_t *tplg_find_config(snd_config_t *config, const char *name);
119 int tplg_config_make_add(snd_config_t **config, const char *id, snd_config_type_t type,
120 			 snd_config_t *parent);
121 
122 char *tplg_snprintf(char *fmt, ...);
123 #endif
124