[RFC PATCH 25/28] media: mali-vpu: handle firmware buffer parameters
From: Charvi Mehta
Date: Thu Nov 19 2026 - 10:45:21 EST
From: Shobhit Pandey <shobhit.pandey@xxxxxxx>
Add protocol definitions and parsing for firmware buffer-parameter
messages. Recognize colour-description and DPB-held-frame
notifications, log and ignore them when no session action is required.
Signed-off-by: Shobhit Pandey <shobhit.pandey@xxxxxxx>
Signed-off-by: Charvi Mehta <charvi.mehta@xxxxxxx>
---
.../platform/arm/mali-vpu/mali-vpu-firmware.c | 32 +++++++++++++++++++
.../platform/arm/mali-vpu/mali-vpu-firmware.h | 5 +++
.../arm/mali-vpu/mali-vpu-protocol-def-v3.h | 19 +++++++++++
.../platform/arm/mali-vpu/mali-vpu-session.c | 9 ++++++
4 files changed, 65 insertions(+)
diff --git a/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.c b/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.c
index 55bad502cae0b..34d57b288a682 100644
--- a/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.c
+++ b/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.c
@@ -8,6 +8,7 @@
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/sizes.h>
+#include <linux/stddef.h>
#include <linux/string.h>
#include "mali-vpu-firmware.h"
@@ -950,6 +951,33 @@ mali_vpu_convert_buffer_bitstream(struct mali_vpu_fw *fw,
return 0;
}
+static int mali_vpu_convert_buffer_param(struct mali_vpu_fw_msg *msg,
+ struct mve_buffer_param *p,
+ size_t size)
+{
+ if (size < sizeof(p->type))
+ return -EPROTO;
+
+ switch (p->type) {
+ case MVE_BUFFER_PARAM_TYPE_COLOUR_DESCRIPTION:
+ /* The colour-description payload is currently ignored. */
+ msg->code = MALI_VPU_FW_CODE_COLOR_DESC;
+ break;
+ case MVE_BUFFER_PARAM_TYPE_DPB_HELD_FRAMES:
+ if (size < offsetofend(struct mve_buffer_param, data.arg))
+ return -EPROTO;
+
+ msg->code = MALI_VPU_FW_CODE_DPB_HELD_FRAMES;
+ msg->data.dpb_held_frames = p->data.arg;
+ break;
+ default:
+ msg->code = MALI_VPU_FW_CODE_UNKNOWN;
+ break;
+ }
+
+ return 1;
+}
+
static int mali_vpu_fw_get_buffer(struct mali_vpu_fw *fw,
struct mali_vpu_fw_proto_page *buf_host_page,
struct mali_vpu_fw_proto_page *buf_mve_page,
@@ -1007,6 +1035,7 @@ int mali_vpu_fw_parse_msg(struct mali_vpu_fw *fw, struct mali_vpu_fw_msg *msg)
struct mve_response_state_change state_change;
struct mve_response_frame_alloc_parameters alloc_params;
struct mve_response_sequence_parameters seq_params;
+ struct mve_buffer_param buffer_param;
struct mve_response_error error;
} fw_msg = {};
size_t size = sizeof(fw_msg);
@@ -1137,6 +1166,9 @@ int mali_vpu_fw_parse_msg(struct mali_vpu_fw *fw, struct mali_vpu_fw_msg *msg)
fw->pending_response_count--;
break;
+ case MVE_BUFFER_CODE_PARAM:
+ ret = mali_vpu_convert_buffer_param(msg, &fw_msg.buffer_param, size);
+ break;
case MVE_RESPONSE_CODE_ERROR: {
size_t message_offset = offsetof(struct mve_response_error, message);
size_t message_size;
diff --git a/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.h b/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.h
index ca90cc71ac64e..6c46f23ac8638 100644
--- a/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.h
+++ b/drivers/media/platform/arm/mali-vpu/mali-vpu-firmware.h
@@ -144,6 +144,8 @@ struct mali_vpu_fw_error {
* @MALI_VPU_FW_CODE_OUTPUT_FLUSH: Firmware successfully completed a CAPTURE queue flush.
* @MALI_VPU_FW_CODE_SEQUENCE_PARAMS: Firmware reported new sequence parameters.
* @MALI_VPU_FW_CODE_ALLOC_PARAM: Firmware reported new frame allocation parameters.
+ * @MALI_VPU_FW_CODE_COLOR_DESC: Firmware reported colour-description metadata.
+ * @MALI_VPU_FW_CODE_DPB_HELD_FRAMES: Firmware reported the number of frames held in the DPB.
* @MALI_VPU_FW_CODE_UNKNOWN: Unrecognized firmware message.
* @MALI_VPU_FW_CODE_MAX: Sentinel marking the end of the message-code enum.
*/
@@ -164,6 +166,8 @@ enum mali_vpu_fw_code {
MALI_VPU_FW_CODE_OUTPUT_FLUSH, /* Driver <- Firmware. */
MALI_VPU_FW_CODE_SEQUENCE_PARAMS, /* Driver <- Firmware. */
MALI_VPU_FW_CODE_ALLOC_PARAM, /* Driver <- Firmware. */
+ MALI_VPU_FW_CODE_COLOR_DESC, /* Driver <- Firmware. */
+ MALI_VPU_FW_CODE_DPB_HELD_FRAMES, /* Driver <- Firmware. */
MALI_VPU_FW_CODE_UNKNOWN, /* Driver <- Firmware. */
MALI_VPU_FW_CODE_MAX
};
@@ -182,6 +186,7 @@ struct mali_vpu_fw_msg {
struct mali_vpu_buffer *vpu_buf;
struct mali_vpu_fw_alloc_param alloc_params;
struct mali_vpu_fw_seq_param seq_params;
+ u32 dpb_held_frames;
} data;
};
diff --git a/drivers/media/platform/arm/mali-vpu/mali-vpu-protocol-def-v3.h b/drivers/media/platform/arm/mali-vpu/mali-vpu-protocol-def-v3.h
index cb4533a367957..76dc7bf076c8f 100644
--- a/drivers/media/platform/arm/mali-vpu/mali-vpu-protocol-def-v3.h
+++ b/drivers/media/platform/arm/mali-vpu/mali-vpu-protocol-def-v3.h
@@ -269,6 +269,8 @@ struct mve_msg_header {
#define MVE_BUFFER_CODE_FRAME (3001)
/* struct mve_buffer_bitstream */
#define MVE_BUFFER_CODE_BITSTREAM (3002)
+ /* struct mve_buffer_param */
+ #define MVE_BUFFER_CODE_PARAM (3003)
u16 size; /* size in bytes of trailing data, 0 if none */
};
@@ -601,4 +603,21 @@ struct mve_buffer_bitstream {
u32 reserved;
};
+/* Parameters that are sent in the same communication channels
+ * as the buffers. A parameter applies to all subsequent buffers.
+ * Some types are only valid for decode, and some only for encode.
+ */
+struct mve_buffer_param {
+ u32 type; /* Extra data: */
+ #define MVE_BUFFER_PARAM_TYPE_COLOUR_DESCRIPTION (15)
+ /* arg, number of output buffers that are complete and held by firmware in the
+ * DPB for reordering purposes. Valid after the next frame is output.
+ */
+ #define MVE_BUFFER_PARAM_TYPE_DPB_HELD_FRAMES (19)
+
+ union {
+ u32 arg;
+ } data;
+};
+
#endif /* __MALI_VPU_PROTOCOL_DEF_V3_H__ */
diff --git a/drivers/media/platform/arm/mali-vpu/mali-vpu-session.c b/drivers/media/platform/arm/mali-vpu/mali-vpu-session.c
index fcfad581223be..411421e175e71 100644
--- a/drivers/media/platform/arm/mali-vpu/mali-vpu-session.c
+++ b/drivers/media/platform/arm/mali-vpu/mali-vpu-session.c
@@ -559,6 +559,15 @@ static int mali_vpu_session_handle_fw_msg(struct mali_vpu_session *sess,
* state update is required.
*/
return 0;
+ case MALI_VPU_FW_CODE_COLOR_DESC:
+ /* Colour metadata is currently not consumed by the driver. */
+ return 0;
+ case MALI_VPU_FW_CODE_DPB_HELD_FRAMES:
+ /* DPB occupancy is informational. */
+ dev_dbg(sess->vpu_dev->dev,
+ "firmware holds %u frames in the DPB\n",
+ fw_msg->data.dpb_held_frames);
+ return 0;
case MALI_VPU_FW_CODE_OUTPUT_FLUSH:
dev_dbg(sess->vpu_dev->dev, "fw rsp: Dst queue flushed\n");
if (sess->role == MALI_VPU_DECODER && sess->drc_pending)
--
2.43.0