All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ander Conselvan de Oliveira <conselvan2@gmail.com>
To: Matt Roper <matthew.d.roper@intel.com>, intel-gfx@lists.freedesktop.org
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>,
	dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 1/9] drm: add helper to get crtc timings (v4)
Date: Thu, 27 Nov 2014 16:19:15 +0200	[thread overview]
Message-ID: <547732E3.5000506@gmail.com> (raw)
In-Reply-To: <1416858786-25376-2-git-send-email-matthew.d.roper@intel.com>

On 11/24/2014 09:52 PM, Matt Roper wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> We need to get hdisplay and vdisplay in a few places so create a
> helper to make our job easier.
>
> v2 (by Matt): Use new stereo doubling function (suggested by Ville)
>
> v3 (by Matt):
>   - Add missing kerneldoc (Daniel)
>   - Use drm_mode_copy() (Jani)
>
> v4 (by Matt):
>   - Drop stereo doubling function again; add 'stereo only' flag
>     to drm_mode_set_crtcinfo() instead (Ville)
>
> Cc: dri-devel@lists.freedesktop.org
> Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> ---
>   drivers/gpu/drm/drm_crtc.c           | 32 ++++++++++++++++++++++----------
>   drivers/gpu/drm/drm_modes.c          | 24 ++++++++++++++----------
>   drivers/gpu/drm/i915/intel_display.c |  6 +++---
>   include/drm/drm_crtc.h               |  2 ++
>   include/drm/drm_modes.h              |  3 +++
>   5 files changed, 44 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 589a921..f06f1b4 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -2499,6 +2499,27 @@ int drm_mode_set_config_internal(struct drm_mode_set *set)
>   EXPORT_SYMBOL(drm_mode_set_config_internal);
>
>   /**
> + * drm_crtc_get_hv_timing - Fetches hdisplay/vdisplay for given mode
> + * @mode: mode to query
> + * @hdisplay: hdisplay value to fill in
> + * @vdisplay: vdisplay value to fill in
> + *
> + * The vdisplay value will be doubled if the specified mode is a stereo mode of
> + * the appropriate layout.
> + */
> +void drm_crtc_get_hv_timing(const struct drm_display_mode *mode,
> +			    int *hdisplay, int *vdisplay)
> +{
> +	struct drm_display_mode adjusted;
> +
> +	drm_mode_copy(&adjusted, mode);
> +	drm_mode_set_crtcinfo(&adjusted, CRTC_STEREO_DOUBLE_ONLY);
> +	*hdisplay = adjusted.crtc_hdisplay;
> +	*vdisplay = adjusted.crtc_vdisplay;
> +}
> +EXPORT_SYMBOL(drm_crtc_get_hv_timing);
> +
> +/**
>    * drm_crtc_check_viewport - Checks that a framebuffer is big enough for the
>    *     CRTC viewport
>    * @crtc: CRTC that framebuffer will be displayed on
> @@ -2515,16 +2536,7 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
>   {
>   	int hdisplay, vdisplay;
>
> -	hdisplay = mode->hdisplay;
> -	vdisplay = mode->vdisplay;
> -
> -	if (drm_mode_is_stereo(mode)) {
> -		struct drm_display_mode adjusted = *mode;
> -
> -		drm_mode_set_crtcinfo(&adjusted, CRTC_STEREO_DOUBLE);
> -		hdisplay = adjusted.crtc_hdisplay;
> -		vdisplay = adjusted.crtc_vdisplay;
> -	}
> +	drm_crtc_get_hv_timing(mode, &hdisplay, &vdisplay);

This changes the behavior slightly since before, for stereo modes, 
dbl_scan and vscan would affect hdisplay and vdisplay. If I understand 
correctly the old behavior is a bug, but it would be good to state that 
the change is intentional.

>
>   	if (crtc->invert_dimensions)
>   		swap(hdisplay, vdisplay);
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 6d8b941..fd5479b 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -765,18 +765,22 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags)
>   		}
>   	}
>
> -	if (p->flags & DRM_MODE_FLAG_DBLSCAN) {
> -		p->crtc_vdisplay *= 2;
> -		p->crtc_vsync_start *= 2;
> -		p->crtc_vsync_end *= 2;
> -		p->crtc_vtotal *= 2;
> +	if (!(adjust_flags & CRTC_NO_DBLSCAN)) {
> +		if (p->flags & DRM_MODE_FLAG_DBLSCAN) {
> +			p->crtc_vdisplay *= 2;
> +			p->crtc_vsync_start *= 2;
> +			p->crtc_vsync_end *= 2;
> +			p->crtc_vtotal *= 2;
> +		}
>   	}
>
> -	if (p->vscan > 1) {
> -		p->crtc_vdisplay *= p->vscan;
> -		p->crtc_vsync_start *= p->vscan;
> -		p->crtc_vsync_end *= p->vscan;
> -		p->crtc_vtotal *= p->vscan;
> +	if (!(adjust_flags & CRTC_NO_VSCAN)) {
> +		if (p->vscan > 1) {
> +			p->crtc_vdisplay *= p->vscan;
> +			p->crtc_vsync_start *= p->vscan;
> +			p->crtc_vsync_end *= p->vscan;
> +			p->crtc_vtotal *= p->vscan;
> +		}
>   	}
>
>   	if (adjust_flags & CRTC_STEREO_DOUBLE) {
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index a3d2a44..b87aeab 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -10205,9 +10205,9 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,
>   	 * computation to clearly distinguish it from the adjusted mode, which
>   	 * can be changed by the connectors in the below retry loop.
>   	 */
> -	drm_mode_set_crtcinfo(&pipe_config->requested_mode, CRTC_STEREO_DOUBLE);
> -	pipe_config->pipe_src_w = pipe_config->requested_mode.crtc_hdisplay;
> -	pipe_config->pipe_src_h = pipe_config->requested_mode.crtc_vdisplay;
> +	drm_crtc_get_hv_timing(&pipe_config->requested_mode,
> +			       &pipe_config->pipe_src_w,
> +			       &pipe_config->pipe_src_h);

Same thing here.


>   encoder_retry:
>   	/* Ensure the port clock defaults are reset when retrying. */
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index b459e8f..6e46c5d 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -1140,6 +1140,8 @@ extern int drm_plane_init(struct drm_device *dev,
>   extern void drm_plane_cleanup(struct drm_plane *plane);
>   extern unsigned int drm_plane_index(struct drm_plane *plane);
>   extern void drm_plane_force_disable(struct drm_plane *plane);
> +extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode,
> +				   int *hdisplay, int *vdisplay);
>   extern int drm_crtc_check_viewport(const struct drm_crtc *crtc,
>   				   int x, int y,
>   				   const struct drm_display_mode *mode,
> diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
> index 91d0582..8f17811 100644
> --- a/include/drm/drm_modes.h
> +++ b/include/drm/drm_modes.h
> @@ -90,6 +90,9 @@ enum drm_mode_status {
>
>   #define CRTC_INTERLACE_HALVE_V	(1 << 0) /* halve V values for interlacing */
>   #define CRTC_STEREO_DOUBLE	(1 << 1) /* adjust timings for stereo modes */
> +#define CRTC_NO_DBLSCAN		(1 << 2) /* don't adjust doublescan */
> +#define CRTC_NO_VSCAN		(1 << 3) /* don't adjust doublescan */
> +#define CRTC_STEREO_DOUBLE_ONLY	(CRTC_NO_DBLSCAN | CRTC_NO_VSCAN)

The kernel doc of drm_mode_set_crtcinfo() has a brief explanation of 
what the flags above do. I think it would be proper to update that with 
the new additions.

Cheers,
Ander

>
>   #define DRM_MODE_FLAG_3D_MAX	DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF
>
>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2014-11-27 14:19 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-24 19:52 [PATCH 0/9] i915 display refactoring (v3) Matt Roper
2014-11-24 19:52 ` [PATCH 1/9] drm: add helper to get crtc timings (v4) Matt Roper
2014-11-27 14:19   ` Ander Conselvan de Oliveira [this message]
2014-11-24 19:52 ` [PATCH 2/9] drm/i915: remove intel_crtc_cursor_set_obj() (v5) Matt Roper
2014-11-24 19:53 ` [PATCH 3/9] drm/i915: remove intel_pipe_set_base() (v4) Matt Roper
2014-11-27 14:20   ` Ander Conselvan de Oliveira
2014-11-24 19:53 ` [PATCH 4/9] drm/i915: Introduce intel_prepare_cursor_plane() Matt Roper
2014-11-28 12:15   ` Ander Conselvan de Oliveira
2014-11-28 13:12     ` Ander Conselvan de Oliveira
2014-11-28 18:10     ` Daniel Vetter
2014-12-01  8:26   ` Ander Conselvan de Oliveira
2014-11-24 19:53 ` [PATCH 5/9] drm/i915: Make intel_plane_state subclass drm_plane_state Matt Roper
2014-11-24 19:53 ` [PATCH 6/9] drm/i915: Consolidate plane 'prepare' functions Matt Roper
2014-11-28 13:00   ` Ander Conselvan de Oliveira
2014-12-01  8:29   ` Ander Conselvan de Oliveira
2014-12-01 21:25     ` Matt Roper
2014-11-24 19:53 ` [PATCH 7/9] drm/i915: Consolidate plane 'cleanup' operations Matt Roper
2014-12-01 13:46   ` Ander Conselvan de Oliveira
2014-11-24 19:53 ` [PATCH 8/9] drm/i915: Consolidate top-level .update_plane() handlers Matt Roper
2014-11-24 19:53 ` [PATCH 9/9] drm/i915: Make all plane disables use 'update_plane' Matt Roper
2014-11-25  7:39   ` [PATCH 9/9] drm/i915: Make all plane disables use shuang.he
2014-11-27 15:57     ` Damien Lespiau
2014-11-28  0:53       ` He, Shuang
2014-11-28 12:21         ` Damien Lespiau
2014-11-28 12:55           ` Jani Nikula
2014-12-01 14:04   ` [PATCH 9/9] drm/i915: Make all plane disables use 'update_plane' Ander Conselvan de Oliveira
2014-12-01 16:46     ` Daniel Vetter

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=547732E3.5000506@gmail.com \
    --to=conselvan2@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.d.roper@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.