mirror of https://git.ffmpeg.org/ffmpeg.git
kmsgrab: Use invalid modifier if modifiers weren't used.
The kernel defaults to initializing the field to 0 when modifiers are not used and this happens to be linear. If we end up actually passing the modifier to a driver, tiling issues happen. So if the kernel doesn't return a modifier set it explicitly to INVALID. That way later processing knows there is no explicit modifier. Signed-off-by: Mark Thompson <sw@jkqxz.net>
This commit is contained in:
parent
06a8596825
commit
03f4b203ba
|
@ -160,6 +160,7 @@ static int kmsgrab_get_fb2(AVFormatContext *avctx,
|
||||||
KMSGrabContext *ctx = avctx->priv_data;
|
KMSGrabContext *ctx = avctx->priv_data;
|
||||||
drmModeFB2 *fb;
|
drmModeFB2 *fb;
|
||||||
int err, i, nb_objects;
|
int err, i, nb_objects;
|
||||||
|
uint64_t modifier = ctx->drm_format_modifier;
|
||||||
|
|
||||||
fb = drmModeGetFB2(ctx->hwctx->fd, plane->fb_id);
|
fb = drmModeGetFB2(ctx->hwctx->fd, plane->fb_id);
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
|
@ -195,6 +196,9 @@ static int kmsgrab_get_fb2(AVFormatContext *avctx,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fb->flags & DRM_MODE_FB_MODIFIERS)
|
||||||
|
modifier = fb->modifier;
|
||||||
|
|
||||||
*desc = (AVDRMFrameDescriptor) {
|
*desc = (AVDRMFrameDescriptor) {
|
||||||
.nb_layers = 1,
|
.nb_layers = 1,
|
||||||
.layers[0] = {
|
.layers[0] = {
|
||||||
|
@ -243,7 +247,7 @@ static int kmsgrab_get_fb2(AVFormatContext *avctx,
|
||||||
desc->objects[obj] = (AVDRMObjectDescriptor) {
|
desc->objects[obj] = (AVDRMObjectDescriptor) {
|
||||||
.fd = fd,
|
.fd = fd,
|
||||||
.size = size,
|
.size = size,
|
||||||
.format_modifier = fb->modifier,
|
.format_modifier = modifier,
|
||||||
};
|
};
|
||||||
desc->layers[0].planes[i] = (AVDRMPlaneDescriptor) {
|
desc->layers[0].planes[i] = (AVDRMPlaneDescriptor) {
|
||||||
.object_index = obj,
|
.object_index = obj,
|
||||||
|
@ -557,6 +561,8 @@ static av_cold int kmsgrab_read_header(AVFormatContext *avctx)
|
||||||
err = AVERROR(EINVAL);
|
err = AVERROR(EINVAL);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fb2->flags & DRM_MODE_FB_MODIFIERS) {
|
||||||
if (ctx->drm_format_modifier != DRM_FORMAT_MOD_INVALID &&
|
if (ctx->drm_format_modifier != DRM_FORMAT_MOD_INVALID &&
|
||||||
ctx->drm_format_modifier != fb2->modifier) {
|
ctx->drm_format_modifier != fb2->modifier) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Framebuffer format modifier "
|
av_log(avctx, AV_LOG_ERROR, "Framebuffer format modifier "
|
||||||
|
@ -567,6 +573,7 @@ static av_cold int kmsgrab_read_header(AVFormatContext *avctx)
|
||||||
} else {
|
} else {
|
||||||
ctx->drm_format_modifier = fb2->modifier;
|
ctx->drm_format_modifier = fb2->modifier;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
av_log(avctx, AV_LOG_VERBOSE, "Format is %s, from "
|
av_log(avctx, AV_LOG_VERBOSE, "Format is %s, from "
|
||||||
"DRM format %"PRIx32" modifier %"PRIx64".\n",
|
"DRM format %"PRIx32" modifier %"PRIx64".\n",
|
||||||
av_get_pix_fmt_name(ctx->format),
|
av_get_pix_fmt_name(ctx->format),
|
||||||
|
|
Loading…
Reference in New Issue