Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp952850pxp; Wed, 16 Mar 2022 22:28:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLSYTFJfHqwxXVYPOl5mw7wfB0OWMMpQjesZFuqBhZsyMxTi7HO/jnR5BBtnMhFWWw/rh2 X-Received: by 2002:a05:6a00:a8f:b0:4e1:2619:11a2 with SMTP id b15-20020a056a000a8f00b004e1261911a2mr2708260pfl.53.1647494890337; Wed, 16 Mar 2022 22:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647494890; cv=none; d=google.com; s=arc-20160816; b=svlkrZFXCgtsYCZ6RpW+BERQ0sPPGxFd6pSBxrOI89HBH/skjzyYVYJ0DuXWJQ1vGq o4I4oq97cKzjQ8+5NHn/Lj+t9jrCsJQlU/ZxAkryQCf1p3nn7yZjMbp4L0Rftl2WIOj+ FjjTuvS7dFFi6Ej6LwenCC3xemalJsgNekOv1PRpnm+Fgu5peU0s1tbiOgZ9Dmqf0qMW +g7oLxEekHRcOxtN+UbR43H0Z4GU7D2OPVgP7/qn1+s36idKdNJFP58GiwKqADK9Bc0F JJKky3k+KQ2uVUJHDRwWOcEOzHsRT6lTrqw+p+Y6KXDV+lf0EX1cJ6jIVI3Ei9Nfgx50 S95Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=wUvXJkVzRf7uiYTXXhHFwsbeVUmmFqsvpsimZzyPA9g=; b=FN8S20QwJIO6+8sqA/Y6gAuPnx6TFMsjrv6aWeh5hbNRFQR5/LuXpWEoayS2FnoQ9K lJtUYPi9UXrs3zA3mV6GXKQcd7Gy5k5OfFlVhvJNvW+LmRtTyGAuwSvlMRNyAumuCddT a9T6mobHMyngERcHzYBi/6emTv+6Hy6zllEFpRPaF4QocRW9BP9UL324ZtKgdOEfks1P PTweFKZbMjUX63kP/61obQBRnQ0XrNQhPR3uEy+6wJuStOaqW0V19ZPISvmh/h8gieoA GfXtYXmRBabqVWi9PHjugv2VP3sroq6Lm3cS8i6ckqegLzIBMhNb1vatjepYvD5AtNRR 2C/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SSigJxLD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y10-20020a056a00190a00b004f78813b2dcsi3993518pfi.124.2022.03.16.22.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:28:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SSigJxLD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 482B9F8B8F; Wed, 16 Mar 2022 21:29:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345471AbiCOHe3 (ORCPT + 99 others); Tue, 15 Mar 2022 03:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345499AbiCOHeZ (ORCPT ); Tue, 15 Mar 2022 03:34:25 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE584E68; Tue, 15 Mar 2022 00:33:03 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id w7so31418480lfd.6; Tue, 15 Mar 2022 00:33:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version; bh=wUvXJkVzRf7uiYTXXhHFwsbeVUmmFqsvpsimZzyPA9g=; b=SSigJxLDv4rhWnbg41qyLZn9tsjJ/AVEbALDktvR/rDDWAv1vtsr5no7rWcdaZczyt /FSc9PerajzZxVHIOJRKvmpoNYXz/hlRAbpJ4mCgoxreXVIDXnXbWpUAk4KEtwLndtYA zPAk4N9TU9j1/0PvD/yS4hYXNNkVRNb9upL4lXoK08gcXpC1ItfSenBaQKbzemhGJSbI gtNlnUsR0ydB3q9bVCG2ADyjj6Fb2BZaF2pdERzclY6BFyu+KOo97rWBnCya98j3d4w7 fe1P3Hf25I8J6lviGRukOVtv8sTxza4w3N7QoFggflEitnjVbOu3YUNmFxZhvp7LwJWm V9aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version; bh=wUvXJkVzRf7uiYTXXhHFwsbeVUmmFqsvpsimZzyPA9g=; b=Pr1t1h2pG1KnOdXCKObchhiAnSExQOIRGYGQctuUAjgIlp56QenmCPTv909V6l1WYe uA8AV0ZR+SE/wKnRsVDe7/bA7/R5uzBP2K81gpTYXeuIHWUebsZcTNtLArLtIw+VnNwc 4BBwJoGt2AKhHiDjccXxkHiBgra+hCMsvcExfsPqqbfeohRRLTEYZCDj2OOKlIQVO3Hw uwaVNKhr0eeBSus6uwaykV3NH36LtgyvtUbpoX+Co6bfL8Kw+nzcRPlHNrWvUxbWzmRU NA8c2fquLxWclttOzf621ud0HTuPucWFWKMHWIhX5bDzRjYOfb7mKS8Hcqy3Zwroo06c ke+Q== X-Gm-Message-State: AOAM531dfUwc0TBf9Ls6jujINQiNqGF9mhlfIor4VbnJPr9CGH/JCdM9 4F4JWGzCN9uwdVekkZmPoao= X-Received: by 2002:a05:6512:b25:b0:448:98bb:efae with SMTP id w37-20020a0565120b2500b0044898bbefaemr4262623lfu.151.1647329581185; Tue, 15 Mar 2022 00:33:01 -0700 (PDT) Received: from eldfell ([194.136.85.206]) by smtp.gmail.com with ESMTPSA id o4-20020a2eb444000000b00247f29888fcsm4281640ljm.124.2022.03.15.00.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 00:33:00 -0700 (PDT) Date: Tue, 15 Mar 2022 09:32:50 +0200 From: Pekka Paalanen To: Finn Thain Cc: Geert Uytterhoeven , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Javier Martinez Canillas , Sam Ravnborg , Helge Deller , Linux Fbdev development list , Linux/m68k , DRI Development , Linux Kernel Mailing List Subject: Re: [PATCH v2 05/10] drm/fourcc: Add DRM_FORMAT_C[124] Message-ID: <20220315093250.71352a56@eldfell> In-Reply-To: <1f915fcc-1d95-99d1-c7b7-dc4e3b49e09f@linux-m68k.org> References: <8d3c0cc370b0214244b01a64c588e5e506531716.1646683502.git.geert@linux-m68k.org> <20220314170539.17400f93@eldfell> <1f915fcc-1d95-99d1-c7b7-dc4e3b49e09f@linux-m68k.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/98Z3rW3o3S.LMmex9/1NFgW"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 --Sig_/98Z3rW3o3S.LMmex9/1NFgW Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Tue, 15 Mar 2022 09:15:08 +1100 (AEDT) Finn Thain wrote: > Hi Geert, >=20 > On Mon, 14 Mar 2022, Geert Uytterhoeven wrote: >=20 > > On Mon, Mar 14, 2022 at 4:05 PM Pekka Paalanen wr= ote: =20 > > > On Mon, 14 Mar 2022 14:30:18 +0100 > > > Geert Uytterhoeven wrote: =20 > > > > On Mon, Mar 7, 2022 at 9:53 PM Geert Uytterhoeven wrote: =20 > > > > > Introduce fourcc codes for color-indexed frame buffer formats wit= h=20 > > > > > two, four, and sixteen colors, and provide a mapping from bit per= =20 > > > > > pixel and depth to fourcc codes. > > > > > > > > > > As the number of bits per pixel is less than eight, these rely on= =20 > > > > > proper block handling for the calculation of bits per pixel and=20 > > > > > pitch. > > > > > > > > > > Signed-off-by: Geert Uytterhoeven =20 > > > > =20 > > > > > --- a/include/uapi/drm/drm_fourcc.h > > > > > +++ b/include/uapi/drm/drm_fourcc.h > > > > > @@ -99,7 +99,10 @@ extern "C" { > > > > > #define DRM_FORMAT_INVALID 0 > > > > > > > > > > /* color index */ > > > > > -#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /= * [7:0] C */ > > > > > +#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') /= * [7:0] C0:C1:C2:C3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte */ > > > > > +#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /= * [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte */ > > > > > +#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /= * [7:0] C0:C1 4:4 two pixels/byte */ > > > > > +#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /= * [7:0] C 8 one pixel/byte */ > > > > > > > > > > /* 8 bpp Red */ > > > > > #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /= * [7:0] R */ =20 > > > > > > > > After replying to Ilia's comment[1], I realized the CFB drawing > > > > operations use native byte and bit ordering, unless > > > > FBINFO_FOREIGN_ENDIAN is set. > > > > While Amiga, Atari, and Sun-3 use big-endian bit ordering, > > > > e.g. Acorn VIDC[2] uses little endian, and SH7760[3] is configurable > > > > (sh7760fb configures ordering to match host order). > > > > BTW, ssd130{7fb,x}_update_rect() both assume little-endian, so I > > > > guess they are broken on big-endian. > > > > Fbtest uses big-endian bit ordering, so < 8 bpp is probably broken > > > > on little-endian. > > > > > > > > Hence the above should become: > > > > > > > > #define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') = /* > > > > [7:0] C7:C6:C5:C4:C3:C2:C1:C0 1:1:1:1:1:1:1:1 eight pixels/byte */ > > > > #define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') = /* > > > > [7:0] C3:C2:C1:C0 2:2:2:2 four pixels/byte */ > > > > #define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') = /* > > > > [7:0] C1:C0 4:4 two pixels/byte */ > > > > > > > > The same changes should be made for DRM_FORMAT_[RD][124]. > > > > > > > > The fbdev emulation code should gain support for these with and wit= hout > > > > DRM_FORMAT_BIG_ENDIAN, the latter perhaps only on big-endian platfo= rms? > > > > > > > > [1] https://lore.kernel.org/r/CAKb7UvgEdm9U=3D+RyRwL0TGRfA_Qc7NbhCW= oZOft2DKdXggtKYw@mail.gmail.com/ > > > > [2] See p.30 of the VIDC datasheet > > > > http://chrisacorns.computinghistory.org.uk/docs/Acorn/Misc/Acor= n_VIDC_Datasheet.pdf > > > > [3] See p.1178 of the SH7660 datasheet > > > > https://datasheet.octopart.com/HD6417760BL200AV-Renesas-datashe= et-14105759.pdf =20 > > > > > > why would CPU endianess affect the order of bits in a byte? =20 > >=20 > > It doesn't, but see below. > > =20 > > > Do you mean that bit 0 one machine is (1 << 0), and on another machine > > > bit 0 is (1 << 7)? =20 > >=20 > > No, I mean that in case of multiple pixels per byte, the display > > hardware pumps out pixels to the CRTC starting from either the MSB > > or the LSB of the first display byte. Which order depends on the > > display hardware, not on the CPU. > > =20 > > > In C, we have only one way to address bits of a byte and that is with > > > arithmetic. You cannot take the address of a bit any other way, can y= ou? > > > > > > Can we standardise on "bit n of a byte is addressed as (1 << n)"? =20 > >=20 > > BIT(n) in Linux works the same for little- and big-endian CPUs. > > But display hardware may use a different bit order. > > =20 >=20 > Perhaps some of this confusion could be avoided if you describe the=20 > problem in terms of the sequence of scan-out of pixels, rather than in=20 > terms of the serialization of bits. The significance of bits within each= =20 > pixel and the ordering of pixels within each memory word are independent,= =20 > right? Yes, that might help. Also, when drm_fourcc.h is describing pixel formats, it needs to consider only how a little-endian CPU accesses them. That's how pixel data in memory is described. Display hardware plays no part in that. It is the driver's job to expose the pixel formats that match display hardware behaviour. Thanks, pq --Sig_/98Z3rW3o3S.LMmex9/1NFgW Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEJQjwWQChkWOYOIONI1/ltBGqqqcFAmIwQSIACgkQI1/ltBGq qqdWYxAArFJHkgpQMmmEJF2XjJ7YkFz1RwOBneGVxoSiwu34NGvFYNI9RQrxIRMZ 6Veq3hEcMsi3IpHXBDklk6UeL/AuVkVK6mngFDczy4amGO4fonk3x6OsnJn2Hb3D bW/We2Ua68RsJu7FGVjO4XW07h5gNKUsdDlK6Mp2ENoo5K3eabxaD9ZkOoPmeerh JQ28LWf+xtk54sOR8uukwnJvogoEzo/0h1+9birqPnKBJlEW22CYzJrRSiaEhLfn PE0ql688tq/KgH0Rhi769hauO/fmrj6oRAqQbwljfZvtKWx9L53T6OW7MvpK6AXw FYsvXksK3IpOrhxm7ahZsW9Iis7GwNeU/NmKLb47SnKKIluMQTBFFkcvMX1mSjRC nCq82HG1e0E/yOQZYs+Ug7JRIKveCgJFEhnHIGgSIdQANA+hCLMPZvXgtpinZAlD t1hDpSfTTO8biGhvB2EhHPDZnqdJ1SmoAvQXb7vJYIgBK/CpKDAAWUAzel7T+mZt BGJnQQN8eN8B+iKrgWYiQbCGaNODiL1PLXTt7LbqKB/pCXHlLRYpJY3ig1Ks/Xx7 JDx1vdAFXGeSBaerSL/gNx1Ltl2W6/4I8y1BkKMOUCLkhPUBCw8/bXrvFqNkyYKR MuOOHqniK8XN77rE4x92pYoVTaR0vAKNPuLcJx7GyhY0JCYrlQ4= =Lr2I -----END PGP SIGNATURE----- --Sig_/98Z3rW3o3S.LMmex9/1NFgW--