[alsa-devel] compress: adding support for hardware dependent params

Banajit Goswami bgoswami at codeaurora.org
Sun Mar 16 06:55:37 CET 2014


>>  We have a requirement, where we need to set a number of hardware
>> specific
>> parameters for compressed offload use-cases, before starting a stream.
>> As
>> these parameters need to be set once for the entire session, we would
>> like to explore the best way to set these additional parameters
>> somewhere
>> before calling trigger() function.
>>  Below are few of the proposed solutions that we could think of at this
>> point for getting this done-
> As you have not mentioned what kind of metadata you are talking about
> I am assuming if your meta data can fit in below structure then we already
> have a code in upstream which takes care of your need.
> 140 struct snd_compr_metadata {
> 141          __u32 key;
> 142          __u32 value[8];
> 143 };
> Structure snd_compr_ops has set_metadata and get_metadata callbacks
> which you can use for your need.

 We can probably use the same snd_compr_metadata structure for setting the
hardware specific parameters, but the only issue is that, currently this
structure is being used only from compress_set_gapless_metadata() in
external/tinycompress/compress.c to set metadata specific to gapless
audio. The parameters we are looking to set is not specific to gapless
audio, but rather a few hardware/board specific parameters (for passing
to our driver)

I think, the best way to use the same structure and have the new
requirement fulfilled is that-

1. Define a new KEY inside the enum in

enum {

2. Have a new generic function (not specific to gapless audio) in
external/tinycompress/compress.c to call driver IOCTL function, to set the
H/W specific parameters-

int compress_set_metadata(struct compress *compress,
	struct compr_gapless_mdata *mdata)
	struct snd_compr_metadata metadata;
	int version;

	if (!is_compress_ready(compress))
		return oops(compress, ENODEV, "device not ready");

	version = get_compress_version(compress);
	if (version <= 0)
		return -1;

	if (version < SNDRV_PROTOCOL_VERSION(0, 1, 1))
		return oops(compress, ENXIO, "gapless apis not supported in kernel");

	metadata.value[0] = mdata->hw_specific_metadata;
	if (ioctl(compress->fd, SNDRV_COMPRESS_SET_METADATA, &metadata))
		return oops(compress, errno, "can't set metadata for stream\n");

	return 0;

Let me know your comment on this.


The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

More information about the Alsa-devel mailing list