Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp637896rdg; Wed, 11 Oct 2023 00:40:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeT3q4yAJtjigJrf6Xxa17lvdVGzsv/Hz2qF5hJHLwReJLMRYOo2ErMofAdyD1p2MBQAqv X-Received: by 2002:a05:6358:3408:b0:14f:852b:4362 with SMTP id h8-20020a056358340800b0014f852b4362mr24340523rwd.19.1697010012274; Wed, 11 Oct 2023 00:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697010012; cv=none; d=google.com; s=arc-20160816; b=Kq8VTNkFrBOXKtvutCOx+yz//dLH6hhav/5u2VyklreJkH/spOung+9dUFK7ALo0gd y3ZlIaduR44pmYMQywUyIPzdlrAmrwHXJHEXW1Cw1iOctoiAZUHoIjDZWzJpC02LBAih eN0arCdg2VsAdcQQZx5hynJuJYlnAxsaLrPVATcN4w8JUB0qJAdR8n0JEwFWH0DhGMrm diqjBb2eIr18ig0tZxq876BJx4GR3DD3QdbEMuo7dqZjzJ8LV98yCpaJ6mQ3BoCBVktG lj40EVSJ1JZvXl4VUjYUhDSiBYsCd+tvwRSiFgyn+Q0B/nB++OvgBXLMs/TY2NzVrlxg BXxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=vdNvUE7bPjHYRVdS6a5GZ79gyzZD+jz7QNorqOknMjA=; fh=N1VjeAkTTAWc63blSQZLytAcIRF19sUJOe1jVUXBTLM=; b=o2H1AqpI0bjnIwnJxkCtBlDgeWwJ38n5teDgT2xizxwUj5+cmYVGumxsLyepJVC+U6 /QRxQJ8jgzqYnYEoFxNRhnENA62yh0ulbYXyd1uWlVsCCnQCoqb8Go8/3RCNO2ot3ibQ J2Q9WFCCCqNK66pogJ5kaJRxchoALxcPaE8PW8r533sO1fdXYvzKN01RJ/V160mxbhrS VlwVYkSj8Cn5qdA+VeosteTVA0oki6Nlh+Zy7mJMcHLsDmXki3tSMmvu+GXjC/N6xPM9 l0vkyS6T8M5gbb0shirzHOe6V0xWWNBZXMZ02/a4Upzg0Vu76WOKwa0HDBJl25s4plDt cm1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id 21-20020a630f55000000b00565e386ff44si13843583pgp.702.2023.10.11.00.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 00:40:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2BFA4833AB14; Wed, 11 Oct 2023 00:40:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345026AbjJKHkB convert rfc822-to-8bit (ORCPT + 99 others); Wed, 11 Oct 2023 03:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344709AbjJKHkA (ORCPT ); Wed, 11 Oct 2023 03:40:00 -0400 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 644DE98 for ; Wed, 11 Oct 2023 00:39:58 -0700 (PDT) Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-5a7c95b8d14so15788377b3.3 for ; Wed, 11 Oct 2023 00:39:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697009997; x=1697614797; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/X15NrvY+cErHcD0y7I5v3H188ScfV0hu8n5YeLnxfI=; b=a90zCRxcWFVsHZFm9ArweUCeZOYwa79w8yjyW/22I/o/vTnpmjyOK3XHnPSsrkgREH 7QZS8chVoJdFBCuzFZb80qmfZ50W7kDsdKRcv9MwnlsXk+DLhitn6+51JscXEX9973GR zkueJUEBEXlZeTmFvxq2ya6tcjii8dBuRoWjh0Rd0JMO12iAq8B19qdQA0NKJQjG77UG kMGYpC+0nL6jjI6SFMrbmnrzswNseZ96KLc0QrFm/cHoU4KjJDYWzQjwJanZz7UbbRPh 84M7enoSM0xZGGuoEIk7FNFjsQSJOI2p1BB57cM+Pr9Xtu/Lh5pt0FeLOF9w07topa/E jVdg== X-Gm-Message-State: AOJu0Yw+XXhVm2H/XUDUHHZ7m4GBXk9hL8XtQ2OIsXk//5Qo+jVfRhbI W63EiAPDvdtVEkI9Nn5V8YnesgUQtnId3A== X-Received: by 2002:a5b:342:0:b0:d88:a049:e901 with SMTP id q2-20020a5b0342000000b00d88a049e901mr18560527ybp.7.1697009997362; Wed, 11 Oct 2023 00:39:57 -0700 (PDT) Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com. [209.85.128.177]) by smtp.gmail.com with ESMTPSA id 63-20020a251942000000b00d7ba4c5e31fsm4337980ybz.39.2023.10.11.00.39.56 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Oct 2023 00:39:56 -0700 (PDT) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-5a7af45084eso27144447b3.0 for ; Wed, 11 Oct 2023 00:39:56 -0700 (PDT) X-Received: by 2002:a0d:f4c7:0:b0:583:3c54:6d89 with SMTP id d190-20020a0df4c7000000b005833c546d89mr20550083ywf.44.1697009996484; Wed, 11 Oct 2023 00:39:56 -0700 (PDT) MIME-Version: 1.0 References: <20231009183522.543918-1-javierm@redhat.com> <20231009183522.543918-4-javierm@redhat.com> In-Reply-To: <20231009183522.543918-4-javierm@redhat.com> From: Geert Uytterhoeven Date: Wed, 11 Oct 2023 09:39:44 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/8] drm/ssd13xx: Replace .page_height field in device info with a constant To: Javier Martinez Canillas Cc: linux-kernel@vger.kernel.org, Maxime Ripard , Thomas Zimmermann , Daniel Vetter , David Airlie , Maarten Lankhorst , dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 11 Oct 2023 00:40:10 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 9, 2023 at 8:36 PM Javier Martinez Canillas wrote: > This deemed useful to avoid hardcoding a page height and allow to support > other Solomon controller families, but dividing the screen in pages seems > to be something that is specific to the SSD130x chip family. > > For example, SSD132x chip family divides the screen in segments (columns) > and common outputs (rows), so the concept of screen pages does not exist > for the SSD132x family. > > Let's drop this field from the device info struct and just use a constant > SSD130X_PAGE_HEIGHT macro to define the page height. While being there, > replace hardcoded 8 values in places where it is used as the page height. > > Signed-off-by: Javier Martinez Canillas > --- a/drivers/gpu/drm/solomon/ssd13xx.c > +++ b/drivers/gpu/drm/solomon/ssd13xx.c > @@ -465,13 +462,13 @@ static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx, > unsigned int width = drm_rect_width(rect); > unsigned int height = drm_rect_height(rect); > unsigned int line_length = DIV_ROUND_UP(width, 8); > - unsigned int page_height = ssd13xx->device_info->page_height; > + unsigned int page_height = SSD130X_PAGE_HEIGHT; > unsigned int pages = DIV_ROUND_UP(height, page_height); > struct drm_device *drm = &ssd13xx->drm; > u32 array_idx = 0; > int ret, i, j, k; > > - drm_WARN_ONCE(drm, y % 8 != 0, "y must be aligned to screen page\n"); > + drm_WARN_ONCE(drm, y % page_height != 0, "y must be aligned to screen page\n"); > > /* > * The screen is divided in pages, each having a height of 8 > @@ -503,27 +500,32 @@ static int ssd13xx_update_rect(struct ssd13xx_device *ssd13xx, > */ > > if (!ssd13xx->page_address_mode) { > + u8 page_start; > + > /* Set address range for horizontal addressing mode */ > ret = ssd13xx_set_col_range(ssd13xx, ssd13xx->col_offset + x, width); > if (ret < 0) > return ret; > > - ret = ssd13xx_set_page_range(ssd13xx, ssd13xx->page_offset + y / 8, pages); > + page_start = ssd13xx->page_offset + y / page_height; > + ret = ssd13xx_set_page_range(ssd13xx, page_start, pages); > if (ret < 0) > return ret; > } > > for (i = 0; i < pages; i++) { > - int m = 8; > + int m = page_height; > > /* Last page may be partial */ > - if (8 * (y / 8 + i + 1) > ssd13xx->height) > - m = ssd13xx->height % 8; > + if (page_height * (y / page_height + i + 1) > ssd13xx->height) > + m = ssd13xx->height % page_height; > + > for (j = 0; j < width; j++) { > u8 data = 0; > > for (k = 0; k < m; k++) { > - u8 byte = buf[(8 * i + k) * line_length + j / 8]; > + u32 idx = (page_height * i + k) * line_length + j / 8; Nit: I would use unsigned int for idx, as that matches all other variables involved. But given array_idx is u32, too, u32 may makes sense. > + u8 byte = buf[idx]; > u8 bit = (byte >> (j % 8)) & 1; > > data |= bit << k; Reviewed-by: Geert Uytterhoeven Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds