lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200721170007.4554-4-srinivas.kandagatla@linaro.org>
Date:   Tue, 21 Jul 2020 18:00:04 +0100
From:   Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To:     broonie@...nel.org
Cc:     vkoul@...nel.org, perex@...ex.cz, tiwai@...e.com,
        lgirdwood@...il.com, alsa-devel@...a-project.org,
        linux-kernel@...r.kernel.org, ckeepax@...nsource.cirrus.com,
        Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Subject: [RFC PATCH v2 3/6] ALSA: compress: add flags to snd_compr_caps to expose dsp caps

Some of the DSPs like Qualcomm QDSP has ablity to change decoders
dynamically on a single stream, This could be used for features
like Cross Fade or gapless with different codec profile tracks.

Exposing such features in flags variable of compress caps descriptor
would provide userspace more flexibity in usings dsp features.

For now only one flag of switching decoders is added which is used
in subsequent patches.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
---
 include/uapi/sound/compress_offload.h |  7 ++++++-
 sound/core/compress_offload.c         | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h
index c46286113a4b..43c78cdf492c 100644
--- a/include/uapi/sound/compress_offload.h
+++ b/include/uapi/sound/compress_offload.h
@@ -88,6 +88,9 @@ enum snd_compr_direction {
 	SND_COMPRESS_CAPTURE
 };
 
+/* DSP can switch decoder in a single Stream while doing gapless */
+#define SND_COMPR_CAP_FLAGS_DSP_CAN_SWITCH_DECODER	((__u32) 0x00000001)
+
 /**
  * struct snd_compr_caps - caps descriptor
  * @codecs: pointer to array of codecs
@@ -97,6 +100,7 @@ enum snd_compr_direction {
  * @min_fragments: min fragments supported by DSP
  * @max_fragments: max fragments supported by DSP
  * @num_codecs: number of codecs supported
+ * @flags: flags to expose various DSP capabilities
  * @reserved: reserved field
  */
 struct snd_compr_caps {
@@ -107,7 +111,8 @@ struct snd_compr_caps {
 	__u32 min_fragments;
 	__u32 max_fragments;
 	__u32 codecs[MAX_NUM_CODECS];
-	__u32 reserved[11];
+	__u32 flags;
+	__u32 reserved[10];
 } __attribute__((packed, aligned(4)));
 
 /**
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 184722643c97..abebd5fee2d2 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -590,12 +590,32 @@ static int snd_compress_check_input(struct snd_compr_params *params)
 
 }
 
+static bool snd_compr_can_dsp_switch_decoder(struct snd_compr_stream *stream)
+{
+	struct snd_compr_caps caps;
+
+	if (!stream->ops->get_caps)
+		return false;
+
+	memset(&caps, 0, sizeof(caps));
+	if (stream->ops->get_caps(stream, &caps))
+		return false;
+
+	if (caps.flags & SND_COMPR_CAP_FLAGS_DSP_CAN_SWITCH_DECODER)
+		return true;
+
+	return false;
+}
+
 static int snd_compr_set_codec_params(struct snd_compr_stream *stream,
 				      unsigned long arg)
 {
 	struct snd_codec *params;
 	int retval;
 
+	if (!snd_compr_can_dsp_switch_decoder(stream))
+		return -ENOTSUPP;
+
 	if (!stream->ops->set_codec_params)
 		return -EPERM;
 
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ