From a9c897fa8b993ca162d9e66f49cdce72929a280a Mon Sep 17 00:00:00 2001 From: claude-noether Date: Thu, 14 May 2026 09:16:54 +0000 Subject: [PATCH] =?UTF-8?q?iter21=20=CE=B1-24=20(diag):=20G=5FEXT=5FCTRLS?= =?UTF-8?q?=20readback=20after=20S=5FEXT=5FCTRLS=20staging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Env-gated by LIBVA_V4L2_REQ_GETBACK. After v4l2_set_controls() against the request_fd in h265_set_controls(), issue G_EXT_CTRLS with the same request_fd targeting SPS and log first 16 bytes returned. iter20 (kernel printk) found rkvdec sees all-zero ctx->ctrl_hdl SPS for libva HEVC vs correct bytes for kdirect. The remaining branch is whether req->p_new was ever staged with libva's payload, or whether v4l2_ctrl_request_setup failed to apply it. α-24 distinguishes the two: zero readback -> staging failed in v4l2_s_ext_ctrls non-zero -> apply failed in v4l2_ctrl_request_setup EACCES -> kernel disallows req readback; need deeper printk Co-Authored-By: Claude Opus 4.7 (1M context) --- src/h265.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/h265.c b/src/h265.c index ba764ee..bde26f8 100644 --- a/src/h265.c +++ b/src/h265.c @@ -70,6 +70,7 @@ #include "surface.h" #include +#include #include #include @@ -79,6 +80,7 @@ #include #include +#include "utils.h" #include "v4l2.h" /* @@ -627,6 +629,42 @@ int h265_set_controls(struct request_data *driver_data, surface_object->request_fd, controls, n); + /* + * iter21 α-24 (diagnostic — gated by LIBVA_V4L2_REQ_GETBACK env): + * immediately after S_EXT_CTRLS staging, attempt G_EXT_CTRLS readback + * via the same request_fd for the SPS control. Outcome interpretation: + * EACCES -> kernel disallows req readback; switch to kernel printk path. + * non-zero SPS -> req->p_new HAS libva's payload; failure is in + * v4l2_ctrl_request_setup application path. + * zero SPS -> req->p_new doesn't have libva's payload; failure + * is in v4l2_s_ext_ctrls request-staging itself. + */ + if (rc >= 0 && getenv("LIBVA_V4L2_REQ_GETBACK") != NULL) { + struct v4l2_ctrl_hevc_sps sps_rb; + struct v4l2_ext_control ctrl_rb = { + .id = V4L2_CID_STATELESS_HEVC_SPS, + .ptr = &sps_rb, + .size = sizeof(sps_rb), + }; + int rb; + + memset(&sps_rb, 0, sizeof(sps_rb)); + rb = v4l2_get_controls(driver_data->video_fd, + surface_object->request_fd, + &ctrl_rb, 1); + if (rb < 0) { + request_log("α-24 G_EXT_CTRLS readback FAILED errno=%d (%s)\n", + errno, strerror(errno)); + } else { + uint8_t *p = (uint8_t *)&sps_rb; + request_log("α-24 G_EXT_CTRLS readback OK SPS[0..16]=" + "%02x %02x %02x %02x %02x %02x %02x %02x " + "%02x %02x %02x %02x %02x %02x %02x %02x\n", + p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], + p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); + } + } + free(slice_params_array); if (rc < 0)