Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6861303ioo; Thu, 2 Jun 2022 15:36:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn51F3zFT0MbfPU+iinYTVhlcY0kUmOqM2VPP4ao/bNftIn9jCg575vsyZjZeOIEEEmQ8S X-Received: by 2002:a63:2319:0:b0:3fb:fe88:5831 with SMTP id j25-20020a632319000000b003fbfe885831mr6234275pgj.85.1654209378869; Thu, 02 Jun 2022 15:36:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654209378; cv=none; d=google.com; s=arc-20160816; b=ZYrnweh27G7tfKNPO+298PJDSTzWrFEc4J5BXP6UAgxKvatymDSKsGZavzrFPHE7gq 1zFBxI607IwkqQlBs7JeGtZD3rTKMQwHyQ4QYde4WyNXMo1l7nP62n2Eh05vI3ge9F3S Iupc8CaDZ4CGnNz9XlYfGKgYuQCPTb0hBCEef+AQ0hCDBemEBGiZHwnekL5rESNXXJ8J FQFQ1kChCzPyf4bzUIn6uPwLHstgM7BrGZCVes2j5oHF0fWyZaIqyF/3wvGgsbXUy6lX gWVIj1DPBeaMiRq2bWeUD7eoVEAZVLwujvkV8NFgrpSFEAdsm++9D9nRE9M5xlco7Q3b H47A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CBkaCoK6wuMtRbb6NmA5F8dDDK95iOEjJpqmo1bo7RU=; b=LriukSAFzCHYLiV9SGBquMcdE9g5wXd2MlEsC8bBv4N9wgNC4miikboJshlxeFuhpk njnjqkenUPdJoraWMJ7ZuNRj4r74ajfnYx0p/gSsWrudRjJlApn6T7W8cP2GCOQ3f/N/ ehwnFbT0uDXo4eSefFFtEbYjJrXaDsAEKHRIw9FihVDOozqkpZXUc0K5CoSGD7hhXMS/ avtQcZjydeU5/OIkDzA6VwJf6fIczo4Ez8aTnEAjVCb79f+fUs4N9D44BXApp+OwN9SK gW7COG+iOyzHYvri2nzm2xJ2zByyDPt0tayC1EEkwgDbevA/7vM+s63ThQ8W3TH1eYNH 0DNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZpoxLgXU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j65-20020a638b44000000b003fcd61d90ccsi4718147pge.852.2022.06.02.15.36.06; Thu, 02 Jun 2022 15:36:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZpoxLgXU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236859AbiFBSBb (ORCPT + 99 others); Thu, 2 Jun 2022 14:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237796AbiFBSB3 (ORCPT ); Thu, 2 Jun 2022 14:01:29 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D43D12B2E91 for ; Thu, 2 Jun 2022 11:01:28 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id o10so7264626edi.1 for ; Thu, 02 Jun 2022 11:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CBkaCoK6wuMtRbb6NmA5F8dDDK95iOEjJpqmo1bo7RU=; b=ZpoxLgXU602v2G/Xd3ivQRZ3M5INDPN8DNhTpEgbihmrZIwuUIQqjuMUHGGYehz9i3 BfZBBrYZOWM6IaNyFU6E+00dNVzVwDW6xwpedw6ki5XAVrDxxGz2ed6hU/XGmtytfyPB 4zRcXaWVMFaa35F65YMuli1Y3LV03vybRbLGb6zXrnspwuyBUo/70qIA6d6VZEpWVDaw l94LfOOUOoIYIOS/OQSX7/VXgosmyXrdT6pwhA+QRqMG2BP3Gv4kVP52VonZiD0z357m h79lWxSqNiv4A/PCv3ur4CfXuyDHDvBA0ZB3GOQMI2VmT6CDzqlAIFXnoECb4Q5VjLrW BCzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CBkaCoK6wuMtRbb6NmA5F8dDDK95iOEjJpqmo1bo7RU=; b=VPaacYsrm0lncisndJpj1Hj5zuqVKp2wuSnpwFzLVzuAMVrHiUIermL36FtDbGKBja zLP46ign5TVdgjWF2+ydMyhnuPfrH17A9TF//w3fY2jthQTp/glwQM3heAXv1/A5AkFl 0yx4y9h1u5DdN2oNrxia6THR7VdvbIuKG2k8GGP29VbJIUdgYTNozZDHYG+z2oqp7Yxp AEBj921QlC2R/RK25GD2RmI2/lSFnMLMQi0pX0zjWzU2IbZbjN5BxeFVOxaFNkCeUFjl a+de/SUtTWiCm0aFzAAk1Eq+/P7nm8Ap2XfVgulz5YlKe5fNBFPMF0FhV7Fljg3Fdfud DG4A== X-Gm-Message-State: AOAM5336/YEVIACipjT0ycVRA6nmhm4p6ap7efUnIyS031rlYGtH3O4m VP/UwZaaeGqdwMfMHARgJ9g= X-Received: by 2002:a05:6402:1007:b0:428:beb6:f483 with SMTP id c7-20020a056402100700b00428beb6f483mr6742760edu.391.1654192887279; Thu, 02 Jun 2022 11:01:27 -0700 (PDT) Received: from orangepi3.mydomain.example ([195.234.74.2]) by smtp.gmail.com with ESMTPSA id kx16-20020a170907775000b00706e8ac43b8sm1972348ejc.199.2022.06.02.11.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 11:01:24 -0700 (PDT) From: Roman Stratiienko To: mripard@kernel.org, wens@csie.org, jernej.skrabec@gmail.com, airlied@linux.ie, daniel@ffwll.ch, samuel@sholland.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, megi@xff.cz Cc: Roman Stratiienko Subject: [PATCH] drm/sun4i: sun8i: Add the ability to keep scaler enabled for VI layer Date: Thu, 2 Jun 2022 18:01:18 +0000 Message-Id: <20220602180118.66170-1-r.stratiienko@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to DE2.0/DE3.0 manual VI scaler enable register is double buffered, but de facto it doesn't, or the hardware has the shadow register latching issues which causes single-frame picture corruption after changing the state of scaler enable register. Allow the user to keep the scaler always enabled, preventing the UI glitches on the transition from scaled to unscaled state. NOTE: UI layer scaler has more registers with double-buffering issue and can't be workarounded in the same manner. You may find a python test and a demo video for this issue at [1] [1]: https://github.com/GloDroid/glodroid_tests/issues/4 Signed-off-by: Roman Stratiienko --- drivers/gpu/drm/sun4i/sun8i_mixer.c | 12 ++++++++++++ drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c index 71ab0a00b4de..15cad0330f66 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c @@ -27,6 +27,18 @@ #include "sun8i_vi_layer.h" #include "sunxi_engine.h" +/* According to DE2.0/DE3.0 manual VI scaler enable register is double + * buffered, but de facto it doesn't, or the hardware has the shadow + * register latching issues which causes single-frame picture corruption + * after changing the state of scaler enable register. + * Allow the user to keep the scaler always enabled, preventing the UI + * glitches on the transition from scaled to unscaled state. + */ +int sun8i_vi_keep_scaler_enabled; +MODULE_PARM_DESC(keep_vi_scaler_enabled, + "Keep VI scaler enabled (1 = enabled, 0 = disabled (default))"); +module_param_named(keep_vi_scaler_enabled, sun8i_vi_keep_scaler_enabled, int, 0644); + struct de2_fmt_info { u32 drm_fmt; u32 de2_fmt; diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c index 662ba1018cc4..f005ab883503 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c @@ -17,6 +17,8 @@ #include "sun8i_vi_layer.h" #include "sun8i_vi_scaler.h" +extern int sun8i_vi_keep_scaler_enabled; + static void sun8i_vi_layer_enable(struct sun8i_mixer *mixer, int channel, int overlay, bool enable, unsigned int zpos) { @@ -149,7 +151,7 @@ static int sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel, */ subsampled = format->hsub > 1 || format->vsub > 1; - if (insize != outsize || subsampled || hphase || vphase) { + if (insize != outsize || subsampled || hphase || vphase || sun8i_vi_keep_scaler_enabled) { unsigned int scanline, required; struct drm_display_mode *mode; u32 hscale, vscale, fps; -- 2.30.2