Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1698761pxb; Wed, 9 Feb 2022 02:31:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/NdZ8JjoxGVVPV/Sh2kdP0wkASjfCZnzhqyW1m3QSvwe903CKbrWQUBImWeouOMITlPvn X-Received: by 2002:a62:1ace:: with SMTP id a197mr1539504pfa.63.1644402665033; Wed, 09 Feb 2022 02:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644402665; cv=none; d=google.com; s=arc-20160816; b=j2bzTmW0dmDlovlexYfCKiofpmg9ZEPyRK6IMVrm3PfiSpt4MZr79eFwsC90LhTHNF 9DrPfWGfW1qbAJnIjgGkjv5JyVVhqT7CP538Z8FkhI7HCYE0UOykeens7LHQG4AM4Xdw 9jsMZsQxOap6oS7D6qeUo/r5RqvOoC/sOEHYGiEFgBUzaaRkOB5onv3shsZb1wS3F9st pG1mkMMR5qH6yuAvS9GxXFwuiW57KZcuZF+4yDcbilt57/3URjlBJk+41vTL1KEDEbz9 5Vcs4sqKCvfwZUXEb8hlQDaFQB4Aw644HevTLbsZ4g/HDgzzy9+GTAiVacnviHgQwexF ykuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8IjWPfErVF56gnkl+7MbKURIscJK6+3f2izeud69z0w=; b=GInTWFo0mIe+szkVYzG5tVRTni08mu+alBswbl2l3CYCxY0MeqMQRRjHWU+XjoXLNK W6xj2+Ew6TPcAplCFIHm9xXhklqIeN0IWM3q1Enzi7jsOsuaflbkHBnPc0vFaNAnIciD 7qnQUyRllugZ8w5L9S4rRkdb0dthkvRJWuQGSpsvo22ImIzXtwJlb+53KTsqEJXCEXGP Cwk5qZOa0RQak6iBBtoB3scohNq0oONA4pbbvwGH6YYcHwkSc27lWrRswF4nHbE1b+R2 6RB1CBj9DbnoQkHL7LCGR9dQBsxJY8rr4a61D5sfjjr+TmBosU629IgStIzFY+WLdXbA Bp2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LUhgR+1e; 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 188si15978879pga.550.2022.02.09.02.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 02:31:05 -0800 (PST) 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=LUhgR+1e; 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 D0A4CC02B5C7; Wed, 9 Feb 2022 01:21:51 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357998AbiBHOAb (ORCPT + 99 others); Tue, 8 Feb 2022 09:00:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347474AbiBHOA3 (ORCPT ); Tue, 8 Feb 2022 09:00:29 -0500 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AEF1C03FECE for ; Tue, 8 Feb 2022 06:00:28 -0800 (PST) Received: by mail-il1-x131.google.com with SMTP id d3so13938959ilr.10 for ; Tue, 08 Feb 2022 06:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8IjWPfErVF56gnkl+7MbKURIscJK6+3f2izeud69z0w=; b=LUhgR+1eKRyE4/ga2Xet0wuA9pHfUbQXrlc8q5dGINWcVWUon/YfDqW5kgxA6BQgiw yO+Fe89vtS5CjphxZIL0HxwBTU4FaKW7Eq5W00ElVcH/6dwzRNpW3UmoP3bWwjY54J+8 pGR5oA4ZqFNbDeQwmSxOOGcU1QkZWYiyogbhy5A14vEDIJOzBEgvYQmkY5NPe7RNq/6b 1kuTFem7o3FvSDTYWGOkGHlS3cVDvcrkAj328ZCtHKg7FxY4n5eyG9psp3OxQXUQcL1R 1PRUQEvZYpvh5NvNa7Kk2dEDY/4SFfg0og7E41jpYIqNKVFVFqoQq+2f2KLv5PIcKNP9 JtxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8IjWPfErVF56gnkl+7MbKURIscJK6+3f2izeud69z0w=; b=j7HWiJOaYarlO88LknH1d9BZGBOVZ8iRwBcQBg20OPbTLAZR58dGiCzABiXZTGlFgJ 2OPGI02DVspuWFMwkMZNPne5+neMt/P5LBbR3b2JdrlnDGSAAIiwPJVBCIVWYodcal0W vW0A1uRxDO8MovCBns+1Sv17dwVWEiM8eJeBrVIuA+MZUhEetchRwElBDDTdzEadkujb L17cDETYAgL+/gmzSOFE2VDIFx7GhL/R3AqyMrDQBSS8kjX1oAc/kidxKDuqkACt7DT5 /SKIeFGa3revjmAfz3TcW0abY0m8EvGDXVroumC6UakV8mLOtS5xENqp6PC8kIJMxQGl aeAQ== X-Gm-Message-State: AOAM530MXSFg3FHYBSnt2iwtmsmvyWDLnknuKJIqYI5xuk0BvLQUNJdJ yQq34+aZ4v69q+paBAGi+qTPC0HnUxTmkhYrIvtx7zv4jyg= X-Received: by 2002:a05:6e02:1ba2:: with SMTP id n2mr2342739ili.5.1644328827834; Tue, 08 Feb 2022 06:00:27 -0800 (PST) MIME-Version: 1.0 References: <20220203002521.162878-1-cmirabil@redhat.com> <20220203002521.162878-4-cmirabil@redhat.com> In-Reply-To: <20220203002521.162878-4-cmirabil@redhat.com> From: Miguel Ojeda Date: Tue, 8 Feb 2022 15:00:16 +0100 Message-ID: Subject: Re: [PATCH 3/6] drivers/auxdisplay: sensehat: Raspberry Pi Sense HAT display driver To: Charles Mirabile Cc: linux-kernel , Serge Schneider , Stefan Wahren , Nicolas Saenz Julienne , Mattias Brugger , linux-rpi-kernel@lists.infradead.org, Linux ARM , fedora-rpi@googlegroups.com, Miguel Ojeda , Mwesigwa Guma , Joel Savitz , Daniel Bauman Content-Type: text/plain; charset="UTF-8" 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 On Thu, Feb 3, 2022 at 1:26 AM Charles Mirabile wrote: > > This patch adds the driver for the 8x8 RGB LED matrix display > on the Sense HAT. It appears as a character device named sense-hat > in /dev/. That special file is 192 bytes large and contains one byte > for each color channel of each pixel. The overall layout is: A general comment about the commit message: I am not sure why the format of the file is included here -- shouldn't this be placed in comments in the code or in Documentation? Is it elsewhere in the series? > col 1 col 8 > | | > v v > 0x00: R . . . R \ > 0x08: G . . . G |> row 1 > 0x10: B . . . B / > . . . > ... . . . > . . . > 0xA8: R . . . R \ > 0xB0: G . . . G |> row 8 > 0xB8: G . . . G / Do you mean B instead of G in row 8? By the way, is there a particular reason for this layout vs., say, RGB tuples? > Each channel may have any value between 0 and 31 (larger values are > wrapped) and are translated by a gamma table before being send to the > device to provide a linear experience of brightness (the gamma table > can be modified or reset using an ioctl call on the file). The constants > for the ioctl are in the sensehat.h header also added in this patch. Even though there is a gamma table, it is unclear what the input encoding is supposed to be. sRGB? Linear sRGB? In any case, where the gamma tables' values come from? i.e. the device's datasheet (or sRGB, or a combination of those), or hand-made, ...? Also, should this conversion be handled by the driver? If yes, why not use the full range 0..255 as input? > + for (i = 0; i < VMEM_SIZE; ++i) > + temp[i] = display->gamma[display->vmem[i] & 0x1f]; Please avoid hardcoded constants (and, in particular, this is in hex while the related constant `GAMMA_SIZE` is in decimal, so it is even harder to see). Or perhaps use a small helper function or macro. > + pos = base + offset; > + if (pos < 0 || pos >= VMEM_SIZE) > + return -EINVAL; > + filp->f_pos = pos; Please check if one of the generic `llseek`'s would work here (e.g. `fixed_size_llseek`). > + memcpy(sensehat_display->gamma, gamma_presets[lowlight], GAMMA_SIZE); Here it is confusing which table you are copying due to the `lowlight` name. I would write `lowlight ? SENSEHAT_GAMMA_LOWLIGHT : SENSEHAT_GAMMA_DEFAULT` even if it is redundant. (Given you created an enum for the presets, it may make sense to use something else than a `bool`, by the way). Cheers, Miguel