iter21 α-24 (diag): G_EXT_CTRLS readback after S_EXT_CTRLS staging

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) <noreply@anthropic.com>
This commit is contained in:
2026-05-14 09:16:54 +00:00
parent 415688dab0
commit a9c897fa8b
+38
View File
@@ -70,6 +70,7 @@
#include "surface.h" #include "surface.h"
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -79,6 +80,7 @@
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <linux/v4l2-controls.h> #include <linux/v4l2-controls.h>
#include "utils.h"
#include "v4l2.h" #include "v4l2.h"
/* /*
@@ -627,6 +629,42 @@ int h265_set_controls(struct request_data *driver_data,
surface_object->request_fd, surface_object->request_fd,
controls, n); 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); free(slice_params_array);
if (rc < 0) if (rc < 0)