[RFC PATCH 1/4] ASoC: qcom: audioreach: exclude headers and padding from PCM format sizes

From: Zhang Jiaxi

Date: Thu Oct 08 2026 - 18:35:33 EST


From: Jiaxi Zhang <z1529105815@xxxxxxxxxxx>

The media-format payload length excludes its preceding headers and
alignment bytes. The shared-memory PCM path currently counts the APM
parameter header and padding; PCM output configuration also includes
alignment bytes in the inner length.

Keep packet allocation and transport alignment unchanged. For stereo
PCM, describe 30 bytes of parameter data and 18 bytes of PCM format
payload. Reject zero channels before allocating either PCM configuration
packet. Preserve the target's physical-to-logical channel-map conversion
and compressed-format serialization.

This independent draft targets sound.git for-next
62d9f9ffdfd44e88010412bf8f23732f0a93a9be. Public Graphservices
format definitions, stock packet observations and actual-function tests
support the length change. Earlier tests and object compilation used
fixed Qualcomm 7.2 source. The three changed objects now compile without
warnings on this exact ASoC target with Clang 22.1.8; this target has not
been hardware-tested. No proprietary profile, calibration data or
Warsaw hardware setup is included.

Signed-off-by: Jiaxi Zhang <z1529105815@xxxxxxxxxxx>

---
diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
--- a/sound/soc/qcom/qdsp6/audioreach.c
+++ b/sound/soc/qcom/qdsp6/audioreach.c
@@ -1185,7 +1185,7 @@
int payload_size;
int i, j;

- if (num_channels > 4) {
+ if (!num_channels || num_channels > 4) {
dev_err(graph->dev, "Error: Invalid channels (%d)!\n", num_channels);
return -EINVAL;
}
@@ -1203,11 +1203,11 @@
param_data->module_instance_id = module->instance_id;
param_data->error_code = 0;
param_data->param_id = PARAM_ID_PCM_OUTPUT_FORMAT_CFG;
- param_data->param_size = payload_size - APM_MODULE_PARAM_DATA_SIZE;
+ param_data->param_size = sizeof(cfg->header) + sizeof(*media_cfg) + num_channels;

cfg->header.data_format = DATA_FORMAT_FIXED_POINT;
cfg->header.fmt_id = MEDIA_FMT_ID_PCM;
- cfg->header.payload_size = APM_PCM_OUT_FMT_CFG_PSIZE(media_cfg, num_channels);
+ cfg->header.payload_size = sizeof(*media_cfg) + num_channels;

media_cfg = &cfg->media_cfg;
media_cfg->alignment = PCM_LSB_ALIGNED;
@@ -1275,7 +1275,7 @@
int i, j;
void *p;

- if (num_channels > 4) {
+ if (!num_channels || num_channels > 4) {
dev_err(graph->dev, "Error: Invalid channels (%d)!\n", num_channels);
return -EINVAL;
}
@@ -1301,7 +1301,8 @@
if (mcfg->fmt == SND_AUDIOCODEC_PCM) {
header->data_format = DATA_FORMAT_FIXED_POINT;
header->fmt_id = MEDIA_FMT_ID_PCM;
- header->payload_size = payload_size - sizeof(*header);
+ header->payload_size = sizeof(*cfg) + num_channels;
+ param_data->param_size = sizeof(*header) + header->payload_size;

p = p + sizeof(*header);
cfg = p;