From patchwork Mon Aug 5 08:58:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 170527 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4011731ile; Mon, 5 Aug 2019 01:59:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsSRtLYz32HYeUiAScj6WGgZh9770/8dV6/P3tUuDQY4sI9DbOBw9JiG2UolC204B6DS5T X-Received: by 2002:a17:90a:25af:: with SMTP id k44mr16811001pje.122.1564995548384; Mon, 05 Aug 2019 01:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564995548; cv=none; d=google.com; s=arc-20160816; b=SModvKOpbyxXSvPHdqFs6Gky0xT3CNwjv0ENV9aRQV9gSkrUi/JqOCX+rXRy5Ws1V+ 7E7+RJID9dH3PfNXJH7MgGj7xTvImOVSdCiRH7YOYqvnLoIcn0+NPRfmIfP0rk6tmQll Eqx7asw61AU86SmQvvCsry7+T2X4NB+8vXtfdhAv5eORm1Z3OQTnVlO0b6EjvTqY0LqU rCwWXpJLa0UvXUxGXtijmkTFDUCV15sOe2tO76hUaub1uoDKeD4Zb3YuGiITY4a8rUYA IeCvEh0ozqkqkFGZXFhvvNiF0jVo0ITMc9O0GGcco27z9f4VmXJSfdh+uIK9T3g5nMg0 xUPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=UqxPPW5ZZs0gexpDoiqdWuy6LILz+DCy717QubOhcrw=; b=iIFuhT/5dUwUvPkqM7iGhytfViJ70RDzUx1eBNDAzcMVXjnsB5RYAivZ6gRDbIYS3M a0zjyk7LdJcOKS4sZoFDhhPvLPUlI7pbIc1Es/hDGbQQWIciW2W9EVlQ8QdeYqCD+QGX AXTTp+HGy6hv2KOuwT404Dl92rbltiSqyGFw1MBhOZu4IsGu0YfNaH8OG0BQaH91Y/2H 7keUzd5h65e4V4x8d7NdvVfIzrjLu7XQsPWqgKDvmE3yhm7KflOqK/JcFG6ASPPZuNk0 07LhAUroFsde3EIeKgoOib/CAtVvSS26g3D7mtMAxF+xD1P50WQLICim351/ONR5cqZe Jr1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id 33si66897145plv.153.2019.08.05.01.59.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Aug 2019 01:59:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A74A6E30D; Mon, 5 Aug 2019 08:59:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0892C6E30D for ; Mon, 5 Aug 2019 08:59:06 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id p17so78639350ljg.1 for ; Mon, 05 Aug 2019 01:59:05 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=XS8NSKoh+CguW/bz0NOSFtpL/Lk0LcQIGEWD1T1/JOM=; b=SJZUkPOJVG+IHw96S0LQiM6yHK4gD1iU3rTSqGv/3zCoVBFyiEQSqdAqRBEfm6AYqF o3hXFfMqLgOmfPdk6mNhQksJbaFNqK+3crZclY/AYjWdZgsgECpr7fQabiAno7+sma0U GWAeJ7J+QkVogeen6xVTMGvy3gFM1k1V3tcbcyMFHuU8+7nIBm4KyNekXGI6YeUrQ2YN v46oNAR+lmygtAfiqyDMUyr35GlU0PegIsauPmtvB0Y/RiguVJjwgH3X47Xt+IC2tIAU Wo+se1XQY6VC8n+n3+YtxLe7KwOMt1040kxYwrSOtifcWAkPB/zEplyfr3OZp0IxnIKK OHbQ== X-Gm-Message-State: APjAAAXJwlopNGqWTbd1HHv3XRtkLGCO85ynwYlc4dQqf3ltLCo2DLit C6hw1gpCliZNIija1NFs3iBirQ== X-Received: by 2002:a2e:8495:: with SMTP id b21mr59894302ljh.149.1564995544322; Mon, 05 Aug 2019 01:59:04 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id b20sm234500lfc.17.2019.08.05.01.59.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 01:59:03 -0700 (PDT) From: Linus Walleij To: Daniel Tang , Fabian Vogt Subject: [PATCH 1/4 v2] drm/pl111: Support grayscale Date: Mon, 5 Aug 2019 10:58:44 +0200 Message-Id: <20190805085847.25554-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190805085847.25554-1-linus.walleij@linaro.org> References: <20190805085847.25554-1-linus.walleij@linaro.org> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XS8NSKoh+CguW/bz0NOSFtpL/Lk0LcQIGEWD1T1/JOM=; b=TaJN+q5ENJDArezn6ZlerbgxeGiw7w3OKzEjj/3FnWUanN6/R+IL+cMVEdjLJZxQKc gUp7dFwr2lelmvLY8MA1Lzkjc2rbXkWEz+2YndDZtEYMQ/DaEoT7EZpBFX/n19VW4Ie+ +ILJrk4AS9SkeW0SDceOJ+UXb0dspph9y/Io5YiEXGInLxSVNs3dkanwW/qQkFRFI6vQ LdJYfz3GgDcxXLcNrfe7ZTBalXzR+8vwMik8VihO5yKajOM6Wssw5zBwiCnFgOnbYhpM 9+oJB3B2qD5ftS/VSXFeBvX1RtXMbZK6Uy/ZexLrVVDZL5z0HYMh5Uevd5QNyBXYTPqQ pOJg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sam Ravnborg , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Migrating the TI nspire calculators to use the PL111 driver for framebuffer requires grayscale support for the elder panel which uses 8bit grayscale only. DRM does not support 8bit grayscale framebuffers in memory, but by defining the bus format to be MEDIA_BUS_FMT_Y8_1X8 we can get the hardware to turn on a grayscaling feature and convert the RGB framebuffer to grayscale for us. Cc: Daniel Tang Cc: Fabian Vogt Tested-by: Fabian Vogt Acked-by: Sam Ravnborg Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Now tested --- drivers/gpu/drm/pl111/pl111_display.c | 29 +++++++++++++++++++++++++-- include/linux/amba/clcd-regs.h | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/pl111/pl111_display.c b/drivers/gpu/drm/pl111/pl111_display.c index 450166d167f6..1751fca6f6f5 100644 --- a/drivers/gpu/drm/pl111/pl111_display.c +++ b/drivers/gpu/drm/pl111/pl111_display.c @@ -126,6 +126,7 @@ static void pl111_display_enable(struct drm_simple_display_pipe *pipe, struct drm_framebuffer *fb = plane->state->fb; struct drm_connector *connector = priv->connector; struct drm_bridge *bridge = priv->bridge; + bool grayscale = false; u32 cntl; u32 ppl, hsw, hfp, hbp; u32 lpp, vsw, vfp, vbp; @@ -185,6 +186,20 @@ static void pl111_display_enable(struct drm_simple_display_pipe *pipe, if (connector->display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE) tim2 |= TIM2_IPC; + + if (connector->display_info.num_bus_formats == 1 && + connector->display_info.bus_formats[0] == + MEDIA_BUS_FMT_Y8_1X8) + grayscale = true; + + /* + * The AC pin bias frequency is set to max count when using + * grayscale so at least once in a while we will reverse + * polarity and get rid of any DC built up that could + * damage the display. + */ + if (grayscale) + tim2 |= TIM2_ACB_MASK; } if (bridge) { @@ -216,8 +231,18 @@ static void pl111_display_enable(struct drm_simple_display_pipe *pipe, writel(0, priv->regs + CLCD_TIM3); - /* Hard-code TFT panel */ - cntl = CNTL_LCDEN | CNTL_LCDTFT | CNTL_LCDVCOMP(1); + /* + * Detect grayscale bus format. We do not support a grayscale mode + * toward userspace, instead we expose an RGB24 buffer and then the + * hardware will activate its grayscaler to convert to the grayscale + * format. + */ + if (grayscale) + cntl = CNTL_LCDEN | CNTL_LCDMONO8; + else + /* Else we assume TFT display */ + cntl = CNTL_LCDEN | CNTL_LCDTFT | CNTL_LCDVCOMP(1); + /* On the ST Micro variant, assume all 24 bits are connected */ if (priv->variant->st_bitmux_control) cntl |= CNTL_ST_CDWID_24; diff --git a/include/linux/amba/clcd-regs.h b/include/linux/amba/clcd-regs.h index 516a6fda83c5..421b0fa90d6a 100644 --- a/include/linux/amba/clcd-regs.h +++ b/include/linux/amba/clcd-regs.h @@ -42,6 +42,7 @@ #define TIM2_PCD_LO_MASK GENMASK(4, 0) #define TIM2_PCD_LO_BITS 5 #define TIM2_CLKSEL (1 << 5) +#define TIM2_ACB_MASK GENMASK(10, 6) #define TIM2_IVS (1 << 11) #define TIM2_IHS (1 << 12) #define TIM2_IPC (1 << 13)