From patchwork Wed Sep 28 08:24:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Yi X-Patchwork-Id: 9353411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 639F360757 for ; Wed, 28 Sep 2016 09:10:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 503F22945B for ; Wed, 28 Sep 2016 09:10:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41B3F2945E; Wed, 28 Sep 2016 09:10:06 +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=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4FC302945B for ; Wed, 28 Sep 2016 09:10:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 009A66E3D8; Wed, 28 Sep 2016 09:10:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 18390 seconds by postgrey-1.35 at gabe; Wed, 28 Sep 2016 09:10:00 UTC Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0069.outbound.protection.outlook.com [104.47.40.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3BA5D6E3D8 for ; Wed, 28 Sep 2016 09:10:00 +0000 (UTC) Received: from DM5PR03CA0019.namprd03.prod.outlook.com (10.175.104.29) by SN1PR0301MB2014.namprd03.prod.outlook.com (10.163.225.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Wed, 28 Sep 2016 08:36:38 +0000 Received: from BL2FFO11FD041.protection.gbl (2a01:111:f400:7c09::176) by DM5PR03CA0019.outlook.office365.com (2603:10b6:3:118::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5 via Frontend Transport; Wed, 28 Sep 2016 08:36:38 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD041.mail.protection.outlook.com (10.173.161.137) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Wed, 28 Sep 2016 08:36:37 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u8S8aX01025742; Wed, 28 Sep 2016 01:36:34 -0700 From: Meng Yi To: , , Subject: [PATCH v5] drm/fsl-dcu: Implement gamma_lut atomic crtc properties Date: Wed, 28 Sep 2016 16:24:29 +0800 Message-ID: <1475051069-24452-1-git-send-email-meng.yi@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131195253986954409; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(47776003)(5001770100001)(77096005)(11100500001)(48376002)(50466002)(7846002)(356003)(8666005)(97736004)(189998001)(4326007)(8936002)(305945005)(8676002)(586003)(81166006)(81156014)(104016004)(50226002)(106466001)(50986999)(92566002)(36756003)(2906002)(19580395003)(105606002)(626004)(85426001)(87936001)(5003940100001)(229853001)(33646002)(68736007)(5660300001)(86362001)(19580405001)(69596002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB2014; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD041; 1:Qtq4QceMPP7L43/O+92OLzYjJi10+evCdK9xcceMuFu5oFW2/TUfdPiI4OLyKpAKd4TBn7bfBe4PQXCOxUT+x4OYRzvG751BmCvkhHuqwc4u1/Do109zjZQFR4hZtgVfM9vqv0yuQQ5CORoXoeC+3Vyt91peXYMkMWnwqg5JyFVHQ29/jKbArfxgh8C/VeulqE/PXyHOBII95v+So8B87i3rNJHB95DTelxVcRkx0vfqd5CZAIiwCSZhIjdM6orNiPQ+R/GJ9P+CuJROde3fwuPPDYb7Q4GQS8+DoiISU2L/CArUeAiGavxhwrptCRwJEA31NtfK5yPOtJr63AzHg67VSogtTFPTcJxLRXQtZ6MszTkSlGP1XZ7itdNM1lDLL9yH9f9tQZ5Rc0VwmttlWNeXb+AVEPdi4WCpL7qDf4YrR5b+zddP6/PMnIfHrtIthU7OEJQ8fghO1OIguL29S69DemBDJRjaTDnU1Q6E4HjZKJmiGKjZTdV41T/vQfv2TEjFB/0SLksjpSrzBZT7bSGYKYVxe7yB1dULYXQBKdbexPriSUlAkr47/YclISjykKCGiBybngfsAtOuA7KCaph80b3sRRKbnhzZ413RduoVTl8p/W4lLnJdrxkbiMcb2iM+IAFgmTXvaU6y7oWrDdFcTQUI0porYoHNEnVl6dS4H5BlJ2EmTUid5hQKtayCJbk9XJtymmNnYfZiJn3T1WnhLYb5niUWAkUaWIzKxxy28O1mm+DRXT5opyE1M3g3pCzaWrKsPJKTwwVkqNur8A== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 8e065042-3316-4a34-ab48-08d3e77a9090 X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2014; 2:2mbXNsb+dFubEkf22wEwWknjopyZzi2AnhBKdlzKneuLLp5ft3AYqAvBrii3w45qUH+sMcU2naVwtXRUSuUiKN6ZOcVcl+wkpF86F1NuesZIFUwX/29eW9/pBOb2Wh5JtWftWZYOQWpj9vtJJGYnjx0pPJhgWqrzNVvZTA3Z9Gyj7AeeR99V4wvd4trIcdg0; 3:KTUpQ07wvUtnM2Ijt4SqfVYPqcmL99rMmfBOP/gtyzQD/6R3yZY7Ze43vXddskBeh34m2KzSJ/opdb9ezYX0HwR17wRFNjqUJ6jYqmCR7vzZlq5TGdStAgnRBNiV2CryZ7DBpDUidAxUjJw/11mbbmP/VqNI0QO9+nTReaiWaVkh6knkSqbGB3fxbDBYA7Smm1STe5gKtzroD9QTc+OxFQXLnzevkxf9+zHOhNmRlHw=; 25:7hD02D6sUPV+RC54Ktl8JT7MM2v6bBi4ouvOCqdZ8HFCO+6U2NVH0n+QaF4eyJs/aem09U+s+k7yst0dNecyUpMo3lQPIk2nHzqEUxaGv0XingyxnO8N6hJuX/xRrDBZ/g35Pqm7PgccMJOClBpmMCk1RMHEHUtoin4rikhBKKytzCtHFXUW1AdBruRXat7GbrdOD7vpt7Z8CaTYlggCFY6Tsfgnx6RITNDHYtwKF3Lx8xJO4F7pDKLUEH297poh6ydj5BGWxTOdX/ZyLPl6zoA4PtDZgx7CvUqe/QzK3IgTcYlomwhUwOFUuYKklUP4NuYA/FT5flo3OEaYAwr7L36cPMeyZ8amrCA24+NAkQnbFbVEIViXpNpQ5+1YAiJ2b8/k0R+XMklMGqzgU8IsDAdpO2CqVCzK17hQ/Y88Keg= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB2014; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2014; 31:Pb+gM5CaQTkak0dDH8fGe93su40csaDpxHldKK8rPqxnH7P8hd8S02VUtG9fM99/aMSlLgYaSbWbrK8pn6YbMa2SSFQWootzpXdXAP+BiMbWnGRvLQxgMP2CHQx3cGVrMdCT5AgFXUF89DITXGp0LDuzBWeZHhzMK0fAvPrTRa6y2O4lcU2ELuCwoxEwQ5vlUYWPpesMuVufhDvvzW0hexwIm4YTd9NDsK9dWETrEKw=; 4:fPCeaGXCu0aBwWz4vmc54kiUSBsjKnshKsvGsxXZhtXNC/KZlQvAfFnbfDKJ+AsCXao0+WjDY6SNRivrs7cmQQGhYu+rcgsjszbWutgToAWCIy2pOG8d3DdXa8UaDza49YYyWuQYUWnGGJfCLzjuQ/IVAlv+5QQx4/jmcyHjXlEDw/rg0dDl1mAztgmxhgmTcxhRiBN8W97WaaNUYnAZd5FNEwqfZMcyhZqZh6gSztDe2tfzuor1+rM3VhrIrIc89coko4EgHqd7dmFDQZtaZvOeQXawUpwt+L1u5d5AVhJcdmEYh9FGTH4kumjjpe6XhEuDfhzh1vw7tODt/duT8EvuDb79a0SRceEmSaFEAp2jX7DzGdtpYH5WujISgmNYqh6pB2E2yag54b7XS0NebwjPiREctWK+KKiR7SbPMejJReYiWjpCYE3kiGPjWHKJ/DPSlNnpsqXIjk7TXbt8nUWh5aCx2ez02Oe8rd5Y2SwX8vdfsxq5sDN1O4OtehHtIe9qY+jsZzDMgdqxt2qn1M+nxYwRCvK2RCgho2P5oyc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13015025)(13017025)(13023025)(13024025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:SN1PR0301MB2014; BCL:0; PCL:0; RULEID:(400006); SRVR:SN1PR0301MB2014; X-Forefront-PRVS: 0079056367 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB2014; 23:7XaQOqodHP8vLzOF288Xmnjcjv4KKs7Bw82FiS/?= =?us-ascii?Q?9fgcCp4igtyYfYIqJhg+0h3OgbAnIP3Ze5RCHix+sLKlxe9vQljIRQ4TGZBr?= =?us-ascii?Q?kj4rOWnLW2RV6Mrt6sQGAaOFJXT5YoIl9um4b68ek6mJjEQXHdLf+l+Jjr3l?= =?us-ascii?Q?k92cFdyIZFsoFSo+cVQSGkwGsxvkhTfwWBCNKjxVzvyz9ztCynBP7wL+3h9L?= =?us-ascii?Q?hf14XvF27lWrGIO4s/zGFMoiN241Ew6967XeaWJx3wAJSYL6KOdR2o8SwlFf?= =?us-ascii?Q?YEHKtN2M6yhs92ssrRfMvBGKci8XarNUSWPkuwlOH5Vt5foWlU8Qh2rR8pab?= =?us-ascii?Q?4PRQ2TWGaSu31W6WhVLZKnc36fAMe/FMvxnj04Azs75h2+OmcBi1v38gRmnR?= =?us-ascii?Q?oT67hKSn//E6c0bv9W7Cth9QARLjdEkoRQXgTgyt/cxXZ5PHPgeL4jNzqHhh?= =?us-ascii?Q?7y5w0bRPLACr5wdrYoIWSXwsV6zSj9Zi3qVmI+iAZfv9gI3TlHpQ55ru36KJ?= =?us-ascii?Q?vEX5sIPC6EzZqI/SdP3oSTSg10beZieaYuyrST1AQoAIs/nlqpUt+aSnkQIA?= =?us-ascii?Q?DWPKpGkkCsiRfVG3FRYLRpeLPPzlBvZzMZ2dOoTpxZK2of+LTLjd8eVLwIEE?= =?us-ascii?Q?PBQzDx9H01grSZ3pb3xZ2HevMZFsMeYk0P0u5AVawOt48FTAjRG/Guu1evNF?= =?us-ascii?Q?HdtdyKND0X9kR5HoDYe2AX9L960+4dXKyxfkwisIusX0wEOjUbEvp08azuAX?= =?us-ascii?Q?LDJZncsf1Lc/ibcCySNmAtZDWIR/h69e5h7SE+7aiINHkyJTIi/UiYqTQmVM?= =?us-ascii?Q?wl/+DYG6SPI4Ub8pLJxwQZtWbd31KdigMxoiKTkbOMtOGF+mlQhQC4UNb9nu?= =?us-ascii?Q?9BmB7BpdxcPl9D2GlmAOBbYStA75icQuRtv6r0fI43daP0F0Kw+d4Wur2B5D?= =?us-ascii?Q?BeemU9Yh3043b/N0kC9hdQalKTgZJXHVuvb6aGV4G16kSV+a43YAMC8xUCXJ?= =?us-ascii?Q?orrHJZ5+xtqm7S/oa5anFhbcs+K95eW5lXYPlC/RYBLzVcHR03a2yrvFXrwo?= =?us-ascii?Q?aPd1waWt6C6vmZ2jUJpHKqceKEZ0c97vWOvRaVkKAOUfbHJiVIaym63QqIZs?= =?us-ascii?Q?CSOK8g4Hncu6Lf8HUD6Olnf3YwCg4no8H?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2014; 6:QTSQ0PmvFg5izoYDixWgvK5TrlQUX0RutDg0TyT8bCSc6ALP+Cowr+4HB0vvcuBoJ0dvcMtdFh9pjGtFzBn+8mOIrpKTt0iTO/r9dZ7PBkN+NXhzL3FxrITKkeE3qvhb1p/U8Lkn7ShmzrI4RNYzh74hcqLvrQUljkDcdY0L8RJRDxCDIOa/QgY10pQPeY9taYGHmCAlu5hYgnp/4HkTg097jlIOk7dteR2O6bK+eT8TQGqU6VdxVUpjorCcQZgeBPfJL6zDelsrMKwHYcE4RBpTx0vGijQNO2et9L9CCZ4=; 5:dB9wzIldDDDL9InbKIDim2BLzQuuZYaq7MhZTZ120D0ZVAGcyPuNEd1AFzSFS7JACq1vKI5a2sP5/7cieTT6Lk1scIOUUV6CpAYdDMBtKNcf0DWuVTCpYNHYYWDCERhV5tuhdR3elVaKkI16r8cfkTpgN9s97AKkXH22NvmWy5Y=; 24:E/TgzSFGqHz4I0hPAnPIT2SNU6li18pfpJ+bXx2WZ0P5+xoFMrcDmPA/+o2uSYsxuw9KZonKqup9gstuZbYknfA+UhcxMQ8c5VVY47Bb8eo=; 7:cbFxbNGJbZuFEfdt3wNQE6X2wCaw6JH7nSLMkpr6fdxsLGvc6Nsgm1f7UNNRic0XxW/aNC3hXCjf1LCh60/FdCKxAxOEbhoS5P8A3PAGJSuPG4PMMrYzGh8ItkQXk6egE0nCmaU2hrerTp3lbxHue1x4E0o1dF6mdtM0479XPxGDMPZ/ey8dwdTD7CdyNmNwNWnydlkH94onMQMP9s2ZoUgwZNIlsav/JYCPAD61wrrluhi5mdm2TT3nFUXnbauoNa0QAyo1nEE0YqGas5b5TCjFL5xNU9aZOSVapKsSEc9afmqTcGxAcSP/uUduIujG SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2016 08:36:37.9622 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0301MB2014 Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Meng Yi X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Gamma correction is optional and can be used to adjust the color output values to match the gamut of a particular TFT LCD panel Split the DCU regs into "regs", "palette", "gamma" and "cursor". Create a second regmap for gamma memory space using little endian. The registers after the first address space are not accessed yet, hence new device trees would even work with old kernels. Just new kernel need the new format so we can access the separate gamma reg space. Suggested-by: Stefan Agner Signed-off-by: Meng Yi Acked-by: Rob Herring Tested-by: Meng Yi --- Changes since V1: -created a second regmap for gamma -updated the DCU DT binding -removed Kconfig for gamma and enable gamma when valid data filled. -extended and simplified comment lines. --- .../devicetree/bindings/display/fsl,dcu.txt | 12 +++++++- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 33 ++++++++++++++++++++ drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 35 +++++++++++++++++++++- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h | 7 +++++ 4 files changed, 85 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/display/fsl,dcu.txt b/Documentation/devicetree/bindings/display/fsl,dcu.txt index 63ec2a6..8140b5d 100644 --- a/Documentation/devicetree/bindings/display/fsl,dcu.txt +++ b/Documentation/devicetree/bindings/display/fsl,dcu.txt @@ -6,6 +6,12 @@ Required properties: * "fsl,vf610-dcu". - reg: Address and length of the register set for dcu. + Must contain four address/length tuples: + 1. Register address space + 2. Palette/Tile address space + 3. Gamma address space + 4. Cursor address space +- reg-names: Should be "regs", "palette", "gamma" and "cursor" - clocks: Handle to "dcu" and "pix" clock (in the order below) This can be the same clock (e.g. LS1021a) See ../clocks/clock-bindings.txt for details. @@ -20,7 +26,11 @@ Optional properties: Examples: dcu: dcu@2ce0000 { compatible = "fsl,ls1021a-dcu"; - reg = <0x0 0x2ce0000 0x0 0x10000>; + reg = <0x0 0x2ce0000 0x0 0x2000>, + <0x0 0x2ce2000 0x0 0x2000>, + <0x0 0x2ce4000 0x0 0xc00>, + <0x0 0x2ce4c00 0x0 0x400>; + reg-names = "regs", "palette", "gamma", "cursor"; clocks = <&platform_clk 0>, <&platform_clk 0>; clock-names = "dcu", "pix"; big-endian; diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c index 3371635..6371e4d 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c @@ -22,6 +22,31 @@ #include "fsl_dcu_drm_drv.h" #include "fsl_dcu_drm_plane.h" +static void fsl_crtc_gamma_set(struct drm_crtc *crtc, struct drm_color_lut *lut, + uint32_t size) +{ + struct fsl_dcu_drm_device *fsl_dev = crtc->dev->dev_private; + unsigned int i; + + if (crtc->state->gamma_lut->data) { + for (i = 0; i < size; i++) { + regmap_write(fsl_dev->regmap_gamma, FSL_GAMMA_R + 4 * i, + lut[i].red); + regmap_write(fsl_dev->regmap_gamma, FSL_GAMMA_G + 4 * i, + lut[i].green); + regmap_write(fsl_dev->regmap_gamma, FSL_GAMMA_B + 4 * i, + lut[i].blue); + } + + regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE, + DCU_MODE_EN_GAMMA_MASK, + DCU_MODE_GAMMA_ENABLE); + } else { + regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE, + DCU_MODE_EN_GAMMA_MASK, 0); + } +} + static void fsl_dcu_drm_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) { @@ -37,6 +62,10 @@ static void fsl_dcu_drm_crtc_atomic_flush(struct drm_crtc *crtc, drm_crtc_send_vblank_event(crtc, event); spin_unlock_irq(&crtc->dev->event_lock); } + + if (crtc->state->color_mgmt_changed && crtc->state->gamma_lut) + fsl_crtc_gamma_set(crtc, (struct drm_color_lut *) + crtc->state->gamma_lut->data, 256); } static void fsl_dcu_drm_disable_crtc(struct drm_crtc *crtc) @@ -135,6 +164,7 @@ static const struct drm_crtc_funcs fsl_dcu_drm_crtc_funcs = { .page_flip = drm_atomic_helper_page_flip, .reset = drm_atomic_helper_crtc_reset, .set_config = drm_atomic_helper_set_config, + .gamma_set = drm_atomic_helper_legacy_gamma_set, }; int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) @@ -158,5 +188,8 @@ int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) drm_crtc_helper_add(crtc, &fsl_dcu_drm_crtc_helper_funcs); + drm_crtc_enable_color_mgmt(crtc, 0, false, 256); + drm_mode_crtc_set_gamma_size(crtc, 256); + return 0; } diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c index 092aaec..e662890 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c @@ -48,6 +48,20 @@ static const struct regmap_config fsl_dcu_regmap_config = { .volatile_reg = fsl_dcu_drm_is_volatile_reg, }; +/* + * force using little endian here since ls1021a's gamma regs are little + * endian while the other regs are big endian, and all vf610s's regs + * are little endian + */ +static const struct regmap_config fsl_dcu_regmap_gamma_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .val_format_endian = REGMAP_ENDIAN_LITTLE, + + .volatile_reg = fsl_dcu_drm_is_volatile_reg, +}; + static int fsl_dcu_drm_irq_init(struct drm_device *dev) { struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; @@ -327,7 +341,7 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) struct drm_device *drm; struct device *dev = &pdev->dev; struct resource *res; - void __iomem *base; + void __iomem *base, *base_gamma; struct drm_driver *driver = &fsl_dcu_drm_driver; struct clk *pix_clk_in; char pix_clk_name[32]; @@ -370,6 +384,25 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) return PTR_ERR(fsl_dev->regmap); } + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gamma"); + if (!res) { + dev_err(dev, "could not get gamma memory resource\n"); + return -ENODEV; + } + + base_gamma = devm_ioremap_resource(dev, res); + if (IS_ERR(base_gamma)) { + ret = PTR_ERR(base_gamma); + return ret; + } + + fsl_dev->regmap_gamma = devm_regmap_init_mmio(dev, base_gamma, + &fsl_dcu_regmap_gamma_config); + if (IS_ERR(fsl_dev->regmap_gamma)) { + dev_err(dev, "regmap_gamma init failed\n"); + return PTR_ERR(fsl_dev->regmap_gamma); + } + fsl_dev->clk = devm_clk_get(dev, "dcu"); if (IS_ERR(fsl_dev->clk)) { dev_err(dev, "failed to get dcu clock\n"); diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h index 3b371fe7..2610b6c 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h @@ -25,6 +25,8 @@ #define DCU_MODE_NORMAL 1 #define DCU_MODE_TEST 2 #define DCU_MODE_COLORBAR 3 +#define DCU_MODE_EN_GAMMA_MASK 0x04 +#define DCU_MODE_GAMMA_ENABLE BIT(2) #define DCU_BGND 0x0014 #define DCU_BGND_R(x) ((x) << 16) @@ -165,6 +167,10 @@ #define VF610_LAYER_REG_NUM 9 #define LS1021A_LAYER_REG_NUM 10 +#define FSL_GAMMA_R 0x000 +#define FSL_GAMMA_G 0x400 +#define FSL_GAMMA_B 0x800 + struct clk; struct device; struct drm_device; @@ -182,6 +188,7 @@ struct fsl_dcu_drm_device { struct device *dev; struct device_node *np; struct regmap *regmap; + struct regmap *regmap_gamma; int irq; struct clk *clk; struct clk *pix_clk;