From patchwork Tue Jun 18 07:41:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marko Kohtala X-Patchwork-Id: 11001059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1564186E for ; Tue, 18 Jun 2019 07:41:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93996288EE for ; Tue, 18 Jun 2019 07:41:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84BA6289B5; Tue, 18 Jun 2019 07:41:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26F3F28A08 for ; Tue, 18 Jun 2019 07:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725913AbfFRHlx (ORCPT ); Tue, 18 Jun 2019 03:41:53 -0400 Received: from mail-wm1-f97.google.com ([209.85.128.97]:53578 "EHLO mail-wm1-f97.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbfFRHlx (ORCPT ); Tue, 18 Jun 2019 03:41:53 -0400 Received: by mail-wm1-f97.google.com with SMTP id x15so2029355wmj.3 for ; Tue, 18 Jun 2019 00:41:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=okoko.fi; s=okoko; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t0Vqi/RB6vd3sTFj8r0XFtYp6zxmyWgaP1RbCqpMuHg=; b=IsxmHO8pbbaTDMMhZXGehcVjKzvL6pC8soL58WAW8Ieg7BqyKeSgr9E/W7QLo/HCPq 9rABZnNUxf/Ka6yoa2Apt6EwSl3CBmEVF8yd7MBvbyZYiu/J70IQ6tI4r7tywLwWdtlh 5w99AgJ6Tjhws4M+bacGgFhWaQ0/FgvNoa+zE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t0Vqi/RB6vd3sTFj8r0XFtYp6zxmyWgaP1RbCqpMuHg=; b=sp08X98FFIKj/g3hgapa2nxpOa4h0lIh3RTf7Porz7wR7rZeCLPR8e1zJFJ23MgGZW 6QKZ3ZlImeox0tVY5GgR//S4BnX2tTCTNodm1rgzmmlEd8fId32mAaOYAwS1xIlKtqbU fxUcdLmbFxrlLASUl4sqYl3sgyav+DUUuFqw7vtX6qpRzYL5jEuc3Z8Fj/GcHZLqNl9t W6UVOBLapANsOPVKhhjcQuU92cjkVQugbO3LvrRgN27sp1inaDe1k7vpFfj8Z1qPMVr0 4AKl42q96aNTYri73FwNiogMj2H2jIqgkEEKCmwmIURIiUHfolIsHueqlC7CUsJo3N0U 5c1Q== X-Gm-Message-State: APjAAAViMzBET9ROG1vZxPjXnsmOSQE/t0V/up42BcRf2hW/1RyGRpam NyVVtrOBeDwfmUNISB++x9rH1apsLRs6U4ZWIUpr8RDbRCZ2lA== X-Google-Smtp-Source: APXvYqydFUxa82KvmETVUZcfjM8PkupOirGSVC5mbNqfnR0pyyVWNFLzIVX6nRu9w3pplClHEc3GhFeBPlpa X-Received: by 2002:a1c:6641:: with SMTP id a62mr2039009wmc.175.1560843711554; Tue, 18 Jun 2019 00:41:51 -0700 (PDT) Received: from localhost.localdomain (46-163-209-30.blcnet.fi. [46.163.209.30]) by smtp-relay.gmail.com with ESMTPS id l18sm212063wrn.66.2019.06.18.00.41.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 00:41:51 -0700 (PDT) X-Relaying-Domain: okoko.fi From: Marko Kohtala To: linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Bartlomiej Zolnierkiewicz , Mark Rutland , Rob Herring , Daniel Vetter , David Airlie , =?utf-8?b?TWljaGFsIFZva8OhxI0=?= , Marko Kohtala Subject: [PATCH 1/6] video: ssd1307fb: Use screen_buffer instead of screen_base Date: Tue, 18 Jun 2019 10:41:06 +0300 Message-Id: <20190618074111.9309-2-marko.kohtala@okoko.fi> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190618074111.9309-1-marko.kohtala@okoko.fi> References: <20190618074111.9309-1-marko.kohtala@okoko.fi> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sparse reported incorrect type due to different address spaces. The screen_base is __iomem, but the memory is not from a device so we can use screen_buffer instead and avoid some type casts. Signed-off-by: Marko Kohtala --- drivers/video/fbdev/ssd1307fb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 3b361bc9feb8..6c2980331ffd 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -150,7 +150,7 @@ static inline int ssd1307fb_write_cmd(struct i2c_client *client, u8 cmd) static void ssd1307fb_update_display(struct ssd1307fb_par *par) { struct ssd1307fb_array *array; - u8 *vmem = par->info->screen_base; + u8 *vmem = par->info->screen_buffer; int i, j, k; array = ssd1307fb_alloc_array(par->width * par->height / 8, @@ -213,7 +213,7 @@ static ssize_t ssd1307fb_write(struct fb_info *info, const char __user *buf, struct ssd1307fb_par *par = info->par; unsigned long total_size; unsigned long p = *ppos; - u8 __iomem *dst; + void *dst; total_size = info->fix.smem_len; @@ -226,7 +226,7 @@ static ssize_t ssd1307fb_write(struct fb_info *info, const char __user *buf, if (!count) return -EINVAL; - dst = (void __force *) (info->screen_base + p); + dst = info->screen_buffer + p; if (copy_from_user(dst, buf, count)) return -EFAULT; @@ -547,7 +547,7 @@ static int ssd1307fb_probe(struct i2c_client *client, struct fb_deferred_io *ssd1307fb_defio; u32 vmem_size; struct ssd1307fb_par *par; - u8 *vmem; + void *vmem; int ret; if (!node) { @@ -657,7 +657,7 @@ static int ssd1307fb_probe(struct i2c_client *client, info->var.blue.length = 1; info->var.blue.offset = 0; - info->screen_base = (u8 __force __iomem *)vmem; + info->screen_buffer = vmem; info->fix.smem_start = __pa(vmem); info->fix.smem_len = vmem_size; From patchwork Tue Jun 18 07:41:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marko Kohtala X-Patchwork-Id: 11001061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D5AF14B6 for ; Tue, 18 Jun 2019 07:41:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FB2C288EE for ; Tue, 18 Jun 2019 07:41:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73FBF28A08; Tue, 18 Jun 2019 07:41:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22C51288EE for ; Tue, 18 Jun 2019 07:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728742AbfFRHly (ORCPT ); Tue, 18 Jun 2019 03:41:54 -0400 Received: from mail-wr1-f100.google.com ([209.85.221.100]:42175 "EHLO mail-wr1-f100.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbfFRHly (ORCPT ); Tue, 18 Jun 2019 03:41:54 -0400 Received: by mail-wr1-f100.google.com with SMTP id x17so12738642wrl.9 for ; Tue, 18 Jun 2019 00:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=okoko.fi; s=okoko; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RJV2c/yp+5Do5r3i0Oh53aiXsFA5fZSjKFxBZIwxxB4=; b=d0+0frtSg952+lM6f0nBtK47869GFo/kZ49bF9nda2IzhOwtCpAxPQQKkPzzfvPy7D 4eY4ARuUNqbPQwctLijpvGklj6NQIdAQo0vMwPAoFiVihX1737VFcv+1WPV8x0kO0nX5 DbqE8tyTJHeLE2P/sdmVxB4dYR2ze9fzb51iw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RJV2c/yp+5Do5r3i0Oh53aiXsFA5fZSjKFxBZIwxxB4=; b=dY30h1L97bb4gxxTMDn59/yBOIAZr9aThCF+q6VIJaOZbZ7AAS7dg27X6gum9kntqG XK53zns9BjgjNg5bWWFRb3piF8M7fvgescDl4rPt0dPotiBueBgn/XZOa8j8qXhSKpg4 QuzRNfqSd+mOm9frQ04lvaKBaVIv3m8G1/+kR8nPZs59ulKc16IRY3GAL3C7JZybmaxp dHoxzkTcRNuJMX8StgcPNBAGXTN18753e0xT+a7+VKcrhe+pI1gTN14raRHfi8FZbR2R BhD+/WWkMq1cxbPwG0ReuTUv8CInRNKI9sicDkMLRUs3//e6ncz6jgjguOCvQnrCbezh FJ1Q== X-Gm-Message-State: APjAAAWYBVT05nKcs15xbGsqyLmmvE6KCRjyvOgJgPyCYBULRHKsDK+G fYmuRuGNlM/kTRuCMGmN55CfrGpJsuwOQ1F5xtFiLEOyBBkzow== X-Google-Smtp-Source: APXvYqzJtYYrIsIVjU6HwCxdrP51kOs3TdA56llOXfWqnnEnzoFlKNoTYyUl5l8w6i5sbjU9eoegASs4TVgl X-Received: by 2002:a5d:53c2:: with SMTP id a2mr27917903wrw.8.1560843712369; Tue, 18 Jun 2019 00:41:52 -0700 (PDT) Received: from localhost.localdomain (46-163-209-30.blcnet.fi. [46.163.209.30]) by smtp-relay.gmail.com with ESMTPS id l18sm212063wrn.66.2019.06.18.00.41.51 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 00:41:52 -0700 (PDT) X-Relaying-Domain: okoko.fi From: Marko Kohtala To: linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Bartlomiej Zolnierkiewicz , Mark Rutland , Rob Herring , Daniel Vetter , David Airlie , =?utf-8?b?TWljaGFsIFZva8OhxI0=?= , Marko Kohtala Subject: [PATCH 2/6] video: ssd1307fb: Remove unneeded semicolons Date: Tue, 18 Jun 2019 10:41:07 +0300 Message-Id: <20190618074111.9309-3-marko.kohtala@okoko.fi> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190618074111.9309-1-marko.kohtala@okoko.fi> References: <20190618074111.9309-1-marko.kohtala@okoko.fi> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP coccicheck reported unneeded semicolons. Remove them. Signed-off-by: Marko Kohtala --- drivers/video/fbdev/ssd1307fb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 6c2980331ffd..9ab00e0dadc7 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -313,7 +313,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par) dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n", par->pwm->pwm, par->pwm_period); - }; + } /* Set initial contrast */ ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); @@ -329,7 +329,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par) ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON); if (ret < 0) return ret; - }; + } /* Set COM direction */ com_invdir = 0xc0 | (par->com_invdir & 0x1) << 3; @@ -716,7 +716,7 @@ static int ssd1307fb_probe(struct i2c_client *client, if (par->device_info->need_pwm) { pwm_disable(par->pwm); pwm_put(par->pwm); - }; + } regulator_enable_error: if (par->vbat_reg) regulator_disable(par->vbat_reg); @@ -740,7 +740,7 @@ static int ssd1307fb_remove(struct i2c_client *client) if (par->device_info->need_pwm) { pwm_disable(par->pwm); pwm_put(par->pwm); - }; + } fb_deferred_io_cleanup(info); __free_pages(__va(info->fix.smem_start), get_order(info->fix.smem_len)); framebuffer_release(info); From patchwork Tue Jun 18 07:41:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marko Kohtala X-Patchwork-Id: 11001063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48C1914B6 for ; Tue, 18 Jun 2019 07:41:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AE24288EE for ; Tue, 18 Jun 2019 07:41:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F5D928A08; Tue, 18 Jun 2019 07:41:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB593288EE for ; Tue, 18 Jun 2019 07:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726505AbfFRHlz (ORCPT ); Tue, 18 Jun 2019 03:41:55 -0400 Received: from mail-wr1-f99.google.com ([209.85.221.99]:45944 "EHLO mail-wr1-f99.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726689AbfFRHly (ORCPT ); Tue, 18 Jun 2019 03:41:54 -0400 Received: by mail-wr1-f99.google.com with SMTP id f9so12693366wre.12 for ; Tue, 18 Jun 2019 00:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=okoko.fi; s=okoko; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=77CACbLG8YOOXSUPh2HvtcwJqatz/ApGlIF/fbxQ6MM=; b=K4G1zQPJ6Avx1u05WN/I0mLZ1eldWEYzvqTshfQHtPvsMJpxkvHeOewu0QPh7/0vof fPUBYzsij0DMRALgWrkiW3fKmEX02BJDb8RMk2qMaScMXglntIKmv5+FfD9A79HrYk1g C6cKvPAC7l/9KumffEhWIiBTkYZKhPDz1pWwo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=77CACbLG8YOOXSUPh2HvtcwJqatz/ApGlIF/fbxQ6MM=; b=tjwePz5OJUZYjAXAimuiyq+L3H5aRzcWcY6loTgcDDpTZ749A9eNZA7FdOWuiHUBzE i7Y0dq4ss7RfLca6prpUs7E2IAd6ogsfa90T7jIcd3Pv1z+8J4U6wfBKTB6lmT5mlb3T S3AQ5U6AWRQi3TEglX1IJSl6i/pW4TWIyaIRxPEwUD/wGh5iru1na7NzsH1vg1v1vKkF A7SmH9iEsPQoM7uapwvIrHP8xZ5wFRMfXKSAuMnQ49MkV5H+y3O88yQ1l8zl+si7ttao GN0yFtR+fJ6DGjH/cKmCkOZvo4QAbOYmW1zWl4HuAA1BzbQxBW+gFCC4+ltJ/BqWoSAX Gs2g== X-Gm-Message-State: APjAAAU62FIXUrTadmKBmLBmOvh6JgvkAXePPtUw00gTEyxJOo70KltQ JVeqjynmrN3T2vqhGuEJYN3sd7zU2tQBKnGzX6G2/N5UeQOgFQ== X-Google-Smtp-Source: APXvYqyGE/GgF3llWsrqocTXT6oGvv/+cbVnAi4GTQVeTr/DTh0qherzKRGe3g2B64lGDtKlirYWQdQUNe/k X-Received: by 2002:adf:c506:: with SMTP id q6mr65175136wrf.219.1560843713168; Tue, 18 Jun 2019 00:41:53 -0700 (PDT) Received: from localhost.localdomain (46-163-209-30.blcnet.fi. [46.163.209.30]) by smtp-relay.gmail.com with ESMTPS id l18sm212063wrn.66.2019.06.18.00.41.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 00:41:53 -0700 (PDT) X-Relaying-Domain: okoko.fi From: Marko Kohtala To: linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Bartlomiej Zolnierkiewicz , Mark Rutland , Rob Herring , Daniel Vetter , David Airlie , =?utf-8?b?TWljaGFsIFZva8OhxI0=?= , Marko Kohtala Subject: [PATCH 3/6] video: ssd1307fb: Start page range at page_offset Date: Tue, 18 Jun 2019 10:41:08 +0300 Message-Id: <20190618074111.9309-4-marko.kohtala@okoko.fi> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190618074111.9309-1-marko.kohtala@okoko.fi> References: <20190618074111.9309-1-marko.kohtala@okoko.fi> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The page_offset was only applied to the end of the page range. This caused the display updates to cause a scrolling effect on the display because the amount of data written to the display did not match the range display expected. Fixes: 301bc0675b67 ("video: ssd1307fb: Make use of horizontal addressing mode") Signed-off-by: Marko Kohtala --- drivers/video/fbdev/ssd1307fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 9ab00e0dadc7..86f2b79f3ed5 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -433,7 +433,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par) if (ret < 0) return ret; - ret = ssd1307fb_write_cmd(par->client, 0x0); + ret = ssd1307fb_write_cmd(par->client, par->page_offset); if (ret < 0) return ret; From patchwork Tue Jun 18 07:41:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marko Kohtala X-Patchwork-Id: 11001065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEA86112C for ; Tue, 18 Jun 2019 07:41:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C022A288EE for ; Tue, 18 Jun 2019 07:41:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4ACF28A09; Tue, 18 Jun 2019 07:41:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E46F288EE for ; Tue, 18 Jun 2019 07:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729015AbfFRHl4 (ORCPT ); Tue, 18 Jun 2019 03:41:56 -0400 Received: from mail-wm1-f99.google.com ([209.85.128.99]:54724 "EHLO mail-wm1-f99.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbfFRHl4 (ORCPT ); Tue, 18 Jun 2019 03:41:56 -0400 Received: by mail-wm1-f99.google.com with SMTP id g135so2020668wme.4 for ; Tue, 18 Jun 2019 00:41:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=okoko.fi; s=okoko; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uaCCOwT6FdYmvMhllu/QeWwGRVseqHgvjzdBnHOd69M=; b=Pfg9Ih+86S3Xtc3Q3MbPoD1yKZf5q9ftjSxkHMFON5uo0EZlqN43AwurFcKUty7P9w oKJWvmQbND30gnRuRugdhgCYJVX/nNysALrdP7FDYbwlnWxdlrXHQFhWpS0P1sFwUorl LQkN+f3DEabIIVpNYWzasblfkpToaGaIedkas= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uaCCOwT6FdYmvMhllu/QeWwGRVseqHgvjzdBnHOd69M=; b=T/flb3bQ64sRt3+jtfv85Neah56RvIAQxVKV2kf16FGWSQVBOwgpogfmBqL0zTI1jS BYv+cxv05LRdRSkJhJdtgV5xu/Zo1No1/u89o8iZ6ruML2eG/0uJXjR80rWyVWQQhCeV VL/RJ+gTJ7FcDBOB2RtNfE6oYotch86i7z7r/FuWNob8ID3xGd8q2lrUYHAVzOecnPGX Ee5CNflB5WyL0Ot11ni9Xpb4CzPa31rFiBK/3eIHTLJ4yKoPny1mx69k997pyXBgiEvu jCuohwNoB5BzPUO2kFUe1HbAlSkwBSQ0XabibbUVogwFX6sU8Ov699S4Q7//Wc1vK/u4 V36g== X-Gm-Message-State: APjAAAXz0gyRnm2bGYG0v3/79www56vnRZRZ1FhBuRNhxEdZt7SBP7sS L/morVrrWeZpvdKPoQZuwwFu4ayUS7OqMnzVBed3fITLskuPaw== X-Google-Smtp-Source: APXvYqwVYysIgOjHK+Kva6RmxGWI0gn5iUhuZshGHTaWhSUakRHcy5t1o7CtKGKWq2sYfpNRq6WDuIHsIVt2 X-Received: by 2002:a1c:448b:: with SMTP id r133mr2204309wma.114.1560843713987; Tue, 18 Jun 2019 00:41:53 -0700 (PDT) Received: from localhost.localdomain (46-163-209-30.blcnet.fi. [46.163.209.30]) by smtp-relay.gmail.com with ESMTPS id l18sm212063wrn.66.2019.06.18.00.41.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 00:41:53 -0700 (PDT) X-Relaying-Domain: okoko.fi From: Marko Kohtala To: linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Bartlomiej Zolnierkiewicz , Mark Rutland , Rob Herring , Daniel Vetter , David Airlie , =?utf-8?b?TWljaGFsIFZva8OhxI0=?= , Marko Kohtala Subject: [PATCH 4/6] video: ssd1307fb: Handle width and height that are not multiple of 8 Date: Tue, 18 Jun 2019 10:41:09 +0300 Message-Id: <20190618074111.9309-5-marko.kohtala@okoko.fi> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190618074111.9309-1-marko.kohtala@okoko.fi> References: <20190618074111.9309-1-marko.kohtala@okoko.fi> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some displays have dimensions that are not multiple of eight, for example height of 36, but the driver divided the dimensions by 8. Defining display to the next multiple of 8 is not good as then the display registers get configured to dimensions that do not match. This contradicts intructions by some display manufacturers. Use DIV_ROUND_UP to multiple of 8 when needed so correct values can be used. The ssd1307fb_update_display bit reordering receives a simplification in the process. Signed-off-by: Marko Kohtala --- drivers/video/fbdev/ssd1307fb.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 86f2b79f3ed5..4f4a1b99d17d 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -151,10 +151,11 @@ static void ssd1307fb_update_display(struct ssd1307fb_par *par) { struct ssd1307fb_array *array; u8 *vmem = par->info->screen_buffer; + unsigned int line_length = par->info->fix.line_length; + unsigned int pages = DIV_ROUND_UP(par->height, 8); int i, j, k; - array = ssd1307fb_alloc_array(par->width * par->height / 8, - SSD1307FB_DATA); + array = ssd1307fb_alloc_array(par->width * pages, SSD1307FB_DATA); if (!array) return; @@ -187,22 +188,24 @@ static void ssd1307fb_update_display(struct ssd1307fb_par *par) * (5) A4 B4 C4 D4 E4 F4 G4 H4 */ - for (i = 0; i < (par->height / 8); i++) { + for (i = 0; i < pages; i++) { for (j = 0; j < par->width; j++) { + int m = 8; u32 array_idx = i * par->width + j; array->data[array_idx] = 0; - for (k = 0; k < 8; k++) { - u32 page_length = par->width * i; - u32 index = page_length + (par->width * k + j) / 8; - u8 byte = *(vmem + index); - u8 bit = byte & (1 << (j % 8)); - bit = bit >> (j % 8); + /* Last page may be partial */ + if (i + 1 == pages && par->height % 8) + m = par->height % 8; + for (k = 0; k < m; k++) { + u8 byte = vmem[(8 * i + k) * line_length + + j / 8]; + u8 bit = (byte >> (j % 8)) & 1; array->data[array_idx] |= bit << k; } } } - ssd1307fb_write_array(par->client, array, par->width * par->height / 8); + ssd1307fb_write_array(par->client, array, par->width * pages); kfree(array); } @@ -438,7 +441,8 @@ static int ssd1307fb_init(struct ssd1307fb_par *par) return ret; ret = ssd1307fb_write_cmd(par->client, - par->page_offset + (par->height / 8) - 1); + par->page_offset + + DIV_ROUND_UP(par->height, 8) - 1); if (ret < 0) return ret; @@ -618,7 +622,7 @@ static int ssd1307fb_probe(struct i2c_client *client, par->dclk_div = par->device_info->default_dclk_div; par->dclk_frq = par->device_info->default_dclk_frq; - vmem_size = par->width * par->height / 8; + vmem_size = DIV_ROUND_UP(par->width, 8) * par->height; vmem = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, get_order(vmem_size)); @@ -641,7 +645,7 @@ static int ssd1307fb_probe(struct i2c_client *client, info->fbops = &ssd1307fb_ops; info->fix = ssd1307fb_fix; - info->fix.line_length = par->width / 8; + info->fix.line_length = DIV_ROUND_UP(par->width, 8); info->fbdefio = ssd1307fb_defio; info->var = ssd1307fb_var; From patchwork Tue Jun 18 07:41:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marko Kohtala X-Patchwork-Id: 11001067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AC9C14B6 for ; Tue, 18 Jun 2019 07:42:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C1FB288EE for ; Tue, 18 Jun 2019 07:42:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 102BD28A08; Tue, 18 Jun 2019 07:42:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B145A288EE for ; Tue, 18 Jun 2019 07:42:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729055AbfFRHl5 (ORCPT ); Tue, 18 Jun 2019 03:41:57 -0400 Received: from mail-wr1-f97.google.com ([209.85.221.97]:45943 "EHLO mail-wr1-f97.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728748AbfFRHl4 (ORCPT ); Tue, 18 Jun 2019 03:41:56 -0400 Received: by mail-wr1-f97.google.com with SMTP id f9so12693478wre.12 for ; Tue, 18 Jun 2019 00:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=okoko.fi; s=okoko; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0PrSR+jN+SJngU5g9VL57RLfBmPfgfrprow1ZhWuEaU=; b=XbZMhCy9PwEALPH0NPGJdcZHF9zS0XOpOR8x3PSFQlEjCQ6Gz4bo2b0Z/DVboYMNYL bawh0DCI+ryYkeLPaXzxB8PkLFsPGYTd04hm54Pli6Hu9JocehoOAo5PJihEnCP9lOXk FkcVPkHXMltxhZ2+oh+mgoHbT57SZMkX/prR0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0PrSR+jN+SJngU5g9VL57RLfBmPfgfrprow1ZhWuEaU=; b=jeuuiOvgXss1NJwmZ95Es+Le5aUGTbB4ppFClW67fDxjpb0wpItBQLCqf48iFBzRbT WMJizZwuH5vfz2hkGnmA0Ifdw2IVoScuATyONjxuuIV3RImQonXDqhZjP1n8sTi5kHeu I4zQkrzfv52thk5MZL8f1Wp/Kzkg3I2VvRutjuq3fOh7LpySspwf0ouaaoRKeMlDiPnq ew8NIXkuLISgv/RvIzofeuLDByRpXLgun6g+oWB3zWrTnHJbtvOvi72OrqV1yCELPqaa HCwgDCWPI2d2vLpO+pk9oQmzpxww5i8LvpLs9S8IGYhzuP3l15ds+9t7feESV6hL16+T oyCw== X-Gm-Message-State: APjAAAUqqj2FtGQgz/V+ZI3uflfgck8HtWVVGSJZH0XL+F/sTOQUQYXh b9XK9cEbyZ8IocciwmV/pf9ECZ0P+w2WQvSMhacNs9tAkLxsmA== X-Google-Smtp-Source: APXvYqzLg7eWFSh4aDeAY+p0mLGpxFDGnAoM7uLRTr9Z17I85OAZshKEtrRGTEUMuiUDdNcm1goZ80zuNSHH X-Received: by 2002:a5d:5702:: with SMTP id a2mr37285683wrv.89.1560843714771; Tue, 18 Jun 2019 00:41:54 -0700 (PDT) Received: from localhost.localdomain (46-163-209-30.blcnet.fi. [46.163.209.30]) by smtp-relay.gmail.com with ESMTPS id l18sm212063wrn.66.2019.06.18.00.41.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 00:41:54 -0700 (PDT) X-Relaying-Domain: okoko.fi From: Marko Kohtala To: linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Bartlomiej Zolnierkiewicz , Mark Rutland , Rob Herring , Daniel Vetter , David Airlie , =?utf-8?b?TWljaGFsIFZva8OhxI0=?= , Marko Kohtala Subject: [PATCH 5/6] dt-bindings: display: ssd1307fb: Add initialization properties Date: Tue, 18 Jun 2019 10:41:10 +0300 Message-Id: <20190618074111.9309-6-marko.kohtala@okoko.fi> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190618074111.9309-1-marko.kohtala@okoko.fi> References: <20190618074111.9309-1-marko.kohtala@okoko.fi> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Document new bindings for adapting ssd1307fb driver to new displays. Signed-off-by: Marko Kohtala Reviewed-by: Rob Herring --- .../devicetree/bindings/display/ssd1307fb.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/display/ssd1307fb.txt b/Documentation/devicetree/bindings/display/ssd1307fb.txt index b67f8caa212c..27333b9551b3 100644 --- a/Documentation/devicetree/bindings/display/ssd1307fb.txt +++ b/Documentation/devicetree/bindings/display/ssd1307fb.txt @@ -27,6 +27,15 @@ Optional properties: - solomon,prechargep2: Length of precharge period (phase 2) in clock cycles. This needs to be the higher, the higher the capacitance of the OLED's pixels is + - solomon,dclk-div: Clock divisor 1 to 16 + - solomon,dclk-frq: Clock frequency 0 to 15, higher value means higher + frequency + - solomon,lookup-table: 8 bit value array of current drive pulse widths for + BANK0, and colors A, B, and C. Each value in range + of 31 to 63 for pulse widths of 32 to 64. Color D + is always width 64. + - solomon,area-color-enable: Display uses color mode + - solomon,low-power. Display runs in low power mode [0]: Documentation/devicetree/bindings/pwm/pwm.txt @@ -46,4 +55,5 @@ ssd1306: oled@3c { solomon,com-lrremap; solomon,com-invdir; solomon,com-offset = <32>; + solomon,lookup-table = /bits/ 8 <0x3f 0x3f 0x3f 0x3f>; }; From patchwork Tue Jun 18 07:41:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marko Kohtala X-Patchwork-Id: 11001069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83B2514B6 for ; Tue, 18 Jun 2019 07:42:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74F8D288EE for ; Tue, 18 Jun 2019 07:42:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 689A128A09; Tue, 18 Jun 2019 07:42:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCE5F28A08 for ; Tue, 18 Jun 2019 07:42:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729076AbfFRHmC (ORCPT ); Tue, 18 Jun 2019 03:42:02 -0400 Received: from mail-wr1-f100.google.com ([209.85.221.100]:35349 "EHLO mail-wr1-f100.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728989AbfFRHl5 (ORCPT ); Tue, 18 Jun 2019 03:41:57 -0400 Received: by mail-wr1-f100.google.com with SMTP id m3so12768040wrv.2 for ; Tue, 18 Jun 2019 00:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=okoko.fi; s=okoko; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rNkk0KsbO3YcUF9ymJ/Izy+/IeIKEUGythTLywp5Ihs=; b=NpcJqVJ7oMwCHKq+K8XtNKFwzz/R4irs1neyzPkukpQlNYfqk2jXuCPYslO9Vbtia1 JGSC72YgcwPtuvPeMMLK/JyeNzFLssUmOFSR9ZTaoKXz9yFfgrgNtYgjoz6jfBI1Ol90 3NZeKgHz4geTHcmiwj/VFOnOfmm6DpVODx9eg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rNkk0KsbO3YcUF9ymJ/Izy+/IeIKEUGythTLywp5Ihs=; b=UW6DnAzQMlj6bWL1U8cvd3DHgjXntL41XE2CL6eq/5Y/9iiDpwl2VWH6guxZIAQ39V 3UUDFJceWKaMGkOpkoAwkT3lokiYf9fxOh4ANTrJqCgzeZ4rZ3ME6BK9RQcPkq0kclmK MOKIG8/SH/r1JNVBbnVZsbtOHz/6sHKEfv0/MOfEdd1rxA+8BGkdxLQmAeih7CHjNpL+ xGHWSqwnb0ZiOs/Z+86db3GwkeEZguk7WnVQrF1HsU6WvhufVvbetO45erBgRbT8fWm3 +B0zP4XjcgWgxfHrwxWuo1XAH99o6+V5BIB5whNNQRP5pU+TpzKyOadEvc9vsiyZCEpr pUgQ== X-Gm-Message-State: APjAAAW/ScFJC8aD1ERSbi+TCc8Zs3N853f9lGOaTYymufEsHVadL/zS 8pEpWn95fVbgDS5UQddNSyxjVsN+4azEHtloOh3MNMJSJ/UoYA== X-Google-Smtp-Source: APXvYqzAuwJZzHjJO+VMYRz/onGA03PFgeWDiSBswwI4SsuQTJYCfILB3zo1KrRCnyTMFgUxJOpzvnc+lfbZ X-Received: by 2002:a5d:6449:: with SMTP id d9mr23754483wrw.192.1560843715707; Tue, 18 Jun 2019 00:41:55 -0700 (PDT) Received: from localhost.localdomain (46-163-209-30.blcnet.fi. [46.163.209.30]) by smtp-relay.gmail.com with ESMTPS id l18sm212063wrn.66.2019.06.18.00.41.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 00:41:55 -0700 (PDT) X-Relaying-Domain: okoko.fi From: Marko Kohtala To: linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Bartlomiej Zolnierkiewicz , Mark Rutland , Rob Herring , Daniel Vetter , David Airlie , =?utf-8?b?TWljaGFsIFZva8OhxI0=?= , Marko Kohtala Subject: [PATCH 6/6] video: ssd1307fb: Add devicetree configuration of display setup Date: Tue, 18 Jun 2019 10:41:11 +0300 Message-Id: <20190618074111.9309-7-marko.kohtala@okoko.fi> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190618074111.9309-1-marko.kohtala@okoko.fi> References: <20190618074111.9309-1-marko.kohtala@okoko.fi> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Various displays have differences that only mean initializing the display driver IC with different fixed register values. Defining these in devicetree offers easier way to adapt the driver to new displays than requiring a patch to the kernel. This adds devicetree properties needed to make the initialization match the example setup as offered by Densitron for their 128x36 display. It also makes some old one bit parameter handling a little cleaner. Signed-off-by: Marko Kohtala --- drivers/video/fbdev/ssd1307fb.c | 80 ++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 4f4a1b99d17d..fca1e91d03d9 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -29,6 +29,7 @@ #define SSD1307FB_SET_COL_RANGE 0x21 #define SSD1307FB_SET_PAGE_RANGE 0x22 #define SSD1307FB_CONTRAST 0x81 +#define SSD1307FB_SET_LOOKUP_TABLE 0x91 #define SSD1307FB_CHARGE_PUMP 0x8d #define SSD1307FB_SEG_REMAP_ON 0xa1 #define SSD1307FB_DISPLAY_OFF 0xae @@ -37,6 +38,7 @@ #define SSD1307FB_START_PAGE_ADDRESS 0xb0 #define SSD1307FB_SET_DISPLAY_OFFSET 0xd3 #define SSD1307FB_SET_CLOCK_FREQ 0xd5 +#define SSD1307FB_SET_AREA_COLOR_MODE 0xd8 #define SSD1307FB_SET_PRECHARGE_PERIOD 0xd9 #define SSD1307FB_SET_COM_PINS_CONFIG 0xda #define SSD1307FB_SET_VCOMH 0xdb @@ -59,10 +61,14 @@ struct ssd1307fb_deviceinfo { }; struct ssd1307fb_par { - u32 com_invdir; - u32 com_lrremap; + unsigned area_color_enable : 1; + unsigned com_invdir : 1; + unsigned com_lrremap : 1; + unsigned com_seq : 1; + unsigned lookup_table_set : 1; + unsigned low_power : 1; + unsigned seg_remap : 1; u32 com_offset; - u32 com_seq; u32 contrast; u32 dclk_div; u32 dclk_frq; @@ -70,6 +76,7 @@ struct ssd1307fb_par { struct i2c_client *client; u32 height; struct fb_info *info; + u8 lookup_table[4]; u32 page_offset; u32 prechargep1; u32 prechargep2; @@ -77,7 +84,6 @@ struct ssd1307fb_par { u32 pwm_period; struct gpio_desc *reset; struct regulator *vbat_reg; - u32 seg_remap; u32 vcomh; u32 width; }; @@ -99,6 +105,9 @@ static const struct fb_fix_screeninfo ssd1307fb_fix = { static const struct fb_var_screeninfo ssd1307fb_var = { .bits_per_pixel = 1, + .red = { .length = 1 }, + .green = { .length = 1 }, + .blue = { .length = 1 }, }; static struct ssd1307fb_array *ssd1307fb_alloc_array(u32 len, u8 type) @@ -335,7 +344,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par) } /* Set COM direction */ - com_invdir = 0xc0 | (par->com_invdir & 0x1) << 3; + com_invdir = 0xc0 | par->com_invdir << 3; ret = ssd1307fb_write_cmd(par->client, com_invdir); if (ret < 0) return ret; @@ -368,6 +377,22 @@ static int ssd1307fb_init(struct ssd1307fb_par *par) if (ret < 0) return ret; + /* Set Set Area Color Mode ON/OFF & Low Power Display Mode */ + if (par->area_color_enable || par->low_power) { + u32 mode; + + ret = ssd1307fb_write_cmd(par->client, + SSD1307FB_SET_AREA_COLOR_MODE); + if (ret < 0) + return ret; + + mode = (par->area_color_enable ? 0x30 : 0) | + (par->low_power ? 5 : 0); + ret = ssd1307fb_write_cmd(par->client, mode); + if (ret < 0) + return ret; + } + /* Set precharge period in number of ticks from the internal clock */ ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD); if (ret < 0) @@ -383,8 +408,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par) if (ret < 0) return ret; - compins = 0x02 | !(par->com_seq & 0x1) << 4 - | (par->com_lrremap & 0x1) << 5; + compins = 0x02 | !par->com_seq << 4 | par->com_lrremap << 5; ret = ssd1307fb_write_cmd(par->client, compins); if (ret < 0) return ret; @@ -408,6 +432,28 @@ static int ssd1307fb_init(struct ssd1307fb_par *par) if (ret < 0) return ret; + /* Set lookup table */ + if (par->lookup_table_set) { + int i; + + ret = ssd1307fb_write_cmd(par->client, + SSD1307FB_SET_LOOKUP_TABLE); + if (ret < 0) + return ret; + + for (i = 0; i < ARRAY_SIZE(par->lookup_table); ++i) { + u8 val = par->lookup_table[i]; + + if (val < 31 || val > 63) + dev_warn(&par->client->dev, + "lookup table index %d value out of range 31 <= %d <= 63\n", + i, val); + ret = ssd1307fb_write_cmd(par->client, val); + if (ret < 0) + return ret; + } + } + /* Switch to horizontal addressing mode */ ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE); if (ret < 0) @@ -610,17 +656,26 @@ static int ssd1307fb_probe(struct i2c_client *client, if (of_property_read_u32(node, "solomon,prechargep2", &par->prechargep2)) par->prechargep2 = 2; + if (!of_property_read_u8_array(node, "solomon,lookup-table", + par->lookup_table, ARRAY_SIZE(par->lookup_table))) + par->lookup_table_set = 1; + par->seg_remap = !of_property_read_bool(node, "solomon,segment-no-remap"); par->com_seq = of_property_read_bool(node, "solomon,com-seq"); par->com_lrremap = of_property_read_bool(node, "solomon,com-lrremap"); par->com_invdir = of_property_read_bool(node, "solomon,com-invdir"); + par->area_color_enable = + of_property_read_bool(node, "solomon,area-color-enable"); + par->low_power = of_property_read_bool(node, "solomon,low-power"); par->contrast = 127; par->vcomh = par->device_info->default_vcomh; /* Setup display timing */ - par->dclk_div = par->device_info->default_dclk_div; - par->dclk_frq = par->device_info->default_dclk_frq; + if (of_property_read_u32(node, "solomon,dclk-div", &par->dclk_div)) + par->dclk_div = par->device_info->default_dclk_div; + if (of_property_read_u32(node, "solomon,dclk-frq", &par->dclk_frq)) + par->dclk_frq = par->device_info->default_dclk_frq; vmem_size = DIV_ROUND_UP(par->width, 8) * par->height; @@ -654,13 +709,6 @@ static int ssd1307fb_probe(struct i2c_client *client, info->var.yres = par->height; info->var.yres_virtual = par->height; - info->var.red.length = 1; - info->var.red.offset = 0; - info->var.green.length = 1; - info->var.green.offset = 0; - info->var.blue.length = 1; - info->var.blue.offset = 0; - info->screen_buffer = vmem; info->fix.smem_start = __pa(vmem); info->fix.smem_len = vmem_size;