Release 4.7 sound/soc/soc-topology.c
/*
* soc-topology.c -- ALSA SoC Topology
*
* Copyright (C) 2012 Texas Instruments Inc.
* Copyright (C) 2015 Intel Corporation.
*
* Authors: Liam Girdwood <liam.r.girdwood@linux.intel.com>
* K, Mythri P <mythri.p.k@intel.com>
* Prusty, Subhransu S <subhransu.s.prusty@intel.com>
* B, Jayachandran <jayachandran.b@intel.com>
* Abdullah, Omair M <omair.m.abdullah@intel.com>
* Jin, Yao <yao.jin@intel.com>
* Lin, Mengdong <mengdong.lin@intel.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* Add support to read audio firmware topology alongside firmware text. The
* topology data can contain kcontrols, DAPM graphs, widgets, DAIs, DAI links,
* equalizers, firmware, coefficients etc.
*
* This file only manages the core ALSA and ASoC components, all other bespoke
* firmware topology data is passed to component drivers for bespoke handling.
*/
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/list.h>
#include <linux/firmware.h>
#include <linux/slab.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/soc-topology.h>
#include <sound/tlv.h>
/*
* We make several passes over the data (since it wont necessarily be ordered)
* and process objects in the following order. This guarantees the component
* drivers will be ready with any vendor data before the mixers and DAPM objects
* are loaded (that may make use of the vendor data).
*/
#define SOC_TPLG_PASS_MANIFEST 0
#define SOC_TPLG_PASS_VENDOR 1
#define SOC_TPLG_PASS_MIXER 2
#define SOC_TPLG_PASS_WIDGET 3
#define SOC_TPLG_PASS_PCM_DAI 4
#define SOC_TPLG_PASS_GRAPH 5
#define SOC_TPLG_PASS_PINS 6
#define SOC_TPLG_PASS_START SOC_TPLG_PASS_MANIFEST
#define SOC_TPLG_PASS_END SOC_TPLG_PASS_PINS
struct soc_tplg {
const struct firmware *fw;
/* runtime FW parsing */
const u8 *pos; /* read postion */
const u8 *hdr_pos; /* header position */
unsigned int pass; /* pass number */
/* component caller */
struct device *dev;
struct snd_soc_component *comp;
u32 index; /* current block index */
u32 req_index; /* required index, only loaded/free matching blocks */
/* vendor specific kcontrol operations */
const struct snd_soc_tplg_kcontrol_ops *io_ops;
int io_ops_count;
/* vendor specific bytes ext handlers, for TLV bytes controls */
const struct snd_soc_tplg_bytes_ext_ops *bytes_ext_ops;
int bytes_ext_ops_count;
/* optional fw loading callbacks to component drivers */
struct snd_soc_tplg_ops *ops;
};
static int soc_tplg_process_headers(struct soc_tplg *tplg);
static void soc_tplg_complete(struct soc_tplg *tplg);
struct snd_soc_dapm_widget *
snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_widget *widget);
struct snd_soc_dapm_widget *
snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_widget *widget);
/* check we dont overflow the data for this control chunk */
static int soc_tplg_check_elem_count(struct soc_tplg *tplg, size_t elem_size,
unsigned int count, size_t bytes, const char *elem_type)
{
const u8 *end = tplg->pos + elem_size * count;
if (end > tplg->fw->data + tplg->fw->size) {
dev_err(tplg->dev, "ASoC: %s overflow end of data\n",
elem_type);
return -EINVAL;
}
/* check there is enough room in chunk for control.
extra bytes at the end of control are for vendor data here */
if (elem_size * count > bytes) {
dev_err(tplg->dev,
"ASoC: %s count %d of size %zu is bigger than chunk %zu\n",
elem_type, count, elem_size, bytes);
return -EINVAL;
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 107 | 100.00% | 1 | 100.00% |
| Total | 107 | 100.00% | 1 | 100.00% |
static inline int soc_tplg_is_eof(struct soc_tplg *tplg)
{
const u8 *end = tplg->hdr_pos;
if (end >= tplg->fw->data + tplg->fw->size)
return 1;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 43 | 100.00% | 1 | 100.00% |
| Total | 43 | 100.00% | 1 | 100.00% |
static inline unsigned long soc_tplg_get_hdr_offset(struct soc_tplg *tplg)
{
return (unsigned long)(tplg->hdr_pos - tplg->fw->data);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 30 | 100.00% | 1 | 100.00% |
| Total | 30 | 100.00% | 1 | 100.00% |
static inline unsigned long soc_tplg_get_offset(struct soc_tplg *tplg)
{
return (unsigned long)(tplg->pos - tplg->fw->data);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 30 | 100.00% | 1 | 100.00% |
| Total | 30 | 100.00% | 1 | 100.00% |
/* mapping of Kcontrol types and associated operations. */
static const struct snd_soc_tplg_kcontrol_ops io_ops[] = {
{SND_SOC_TPLG_CTL_VOLSW, snd_soc_get_volsw,
snd_soc_put_volsw, snd_soc_info_volsw},
{SND_SOC_TPLG_CTL_VOLSW_SX, snd_soc_get_volsw_sx,
snd_soc_put_volsw_sx, NULL},
{SND_SOC_TPLG_CTL_ENUM, snd_soc_get_enum_double,
snd_soc_put_enum_double, snd_soc_info_enum_double},
{SND_SOC_TPLG_CTL_ENUM_VALUE, snd_soc_get_enum_double,
snd_soc_put_enum_double, NULL},
{SND_SOC_TPLG_CTL_BYTES, snd_soc_bytes_get,
snd_soc_bytes_put, snd_soc_bytes_info},
{SND_SOC_TPLG_CTL_RANGE, snd_soc_get_volsw_range,
snd_soc_put_volsw_range, snd_soc_info_volsw_range},
{SND_SOC_TPLG_CTL_VOLSW_XR_SX, snd_soc_get_xr_sx,
snd_soc_put_xr_sx, snd_soc_info_xr_sx},
{SND_SOC_TPLG_CTL_STROBE, snd_soc_get_strobe,
snd_soc_put_strobe, NULL},
{SND_SOC_TPLG_DAPM_CTL_VOLSW, snd_soc_dapm_get_volsw,
snd_soc_dapm_put_volsw, snd_soc_info_volsw},
{SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE, snd_soc_dapm_get_enum_double,
snd_soc_dapm_put_enum_double, snd_soc_info_enum_double},
{SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT, snd_soc_dapm_get_enum_double,
snd_soc_dapm_put_enum_double, NULL},
{SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE, snd_soc_dapm_get_enum_double,
snd_soc_dapm_put_enum_double, NULL},
{SND_SOC_TPLG_DAPM_CTL_PIN, snd_soc_dapm_get_pin_switch,
snd_soc_dapm_put_pin_switch, snd_soc_dapm_info_pin_switch},
};
struct soc_tplg_map {
int uid;
int kid;
};
/* mapping of widget types from UAPI IDs to kernel IDs */
static const struct soc_tplg_map dapm_map[] = {
{SND_SOC_TPLG_DAPM_INPUT, snd_soc_dapm_input},
{SND_SOC_TPLG_DAPM_OUTPUT, snd_soc_dapm_output},
{SND_SOC_TPLG_DAPM_MUX, snd_soc_dapm_mux},
{SND_SOC_TPLG_DAPM_MIXER, snd_soc_dapm_mixer},
{SND_SOC_TPLG_DAPM_PGA, snd_soc_dapm_pga},
{SND_SOC_TPLG_DAPM_OUT_DRV, snd_soc_dapm_out_drv},
{SND_SOC_TPLG_DAPM_ADC, snd_soc_dapm_adc},
{SND_SOC_TPLG_DAPM_DAC, snd_soc_dapm_dac},
{SND_SOC_TPLG_DAPM_SWITCH, snd_soc_dapm_switch},
{SND_SOC_TPLG_DAPM_PRE, snd_soc_dapm_pre},
{SND_SOC_TPLG_DAPM_POST, snd_soc_dapm_post},
{SND_SOC_TPLG_DAPM_AIF_IN, snd_soc_dapm_aif_in},
{SND_SOC_TPLG_DAPM_AIF_OUT, snd_soc_dapm_aif_out},
{SND_SOC_TPLG_DAPM_DAI_IN, snd_soc_dapm_dai_in},
{SND_SOC_TPLG_DAPM_DAI_OUT, snd_soc_dapm_dai_out},
{SND_SOC_TPLG_DAPM_DAI_LINK, snd_soc_dapm_dai_link},
};
static int tplc_chan_get_reg(struct soc_tplg *tplg,
struct snd_soc_tplg_channel *chan, int map)
{
int i;
for (i = 0; i < SND_SOC_TPLG_MAX_CHAN; i++) {
if (chan[i].id == map)
return chan[i].reg;
}
return -EINVAL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 60 | 100.00% | 1 | 100.00% |
| Total | 60 | 100.00% | 1 | 100.00% |
static int tplc_chan_get_shift(struct soc_tplg *tplg,
struct snd_soc_tplg_channel *chan, int map)
{
int i;
for (i = 0; i < SND_SOC_TPLG_MAX_CHAN; i++) {
if (chan[i].id == map)
return chan[i].shift;
}
return -EINVAL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 60 | 100.00% | 1 | 100.00% |
| Total | 60 | 100.00% | 1 | 100.00% |
static int get_widget_id(int tplg_type)
{
int i;
for (i = 0; i < ARRAY_SIZE(dapm_map); i++) {
if (tplg_type == dapm_map[i].uid)
return dapm_map[i].kid;
}
return -EINVAL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 53 | 100.00% | 1 | 100.00% |
| Total | 53 | 100.00% | 1 | 100.00% |
static inline void soc_bind_err(struct soc_tplg *tplg,
struct snd_soc_tplg_ctl_hdr *hdr, int index)
{
dev_err(tplg->dev,
"ASoC: invalid control type (g,p,i) %d:%d:%d index %d at 0x%lx\n",
hdr->ops.get, hdr->ops.put, hdr->ops.info, index,
soc_tplg_get_offset(tplg));
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 54 | 100.00% | 1 | 100.00% |
| Total | 54 | 100.00% | 1 | 100.00% |
static inline void soc_control_err(struct soc_tplg *tplg,
struct snd_soc_tplg_ctl_hdr *hdr, const char *name)
{
dev_err(tplg->dev,
"ASoC: no complete mixer IO handler for %s type (g,p,i) %d:%d:%d at 0x%lx\n",
name, hdr->ops.get, hdr->ops.put, hdr->ops.info,
soc_tplg_get_offset(tplg));
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 56 | 100.00% | 1 | 100.00% |
| Total | 56 | 100.00% | 1 | 100.00% |
/* pass vendor data to component driver for processing */
static int soc_tplg_vendor_load_(struct soc_tplg *tplg,
struct snd_soc_tplg_hdr *hdr)
{
int ret = 0;
if (tplg->comp && tplg->ops && tplg->ops->vendor_load)
ret = tplg->ops->vendor_load(tplg->comp, hdr);
else {
dev_err(tplg->dev, "ASoC: no vendor load callback for ID %d\n",
hdr->vendor_type);
return -EINVAL;
}
if (ret < 0)
dev_err(tplg->dev,
"ASoC: vendor load failed at hdr offset %ld/0x%lx for type %d:%d\n",
soc_tplg_get_hdr_offset(tplg),
soc_tplg_get_hdr_offset(tplg),
hdr->type, hdr->vendor_type);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 108 | 100.00% | 1 | 100.00% |
| Total | 108 | 100.00% | 1 | 100.00% |
/* pass vendor data to component driver for processing */
static int soc_tplg_vendor_load(struct soc_tplg *tplg,
struct snd_soc_tplg_hdr *hdr)
{
if (tplg->pass != SOC_TPLG_PASS_VENDOR)
return 0;
return soc_tplg_vendor_load_(tplg, hdr);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 35 | 100.00% | 1 | 100.00% |
| Total | 35 | 100.00% | 1 | 100.00% |
/* optionally pass new dynamic widget to component driver. This is mainly for
* external widgets where we can assign private data/ops */
static int soc_tplg_widget_load(struct soc_tplg *tplg,
struct snd_soc_dapm_widget *w, struct snd_soc_tplg_dapm_widget *tplg_w)
{
if (tplg->comp && tplg->ops && tplg->ops->widget_load)
return tplg->ops->widget_load(tplg->comp, w, tplg_w);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 56 | 100.00% | 1 | 100.00% |
| Total | 56 | 100.00% | 1 | 100.00% |
/* pass DAI configurations to component driver for extra intialization */
static int soc_tplg_dai_load(struct soc_tplg *tplg,
struct snd_soc_dai_driver *dai_drv)
{
if (tplg->comp && tplg->ops && tplg->ops->dai_load)
return tplg->ops->dai_load(tplg->comp, dai_drv);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 43 | 87.76% | 1 | 50.00% |
mengdong lin | mengdong lin | 6 | 12.24% | 1 | 50.00% |
| Total | 49 | 100.00% | 2 | 100.00% |
/* pass link configurations to component driver for extra intialization */
static int soc_tplg_dai_link_load(struct soc_tplg *tplg,
struct snd_soc_dai_link *link)
{
if (tplg->comp && tplg->ops && tplg->ops->link_load)
return tplg->ops->link_load(tplg->comp, link);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mengdong lin | mengdong lin | 49 | 100.00% | 1 | 100.00% |
| Total | 49 | 100.00% | 1 | 100.00% |
/* tell the component driver that all firmware has been loaded in this request */
static void soc_tplg_complete(struct soc_tplg *tplg)
{
if (tplg->comp && tplg->ops && tplg->ops->complete)
tplg->ops->complete(tplg->comp);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 38 | 100.00% | 1 | 100.00% |
| Total | 38 | 100.00% | 1 | 100.00% |
/* add a dynamic kcontrol */
static int soc_tplg_add_dcontrol(struct snd_card *card, struct device *dev,
const struct snd_kcontrol_new *control_new, const char *prefix,
void *data, struct snd_kcontrol **kcontrol)
{
int err;
*kcontrol = snd_soc_cnew(control_new, data, control_new->name, prefix);
if (*kcontrol == NULL) {
dev_err(dev, "ASoC: Failed to create new kcontrol %s\n",
control_new->name);
return -ENOMEM;
}
err = snd_ctl_add(card, *kcontrol);
if (err < 0) {
dev_err(dev, "ASoC: Failed to add %s: %d\n",
control_new->name, err);
return err;
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 117 | 100.00% | 1 | 100.00% |
| Total | 117 | 100.00% | 1 | 100.00% |
/* add a dynamic kcontrol for component driver */
static int soc_tplg_add_kcontrol(struct soc_tplg *tplg,
struct snd_kcontrol_new *k, struct snd_kcontrol **kcontrol)
{
struct snd_soc_component *comp = tplg->comp;
return soc_tplg_add_dcontrol(comp->card->snd_card,
comp->dev, k, NULL, comp, kcontrol);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 53 | 100.00% | 1 | 100.00% |
| Total | 53 | 100.00% | 1 | 100.00% |
/* remove a mixer kcontrol */
static void remove_mixer(struct snd_soc_component *comp,
struct snd_soc_dobj *dobj, int pass)
{
struct snd_card *card = comp->card->snd_card;
struct soc_mixer_control *sm =
container_of(dobj, struct soc_mixer_control, dobj);
const unsigned int *p = NULL;
if (pass != SOC_TPLG_PASS_MIXER)
return;
if (dobj->ops && dobj->ops->control_unload)
dobj->ops->control_unload(comp, dobj);
if (sm->dobj.control.kcontrol->tlv.p)
p = sm->dobj.control.kcontrol->tlv.p;
snd_ctl_remove(card, sm->dobj.control.kcontrol);
list_del(&sm->dobj.list);
kfree(sm);
kfree(p);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 144 | 100.00% | 1 | 100.00% |
| Total | 144 | 100.00% | 1 | 100.00% |
/* remove an enum kcontrol */
static void remove_enum(struct snd_soc_component *comp,
struct snd_soc_dobj *dobj, int pass)
{
struct snd_card *card = comp->card->snd_card;
struct soc_enum *se = container_of(dobj, struct soc_enum, dobj);
int i;
if (pass != SOC_TPLG_PASS_MIXER)
return;
if (dobj->ops && dobj->ops->control_unload)
dobj->ops->control_unload(comp, dobj);
snd_ctl_remove(card, se->dobj.control.kcontrol);
list_del(&se->dobj.list);
kfree(se->dobj.control.dvalues);
for (i = 0; i < se->items; i++)
kfree(se->dobj.control.dtexts[i]);
kfree(se);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 146 | 100.00% | 1 | 100.00% |
| Total | 146 | 100.00% | 1 | 100.00% |
/* remove a byte kcontrol */
static void remove_bytes(struct snd_soc_component *comp,
struct snd_soc_dobj *dobj, int pass)
{
struct snd_card *card = comp->card->snd_card;
struct soc_bytes_ext *sb =
container_of(dobj, struct soc_bytes_ext, dobj);
if (pass != SOC_TPLG_PASS_MIXER)
return;
if (dobj->ops && dobj->ops->control_unload)
dobj->ops->control_unload(comp, dobj);
snd_ctl_remove(card, sb->dobj.control.kcontrol);
list_del(&sb->dobj.list);
kfree(sb);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 103 | 100.00% | 1 | 100.00% |
| Total | 103 | 100.00% | 1 | 100.00% |
/* remove a widget and it's kcontrols - routes must be removed first */
static void remove_widget(struct snd_soc_component *comp,
struct snd_soc_dobj *dobj, int pass)
{
struct snd_card *card = comp->card->snd_card;
struct snd_soc_dapm_widget *w =
container_of(dobj, struct snd_soc_dapm_widget, dobj);
int i;
if (pass != SOC_TPLG_PASS_WIDGET)
return;
if (dobj->ops && dobj->ops->widget_unload)
dobj->ops->widget_unload(comp, dobj);
/*
* Dynamic Widgets either have 1 enum kcontrol or 1..N mixers.
* The enum may either have an array of values or strings.
*/
if (dobj->widget.kcontrol_enum) {
/* enumerated widget mixer */
struct soc_enum *se =
(struct soc_enum *)w->kcontrols[0]->private_value;
snd_ctl_remove(card, w->kcontrols[0]);
kfree(se->dobj.control.dvalues);
for (i = 0; i < se->items; i++)
kfree(se->dobj.control.dtexts[i]);
kfree(se);
kfree(w->kcontrol_news);
} else {
/* non enumerated widget mixer */
for (i = 0; i < w->num_kcontrols; i++) {
struct snd_kcontrol *kcontrol = w->kcontrols[i];
struct soc_mixer_control *sm =
(struct soc_mixer_control *) kcontrol->private_value;
kfree(w->kcontrols[i]->tlv.p);
snd_ctl_remove(card, w->kcontrols[i]);
kfree(sm);
}
kfree(w->kcontrol_news);
}
/* widget w is freed by soc-dapm.c */
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 259 | 100.00% | 1 | 100.00% |
| Total | 259 | 100.00% | 1 | 100.00% |
/* remove DAI configurations */
static void remove_dai(struct snd_soc_component *comp,
struct snd_soc_dobj *dobj, int pass)
{
struct snd_soc_dai_driver *dai_drv =
container_of(dobj, struct snd_soc_dai_driver, dobj);
if (pass != SOC_TPLG_PASS_PCM_DAI)
return;
if (dobj->ops && dobj->ops->dai_unload)
dobj->ops->dai_unload(comp, dobj);
list_del(&dobj->list);
kfree(dai_drv);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 58 | 75.32% | 1 | 50.00% |
mengdong lin | mengdong lin | 19 | 24.68% | 1 | 50.00% |
| Total | 77 | 100.00% | 2 | 100.00% |
/* remove link configurations */
static void remove_link(struct snd_soc_component *comp,
struct snd_soc_dobj *dobj, int pass)
{
struct snd_soc_dai_link *link =
container_of(dobj, struct snd_soc_dai_link, dobj);
if (pass != SOC_TPLG_PASS_PCM_DAI)
return;
if (dobj->ops && dobj->ops->link_unload)
dobj->ops->link_unload(comp, dobj);
list_del(&dobj->list);
snd_soc_remove_dai_link(comp->card, link);
kfree(link);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mengdong lin | mengdong lin | 86 | 100.00% | 1 | 100.00% |
| Total | 86 | 100.00% | 1 | 100.00% |
/* bind a kcontrol to it's IO handlers */
static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
struct snd_kcontrol_new *k,
const struct soc_tplg *tplg)
{
const struct snd_soc_tplg_kcontrol_ops *ops;
const struct snd_soc_tplg_bytes_ext_ops *ext_ops;
int num_ops, i;
if (hdr->ops.info == SND_SOC_TPLG_CTL_BYTES
&& k->iface & SNDRV_CTL_ELEM_IFACE_MIXER
&& k->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE
&& k->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
struct soc_bytes_ext *sbe;
struct snd_soc_tplg_bytes_control *be;
sbe = (struct soc_bytes_ext *)k->private_value;
be = container_of(hdr, struct snd_soc_tplg_bytes_control, hdr);
/* TLV bytes controls need standard kcontrol info handler,
* TLV callback and extended put/get handlers.
*/
k->info = snd_soc_bytes_info_ext;
k->tlv.c = snd_soc_bytes_tlv_callback;
ext_ops = tplg->bytes_ext_ops;
num_ops = tplg->bytes_ext_ops_count;
for (i = 0; i < num_ops; i++) {
if (!sbe->put && ext_ops[i].id == be->ext_ops.put)
sbe->put = ext_ops[i].put;
if (!sbe->get && ext_ops[i].id == be->ext_ops.get)
sbe->get = ext_ops[i].get;
}
if (sbe->put && sbe->get)
return 0;
else
return -EINVAL;
}
/* try and map vendor specific kcontrol handlers first */
ops = tplg->io_ops;
num_ops = tplg->io_ops_count;
for (i = 0; i < num_ops; i++) {
if (k->put == NULL && ops[i].id == hdr->ops.put)
k->put = ops[i].put;
if (k->get == NULL && ops[i].id == hdr->ops.get)
k->get = ops[i].get;
if (k->info == NULL && ops[i].id == hdr->ops.info)
k->info = ops[i].info;
}
/* vendor specific handlers found ? */
if (k->put && k->get && k->info)
return 0;
/* none found so try standard kcontrol handlers */
ops = io_ops;
num_ops = ARRAY_SIZE(io_ops);
for (i = 0; i < num_ops; i++) {
if (k->put == NULL && ops[i].id == hdr->ops.put)
k->put = ops[i].put;
if (k->get == NULL && ops[i].id == hdr->ops.get)
k->get = ops[i].get;
if (k->info == NULL && ops[i].id == hdr->ops.info)
k->info = ops[i].info;
}
/* standard handlers found ? */
if (k->put && k->get && k->info)
return 0;
/* nothing to bind */
return -EINVAL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 282 | 55.08% | 1 | 20.00% |
mengdong lin | mengdong lin | 229 | 44.73% | 3 | 60.00% |
omair mohammed abdullah | omair mohammed abdullah | 1 | 0.20% | 1 | 20.00% |
| Total | 512 | 100.00% | 5 | 100.00% |
/* bind a widgets to it's evnt handlers */
int snd_soc_tplg_widget_bind_event(struct snd_soc_dapm_widget *w,
const struct snd_soc_tplg_widget_events *events,
int num_events, u16 event_type)
{
int i;
w->event = NULL;
for (i = 0; i < num_events; i++) {
if (event_type == events[i].type) {
/* found - so assign event */
w->event = events[i].event_handler;
return 0;
}
}
/* not found */
return -EINVAL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 79 | 100.00% | 1 | 100.00% |
| Total | 79 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL_GPL(snd_soc_tplg_widget_bind_event);
/* optionally pass new dynamic kcontrol to component driver. */
static int soc_tplg_init_kcontrol(struct soc_tplg *tplg,
struct snd_kcontrol_new *k, struct snd_soc_tplg_ctl_hdr *hdr)
{
if (tplg->comp && tplg->ops && tplg->ops->control_load)
return tplg->ops->control_load(tplg->comp, k, hdr);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
liam girdwood | liam girdwood | 56 | 100.00% | 1 | 100.00% |
| Total | 56 | 100.00% | 1 | 100.00% |
static int soc_tplg_create_tlv_db_scale(struct soc_tplg *tplg,
struct snd_kcontrol_new *kc, struct snd_soc_tplg_tlv_dbscale *scale)
{
unsigned int item_len = 2 * sizeof(unsigned int);
unsigned int *p;
p = kzalloc(item_len + 2 * sizeof(unsigned int), GFP_KERNEL);
if (!p)
return -ENOMEM;
p