From: Fred Treven <fred.treven@cirrus.com>
To: Fred Treven <fred.treven@cirrus.com>,
Ben Bright <ben.bright@cirrus.com>,
James Ogletree <james.ogletree@cirrus.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
Simon Trimmer <simont@opensource.cirrus.com>,
Charles Keepax <ckeepax@opensource.cirrus.com>,
Richard Fitzgerald <rf@opensource.cirrus.com>,
<patches@opensource.cirrus.com>, <linux-input@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <lee@kernel.org>
Subject: [PATCH 3/5] firmware: cs_dsp: Add ability to loa multiple coefficient files
Date: Thu, 25 May 2023 19:04:29 -0500 [thread overview]
Message-ID: <1685059471-9598-3-git-send-email-fred.treven@cirrus.com> (raw)
In-Reply-To: <1685059471-9598-1-git-send-email-fred.treven@cirrus.com>
Add cs_dsp_power_up_multiple() which accepts an array of
cs_dsp_coeff_desc firmware-filename pairs to load.
This enables the user to load more than one tuning file
along with the associated firmware.
Change cs_dsp_power_up() to make use of the new function
with a single coefficient file.
Signed-off-by: Fred Treven <fred.treven@cirrus.com>
---
drivers/firmware/cirrus/cs_dsp.c | 61 ++++++++++++++++++++++++++--------
include/linux/firmware/cirrus/cs_dsp.h | 20 +++++++++--
2 files changed, 66 insertions(+), 15 deletions(-)
diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c
index f558b390fbfe..3242095c1b13 100644
--- a/drivers/firmware/cirrus/cs_dsp.c
+++ b/drivers/firmware/cirrus/cs_dsp.c
@@ -2515,28 +2515,30 @@ static void cs_dsp_halo_stop_watchdog(struct cs_dsp *dsp)
}
/**
- * cs_dsp_power_up() - Downloads firmware to the DSP
- * @dsp: pointer to DSP structure
+ * cs_dsp_power_up_multiple() - Downloads firmware and multiple coefficient files to the DSP
+ * @dsp: pointer to the DSP structure
* @wmfw_firmware: the firmware to be sent
* @wmfw_filename: file name of firmware to be sent
- * @coeff_firmware: the coefficient data to be sent
- * @coeff_filename: file name of coefficient to data be sent
+ * @coeffs: coefficient data and filename pairs to be sent
+ * @num_coeffs: number of coefficient files to be sent
* @fw_name: the user-friendly firmware name
*
* This function is used on ADSP2 and Halo DSP cores, it powers-up the DSP core
* and downloads the firmware but does not start the firmware running. The
* cs_dsp booted flag will be set once completed and if the core has a low-power
* memory retention mode it will be put into this state after the firmware is
- * downloaded.
+ * downloaded. Differs from cs_dsp_power_up() in that it allows for multiple
+ * coefficient files to be downloaded.
*
* Return: Zero for success, a negative number on error.
+ *
+ *
*/
-int cs_dsp_power_up(struct cs_dsp *dsp,
- const struct firmware *wmfw_firmware, char *wmfw_filename,
- const struct firmware *coeff_firmware, char *coeff_filename,
- const char *fw_name)
+int cs_dsp_power_up_multiple(struct cs_dsp *dsp, const struct firmware *wmfw_firmware,
+ char *wmfw_filename, struct cs_dsp_coeff_desc *coeffs, int num_coeffs,
+ const char *fw_name)
{
- int ret;
+ int i, ret;
mutex_lock(&dsp->pwr_lock);
@@ -2562,9 +2564,12 @@ int cs_dsp_power_up(struct cs_dsp *dsp,
if (ret != 0)
goto err_ena;
- ret = cs_dsp_load_coeff(dsp, coeff_firmware, coeff_filename);
- if (ret != 0)
- goto err_ena;
+ for (i = 0; i < num_coeffs; i++) {
+ ret = cs_dsp_load_coeff(dsp, coeffs[i].coeff_firmware,
+ coeffs[i].coeff_filename);
+ if (ret != 0 && !coeffs[i].optional)
+ goto err_ena;
+ }
/* Initialize caches for enabled and unset controls */
ret = cs_dsp_coeff_init_control_caches(dsp);
@@ -2590,6 +2595,36 @@ int cs_dsp_power_up(struct cs_dsp *dsp,
return ret;
}
+EXPORT_SYMBOL_NS_GPL(cs_dsp_power_up_multiple, FW_CS_DSP);
+
+/**
+ * cs_dsp_power_up() - Downloads firmware to the DSP
+ * @dsp: pointer to DSP structure
+ * @wmfw_firmware: the firmware to be sent
+ * @wmfw_filename: file name of firmware to be sent
+ * @coeff_firmware: the coefficient data to be sent
+ * @coeff_filename: file name of coefficient data to be sent
+ * @fw_name: the user-friendly firmware name
+ *
+ * This function is used on ADSP2 and Halo DSP cores, it powers-up the DSP core
+ * and downloads the firmware but does not start the firmware running. The
+ * cs_dsp booted flag will be set once completed and if the core has a low-power
+ * memory retention mode it will be put into this state after the firmware is
+ * downloaded.
+ *
+ * Return: Zero for success, a negative number on error.
+ */
+int cs_dsp_power_up(struct cs_dsp *dsp, const struct firmware *wmfw_firmware, char *wmfw_filename,
+ const struct firmware *coeff_firmware, char *coeff_filename, const char *fw_name)
+{
+ struct cs_dsp_coeff_desc coeff_desc;
+
+ coeff_desc.coeff_firmware = coeff_firmware;
+ coeff_desc.coeff_filename = coeff_filename;
+ coeff_desc.optional = false;
+
+ return cs_dsp_power_up_multiple(dsp, wmfw_firmware, wmfw_filename, &coeff_desc, 1, fw_name);
+}
EXPORT_SYMBOL_NS_GPL(cs_dsp_power_up, FW_CS_DSP);
/**
diff --git a/include/linux/firmware/cirrus/cs_dsp.h b/include/linux/firmware/cirrus/cs_dsp.h
index cad828e21c72..1fda4104140c 100644
--- a/include/linux/firmware/cirrus/cs_dsp.h
+++ b/include/linux/firmware/cirrus/cs_dsp.h
@@ -43,6 +43,18 @@
#define CS_DSP_ACKED_CTL_MAX_VALUE 0xFFFFFF
/**
+ * struct cs_dsp_coeff_desc - Describes a coeff. file + filename pair
+ * @coeff_firmware: Firmware struct to populate with coeff. data
+ * @coeff_filename: File from which coeff. data is loaded
+ * @optional: Designates whether or not to error out if file fails to load
+ */
+struct cs_dsp_coeff_desc {
+ const struct firmware *coeff_firmware;
+ char *coeff_filename;
+ bool optional;
+};
+
+/**
* struct cs_dsp_region - Describes a logical memory region in DSP address space
* @type: Memory region type
* @base: Address of region
@@ -217,10 +229,14 @@ int cs_dsp_adsp1_power_up(struct cs_dsp *dsp,
const struct firmware *coeff_firmware, char *coeff_filename,
const char *fw_name);
void cs_dsp_adsp1_power_down(struct cs_dsp *dsp);
-int cs_dsp_power_up(struct cs_dsp *dsp,
+int cs_dsp_power_up_multiple(struct cs_dsp *dsp,
const struct firmware *wmfw_firmware, char *wmfw_filename,
- const struct firmware *coeff_firmware, char *coeff_filename,
+ struct cs_dsp_coeff_desc *coeffs, int num_coeffs,
const char *fw_name);
+int cs_dsp_power_up(struct cs_dsp *dsp,
+ const struct firmware *wmfw_firmware, char *wmfw_filename,
+ const struct firmware *coeff_firmware, char *coeff_filename,
+ const char *fw_name);
void cs_dsp_power_down(struct cs_dsp *dsp);
int cs_dsp_run(struct cs_dsp *dsp);
void cs_dsp_stop(struct cs_dsp *dsp);
--
2.7.4
next prev parent reply other threads:[~2023-05-26 0:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 0:04 [PATCH v2 1/5] dt-bindings: input: cirrus,cs40l26: Support for CS40L26 Fred Treven
2023-05-26 0:04 ` [PATCH v2 2/5] Input: cs40l26 - Support for CS40L26 Haptic Device Fred Treven
2023-05-26 0:04 ` Fred Treven [this message]
2023-05-26 0:04 ` [PATCH 4/5] Input: cs40l26 - Load multiple coefficient files Fred Treven
2023-05-26 19:37 ` Jeff LaBundy
2023-05-26 0:04 ` [PATCH RFC 5/5] mfd: cs40l26: Add CODEC driver component Fred Treven
2023-05-26 7:54 ` Lee Jones
2023-05-26 19:43 ` Jeff LaBundy
2023-05-26 21:23 ` Fred Treven
2023-05-26 21:55 ` Jeff LaBundy
2023-05-26 19:27 ` [PATCH v2 1/5] dt-bindings: input: cirrus,cs40l26: Support for CS40L26 Conor Dooley
2023-05-26 21:32 ` Fred Treven
2023-05-26 22:03 ` Conor Dooley
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=1685059471-9598-3-git-send-email-fred.treven@cirrus.com \
--to=fred.treven@cirrus.com \
--cc=ben.bright@cirrus.com \
--cc=ckeepax@opensource.cirrus.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=james.ogletree@cirrus.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=rf@opensource.cirrus.com \
--cc=robh+dt@kernel.org \
--cc=simont@opensource.cirrus.com \
/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
all inboxes | Powered by JetHome®