From patchwork Tue Aug 19 13:07:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jon Medhurst \(Tixy\)" X-Patchwork-Id: 35590 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f197.google.com (mail-yk0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3C341202FA for ; Tue, 19 Aug 2014 13:11:50 +0000 (UTC) Received: by mail-yk0-f197.google.com with SMTP id 142sf21455595ykq.8 for ; Tue, 19 Aug 2014 06:11:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:subject:from:to:cc:date :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=R2OmJCdRXcQF+nSWM2vQJdxDWC1ozM463r1PL68FW+Y=; b=bgIXlioRfxJBQRKtohUEFlpagxL8xJJ72urdZ7XKv7xMFqZnXO7+CGwAt8ylzhkhvi k2QYyd339rlI/xHtpEAk7Nvby8lsPLFdM5ztwfDuG9LGPJsII4NLxFTA/uPpf6V8Kaxn bEOfoMZ7THkP/MYuE/M+3YeqAMlmaydBc5tAO5jVXtUJLiu0GmZAdCfM4LyvsUN9jqgp cf4vu7RNWqM3/mpRTnWcpaSzNvBhVQuoTdQT6U8IsZJnz15A6F6h+NDxiLznFOwgesPJ 90hFPU0a9WZvT7rB3qo0NgBg30SCfZUzBuGpw9AndTAoFbsYz+hoULvl9FyvpKFdvski +cJw== X-Gm-Message-State: ALoCoQmEgTQk/jQzVWgwLViAyHkmQayGWQI6QZqVW1hIfMrh7UrPLSnN6bI+sttGo71hZKJ6IVLr X-Received: by 10.236.124.161 with SMTP id x21mr4437706yhh.48.1408453910038; Tue, 19 Aug 2014 06:11:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.170 with SMTP id u39ls2839510qga.21.gmail; Tue, 19 Aug 2014 06:11:49 -0700 (PDT) X-Received: by 10.52.146.194 with SMTP id te2mr26252632vdb.4.1408453909938; Tue, 19 Aug 2014 06:11:49 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id b8si8616835vcf.7.2014.08.19.06.11.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Aug 2014 06:11:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id le20so7389757vcb.14 for ; Tue, 19 Aug 2014 06:11:49 -0700 (PDT) X-Received: by 10.52.119.229 with SMTP id kx5mr1245666vdb.40.1408453909842; Tue, 19 Aug 2014 06:11:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp237494vcb; Tue, 19 Aug 2014 06:11:49 -0700 (PDT) X-Received: by 10.66.161.41 with SMTP id xp9mr28229137pab.120.1408453908588; Tue, 19 Aug 2014 06:11:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zd10si26824592pac.144.2014.08.19.06.11.39 for ; Tue, 19 Aug 2014 06:11:40 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753298AbaHSNHh (ORCPT + 23 others); Tue, 19 Aug 2014 09:07:37 -0400 Received: from smarthost01c.mail.zen.net.uk ([212.23.1.5]:52210 "EHLO smarthost01c.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752610AbaHSNHf (ORCPT ); Tue, 19 Aug 2014 09:07:35 -0400 Received: from [82.69.122.217] (helo=linaro1) by smarthost01c.mail.zen.net.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XJj8N-00019W-VR; Tue, 19 Aug 2014 13:07:32 +0000 Message-ID: <1408453651.3746.41.camel@linaro1.home> Subject: [PATCH] video: ARM CLCD: Ensure bits-per-pixel is a power of 2 and <= 32 From: "Jon Medhurst (Tixy)" To: Tomi Valkeinen , Russell King , Jean-Christophe Plagniol-Villard Cc: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pawel Moll , linux-arm-kernel@lists.infradead.org Date: Tue, 19 Aug 2014 14:07:31 +0100 X-Mailer: Evolution 3.12.2-1+b1 Mime-Version: 1.0 X-Originating-smarthost01c-IP: [82.69.122.217] Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tixy@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , If the device-tree specifies a max-memory-bandwidth property then the CLCD driver uses that to calculate the bits-per-pixel supported, however, it doesn't ensure that the result is a sane value, i.e. a power of 2 and <= 32 as the rest of the code assumes. Acked-by: Pawel Moll Signed-off-by: Jon Medhurst --- This fixes code which is new in 3.17 (commit d10715be03) and so I assume is a candidate for adding to a coming -rc ? Without the fix, people can be left (as I was) with a blank non-functioning screen even if they create a valid device-tree for the new driver functionality. drivers/video/fbdev/amba-clcd.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c index beadd3e..98b66b7 100644 --- a/drivers/video/fbdev/amba-clcd.c +++ b/drivers/video/fbdev/amba-clcd.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -650,6 +651,7 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) { struct device_node *endpoint; int err; + int bpp; u32 max_bandwidth; u32 tft_r0b0g0[3]; @@ -667,11 +669,15 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth", &max_bandwidth); - if (!err) - fb->panel->bpp = 8 * max_bandwidth / (fb->panel->mode.xres * + if (!err) { + bpp = 8 * max_bandwidth / (fb->panel->mode.xres * fb->panel->mode.yres * fb->panel->mode.refresh); - else - fb->panel->bpp = 32; + bpp = rounddown_pow_of_two(bpp); + if (bpp > 32) + bpp = 32; + } else + bpp = 32; + fb->panel->bpp = bpp; #ifdef CONFIG_CPU_BIG_ENDIAN fb->panel->cntl |= CNTL_BEBO;