Commit 605391d0 authored by Richard Fitzgerald's avatar Richard Fitzgerald Committed by Mark Brown

ASoC: wm_adsp: Make DSP name configurable by codec driver

Instead of harcoding that a core must always be called "DSPn"
add a name member to struct wm_adsp so that the owning codec
driver can provide a custom name. This allows for re-use of
the wm_adsp driver with parts where the processing cores are
named differently.

If no name is provided the default DSPn name is used.
Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 35ef57a4
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/ctype.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -35,15 +36,15 @@ ...@@ -35,15 +36,15 @@
#include "wm_adsp.h" #include "wm_adsp.h"
#define adsp_crit(_dsp, fmt, ...) \ #define adsp_crit(_dsp, fmt, ...) \
dev_crit(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) dev_crit(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__)
#define adsp_err(_dsp, fmt, ...) \ #define adsp_err(_dsp, fmt, ...) \
dev_err(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) dev_err(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__)
#define adsp_warn(_dsp, fmt, ...) \ #define adsp_warn(_dsp, fmt, ...) \
dev_warn(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) dev_warn(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__)
#define adsp_info(_dsp, fmt, ...) \ #define adsp_info(_dsp, fmt, ...) \
dev_info(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) dev_info(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__)
#define adsp_dbg(_dsp, fmt, ...) \ #define adsp_dbg(_dsp, fmt, ...) \
dev_dbg(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) dev_dbg(_dsp->dev, "%s: " fmt, _dsp->name, ##__VA_ARGS__)
#define ADSP1_CONTROL_1 0x00 #define ADSP1_CONTROL_1 0x00
#define ADSP1_CONTROL_2 0x02 #define ADSP1_CONTROL_2 0x02
...@@ -608,7 +609,6 @@ static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, ...@@ -608,7 +609,6 @@ static void wm_adsp2_init_debugfs(struct wm_adsp *dsp,
struct snd_soc_component *component) struct snd_soc_component *component)
{ {
struct dentry *root = NULL; struct dentry *root = NULL;
char *root_name;
int i; int i;
if (!component->debugfs_root) { if (!component->debugfs_root) {
...@@ -616,13 +616,7 @@ static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, ...@@ -616,13 +616,7 @@ static void wm_adsp2_init_debugfs(struct wm_adsp *dsp,
goto err; goto err;
} }
root_name = kmalloc(PAGE_SIZE, GFP_KERNEL); root = debugfs_create_dir(dsp->name, component->debugfs_root);
if (!root_name)
goto err;
snprintf(root_name, PAGE_SIZE, "dsp%d", dsp->num);
root = debugfs_create_dir(root_name, component->debugfs_root);
kfree(root_name);
if (!root) if (!root)
goto err; goto err;
...@@ -1315,12 +1309,12 @@ static int wm_adsp_create_control(struct wm_adsp *dsp, ...@@ -1315,12 +1309,12 @@ static int wm_adsp_create_control(struct wm_adsp *dsp,
switch (dsp->fw_ver) { switch (dsp->fw_ver) {
case 0: case 0:
case 1: case 1:
snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "DSP%d %s %x", snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s %s %x",
dsp->num, region_name, alg_region->alg); dsp->name, region_name, alg_region->alg);
break; break;
default: default:
ret = snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, ret = snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
"DSP%d%c %.12s %x", dsp->num, *region_name, "%s%c %.12s %x", dsp->name, *region_name,
wm_adsp_fw_text[dsp->fw], alg_region->alg); wm_adsp_fw_text[dsp->fw], alg_region->alg);
/* Truncate the subname from the start if it is too long */ /* Truncate the subname from the start if it is too long */
...@@ -1648,7 +1642,7 @@ static int wm_adsp_load(struct wm_adsp *dsp) ...@@ -1648,7 +1642,7 @@ static int wm_adsp_load(struct wm_adsp *dsp)
if (file == NULL) if (file == NULL)
return -ENOMEM; return -ENOMEM;
snprintf(file, PAGE_SIZE, "%s-dsp%d-%s.wmfw", dsp->part, dsp->num, snprintf(file, PAGE_SIZE, "%s-%s-%s.wmfw", dsp->part, dsp->fwf_name,
wm_adsp_fw[dsp->fw].file); wm_adsp_fw[dsp->fw].file);
file[PAGE_SIZE - 1] = '\0'; file[PAGE_SIZE - 1] = '\0';
...@@ -2226,7 +2220,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp) ...@@ -2226,7 +2220,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
if (file == NULL) if (file == NULL)
return -ENOMEM; return -ENOMEM;
snprintf(file, PAGE_SIZE, "%s-dsp%d-%s.bin", dsp->part, dsp->num, snprintf(file, PAGE_SIZE, "%s-%s-%s.bin", dsp->part, dsp->fwf_name,
wm_adsp_fw[dsp->fw].file); wm_adsp_fw[dsp->fw].file);
file[PAGE_SIZE - 1] = '\0'; file[PAGE_SIZE - 1] = '\0';
...@@ -2398,8 +2392,38 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp) ...@@ -2398,8 +2392,38 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
return ret; return ret;
} }
static int wm_adsp_create_name(struct wm_adsp *dsp)
{
char *p;
if (!dsp->name) {
dsp->name = devm_kasprintf(dsp->dev, GFP_KERNEL, "DSP%d",
dsp->num);
if (!dsp->name)
return -ENOMEM;
}
if (!dsp->fwf_name) {
p = devm_kstrdup(dsp->dev, dsp->name, GFP_KERNEL);
if (!p)
return -ENOMEM;
dsp->fwf_name = p;
for (; *p != 0; ++p)
*p = tolower(*p);
}
return 0;
}
int wm_adsp1_init(struct wm_adsp *dsp) int wm_adsp1_init(struct wm_adsp *dsp)
{ {
int ret;
ret = wm_adsp_create_name(dsp);
if (ret)
return ret;
INIT_LIST_HEAD(&dsp->alg_regions); INIT_LIST_HEAD(&dsp->alg_regions);
mutex_init(&dsp->pwr_lock); mutex_init(&dsp->pwr_lock);
...@@ -2672,7 +2696,7 @@ int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol, ...@@ -2672,7 +2696,7 @@ int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol,
struct wm_adsp *dsp = &dsps[mc->shift - 1]; struct wm_adsp *dsp = &dsps[mc->shift - 1];
char preload[32]; char preload[32];
snprintf(preload, ARRAY_SIZE(preload), "DSP%u Preload", mc->shift); snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->name);
dsp->preloaded = ucontrol->value.integer.value[0]; dsp->preloaded = ucontrol->value.integer.value[0];
...@@ -2867,8 +2891,7 @@ int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *comp ...@@ -2867,8 +2891,7 @@ int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *comp
{ {
char preload[32]; char preload[32];
snprintf(preload, ARRAY_SIZE(preload), "DSP%d Preload", dsp->num); snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->name);
snd_soc_component_disable_pin(component, preload); snd_soc_component_disable_pin(component, preload);
wm_adsp2_init_debugfs(dsp, component); wm_adsp2_init_debugfs(dsp, component);
...@@ -2891,6 +2914,10 @@ int wm_adsp2_init(struct wm_adsp *dsp) ...@@ -2891,6 +2914,10 @@ int wm_adsp2_init(struct wm_adsp *dsp)
{ {
int ret; int ret;
ret = wm_adsp_create_name(dsp);
if (ret)
return ret;
switch (dsp->rev) { switch (dsp->rev) {
case 0: case 0:
/* /*
......
...@@ -57,6 +57,8 @@ struct wm_adsp_compr_buf; ...@@ -57,6 +57,8 @@ struct wm_adsp_compr_buf;
struct wm_adsp { struct wm_adsp {
const char *part; const char *part;
const char *name;
const char *fwf_name;
int rev; int rev;
int num; int num;
int type; int type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment