From patchwork Mon Mar 18 13:57:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Urja Rannikko X-Patchwork-Id: 10857689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13BC71669 for ; Mon, 18 Mar 2019 13:57:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5D092901E for ; Mon, 18 Mar 2019 13:57:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D98D728653; Mon, 18 Mar 2019 13:57:43 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5E57F2901E for ; Mon, 18 Mar 2019 13:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xwgcb3vh6upi+h0VzIzDbtcV93Axg77xOXCl13a5YMs=; b=s/ZRaPYMutgwj3 pmDAmpGwfp++M2l/9EQ4aF3U8nWzmzjT0gnVhqLDEKhA38Dbyd9OPuuAljEd35y3ZrWE1mFqrioei we1gtxUrmA2Y7d7TFLvnbjS1zfl9jfrQJJAIDax15s8ne/Jyb0fgibTzg63Y9n+Aqe/EbbZquWqeG +8ZQOiCbxWLJ/1zi4xK1Q/r+waeH830SAK5dsPHpYbRZ83pjGbzGpDbZG1q/vxwSt7MtBVlcAm1+q vvFiHlU46Y913eA/HDZlAwdC5/MEAarjjG/lqg6shzWZ1a2ANk47B1Ph5Urt2L8a9f4yvfYpil12f HKnbWGgh3f+3Q8d7S25Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5slo-0000s3-1W; Mon, 18 Mar 2019 13:57:40 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5slk-0000rf-OU; Mon, 18 Mar 2019 13:57:38 +0000 Received: by mail-wr1-x443.google.com with SMTP id j9so2994159wrn.6; Mon, 18 Mar 2019 06:57:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mBfiYY2Hun9iqzOlwigI7Jfqhy8dxgpqIEgZVcY20RU=; b=pp/xPZMOQNWGEbcQAjTUk44KCX1237FyUSRN8RSaN2LSiRQ67/f7Wb+KGf9pwpbAGm 5t5Ond1hbX93Wve3T4FyLTMP7QSmbIMN5m5THhRr5PPapXzNtQCxc2aA25UhMvkKU+Gf M+nQjPOjnGgs67xgDdRNFPe6Oz9FokkwTAqZX4sGYocI+4zyjgMuwx0SsKTwWxZ9HMRF pJP3o6s08tW3rG+DBIdl14DbcDrjetlTzdT+adcZlEZNpdObllUtCv8BPAfZciV6560c B6Dq21FYicHz+bCWJztrkFkYWJ7MArK6wBIoAYp5CyPc2Sfz8eCjELVpjVOjuPy1KnIN WW/Q== 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=mBfiYY2Hun9iqzOlwigI7Jfqhy8dxgpqIEgZVcY20RU=; b=DUUhRhyIBUfxK4Yek6/ZAmcj6Py9RRtC3I7eU8aFcXxOXQkUaLtjHRf73/YlXhcgff 3um1HQgLCgSAQUk4HsiFO4xDpi5c8YnTnAvr91oqi5x36pS0I61sApdxnCoR2awHo9WJ VYqeSdECzwrrA7lNlhiwQEMhDj9eNeCVjGcsbpF/NjN4yHAHaxtvMuEIfTn9rVffRUfb w7w2FLmaOve8RB1SBiZz1j7U1fTZYS7R0mhkH/J0Kh2EQX77DrPt2/7cokxQqO/QEO/Y A+ZDKNWTpQggkMZTusKeGyxk7aHh2x8IV1aBlolznWdYETvZJwW9bVepLDtYvPw8EDcA uh4Q== X-Gm-Message-State: APjAAAUz9+pTqi37KS1G0Clr/beHEvFtd/afYTeq3Nj4GHZeJrK+ZvJA fNgj1xhLSjHUFO+dEmCMhHT6UGDfvw== X-Google-Smtp-Source: APXvYqxdsZnCOQNhj3tumILFReZCPCgQ6D/YtKnn19QvtXgaG345WOQulj3G5VxOrRrRz2KL15idoA== X-Received: by 2002:adf:b651:: with SMTP id i17mr11469455wre.108.1552917454488; Mon, 18 Mar 2019 06:57:34 -0700 (PDT) Received: from localhost.localdomain (esm-84-240-79-214.netplaza.fi. [84.240.79.214]) by smtp.gmail.com with ESMTPSA id d5sm7206213wrx.12.2019.03.18.06.57.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 06:57:33 -0700 (PDT) From: Urja Rannikko To: linux-rockchip@lists.infradead.org Subject: [PATCH v3] drm/rockchip: vop: Support dithering to RGB666 Date: Mon, 18 Mar 2019 13:57:01 +0000 Message-Id: <20190318135701.7098-1-urjaman@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190219100848.2222-1-urjaman@gmail.com> References: <20190219100848.2222-1-urjaman@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_065736_822565_43BA9C3A X-CRM114-Status: GOOD ( 15.42 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Urja Rannikko , heiko@sntech.de, linux-arm-kernel@lists.infradead.org, hjc@rock-chips.com Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Splits out the dither register bits and introduces the same config enumerations as in the rockchip kernel tree. Tested to fix the banding on my ASUS C201. Signed-off-by: Urja Rannikko --- v3: Support RK3066 which doesnt have the sel bit, thus question: should we avoid that vop_reg_write call if the bit isnt supported as i did? If yes should i add a macro for the test? (Since that doesnt yet exist in this version of the driver) - This is a version of the patch that is quite inspired by the rockchip kernel tree (that i hadn't looked at enough), but still keeps to just implementing RGB666 dithering because more changes are needed to get the information in place for detecting RGB565, but adding that should be easier afterwards. drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 26 +++++++++++++++++---- drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 14 ++++++++++- drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 20 ++++++++++++++-- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index c7d4c6073ea5..26b4d74c109e 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1086,10 +1086,28 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc, !(vop_data->feature & VOP_FEATURE_OUTPUT_RGB10)) s->output_mode = ROCKCHIP_OUT_MODE_P888; - if (s->output_mode == ROCKCHIP_OUT_MODE_AAAA && s->output_bpc == 8) - VOP_REG_SET(vop, common, pre_dither_down, 1); - else - VOP_REG_SET(vop, common, pre_dither_down, 0); + if (s->output_bpc) { /* Only dither if bpc known. */ + if (vop_data->feature & VOP_FEATURE_OUTPUT_RGB10) { + if (s->output_mode == ROCKCHIP_OUT_MODE_AAAA && s->output_bpc <= 8) + VOP_REG_SET(vop, common, pre_dither_down, 1); + else + VOP_REG_SET(vop, common, pre_dither_down, 0); + } + if (s->output_bpc == 6) { + if (&vop->data->common->dither_down_sel.mask) + VOP_REG_SET(vop, common, dither_down_sel, DITHER_DOWN_ALLEGRO); + + VOP_REG_SET(vop, common, dither_down_mode, RGB888_TO_RGB666); + VOP_REG_SET(vop, common, dither_down_en, 1); + } else { + VOP_REG_SET(vop, common, dither_down_en, 0); + } + } else { + if (vop_data->feature & VOP_FEATURE_OUTPUT_RGB10) + VOP_REG_SET(vop, common, pre_dither_down, 0); + + VOP_REG_SET(vop, common, dither_down_en, 0); + } VOP_REG_SET(vop, common, out_mode, s->output_mode); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h index 04ed401d2325..e64351dab610 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h @@ -71,7 +71,9 @@ struct vop_common { struct vop_reg dsp_blank; struct vop_reg data_blank; struct vop_reg pre_dither_down; - struct vop_reg dither_down; + struct vop_reg dither_down_sel; + struct vop_reg dither_down_mode; + struct vop_reg dither_down_en; struct vop_reg dither_up; struct vop_reg gate_en; struct vop_reg mmu_en; @@ -287,6 +289,16 @@ enum scale_down_mode { SCALE_DOWN_AVG = 0x1 }; +enum dither_down_mode { + RGB888_TO_RGB565 = 0x0, + RGB888_TO_RGB666 = 0x1 +}; + +enum dither_down_mode_sel { + DITHER_DOWN_ALLEGRO = 0x0, + DITHER_DOWN_FRC = 0x1 +}; + enum vop_pol { HSYNC_POSITIVE = 0, VSYNC_POSITIVE = 1, diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c index bd76328c0fdb..e732b73033c8 100644 --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c @@ -137,6 +137,9 @@ static const struct vop_common rk3036_common = { .standby = VOP_REG_SYNC(RK3036_SYS_CTRL, 0x1, 30), .out_mode = VOP_REG(RK3036_DSP_CTRL0, 0xf, 0), .dsp_blank = VOP_REG(RK3036_DSP_CTRL1, 0x1, 24), + .dither_down_sel = VOP_REG(RK3036_DSP_CTRL0, 0x1, 27), + .dither_down_en = VOP_REG(RK3036_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3036_DSP_CTRL0, 0x1, 10), .cfg_done = VOP_REG_SYNC(RK3036_REG_CFG_DONE, 0x1, 0), }; @@ -200,6 +203,9 @@ static const struct vop_common px30_common = { .standby = VOP_REG_SYNC(PX30_SYS_CTRL2, 0x1, 1), .out_mode = VOP_REG(PX30_DSP_CTRL2, 0xf, 16), .dsp_blank = VOP_REG(PX30_DSP_CTRL2, 0x1, 14), + .dither_down_en = VOP_REG(PX30_DSP_CTRL2, 0x1, 8), + .dither_down_sel = VOP_REG(PX30_DSP_CTRL2, 0x1, 7), + .dither_down_mode = VOP_REG(PX30_DSP_CTRL2, 0x1, 6), .cfg_done = VOP_REG_SYNC(PX30_REG_CFG_DONE, 0x1, 0), }; @@ -365,6 +371,8 @@ static const struct vop_common rk3066_common = { .standby = VOP_REG(RK3066_SYS_CTRL0, 0x1, 1), .out_mode = VOP_REG(RK3066_DSP_CTRL0, 0xf, 0), .cfg_done = VOP_REG(RK3066_REG_CFG_DONE, 0x1, 0), + .dither_down_en = VOP_REG(RK3066_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3066_DSP_CTRL0, 0x1, 10), .dsp_blank = VOP_REG(RK3066_DSP_CTRL1, 0x1, 24), }; @@ -458,6 +466,9 @@ static const struct vop_common rk3188_common = { .standby = VOP_REG(RK3188_SYS_CTRL, 0x1, 30), .out_mode = VOP_REG(RK3188_DSP_CTRL0, 0xf, 0), .cfg_done = VOP_REG(RK3188_REG_CFG_DONE, 0x1, 0), + .dither_down_sel = VOP_REG(RK3188_DSP_CTRL0, 0x1, 27), + .dither_down_en = VOP_REG(RK3188_DSP_CTRL0, 0x1, 11), + .dither_down_mode = VOP_REG(RK3188_DSP_CTRL0, 0x1, 10), .dsp_blank = VOP_REG(RK3188_DSP_CTRL1, 0x3, 24), }; @@ -585,8 +596,10 @@ static const struct vop_common rk3288_common = { .standby = VOP_REG_SYNC(RK3288_SYS_CTRL, 0x1, 22), .gate_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 23), .mmu_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 20), + .dither_down_sel = VOP_REG(RK3288_DSP_CTRL1, 0x1, 4), + .dither_down_mode = VOP_REG(RK3288_DSP_CTRL1, 0x1, 3), + .dither_down_en = VOP_REG(RK3288_DSP_CTRL1, 0x1, 2), .pre_dither_down = VOP_REG(RK3288_DSP_CTRL1, 0x1, 1), - .dither_down = VOP_REG(RK3288_DSP_CTRL1, 0xf, 1), .dither_up = VOP_REG(RK3288_DSP_CTRL1, 0x1, 6), .data_blank = VOP_REG(RK3288_DSP_CTRL0, 0x1, 19), .dsp_blank = VOP_REG(RK3288_DSP_CTRL0, 0x3, 18), @@ -878,7 +891,10 @@ static const struct vop_misc rk3328_misc = { static const struct vop_common rk3328_common = { .standby = VOP_REG_SYNC(RK3328_SYS_CTRL, 0x1, 22), - .dither_down = VOP_REG(RK3328_DSP_CTRL1, 0xf, 1), + .dither_down_sel = VOP_REG(RK3328_DSP_CTRL1, 0x1, 4), + .dither_down_mode = VOP_REG(RK3328_DSP_CTRL1, 0x1, 3), + .dither_down_en = VOP_REG(RK3328_DSP_CTRL1, 0x1, 2), + .pre_dither_down = VOP_REG(RK3328_DSP_CTRL1, 0x1, 1), .dither_up = VOP_REG(RK3328_DSP_CTRL1, 0x1, 6), .dsp_blank = VOP_REG(RK3328_DSP_CTRL0, 0x3, 18), .out_mode = VOP_REG(RK3328_DSP_CTRL0, 0xf, 0),