[FFmpeg-devel] [PATCH v06 1/5] KMSGrab: getfb2 format_modifier if user doesnt specify

C Hanish Menon hanishkvc at gmail.com
Sun Jul 5 23:21:14 EEST 2020


Hi

Don't apply this patch, I will try and use ioctl directly instead of using
xf86's GetFB2.

Based on the reported compile issue with initialising global const for the
fbtile patch when using older versions of gcc, I was checking the same
using Ubuntu 16.04 setup, and realised that the older xf86drmMode.h in it
doesn't provide GetFB2.


On Sun, 5 Jul, 2020, 00:51 Lynne, <dev at lynne.ee> wrote:

> Jul 4, 2020, 14:17 by hanishkvc at gmail.com:
>
> > If user doesnt specify a format_modifier explicitly, then use GetFB2
> > to identify the format_modifier of the framebuffer being grabbed.
> > ---
> >  Changelog             |  1 +
> >  libavdevice/kmsgrab.c | 22 +++++++++++++++++++++-
> >  2 files changed, 22 insertions(+), 1 deletion(-)
> >
> > diff --git a/Changelog b/Changelog
> > index a60e7d2eb8..3881587caa 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to
> youngest within each release,
> >  releases are sorted from youngest to oldest.
> >
> >  version <next>:
> > +- kmsgrab GetFB2 format_modifier, if user doesnt specify
> >  - AudioToolbox output device
> >  - MacCaption demuxer
> >
> > diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
> > index d0de774871..10ed707e60 100644
> > --- a/libavdevice/kmsgrab.c
> > +++ b/libavdevice/kmsgrab.c
> > @@ -239,6 +239,7 @@ static av_cold int
> kmsgrab_read_header(AVFormatContext *avctx)
> >  drmModePlaneRes *plane_res = NULL;
> >  drmModePlane *plane = NULL;
> >  drmModeFB *fb = NULL;
> > +    drmModeFB2 *fb2 = NULL;
> >  AVStream *stream;
> >  int err, i;
> >
> > @@ -364,6 +365,23 @@ static av_cold int
> kmsgrab_read_header(AVFormatContext *avctx)
> >  goto fail;
> >  }
> >
> > +    fb2 = drmModeGetFB2(ctx->hwctx->fd, plane->fb_id);
> > +    if (!fb2) {
> > +        err = errno;
> > +        av_log(avctx, AV_LOG_ERROR, "Failed to get "
> > +               "framebuffer2 %"PRIu32": %s.\n",
> > +               plane->fb_id, strerror(err));
> > +        err = AVERROR(err);
> > +        goto fail;
> > +    }
> > +
> > +    av_log(avctx, AV_LOG_INFO, "Template framebuffer2 is %"PRIu32": "
> > +           "%"PRIu32"x%"PRIu32", pixel_format: 0x%"PRIx32",
> format_modifier: 0x%"PRIx64".\n",
> > +           fb2->fb_id, fb2->width, fb2->height, fb2->pixel_format,
> fb2->modifier);
> > +
> > +    if (ctx->drm_format_modifier == DRM_FORMAT_MOD_INVALID)
> > +        ctx->drm_format_modifier  = fb2->modifier;
> > +
> >  stream = avformat_new_stream(avctx, NULL);
> >  if (!stream) {
> >  err = AVERROR(ENOMEM);
> > @@ -408,6 +426,8 @@ fail:
> >  drmModeFreePlane(plane);
> >  if (fb)
> >  drmModeFreeFB(fb);
> > +    if (fb2)
> > +        drmModeFreeFB2(fb2);
> >
> >  return err;
> >  }
> > @@ -433,7 +453,7 @@ static const AVOption options[] = {
> >  { .i64 = AV_PIX_FMT_BGR0 }, 0, UINT32_MAX, FLAGS },
> >  { "format_modifier", "DRM format modifier for framebuffer",
> >  OFFSET(drm_format_modifier), AV_OPT_TYPE_INT64,
> > -      { .i64 = DRM_FORMAT_MOD_NONE }, 0, INT64_MAX, FLAGS },
> > +      { .i64 = DRM_FORMAT_MOD_INVALID}, 0, INT64_MAX, FLAGS },
> >  { "crtc_id", "CRTC ID to define capture source",
> >  OFFSET(source_crtc), AV_OPT_TYPE_INT64,
> >  { .i64 = 0 }, 0, UINT32_MAX, FLAGS },
> > --
> > 2.25.1
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request at ffmpeg.org>  with subject "unsubscribe".
> >
>
> This one looks fine to me, but Mark Thompson should check this one too.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list