^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * dsp_pipeline.c: pipelined audio processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2007, Nadi Sarrar
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Nadi Sarrar <nadi@beronet.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/mISDNif.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/mISDNdsp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "dsp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "dsp_hwec.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct dsp_pipeline_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct mISDN_dsp_element *elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) void *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct dsp_element_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct mISDN_dsp_element *elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct device dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static LIST_HEAD(dsp_elements);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* sysfs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static struct class *elements_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) attr_show_args(struct device *dev, struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct mISDN_dsp_element *elem = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) char *p = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *buf = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) for (i = 0; i < elem->num_args; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) p += sprintf(p, "Name: %s\n%s%s%sDescription: %s\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) elem->args[i].name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) elem->args[i].def ? "Default: " : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) elem->args[i].def ? elem->args[i].def : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) elem->args[i].def ? "\n" : "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) elem->args[i].desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return p - buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static struct device_attribute element_attributes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) __ATTR(args, 0444, attr_show_args, NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) mISDN_dsp_dev_release(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct dsp_element_entry *entry =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) container_of(dev, struct dsp_element_entry, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) list_del(&entry->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct dsp_element_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) if (!elem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) entry = kzalloc(sizeof(struct dsp_element_entry), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) if (!entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) entry->elem = elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) entry->dev.class = elements_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) entry->dev.release = mISDN_dsp_dev_release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) dev_set_drvdata(&entry->dev, elem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) dev_set_name(&entry->dev, "%s", elem->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) ret = device_register(&entry->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) printk(KERN_ERR "%s: failed to register %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) __func__, elem->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) goto err1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) list_add_tail(&entry->list, &dsp_elements);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) for (i = 0; i < ARRAY_SIZE(element_attributes); ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ret = device_create_file(&entry->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) &element_attributes[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) printk(KERN_ERR "%s: failed to create device file\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) goto err2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) err2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) device_unregister(&entry->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) err1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) EXPORT_SYMBOL(mISDN_dsp_element_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) void mISDN_dsp_element_unregister(struct mISDN_dsp_element *elem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct dsp_element_entry *entry, *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) if (!elem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) list_for_each_entry_safe(entry, n, &dsp_elements, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) if (entry->elem == elem) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) device_unregister(&entry->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) printk(KERN_ERR "%s: element %s not in list.\n", __func__, elem->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) EXPORT_SYMBOL(mISDN_dsp_element_unregister);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int dsp_pipeline_module_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) elements_class = class_create(THIS_MODULE, "dsp_pipeline");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (IS_ERR(elements_class))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) return PTR_ERR(elements_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) dsp_hwec_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) void dsp_pipeline_module_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct dsp_element_entry *entry, *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) dsp_hwec_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) class_destroy(elements_class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) list_for_each_entry_safe(entry, n, &dsp_elements, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) list_del(&entry->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) printk(KERN_WARNING "%s: element was still registered: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) __func__, entry->elem->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) int dsp_pipeline_init(struct dsp_pipeline *pipeline)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (!pipeline)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) INIT_LIST_HEAD(&pipeline->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static inline void _dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) struct dsp_pipeline_entry *entry, *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) list_for_each_entry_safe(entry, n, &pipeline->list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) list_del(&entry->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (entry->elem == dsp_hwec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) dsp_hwec_disable(container_of(pipeline, struct dsp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) pipeline));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) entry->elem->free(entry->p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) void dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (!pipeline)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) _dsp_pipeline_destroy(pipeline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) int found = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) char *dup, *next, *tok, *name, *args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct dsp_element_entry *entry, *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct dsp_pipeline_entry *pipeline_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct mISDN_dsp_element *elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (!pipeline)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (!list_empty(&pipeline->list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) _dsp_pipeline_destroy(pipeline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) dup = next = kstrdup(cfg, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (!dup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) while ((tok = strsep(&next, "|"))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (!strlen(tok))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) name = strsep(&tok, "(");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) args = strsep(&tok, ")");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (args && !*args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) args = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) list_for_each_entry_safe(entry, n, &dsp_elements, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if (!strcmp(entry->elem->name, name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) elem = entry->elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) pipeline_entry = kmalloc(sizeof(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) dsp_pipeline_entry), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (!pipeline_entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) printk(KERN_ERR "%s: failed to add "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) "entry to pipeline: %s (out of "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) "memory)\n", __func__, elem->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) goto _out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) pipeline_entry->elem = elem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) if (elem == dsp_hwec) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /* This is a hack to make the hwec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) available as a pipeline module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) dsp_hwec_enable(container_of(pipeline,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct dsp, pipeline), args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) list_add_tail(&pipeline_entry->list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) &pipeline->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) pipeline_entry->p = elem->new(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (pipeline_entry->p) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) list_add_tail(&pipeline_entry->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) list, &pipeline->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) printk(KERN_ERR "%s: failed "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) "to add entry to pipeline: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) "%s (new() returned NULL)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) __func__, elem->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) kfree(pipeline_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) found = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (found)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) found = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) printk(KERN_ERR "%s: element not found, skipping: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) "%s\n", __func__, name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) _out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) if (!list_empty(&pipeline->list))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) pipeline->inuse = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) pipeline->inuse = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) kfree(dup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) void dsp_pipeline_process_tx(struct dsp_pipeline *pipeline, u8 *data, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) struct dsp_pipeline_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) if (!pipeline)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) list_for_each_entry(entry, &pipeline->list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (entry->elem->process_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) entry->elem->process_tx(entry->p, data, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data, int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) unsigned int txlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) struct dsp_pipeline_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) if (!pipeline)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) list_for_each_entry_reverse(entry, &pipeline->list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) if (entry->elem->process_rx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) entry->elem->process_rx(entry->p, data, len, txlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }