Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp290985ybg; Tue, 28 Jul 2020 06:14:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlI39aomuMHftilaWXIUY0aatayOs7WKWmsSFdcy/iG9+J2/0J6RFQe0o7yljmFM8p5iqE X-Received: by 2002:a17:906:3c59:: with SMTP id i25mr15427740ejg.202.1595942095136; Tue, 28 Jul 2020 06:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595942095; cv=none; d=google.com; s=arc-20160816; b=grL8lhiou0rab18gpv3pObDgvhOT+VJhSAQUJbsoQR3RSkq0dlISR3prq2dc9GM4Vs CGKkPZi1PLZp84usZWcNBo11DcleFDyGjz2cWnGVoZGhIC3r2U/oYpB9wzeg6UWPiIMN 3aHowzVWkb5tCl5k0jmM8lXVKgS8szt8MonItiGBsUR9uJ9pM1P5Dtx31aGjLtX52BFI j37lvs21M8xto2hM5jjC6IhXCvDArU2D6DQW3huZeiEFOwmc9nNTMaqK5Dbf88fBXhye Jj49ffz2E+jb/cKKgAp2DEkpMMtwNDOJW0vtIjlNUFt/qdpJ998myFeupUzYYTBI/2jv UGhA== 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=hn73ZeTsbvvZEe6zF6c1TcaGJ3Kb+2Neo3dKxuwxqwI=; b=I0t7owM7mntF+Q6aYs1Ue0PaCs5JTWfOIb1dNvy18vK/3X6SFHXprtuwAjR8T5+ON3 KqafUirBwNBXw9yRo366TXC43eDbpCPmQ+mFr92MzL2jl7O7EaNy8BPU/WroiUqw7TeT gp38iQpu4C37VtN1zB/Shh1AJCmhrspznIPw1cDPiPVs9poXRQAPj1eQIVW4OxnsXbSN xd8NoPUWiBHC4vQ49j5X32Y6Xl6hCuZWFHJDUDmk6047onYyYAFIbj0haISEz5i9/vM3 vE4q1TST5fkqfjG5asLgvExJ0Xjx6f9qh3VhqX+STqZGE4Jv0f7fAO8S07giqh9HyZMb LoJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=O64uoCHV; 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 um11si4479078ejb.117.2020.07.28.06.14.32; Tue, 28 Jul 2020 06:14:55 -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=O64uoCHV; 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 S1730003AbgG1NNO (ORCPT + 99 others); Tue, 28 Jul 2020 09:13:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729923AbgG1NNN (ORCPT ); Tue, 28 Jul 2020 09:13:13 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7659C061794 for ; Tue, 28 Jul 2020 06:13:12 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id c80so17266893wme.0 for ; Tue, 28 Jul 2020 06:13:12 -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=hn73ZeTsbvvZEe6zF6c1TcaGJ3Kb+2Neo3dKxuwxqwI=; b=O64uoCHVwK8OV2TsHjId6t4SCQ2EwLv1Nlbsa5qLH4EFhek7Lxuf5K7I0Xcqsyb3cx rOlCF+Jc36Z/OfuQAcZSE3GN7mOqwk4cttMNEgd3z5LtE3xV5nFeQlUXgyG3NmUw7kAQ BfXzolvhIsne8zHf11w+A8GPIeWx5gFDlN/yCVSCEnq+rFtoH3yncRfVbhoc/g8sq9Hd W4slxdlT4/o8bF7am460uU1vP1GFDqiSF36DLpk7XPx0qr/+rU81W36sbYRJgVDOuK+D fiMpF50F3dpH8xLjIzu3OWdGc86R7wJprr9KtIjffdmiCAdcnYNXmHvuimvajdw1VcL2 CjaQ== 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=hn73ZeTsbvvZEe6zF6c1TcaGJ3Kb+2Neo3dKxuwxqwI=; b=QuXSSV0WnpmEKIIJVbQyK86PBYUEoAGEobcATpk1ZNvNkBN7n9XPuqwCpRLX6aOUzx mwb7kELDpoxGeg+NlSZyBzSYdeiFCN5CNeBfNqaZZyg5+71q9n800yJ9saN60QkWZVdl BeCypf32Be9728PoWVXASQDFDacqavqe4641R+8hdAND4VMRNWTyYrVfmM0nnne1obBN Gfm8aJt6CSJsgj9kIuVDV5oGx0mvnaH2qCZbAJiTkNkHjqMe2t4vVDaiSEPtZ6NIdghD gqOT5Z+/TJCypcXp01hsyILJZQ48pU+0Kn2JUQEYma8O0l5vS1zPFuOCRRYhsYY1waG0 mSGQ== X-Gm-Message-State: AOAM533JT7A47W+Q0GTpkdClVoTpwkkSGm9yO94RqxhbYE2T5vL7NTjs 64ZHuE1o8ZVYzoXqKHyjHBmhzMwWzflbhPF07KeBPmVGzd8= X-Received: by 2002:a1c:1d52:: with SMTP id d79mr1526380wmd.82.1595941991293; Tue, 28 Jul 2020 06:13:11 -0700 (PDT) MIME-Version: 1.0 References: <7e00240a06b54e2ee7175a892310914d7f565426.1594230107.git-series.maxime@cerno.tech> In-Reply-To: <7e00240a06b54e2ee7175a892310914d7f565426.1594230107.git-series.maxime@cerno.tech> From: Dave Stevenson Date: Tue, 28 Jul 2020 14:12:55 +0100 Message-ID: Subject: Re: [PATCH v4 55/78] 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 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 Wed, 8 Jul 2020 at 18:43, 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. We've gained the set_timings callback in this patch as well as csc_setup. Was that an accidental squash as we had them as independent commits in v1. Dave > Signed-off-by: Maxime Ripard > --- > drivers/gpu/drm/vc4/vc4_hdmi.c | 142 +++++++++++++++++++--------------- > drivers/gpu/drm/vc4/vc4_hdmi.h | 7 ++- > 2 files changed, 89 insertions(+), 60 deletions(-) > > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c > index 19897d6525ac..a50220bfd5dd 100644 > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c > @@ -334,12 +334,44 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder) > DRM_ERROR("Failed to release power domain: %d\n", ret); > } > > -static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) > +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_set_timings(struct vc4_hdmi *vc4_hdmi, > + struct drm_display_mode *mode) > { > - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; > - struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); > - struct vc4_hdmi_encoder *vc4_encoder = &vc4_hdmi->encoder; > - bool debug_dump_regs = false; > bool hsync_pos = mode->flags & DRM_MODE_FLAG_PHSYNC; > bool vsync_pos = mode->flags & DRM_MODE_FLAG_PVSYNC; > bool interlaced = mode->flags & DRM_MODE_FLAG_INTERLACE; > @@ -357,7 +389,41 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) > mode->crtc_vsync_end - > interlaced, > VC4_HDMI_VERTB_VBP)); > - u32 csc_ctl; > + > + HDMI_WRITE(HDMI_HORZA, > + (vsync_pos ? VC4_HDMI_HORZA_VPOS : 0) | > + (hsync_pos ? VC4_HDMI_HORZA_HPOS : 0) | > + VC4_SET_FIELD(mode->hdisplay * pixel_rep, > + VC4_HDMI_HORZA_HAP)); > + > + HDMI_WRITE(HDMI_HORZB, > + VC4_SET_FIELD((mode->htotal - > + mode->hsync_end) * pixel_rep, > + VC4_HDMI_HORZB_HBP) | > + VC4_SET_FIELD((mode->hsync_end - > + mode->hsync_start) * pixel_rep, > + VC4_HDMI_HORZB_HSP) | > + VC4_SET_FIELD((mode->hsync_start - > + mode->hdisplay) * pixel_rep, > + VC4_HDMI_HORZB_HFP)); > + > + HDMI_WRITE(HDMI_VERTA0, verta); > + HDMI_WRITE(HDMI_VERTA1, verta); > + > + HDMI_WRITE(HDMI_VERTB0, vertb_even); > + HDMI_WRITE(HDMI_VERTB1, vertb); > + > + HDMI_WRITE(HDMI_VID_CTL, > + (vsync_pos ? 0 : VC4_HD_VID_CTL_VSYNC_LOW) | > + (hsync_pos ? 0 : VC4_HD_VID_CTL_HSYNC_LOW)); > +} > + > +static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) > +{ > + struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; > + struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); > + struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder); > + bool debug_dump_regs = false; > int ret; > > ret = pm_runtime_get_sync(&vc4_hdmi->pdev->dev); > @@ -401,68 +467,22 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder) > VC4_HDMI_SCHEDULER_CONTROL_MANUAL_FORMAT | > VC4_HDMI_SCHEDULER_CONTROL_IGNORE_VSYNC_PREDICTS); > > - HDMI_WRITE(HDMI_HORZA, > - (vsync_pos ? VC4_HDMI_HORZA_VPOS : 0) | > - (hsync_pos ? VC4_HDMI_HORZA_HPOS : 0) | > - VC4_SET_FIELD(mode->hdisplay * pixel_rep, > - VC4_HDMI_HORZA_HAP)); > - > - HDMI_WRITE(HDMI_HORZB, > - VC4_SET_FIELD((mode->htotal - > - mode->hsync_end) * pixel_rep, > - VC4_HDMI_HORZB_HBP) | > - VC4_SET_FIELD((mode->hsync_end - > - mode->hsync_start) * pixel_rep, > - VC4_HDMI_HORZB_HSP) | > - VC4_SET_FIELD((mode->hsync_start - > - mode->hdisplay) * pixel_rep, > - VC4_HDMI_HORZB_HFP)); > - > - HDMI_WRITE(HDMI_VERTA0, verta); > - HDMI_WRITE(HDMI_VERTA1, verta); > - > - HDMI_WRITE(HDMI_VERTB0, vertb_even); > - HDMI_WRITE(HDMI_VERTB1, vertb); > - > - HDMI_WRITE(HDMI_VID_CTL, > - (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_hdmi->variant->set_timings) > + vc4_hdmi->variant->set_timings(vc4_hdmi, mode); > > 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) { > @@ -1431,7 +1451,9 @@ 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, > + .set_timings = vc4_hdmi_set_timings, > .phy_init = vc4_hdmi_phy_init, > .phy_disable = vc4_hdmi_phy_disable, > .phy_rng_enable = vc4_hdmi_phy_rng_enable, > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h > index 950accbc44e4..0c32dc46d289 100644 > --- a/drivers/gpu/drm/vc4/vc4_hdmi.h > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h > @@ -41,6 +41,13 @@ 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 configure the video timings in the HDMI block */ > + void (*set_timings)(struct vc4_hdmi *vc4_hdmi, > + struct drm_display_mode *mode); > + > /* 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