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)