@@ -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)));
/**
@@ -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;
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@linaro.org> --- include/uapi/sound/compress_offload.h | 7 ++++++- sound/core/compress_offload.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-)