LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org,
	David Airlie <airlied@linux.ie>,
	"open list:DRM DRIVERS FOR RENESAS"
	<dri-devel@lists.freedesktop.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 06/17] drm: rcar-du: Allow DU groups to work with hardware indexing
Date: Thu, 26 Apr 2018 23:36:48 +0300	[thread overview]
Message-ID: <10312647.9oa0HbEkDa@avalon> (raw)
In-Reply-To: <20180426165346.494-7-kieran.bingham+renesas@ideasonboard.com>

Hi Kieran,

Thank you for the patch.

On Thursday, 26 April 2018 19:53:35 EEST Kieran Bingham wrote:
> The group objects assume linear indexing, and more so always assume that
> channel 0 of any active group is used.
> 
> Now that the CRTC objects support non-linear indexing, adapt the groups
> to remove assumptions that channel 0 is utilised in each group by using
> the channel mask provided in the device structures.
> 
> Finally ensure that the RGB routing is determined from the index of the
> CRTC object (which represents the hardware DU channel index).
> 
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_group.c | 14 +++++++++-----
>  drivers/gpu/drm/rcar-du/rcar_du_group.h |  2 ++
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c   |  5 ++++-
>  3 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c
> b/drivers/gpu/drm/rcar-du/rcar_du_group.c index eead202c95c7..c52091fe02ba
> 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
> @@ -46,9 +46,12 @@ void rcar_du_group_write(struct rcar_du_group *rgrp, u32
> reg, u32 data)
> 
>  static void rcar_du_group_setup_pins(struct rcar_du_group *rgrp)
>  {
> -	u32 defr6 = DEFR6_CODE | DEFR6_ODPM02_DISP;
> +	u32 defr6 = DEFR6_CODE;
> 
> -	if (rgrp->num_crtcs > 1)
> +	if (rgrp->channel_mask & BIT(0))
> +		defr6 |= DEFR6_ODPM02_DISP;
> +
> +	if (rgrp->channel_mask & BIT(1))
>  		defr6 |= DEFR6_ODPM12_DISP;

So much cleaner with the channels mask, I like this.

>  	rcar_du_group_write(rgrp, DEFR6, defr6);
> @@ -80,10 +83,11 @@ static void rcar_du_group_setup_defr8(struct
> rcar_du_group *rgrp) * On Gen3 VSPD routing can't be configured, but DPAD
> routing
>  		 * needs to be set despite having a single option available.
>  		 */
> -		u32 crtc = ffs(possible_crtcs) - 1;
> +		unsigned int rgb_crtc = ffs(possible_crtcs) - 1;
> +		struct rcar_du_crtc *crtc = &rcdu->crtcs[rgb_crtc];
> 
> -		if (crtc / 2 == rgrp->index)
> -			defr8 |= DEFR8_DRGBS_DU(crtc);
> +		if (crtc->index / 2 == rgrp->index)
> +			defr8 |= DEFR8_DRGBS_DU(crtc->index);
>  	}
> 
>  	rcar_du_group_write(rgrp, DEFR8, defr8);
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h
> b/drivers/gpu/drm/rcar-du/rcar_du_group.h index 5e3adc6b31b5..d29a68e006a7
> 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_group.h
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h
> @@ -25,6 +25,7 @@ struct rcar_du_device;
>   * @dev: the DU device
>   * @mmio_offset: registers offset in the device memory map
>   * @index: group index
> + * @channel_mask: bitmask of populated DU channels in this group
>   * @num_crtcs: number of CRTCs in this group (1 or 2)
>   * @use_count: number of users of the group (rcar_du_group_(get|put))
>   * @used_crtcs: number of CRTCs currently in use
> @@ -39,6 +40,7 @@ struct rcar_du_group {
>  	unsigned int mmio_offset;
>  	unsigned int index;
> 
> +	unsigned int channel_mask;

Depending on how you like my suggestion in patch 05/17, this might be better 
called channels_mask.

>  	unsigned int num_crtcs;
>  	unsigned int use_count;
>  	unsigned int used_crtcs;
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 19a445fbc879..45fb554fd3c7
> 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> @@ -597,7 +597,10 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
>  		rgrp->dev = rcdu;
>  		rgrp->mmio_offset = mmio_offsets[i];
>  		rgrp->index = i;
> -		rgrp->num_crtcs = min(rcdu->num_crtcs - 2 * i, 2U);
> +		/* Extract the channel mask for this group only */

s/only/only./

> +		rgrp->channel_mask = (rcdu->info->channel_mask >> (2 * i))
> +				   & GENMASK(1, 0);
> +		rgrp->num_crtcs = hweight8(rgrp->channel_mask);

You could optimize this by computing it as

	rgrp->num_crtcs = (rgrp->channel_mask >> 1)
			| (rgrp->channel_mask & 1);

as you know that only two bits at most can be set. Up to you.

>  		/*
>  		 * If we have more than one CRTCs in this group pre-associate

With those small issues fixed,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2018-04-26 20:36 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180426165346.494-1-kieran.bingham+renesas@ideasonboard.com>
2018-04-26 16:53 ` [PATCH 01/17] dt-bindings: display: renesas: du: Increase indent in output table Kieran Bingham
2018-04-26 20:08   ` Laurent Pinchart
2018-04-26 16:53 ` [PATCH 02/17] dt-bindings: display: renesas: du: Document the R8A77965 bindings Kieran Bingham
2018-04-26 16:57   ` Kieran Bingham
2018-04-26 20:10     ` Laurent Pinchart
2018-04-27  8:40       ` Kieran Bingham
2018-04-26 16:53 ` [PATCH 03/17] pinctrl: sh-pfc: r8a77965: Add DU RGB output pins, groups and functions Kieran Bingham
2018-04-26 20:16   ` Laurent Pinchart
2018-04-26 16:53 ` [PATCH 04/17] drm: rcar-du: Use the correct naming for ODPM fields in DEFR6 Kieran Bingham
2018-04-26 20:18   ` Laurent Pinchart
2018-04-26 16:53 ` [PATCH 05/17] drm: rcar-du: Split CRTC handling to support hardware indexing Kieran Bingham
2018-04-26 20:30   ` Laurent Pinchart
2018-04-27 10:15     ` Kieran Bingham
2018-04-26 16:53 ` [PATCH 06/17] drm: rcar-du: Allow DU groups to work with " Kieran Bingham
2018-04-26 20:36   ` Laurent Pinchart [this message]
2018-04-27 10:10     ` Kieran Bingham
2018-04-26 16:53 ` [PATCH 07/17] drm: rcar-du: Add R8A77965 support Kieran Bingham
2018-04-26 20:43   ` Laurent Pinchart
2018-04-27 10:14     ` Kieran Bingham
2018-04-26 16:53 ` [PATCH 08/17] arm64: dts: r8a77965: Provide sysc header definitions Kieran Bingham
2018-04-26 20:53   ` Laurent Pinchart
2018-04-26 16:53 ` [PATCH 09/17] arm64: dts: r8a77965: Use the correct CPG header Kieran Bingham
2018-04-26 21:16   ` Laurent Pinchart
2018-04-26 16:53 ` [PATCH 10/17] arm64: dts: r8a77965: Add FCPF and FCPV instances Kieran Bingham
2018-04-26 21:06   ` Laurent Pinchart
2018-04-26 16:53 ` [PATCH 11/17] arm64: dts: r8a77965: Add VSP instances Kieran Bingham
2018-04-26 21:11   ` Laurent Pinchart
2018-04-27 16:33     ` Kieran Bingham
2018-06-08  9:29     ` Geert Uytterhoeven
2018-06-08 11:00       ` Laurent Pinchart
2018-04-26 16:53 ` [PATCH 12/17] arm64: dts: r8a77965: Populate the DU instance placeholder Kieran Bingham
2018-04-26 21:15   ` Laurent Pinchart
2018-04-27 16:34     ` Kieran Bingham
2018-04-26 16:53 ` [PATCH 13/17] arm64: dts: r8a77965: Add HDMI encoder instance Kieran Bingham
2018-04-26 21:17   ` Laurent Pinchart
2018-04-26 16:53 ` [PATCH 14/17] arm64: dts: r8a77965-salvator-x: Add DU external dot clocks Kieran Bingham
2018-04-26 21:18   ` Laurent Pinchart
2018-04-26 16:53 ` [PATCH 15/17] arm64: dts: r8a77965-salvator-x: Enable HDMI output Kieran Bingham
2018-04-26 21:21   ` Laurent Pinchart
2018-04-27 16:22     ` Kieran Bingham
2018-04-26 16:53 ` [PATCH 16/17] arm64: dts: r8a77965-salvator-xs: Add DU external dot clocks Kieran Bingham
2018-04-26 21:22   ` Laurent Pinchart
2018-04-26 16:53 ` [PATCH 17/17] arm64: dts: r8a77965-salvator-xs: Enable HDMI output Kieran Bingham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10312647.9oa0HbEkDa@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --subject='Re: [PATCH 06/17] drm: rcar-du: Allow DU groups to work with hardware indexing' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).