Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp797798imw; Fri, 8 Jul 2022 11:55:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uWRKEXZHrgyUWGG+0zW3CYwaQ5GO/WJVCnQmKPaC8hQVHEXQOFEGFRtiJY+yffuRLtNY+D X-Received: by 2002:a17:90b:3911:b0:1ef:fa84:dc80 with SMTP id ob17-20020a17090b391100b001effa84dc80mr1409301pjb.7.1657306534564; Fri, 08 Jul 2022 11:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657306534; cv=none; d=google.com; s=arc-20160816; b=lMRnpvwLh/4qPfm/qH5NJCmTQclYts2w5baiMwMfP8HSWnD3g1gely+yRRAX3iogzm mYyVCs5tfJ3ZW9WSG1l+w0Vcte99Yzr+Uw39r10PNrJF8ptllP8ikNfYk9y1INtwYzeS Ts6qqamW3IRc3jOZt9VC5rpk8dRJId6E4JA8+tT/jbAAPCu83twmJNIyoDTlLE6wyDqY aiMF+d5Wg0YAlrAGcdorkNX2VxvC4S6P/2hln3iWPgEa1UlZGs079D3FpdCwkVPl9zrK GKN72ia2nKxxBffj6vEkJgrAfPc7uPMz4IzEMLvSguc4UoBzzHDYdexVbOB1t6Tbwbsb VVmQ== 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=FoWCnk8ZO6uRaoJ1Qy8DAfbJhUdM7Tw5ubxz3esXLYI=; b=W6Kl8oQxAN4jE1RZZD8RrzaZIeOBy+AyRPawefz7nAbLm+zUQvNDpenlLGAUuwr3KQ P3FR0zsekMoEfDdvrolCutx/bCo0oWXeCeko42mC8Nf04EzzcYF1RQznWmbrXWLm+f05 n3AXflFayHYU0ahLR+w6oYXjRswsbWY7c6veyNSQQzKMoAY2U/p2lnq03Mw3VoSJ01F6 JGwnB0vus7aIIvSKgPX32JUs4MtvgYa1zeyx4LEG5sQZQfDmM7m3mMpKDB/F4NzEKCxJ Nrl3GUHGzsJMpcAlAkghd5kto9WV19n6p1/gkHnJszahBK9E+7mQMJR4nI+rlWQbyteg bEng== 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 i9-20020a17090332c900b0016c2ae85bd7si1440112plr.400.2022.07.08.11.55.22; Fri, 08 Jul 2022 11:55:34 -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 S239103AbiGHSVU (ORCPT + 99 others); Fri, 8 Jul 2022 14:21:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238880AbiGHSVO (ORCPT ); Fri, 8 Jul 2022 14:21:14 -0400 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDECA82384 for ; Fri, 8 Jul 2022 11:21:10 -0700 (PDT) Received: from ramsan.of.borg ([84.195.186.194]) by albert.telenet-ops.be with bizsmtp id siM72700L4C55Sk06iM7W3; Fri, 08 Jul 2022 20:21:08 +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 1o9sbD-002fGt-21; Fri, 08 Jul 2022 20:21:07 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbC-00BtK3-Jj; Fri, 08 Jul 2022 20:21:06 +0200 From: Geert Uytterhoeven To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Javier Martinez Canillas Subject: [PATCH/RFC v3 09/10] drm/fourcc: Add DRM_FORMAT_R[124] Date: Fri, 8 Jul 2022 20:20:54 +0200 Message-Id: <96561a88e53c59cac72e66642bf4c097aacefd18.1657294931.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=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 Introduce fourcc codes for single-channel frame buffer formats with two, four, and sixteen brightness levels, where there is a direct relationship between channel value and brightness. As the number of bits per pixel is less than eight, these rely on proper block handling for the calculation of bits per pixel and pitch. The fill order (the order in which multiple pixels are packed in a byte) is the same order as used for grayscale (2, 4, and 16 levels) images in the PNG specification, Version 1.2. This order is also the recommended and default order (FillOrder = 1) for bilevel and grayscale (16 levels) images in the TIFF 6.0 Specification, and is also used for monochrome images in the PBM file format, monochrome Linux frame buffer logos, and BDF and PSF (Linux kernel) font files. Signed-off-by: Geert Uytterhoeven Reviewed-by: Javier Martinez Canillas --- RFC, as I have no immediate need for these formats. v3: - Add Reviewed-by, - Document fill order, - Replace light-on-dark by direct relationship between channel value and brightness, v2: - Improve pixel description. --- drivers/gpu/drm/drm_fourcc.c | 6 ++++++ include/uapi/drm/drm_fourcc.h | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index 29f4fe199c4ddcf0..05e65e9ab0c69c6a 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -154,6 +154,12 @@ const struct drm_format_info *__drm_format_info(u32 format) { .format = DRM_FORMAT_C4, .depth = 4, .num_planes = 1, .char_per_block = { 1, }, .block_w = { 2, }, .block_h = { 1, }, .hsub = 1, .vsub = 1, .is_color_indexed = true }, { .format = DRM_FORMAT_C8, .depth = 8, .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1, .is_color_indexed = true }, + { .format = DRM_FORMAT_R1, .depth = 1, .num_planes = 1, + .char_per_block = { 1, }, .block_w = { 8, }, .block_h = { 1, }, .hsub = 1, .vsub = 1 }, + { .format = DRM_FORMAT_R2, .depth = 2, .num_planes = 1, + .char_per_block = { 1, }, .block_w = { 4, }, .block_h = { 1, }, .hsub = 1, .vsub = 1 }, + { .format = DRM_FORMAT_R4, .depth = 4, .num_planes = 1, + .char_per_block = { 1, }, .block_w = { 2, }, .block_h = { 1, }, .hsub = 1, .vsub = 1 }, { .format = DRM_FORMAT_R8, .depth = 8, .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 }, { .format = DRM_FORMAT_R10, .depth = 10, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 }, { .format = DRM_FORMAT_R12, .depth = 12, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 }, diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h index dff5072fccaaf65c..6db4f195d6a15129 100644 --- a/include/uapi/drm/drm_fourcc.h +++ b/include/uapi/drm/drm_fourcc.h @@ -104,6 +104,15 @@ extern "C" { #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 */ +/* 1 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ') /* [7:0] R0:R1:R2:R3:R4:R5:R6:R7 1:1:1:1:1:1:1:1 eight pixels/byte */ + +/* 2 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ') /* [7:0] R0:R1:R2:R3 2:2:2:2 four pixels/byte */ + +/* 4 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ') /* [7:0] R0:R1 4:4 two pixels/byte */ + /* 8 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ -- 2.25.1