From patchwork Wed Feb 1 12:05:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 9549465 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 57D1260415 for ; Wed, 1 Feb 2017 12:05:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48CAC28428 for ; Wed, 1 Feb 2017 12:05:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D5FE28429; Wed, 1 Feb 2017 12:05:19 +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.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 7295628305 for ; Wed, 1 Feb 2017 12:05:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2AD266E32B; Wed, 1 Feb 2017 12:05:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0057.outbound.protection.outlook.com [104.47.2.57]) by gabe.freedesktop.org (Postfix) with ESMTPS id 300A76E32A for ; Wed, 1 Feb 2017 12:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/O6qGor6yX4pjV71PLX4DxEC3Isvfg/D0E5oAnrUNCg=; b=b9zuwid/BmwRQMsKdK6pM9ffgQls6ufNMBe78w5PN+xYV06vvvsfaET8qxOlYUjF2K8Fg29Rh+I4kFuoNYKJoN6YQZ8E/nXpbTJ/bkSQ/xhTK19xz1CCqpk5u/t7ClDhP0Q3WjTP7ShpLIC92nllcCVz/OzXqKmYy6943qgAnkQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Mihail.Atanassov@arm.com; Received: from e110433-lin.cambridge.arm.com (217.140.96.140) by HE1PR08MB0890.eurprd08.prod.outlook.com (10.164.53.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Wed, 1 Feb 2017 12:05:08 +0000 From: Mihail Atanassov To: Subject: [PATCH] drm: mali-dp: Add CTM support Date: Wed, 1 Feb 2017 12:05:03 +0000 Message-ID: <1485950703-11163-1-git-send-email-mihail.atanassov@arm.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: AM4PR0101CA0071.eurprd01.prod.exchangelabs.com (10.165.22.167) To HE1PR08MB0890.eurprd08.prod.outlook.com (10.164.53.28) X-MS-Office365-Filtering-Correlation-Id: bdc200f9-e634-453c-9cd5-08d44a9a911e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:HE1PR08MB0890; X-Microsoft-Exchange-Diagnostics: 1; HE1PR08MB0890; 3:Kg0l0DbAx+qOfGsiECF58YuZlw68/kJB7wFdy2r8ouWI4Rt5S0mTDTkIzdPIEgZLs++8vAvCjg9l4WvirOa7b4tFSjvc5df1yxpddTNYMK/8yp9/OGv9oZIUFhFSk3cvSal3m/2GYsb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: 1; HE1PR08MB0890; 31:FEKFMXbkb81JiBl01fEWcRtC9pxUragriUn4HhnJrL/PwLkNDQaVdqu8Mt5jUTFU336tIu7yBtIgzeoYpp2HUbClXn4zF6ieLj/JC77T0EIuWvevOuHK7ZO/CO06BwnYH6vKBDuLC/tVkP9OtUNRe35v9NHZZPVx7Idbo0ssZTPyXY9EY7wsixQQ5JGK8ubRQ9Zh7+ecV6zwk7ttiHDQ+CEdkUbS8MbQs3CUKqzv1l2hzoRxJ9d57qy9NA0Yq5DJ; 20:83zdTSFMofvy2CTCgXLuhrilGyKz4IcWAuj1XaCnIGb6UQBIy4l07Nbleu7FZL9xW/m3Ze5Bi4rvw4vDD9iEvlxOzBfqdVc1krFKODhYJAoavKeQlUQ5hBVnk6nTCYJ5vh4EeRjj5ieCO404TFftJ9VO1TavYJ1a1rHC+eRsOQ8= NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123558025)(20161123562025)(20161123564025)(6072148); SRVR:HE1PR08MB0890; BCL:0; PCL:0; RULEID:; SRVR:HE1PR08MB0890; X-Microsoft-Exchange-Diagnostics: 1; HE1PR08MB0890; 4:AFtIX4Kl8VunovPt6wy491AIVettDzjQ2sp9UT4nX0xQC1mpzS4rAZmuf/TAP+j3XE2ngdeAP3u2HE3jVI4BV35PBWh9t29fy3gM1FgpxxiTGSMECzB70tG6Avymo10eUbhI0PbRyKkrhiF65NObBya1BUWNKynMDW0KyXS5CrkK+MBUATJ8uA5+S2dNp9Q0m2oWHznL9UWIIvi0XhZAaE9s7NZLab5SXGEB1HR67TcCL860Ez/gLQZXZmehTHy8h4oi5S+NrdxKxLqa5KlSlYxDTbB1KX1B+YHaSyeTLzUwYfDiI+F+HjUfMHzaLtVhtfnD0Ck5nkPRdXJVvk5k645Kqy9ovt8hsWPKnOYRihBHMIQRtmyTEDfZeEVVMZrVNCxyY6YKPbhnDqs5AZ58e/e64tv1k8TPkTydqlE2lvMeS0aBFwBT0n3gUIM2JF825y2UYuk7POgCaeIl2lwqov37DQTrxRGfIOhCHjZiWLnqp4JxxashFtwKcGWi+2w/iSVBytQqbioFTeynC9T/LEP+yg9yEzRwJfLyvlJQDyhJMXgq75bPo4QBQEfy7UDwN7gu64nVDe4dQNenXBr12XB0x6fQC5SbYqwp1fZ7BGimwn/LXSKsMwdrtdd3/+lceAH6KM0UNefDqCldxIf4UycJ4VyT+ZtZMF+IT3AmyHFt3plhdvBc/LAedSPl2IGbizCRJn631X9nPAJmbxD7Nw== X-Forefront-PRVS: 0205EDCD76 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39850400002)(39450400003)(39410400002)(39840400002)(189002)(199003)(110136003)(92566002)(6486002)(6116002)(50226002)(5660300001)(7736002)(5003940100001)(3846002)(66066001)(36756003)(4326007)(6916009)(53936002)(81156014)(47776003)(2906002)(6666003)(8676002)(68736007)(305945005)(38730400001)(81166006)(86362001)(105586002)(5890100001)(33646002)(106356001)(2351001)(42186005)(101416001)(97736004)(54906002)(189998001)(50466002)(575784001)(25786008)(48376002)(50986999)(6306002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR08MB0890; H:e110433-lin.cambridge.arm.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR08MB0890; 23:PLI3LS+1i3c5/r0z7TxB3TL8CJwvLs59YHEDqLTRv?= =?us-ascii?Q?xhNZMOyDw+AL0rf4Y37vaMiUKhLqIWsUSm8BqET8wucfVlzMo0clTLm6XFyd?= =?us-ascii?Q?UDaS6VB8JiGnYJeyT5mKF1RLb6tUX7nI7DpVv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; HE1PR08MB0890; 7:hDhua6gCT3bwCqVNhaSXyY6wQJjn7r1QRvjHQakf52Ao9jqJyVSi8ynYEfvnxWTMkwWXKJrb+d46tAIimQqCG/zCU8+O6amiEaueHT/DNh0LURnfZC4fFy3kclICSJ+7Mm7BhJXa2mtSCtOPQw4pucWpKV0LMJcR2/6uaMqeOdWoiDDHYRH1x3sQG3VTFss53CX7qr4Nm8ifWipDc1ezST0SlhZG1B0Xl1pCDidU+wvXi3Ar7CCPxWxSxSFJSn8iEtY44vSzbJAEQIc86gTTisZgbPkh0mNsjPBfikl9z/qhFkV13Et30YEnCPGXl8gBRSP/d44Nc0k8MQnTd76QQEf5TXhm7U2F1uqIWVffQ9zvh40VrK6I8vBG+FZxNys5hONQqPX45MIwJFRItrziuOxGD4QBMAGhE2tonlA2rRQ47fs77m5fXB4Jju/vjShuL3YxqXwXb8toZg+S1DbCWvcD11ciuRSv45VLUlLdfwVDHR40CJTzc1X6HsRqBcZg1E6kucEJMwR6R2xh14rzrCdtBIOb7zZnrc1vjGILXpx+OmC1b5X9TqqfXjHv/QBC X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2017 12:05:08.1950 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR08MB0890 Cc: Liviu Dudau , linux-kernel@vger.kernel.org, Mali DP Maintainers , nd@arm.com 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 All DPs have a COLORADJ matrix which is applied prior to output gamma. Attach that to the CTM property. Also, ensure the input CTM's coefficients can fit in the DP registers' Q3.12 format. Signed-off-by: Mihail Atanassov --- This patch depends on "[PATCH 2/2] drm: mali-dp: enable gamma support", sent out earlier (https://lkml.org/lkml/2017/2/1/201). drivers/gpu/drm/arm/malidp_crtc.c | 59 +++++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/arm/malidp_drv.c | 35 +++++++++++++++++++++++ drivers/gpu/drm/arm/malidp_drv.h | 1 + drivers/gpu/drm/arm/malidp_regs.h | 2 ++ 4 files changed, 95 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/arm/malidp_crtc.c b/drivers/gpu/drm/arm/malidp_crtc.c index 10f79b6..2f366e4 100644 --- a/drivers/gpu/drm/arm/malidp_crtc.c +++ b/drivers/gpu/drm/arm/malidp_crtc.c @@ -190,6 +190,55 @@ static int malidp_crtc_atomic_check_gamma(struct drm_crtc *crtc, return 0; } +/* + * Check if there is a new CTM and if it contains valid input. Valid here means + * that the number is inside the representable range for a Q3.12 number, + * excluding truncating the fractional part of the input data. + * + * The COLORADJ registers can be changed atomically. + */ +static int malidp_crtc_atomic_check_ctm(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + struct malidp_crtc_state *mc = to_malidp_crtc_state(state); + struct drm_color_ctm *ctm; + int i; + + if (!state->color_mgmt_changed) + return 0; + + if (!state->ctm) + return 0; + + if (crtc->state->ctm && (crtc->state->ctm->base.id == + state->ctm->base.id)) + return 0; + + /* + * The size of the ctm is checked in + * drm_atomic_replace_property_blob_from_id. + */ + ctm = (struct drm_color_ctm *)state->ctm->data; + for (i = 0; i < ARRAY_SIZE(ctm->matrix); ++i) { + /* Convert from S31.32 to Q3.12. */ + s64 val = ctm->matrix[i]; + u64 mag = ((((u64)val) & ~BIT_ULL(63)) >> 20) & + GENMASK_ULL(14, 0); + + /* Check the destination's top bit for overflow. */ + if (val & BIT_ULL(63)) { + mag = ~mag + 1; + if (!(mag & BIT_ULL(14))) + return -EINVAL; + } else if (mag & BIT_ULL(14)) { + return -EINVAL; + } + mc->coloradj_coeffs[i] = mag; + } + + return 0; +} + static int malidp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state) { @@ -270,6 +319,10 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc, if (ret) return ret; + ret = malidp_crtc_atomic_check_ctm(crtc, state); + if (ret) + return ret; + return 0; } @@ -289,6 +342,8 @@ static struct drm_crtc_state *malidp_crtc_duplicate_state(struct drm_crtc *crtc) __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base); memcpy(state->gamma_coeffs, cs->gamma_coeffs, sizeof(state->gamma_coeffs)); + memcpy(state->coloradj_coeffs, cs->coloradj_coeffs, + sizeof(state->coloradj_coeffs)); return &state->base; } @@ -359,10 +414,10 @@ int malidp_crtc_init(struct drm_device *drm) drm_crtc_helper_add(&malidp->crtc, &malidp_crtc_helper_funcs); drm_mode_crtc_set_gamma_size(&malidp->crtc, 4096); - /* No inverse-gamma and color adjustments yet. */ + /* No inverse-gamma: it is per-plane. */ drm_crtc_enable_color_mgmt(&malidp->crtc, 0, - false, + true, 4096); return 0; diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c index a9f787d..682901a 100644 --- a/drivers/gpu/drm/arm/malidp_drv.c +++ b/drivers/gpu/drm/arm/malidp_drv.c @@ -78,6 +78,37 @@ static void malidp_atomic_commit_update_gamma(struct drm_crtc *crtc, } } +static +void malidp_atomic_commit_update_coloradj(struct drm_crtc *crtc, + struct drm_crtc_state *old_state) +{ + struct malidp_drm *malidp = crtc_to_malidp_device(crtc); + struct malidp_hw_device *hwdev = malidp->dev; + int i; + + if (!crtc->state->color_mgmt_changed) + return; + + if (!crtc->state->ctm) { + malidp_hw_clearbits(hwdev, MALIDP_DISP_FUNC_CADJ, + MALIDP_DE_DISPLAY_FUNC); + } else { + struct malidp_crtc_state *mc = + to_malidp_crtc_state(crtc->state); + + if (!old_state->ctm || (crtc->state->ctm->base.id != + old_state->ctm->base.id)) + for (i = 0; i < MALIDP_COLORADJ_NUM_COEFFS; ++i) + malidp_hw_write(hwdev, + mc->coloradj_coeffs[i], + hwdev->map.coeffs_base + + MALIDP_COLOR_ADJ_COEF + 4 * i); + + malidp_hw_setbits(hwdev, MALIDP_DISP_FUNC_CADJ, + MALIDP_DE_DISPLAY_FUNC); + } +} + /* * set the "config valid" bit and wait until the hardware acts on it */ @@ -144,6 +175,10 @@ static void malidp_atomic_commit_tail(struct drm_atomic_state *state) malidp_atomic_commit_update_gamma(crtc, old_crtc_state); drm_atomic_helper_commit_modeset_enables(drm, state); + + for_each_crtc_in_state(state, crtc, old_crtc_state, i) + malidp_atomic_commit_update_coloradj(crtc, old_crtc_state); + drm_atomic_helper_commit_planes(drm, state, 0); malidp_atomic_commit_hw_done(state); diff --git a/drivers/gpu/drm/arm/malidp_drv.h b/drivers/gpu/drm/arm/malidp_drv.h index 374d43e..55b0f8b 100644 --- a/drivers/gpu/drm/arm/malidp_drv.h +++ b/drivers/gpu/drm/arm/malidp_drv.h @@ -50,6 +50,7 @@ struct malidp_plane_state { struct malidp_crtc_state { struct drm_crtc_state base; u32 gamma_coeffs[MALIDP_COEFFTAB_NUM_COEFFS]; + u32 coloradj_coeffs[MALIDP_COLORADJ_NUM_COEFFS]; }; #define to_malidp_crtc_state(x) container_of(x, struct malidp_crtc_state, base) diff --git a/drivers/gpu/drm/arm/malidp_regs.h b/drivers/gpu/drm/arm/malidp_regs.h index 2e213c3..b15ef50 100644 --- a/drivers/gpu/drm/arm/malidp_regs.h +++ b/drivers/gpu/drm/arm/malidp_regs.h @@ -64,6 +64,7 @@ /* bit masks that are common between products */ #define MALIDP_CFG_VALID (1 << 0) #define MALIDP_DISP_FUNC_GAM (1 << 0) +#define MALIDP_DISP_FUNC_CADJ (1 << 4) #define MALIDP_DISP_FUNC_ILACED (1 << 8) /* register offsets for IRQ management */ @@ -93,6 +94,7 @@ #define MALIDP_DE_H_ACTIVE(x) (((x) & 0x1fff) << 0) #define MALIDP_DE_V_ACTIVE(x) (((x) & 0x1fff) << 16) +#define MALIDP_COLORADJ_NUM_COEFFS 12 #define MALIDP_COEFFTAB_NUM_COEFFS 64 /* register offsets relative to MALIDP5x0_COEFFS_BASE */ #define MALIDP_COLOR_ADJ_COEF 0x00000