Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1413201pxk; Fri, 4 Sep 2020 08:47:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFwhEbCNsGJSge+ioR9UcSV55HhTJl9Ufj6RKEA3bK/qnZpUUvZmTNIbHsw59sIZ6r4Kf1 X-Received: by 2002:aa7:c155:: with SMTP id r21mr9486283edp.140.1599234459708; Fri, 04 Sep 2020 08:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599234459; cv=none; d=google.com; s=arc-20160816; b=qUa17pMnMyH/wntePtB1q9EtvL2rXN9Wqj+sVT05dGQ+4WLfP72NyjrIkmB1mAuE5b N0Ts4fndc8ZJky+/Q7YGlWPudDjckT6ciDxaqdX+sROcSGVcTGJ9PxjrXLI7Tay/sQ6X 569CGljWyC/P2nl6wdZ7M2mGRP11m+ugdxjYIOnIp8ApywLMfpbMPbuGvgPzqAOG4HO+ 9X49lsAT3mPL+jtQ4cGE5IQgOPOre4rqUqoQ48nHzMqrOkmDstT6YLOBfXKGBPOJtccY 6I93Ra5pNDVWV6VjpAdUfaQaGh7VdB4B9DXQvW2c/UAKqzZ3aeKUENg4mRWXGC201HxF bSxg== 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:dkim-signature; bh=BWAhN7a+4874hzvxevYBZLVV3qk181dMhkmwcopVXuI=; b=sZG90hZ4zRSJ4TrAbcUik1NTdYUumWIKyRKO0SBaqM+G5wdOaH8vmk5sxugvZOAfKT EXaaIGZyORJAHKXMZBx99qld8V/0HbUXfeaBafgyMgsDS1S5faY4E6krhOjahXTVSFQh z34tC8+O9QqsWWSxD3KMdX2rfNlxSzsLEzQ68NCMVuuz2jTWaexB9B+nuU8F3Oy31GKt JqJxM8iheNRVMmEBfaPyEa/g7kNAkDI6lfEwstRr16pLbKVt7nTzqin1sciURcNzPWGY f7P67zfPizU+DdDYc5pOvulrPGiB0R1nXmMvKyLvimY0G1DAq6qGQ6AZDCR9KyZwT+r1 IjjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=oFrwyne8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=raspberrypi.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si4242162ejt.351.2020.09.04.08.47.15; Fri, 04 Sep 2020 08:47:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=oFrwyne8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=raspberrypi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726339AbgIDPp4 (ORCPT + 99 others); Fri, 4 Sep 2020 11:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbgIDPpy (ORCPT ); Fri, 4 Sep 2020 11:45:54 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2D84C061244 for ; Fri, 4 Sep 2020 08:45:52 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id w2so6504415wmi.1 for ; Fri, 04 Sep 2020 08:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BWAhN7a+4874hzvxevYBZLVV3qk181dMhkmwcopVXuI=; b=oFrwyne8UjE4GXeuhjjOpVE9dYZzB2GlQAZCkFaOP1wA0cXqKCn7uoJJwGDObMHxPc dFLnAam23p6BBsCONYgBCS8Y3VSJ7EySoY4Fq5UoZy/F8Fn2lbfkkqBi1OjU/s5JCuEQ +UHKUniKfnrVglb99KDPOYVPapsE5nuHsbwWDUXY5kMUq5FTRJ89pfRug0hq4ZLwqTag kxJjyxhTh7qRPvOCRVNb+dWojAmEJ2ch1rJknyxyZUNQd2ZIZPR2hKHtF5EnNzeGSe5W 3LkwSplCw1X7pDUYAp/rmsDgjRmrze7FYppzpfhj7RhzMpSAeo+cHJAmHAAMamm/Yicg alXg== 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=BWAhN7a+4874hzvxevYBZLVV3qk181dMhkmwcopVXuI=; b=qX9iUVH/lBEpfNnilecqEZPbaztKnGSpv/H0jWS8u6zSSi7CeTYrR40yo/9RG+Rwag GfUCaBbN2+d2OWdu702dKwJzH8yuIdh+vstQsfe8ii38Zo/ewThY4bKYZwnwM1oCAcNr JXtLEPvGqB4cqJs+yCdkXzLhVLW2El01KvWqTSWCmWGZkcB9IH5kk7kEKtM16rGwsiwi KhKD/EvjtjgaJ0MpR1aPGklY0QTse+9a9HU9uiCoBY2d4VjwuAryIL1Ekn/5hSA7k56E TzIc11EIXQM1AOSLyPalkz13kJxsmEt0AP7jnxYHdcp+XkOPQPXSwsxwZJqTj2UJItv0 Bypg== X-Gm-Message-State: AOAM5316KGVkN69+mkaZGa7d+wl56GXdWoUO8ymaqQJyWmM1Cbla8Kv7 VfTOXxja8Z0DqdmCqqxTKnLe44AtlvY97sUFXmZxvQ== X-Received: by 2002:a1c:4303:: with SMTP id q3mr8102774wma.158.1599234351549; Fri, 04 Sep 2020 08:45:51 -0700 (PDT) MIME-Version: 1.0 References: <5c19bbf10153cb42ca0fb67e08606c8295c17236.1599120059.git-series.maxime@cerno.tech> In-Reply-To: <5c19bbf10153cb42ca0fb67e08606c8295c17236.1599120059.git-series.maxime@cerno.tech> From: Dave Stevenson Date: Fri, 4 Sep 2020 16:45:36 +0100 Message-ID: Subject: Re: [PATCH v5 55/80] drm/vc4: hdmi: Add a CSC setup callback To: Maxime Ripard Cc: Nicolas Saenz Julienne , Eric Anholt , DRI Development , linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, LKML , Tim Gover , Phil Elwell , Chanwoo Choi , Hoegeun Kwon , Stefan Wahren 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 Hi Maxime On Thu, 3 Sep 2020 at 09:03, Maxime Ripard wrote: > > Similarly to the previous patches, the CSC setup is slightly different in > the BCM2711 than in the previous generations. Let's add a callback for it. > > Tested-by: Chanwoo Choi > Tested-by: Hoegeun Kwon > Tested-by: Stefan Wahren > Signed-off-by: Maxime Ripard Reviewed-by: Dave Stevenson > --- > drivers/gpu/drm/vc4/vc4_hdmi.c | 70 +++++++++++++++++++++-------------- > drivers/gpu/drm/vc4/vc4_hdmi.h | 3 ++- > 2 files changed, 45 insertions(+), 28 deletions(-) > > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c > index c29376c3fd8a..532618e02399 100644 > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c > @@ -334,6 +334,41 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder) > DRM_ERROR("Failed to release power domain: %d\n", ret); > } > > +static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, bool enable) > +{ > + u32 csc_ctl; > + > + csc_ctl = VC4_SET_FIELD(VC4_HD_CSC_CTL_ORDER_BGR, > + VC4_HD_CSC_CTL_ORDER); > + > + if (enable) { > + /* CEA VICs other than #1 requre limited range RGB > + * output unless overridden by an AVI infoframe. > + * Apply a colorspace conversion to squash 0-255 down > + * to 16-235. The matrix here is: > + * > + * [ 0 0 0.8594 16] > + * [ 0 0.8594 0 16] > + * [ 0.8594 0 0 16] > + * [ 0 0 0 1] > + */ > + csc_ctl |= VC4_HD_CSC_CTL_ENABLE; > + csc_ctl |= VC4_HD_CSC_CTL_RGB2YCC; > + csc_ctl |= VC4_SET_FIELD(VC4_HD_CSC_CTL_MODE_CUSTOM, > + VC4_HD_CSC_CTL_MODE); > + > + HDMI_WRITE(HDMI_CSC_12_11, (0x000 << 16) | 0x000); > + HDMI_WRITE(HDMI_CSC_14_13, (0x100 << 16) | 0x6e0); > + HDMI_WRITE(HDMI_CSC_22_21, (0x6e0 << 16) | 0x000); > + HDMI_WRITE(HDMI_CSC_24_23, (0x100 << 16) | 0x000); > + HDMI_WRITE(HDMI_CSC_32_31, (0x000 << 16) | 0x6e0); > + HDMI_WRITE(HDMI_CSC_34_33, (0x100 << 16) | 0x000); > + } > + > + /* The RGB order applies even when CSC is disabled. */ > + HDMI_WRITE(HDMI_CSC_CTL, csc_ctl); > +} > + > static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) > { > struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; > @@ -357,7 +392,6 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) > mode->crtc_vsync_end - > interlaced, > VC4_HDMI_VERTB_VBP)); > - u32 csc_ctl; > int ret; > > ret = pm_runtime_get_sync(&vc4_hdmi->pdev->dev); > @@ -428,41 +462,20 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) > (vsync_pos ? 0 : VC4_HD_VID_CTL_VSYNC_LOW) | > (hsync_pos ? 0 : VC4_HD_VID_CTL_HSYNC_LOW)); > > - csc_ctl = VC4_SET_FIELD(VC4_HD_CSC_CTL_ORDER_BGR, > - VC4_HD_CSC_CTL_ORDER); > > if (vc4_encoder->hdmi_monitor && > - drm_default_rgb_quant_range(mode) == > - HDMI_QUANTIZATION_RANGE_LIMITED) { > - /* CEA VICs other than #1 requre limited range RGB > - * output unless overridden by an AVI infoframe. > - * Apply a colorspace conversion to squash 0-255 down > - * to 16-235. The matrix here is: > - * > - * [ 0 0 0.8594 16] > - * [ 0 0.8594 0 16] > - * [ 0.8594 0 0 16] > - * [ 0 0 0 1] > - */ > - csc_ctl |= VC4_HD_CSC_CTL_ENABLE; > - csc_ctl |= VC4_HD_CSC_CTL_RGB2YCC; > - csc_ctl |= VC4_SET_FIELD(VC4_HD_CSC_CTL_MODE_CUSTOM, > - VC4_HD_CSC_CTL_MODE); > + drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED) { > + if (vc4_hdmi->variant->csc_setup) > + vc4_hdmi->variant->csc_setup(vc4_hdmi, true); > > - HDMI_WRITE(HDMI_CSC_12_11, (0x000 << 16) | 0x000); > - HDMI_WRITE(HDMI_CSC_14_13, (0x100 << 16) | 0x6e0); > - HDMI_WRITE(HDMI_CSC_22_21, (0x6e0 << 16) | 0x000); > - HDMI_WRITE(HDMI_CSC_24_23, (0x100 << 16) | 0x000); > - HDMI_WRITE(HDMI_CSC_32_31, (0x000 << 16) | 0x6e0); > - HDMI_WRITE(HDMI_CSC_34_33, (0x100 << 16) | 0x000); > vc4_encoder->limited_rgb_range = true; > } else { > + if (vc4_hdmi->variant->csc_setup) > + vc4_hdmi->variant->csc_setup(vc4_hdmi, false); > + > vc4_encoder->limited_rgb_range = false; > } > > - /* The RGB order applies even when CSC is disabled. */ > - HDMI_WRITE(HDMI_CSC_CTL, csc_ctl); > - > HDMI_WRITE(HDMI_FIFO_CTL, VC4_HDMI_FIFO_CTL_MASTER_SLAVE_N); > > if (debug_dump_regs) { > @@ -1430,6 +1443,7 @@ static const struct vc4_hdmi_variant bcm2835_variant = { > .num_registers = ARRAY_SIZE(vc4_hdmi_fields), > > .init_resources = vc4_hdmi_init_resources, > + .csc_setup = vc4_hdmi_csc_setup, > .reset = vc4_hdmi_reset, > .phy_init = vc4_hdmi_phy_init, > .phy_disable = vc4_hdmi_phy_disable, > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h > index 950accbc44e4..c8fd58548ea2 100644 > --- a/drivers/gpu/drm/vc4/vc4_hdmi.h > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h > @@ -41,6 +41,9 @@ struct vc4_hdmi_variant { > /* Callback to reset the HDMI block */ > void (*reset)(struct vc4_hdmi *vc4_hdmi); > > + /* Callback to enable / disable the CSC */ > + void (*csc_setup)(struct vc4_hdmi *vc4_hdmi, bool enable); > + > /* Callback to initialize the PHY according to the mode */ > void (*phy_init)(struct vc4_hdmi *vc4_hdmi, > struct drm_display_mode *mode); > -- > git-series 0.9.1