mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	David Airlie <airlied@linux.ie>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Hans de Goede <hdegoede@redhat.com>, Chen-Yu Tsai <wens@csie.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 5/5] drm/sun4i: Add support for the overscan profiles
Date: Tue, 8 Nov 2016 09:59:27 +0100	[thread overview]
Message-ID: <20161108085927.ibyett46cjgyfwu2@phenom.ffwll.local> (raw)
In-Reply-To: <b980759ad766658d7bc3d67c18f505c5bf727ef5.1476779323.git-series.maxime.ripard@free-electrons.com>

On Tue, Oct 18, 2016 at 10:29:38AM +0200, Maxime Ripard wrote:
> Create overscan profiles reducing the displayed zone.
> 
> For each TV standard (PAL and NTSC so far), we create 4 more reduced modes
> by steps of 5% that the user will be able to select.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

tbh I think if we agree to do this (and that still seems an open question)
I think there should be a generic helper to add these overscan modes with
increased porches. Anything that only depends upon the sink (and
overscanning is something the sink does) should imo be put into a suitable
helper library for everyone to share.

Or maybe even stash it into the probe helpers and call it for all TV
connectors. Definitely not a driver-private thing.
-Daniel
> ---
>  drivers/gpu/drm/sun4i/sun4i_tv.c | 60 +++++++++++++++++++--------------
>  1 file changed, 36 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c b/drivers/gpu/drm/sun4i/sun4i_tv.c
> index f99886462cb8..9ee03ba086b6 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_tv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_tv.c
> @@ -301,27 +301,33 @@ static const struct tv_mode *sun4i_tv_find_tv_by_mode(const struct drm_display_m
>  		DRM_DEBUG_DRIVER("Comparing mode %s vs %s",
>  				 mode->name, tv_mode->name);
>  
> -		if (!strcmp(mode->name, tv_mode->name))
> +		if (!strncmp(mode->name, tv_mode->name, strlen(tv_mode->name)))
>  			return tv_mode;
>  	}
>  
>  	/* Then by number of lines */
>  	for (i = 0; i < ARRAY_SIZE(tv_modes); i++) {
>  		const struct tv_mode *tv_mode = &tv_modes[i];
> +		int j;
>  
> -		DRM_DEBUG_DRIVER("Comparing mode %s vs %s (X: %d vs %d)",
> -				 mode->name, tv_mode->name,
> -				 mode->vdisplay, tv_mode->vdisplay);
> +		for (j = 0; j < 20; j += 5) {
> +			u32 vdisplay = tv_mode->vdisplay * (100 - j) / 100;
>  
> -		if (mode->vdisplay == tv_mode->vdisplay)
> -			return tv_mode;
> +			DRM_DEBUG_DRIVER("Comparing mode with %s (%d) (X: %d vs %d)",
> +					 tv_mode->name, j,
> +					 vdisplay, tv_mode->vdisplay);
> +
> +			if (vdisplay == tv_mode->vdisplay)
> +				return tv_mode;
> +		}
>  	}
>  
>  	return NULL;
>  }
>  
>  static void sun4i_tv_mode_to_drm_mode(const struct tv_mode *tv_mode,
> -				      struct drm_display_mode *mode)
> +				      struct drm_display_mode *mode,
> +				      int overscan)
>  {
>  	DRM_DEBUG_DRIVER("Creating mode %s\n", mode->name);
>  
> @@ -329,12 +335,12 @@ static void sun4i_tv_mode_to_drm_mode(const struct tv_mode *tv_mode,
>  	mode->clock = 13500;
>  	mode->flags = DRM_MODE_FLAG_INTERLACE;
>  
> -	mode->hdisplay = tv_mode->hdisplay;
> +	mode->hdisplay = tv_mode->hdisplay * (100 - overscan) / 100;
>  	mode->hsync_start = mode->hdisplay + tv_mode->hfront_porch;
>  	mode->hsync_end = mode->hsync_start + tv_mode->hsync_len;
>  	mode->htotal = mode->hsync_end  + tv_mode->hback_porch;
>  
> -	mode->vdisplay = tv_mode->vdisplay;
> +	mode->vdisplay = tv_mode->vdisplay * (100 - overscan) / 100;
>  	mode->vsync_start = mode->vdisplay + tv_mode->vfront_porch;
>  	mode->vsync_end = mode->vsync_start + tv_mode->vsync_len;
>  	mode->vtotal = mode->vsync_end  + tv_mode->vback_porch;
> @@ -352,10 +358,10 @@ static int sun4i_tv_atomic_check(struct drm_encoder *encoder,
>  		return -EINVAL;
>  
>  	state->display_x_size = tv_mode->hdisplay;
> -	state->plane_x_offset = 0;
> +	state->plane_x_offset = (tv_mode->hdisplay - mode->hdisplay) / 2;
>  
>  	state->display_y_size = tv_mode->vdisplay;
> -	state->plane_y_offset = 0;
> +	state->plane_y_offset = (tv_mode->vdisplay - mode->vdisplay) / 2;
>  
>  	return 0;
>  }
> @@ -404,7 +410,7 @@ static void sun4i_tv_mode_set(struct drm_encoder *encoder,
>  	struct drm_display_mode tv_drm_mode = { 0 };
>  
>  	strcpy(tv_drm_mode.name, "TV");
> -	sun4i_tv_mode_to_drm_mode(tv_mode, &tv_drm_mode);
> +	sun4i_tv_mode_to_drm_mode(tv_mode, &tv_drm_mode, 0);
>  	drm_mode_set_crtcinfo(&tv_drm_mode, CRTC_INTERLACE_HALVE_V);
>  
>  	sun4i_tcon1_mode_set(tcon, &tv_drm_mode);
> @@ -526,22 +532,28 @@ static int sun4i_tv_comp_get_modes(struct drm_connector *connector)
>  	int i;
>  
>  	for (i = 0; i < ARRAY_SIZE(tv_modes); i++) {
> -		struct drm_display_mode *mode;
>  		const struct tv_mode *tv_mode = &tv_modes[i];
> -
> -		mode = drm_mode_create(connector->dev);
> -		if (!mode) {
> -			DRM_ERROR("Failed to create a new display mode\n");
> -			return 0;
> +		int j;
> +
> +		for (j = 0; j < 20; j += 5) {
> +			struct drm_display_mode *mode = drm_mode_create(connector->dev);
> +			if (!mode) {
> +				DRM_ERROR("Failed to create a new display mode\n");
> +				return 0;
> +			}
> +
> +			if (j)
> +				sprintf(mode->name, "%s%d", tv_mode->name,
> +					j);
> +			else
> +				strcpy(mode->name, tv_mode->name);
> +
> +			sun4i_tv_mode_to_drm_mode(tv_mode, mode, j);
> +			drm_mode_probed_add(connector, mode);
>  		}
> -
> -		strcpy(mode->name, tv_mode->name);
> -
> -		sun4i_tv_mode_to_drm_mode(tv_mode, mode);
> -		drm_mode_probed_add(connector, mode);
>  	}
>  
> -	return i;
> +	return i * 4;
>  }
>  
>  static int sun4i_tv_comp_mode_valid(struct drm_connector *connector,
> -- 
> git-series 0.8.10
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2016-11-08  8:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18  8:29 [PATCH 0/5] drm/sun4i: Handle TV overscan Maxime Ripard
2016-10-18  8:29 ` [PATCH 1/5] drm/modes: Rewrite the command line parser Maxime Ripard
2016-11-16 17:12   ` Sean Paul
2016-11-21  7:36     ` Maxime Ripard
2016-10-18  8:29 ` [PATCH 2/5] drm/modes: Support modes names on the command line Maxime Ripard
2016-11-16 17:21   ` Sean Paul
2016-11-21  7:40     ` Maxime Ripard
2016-10-18  8:29 ` [PATCH 3/5] drm/sun4i: Add custom crtc state Maxime Ripard
2016-10-18  8:29 ` [PATCH 4/5] drm/sun4i: Compute TCON1 mode from tv mode Maxime Ripard
2016-10-18  8:29 ` [PATCH 5/5] drm/sun4i: Add support for the overscan profiles Maxime Ripard
2016-11-08  8:59   ` Daniel Vetter [this message]
2016-11-10 14:56     ` Maxime Ripard
2016-11-11  9:17       ` Daniel Vetter
2016-11-21  7:30         ` Maxime Ripard
2016-10-18  9:24 ` [PATCH 0/5] drm/sun4i: Handle TV overscan Russell King - ARM Linux
2016-10-18 10:03   ` Maxime Ripard
2016-10-18 17:57     ` Jean-Francois Moine
2016-10-31  8:42     ` Russell King - ARM Linux
2016-11-03  9:01       ` Maxime Ripard
2016-11-03  9:54         ` Russell King - ARM Linux
2016-11-07 15:09           ` Maxime Ripard
2016-11-07 15:46             ` Russell King - ARM Linux
2016-11-10 14:25               ` Maxime Ripard
2016-11-03 21:11         ` Sean Paul
2016-11-07 14:11           ` Maxime Ripard

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=20161108085927.ibyett46cjgyfwu2@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hdegoede@redhat.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=wens@csie.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®