Re: [RFC PATCH 04/28] media: mali-vpu: initialize decoder format state
From: Charvi Mehta
Date: Tue Nov 24 2026 - 09:57:04 EST
On 11/19/26 20:30, Nicolas Dufresne wrote:
The format arrays are already static const and shared; only the list descriptor+void mali_vpu_session_init_dec(struct mali_vpu_session *sess)Why? the variant are constant, you can just read the information from the
+{
+ const struct mali_vpu_format_caps *variant_fmts = &sess->vpu_dev->variant->fmt_caps;
+
+ sess->port_src.supported_fmts = variant_fmts->dec_src;
+ sess->port_dst.supported_fmts = variant_fmts->dec_dst;
variant. Make a getter or point to it.
(the pointer and count) is copied. However, you’re right that each port could
simply point to the const list in the variant, avoiding that copy too.
I’ll make that change.
p.s. is that "port" like in OMX IL?Here, “port” just groups the format and streaming state for a V4L2 OUTPUT
or CAPTURE queue.
+static int mali_vpu_set_port_fmt(struct mali_vpu_port *port,I might have to come back to this code once we have TRY/SET_FMT in place,
+ enum v4l2_buf_type type,
+ u32 width, u32 height)
+{
+ struct v4l2_pix_format_mplane *pix_mp = &port->curr_fmt.fmt.pix_mp;
+ const struct mali_vpu_format_desc *fmt_default;
+ int ret;
+
+ if (!port->supported_fmts.fmts || !port->supported_fmts.num_fmts)
+ return -EINVAL;
+
+ fmt_default = &port->supported_fmts.fmts[0];
+
+ memset(&port->curr_fmt, 0, sizeof(port->curr_fmt));
+ port->curr_fmt.type = type;
+
+ if (fmt_default->flags & V4L2_FMT_FLAG_COMPRESSED) {
+ pix_mp->pixelformat = fmt_default->fourcc;
+ pix_mp->num_planes = 1;
+ pix_mp->width = width;
+ pix_mp->height = height;
+ pix_mp->plane_fmt[0].bytesperline = 0;
+
+ /*
+ * Use one byte per pixel as the default compressed sizeimage,
+ * with a minimum of one page, aligned to a page boundary.
+ */
+ pix_mp->plane_fmt[0].sizeimage = PAGE_ALIGN(max_t(u32, PAGE_SIZE, width * height));
+ } else {
+ ret = v4l2_fill_pixfmt_mp(pix_mp, fmt_default->fourcc, width, height);
+ if (ret)
+ return ret;
meanwhile it seems more like a default setting helper then something that will
be part of the ioctl interface.
Thanks, yes, this helper initializes the queue’s default format.
I’ll rename it to `mali_vpu_init_port_fmt()` to make that clear.
Patch 7 extracts the format-filling logic into `mali_vpu_fill_pixmp_fmt()`,
shared by initialization and TRY_FMT/S_FMT.
I’ve generally placed the direction last, as in dec_src/dec_dst and pixmp_src/pixmp_dst.struct mali_vpu_session {Ok, its time to comment, src_port and dst_port is a lot easier to read imho.
struct mali_vpu_dev *vpu_dev;
enum mali_vpu_session_role role;
+ struct mali_vpu_port port_src;
+ struct mali_vpu_port port_dst;
I’d prefer to retain port_src/port_dst to follow that pattern.
These limits apply to H.264 and the three 8-bit YUV420 capture formats+ },Are you sure this will be the same for all codecs and all formats?
+ .frmsz_caps = {
+ .stepwise = {
+ .min_width = MALI_V76_MIN_FRAME_WIDTH,
+ .max_width = MALI_V76_MAX_FRAME_WIDTH,
+ .step_width = 2,
+ .min_height = MALI_V76_MIN_FRAME_HEIGHT,
+ .max_height = MALI_V76_MAX_FRAME_HEIGHT,
+ .step_height = 2,
+ },
currently exposed by the driver. The plan is to introduce separate ranges
when adding a codec or format that needs different limits.
Here, dec identifies the decoder role and src/dst the queue direction;+struct mali_vpu_format_caps {Strange naming, perhaps src_formats/dst_formats?
+ const struct mali_vpu_format_list dec_src;
+ const struct mali_vpu_format_list dec_dst;
fmt_caps already provides the format context. I’d prefer to retain it.
Regards,
Charvi