From patchwork Fri Jun 9 17:09:36 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: 105738 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1067039vqr; Fri, 9 Jun 2023 10:20:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YEKzVHX3QxEGPNEbwHSm2qMsSQ3c85d8AD0oPXYaMak0YmpKJIIG6a4zPxd9sdZCkUMSw X-Received: by 2002:a17:90a:1d1:b0:253:34da:487 with SMTP id 17-20020a17090a01d100b0025334da0487mr1618746pjd.35.1686331225282; Fri, 09 Jun 2023 10:20:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686331225; cv=none; d=google.com; s=arc-20160816; b=MXaT6p4Nx0PcWnCUl0NjV2ZovVJur670jLoyOscpPallpFWrTN1z/wkDmmo5O9QlU/ rA3eK5IdJMYFvOxzwOfSYW+5Ksh8gflUeebg4B3dTIUv24bT7LkHhv1RbLW6z5poOmrS dFa3YSi1Md+2wOW0CyE8rs+wHM9q2knOmws2+lePFA9oqfToL1PnEso0OVLphXzFrUvS iRVKs1wnH8hIKEH4RwofuHcJ1xJJqRo43O4EyLvJyhPuBEzz6kdqGoAs7ATCyBeJtCEz elnpB5KUOfhupvSL3vX+MS3KJ/Wa/5goWKg5o0M+ZapUSsGuCF2e8rbAPMYkHwdh1unV ygdQ== 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 :dkim-signature; bh=WyUw3HGVpJG+fchnm3dK6kO6DBjp5MZOwzGlWiysi+E=; b=dbtbzdIyW6zafMpGh2rKmVbjVVkk62GRQYRdoz3Fi9k7jbGtisEjBGvf9F2GpjpYs+ Vdl6ysaOmqatMzhp9Jo9eQTZyz+SGT97gT5xRBphro7x+ge+I4VWTH84ZquYLxinRQkN jXGP3geEgvp9mE9IdelGxA/gMuzPXo+2nZumSJUQ6nlQ7ilnL27dSg+iYW5GTjBw/6B2 8TXudUrlV3Qinp/W58H9kSLD3aZgEkL5xD2NMreDINSKAaZ8cPsY8Mc5Fbfhdi4zX5A5 iR4pT/gcZXvuZldWxs4D5kbwCaLlqjhkDJ7NYaHdWdQsg8tAtaflMYlj6i0U0UqO+4FP 3oug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="apb1Q/H8"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm13-20020a17090afa0d00b0025935dba5e7si3031908pjb.115.2023.06.09.10.20.10; Fri, 09 Jun 2023 10:20:25 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="apb1Q/H8"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230160AbjFIRKj (ORCPT + 99 others); Fri, 9 Jun 2023 13:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjFIRKd (ORCPT ); Fri, 9 Jun 2023 13:10:33 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 012833595 for ; Fri, 9 Jun 2023 10:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686330589; 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=WyUw3HGVpJG+fchnm3dK6kO6DBjp5MZOwzGlWiysi+E=; b=apb1Q/H8he3G8sf6ufnpJr06HFhj8Qujv+lYzkyDFc3n1vvc92GAaRRC2Z1AL8/58i2av4 RhZcDIjIsnfiAvDtYxYOG2lmkiOQ4i4YxsavR9uPLzJn/MH+joUG7c/PQLSogAIgQjaoBh Bg996tSduQq8Borpzst3rNSLqWveIR4= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-43-FwID7dYfMl2QHCNHNlkzDQ-1; Fri, 09 Jun 2023 13:09:48 -0400 X-MC-Unique: FwID7dYfMl2QHCNHNlkzDQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3f41a04a297so9497345e9.3 for ; Fri, 09 Jun 2023 10:09:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686330586; x=1688922586; 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=WyUw3HGVpJG+fchnm3dK6kO6DBjp5MZOwzGlWiysi+E=; b=jMEPFE+txvNXVIKNEYutPz2rUzxU/f1prK9VTL1zcweJyAB2N/oCuE7DD7CM63j0g/ rl6b4To6hVS7EuqWiKRj5H75rmclx0m+e3V/IiRTCLMAFRZeKIwagQUVh5digVunt/nU jZ0h2Ea05ItF5pDsLqD92naarFeO9SWZxpJ0NFZjYLJmnEftv2uk2n9AXdv7ceARK+d8 3yOLj2A0wTtP3U59rK8NsRY7HwNHQWJ6n8Vv+AZVMD+RtIu/cMJ9kYR1UZtLNosT6Jn/ Hc4fUimYXx03lOKMAf34vOxRaStnSLL/4chxSNI3cHXMwnWkUmLlZx4lVeE+sXDs7+gm Zvbg== X-Gm-Message-State: AC+VfDwUzqmFD1te2h/ACYLxRLmvZv4SyjO2cLv4+KTMhUwuxpXJJSSx M9l4D2OwB9279VL+sFF3c/erEXPwUfdxO9kXONiZKoRAAHi0odHnZtKSenK7/uFfLnRqNfrDaC6 Kz/ITvZKdzPRvD4CQJ+yIE0JxRTAGzcIHmFIsKYOploOqobIiWd9OeKsWSRN5nBmcLGF9Pr72t9 QDqGNLIAw= X-Received: by 2002:a05:600c:290:b0:3f7:3991:e128 with SMTP id 16-20020a05600c029000b003f73991e128mr1326611wmk.2.1686330586505; Fri, 09 Jun 2023 10:09:46 -0700 (PDT) X-Received: by 2002:a05:600c:290:b0:3f7:3991:e128 with SMTP id 16-20020a05600c029000b003f73991e128mr1326590wmk.2.1686330586233; Fri, 09 Jun 2023 10:09:46 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm3265526wmr.2.2023.06.09.10.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:09:45 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Geert Uytterhoeven , Thomas Zimmermann , Maxime Ripard , Javier Martinez Canillas , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/5] drm/ssd130x: Make default width and height to be controller dependent Date: Fri, 9 Jun 2023 19:09:36 +0200 Message-Id: <20230609170941.1150941-2-javierm@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609170941.1150941-1-javierm@redhat.com> References: <20230609170941.1150941-1-javierm@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768246450712227066?= X-GMAIL-MSGID: =?utf-8?q?1768246450712227066?= 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 - SSD1305: 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 Reviewed-by: Thomas Zimmermann --- (no changes since v1) 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 Fri Jun 9 17:09:37 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: 105741 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1070894vqr; Fri, 9 Jun 2023 10:27:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ47YzdIIDPHJB5RMiTkAzlPYzJUmZHiQxZEi4WRpqPNyBpvBYAHeA53z5xzrtQvYWJekKAe X-Received: by 2002:a05:6a20:a11a:b0:114:af27:41dd with SMTP id q26-20020a056a20a11a00b00114af2741ddmr1721068pzk.34.1686331677000; Fri, 09 Jun 2023 10:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686331676; cv=none; d=google.com; s=arc-20160816; b=uHn8+aq2GsvADKSAU8fjy4dh6DLVwhCYsum/oM3ho1oRrbIImHd1K+7sMYCkkGGZbj 1yM9Xc8t4K/VO038KS6PlfPp+L8QLFvLNcAhNLG3/VKk44YT4iRT/n9Vgl3k9Eh93k6G sOdBGd6YuxhhT4MlYBn9+Qa3YlbrSvkp3vO/3UYkNOIteyPnerm82TT3LZbzuPCoNG12 es3jpNOvBWvUcsKEb3SXk7K8MpxxSzH3So4DBocXHY0GrFQgV3iuINkJ07jFbaT3B0gd pS4pBC+riA5VEZMcLhQXu29lQxIha9fXb9IZmm13MILoiQ11BlLz+NYLxtbwD5WoY2Z5 ajdA== 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 :dkim-signature; bh=rXfuy13isQUH9meYMWRMilnarujeOibtxjp5Z2EnlHc=; b=OidGVLv3hWpASltqHBv74Y+WuC8kHcX4i9ZUptrFm/+QztU/j+KxpjqCYp8cviPjXz uRjMLmP9dY6FpKD02u82Rpl572gnYc+xsZK720QW0mgjJzHgsrD3bzRLbNYAJ2m3Zzen NXN45DCj1Wmr1j/ZE4oFKdi/jzzETDbtaIr85sUdpLmBQrXrGP8LeGsjeHlZ7fyT2K6m qbPBReCAfaSsZ4Fpb4W+mS3nKOfDFuzKeGqzVeC3TFkY/AjdvjtXbyCjShQKWu6DWQMZ RGMU7pKyGhHgeI6ClKqxSv40jEdbIRu/JCQ3K3W3uaBSGIIUB4vjykSnew1edPveG6CE 3otw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QueaOLzf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lg16-20020a170902fb9000b001ae0691dfdbsi2911982plb.158.2023.06.09.10.27.44; Fri, 09 Jun 2023 10:27:56 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QueaOLzf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230191AbjFIRKn (ORCPT + 99 others); Fri, 9 Jun 2023 13:10:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbjFIRKi (ORCPT ); Fri, 9 Jun 2023 13:10:38 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B7323598 for ; Fri, 9 Jun 2023 10:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686330591; 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=rXfuy13isQUH9meYMWRMilnarujeOibtxjp5Z2EnlHc=; b=QueaOLzfaq011vSgiz156s3ulnthgprx2xESQE3VEgagBGxtKEyruk3Gn9LAuS92KseXnD 15acIupvEoqFZHtDRtu1aCL80+WMwnn9Wyb5ICDDLdHZSsoCmGBQqkMxOpNFcqfOfO4hDk yCMxxMHjYzFVlgkGum34ecoQtV5EVXw= 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-235-SnrMtooqNIqdV3lWPxTuTA-1; Fri, 09 Jun 2023 13:09:49 -0400 X-MC-Unique: SnrMtooqNIqdV3lWPxTuTA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f725f64b46so32544525e9.1 for ; Fri, 09 Jun 2023 10:09:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686330588; x=1688922588; 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=rXfuy13isQUH9meYMWRMilnarujeOibtxjp5Z2EnlHc=; b=hWLN7r8dAEL+cDS2WsLC4l7nCvV3exEOb9eSK1urleI29aV1QqG3gAxO6g2EGUXGxq HK9TDLVojQAlBamfMNvNox15x3CG6E/dchIjqL5i2HXjF0dx4LQhTa4Ykk2t+fgdPYaz y75fdzrm/6X3O3OG3zvRJ094tedfbVNTvpsuzf13nBsn+ofNJtwJ9TfDJWno8C+UT9V1 keqWSFe7V6tYxnnrDQ1m1kYKcvGtxK/Av1loY9bmYtmCB2fyam2Gw605oFyRwFIDSO/W b9koocOlPTf/HSKWZAPoGIMmrZdm3psZVrqkFTmKILzHZFpFE3N+R4N6Z6yVJMlRRr40 dDsQ== X-Gm-Message-State: AC+VfDzCzlQaxfBLHTieuw8l+PegAPcGXkI1K8+1BAv0myeoUy1rrZiU NLFE2Pf6TVYOxrfoVLxEjcIM6nMj91x7L2qzCaMa7/SlHuWwzjd25BxKwL6SVs0yo6C0ZsqxnBt 0VZTkYqejNrtMaDwfNNf+sC0ay8sJnFBp8phVj4z21XWx0NgZfTV/mI3JSmFzvlK4YjQc1cl9SE lbR9LNP/E= X-Received: by 2002:a05:600c:2297:b0:3f7:f544:4993 with SMTP id 23-20020a05600c229700b003f7f5444993mr1713202wmf.20.1686330588102; Fri, 09 Jun 2023 10:09:48 -0700 (PDT) X-Received: by 2002:a05:600c:2297:b0:3f7:f544:4993 with SMTP id 23-20020a05600c229700b003f7f5444993mr1713180wmf.20.1686330587766; Fri, 09 Jun 2023 10:09:47 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm3265526wmr.2.2023.06.09.10.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:09:47 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Geert Uytterhoeven , Thomas Zimmermann , Maxime Ripard , Javier Martinez Canillas , Conor Dooley , Daniel Vetter , David Airlie , Krzysztof Kozlowski , Rob Herring , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/5] dt-bindings: display: ssd1307fb: Remove default width and height values Date: Fri, 9 Jun 2023 19:09:37 +0200 Message-Id: <20230609170941.1150941-3-javierm@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609170941.1150941-1-javierm@redhat.com> References: <20230609170941.1150941-1-javierm@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768246924577689061?= X-GMAIL-MSGID: =?utf-8?q?1768246924577689061?= 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. The datasheets for the chips describes the following display resolutions: - SH1106: 132 x 64 Dot Matrix OLED/PLED - SSD1305: 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 Update DT schema to reflect what the driver does and make its users aware. Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann --- Changes in v2: - List per controller default width/height values in DT schema (Maxime Ripard). .../bindings/display/solomon,ssd1307fb.yaml | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml b/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml index 94bb5ef567c6..20e2bd15d4d2 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 @@ -157,6 +157,10 @@ allOf: const: sinowealth,sh1106 then: properties: + width: + default: 132 + height: + default: 64 solomon,dclk-div: default: 1 solomon,dclk-frq: @@ -171,6 +175,10 @@ allOf: - solomon,ssd1305 then: properties: + width: + default: 132 + height: + default: 64 solomon,dclk-div: default: 1 solomon,dclk-frq: @@ -185,6 +193,10 @@ allOf: - solomon,ssd1306 then: properties: + width: + default: 128 + height: + default: 64 solomon,dclk-div: default: 1 solomon,dclk-frq: @@ -199,6 +211,10 @@ allOf: - solomon,ssd1307 then: properties: + width: + default: 128 + height: + default: 39 solomon,dclk-div: default: 2 solomon,dclk-frq: @@ -215,6 +231,10 @@ allOf: - solomon,ssd1309 then: properties: + width: + default: 128 + height: + default: 64 solomon,dclk-div: default: 1 solomon,dclk-frq: From patchwork Fri Jun 9 17:09:38 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: 105740 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1068005vqr; Fri, 9 Jun 2023 10:22:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/vD4xsludrt2SFGM+fnOWXxQmHY4ANt2UU5rPZMPcwZIfX/OPiFNDfQRX7nSYuACkS9mO X-Received: by 2002:a17:90a:4104:b0:259:9b2b:e15f with SMTP id u4-20020a17090a410400b002599b2be15fmr1518067pjf.8.1686331333272; Fri, 09 Jun 2023 10:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686331333; cv=none; d=google.com; s=arc-20160816; b=i8/FfpBJE7N1wmZvUG0emBOXvyNzox5HxGZ6O+f+wY+4CH3zUWViGHb0tVd5U9RkgT xe+7TQy7X7g8g2XKAfTJJJpi7/LeISyg+h/CzKRUFans2bf9bm6Ng/27XuvQNHvA5o5m gu6WORoOzQ+K5XfwFirLJXtzX5oBGl+OIkXZPLT6HVvbeW7pRAKAiBi8x7l71NshFCSb ynLrp/EvYtWQg/aqruJqcGSxok7KSM0BbQDhNMLx7vkTRIocVOKKnxiaudpsv2BcMhms Yn2sUEZEPkmGkWU7ob1/86U5lAmaqzqxOQ42ZBPwxWSQ/KaCCqn895qFVZLh04ciKVI9 w0cg== 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 :dkim-signature; bh=Jdi1ahNEpgpsHvIKoDJGTzIDYZ+gLZdkQID+ItWX/g4=; b=KaoLxzpw27SXi9thI2laZoW5qb8N3wKEO8fQeOYkVcwZqk1VILVt+HjN9Ybzjjr+Fh 8bVci+siGrXmIU32RcmY34LgCqCSrzlMTMYy7yCchECv0wPjK+lcTa2hiiY7b0HZjuVZ AIWfoF/hBK9XrcgSvjxvpUEdnrYQ7+0Ea1l6HvDo0Wn7eGIOf9L3qufV4m7UaDiylFMI 3selxfMcy7sh0h1TeAJaYrC2nZOHwQfbzZ1fIm0J2hoxGdbOV6hgDztUfveNgVtiiZgu PdGHeVe5R9o6n81uzabpTSO55lsk6LwP1xZVbgjVIdoto+LZlzSvp39k/kMQQk59raDi 0SjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="CZBgk98/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rj14-20020a17090b3e8e00b00250d10c6fe7si69824pjb.67.2023.06.09.10.21.59; Fri, 09 Jun 2023 10:22:13 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="CZBgk98/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbjFIRKh (ORCPT + 99 others); Fri, 9 Jun 2023 13:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbjFIRKd (ORCPT ); Fri, 9 Jun 2023 13:10:33 -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 E70AB3A8C for ; Fri, 9 Jun 2023 10:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686330592; 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=Jdi1ahNEpgpsHvIKoDJGTzIDYZ+gLZdkQID+ItWX/g4=; b=CZBgk98/RWvnAhp/bjF+uLk8Y6svAVbF4yVcWEXerOJnTG/vOxOaPSiyJMb6hm2NIp8CX5 NKty/oNtb5CrxBAstUfzxf/It50HVRbz8TsULvlUwuQy3LuT9Gc7y8f87hDUlTJqcJ8VRZ kNvlQ0c7Lx/CG7HIGwRE5NUlMz9HVWE= 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-342-ySsOBsUtPdyA0hdmLO4Avg-1; Fri, 09 Jun 2023 13:09:51 -0400 X-MC-Unique: ySsOBsUtPdyA0hdmLO4Avg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f7e7cfcae4so11173215e9.1 for ; Fri, 09 Jun 2023 10:09:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686330589; x=1688922589; 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=Jdi1ahNEpgpsHvIKoDJGTzIDYZ+gLZdkQID+ItWX/g4=; b=Ok4VSyX07Qg//N8/6y0UqZENdS6w7UPzAPLph57tre+UZ/c+urWfF7/C8XJEWDCyVM FfqWFd6IZjA57BQwJdl7pPrMXmGxnQN6wCFiiwpiihubPCnBVWLnxI5MSZ4Cz0e4IENO IArRCD6kCUFepyt0flF8d6gRmHcPeR24+N/yzWAK7GqIyt4jK+462h3vVskHnTuH9TBC 1gcG3v5Y5Cw50wK6Z+guR62CJBVqrVsWzmT9hVFrVLBC1nmly3FJldtbI9En/E671mxX ugAz1xv3VI2l5cahSwrAgRPYO7osf59FDbEpviPgtX4iz5C+TgDLQDF+uB3G8rZefIPy yUTw== X-Gm-Message-State: AC+VfDy1gavdQRnCZuIfCoEeSoQ5jTUZprD7PIK5UVr06XC16eH8Npuh Si0ExwtfHNTH8QlO2bg8RBtmt0IPuuuLnC7hmIBZGW8CLRS6mLPmcDUnORHQJDQjdEpDeSymRSi fYXXxxnuCys+wQc9/m5WvA+82skaiOh96xidYdD7qlsgF9hE7Fi1elQuAyqj1Ba8/9bJLMaPfNa ur8lx3TvM= X-Received: by 2002:a05:600c:b41:b0:3f7:eadb:941d with SMTP id k1-20020a05600c0b4100b003f7eadb941dmr1733495wmr.19.1686330589592; Fri, 09 Jun 2023 10:09:49 -0700 (PDT) X-Received: by 2002:a05:600c:b41:b0:3f7:eadb:941d with SMTP id k1-20020a05600c0b4100b003f7eadb941dmr1733473wmr.19.1686330589330; Fri, 09 Jun 2023 10:09:49 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm3265526wmr.2.2023.06.09.10.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:09:48 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Geert Uytterhoeven , Thomas Zimmermann , Maxime Ripard , Javier Martinez Canillas , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org Subject: [PATCH v2 3/5] drm/ssd130x: Set the page height value in the device info data Date: Fri, 9 Jun 2023 19:09:38 +0200 Message-Id: <20230609170941.1150941-4-javierm@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609170941.1150941-1-javierm@redhat.com> References: <20230609170941.1150941-1-javierm@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768246564460302105?= X-GMAIL-MSGID: =?utf-8?q?1768246564460302105?= 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 Reviewed-by: Thomas Zimmermann --- (no changes since v1) 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 Fri Jun 9 17:09:39 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: 105736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1063601vqr; Fri, 9 Jun 2023 10:14:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61mdMa6vxHLdkt7n9d7R8R7HK5S8JdHXuSRHp3d7YwGnx/b+EdPQPfWY6+xof8EZdd9HIa X-Received: by 2002:a05:6a20:e686:b0:106:25b3:2f92 with SMTP id mz6-20020a056a20e68600b0010625b32f92mr1381340pzb.52.1686330848526; Fri, 09 Jun 2023 10:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686330848; cv=none; d=google.com; s=arc-20160816; b=v/PH78y7WnZnhVEQhqeBT74QTrnpQn8+momEg/WReNPTVxX+VwDzflABPITizItimr 5eywROlHTYNLBHHCmNbENfYTjw69Gv8O56dKJLqCRU/RJgQBFRZx7CoxHzxZ+jcWJ7cW 630axyHIiZISFvRWPxhqyFIp7eMXZxB5bDkCWr5fNQHcQW/S1NkUra/CQsQStyDvX8Dv GCOMfAWdTOHnyL50mcbISlPGHTWdD/9c1e9kWrFUHkUT8LpxH6glJzuuHlxRVghUdqxr /MS70A6T5yfXmHnxqtmtG6tUBoZwn3lbZtMHmc5CM5uDw7RJiIm/CI/cZ/W6tujbShKB U+kw== 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 :dkim-signature; bh=osHYEg9JMVxcIID/3FozYzoCPjrYA2Xwquo9voZzxrU=; b=EVB4Klg5XrCBwxzGGyHHYkSH7HQrJA4NbS2NKMrMSMFNqOG20OTT+aqqoTnq+Af2a7 90djLbgLf9VtOEmzGsGKZDd3WKTi8huuejnNugQHGHkGhEZhNLUdFoJwbqz/5LZU8wbt mx78PUrCjTTOaEUdW+EV+d3xdS/jYQJaYM/O4nNJ4EtRoNOeoZ/XbA2fkAU9Iudz+f+y B7i89VNavjpUaMBKsCgiPQY3KiNCicCgnN4sqFgqAPiKGbBaMzXP6sBXaUip4ATFg2PO NgN53bQjJkTc/lJYQgIvHtFV8a8TzWw6rf+LSjpcd9qexbnR7EtA5aJhEb9mV+DgKo0X HzSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="K7w0l/x1"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q25-20020a637519000000b0051423af249fsi2957313pgc.304.2023.06.09.10.13.55; Fri, 09 Jun 2023 10:14:08 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="K7w0l/x1"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230172AbjFIRLU (ORCPT + 99 others); Fri, 9 Jun 2023 13:11:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjFIRLS (ORCPT ); Fri, 9 Jun 2023 13:11:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F26CA3A91 for ; Fri, 9 Jun 2023 10:09:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686330596; 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=osHYEg9JMVxcIID/3FozYzoCPjrYA2Xwquo9voZzxrU=; b=K7w0l/x1JJYWVfKzUyGcOceebIbQyq7peaPFgdPcjZ9WUlPV9cJb5GLRd+KwDpVu+9OwNv uLYmKtRk83MOi8ISCS05FruaN9nDQBJGJOtsZ18kfUcnkUtWwbfe253BFNoAZrP56lUv29 rSdwJOz9kQb4wtte+V/oq5dtAmeFR6M= 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-107-5E6H4JA9NRy8DozdvDF6Jw-1; Fri, 09 Jun 2023 13:09:52 -0400 X-MC-Unique: 5E6H4JA9NRy8DozdvDF6Jw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3f7ecc15771so9674835e9.1 for ; Fri, 09 Jun 2023 10:09:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686330591; x=1688922591; 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=osHYEg9JMVxcIID/3FozYzoCPjrYA2Xwquo9voZzxrU=; b=VK3+RdG2GmL/2IJFGVAUjtcWcum0ZJpEh7ulniXL2IAMznUMAMRp99TxQ8BHd6OzOY /Li5eNeiVBjiEFulm/MryMhq2HOUBJ7ORRZ2JcWfTFlTtlhGEDca87bLKdsfcA40L5jS BYBwUaAa35ahwj33JkVXq0NLA4KRrUwdVRTNwm2WRQzUlpxKnFIDBdfuVu8DdLorMF5t hjSCkda543KE2bq3gkLMlXe7NsoL9P55JN53OpSZTtNBMQkIhXwAOQ5DFsQmzAb5s2g4 vaotA5B5kh8r727dgCRpGnRZ1boiGa4ma1/sjNDQFeD1XV8M150jZaPDCUmltGLFKMdB /32g== X-Gm-Message-State: AC+VfDz/3Q3uHBhqHokfM2wDgKLv5ywx4h/bhsanLaAedhEvzh9nJPyU oGIo6lPwGkzM1OClM9EAOP83b+qvqtRISgYeAnXpJoqYciNeLFSbMcncDRGqHek0A8rxbV9ibVH DA5IIBbmQWllZI5CjxCUB3Vi767B4N2IpVDEwtgpuZBSvoYiCk+Fhig71aG3Phc17K7TzrYDWFs vmivSEE0c= X-Received: by 2002:a05:600c:1c15:b0:3f7:aee8:c23a with SMTP id j21-20020a05600c1c1500b003f7aee8c23amr4211146wms.19.1686330591010; Fri, 09 Jun 2023 10:09:51 -0700 (PDT) X-Received: by 2002:a05:600c:1c15:b0:3f7:aee8:c23a with SMTP id j21-20020a05600c1c1500b003f7aee8c23amr4211127wms.19.1686330590735; Fri, 09 Jun 2023 10:09:50 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm3265526wmr.2.2023.06.09.10.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:09:50 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Geert Uytterhoeven , Thomas Zimmermann , Maxime Ripard , Javier Martinez Canillas , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org Subject: [PATCH v2 4/5] drm/ssd130x: Don't allocate buffers on each plane update Date: Fri, 9 Jun 2023 19:09:39 +0200 Message-Id: <20230609170941.1150941-5-javierm@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609170941.1150941-1-javierm@redhat.com> References: <20230609170941.1150941-1-javierm@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768246055927820710?= X-GMAIL-MSGID: =?utf-8?q?1768246055927820710?= 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 Reviewed-by: Thomas Zimmermann --- (no changes since v1) 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 Fri Jun 9 17:09:40 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: 105737 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1063642vqr; Fri, 9 Jun 2023 10:14:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Iv7A3h6eVc/Mo+zPs8nTw22p9k//Ps6y1WvjgTf/m+R/XtGhNTwgaytS6iQ8C8ov1jVMQ X-Received: by 2002:a05:6a20:1e9c:b0:114:788f:ae3f with SMTP id dl28-20020a056a201e9c00b00114788fae3fmr1276187pzb.57.1686330851931; Fri, 09 Jun 2023 10:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686330851; cv=none; d=google.com; s=arc-20160816; b=wCKhgcTkDqLzXr1eNBd4/KkUsFRVyCdIzQSyMfmPbLLdTqBFvZDLPBvdos7XPoOGMJ vOozqVKeG42P2KouC/qD5CIYU82FI100UW9dQsTiquS1vpVtUHitGVODvWQg1N6bDl5z VhxjwRRG2TGlO9UsgFil5kLJbdD3lNSCXe7S2VnY3Xf8szRFaqsNNMppvUfbIiOXzjsQ D9AH7DCvcHdXJ78yfHXFQAHO5VzGV3ItyKUH3XwqQavPirozIgRV1apraQjLd7HPF8fT Hr3PlmSAJ5c1/xPp3rn/ktGX5W1PYOdAmhTDrxHncgTQPbnmTdis23UsYl06VZvAft2S i9rw== 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 :dkim-signature; bh=bc1LYu0VxicAbeViPWlWxEzFMdxQOVZhpaNTOwtL/hg=; b=lJPxXx/KEKqFG5XuZVnQjIX9korxlUnRO3QtsbZU27kSEDO2mskKkLWv1vXTKQVqRS 2a56lgMyhNPl7Ohh1wXVgfETjTcEDF3BMlKMwZMmu87z0BcWkCC9VbePESQ/IK9eAzRj x8aTkbphA4wdurPEpHwSyvyswyt5tdgzG7yVbkI9zaSShCG4DwJbqxqt9p3/XhNBhqdB eu4MdWTu1y0EFifTVO2vQt6xwzNhVLaNipvngOQQ4p3cDUh0UAsjOwIW9kH3xMl2HP4o k5zO1KNMQtP3WH9rk383nIy56GUiAxVj2RmeJHeHLh9fVXX2f2JMS2ngQ/JrW0GqKrqP Ay/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dUr6eLUn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l72-20020a63914b000000b0053ef518d7ffsi2995577pge.303.2023.06.09.10.13.58; Fri, 09 Jun 2023 10:14:11 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dUr6eLUn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbjFIRLY (ORCPT + 99 others); Fri, 9 Jun 2023 13:11:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbjFIRLV (ORCPT ); Fri, 9 Jun 2023 13:11:21 -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 587793A90 for ; Fri, 9 Jun 2023 10:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686330602; 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=bc1LYu0VxicAbeViPWlWxEzFMdxQOVZhpaNTOwtL/hg=; b=dUr6eLUnI9y07SSB80Ht6+bDDKCHzTdzI59/TIH3DD/yEoM16z4s3AyOygEuwERx87HDXC YlOJfKpGJrQh7j3eLWE0rYX9PuO9IRPH0oaBv/l/qPfWCVVUVa/+IYeRamq7xPdz1QRMnI hn89lWqWFbguzXcls0yi5g+HzQB00hs= 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-58-sTr0OLniOZigBGqoKYtIuA-1; Fri, 09 Jun 2023 13:09:53 -0400 X-MC-Unique: sTr0OLniOZigBGqoKYtIuA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f7e7cfcae4so11173415e9.1 for ; Fri, 09 Jun 2023 10:09:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686330592; x=1688922592; 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=bc1LYu0VxicAbeViPWlWxEzFMdxQOVZhpaNTOwtL/hg=; b=XfbTHJDH9wE+xz24owqwPB5Qye/Y9/2ubGqW1J5vrWQIiRrIWpk0BMd3I6e1L4vosh Ks/5lI5H8+hg5APk4On6MeaPZtzvsk9jA2AUI1RvQSkpTUnTXem8RAHvEO9jjsq2JWS+ fO/Hx3JJ0skrur5l3YtPZI+VuotSe9lBfnspSD97a9Ho0LPt6EKRxcIkMlcbfgG56IqR YR4Of81Jx3aLauO1I2x17obCZAhrrpykM7pzVVo0JlWz45sshmRC78RSW7DBrfUc9Bda TLnO7/nOuS+Ej9Vv/U6RjsR7OgG8zTKHvyFZqzo/fJZk0b5/JUQpqbR1/RvIVuMmeZhX KKaw== X-Gm-Message-State: AC+VfDwUv0ggYD6wmu5taScX54rlGXnFlvg/Xz1WlgVKvbOU0/OPnIJy F5VjLC3xWKmehFcImuR1FrOYIxrKy966izaawrmqIlOxsdw2jTbLy1L/pG2GyZNOYGP8neTRaRc y8gO2vloWhP+LaiNpf5xYvXQmiwEJiAoOtbXuc/WiZcGQ2ytmERhVGE/yBayHQRVgKRiEmp8GMV bGS4NHBxk= X-Received: by 2002:a05:600c:21c7:b0:3f5:ce4:6c3f with SMTP id x7-20020a05600c21c700b003f50ce46c3fmr1652661wmj.7.1686330592184; Fri, 09 Jun 2023 10:09:52 -0700 (PDT) X-Received: by 2002:a05:600c:21c7:b0:3f5:ce4:6c3f with SMTP id x7-20020a05600c21c700b003f50ce46c3fmr1652644wmj.7.1686330591943; Fri, 09 Jun 2023 10:09:51 -0700 (PDT) Received: from minerva.home (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0ad500b003f7310a3ffasm3265526wmr.2.2023.06.09.10.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 10:09:51 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Geert Uytterhoeven , Thomas Zimmermann , Maxime Ripard , Javier Martinez Canillas , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org Subject: [PATCH v2 5/5] drm/ssd130x: Remove hardcoded bits-per-pixel in ssd130x_buf_alloc() Date: Fri, 9 Jun 2023 19:09:40 +0200 Message-Id: <20230609170941.1150941-6-javierm@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609170941.1150941-1-javierm@redhat.com> References: <20230609170941.1150941-1-javierm@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768246059514215595?= X-GMAIL-MSGID: =?utf-8?q?1768246059514215595?= 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 Reviewed-by: Thomas Zimmermann --- (no changes since v1) 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;