Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp793847imw; Fri, 8 Jul 2022 11:50:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u6JGPdWkY2dv6HbKg9n3whc/MMgqOkmFJU+6M9kx1rYZVnD6tqKxly1oB3sS3slytIA/te X-Received: by 2002:a17:907:a406:b0:726:34db:89ee with SMTP id sg6-20020a170907a40600b0072634db89eemr5121659ejc.540.1657306251683; Fri, 08 Jul 2022 11:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657306251; cv=none; d=google.com; s=arc-20160816; b=OB/zwJS3QqdLDg8TUTz1/oM+Ut8o3UPhX6CWZsS3uN4e5Qpz8pPJJ00v/02tF2q9CL mg7Ivh6J7pD5u4FFtGCr29QGX+b0PSOJwMgnwEnSoOl7VTuxf7FRU1rep23l/O2DdaX9 3cEz/vx9hAh0PK8XuKwHh83ZThyHXZ4YJ4LF3JqwhbV8YpScfGMIrz6w0cim6Kl93MBm 41Xg7429+94mtEfKJVdEoKLboSY0MV46yLqSk9naQ5TQF1m7pXD2nW0d4D/POz6ocXd6 l+rskq0454SAZaXjFHC9VOv2jXpZDA45wnOGhHuDoh97Fg5+VUmEcoFynp+W+01Q0Ei7 P6tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pFK9Eb2w8We60qTMCYcXdQOabH0AHkLr3hen0e7XdP0=; b=KAIbqd8mDmjgMJhWIAiIyeF2uNbZ13dbrwajKb6di1JustGP88iIvqLgKkGOLFcQ2z KACM4rXn8k4J2TiLqev5mba+pziK2mIYi7v4BitHXPiXj+oO/+tDm1MIso0sGey+rMx/ 4KuB2XPUeSyhYCEpLqQQW6q+vejnPKEwFqpfudWClXwEhJ84DXmT8gf6K05LCs+JowmH sDqfQzMT9I1Jyr6W8zr9FwEo0wPBrrOOdcRX2XE5f73+6sojT243Qbielpe/bhVhFEr4 yiSWz7wLQyFEiyCceAS3JlsPSDeuFzcjmtzIwnRFSDRSHiGujz0I0fMhwWrzclyB/idw uzNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di8-20020a170906730800b0072b211d9463si4284056ejc.166.2022.07.08.11.50.26; Fri, 08 Jul 2022 11:50:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239230AbiGHSWJ (ORCPT + 99 others); Fri, 8 Jul 2022 14:22:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239223AbiGHSVf (ORCPT ); Fri, 8 Jul 2022 14:21:35 -0400 Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78482D12C for ; Fri, 8 Jul 2022 11:21:32 -0700 (PDT) Received: from ramsan.of.borg ([84.195.186.194]) by baptiste.telenet-ops.be with bizsmtp id siMU270024C55Sk01iMUmx; Fri, 08 Jul 2022 20:21:30 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1o9sbX-002fJg-CX; Fri, 08 Jul 2022 20:21:27 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbW-00BtNW-MT; Fri, 08 Jul 2022 20:21:26 +0200 From: Geert Uytterhoeven To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , Gerd Hoffmann Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 1/3] drm/fourcc: Add missing big-endian XRGB1555 and RGB565 formats Date: Fri, 8 Jul 2022 20:21:07 +0200 Message-Id: <0744671ac096a12f0d538906bd324efa71b11400.1657300532.git.geert@linux-m68k.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As of commit eae06120f1974e1a ("drm: refuse ADDFB2 ioctl for broken bigendian drivers"), drivers must set the quirk_addfb_prefer_host_byte_order quirk to make the drm_mode_addfb() compat code work correctly on big-endian machines. While that works fine for big-endian XRGB8888 and ARGB8888, which are mapped to the existing little-endian BGRX8888 and BGRA8888 formats, it does not work for big-endian XRGB1555 and RGB565, as the latter are not listed in the format database. Fix this by adding the missing formats. Limit this to big-endian platforms, as there is currently no need to support these formats on little-endian platforms. Fixes: 6960e6da9cec3f66 ("drm: fix drm_mode_addfb() on big endian machines.") Signed-off-by: Geert Uytterhoeven --- Cirrus is the only driver setting quirk_addfb_prefer_host_byte_order and supporting RGB565 or XRGB1555, but no one tried that on big-endian? Cirrus does not support DRM_FORMAT_RGB565 | DRM_FORMAT_BIG_ENDIAN in cirrus_fb_create, so you cannot get a graphical text console. Do we need these definitions on little-endian platforms, too? Would it be better to use "DRM_FORMAT_{XRGB1555,RGB565} | DRM_FORMAT_BIG_ENDIAN" instead of "DRM_FORMAT_HOST_{XRGB1555,RGB565}" in formats[]? Alternative, callers could filter out the DRM_FORMAT_BIG_ENDIAN flag when calling {,__}drm_format_info(). Advantages: - No need to have separate entries with DRM_FORMAT_BIG_ENDIAN set. Disadvantages: - {,__}drm_format_info() returns a pointer to a const object, whose .format field won't have the DRM_FORMAT_BIG_ENDIAN flag set, complicating callers, - All callers need to be updated, - It is difficult to know which big-endian formats are really supported, especially as only a few are needed. --- drivers/gpu/drm/drm_fourcc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index e09331bb3bc73f21..16a854c9e07fa4b0 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -190,6 +190,10 @@ const struct drm_format_info *__drm_format_info(u32 format) { .format = DRM_FORMAT_BGRA5551, .depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true }, { .format = DRM_FORMAT_RGB565, .depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 }, { .format = DRM_FORMAT_BGR565, .depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 }, +#ifdef __BIG_ENDIAN + { .format = DRM_FORMAT_HOST_XRGB1555, .depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 }, + { .format = DRM_FORMAT_HOST_RGB565, .depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 }, +#endif { .format = DRM_FORMAT_RGB888, .depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 }, { .format = DRM_FORMAT_BGR888, .depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 }, { .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 }, -- 2.25.1