From nobody Fri Dec 19 04:06:51 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93351CDB46E for ; Thu, 12 Oct 2023 06:59:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377684AbjJLG70 (ORCPT ); Thu, 12 Oct 2023 02:59:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377629AbjJLG7Q (ORCPT ); Thu, 12 Oct 2023 02:59:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEC8690 for ; Wed, 11 Oct 2023 23:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697093912; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mbymuqok05VINAfw8cxu/tPwEjlcj5Oue+IDRMaC16g=; b=AG5lfWdxUaKJQkgLagvjIE+Iwi1Fot+jWShTPliF9k6F0mrOrQ5R6ae6wDldlMsX++wsp3 NBLKbLI7+ehlbyU+w+0ccK+9F8tMN0UDZkJqo5TA2xL1mWenHwUxDEvof45VJBi9cFj/9Z DtL9gpAB2rUNyN7iEmubGeRQe/Dz2pE= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-pUYlyj4UMbCTG_uzpm2UVg-1; Thu, 12 Oct 2023 02:58:29 -0400 X-MC-Unique: pUYlyj4UMbCTG_uzpm2UVg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-32172e3679bso399526f8f.2 for ; Wed, 11 Oct 2023 23:58:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697093908; x=1697698708; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mbymuqok05VINAfw8cxu/tPwEjlcj5Oue+IDRMaC16g=; b=HQc7CXquRSlyhHsYQ5SZZ9+o7MfHnpfhyagbu+jjIMfq5J5lEHZyv+ycQmhMHXN2y5 RssgACyphBYD+XGaBYI2uHvAhQqw0qDLx6dUeqWcjt6mimil5fINvMvuE3zpiEmdhMhP 8holOA9KJ9rxulYbAEiFk+WXrmvyLdXNK3252b5ltnmjrpe0otExFyU+MkwGeJZUlVd0 QAWEz8+HthbPmOTCFQz4h3zKyVlVm8HVRdacUu2c64iIfbZNlEEr3BPVxbtAeKyp7yEc 8geB9ztTEpXXeO8fNBAG+c9V9E6GGpp/7x0uUfioWFUP6smY7ZYo8P4cxA97wuhFTN29 C8FQ== X-Gm-Message-State: AOJu0YzXMe1TQVhyQSvcz6lpPjjnr14+iNEF17pSt1rwnnF1rPGDwmop IC9q0NWL5vrQyiwmBp9hgizhmgZLF7/8o8pbvGj0wMT9Xc7vQ210oIGCR73M4vBqz2bd822EpDh CZ/+mtfES+vO6qnhYajf/djCWw9AC1vxCh/GbyXZoF2/t8T6GnrtBoyDQpZuBbcMCm0P5yxrY25 CRt68vrLM= X-Received: by 2002:a05:6000:a14:b0:32c:a930:fe0e with SMTP id co20-20020a0560000a1400b0032ca930fe0emr7866711wrb.14.1697093907742; Wed, 11 Oct 2023 23:58:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFyFeT+2x5WBZld6FVhLFSCPrBl+EViMXQ3LHhy0Jx56i32BtM/idfewL94KsllK10JzCqiEA== X-Received: by 2002:a05:6000:a14:b0:32c:a930:fe0e with SMTP id co20-20020a0560000a1400b0032ca930fe0emr7866681wrb.14.1697093907430; Wed, 11 Oct 2023 23:58:27 -0700 (PDT) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id r18-20020adfe692000000b0031912c0ffebsm17460772wrm.23.2023.10.11.23.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 23:58:26 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Thomas Zimmermann , Conor Dooley , Peter Robinson , Rob Herring , Maxime Ripard , Geert Uytterhoeven , Javier Martinez Canillas , Geert Uytterhoeven , Daniel Vetter , David Airlie , Maarten Lankhorst , dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/6] drm/ssd130x: Replace .page_height field in device info with a constant Date: Thu, 12 Oct 2023 08:58:10 +0200 Message-ID: <20231012065822.1007930-2-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012065822.1007930-1-javierm@redhat.com> References: <20231012065822.1007930-1-javierm@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Geert Uytterhoeven --- Changes in v2: - Add Geert Uytterhoeven's Reviewed-by tag to patch #1. drivers/gpu/drm/solomon/ssd130x.c | 37 +++++++++++++++---------------- drivers/gpu/drm/solomon/ssd130x.h | 1 - 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ss= d130x.c index 6dcf3e041113..2852cddb098b 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -42,6 +42,8 @@ #define DRIVER_MAJOR 1 #define DRIVER_MINOR 0 =20 +#define SSD130X_PAGE_HEIGHT 8 + #define SSD130X_PAGE_COL_START_LOW 0x00 #define SSD130X_PAGE_COL_START_HIGH 0x10 #define SSD130X_SET_ADDRESS_MODE 0x20 @@ -102,7 +104,6 @@ const struct ssd130x_deviceinfo ssd130x_variants[] =3D { .default_width =3D 132, .default_height =3D 64, .page_mode_only =3D 1, - .page_height =3D 8, }, [SSD1305_ID] =3D { .default_vcomh =3D 0x34, @@ -110,7 +111,6 @@ const struct ssd130x_deviceinfo ssd130x_variants[] =3D { .default_dclk_frq =3D 7, .default_width =3D 132, .default_height =3D 64, - .page_height =3D 8, }, [SSD1306_ID] =3D { .default_vcomh =3D 0x20, @@ -119,7 +119,6 @@ const struct ssd130x_deviceinfo ssd130x_variants[] =3D { .need_chargepump =3D 1, .default_width =3D 128, .default_height =3D 64, - .page_height =3D 8, }, [SSD1307_ID] =3D { .default_vcomh =3D 0x20, @@ -128,7 +127,6 @@ const struct ssd130x_deviceinfo ssd130x_variants[] =3D { .need_pwm =3D 1, .default_width =3D 128, .default_height =3D 39, - .page_height =3D 8, }, [SSD1309_ID] =3D { .default_vcomh =3D 0x34, @@ -136,7 +134,6 @@ const struct ssd130x_deviceinfo ssd130x_variants[] =3D { .default_dclk_frq =3D 10, .default_width =3D 128, .default_height =3D 64, - .page_height =3D 8, } }; EXPORT_SYMBOL_NS_GPL(ssd130x_variants, DRM_SSD130X); @@ -465,13 +462,13 @@ static int ssd130x_update_rect(struct ssd130x_device = *ssd130x, unsigned int width =3D drm_rect_width(rect); unsigned int height =3D drm_rect_height(rect); unsigned int line_length =3D DIV_ROUND_UP(width, 8); - unsigned int page_height =3D ssd130x->device_info->page_height; + unsigned int page_height =3D SSD130X_PAGE_HEIGHT; unsigned int pages =3D DIV_ROUND_UP(height, page_height); struct drm_device *drm =3D &ssd130x->drm; u32 array_idx =3D 0; int ret, i, j, k; =20 - drm_WARN_ONCE(drm, y % 8 !=3D 0, "y must be aligned to screen page\n"); + drm_WARN_ONCE(drm, y % page_height !=3D 0, "y must be aligned to screen p= age\n"); =20 /* * The screen is divided in pages, each having a height of 8 @@ -503,27 +500,32 @@ static int ssd130x_update_rect(struct ssd130x_device = *ssd130x, */ =20 if (!ssd130x->page_address_mode) { + u8 page_start; + /* Set address range for horizontal addressing mode */ ret =3D ssd130x_set_col_range(ssd130x, ssd130x->col_offset + x, width); if (ret < 0) return ret; =20 - ret =3D ssd130x_set_page_range(ssd130x, ssd130x->page_offset + y / 8, pa= ges); + page_start =3D ssd130x->page_offset + y / page_height; + ret =3D ssd130x_set_page_range(ssd130x, page_start, pages); if (ret < 0) return ret; } =20 for (i =3D 0; i < pages; i++) { - int m =3D 8; + int m =3D page_height; =20 /* Last page may be partial */ - if (8 * (y / 8 + i + 1) > ssd130x->height) - m =3D ssd130x->height % 8; + if (page_height * (y / page_height + i + 1) > ssd130x->height) + m =3D ssd130x->height % page_height; + for (j =3D 0; j < width; j++) { u8 data =3D 0; =20 for (k =3D 0; k < m; k++) { - u8 byte =3D buf[(8 * i + k) * line_length + j / 8]; + u32 idx =3D (page_height * i + k) * line_length + j / 8; + u8 byte =3D buf[idx]; u8 bit =3D (byte >> (j % 8)) & 1; =20 data |=3D bit << k; @@ -559,8 +561,7 @@ static int ssd130x_update_rect(struct ssd130x_device *s= sd130x, =20 static void ssd130x_clear_screen(struct ssd130x_device *ssd130x, u8 *data_= array) { - unsigned int page_height =3D ssd130x->device_info->page_height; - unsigned int pages =3D DIV_ROUND_UP(ssd130x->height, page_height); + unsigned int pages =3D DIV_ROUND_UP(ssd130x->height, SSD130X_PAGE_HEIGHT); unsigned int width =3D ssd130x->width; int ret, i; =20 @@ -605,14 +606,13 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffe= r *fb, u8 *buf, u8 *data_array) { struct ssd130x_device *ssd130x =3D drm_to_ssd130x(fb->dev); - unsigned int page_height =3D ssd130x->device_info->page_height; struct iosys_map dst; unsigned int dst_pitch; int ret =3D 0; =20 /* Align y to display page boundaries */ - rect->y1 =3D round_down(rect->y1, page_height); - rect->y2 =3D min_t(unsigned int, round_up(rect->y2, page_height), ssd130x= ->height); + rect->y1 =3D round_down(rect->y1, SSD130X_PAGE_HEIGHT); + rect->y2 =3D min_t(unsigned int, round_up(rect->y2, SSD130X_PAGE_HEIGHT),= ssd130x->height); =20 dst_pitch =3D DIV_ROUND_UP(drm_rect_width(rect), 8); =20 @@ -814,8 +814,7 @@ static int ssd130x_crtc_atomic_check(struct drm_crtc *c= rtc, struct ssd130x_device *ssd130x =3D drm_to_ssd130x(drm); struct drm_crtc_state *crtc_state =3D drm_atomic_get_new_crtc_state(state= , crtc); struct ssd130x_crtc_state *ssd130x_state =3D to_ssd130x_crtc_state(crtc_s= tate); - unsigned int page_height =3D ssd130x->device_info->page_height; - unsigned int pages =3D DIV_ROUND_UP(ssd130x->height, page_height); + unsigned int pages =3D DIV_ROUND_UP(ssd130x->height, SSD130X_PAGE_HEIGHT); int ret; =20 ret =3D drm_crtc_helper_atomic_check(crtc, state); diff --git a/drivers/gpu/drm/solomon/ssd130x.h b/drivers/gpu/drm/solomon/ss= d130x.h index aa39b13615eb..bbe374453605 100644 --- a/drivers/gpu/drm/solomon/ssd130x.h +++ b/drivers/gpu/drm/solomon/ssd130x.h @@ -39,7 +39,6 @@ struct ssd130x_deviceinfo { u32 default_dclk_frq; u32 default_width; u32 default_height; - u32 page_height; bool need_pwm; bool need_chargepump; bool page_mode_only; --=20 2.41.0