From patchwork Mon Jun 5 07:47:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13267039 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79E99C7EE24 for ; Mon, 5 Jun 2023 07:48:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6519810E192; Mon, 5 Jun 2023 07:48:18 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id C378310E190 for ; Mon, 5 Jun 2023 07:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685951292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mJ6LVDenz7leEoWEGqkNGYbuR5Ekaz6eOK5tZIJsJWA=; b=F6eg4RN7Qc4nBSLB0twUfe2JWx2Mdf7auB8/KGUNWNz1ClGctsr5BDXc1pu5akN4Bkj/VQ Fa30GguXTPco6Syu7seiPphBah4crIF5MPaKmnJ++BvvBSq4ndPFrSS8trUBJHXL2Ls8Zz e/IgZ72uuabycIhBB9tGkN8mudz02j0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-359-4MNR2TQDNkq_wI49ULJC4Q-1; Mon, 05 Jun 2023 03:48:09 -0400 X-MC-Unique: 4MNR2TQDNkq_wI49ULJC4Q-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f6fa88a86bso24748905e9.0 for ; Mon, 05 Jun 2023 00:48:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685951288; x=1688543288; 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=mJ6LVDenz7leEoWEGqkNGYbuR5Ekaz6eOK5tZIJsJWA=; b=BOCUurYvKbs+WLYzucInxK05lGsvMcZ3PbXKtvDKYXO/mIEB8Xe4favTzcJlt+JjnD IqLyceDMePatQFUYZ3nVStiYDWl8Qx5Dne0pY0hYDo2e3AJCeHRSEwpsSbhbkevan1Dt 05gzenEK4iBUJGOE7mhMSiKym/yDE3NdwhnTduEcRrV2ieYcU12ABKk4DU8KShqZs56+ cQh7MI90A8Rb+3sgMj3FJI9fBqpU3XqK2CVRcdAcfxCzSe4ZIk36zRdik+PE23JDKQDv S3WlwrEnEVshJTrlc9osSuCJ36RvmDiLOCparnLbE1ppP1jRq34iRTffgNV2AxrlDIzy rNZg== X-Gm-Message-State: AC+VfDxAYZ2USv7dccXUZRk3MHbmAtLD5nW5mCPOMyfgIyVRO5sXQJnA e+b8kBLv1wNv3o9HZDFzT6DISGI78ISzB/7onSdLNgugK05pc56HZz+WEkEX9ZA1TRznYoYu+eY mP2jdKDLjQQFuVqXqcrwlAJX/1NwQ X-Received: by 2002:a05:600c:284a:b0:3f6:1377:8b15 with SMTP id r10-20020a05600c284a00b003f613778b15mr7656282wmb.21.1685951288531; Mon, 05 Jun 2023 00:48:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Y3sEsxNIwZK3n9IEdro6U7y6EP48MP57T3BvOfN5LZhOYLajzhcd2K85ImHRDwpnr2Kb1WQ== X-Received: by 2002:a05:600c:284a:b0:3f6:1377:8b15 with SMTP id r10-20020a05600c284a00b003f613778b15mr7656272wmb.21.1685951288313; Mon, 05 Jun 2023 00:48:08 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id q21-20020a1ce915000000b003f4fb5532a1sm9715192wmc.43.2023.06.05.00.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 00:48:07 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 1/5] drm/ssd130x: Make default width and height to be controller dependent Date: Mon, 5 Jun 2023 09:47:49 +0200 Message-Id: <20230605074753.562332-2-javierm@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230605074753.562332-1-javierm@redhat.com> References: <20230605074753.562332-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , Javier Martinez Canillas , Maxime Ripard , Geert Uytterhoeven , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently the driver hardcodes the default values to 96x16 pixels but this default resolution depends on the controller. The datasheets for the chips describes the following display controller resolutions: - SH1106: 132 x 64 Dot Matrix OLED/PLED - SSD1306: 128 x 64 Dot Matrix OLED/PLED - SSD1307: 128 x 39 Dot Matrix OLED/PLED - SSD1309: 128 x 64 Dot Matrix OLED/PLED Add this information to the devices' info structures, and use it set as a default if not defined in DT rather than hardcoding to an arbitrary value. Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/solomon/ssd130x.c | 14 ++++++++++++-- drivers/gpu/drm/solomon/ssd130x.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c index 8cbf5aa66e19..a0e5e26c0bc9 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -99,29 +99,39 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { .default_vcomh = 0x40, .default_dclk_div = 1, .default_dclk_frq = 5, + .default_width = 132, + .default_height = 64, .page_mode_only = 1, }, [SSD1305_ID] = { .default_vcomh = 0x34, .default_dclk_div = 1, .default_dclk_frq = 7, + .default_width = 132, + .default_height = 64, }, [SSD1306_ID] = { .default_vcomh = 0x20, .default_dclk_div = 1, .default_dclk_frq = 8, .need_chargepump = 1, + .default_width = 128, + .default_height = 64, }, [SSD1307_ID] = { .default_vcomh = 0x20, .default_dclk_div = 2, .default_dclk_frq = 12, .need_pwm = 1, + .default_width = 128, + .default_height = 39, }, [SSD1309_ID] = { .default_vcomh = 0x34, .default_dclk_div = 1, .default_dclk_frq = 10, + .default_width = 128, + .default_height = 64, } }; EXPORT_SYMBOL_NS_GPL(ssd130x_variants, DRM_SSD130X); @@ -798,10 +808,10 @@ static void ssd130x_parse_properties(struct ssd130x_device *ssd130x) struct device *dev = ssd130x->dev; if (device_property_read_u32(dev, "solomon,width", &ssd130x->width)) - ssd130x->width = 96; + ssd130x->width = ssd130x->device_info->default_width; if (device_property_read_u32(dev, "solomon,height", &ssd130x->height)) - ssd130x->height = 16; + ssd130x->height = ssd130x->device_info->default_height; if (device_property_read_u32(dev, "solomon,page-offset", &ssd130x->page_offset)) ssd130x->page_offset = 1; diff --git a/drivers/gpu/drm/solomon/ssd130x.h b/drivers/gpu/drm/solomon/ssd130x.h index db03ee5db392..a2bc8d75078b 100644 --- a/drivers/gpu/drm/solomon/ssd130x.h +++ b/drivers/gpu/drm/solomon/ssd130x.h @@ -37,6 +37,8 @@ struct ssd130x_deviceinfo { u32 default_vcomh; u32 default_dclk_div; u32 default_dclk_frq; + u32 default_width; + u32 default_height; int need_pwm; int need_chargepump; bool page_mode_only; From patchwork Mon Jun 5 07:47:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13267037 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 009E9C7EE23 for ; Mon, 5 Jun 2023 07:48:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 24D6410E18C; Mon, 5 Jun 2023 07:48:15 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id AA1BF10E18C for ; Mon, 5 Jun 2023 07:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685951292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wy1ybExd+DdkhzJijCZf2robb5n3TSjvDJzl2U7VfoI=; b=K8gJnHc6utf2QG3zsZ3XhSBRxgfIOfF9pRTBPtJBlT9320yccY9N08nHyIJstEZsPrHMID w2398pvgxyihzlDz61yWzrwtN+Ia8Iy2F0S+PgKAubskZCw3IEnAgLO8J8S4Nj1O+fDgrn LJBZRg2Xz34iVQAdiQBtlBRUVDBl58U= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-ymxPIuoHPtauMxE5b-rCfw-1; Mon, 05 Jun 2023 03:48:11 -0400 X-MC-Unique: ymxPIuoHPtauMxE5b-rCfw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f725f64b46so57345675e9.1 for ; Mon, 05 Jun 2023 00:48:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685951290; x=1688543290; 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=Wy1ybExd+DdkhzJijCZf2robb5n3TSjvDJzl2U7VfoI=; b=P/8u7po7odQjtwpxu45UvrvqumGkRbqcP+FecuvoEgjwWsVJ7KsipO9T3oPlY51iv5 KxCcWl5rhkGkaWvQwvYwSInxidRlRguNxZbQl38n4nC8B9Vn+TGKYBV55o6Sg1CxVYS2 Wbo7RFDwTp/hWDIQb2ayUk1ppdrpM/MHqVqOGFXY2KeDkYlKOtiC5hapXTDan8d4SWxc +78lD48CfTgO7mH2Ya8Nu17ZmJAR9PG8JTBRKri6rbzKcYqx5aa0HFV/LRuBK3kqVD9A MWV6OxyYHK4YXgPq45cfi6BySWzaLHpowngR9V/Ex2BtBi81FIvbvyqUffchSuOaV/8K pVUA== X-Gm-Message-State: AC+VfDzUw0cDWs5gmg0wmNkiFA8hHAhwJCKlEcM9ygjPytDTTnbraupX vf6AyLMZnL5BVqZY3jCTpQ/4olBRm211wCwnSyYCsFMaG+ihozpZssWtnV0Y7FvH7OBvR4Mk0/T 4IOGuPB7C+naoSGZziqo4v1p614tY X-Received: by 2002:a05:600c:246:b0:3f6:a66:a36d with SMTP id 6-20020a05600c024600b003f60a66a36dmr6957918wmj.10.1685951290364; Mon, 05 Jun 2023 00:48:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7eFHg9bKquUpdsiK2KD6fy5tNMuQeT4ijXo/E1E9L9E6LlQGTfx9UJ7jtWPmSqTB0TklZmdQ== X-Received: by 2002:a05:600c:246:b0:3f6:a66:a36d with SMTP id 6-20020a05600c024600b003f60a66a36dmr6957906wmj.10.1685951290089; Mon, 05 Jun 2023 00:48:10 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id q21-20020a1ce915000000b003f4fb5532a1sm9715192wmc.43.2023.06.05.00.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 00:48:09 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 2/5] dt-bindings: display: ssd1307fb: Remove default width and height values Date: Mon, 5 Jun 2023 09:47:50 +0200 Message-Id: <20230605074753.562332-3-javierm@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230605074753.562332-1-javierm@redhat.com> References: <20230605074753.562332-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Conor Dooley , Thomas Zimmermann , Krzysztof Kozlowski , Javier Martinez Canillas , Maxime Ripard , Rob Herring , Geert Uytterhoeven , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" A default resolution in the ssd130x driver isn't set to an arbitrary 96x16 anymore. Instead is set to a width and height that's controller dependent. Update DT schema to reflect what the driver does and make its users aware. Signed-off-by: Javier Martinez Canillas --- .../devicetree/bindings/display/solomon,ssd1307fb.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml b/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml index 94bb5ef567c6..e8ed642dc144 100644 --- a/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml +++ b/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml @@ -49,15 +49,15 @@ properties: solomon,height: $ref: /schemas/types.yaml#/definitions/uint32 - default: 16 description: - Height in pixel of the screen driven by the controller + Height in pixel of the screen driven by the controller. + The default value is controller-dependent. solomon,width: $ref: /schemas/types.yaml#/definitions/uint32 - default: 96 description: - Width in pixel of the screen driven by the controller + Width in pixel of the screen driven by the controller. + The default value is controller-dependent. solomon,page-offset: $ref: /schemas/types.yaml#/definitions/uint32 From patchwork Mon Jun 5 07:47:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13267038 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1140FC7EE23 for ; Mon, 5 Jun 2023 07:48:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B5B210E191; Mon, 5 Jun 2023 07:48:16 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9DFA010E18C for ; Mon, 5 Jun 2023 07:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685951293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g4KVF35q3WBd9EqBejhEs82WHdBZCv0emJ0RazkmxtQ=; b=NN9ejo55bj35A2gr0BA4aeWkC0K1wtHnmYj2P1n6KXf5vVhvqDzfWXxdxkkZIBBRN725Vi GgrrXP2rrlAvlMkuJvgunCVv+Q5vJ6ACGTQ6ZOr8LCJtroZiq2J3wlTJcM6oTB2jucB8Fs PiDcaJe5zVV38EA8DE4V6o0QYxx2qXU= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-523-WLLyvvX0OsuEUONyVy0W4Q-1; Mon, 05 Jun 2023 03:48:12 -0400 X-MC-Unique: WLLyvvX0OsuEUONyVy0W4Q-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3f5fa06debcso27094335e9.0 for ; Mon, 05 Jun 2023 00:48:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685951291; x=1688543291; 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=g4KVF35q3WBd9EqBejhEs82WHdBZCv0emJ0RazkmxtQ=; b=SqPFof2B9kZ06lqA/CxDlRaIJ2hkagmMMzqxlgP6yvXg3bHeB9FbaNOJi42XrGT9vw Z5Z9gArdJXu0dyoAm0Ps7EyjZRjUXkL4O0MLbAeIvNmCO7cyQ0VAPams1eaybCQAYSZQ 9sgoCg0ZBNSHILX7Nn5SqhEdMI1NE1cJdQUcMqUTRqa8I76Zey25MWcvzhspnG6AhxaP 2Rn5L+dv/m9NVzYA843tPwR0IiYN+G99MuPAunUcqPs6+qR/Mau9dPkgVx2mO+2BOqNO xKkdFRJVYuvjz4NfmOjwucZ4N5f9f3Uk9Zm6iL4Kd6dO9Z8VMaOpIpPJ2Pj2HRURJFCo eXrw== X-Gm-Message-State: AC+VfDzDoRLbQ0lz286U+eMoLfBvKqmZ0bN1w8DLmVmmob2YT9U6/OGv +pSJ3dnvb9YYWlUeTJxNYp+f7CAoEayXGugsQPkyJzzVvH6NiT/DZCb4Aghm8ocXzGxG1BxRdXf zI51yqWqSyGC9gxy9jIelz2oYpjnR X-Received: by 2002:a1c:cc06:0:b0:3f6:cf3:dba8 with SMTP id h6-20020a1ccc06000000b003f60cf3dba8mr6585878wmb.34.1685951291592; Mon, 05 Jun 2023 00:48:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5uUoaBIg2ErX2rEl1Ihe8Mg/m56SNQQp37Cn9eD4HysfFWzxkC30GePmgb+XQHaSfZx9srPQ== X-Received: by 2002:a1c:cc06:0:b0:3f6:cf3:dba8 with SMTP id h6-20020a1ccc06000000b003f60cf3dba8mr6585872wmb.34.1685951291413; Mon, 05 Jun 2023 00:48:11 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id q21-20020a1ce915000000b003f4fb5532a1sm9715192wmc.43.2023.06.05.00.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 00:48:11 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 3/5] drm/ssd130x: Set the page height value in the device info data Date: Mon, 5 Jun 2023 09:47:51 +0200 Message-Id: <20230605074753.562332-4-javierm@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230605074753.562332-1-javierm@redhat.com> References: <20230605074753.562332-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , Javier Martinez Canillas , Maxime Ripard , Geert Uytterhoeven , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The driver only supports OLED controllers that have a page height of 8 but there are devices that have different page heights. So it is better to not hardcode this value and instead have it as a per controller data value. Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/solomon/ssd130x.c | 15 +++++++++++---- drivers/gpu/drm/solomon/ssd130x.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c index a0e5e26c0bc9..5cac1149e34e 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -102,6 +102,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { .default_width = 132, .default_height = 64, .page_mode_only = 1, + .page_height = 8, }, [SSD1305_ID] = { .default_vcomh = 0x34, @@ -109,6 +110,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { .default_dclk_frq = 7, .default_width = 132, .default_height = 64, + .page_height = 8, }, [SSD1306_ID] = { .default_vcomh = 0x20, @@ -117,6 +119,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { .need_chargepump = 1, .default_width = 128, .default_height = 64, + .page_height = 8, }, [SSD1307_ID] = { .default_vcomh = 0x20, @@ -125,6 +128,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { .need_pwm = 1, .default_width = 128, .default_height = 39, + .page_height = 8, }, [SSD1309_ID] = { .default_vcomh = 0x34, @@ -132,6 +136,7 @@ const struct ssd130x_deviceinfo ssd130x_variants[] = { .default_dclk_frq = 10, .default_width = 128, .default_height = 64, + .page_height = 8, } }; EXPORT_SYMBOL_NS_GPL(ssd130x_variants, DRM_SSD130X); @@ -437,7 +442,8 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf, 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 pages = DIV_ROUND_UP(height, 8); + unsigned int page_height = ssd130x->device_info->page_height; + unsigned int pages = DIV_ROUND_UP(height, page_height); struct drm_device *drm = &ssd130x->drm; u32 array_idx = 0; int ret, i, j, k; @@ -559,16 +565,17 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_m struct drm_rect *rect) { struct ssd130x_device *ssd130x = drm_to_ssd130x(fb->dev); + unsigned int page_height = ssd130x->device_info->page_height; struct iosys_map dst; unsigned int dst_pitch; int ret = 0; u8 *buf = NULL; /* Align y to display page boundaries */ - rect->y1 = round_down(rect->y1, 8); - rect->y2 = min_t(unsigned int, round_up(rect->y2, 8), ssd130x->height); + rect->y1 = round_down(rect->y1, page_height); + rect->y2 = min_t(unsigned int, round_up(rect->y2, page_height), ssd130x->height); - dst_pitch = DIV_ROUND_UP(drm_rect_width(rect), 8); + dst_pitch = DIV_ROUND_UP(drm_rect_width(rect), page_height); buf = kcalloc(dst_pitch, drm_rect_height(rect), GFP_KERNEL); if (!buf) return -ENOMEM; diff --git a/drivers/gpu/drm/solomon/ssd130x.h b/drivers/gpu/drm/solomon/ssd130x.h index a2bc8d75078b..87968b3e7fb8 100644 --- a/drivers/gpu/drm/solomon/ssd130x.h +++ b/drivers/gpu/drm/solomon/ssd130x.h @@ -39,6 +39,7 @@ struct ssd130x_deviceinfo { u32 default_dclk_frq; u32 default_width; u32 default_height; + u32 page_height; int need_pwm; int need_chargepump; bool page_mode_only; From patchwork Mon Jun 5 07:47:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13267040 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B825C7EE23 for ; Mon, 5 Jun 2023 07:48:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E5CBB10E19A; Mon, 5 Jun 2023 07:48:20 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 632E510E192 for ; Mon, 5 Jun 2023 07:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685951296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jb5ZBNmOsLwdAeIIsEiIHMvr3a3yTgXtkOj9ysBMgic=; b=DD3ihL52n160gaBZ9EsArywXRe/xtsSv6PHlHqkc5PB6WHu8GSwzpM+5cF5P08zS9dnh+y ix2F3iFT2up/54whEDLhnojRMI4LP6BuhlFZOJqEsjZGzaonxcTuT3KuOW8cnY5lcPYS/I +jeR4FgWST7Syrzbk3sMIKwE+nyr6zs= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-458-9io4ftpKP1WRwgBVl60emA-1; Mon, 05 Jun 2023 03:48:15 -0400 X-MC-Unique: 9io4ftpKP1WRwgBVl60emA-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-4edc5526c5fso2866310e87.2 for ; Mon, 05 Jun 2023 00:48:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685951293; x=1688543293; 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=Jb5ZBNmOsLwdAeIIsEiIHMvr3a3yTgXtkOj9ysBMgic=; b=RoTG3Lnbv1EDzIz5oV7kNO3zCeQxF3KFP37gnS14wzbNv0H9GIGVNaUl3uPzDgQ1IN Q07C7lPKWmeTOeIiaRFu1qvpg97TkH9nrGmAAT/Htq22gTdASi+vTwrGEH8LdEbtsHsw lU9yR53pS3fjT4dIHAzfe8RYsvNaKjLlmmmlSD1wCbd4gWvz1Cww9Du3V13NX+WS89+F uaaKiI5/reF9RZqN4zbNVmwBbWgl5s91+UIYOe3lTM6mOlT7XCTU6JavnazyQx0zBiHJ AQCaTpXS/f0iuxVW7fJ9B1ewKNA2zwO5KTEvaUx+dDS+4u+XtAzQxDtak/3+V/bXM3b7 /z5w== X-Gm-Message-State: AC+VfDy3W2aofxBwMdUoG870jyhSuDIlK+wgxp0etTf+v4BuRBBe/7iK /HnFOTOrlRiyVNCHWsNu3oYGQ4ElOOSMpY2znmUMA4sgmbjR1X6JLx66bW0Kx1H0EIOJqUPotWd zKbZh38dyJxx7A2LX30O0xVnL/dNo X-Received: by 2002:a05:6512:24b:b0:4f2:5aae:937 with SMTP id b11-20020a056512024b00b004f25aae0937mr5246337lfo.64.1685951293667; Mon, 05 Jun 2023 00:48:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7bqR8PicwO8eChYyt0UvbKtzS7nL0qmlSCkFqy6xk6A9Rh2IHMPd0RSsywg3FEcXJyOuukLA== X-Received: by 2002:a05:6512:24b:b0:4f2:5aae:937 with SMTP id b11-20020a056512024b00b004f25aae0937mr5246326lfo.64.1685951293248; Mon, 05 Jun 2023 00:48:13 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id q21-20020a1ce915000000b003f4fb5532a1sm9715192wmc.43.2023.06.05.00.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 00:48:12 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 4/5] drm/ssd130x: Don't allocate buffers on each plane update Date: Mon, 5 Jun 2023 09:47:52 +0200 Message-Id: <20230605074753.562332-5-javierm@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230605074753.562332-1-javierm@redhat.com> References: <20230605074753.562332-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , Javier Martinez Canillas , Maxime Ripard , Geert Uytterhoeven , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The resolutions for these panels are fixed and defined in the Device Tree, so there's no point to allocate the buffers on each plane update and that can just be done once. Let's do the allocation and free on the encoder enable and disable helpers since that's where others initialization and teardown operations are done. Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/solomon/ssd130x.c | 88 +++++++++++++++++++------------ drivers/gpu/drm/solomon/ssd130x.h | 3 ++ 2 files changed, 56 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c index 5cac1149e34e..0be3b476dc60 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -146,6 +146,31 @@ static inline struct ssd130x_device *drm_to_ssd130x(struct drm_device *drm) return container_of(drm, struct ssd130x_device, drm); } +static int ssd130x_buf_alloc(struct ssd130x_device *ssd130x) +{ + unsigned int page_height = ssd130x->device_info->page_height; + unsigned int pages = DIV_ROUND_UP(ssd130x->height, page_height); + + ssd130x->buffer = kcalloc(DIV_ROUND_UP(ssd130x->width, 8), + ssd130x->height, GFP_KERNEL); + if (!ssd130x->buffer) + return -ENOMEM; + + ssd130x->data_array = kcalloc(ssd130x->width, pages, GFP_KERNEL); + if (!ssd130x->data_array) { + kfree(ssd130x->buffer); + return -ENOMEM; + } + + return 0; +} + +static void ssd130x_buf_free(struct ssd130x_device *ssd130x) +{ + kfree(ssd130x->data_array); + kfree(ssd130x->buffer); +} + /* * Helper to write data (SSD130X_DATA) to the device. */ @@ -434,11 +459,12 @@ static int ssd130x_init(struct ssd130x_device *ssd130x) SSD130X_SET_ADDRESS_MODE_HORIZONTAL); } -static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf, - struct drm_rect *rect) +static int ssd130x_update_rect(struct ssd130x_device *ssd130x, struct drm_rect *rect) { unsigned int x = rect->x1; unsigned int y = rect->y1; + u8 *buf = ssd130x->buffer; + u8 *data_array = ssd130x->data_array; unsigned int width = drm_rect_width(rect); unsigned int height = drm_rect_height(rect); unsigned int line_length = DIV_ROUND_UP(width, 8); @@ -447,14 +473,9 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf, struct drm_device *drm = &ssd130x->drm; u32 array_idx = 0; int ret, i, j, k; - u8 *data_array = NULL; drm_WARN_ONCE(drm, y % 8 != 0, "y must be aligned to screen page\n"); - data_array = kcalloc(width, pages, GFP_KERNEL); - if (!data_array) - return -ENOMEM; - /* * The screen is divided in pages, each having a height of 8 * pixels, and the width of the screen. When sending a byte of @@ -488,11 +509,11 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf, /* Set address range for horizontal addressing mode */ ret = ssd130x_set_col_range(ssd130x, ssd130x->col_offset + x, width); if (ret < 0) - goto out_free; + return ret; ret = ssd130x_set_page_range(ssd130x, ssd130x->page_offset + y / 8, pages); if (ret < 0) - goto out_free; + return ret; } for (i = 0; i < pages; i++) { @@ -522,11 +543,11 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf, ssd130x->page_offset + i, ssd130x->col_offset + x); if (ret < 0) - goto out_free; + return ret; ret = ssd130x_write_data(ssd130x, data_array, width); if (ret < 0) - goto out_free; + return ret; array_idx = 0; } @@ -536,14 +557,11 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf, if (!ssd130x->page_address_mode) ret = ssd130x_write_data(ssd130x, data_array, width * pages); -out_free: - kfree(data_array); return ret; } static void ssd130x_clear_screen(struct ssd130x_device *ssd130x) { - u8 *buf = NULL; struct drm_rect fullscreen = { .x1 = 0, .x2 = ssd130x->width, @@ -551,14 +569,7 @@ static void ssd130x_clear_screen(struct ssd130x_device *ssd130x) .y2 = ssd130x->height, }; - buf = kcalloc(DIV_ROUND_UP(ssd130x->width, 8), ssd130x->height, - GFP_KERNEL); - if (!buf) - return; - - ssd130x_update_rect(ssd130x, buf, &fullscreen); - - kfree(buf); + ssd130x_update_rect(ssd130x, &fullscreen); } static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_map *vmap, @@ -569,30 +580,27 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_m struct iosys_map dst; unsigned int dst_pitch; int ret = 0; - u8 *buf = NULL; + u8 *buf = ssd130x->buffer; + + if (!buf) + return 0; /* Align y to display page boundaries */ rect->y1 = round_down(rect->y1, page_height); rect->y2 = min_t(unsigned int, round_up(rect->y2, page_height), ssd130x->height); dst_pitch = DIV_ROUND_UP(drm_rect_width(rect), page_height); - buf = kcalloc(dst_pitch, drm_rect_height(rect), GFP_KERNEL); - if (!buf) - return -ENOMEM; ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE); if (ret) - goto out_free; + return ret; iosys_map_set_vaddr(&dst, buf); drm_fb_xrgb8888_to_mono(&dst, &dst_pitch, vmap, fb, rect); drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE); - ssd130x_update_rect(ssd130x, buf, rect); - -out_free: - kfree(buf); + ssd130x_update_rect(ssd130x, rect); return ret; } @@ -701,14 +709,22 @@ static void ssd130x_encoder_helper_atomic_enable(struct drm_encoder *encoder, return; ret = ssd130x_init(ssd130x); - if (ret) { - ssd130x_power_off(ssd130x); - return; - } + if (ret) + goto power_off; + + ret = ssd130x_buf_alloc(ssd130x); + if (ret) + goto power_off; ssd130x_write_cmd(ssd130x, 1, SSD130X_DISPLAY_ON); backlight_enable(ssd130x->bl_dev); + + return; + +power_off: + ssd130x_power_off(ssd130x); + return; } static void ssd130x_encoder_helper_atomic_disable(struct drm_encoder *encoder, @@ -721,6 +737,8 @@ static void ssd130x_encoder_helper_atomic_disable(struct drm_encoder *encoder, ssd130x_write_cmd(ssd130x, 1, SSD130X_DISPLAY_OFF); + ssd130x_buf_free(ssd130x); + ssd130x_power_off(ssd130x); } diff --git a/drivers/gpu/drm/solomon/ssd130x.h b/drivers/gpu/drm/solomon/ssd130x.h index 87968b3e7fb8..161588b1cc4d 100644 --- a/drivers/gpu/drm/solomon/ssd130x.h +++ b/drivers/gpu/drm/solomon/ssd130x.h @@ -89,6 +89,9 @@ struct ssd130x_device { u8 col_end; u8 page_start; u8 page_end; + + u8 *buffer; + u8 *data_array; }; extern const struct ssd130x_deviceinfo ssd130x_variants[]; From patchwork Mon Jun 5 07:47:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13267041 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E50FEC7EE2E for ; Mon, 5 Jun 2023 07:48:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CA1AA10E1AE; Mon, 5 Jun 2023 07:48:21 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6CDA10E192 for ; Mon, 5 Jun 2023 07:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685951297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JkfyBiLVG0HjTgYBw5BL2+2f7LnDXq371QsA6cUQbfY=; b=hzJ3QXn/gjWqCMKo9vH0b2p4GfyXY5FjInM/Dw2E9+M+edtzK63ZCnnt+GhUrX6nwkq7lf v5LQ0gMuiCpwGMZzh0s4sdVuxXdozNZVJrKc2rtkTnhCXK6asflCb2kCHwmUb6bMFiLY0h 0qzX46f8/g7VGQA+POUllIShrYK5cUY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-597-Z5QqDHzvMri-OhPPMi6a5Q-1; Mon, 05 Jun 2023 03:48:15 -0400 X-MC-Unique: Z5QqDHzvMri-OhPPMi6a5Q-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f5df65f9f4so21889695e9.2 for ; Mon, 05 Jun 2023 00:48:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685951294; x=1688543294; 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=JkfyBiLVG0HjTgYBw5BL2+2f7LnDXq371QsA6cUQbfY=; b=k5wmIScIgszzQuc78Zvcgpg4YwNXprjp/BE7MoVK2jxMF/PbiOfj5on+hRh9CXYAvT blZUk5l6g0gT9HwBi6I8gLPKjEoBmlGVLJTQROdBGW5BBev+KKNmqocdNf590cClxg93 gQ+fozxcobgp0TSWEDoO9eArpYXhxOSZ/e4itI780jTz5c+uFHmEuui+5gbs4d6zWkBd wiSMla/07/3xlybad0HWyGSZPj616k6lCXNqVy7uk/U0gg3f1ONLfScE2dq+Q8pManJR /tOlulZOcHOh96/hWUyOgk5VblyoW0cjyg8xJdHzoFLrcLMB2RpVf9d0Wt2x7abw0YP3 xV+Q== X-Gm-Message-State: AC+VfDxKFNWgE2MqXanic0ADnNSsOOVx2mZ/qATLJ2aYiGMwpgTJPmvh S1k3XxzOjbW8zZyD8m14Be/Rwurqv7fZm13pPoJt6/7PsyWZPWxTparLYfT0NTYls2abiqEVBWu zEv4KkBi1uOQD/yeU5uKpdoKJWvLy X-Received: by 2002:a1c:7705:0:b0:3f4:2897:4eb7 with SMTP id t5-20020a1c7705000000b003f428974eb7mr6150063wmi.38.1685951294651; Mon, 05 Jun 2023 00:48:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5lQbDXqEhzDQtCOm3eBqsPv8QaZ/hSWBzIQiuedzRf86vjl1o6k2bXEStnJY2w/EfQS4x/HQ== X-Received: by 2002:a1c:7705:0:b0:3f4:2897:4eb7 with SMTP id t5-20020a1c7705000000b003f428974eb7mr6150051wmi.38.1685951294488; Mon, 05 Jun 2023 00:48:14 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id q21-20020a1ce915000000b003f4fb5532a1sm9715192wmc.43.2023.06.05.00.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 00:48:13 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 5/5] drm/ssd130x: Remove hardcoded bits-per-pixel in ssd130x_buf_alloc() Date: Mon, 5 Jun 2023 09:47:53 +0200 Message-Id: <20230605074753.562332-6-javierm@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230605074753.562332-1-javierm@redhat.com> References: <20230605074753.562332-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , Javier Martinez Canillas , Maxime Ripard , Geert Uytterhoeven , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The driver only supports OLED controllers that have a native DRM_FORMAT_C1 pixel format and that is why it has harcoded a division of the width by 8. But the driver might be extended to support devices that have a different pixel format. So it's better to use the struct drm_format_info helpers to compute the size of the buffer, used to store the pixels in native format. Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/solomon/ssd130x.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c index 0be3b476dc60..b3dc1ca9dc10 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -150,9 +150,16 @@ static int ssd130x_buf_alloc(struct ssd130x_device *ssd130x) { unsigned int page_height = ssd130x->device_info->page_height; unsigned int pages = DIV_ROUND_UP(ssd130x->height, page_height); + const struct drm_format_info *fi; + unsigned int pitch; - ssd130x->buffer = kcalloc(DIV_ROUND_UP(ssd130x->width, 8), - ssd130x->height, GFP_KERNEL); + fi = drm_format_info(DRM_FORMAT_C1); + if (!fi) + return -EINVAL; + + pitch = drm_format_info_min_pitch(fi, 0, ssd130x->width); + + ssd130x->buffer = kcalloc(pitch, ssd130x->height, GFP_KERNEL); if (!ssd130x->buffer) return -ENOMEM;