diff mbox series

[FFmpeg-devel] hwcontext_vaapi: Don't require a render node when deriving from DRM

Message ID a1d1feff-6a67-b56b-21c9-cb55cedd7d55@jkqxz.net
State Accepted
Headers show
Series [FFmpeg-devel] hwcontext_vaapi: Don't require a render node when deriving from DRM | expand

Checks

Context Check Description
andriy/default pending
andriy/configure warning Failed to apply patch

Commit Message

Mark Thompson Aug. 28, 2020, 10:15 p.m. UTC
The V4L2 driver does not actually have an associated DRM device at all, so
users work around the requirement by giving libva an unrelated display-only
device instead (which is fine, because it doesn't actually do anything with
that device).  This was broken by bc9b6358fb7315c0173de322472641766f6289da
forcing a render node, because the display-only device did not have an
associated render node to use.  Fix that by just passing through the
original non-render DRM fd if we can't find a render node.

Reported-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
Also tested by the reporter.  I'll apply this in a few days if there are no comments.

- Mark


  libavutil/hwcontext_vaapi.c | 28 ++++++++++++++++------------
  1 file changed, 16 insertions(+), 12 deletions(-)

Comments

Mark Thompson Aug. 31, 2020, 8:48 p.m. UTC | #1
On 28/08/2020 23:15, Mark Thompson wrote:
> The V4L2 driver does not actually have an associated DRM device at all, so
> users work around the requirement by giving libva an unrelated display-only
> device instead (which is fine, because it doesn't actually do anything with
> that device).  This was broken by bc9b6358fb7315c0173de322472641766f6289da
> forcing a render node, because the display-only device did not have an
> associated render node to use.  Fix that by just passing through the
> original non-render DRM fd if we can't find a render node.
> 
> Reported-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
> Also tested by the reporter.  I'll apply this in a few days if there are no comments.

Applied.

Thanks,

- Mark
diff mbox series

Patch

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 38bdeb7820..2227d6ed69 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1677,20 +1677,24 @@  static int vaapi_device_derive(AVHWDeviceContext *ctx,
              } else {
                  render_node = drmGetRenderDeviceNameFromFd(src_hwctx->fd);
                  if (!render_node) {
-                    av_log(ctx, AV_LOG_ERROR, "Failed to find a render node "
-                           "matching the DRM device.\n");
-                    return AVERROR(ENODEV);
-                }
-                fd = open(render_node, O_RDWR);
-                if (fd < 0) {
-                    av_log(ctx, AV_LOG_ERROR, "Failed to open render node %s"
-                           "matching the DRM device.\n", render_node);
+                    av_log(ctx, AV_LOG_VERBOSE, "Using non-render node "
+                           "because the device does not have an "
+                           "associated render node.\n");
+                    fd = src_hwctx->fd;
+                } else {
+                    fd = open(render_node, O_RDWR);
+                    if (fd < 0) {
+                        av_log(ctx, AV_LOG_VERBOSE, "Using non-render node "
+                               "because the associated render node "
+                               "could not be opened.\n");
+                        fd = src_hwctx->fd;
+                    } else {
+                        av_log(ctx, AV_LOG_VERBOSE, "Using render node %s "
+                               "in place of non-render DRM device.\n",
+                               render_node);
+                    }
                      free(render_node);
-                    return AVERROR(errno);
                  }
-                av_log(ctx, AV_LOG_VERBOSE, "Using render node %s in place "
-                       "of non-render DRM device.\n", render_node);
-                free(render_node);
              }
          }
  #else