2021-03-27 20:33:33 +01:00
|
|
|
/*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PRE_PROCESSOR_H
|
|
|
|
#define __PRE_PROCESSOR_H
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2021-04-23 22:13:01 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
2021-03-27 20:33:33 +01:00
|
|
|
#include "topology.h"
|
|
|
|
|
|
|
|
#define DEBUG_MAX_LENGTH 256
|
2021-04-26 20:19:31 +02:00
|
|
|
#define ARRAY_SIZE(a) (sizeof (a) / sizeof (a)[0])
|
|
|
|
|
|
|
|
#define MAX_CONFIGS_IN_TEMPLATE 32
|
2021-12-14 16:11:51 +01:00
|
|
|
|
2021-04-26 20:19:31 +02:00
|
|
|
struct config_template_items {
|
|
|
|
char *int_config_ids[MAX_CONFIGS_IN_TEMPLATE];
|
|
|
|
char *string_config_ids[MAX_CONFIGS_IN_TEMPLATE];
|
|
|
|
char *compound_config_ids[MAX_CONFIGS_IN_TEMPLATE];
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef int (*build_func)(struct tplg_pre_processor *tplg_pp, snd_config_t *obj,
|
|
|
|
snd_config_t *parent);
|
|
|
|
|
2021-06-02 07:20:49 +02:00
|
|
|
typedef int (*update_auto_attr_func)(struct tplg_pre_processor *tplg_pp,
|
|
|
|
snd_config_t *obj, snd_config_t *parent);
|
|
|
|
|
2021-04-26 20:19:31 +02:00
|
|
|
struct build_function_map {
|
|
|
|
char *class_type;
|
|
|
|
char *class_name;
|
|
|
|
char *section_name;
|
|
|
|
build_func builder;
|
2021-06-02 07:20:49 +02:00
|
|
|
update_auto_attr_func auto_attr_updater;
|
2021-04-26 20:19:31 +02:00
|
|
|
const struct config_template_items *template_items;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct build_function_map object_build_map[];
|
2021-03-27 20:33:33 +01:00
|
|
|
|
|
|
|
/* debug helpers */
|
|
|
|
void tplg_pp_debug(char *fmt, ...);
|
|
|
|
void tplg_pp_config_debug(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg);
|
2021-04-23 20:06:29 +02:00
|
|
|
|
2021-04-26 20:19:31 +02:00
|
|
|
/* object build helpers */
|
|
|
|
int tplg_build_object_from_template(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t **wtop, snd_config_t *top_config,
|
|
|
|
bool skip_name);
|
2021-04-26 21:49:51 +02:00
|
|
|
int tplg_build_tlv_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t *parent);
|
2021-04-26 21:55:26 +02:00
|
|
|
int tplg_build_scale_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t *parent);
|
|
|
|
int tplg_build_ops_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t *parent);
|
|
|
|
int tplg_build_channel_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t *parent);
|
2021-04-26 22:03:57 +02:00
|
|
|
int tplg_build_mixer_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t *parent);
|
|
|
|
int tplg_build_bytes_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t *parent);
|
2021-04-26 22:07:00 +02:00
|
|
|
int tplg_build_dapm_route_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t *parent);
|
2021-04-26 22:26:08 +02:00
|
|
|
int tplg_build_hw_cfg_object(struct tplg_pre_processor *tplg_pp,
|
|
|
|
snd_config_t *obj_cfg, snd_config_t *parent);
|
2021-04-26 22:31:00 +02:00
|
|
|
int tplg_build_fe_dai_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t *parent);
|
|
|
|
int tplg_build_base_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t *parent, bool skip_name);
|
2021-04-26 22:34:26 +02:00
|
|
|
int tplg_build_pcm_caps_object(struct tplg_pre_processor *tplg_pp,
|
|
|
|
snd_config_t *obj_cfg, snd_config_t *parent);
|
2021-04-26 20:48:43 +02:00
|
|
|
int tplg_parent_update(struct tplg_pre_processor *tplg_pp, snd_config_t *parent,
|
|
|
|
const char *section_name, const char *item_name);
|
2021-06-16 01:15:06 +02:00
|
|
|
int tplg_add_object_data(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
|
|
|
|
snd_config_t *top, const char *array_name);
|
2021-04-26 20:19:31 +02:00
|
|
|
|
2021-04-26 18:34:48 +02:00
|
|
|
/* object helpers */
|
|
|
|
int tplg_pre_process_objects(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg,
|
|
|
|
snd_config_t *parent);
|
|
|
|
snd_config_t *tplg_object_get_instance_config(struct tplg_pre_processor *tplg_pp,
|
|
|
|
snd_config_t *class_type);
|
2021-04-26 20:19:31 +02:00
|
|
|
const char *tplg_object_get_name(struct tplg_pre_processor *tplg_pp,
|
|
|
|
snd_config_t *object);
|
2021-04-26 20:33:12 +02:00
|
|
|
snd_config_t *tplg_object_get_section(struct tplg_pre_processor *tplg_pp, snd_config_t *class);
|
2021-04-26 18:34:48 +02:00
|
|
|
|
2021-04-23 21:23:19 +02:00
|
|
|
/* class helpers */
|
|
|
|
snd_config_t *tplg_class_lookup(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg);
|
2021-04-23 21:35:56 +02:00
|
|
|
snd_config_t *tplg_class_find_attribute_by_name(struct tplg_pre_processor *tplg_pp,
|
|
|
|
snd_config_t *class, const char *name);
|
2021-04-23 22:13:01 +02:00
|
|
|
bool tplg_class_is_attribute_mandatory(const char *attr, snd_config_t *class_cfg);
|
|
|
|
bool tplg_class_is_attribute_immutable(const char *attr, snd_config_t *class_cfg);
|
|
|
|
bool tplg_class_is_attribute_unique(const char *attr, snd_config_t *class_cfg);
|
2021-04-23 22:32:26 +02:00
|
|
|
const char *tplg_class_get_unique_attribute_name(struct tplg_pre_processor *tplg_pp,
|
|
|
|
snd_config_t *class);
|
2021-04-23 22:36:48 +02:00
|
|
|
snd_config_type_t tplg_class_get_attribute_type(struct tplg_pre_processor *tplg_pp,
|
|
|
|
snd_config_t *attr);
|
2021-04-23 22:41:45 +02:00
|
|
|
const char *tplg_class_get_attribute_token_ref(struct tplg_pre_processor *tplg_pp,
|
2021-05-25 18:28:00 +02:00
|
|
|
snd_config_t *class, const char *attr_name);
|
2021-04-23 22:46:24 +02:00
|
|
|
long tplg_class_attribute_valid_tuple_value(struct tplg_pre_processor *tplg_pp,
|
2021-05-25 18:28:00 +02:00
|
|
|
snd_config_t *class, snd_config_t *attr);
|
2021-04-23 21:23:19 +02:00
|
|
|
|
2021-04-23 20:06:29 +02:00
|
|
|
/* config helpers */
|
|
|
|
snd_config_t *tplg_find_config(snd_config_t *config, const char *name);
|
|
|
|
int tplg_config_make_add(snd_config_t **config, const char *id, snd_config_type_t type,
|
|
|
|
snd_config_t *parent);
|
2021-04-26 20:48:43 +02:00
|
|
|
|
2021-04-23 20:15:59 +02:00
|
|
|
char *tplg_snprintf(char *fmt, ...);
|
2021-03-27 20:33:33 +01:00
|
|
|
#endif
|