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 struct config_template_items { 30 char *int_config_ids[MAX_CONFIGS_IN_TEMPLATE]; 31 char *string_config_ids[MAX_CONFIGS_IN_TEMPLATE]; 32 char *compound_config_ids[MAX_CONFIGS_IN_TEMPLATE]; 33 }; 34 35 typedef int (*build_func)(struct tplg_pre_processor *tplg_pp, snd_config_t *obj, 36 snd_config_t *parent); 37 38 typedef int (*update_auto_attr_func)(struct tplg_pre_processor *tplg_pp, 39 snd_config_t *obj, snd_config_t *parent); 40 41 struct build_function_map { 42 char *class_type; 43 char *class_name; 44 char *section_name; 45 build_func builder; 46 update_auto_attr_func auto_attr_updater; 47 const struct config_template_items *template_items; 48 }; 49 50 extern const struct build_function_map object_build_map[]; 51 52 /* debug helpers */ 53 void tplg_pp_debug(char *fmt, ...); 54 void tplg_pp_config_debug(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg); 55 56 /* object build helpers */ 57 int tplg_build_object_from_template(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 58 snd_config_t **wtop, snd_config_t *top_config, 59 bool skip_name); 60 int tplg_build_tlv_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 61 snd_config_t *parent); 62 int tplg_build_scale_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 63 snd_config_t *parent); 64 int tplg_build_ops_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 65 snd_config_t *parent); 66 int tplg_build_channel_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 67 snd_config_t *parent); 68 int tplg_build_mixer_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 69 snd_config_t *parent); 70 int tplg_build_bytes_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 71 snd_config_t *parent); 72 int tplg_build_dapm_route_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 73 snd_config_t *parent); 74 int tplg_build_hw_cfg_object(struct tplg_pre_processor *tplg_pp, 75 snd_config_t *obj_cfg, snd_config_t *parent); 76 int tplg_build_fe_dai_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 77 snd_config_t *parent); 78 int tplg_build_base_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 79 snd_config_t *parent, bool skip_name); 80 int tplg_build_pcm_caps_object(struct tplg_pre_processor *tplg_pp, 81 snd_config_t *obj_cfg, snd_config_t *parent); 82 int tplg_parent_update(struct tplg_pre_processor *tplg_pp, snd_config_t *parent, 83 const char *section_name, const char *item_name); 84 int tplg_update_buffer_auto_attr(struct tplg_pre_processor *tplg_pp, 85 snd_config_t *buffer_cfg, snd_config_t *parent); 86 int tplg_add_object_data(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg, 87 snd_config_t *top, const char *array_name); 88 89 /* object helpers */ 90 int tplg_pre_process_objects(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg, 91 snd_config_t *parent); 92 snd_config_t *tplg_object_get_instance_config(struct tplg_pre_processor *tplg_pp, 93 snd_config_t *class_type); 94 const char *tplg_object_get_name(struct tplg_pre_processor *tplg_pp, 95 snd_config_t *object); 96 snd_config_t *tplg_object_get_section(struct tplg_pre_processor *tplg_pp, snd_config_t *class); 97 98 /* class helpers */ 99 snd_config_t *tplg_class_lookup(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg); 100 snd_config_t *tplg_class_find_attribute_by_name(struct tplg_pre_processor *tplg_pp, 101 snd_config_t *class, const char *name); 102 bool tplg_class_is_attribute_mandatory(const char *attr, snd_config_t *class_cfg); 103 bool tplg_class_is_attribute_immutable(const char *attr, snd_config_t *class_cfg); 104 bool tplg_class_is_attribute_unique(const char *attr, snd_config_t *class_cfg); 105 const char *tplg_class_get_unique_attribute_name(struct tplg_pre_processor *tplg_pp, 106 snd_config_t *class); 107 snd_config_type_t tplg_class_get_attribute_type(struct tplg_pre_processor *tplg_pp, 108 snd_config_t *attr); 109 const char *tplg_class_get_attribute_token_ref(struct tplg_pre_processor *tplg_pp, 110 snd_config_t *class, const char *attr_name); 111 long tplg_class_attribute_valid_tuple_value(struct tplg_pre_processor *tplg_pp, 112 snd_config_t *class, snd_config_t *attr); 113 114 /* config helpers */ 115 snd_config_t *tplg_find_config(snd_config_t *config, const char *name); 116 int tplg_config_make_add(snd_config_t **config, const char *id, snd_config_type_t type, 117 snd_config_t *parent); 118 119 char *tplg_snprintf(char *fmt, ...); 120 #endif 121