PR #23632 opened by add-uos-ffmpeg
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23632
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23632.patch

The verbose log messages in the DRM device discovery loop currently print
the device index (e.g. "device 0") which is not directly useful for
debugging since users cannot map the index to the actual device path.
Change all log messages to print the full device path (e.g.
"/dev/dri/renderD128") via the already-available path variable,
consistent with the existing log at line 1780 that already uses %s/path.

Also rename the local drmDevicePtr variable from 'device' to 'drm_dev'
to avoid shadowing the outer function parameter 'const char *device'.

Signed-off-by: zhanghongyuan <[email protected]>

# Summary of changes

Print DRM device paths instead of numeric indices in VAAPI discovery logs and 
rename local variable to avoid shadowing function parameter.


- Before: 
` Trying to use DRM render node for device 0.`

- After:
 `Trying to use DRM render node for device /dev/dri/renderD128.`



From be89f3c1716e6cbe2acb0937f2880c397188e2c1 Mon Sep 17 00:00:00 2001
From: zhanghongyuan <[email protected]>
Date: Tue, 23 Jun 2026 21:37:31 +0800
Subject: [PATCH] avutil/hwcontext_vaapi: print DRM device path instead of
 index in log messages

The verbose log messages in the DRM device discovery loop currently print
the device index (e.g. "device 0") which is not directly useful for
debugging since users cannot map the index to the actual device path.
Change all log messages to print the full device path (e.g.
"/dev/dri/renderD128") via the already-available path variable,
consistent with the existing log at line 1780 that already uses %s/path.

Also rename the local drmDevicePtr variable from 'device' to 'drm_dev'
to avoid shadowing the outer function parameter 'const char *device'.

Signed-off-by: zhanghongyuan <[email protected]>
---
 libavutil/hwcontext_vaapi.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 98130f9fb1..e51303b89a 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1787,77 +1787,77 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, 
const char *device,
                                "for DRM render node.\n");
                     } else
                         av_log(ctx, AV_LOG_VERBOSE, "Cannot open "
-                               "DRM render node for device %d.\n", n);
+                               "DRM render node for device %s.\n", path);
                     break;
                 }
 #if CONFIG_LIBDRM
                 info = drmGetVersion(priv->drm_fd);
                 if (!info) {
                     av_log(ctx, AV_LOG_VERBOSE,
-                           "Failed to get DRM version for device %d.\n", n);
+                           "Failed to get DRM version for device %s.\n", path);
                     close(priv->drm_fd);
                     priv->drm_fd = -1;
                     continue;
                 }
                 if (kernel_driver) {
                     if (strcmp(kernel_driver->value, info->name)) {
-                        av_log(ctx, AV_LOG_VERBOSE, "Ignoring device %d "
+                        av_log(ctx, AV_LOG_VERBOSE, "Ignoring device %s "
                                "with non-matching kernel driver (%s).\n",
-                               n, info->name);
+                               path, info->name);
                         drmFreeVersion(info);
                         close(priv->drm_fd);
                         priv->drm_fd = -1;
                         continue;
                     }
                     av_log(ctx, AV_LOG_VERBOSE, "Trying to use "
-                           "DRM render node for device %d, "
+                           "DRM render node for device %s, "
                            "with matching kernel driver (%s).\n",
-                           n, info->name);
+                           path, info->name);
                     drmFreeVersion(info);
                     break;
                 // drmGetVersion() ensures |info->name| is 0-terminated.
                 } else if (!strcmp(info->name, "vgem")) {
                     av_log(ctx, AV_LOG_VERBOSE,
-                           "Skipping vgem node for device %d.\n", n);
+                           "Skipping vgem node for device %s.\n", path);
                     drmFreeVersion(info);
                     close(priv->drm_fd);
                     priv->drm_fd = -1;
                     continue;
                 } else if (vendor_id) {
-                    drmDevicePtr device;
+                    drmDevicePtr drm_dev;
                     char drm_vendor[8];
-                    if (drmGetDevice(priv->drm_fd, &device)) {
+                    if (drmGetDevice(priv->drm_fd, &drm_dev)) {
                         av_log(ctx, AV_LOG_VERBOSE,
-                               "Failed to get DRM device info for device 
%d.\n", n);
+                               "Failed to get DRM device info for device 
%s.\n", path);
                         close(priv->drm_fd);
                         priv->drm_fd = -1;
                         drmFreeVersion(info);
                         continue;
                     }
 
-                    snprintf(drm_vendor, sizeof(drm_vendor), "0x%x", 
device->deviceinfo.pci->vendor_id);
+                    snprintf(drm_vendor, sizeof(drm_vendor), "0x%x", 
drm_dev->deviceinfo.pci->vendor_id);
                     if (strcmp(vendor_id->value, drm_vendor)) {
-                        av_log(ctx, AV_LOG_VERBOSE, "Ignoring device %d "
+                        av_log(ctx, AV_LOG_VERBOSE, "Ignoring device %s "
                                "with non-matching vendor id (%s).\n",
-                               n, vendor_id->value);
-                        drmFreeDevice(&device);
+                               path, vendor_id->value);
+                        drmFreeDevice(&drm_dev);
                         close(priv->drm_fd);
                         priv->drm_fd = -1;
                         drmFreeVersion(info);
                         continue;
                     }
                     av_log(ctx, AV_LOG_VERBOSE, "Trying to use "
-                           "DRM render node for device %d, "
+                           "DRM render node for device %s, "
                            "with matching vendor id (%s).\n",
-                           n, vendor_id->value);
-                    drmFreeDevice(&device);
+                           path, vendor_id->value);
+                    drmFreeDevice(&drm_dev);
                     drmFreeVersion(info);
                     break;
                 }
                 drmFreeVersion(info);
 #endif
                 av_log(ctx, AV_LOG_VERBOSE, "Trying to use "
-                       "DRM render node for device %d.\n", n);
+                       "DRM render node for device %s.\n", path);
                 break;
             }
             if (n >= max_devices)
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to