Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4253472ybi; Tue, 18 Jun 2019 14:48:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcLvcGSB1pa9JjNQH4KcuZ5bdf5Oz8shq9gqsVpg5nl+TnCYthoD+aWgJQtVfvClCduDn0 X-Received: by 2002:a65:6649:: with SMTP id z9mr4654876pgv.413.1560894480838; Tue, 18 Jun 2019 14:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560894480; cv=none; d=google.com; s=arc-20160816; b=DYooQoa7vVrjipUy7Y1JOEkrgBYUVF9i0KbZJ/ap51Nspm+GttoUIq85GXE4CZXjUH SFn+BObLPEgcPky+akWiZWMUYlAEHSrRkr6J1srvevihveY+HFL93DjeuGgdyFZH/EM7 5HMesq8EOqYccGl30j/szP6JBS8afrzXbwfVrWcl6qxclqDcoyfETCO5VIAnUqDR4HJ8 skMaEe+qLn/zybA93P2/a79azdXRF15OqH4Ohy1W9OHO1mP28J2w1D8WqsaBtpy23ZbU Wpxk58I1nTcezUzCI735Bo4F7eBh/zj041PZ96302Qrd84eApdP1DWNE2nbYxk9ZQPY8 KWbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=I0RWfX7/brWCQJZlmTP4b1pf0cVwk5bUjTnCrdF8UAY=; b=U87jXjOdKknBPnlQ4s3fPiiA9RstEzwgpioeV3JQu9AUTXuWdBIifivc/aOCAzfVaP HSMJTMvUKHxdwRxits5bVBBLm3+53gNZ47y4ov19mtmsT6OgWByMj70ZnMFMFKTosyIl bi+L0yXZiLdee8pLHaOlmV4JV4GpJgMDwbAIHs1f0H0q3ninrABrPcWfTny3jwQk8DVp CO/2EF7RmFb+88QyYShAZOU/UJHNKRntMRmhCg65ybzqDetKHbDVR8BzToLoVMhYoE4t JJTGyAEXDU81cPViwR52tkrfaQGmOAbGyB7ZUhGD4++XIUmUaJYVwzrvmNjbGuWv9Nmp CE9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13si1159955pgp.478.2019.06.18.14.47.45; Tue, 18 Jun 2019 14:48:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730615AbfFRVrf (ORCPT + 99 others); Tue, 18 Jun 2019 17:47:35 -0400 Received: from mail-ua1-f65.google.com ([209.85.222.65]:43559 "EHLO mail-ua1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729982AbfFRVre (ORCPT ); Tue, 18 Jun 2019 17:47:34 -0400 Received: by mail-ua1-f65.google.com with SMTP id o2so7584166uae.10; Tue, 18 Jun 2019 14:47:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=I0RWfX7/brWCQJZlmTP4b1pf0cVwk5bUjTnCrdF8UAY=; b=cUXKUiQ935N3nlS6kFzB0TCzb78U/V078a6zAg8F82mDBMaMZoPg24ItFFb8STlRVS F0qSgwpTj19HwCLZuQ5/VqymocKDL9fmNtXngjG4hw9y/LiEtjX/racQ8UdhvRXcbUUu oYHz8JQ9FFwRGHsOXSB8+ZYOd3MJA6lJQrBLQdJZMzOtSWW6H9hAyOiZwv9UfhPQzpUs 0Jqzmn2jcRfg7Fa9Lx5xfMz3wUM/GW7AZv9cFgzmVk3fosTWXsiqx5iz2A0i2yswVRQg 7alXD9gi3PqGitRKAd9lsc5rc3Y/SIFoGkm3Mu+T5cS3uPGa1SXHgL2d6Qi8ImVl3p3g ZMFQ== X-Gm-Message-State: APjAAAX2jRINuruQlVgUrOa1WZ/ZQS84rlABKMfZ+NTTTavUoL97atj3 kLzVFQr7S/StsmNNsiDuu47/1925KSo0reKl+kg= X-Received: by 2002:a9f:31a2:: with SMTP id v31mr12191937uad.15.1560894453845; Tue, 18 Jun 2019 14:47:33 -0700 (PDT) MIME-Version: 1.0 References: <20190618213406.7667-1-ezequiel@collabora.com> <20190618213406.7667-3-ezequiel@collabora.com> In-Reply-To: <20190618213406.7667-3-ezequiel@collabora.com> From: Ilia Mirkin Date: Tue, 18 Jun 2019 17:47:22 -0400 Message-ID: Subject: Re: [PATCH 2/3] drm/rockchip: Add optional support for CRTC gamma LUT To: Ezequiel Garcia Cc: dri-devel , linux-rockchip@lists.infradead.org, =?UTF-8?Q?Heiko_St=C3=BCbner?= , Sandy Huang , kernel@collabora.com, Sean Paul , Boris Brezillon , Douglas Anderson , Jacopo Mondi , Rob Herring , Mark Rutland , devicetree , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 18, 2019 at 5:43 PM Ezequiel Garcia wrote: > > Add an optional CRTC gamma LUT support, and enable it on RK3288. > This is currently enabled via a separate address resource, > which needs to be specified in the devicetree. > > The address resource is required because on some SoCs, such as > RK3288, the LUT address is after the MMU address, and the latter > is supported by a different driver. This prevents the DRM driver > from requesting an entire register space. > > The current implementation works for RGB 10-bit tables, as that > is what seems to work on RK3288. > > Signed-off-by: Ezequiel Garcia > --- > Changes from RFC: > * Request (an optional) address resource for the LUT. > * Drop support for RK3399, which doesn't seem to work > out of the box and needs more research. > * Support pass-thru setting when GAMMA_LUT is NULL. > * Add a check for the gamma size, as suggested by Ilia. > * Move gamma setting to atomic_commit_tail, as pointed > out by Jacopo/Laurent, is the correct way. > --- > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c > index 12ed5265a90b..5b6edbe2673f 100644 > --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c > +static void vop_crtc_gamma_set(struct vop *vop, struct drm_crtc *crtc, > + struct drm_crtc_state *old_state) > +{ > + int idle, ret, i; > + > + spin_lock(&vop->reg_lock); > + VOP_REG_SET(vop, common, dsp_lut_en, 0); > + vop_cfg_done(vop); > + spin_unlock(&vop->reg_lock); > + > + ret = readx_poll_timeout(vop_dsp_lut_is_enable, vop, > + idle, !idle, 5, 30 * 1000); > + if (ret) > + return; > + > + spin_lock(&vop->reg_lock); > + > + if (crtc->state->gamma_lut) { > + if (!old_state->gamma_lut || (crtc->state->gamma_lut->base.id != > + old_state->gamma_lut->base.id)) > + vop_crtc_write_gamma_lut(vop, crtc); > + } else { > + for (i = 0; i < crtc->gamma_size; i++) { > + u32 word; > + > + word = (i << 20) | (i << 10) | i; > + writel(word, vop->lut_regs + i * 4); > + } Note - I'm not in any way familiar with the hardware, so take with a grain of salt -- Could you just leave dsp_lut_en turned off in this case? Cheers, -ilia > + } > + > + VOP_REG_SET(vop, common, dsp_lut_en, 1); > + vop_cfg_done(vop); > + spin_unlock(&vop->reg_lock); > +}