From patchwork Wed Jul 24 19:06:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Zalewski X-Patchwork-Id: 13741346 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E26F3C3DA63 for ; Wed, 24 Jul 2024 20:43:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EBFBB10E109; Wed, 24 Jul 2024 20:43:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; secure) header.d=proton.me header.i=@proton.me header.b="SXHfdTki"; dkim-atps=neutral Received: from mail-41103.protonmail.ch (mail-41103.protonmail.ch [185.70.41.103]) by gabe.freedesktop.org (Postfix) with ESMTPS id 61BE310E79B for ; Wed, 24 Jul 2024 19:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1721847972; x=1722107172; bh=xXyqPAWiPGTlRuUl6Au8Vf9PuxCMIzRAhei2a3kfeEc=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=SXHfdTkirkEZ7voqfB1b9hCVgNVFDCeiog1HpomvahB/1qkgF/apiVYgqfMBlNNLX ibac/UXQF/TynZ5If8hwimNQaDS+i/pGgl9bpmstV+AAr1eNbzDFjz1EGOA8KwCnMm I3p0Tj/4sjm6mJ8KslR1bgdYMTCjfVFaE43oK+aLmzM4XEMjf/8e3BDTgfP125e29N oz9vncaAOwRbr9WxYFNtORrtN4BDBJqR/U3jmrQ+hqbEVejnSuFmncEgcQMnTVZDAu lnP8LvcOxQz0tKnHGZ1NqLBJ6dvK8no3vkkte3/hiUiq2udoFv3FvnPMqj2+vfwxx1 73KoCFUrOPhtg== Date: Wed, 24 Jul 2024 19:06:01 +0000 To: "airlied@gmail.com" , "andy.yan@rock-chips.com" , "daniel@ffwll.ch" , "dri-devel@lists.freedesktop.org" , "heiko@sntech.de" , "hjc@rock-chips.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-rockchip@lists.infradead.org" , "maarten.lankhorst@linux.intel.com" , "mripard@kernel.org" , "tzimmermann@suse.de" From: Piotr Zalewski Subject: [PATCH v2] rockchip/drm: vop2: add support for gamma LUT Message-ID: Feedback-ID: 53478694:user:proton X-Pm-Message-ID: 2763f33b849810a95c08efa9a15f31ec8564793e MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 24 Jul 2024 20:43:44 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Add support for gamma LUT in VOP2 driver. The implementation is based on the one found in VOP driver and modified to be compatible with VOP2. Blue and red channels in gamma LUT register write were swapped with respect to how gamma LUT values are written in VOP. Write of the current video port id to VOP2_SYS_LUT_PORT_SEL register was added before the write of DSP_LUT_EN bit. Gamma size is set and drm color management is enabled for each video port's CRTC except ones which have no associated device. Tested on RK3566 (Pinetab2). Helped-by: Dragan Simic Signed-off-by: Piotr Zalewski --- Notes: Changes in v2: - Apply code styling corrections [1] - Move gamma LUT write inside the vop2 lock Link to v1: https://lore.kernel.org/linux-rockchip/9736eadf6a9d8e97eef919c6b3d88828@manjaro.org/T/#t [1] https://lore.kernel.org/linux-rockchip/d019761504b540600d9fc7a585d6f95f@manjaro.org/ diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index 16abdc4a59a8..37fcf544a5fd 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -1515,9 +1515,8 @@ static void vop2_vp_dsp_lut_disable(struct vop2_video_port *vp) static void vop2_crtc_write_gamma_lut(struct vop2 *vop2, struct drm_crtc *crtc) { - const struct vop2_data *vop2_data = vop2->data; const struct vop2_video_port *vp = to_vop2_video_port(crtc); - const struct vop2_video_port_data *vp_data = &vop2_data->vp[vp->id]; + const struct vop2_video_port_data *vp_data = &vop2->data->vp[vp->id]; struct drm_color_lut *lut = crtc->state->gamma_lut->data; unsigned int i, bpc = ilog2(vp_data->gamma_lut_len); @@ -1558,9 +1557,8 @@ static void vop2_crtc_gamma_set(struct vop2 *vop2, struct drm_crtc *crtc, * In order to write the LUT to the internal memory, * we need to first make sure the dsp_lut_en bit is cleared. */ - ret = - readx_poll_timeout(vop2_vp_dsp_lut_is_enabled, vp, dsp_ctrl, !dsp_ctrl, 5, - 30 * 1000); + ret = readx_poll_timeout(vop2_vp_dsp_lut_is_enabled, vp, dsp_ctrl, + !dsp_ctrl, 5, 30 * 1000); if (ret) { DRM_DEV_ERROR(vop2->dev, "display LUT RAM enable timeout!\n"); @@ -1571,9 +1569,9 @@ static void vop2_crtc_gamma_set(struct vop2 *vop2, struct drm_crtc *crtc, return; } - vop2_crtc_write_gamma_lut(vop2, crtc); vop2_lock(vop2); + vop2_crtc_write_gamma_lut(vop2, crtc); vop2_writel(vp->vop2, RK3568_LUT_PORT_SEL, vp->id); vop2_vp_dsp_lut_enable(vp);