From: Shenghao Ding <shenghao-ding@ti.com>
To: <broonie@kernel.org>
Cc: <robh+dt@kernel.org>, <andriy.shevchenko@linux.intel.com>,
<lgirdwood@gmail.com>, <perex@perex.cz>,
<pierre-louis.bossart@linux.intel.com>, <kevin-lu@ti.com>,
<13916275206@139.com>, <alsa-devel@alsa-project.org>,
<linux-kernel@vger.kernel.org>, <liam.r.girdwood@intel.com>,
<mengdong.lin@intel.com>, <baojun.xu@ti.com>,
<thomas.gfeller@q-drop.com>, <peeyush@ti.com>, <navada@ti.com>,
<tiwai@suse.de>, Shenghao Ding <shenghao-ding@ti.com>
Subject: [PATCH v1] ASoC: tas2781: fixed compiling issue in m68k
Date: Mon, 2 Oct 2023 17:04:33 +0800 [thread overview]
Message-ID: <20231002090434.1896-1-shenghao-ding@ti.com> (raw)
fixed m68k compiling issue: mapping table can save code field; storing the
dev_idx as a member of block can reduce unnecessary time and system
resource comsumption of dev_idx mapping every time the block data writing
to the dsp.
Signed-off-by: Shenghao Ding <shenghao-ding@ti.com>
---
Changes in v1:
- | Reported-by: kernel test robot <lkp@intel.com>
| Closes:
| https://lore.kernel.org/oe-kbuild-all/202309222048.RnSqEIK5-lkp@intel.
| com/
---
include/sound/tas2781-dsp.h | 5 +
sound/soc/codecs/tas2781-fmwlib.c | 234 +++++++++++++-----------------
2 files changed, 107 insertions(+), 132 deletions(-)
diff --git a/include/sound/tas2781-dsp.h b/include/sound/tas2781-dsp.h
index bd1b72bf47a5..ea9af2726a53 100644
--- a/include/sound/tas2781-dsp.h
+++ b/include/sound/tas2781-dsp.h
@@ -77,6 +77,11 @@ struct tasdev_blk {
unsigned int nr_cmds;
unsigned int blk_size;
unsigned int nr_subblocks;
+ /* fixed m68k compiling issue, storing the dev_idx as a member of block
+ * can reduce unnecessary timeand system resource comsumption of
+ * dev_idx mapping every time the block data writing to the dsp.
+ */
+ unsigned char dev_idx;
unsigned char *data;
};
diff --git a/sound/soc/codecs/tas2781-fmwlib.c b/sound/soc/codecs/tas2781-fmwlib.c
index eb55abae0d7b..e27775d834e9 100644
--- a/sound/soc/codecs/tas2781-fmwlib.c
+++ b/sound/soc/codecs/tas2781-fmwlib.c
@@ -80,10 +80,72 @@ struct tas_crc {
unsigned char len;
};
+struct blktyp_devidx_map {
+ unsigned char blktyp;
+ unsigned char dev_idx;
+};
+
static const char deviceNumber[TASDEVICE_DSP_TAS_MAX_DEVICE] = {
1, 2, 1, 2, 1, 1, 0, 2, 4, 3, 1, 2, 3, 4
};
+/* fixed m68k compiling issue: mapping table can save code field */
+static const struct blktyp_devidx_map ppc3_tas2781_mapping_table[] = {
+ { MAIN_ALL_DEVICES_1X, 0x80 },
+ { MAIN_DEVICE_A_1X, 0x81 },
+ { COEFF_DEVICE_A_1X, 0xC1 },
+ { PRE_DEVICE_A_1X, 0xC1 },
+ { PRE_SOFTWARE_RESET_DEVICE_A, 0xC1 },
+ { POST_SOFTWARE_RESET_DEVICE_A, 0xC1 },
+ { MAIN_DEVICE_B_1X, 0x82 },
+ { COEFF_DEVICE_B_1X, 0xC2 },
+ { PRE_DEVICE_B_1X, 0xC2 },
+ { PRE_SOFTWARE_RESET_DEVICE_B, 0xC2 },
+ { POST_SOFTWARE_RESET_DEVICE_B, 0xC2 },
+ { MAIN_DEVICE_C_1X, 0x83 },
+ { COEFF_DEVICE_C_1X, 0xC3 },
+ { PRE_DEVICE_C_1X, 0xC3 },
+ { PRE_SOFTWARE_RESET_DEVICE_C, 0xC3 },
+ { POST_SOFTWARE_RESET_DEVICE_C, 0xC3 },
+ { MAIN_DEVICE_D_1X, 0x84 },
+ { COEFF_DEVICE_D_1X, 0xC4 },
+ { PRE_DEVICE_D_1X, 0xC4 },
+ { PRE_SOFTWARE_RESET_DEVICE_D, 0xC4 },
+ { POST_SOFTWARE_RESET_DEVICE_D, 0xC4 },
+};
+
+static const struct blktyp_devidx_map ppc3_mapping_table[] = {
+ { MAIN_ALL_DEVICES_1X, 0x80 },
+ { MAIN_DEVICE_A_1X, 0x81 },
+ { COEFF_DEVICE_A_1X, 0xC1 },
+ { PRE_DEVICE_A_1X, 0xC1 },
+ { MAIN_DEVICE_B_1X, 0x82 },
+ { COEFF_DEVICE_B_1X, 0xC2 },
+ { PRE_DEVICE_B_1X, 0xC2 },
+ { MAIN_DEVICE_C_1X, 0x83 },
+ { COEFF_DEVICE_C_1X, 0xC3 },
+ { PRE_DEVICE_C_1X, 0xC3 },
+ { MAIN_DEVICE_D_1X, 0x84 },
+ { COEFF_DEVICE_D_1X, 0xC4 },
+ { PRE_DEVICE_D_1X, 0xC4 },
+};
+
+static const struct blktyp_devidx_map non_ppc3_mapping_table[] = {
+ { MAIN_ALL_DEVICES, 0x80 },
+ { MAIN_DEVICE_A, 0x81 },
+ { COEFF_DEVICE_A, 0xC1 },
+ { PRE_DEVICE_A, 0xC1 },
+ { MAIN_DEVICE_B, 0x82 },
+ { COEFF_DEVICE_B, 0xC2 },
+ { PRE_DEVICE_B, 0xC2 },
+ { MAIN_DEVICE_C, 0x83 },
+ { COEFF_DEVICE_C, 0xC3 },
+ { PRE_DEVICE_C, 0xC3 },
+ { MAIN_DEVICE_D, 0x84 },
+ { COEFF_DEVICE_D, 0xC4 },
+ { PRE_DEVICE_D, 0xC4 },
+};
+
static struct tasdevice_config_info *tasdevice_add_config(
struct tasdevice_priv *tas_priv, unsigned char *config_data,
unsigned int config_size, int *status)
@@ -316,6 +378,37 @@ int tasdevice_rca_parser(void *context, const struct firmware *fmw)
}
EXPORT_SYMBOL_NS_GPL(tasdevice_rca_parser, SND_SOC_TAS2781_FMWLIB);
+/* fixed m68k compiling issue: mapping table can save code field */
+static unsigned char map_dev_idx(struct tasdevice_fw *tas_fmw,
+ struct tasdev_blk *block)
+{
+
+ struct blktyp_devidx_map *p =
+ (struct blktyp_devidx_map *)non_ppc3_mapping_table;
+ struct tasdevice_dspfw_hdr *fw_hdr = &(tas_fmw->fw_hdr);
+ struct tasdevice_fw_fixed_hdr *fw_fixed_hdr = &(fw_hdr->fixed_hdr);
+
+ int i, n = ARRAY_SIZE(non_ppc3_mapping_table);
+ unsigned char dev_idx = 0;
+
+ if (fw_fixed_hdr->ppcver >= PPC3_VERSION_TAS2781) {
+ p = (struct blktyp_devidx_map *)ppc3_tas2781_mapping_table;
+ n = ARRAY_SIZE(ppc3_tas2781_mapping_table);
+ } else if (fw_fixed_hdr->ppcver >= PPC3_VERSION) {
+ p = (struct blktyp_devidx_map *)ppc3_mapping_table;
+ n = ARRAY_SIZE(ppc3_mapping_table);
+ }
+
+ for (i = 0; i < n; i++) {
+ if (block->type == p[i].blktyp) {
+ dev_idx = p[i].dev_idx;
+ break;
+ }
+ }
+
+ return dev_idx;
+}
+
static int fw_parse_block_data_kernel(struct tasdevice_fw *tas_fmw,
struct tasdev_blk *block, const struct firmware *fmw, int offset)
{
@@ -351,6 +444,14 @@ static int fw_parse_block_data_kernel(struct tasdevice_fw *tas_fmw,
block->nr_subblocks = be32_to_cpup((__be32 *)&data[offset]);
offset += 4;
+ /* fixed m68k compiling issue:
+ * 1. mapping table can save code field.
+ * 2. storing the dev_idx as a member of block can reduce unnecessary
+ * time and system resource comsumption of dev_idx mapping every
+ * time the block data writing to the dsp.
+ */
+ block->dev_idx = map_dev_idx(tas_fmw, block);
+
if (offset + block->blk_size > fmw->size) {
dev_err(tas_fmw->dev, "%s: nSublocks error\n", __func__);
offset = -EINVAL;
@@ -768,144 +869,13 @@ EXPORT_SYMBOL_NS_GPL(tasdevice_select_cfg_blk, SND_SOC_TAS2781_FMWLIB);
static int tasdevice_load_block_kernel(
struct tasdevice_priv *tasdevice, struct tasdev_blk *block)
{
- struct tasdevice_dspfw_hdr *fw_hdr = &(tasdevice->fmw->fw_hdr);
- struct tasdevice_fw_fixed_hdr *fw_fixed_hdr = &(fw_hdr->fixed_hdr);
const unsigned int blk_size = block->blk_size;
unsigned int i, length;
unsigned char *data = block->data;
- unsigned char dev_idx = 0;
-
- if (fw_fixed_hdr->ppcver >= PPC3_VERSION_TAS2781) {
- switch (block->type) {
- case MAIN_ALL_DEVICES_1X:
- dev_idx = 0x80;
- break;
- case MAIN_DEVICE_A_1X:
- dev_idx = 0x81;
- break;
- case COEFF_DEVICE_A_1X:
- case PRE_DEVICE_A_1X:
- case PRE_SOFTWARE_RESET_DEVICE_A:
- case POST_SOFTWARE_RESET_DEVICE_A:
- dev_idx = 0xC1;
- break;
- case MAIN_DEVICE_B_1X:
- dev_idx = 0x82;
- break;
- case COEFF_DEVICE_B_1X:
- case PRE_DEVICE_B_1X:
- case PRE_SOFTWARE_RESET_DEVICE_B:
- case POST_SOFTWARE_RESET_DEVICE_B:
- dev_idx = 0xC2;
- break;
- case MAIN_DEVICE_C_1X:
- dev_idx = 0x83;
- break;
- case COEFF_DEVICE_C_1X:
- case PRE_DEVICE_C_1X:
- case PRE_SOFTWARE_RESET_DEVICE_C:
- case POST_SOFTWARE_RESET_DEVICE_C:
- dev_idx = 0xC3;
- break;
- case MAIN_DEVICE_D_1X:
- dev_idx = 0x84;
- break;
- case COEFF_DEVICE_D_1X:
- case PRE_DEVICE_D_1X:
- case PRE_SOFTWARE_RESET_DEVICE_D:
- case POST_SOFTWARE_RESET_DEVICE_D:
- dev_idx = 0xC4;
- break;
- default:
- dev_info(tasdevice->dev,
- "%s: load block: Other Type = 0x%02x\n",
- __func__, block->type);
- break;
- }
- } else if (fw_fixed_hdr->ppcver >=
- PPC3_VERSION) {
- switch (block->type) {
- case MAIN_ALL_DEVICES_1X:
- dev_idx = 0x80;
- break;
- case MAIN_DEVICE_A_1X:
- dev_idx = 0x81;
- break;
- case COEFF_DEVICE_A_1X:
- case PRE_DEVICE_A_1X:
- dev_idx = 0xC1;
- break;
- case MAIN_DEVICE_B_1X:
- dev_idx = 0x82;
- break;
- case COEFF_DEVICE_B_1X:
- case PRE_DEVICE_B_1X:
- dev_idx = 0xC2;
- break;
- case MAIN_DEVICE_C_1X:
- dev_idx = 0x83;
- break;
- case COEFF_DEVICE_C_1X:
- case PRE_DEVICE_C_1X:
- dev_idx = 0xC3;
- break;
- case MAIN_DEVICE_D_1X:
- dev_idx = 0x84;
- break;
- case COEFF_DEVICE_D_1X:
- case PRE_DEVICE_D_1X:
- dev_idx = 0xC4;
- break;
- default:
- dev_info(tasdevice->dev,
- "%s: load block: Other Type = 0x%02x\n",
- __func__, block->type);
- break;
- }
- } else {
- switch (block->type) {
- case MAIN_ALL_DEVICES:
- dev_idx = 0|0x80;
- break;
- case MAIN_DEVICE_A:
- dev_idx = 0x81;
- break;
- case COEFF_DEVICE_A:
- case PRE_DEVICE_A:
- dev_idx = 0xC1;
- break;
- case MAIN_DEVICE_B:
- dev_idx = 0x82;
- break;
- case COEFF_DEVICE_B:
- case PRE_DEVICE_B:
- dev_idx = 0xC2;
- break;
- case MAIN_DEVICE_C:
- dev_idx = 0x83;
- break;
- case COEFF_DEVICE_C:
- case PRE_DEVICE_C:
- dev_idx = 0xC3;
- break;
- case MAIN_DEVICE_D:
- dev_idx = 0x84;
- break;
- case COEFF_DEVICE_D:
- case PRE_DEVICE_D:
- dev_idx = 0xC4;
- break;
- default:
- dev_info(tasdevice->dev,
- "%s: load block: Other Type = 0x%02x\n",
- __func__, block->type);
- break;
- }
- }
for (i = 0, length = 0; i < block->nr_subblocks; i++) {
int rc = tasdevice_process_block(tasdevice, data + length,
- dev_idx, blk_size - length);
+ block->dev_idx, blk_size - length);
if (rc < 0) {
dev_err(tasdevice->dev,
"%s: %u %u sublock write error\n",
--
2.34.1
next reply other threads:[~2023-10-02 9:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-02 9:04 Shenghao Ding [this message]
2023-10-02 15:17 ` [PATCH v1] ASoC: tas2781: fixed compiling issue in m68k Mark Brown
2023-10-02 19:24 ` Geert Uytterhoeven
2023-10-03 8:52 ` Andy Shevchenko
2023-10-03 10:16 ` Geert Uytterhoeven
2023-10-03 10:46 ` [EXTERNAL] " Ding, Shenghao
2023-10-03 12:15 ` Geert Uytterhoeven
2023-10-03 16:23 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231002090434.1896-1-shenghao-ding@ti.com \
--to=shenghao-ding@ti.com \
--cc=13916275206@139.com \
--cc=alsa-devel@alsa-project.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=kevin-lu@ti.com \
--cc=lgirdwood@gmail.com \
--cc=liam.r.girdwood@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mengdong.lin@intel.com \
--cc=navada@ti.com \
--cc=peeyush@ti.com \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=robh+dt@kernel.org \
--cc=thomas.gfeller@q-drop.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).