From patchwork Thu Nov 16 13:16:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13457881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8928C54FB9 for ; Thu, 16 Nov 2023 13:17:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E540210E5D5; Thu, 16 Nov 2023 13:17:04 +0000 (UTC) Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by gabe.freedesktop.org (Postfix) with ESMTPS id A28DF10E5D5 for ; Thu, 16 Nov 2023 13:17:02 +0000 (UTC) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:1f07:ca72:c5f4:4244]) by albert.telenet-ops.be with bizsmtp id B1Gv2B00S4CbZ7h061Gvkt; Thu, 16 Nov 2023 14:17:01 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1r3cEe-009Qwb-9o; Thu, 16 Nov 2023 14:16:55 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1r3cEp-007jda-GC; Thu, 16 Nov 2023 14:16:55 +0100 From: Geert Uytterhoeven To: Christian Zigotzky , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Thomas Zimmermann , Laurent Vivier , Javier Martinez Canillas , Hamza Mahfooz , linux-m68k@lists.linux-m68k.org Subject: [PATCH v2] drm/virtio: Add suppport for non-native buffer formats Date: Thu, 16 Nov 2023 14:16:54 +0100 Message-Id: <47a81d2e0e47b1715718779b6978a8b595cc7c5d.1700140609.git.geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Geert Uytterhoeven , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When using virtgpu on a big-endian machine, e.g. powerpc QEMU: virtio-pci 0000:00:02.0: [drm] *ERROR* fbdev: Failed to setup generic emulation (ret=-2) or m68k/virt: virtio-mmio virtio-mmio.125: [drm] *ERROR* fbdev: Failed to setup generic emulation (ret=-2) and the graphical display fails to come up. Before, the call to drm_mode_addfb() caused a translation from a fourcc format (XR24) to a bpp/depth pair (32/24) to a potentially different fourcc format (BX24 on big-endian), due to the quirk processing in drm_driver_legacy_fb_format(). After, the original fourcc format (XR24) is passed unmodified. However, the virtgpu DRM driver supports only a single format for its main plane: DRM_FORMAT_HOST_XRGB8888, which is XR24 on little-endian, and BX24 on big-endian. I.e. on big-endian, virtgpu does not support XR24, which is the default DRM format, and must be supported by all drivers. Before, this was reported, but didn't lead to a failure: virtio-mmio virtio-mmio.125: [drm] bpp/depth value of 32/24 not supported virtio-mmio virtio-mmio.125: [drm] No compatible format found As the core virtgpu driver and device support both XR24 and BX24 on both little-endian and big-endian just fine, fix this extending the list of supported formats for main plane and cursor plane to XR24/BX24 resp. AR24/BA24. Fixes: 6ae2ff23aa43a0c4 ("drm/client: Convert drm_client_buffer_addfb() to drm_mode_addfb2()") Reported-by: Christian Zigotzky Closes: https://lore.kernel.org/r/c47fba21-3ae9-4021-9f4a-09c2670ebdbc@xenosoft.de Suggested-by: Gerd Hoffmann Signed-off-by: Geert Uytterhoeven Reviewed-by: Javier Martinez Canillas Reviewed-by: Gerd Hoffmann --- v2: - Fix truncated one-line summary. --- drivers/gpu/drm/virtio/virtgpu_display.c | 11 +++++++++-- drivers/gpu/drm/virtio/virtgpu_plane.c | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c index ad924a8502e9025c..49c89000aec33f23 100644 --- a/drivers/gpu/drm/virtio/virtgpu_display.c +++ b/drivers/gpu/drm/virtio/virtgpu_display.c @@ -301,9 +301,16 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev, struct virtio_gpu_framebuffer *virtio_gpu_fb; int ret; - if (mode_cmd->pixel_format != DRM_FORMAT_HOST_XRGB8888 && - mode_cmd->pixel_format != DRM_FORMAT_HOST_ARGB8888) + switch (mode_cmd->pixel_format) { + case DRM_FORMAT_XRGB8888: + case DRM_FORMAT_ARGB8888: + case DRM_FORMAT_BGRX8888: + case DRM_FORMAT_BGRA8888: + break; + + default: return ERR_PTR(-ENOENT); + } /* lookup object associated with res handle */ obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]); diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c index a2e045f3a0004a1b..a547d76b8fb0a77d 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -30,11 +30,13 @@ #include "virtgpu_drv.h" static const uint32_t virtio_gpu_formats[] = { - DRM_FORMAT_HOST_XRGB8888, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_BGRX8888, }; static const uint32_t virtio_gpu_cursor_formats[] = { - DRM_FORMAT_HOST_ARGB8888, + DRM_FORMAT_ARGB8888, + DRM_FORMAT_BGRA8888, }; uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)