Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp557041pxp; Wed, 16 Mar 2022 11:10:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT5JtQQBbmGAeBP7PzrtJ0kP+5+d8wMu298QQRVtmXB8T8uy4IYBggjIL/8RQfDC9ihpEw X-Received: by 2002:a17:906:b287:b0:6ce:98af:3f6e with SMTP id q7-20020a170906b28700b006ce98af3f6emr1010081ejz.216.1647454240546; Wed, 16 Mar 2022 11:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647454240; cv=none; d=google.com; s=arc-20160816; b=IbJZeDDojOYGHpM5Xe4uQ+NbZGan4H+9R2kxPQAblpBDCP97c8cox0S5Slz+gVMRCO S285eWfvX1dW2VH1q/hcrk/uLRJFMaXccB4nuWgCgg7HkIeKYbtoUUm5zS4Fzi0tvOdt cVkSEbWvq3KE7yCS2uGGjISXq+yjoat+hT2qIUf14z5fE6Kx6HqVensJQ5TtEvoUCr9P oN0zA3GDqlTHf6dI+KPGNBIWSdNzckwmtsJmyfB/dYzLlhnjuN+FJ0zCmBatuQEdInb5 20SELtiUSHVF14ek/v9dZSi9wgszWSU82jSO4oxn6iEis7Rw3POpxIrBWRQFqZNc6jkh 4tHA== 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=haMOXrxpicM2XmywP7XAKAqLFk8f/h56BBMGPfa8QHM=; b=bOmk9oK6VjkXO9c2l5xEvhcrKqNX76TtZpht90fsiUDXx1nD4ptJNOWSUPcwso0hYt R1pSWJaX2Rl0oazeQycKndFVXNf6EFlsBWc7o6B/BwE7rNr057Tf8JxpAOAm/le3fvpC tyrAB1GHNjTl9oppoA546F/AEuFSvB0bAe5CMazrDKKaLSDDOZc+gfzl27zc93VuIrr4 8u9FVAWhH8OOUZvXxT3bW+dsY0M324LlRJAKbIPJx6dzkqnJVjEiZSfjtJUrC3bG9YC9 NNcLpW5RvIoJEfnssj5jkEM/tqbcwdhfRjwpCU9oMsrWORQNT3qrxeuMKlVkRWpWRuvx l7wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GfQ0osm3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m18-20020a1709060d9200b006df87911364si629708eji.772.2022.03.16.11.10.11; Wed, 16 Mar 2022 11:10:40 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GfQ0osm3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346138AbiCOIrO (ORCPT + 99 others); Tue, 15 Mar 2022 04:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244784AbiCOIrM (ORCPT ); Tue, 15 Mar 2022 04:47:12 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2F284CD7D; Tue, 15 Mar 2022 01:45:59 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id s25so25461832lji.5; Tue, 15 Mar 2022 01:45:59 -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=haMOXrxpicM2XmywP7XAKAqLFk8f/h56BBMGPfa8QHM=; b=GfQ0osm33Fhk/Cx3Bo54rjfxBi31DXQiWfVJXfemEVmWXIy+OGuL6itb0hLogRlMAY LHmJVtlhBAMlfo4br4H4sBBFJuBTLDIkoBuOKQBqxVcIgYHd1q9dsfykFt4tGFfkguoU V1vrfvRZpaYxe8GziNzunKXilP8e6LzsyQ+lPtVkl9LPf5kT2AJlU1u78rU+6Dc8uqzl b52G9KIPxqabpZlmJOivlPfZXNiTd5LusUMXeTyonP3ngwQfQAyeKxkuhd8dNzaAkgpU 6BJAfCPoJobLbpBzsMDKrebQUvY7PqayHG/ImnCDP2WX0vQIAo2KMYlbv2aMPkmuuXFk HIKw== 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=haMOXrxpicM2XmywP7XAKAqLFk8f/h56BBMGPfa8QHM=; b=TaPAAix0VXkurE4+P5fKax+4/2Hv+JO6OoTR1Mr/yVmdoMTan0LLCcTgxnQjaad4+3 vyKg3mJXLqEoG3aYITvsaQTjSbBLVjDXSHRvz2HMqaj/cmy1Qj99o6dq5elcr8Sgqc8f vjUyEQ9etFV/SdkMXIZ3M6pGn11mZ5fWE7BXzAlFq1FOQzdILaWfmXuopxJov/2nAo2V i+VFRAJHbJ4ob+r8gPwxV1otx5QFWhWSKpj7+3gcfzu/e5MPr5xMLrQ+aKOAw/22KU6G cUttraRcIXXdCpizYQReeBSuUDR8LuKkGShHgWWT2BcvI4qN/FREfCwH5kkzDre4WoEa 8luw== X-Gm-Message-State: AOAM532ZaUdaGBY9ciYV7eaJuDeT8ybIphTi82d036/pHJAiajyhLf8K pHAXD3ULWGVxYgF0DCkTRyQ= X-Received: by 2002:a2e:8403:0:b0:248:31d:3e35 with SMTP id z3-20020a2e8403000000b00248031d3e35mr16107402ljg.445.1647333958051; Tue, 15 Mar 2022 01:45:58 -0700 (PDT) Received: from eldfell ([194.136.85.206]) by smtp.gmail.com with ESMTPSA id d26-20020a056512321a00b0044867936e9csm2898972lfe.18.2022.03.15.01.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 01:45:57 -0700 (PDT) Date: Tue, 15 Mar 2022 10:45:54 +0200 From: Pekka Paalanen To: Geert Uytterhoeven Cc: Finn Thain , 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: <20220315104554.1961d62d@eldfell> In-Reply-To: References: <8d3c0cc370b0214244b01a64c588e5e506531716.1646683502.git.geert@linux-m68k.org> <20220314170539.17400f93@eldfell> <1f915fcc-1d95-99d1-c7b7-dc4e3b49e09f@linux-m68k.org> <20220315093250.71352a56@eldfell> 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_/vI_Pac=RFEkBtKEOIWIsjeU"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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_/vI_Pac=RFEkBtKEOIWIsjeU Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Tue, 15 Mar 2022 08:51:31 +0100 Geert Uytterhoeven wrote: > Hi Pekka, >=20 > On Tue, Mar 15, 2022 at 8:33 AM Pekka Paalanen wrot= e: > > On Tue, 15 Mar 2022 09:15:08 +1100 (AEDT) > > Finn Thain wrote: =20 > > > On Mon, 14 Mar 2022, Geert Uytterhoeven wrote: =20 > > > > On Mon, Mar 14, 2022 at 4:05 PM Pekka Paalanen wrote: =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= with > > > > > > > two, four, and sixteen colors, and provide a mapping from bit= per > > > > > > > pixel and depth to fourcc codes. > > > > > > > > > > > > > > As the number of bits per pixel is less than eight, these rel= y on > > > > > > > proper block handling for the calculation of bits per pixel a= nd > > > > > > > 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 configu= rable > > > > > > (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 bro= ken > > > > > > 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= without > > > > > > DRM_FORMAT_BIG_ENDIAN, the latter perhaps only on big-endian pl= atforms? > > > > > > > > > > > > [1] https://lore.kernel.org/r/CAKb7UvgEdm9U=3D+RyRwL0TGRfA_Qc7N= bhCWoZOft2DKdXggtKYw@mail.gmail.com/ > > > > > > [2] See p.30 of the VIDC datasheet > > > > > > http://chrisacorns.computinghistory.org.uk/docs/Acorn/Misc/= Acorn_VIDC_Datasheet.pdf > > > > > > [3] See p.1178 of the SH7660 datasheet > > > > > > https://datasheet.octopart.com/HD6417760BL200AV-Renesas-dat= asheet-14105759.pdf =20 > > > > > > > > > > why would CPU endianess affect the order of bits in a byte? =20 > > > > > > > > It doesn't, but see below. > > > > =20 > > > > > Do you mean that bit 0 one machine is (1 << 0), and on another ma= chine > > > > > bit 0 is (1 << 7)? =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, c= an you? > > > > > > > > > > Can we standardise on "bit n of a byte is addressed as (1 << n)"?= =20 > > > > > > > > BIT(n) in Linux works the same for little- and big-endian CPUs. > > > > But display hardware may use a different bit order. =20 > > > > > > Perhaps some of this confusion could be avoided if you describe the > > > problem in terms of the sequence of scan-out of pixels, rather than in > > > terms of the serialization of bits. The significance of bits within e= ach > > > pixel and the ordering of pixels within each memory word are independ= ent, > > > right? =20 > > > > Yes, that might help. =20 >=20 > Display: >=20 > P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 >=20 > P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 Hi Geert, does this mean the display hardware emits even rows from left to right and odd rows from right to left? I suppose that would practically eliminate the horizontal blanking period in CRT timings. If so, I think that might be best represented as a new format modifier. I'm guessing P stands for "pixel". >=20 > Memory: >=20 > 1 bpp (MSB first): >=20 > bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 > ---- ---- ---- ---- ---- ---- ---- ---- > byte 0: P0 P1 P2 P3 P4 P5 P6 P7 > byte 1: P8 P9 P10 P11 P12 P13 P14 P15 >=20 > 1 bpp (LSB first): >=20 > bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 > ---- ---- ---- ---- ---- ---- ---- ---- > byte 0: P7 P6 P5 P4 P3 P2 P1 P0 > byte 1: P15 P14 P13 P12 P11 P10 P9 P8 >=20 > 2 bpp (MSB first): >=20 > bits7-6 bits5-4 bits3-2 bits1-0 > ------- ------- ------- ------- > byte 0: P0 P1 P2 P3 > byte 1: P4 P5 P6 P7 > byte 2: P8 P9 P10 P11 > byte 3: P12 P13 P14 P15 >=20 > 2 bpp (LSB first): >=20 > bits7-6 bits5-4 bits3-2 bits1-0 > ------- ------- ------- ------- > byte 0: P3 P2 P1 P0 > byte 1: P7 P6 P5 P4 > byte 2: P11 P10 P9 P8 > byte 3: P15 P14 P13 P12 >=20 > 4 bpp (MSB first): >=20 > bits7-4 bits3-0 > ------- ------- > byte 0: P0 P1 > byte 1: P2 P3 > byte 2: P4 P5 > byte 3: P6 P7 > byte 4: P8 P9 > byte 5: P10 P11 > byte 6: P12 P13 > byte 7: P14 P15 >=20 > 4 bpp (LSB first): >=20 > bits7-4 bits3-0 > ------- ------- > byte 0: P1 P0 > byte 1: P3 P2 > byte 2: P5 P4 > byte 3: P7 P6 > byte 4: P9 P8 > byte 5: P11 P10 > byte 6: P13 P12 > byte 7: P15 P14 I think I can guess what you meant there, and it looks understandable to me. These tables are actually very clear, and leave only one thing undefined: when multiple bits form a pixel, in which order do the bits form the value. I recall you said fbdev allows for both orderings but only one order is ever used if I understood right. > > 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. =20 >=20 > But if the "CPU format" does not match the "display support", > all pixel data must be converted? Of course. If the driver author does not want to convert pixel data in flight, then the author should not let the driver expose a format that needs conversion. Thanks, pq --Sig_/vI_Pac=RFEkBtKEOIWIsjeU Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEJQjwWQChkWOYOIONI1/ltBGqqqcFAmIwUkIACgkQI1/ltBGq qqcfFg//RyTkAJFiAFknFvNsFj/AoVl7Oztr2cIdV3P1Iy5TMXkGUFgF6Lkf4ibM 7VdTy2OIK0euqBmJgFE6T2h88d0ZuU5YvekNgeUtJiVJstkO5UwVD3RBUEfKWjyA +J8Ux6XUbuK7QhgQ9Cn4LTp6mq1Y035mrOz4NKSTUb2+HSIUCMorB7NthkMINhKB Qna87k0bPEBnwVBPmZsOgbPDRWdPDy9OSXnVTBTfk/x4K1utOo8g/Ttu8brJdfpI mWZxH8C9dtnmsGVRpngrLwHHGOY+/DcxQdHGWQRu+vCNuwG0cUsZE2e7p9KHuAeB W7e9GfkgRgFzzuKX2WyrtCNDOQAkveWgstvRqKXsy3l/eUGhOehFvX1LbbLngKwl P0a2mcZpg4exEcyu88z9k8QqK0hKzY+A4ekxMUYk7MfDDi3csiEkibJpOda7Tyz9 C2N/G67qB01yFW7HFjmsDmqPg07Gd3LYQYtaHFekBGf1KU4DYOIZ9aDowCSZa4b+ Yr6AQew586xUw4HiZpyfZk2++kwFux64+FaiScN/jL6X71E1wIa7y4IqfKRQb11V KwNh2smSFQC9ArdCmrJLjWIygkzE1uslonvrehqvl9g+qx8+fg2FJQJwUUYXnEsv VYNmrVPxje4Ngo8R8hwGGmlGHoMVi1AN3eBoctuu1CDnw3gQ5o8= =k+m2 -----END PGP SIGNATURE----- --Sig_/vI_Pac=RFEkBtKEOIWIsjeU--