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: 13741276 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 69B88C3DA61 for ; Wed, 24 Jul 2024 19:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Subject:From:To:Date:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=xXyqPAWiPGTlRuUl6Au8Vf9PuxCMIzRAhei2a3kfeEc=; b=LiNS4WY9KAoaOCjzw/IYoGBXDR EUR1m4y6wiR9Fbm/X9ly/shVlGxzmeBJ0xwxCqRxhBHfUAAOs68y5GpT/NOS8j4CsRNJDT1ZNVdHs myW31QVx4hGFu2SJ3c1QDBuzGFsjTOhMTEiGrnhy9sxYaIk9NWutg30hU0fTONVX5bdH831J4lMzN r1S9rfJK9JeOcwxyNlv4Cz0gk1uWTi6FY9EdjzL5PfFJFtUdsCIJGI9+BAsQ/ok2nsoj7xPIWFgcy VvY0bHTXQHaD/1Hb27uNEyNiojKVtpavxxEJ7q4ELyX1vgcamMvm8ipFq3H2FsAif3ZssWtYuZ9k3 ogXCIIJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWhJy-0000000GHn0-0Rb8; Wed, 24 Jul 2024 19:06:42 +0000 Received: from mail-40132.protonmail.ch ([185.70.40.132]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWhJZ-0000000GHiv-1RjZ for linux-arm-kernel@lists.infradead.org; Wed, 24 Jul 2024 19:06:19 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240724_120618_017091_E52AA3D6 X-CRM114-Status: UNSURE ( 8.16 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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);