public inbox for dri-devel@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Imre Deak <imre.deak@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 14/15] drm/i915/tv: Fix >1024 modes on gen3
Date: Wed, 23 Jan 2019 18:38:17 +0200	[thread overview]
Message-ID: <20190123163817.GC20097@intel.com> (raw)
In-Reply-To: <20190123134902.GE17259@ideak-desk.fi.intel.com>

On Wed, Jan 23, 2019 at 03:49:02PM +0200, Imre Deak wrote:
> On Mon, Nov 12, 2018 at 06:59:59PM +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > On gen3 we must disable the TV encoder vertical filter for >1024
> > pixel wide sources. Once that's done all we can is try to center
> > the image on the screen. Naturally the TV mode vertical resolution
> > must be equal or larger than the user mode vertical resolution
> > or else we'd have to cut off part of the user mode.
> > 
> > And while we may not be able to respect the user's choice of
> > top and bottom borders exactly (or we'd have to reject he mode
> > most likely), we can try to maintain the relative sizes of the
> > top and bottom border with respect to each orher.
> > 
> > Additionally we must configure the pipe as interlaced if the
> > TV mode is interlaced.
> > 
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_tv.c | 100 +++++++++++++++++++++++++++++---
> >  1 file changed, 92 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
> > index 75126fce655d..7099d837e31a 100644
> > --- a/drivers/gpu/drm/i915/intel_tv.c
> > +++ b/drivers/gpu/drm/i915/intel_tv.c
> > @@ -861,6 +861,44 @@ static const struct tv_mode tv_modes[] = {
> >  	},
> >  };
> >  
> > +struct intel_tv_connector_state {
> > +	struct drm_connector_state base;
> > +
> > +	/*
> > +	 * May need to override the user margins for
> > +	 * gen3 >1024 wide source vertical centering.
> > +	 */
> > +	struct {
> > +		u16 top, bottom;
> > +	} margins;
> > +
> > +	bool bypass_vfilter;
> > +};
> > +
> > +#define to_intel_tv_connector_state(x) container_of(x, struct intel_tv_connector_state, base)
> > +
> > +/**
> > + * intel_digital_connector_duplicate_state - duplicate connector state
>       ^intel_tv_connector_duplicate_state
> > + * @connector: digital connector
>                   ^tv connector?
> > + *
> > + * Allocates and returns a copy of the connector state (both common and
> > + * digital connector specific) for the specified connector.
> > + *
> > + * Returns: The newly allocated connector state, or NULL on failure.
> > + */
> > +struct drm_connector_state *
> > +intel_tv_connector_duplicate_state(struct drm_connector *connector)
> > +{
> > +	struct intel_tv_connector_state *state;
> > +
> > +	state = kmemdup(connector->state, sizeof(*state), GFP_KERNEL);
> > +	if (!state)
> > +		return NULL;
> > +
> > +	__drm_atomic_helper_connector_duplicate_state(connector, &state->base);
> > +	return &state->base;
> > +}
> 
> You didn't add the corresponding checks for the new
> intel_tv_connector_state fields to intel_tv_atomic_check(). I suppose
> that's ok since something resulting in a change in those will force a
> modeset anyway:

The new fields are not visible to the user so nothing external
will change them. intel_tv_compute_config() (which is executed
after .atomic_check()) will just recompute them based on other
user visible state.

> 
> Reviewed-by: Imre Deak <imre.deak@intel.com>
> 
> > +
> >  static struct intel_tv *enc_to_tv(struct intel_encoder *encoder)
> >  {
> >  	return container_of(encoder, struct intel_tv, base);
> > @@ -1129,6 +1167,9 @@ intel_tv_compute_config(struct intel_encoder *encoder,
> >  			struct intel_crtc_state *pipe_config,
> >  			struct drm_connector_state *conn_state)
> >  {
> > +	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> > +	struct intel_tv_connector_state *tv_conn_state =
> > +		to_intel_tv_connector_state(conn_state);
> >  	const struct tv_mode *tv_mode = intel_tv_mode_find(conn_state);
> >  	struct drm_display_mode *adjusted_mode =
> >  		&pipe_config->base.adjusted_mode;
> > @@ -1149,6 +1190,43 @@ intel_tv_compute_config(struct intel_encoder *encoder,
> >  	pipe_config->port_clock = tv_mode->clock;
> >  
> >  	intel_tv_mode_to_mode(adjusted_mode, tv_mode);
> > +	drm_mode_set_crtcinfo(adjusted_mode, 0);
> > +
> > +	if (IS_GEN3(dev_priv) && hdisplay > 1024) {
> > +		int extra, top, bottom;
> > +
> > +		extra = adjusted_mode->crtc_vdisplay - vdisplay;
> > +
> > +		if (extra < 0) {
> > +			DRM_DEBUG_KMS("No vertical scaling for >1024 pixel wide modes\n");
> > +			return false;
> > +		}
> > +
> > +		/* Need to turn off the vertical filter and center the image */
> > +
> > +		/* Attempt to maintain the relative sizes of the margins */
> > +		top = conn_state->tv.margins.top;
> > +		bottom = conn_state->tv.margins.bottom;
> > +
> > +		if (top + bottom)
> > +			top = extra * top / (top + bottom);
> > +		else
> > +			top = extra / 2;
> > +		bottom = extra - top;
> > +
> > +		tv_conn_state->margins.top = top;
> > +		tv_conn_state->margins.bottom = bottom;
> > +
> > +		tv_conn_state->bypass_vfilter = true;
> > +
> > +		if (!tv_mode->progressive)
> > +			adjusted_mode->flags |= DRM_MODE_FLAG_INTERLACE;
> > +	} else {
> > +		tv_conn_state->margins.top = conn_state->tv.margins.top;
> > +		tv_conn_state->margins.bottom = conn_state->tv.margins.bottom;
> > +
> > +		tv_conn_state->bypass_vfilter = false;
> > +	}
> >  
> >  	DRM_DEBUG_KMS("TV mode:\n");
> >  	drm_mode_debug_printmodeline(adjusted_mode);
> > @@ -1222,8 +1300,8 @@ intel_tv_compute_config(struct intel_encoder *encoder,
> >  				  conn_state->tv.margins.left,
> >  				  conn_state->tv.margins.right);
> >  	intel_tv_scale_mode_vert(adjusted_mode, vdisplay,
> > -				 conn_state->tv.margins.top,
> > -				 conn_state->tv.margins.bottom);
> > +				 tv_conn_state->margins.top,
> > +				 tv_conn_state->margins.bottom);
> >  	drm_mode_set_crtcinfo(adjusted_mode, 0);
> >  	adjusted_mode->name[0] = '\0';
> >  
> > @@ -1316,8 +1394,10 @@ static void intel_tv_pre_enable(struct intel_encoder *encoder,
> >  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> >  	struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc);
> >  	struct intel_tv *intel_tv = enc_to_tv(encoder);
> > +	const struct intel_tv_connector_state *tv_conn_state =
> > +		to_intel_tv_connector_state(conn_state);
> >  	const struct tv_mode *tv_mode = intel_tv_mode_find(conn_state);
> > -	u32 tv_ctl;
> > +	u32 tv_ctl, tv_filter_ctl;
> >  	u32 scctl1, scctl2, scctl3;
> >  	int i, j;
> >  	const struct video_levels *video_levels;
> > @@ -1425,16 +1505,20 @@ static void intel_tv_pre_enable(struct intel_encoder *encoder,
> >  	assert_pipe_disabled(dev_priv, intel_crtc->pipe);
> >  
> >  	/* Filter ctl must be set before TV_WIN_SIZE */
> > -	I915_WRITE(TV_FILTER_CTL_1, TV_AUTO_SCALE);
> > +	tv_filter_ctl = TV_AUTO_SCALE;
> > +	if (tv_conn_state->bypass_vfilter)
> > +		tv_filter_ctl |= TV_V_FILTER_BYPASS;
> > +	I915_WRITE(TV_FILTER_CTL_1, tv_filter_ctl);
> > +
> >  	xsize = tv_mode->hblank_start - tv_mode->hblank_end;
> >  	ysize = intel_tv_mode_vdisplay(tv_mode);
> >  
> >  	xpos = conn_state->tv.margins.left;
> > -	ypos = conn_state->tv.margins.top;
> > +	ypos = tv_conn_state->margins.top;
> >  	xsize -= (conn_state->tv.margins.left +
> >  		  conn_state->tv.margins.right);
> > -	ysize -= (conn_state->tv.margins.top +
> > -		  conn_state->tv.margins.bottom);
> > +	ysize -= (tv_conn_state->margins.top +
> > +		  tv_conn_state->margins.bottom);
> >  	I915_WRITE(TV_WIN_POS, (xpos<<16)|ypos);
> >  	I915_WRITE(TV_WIN_SIZE, (xsize<<16)|ysize);
> >  
> > @@ -1701,7 +1785,7 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = {
> >  	.destroy = intel_connector_destroy,
> >  	.fill_modes = drm_helper_probe_single_connector_modes,
> >  	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> > -	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> > +	.atomic_duplicate_state = intel_tv_connector_duplicate_state,
> >  };
> >  
> >  static int intel_tv_atomic_check(struct drm_connector *connector,
> > -- 
> > 2.18.1
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-01-23 16:38 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-12 16:59 [PATCH 00/15] drm/i915: Fix TV encoder support Ville Syrjala
2018-11-12 16:59 ` [PATCH 01/15] drm/vblank: Allow dynamic per-crtc max_vblank_count Ville Syrjala
2018-11-21  9:27   ` Daniel Vetter
2018-11-21 11:37     ` Ville Syrjälä
2018-11-21 15:19       ` Daniel Vetter
2018-11-21 16:16         ` Ville Syrjälä
2018-11-21 16:22           ` Daniel Vetter
2018-11-21 16:46             ` Ville Syrjälä
2018-11-22  8:53               ` Daniel Vetter
2018-11-27 18:20   ` [PATCH v2 " Ville Syrjala
2018-11-27 19:42     ` Daniel Vetter
2018-11-12 16:59 ` [PATCH 02/15] drm/i915: Don't try to use the hardware frame counter with i965gm TV output Ville Syrjala
2018-11-27 18:21   ` [PATCH v2 " Ville Syrjala
2018-11-27 20:05   ` [PATCH v3 " Ville Syrjala
2019-01-22 12:51     ` Imre Deak
2018-11-12 16:59 ` [PATCH 03/15] drm/i915/tv: Fix interlaced ysize calculation Ville Syrjala
2019-01-22 12:54   ` Imre Deak
2018-11-12 16:59 ` [PATCH 04/15] drm/i915/tv: Fix tv mode clocks Ville Syrjala
2019-01-22 12:56   ` Imre Deak
2018-11-12 16:59 ` [PATCH 05/15] drm/i915/tv: Store the TV oversampling factor in the TV mode Ville Syrjala
2019-01-22 13:03   ` Imre Deak
2018-11-12 16:59 ` [PATCH 06/15] drm/i915/tv: Use bools where appropriate Ville Syrjala
2019-01-22 13:07   ` Imre Deak
2018-11-12 16:59 ` [PATCH 07/15] drm/i915/tv: Nuke silly 0 initialzation of xpos/ypos Ville Syrjala
2019-01-22 13:09   ` Imre Deak
2018-11-12 16:59 ` [PATCH 07/15] drm/i915/tv: Nuke silly 0 inittialization " Ville Syrjala
2018-11-12 16:59 ` [PATCH 08/15] drm/i915/tv: Deobfuscate preferred mode selection Ville Syrjala
2019-01-22 14:43   ` [Intel-gfx] " Imre Deak
2018-11-12 16:59 ` [PATCH 09/15] drm/i915/tv: Use drm_mode_set_name() to name TV modes Ville Syrjala
2019-01-22 14:45   ` Imre Deak
2018-11-12 16:59 ` [PATCH 10/15] drm/i915/tv: Make TV mode autoselection actually useable Ville Syrjala
2019-01-22 14:54   ` Imre Deak
2018-11-12 16:59 ` [PATCH 11/15] drm/i915/tv: Nuke reported_modes[] Ville Syrjala
2019-01-22 15:08   ` Imre Deak
2018-11-12 16:59 ` [PATCH 12/15] drm/i915/tv: Add 1080p30/50/60 TV modes Ville Syrjala
2019-01-22 15:09   ` [Intel-gfx] " Imre Deak
2018-11-12 16:59 ` [PATCH 13/15] drm/i915/tv: Generate better pipe timings for TV encoder Ville Syrjala
2019-01-22 17:22   ` Imre Deak
2019-01-22 17:34     ` Ville Syrjälä
2019-01-23 10:30       ` Imre Deak
2018-11-12 16:59 ` [PATCH 14/15] drm/i915/tv: Fix >1024 modes on gen3 Ville Syrjala
2019-01-23 13:49   ` Imre Deak
2019-01-23 16:38     ` Ville Syrjälä [this message]
2019-01-24 10:40       ` Imre Deak
2019-01-25 18:11     ` [Intel-gfx] " Ville Syrjälä
2018-11-12 17:00 ` [PATCH 15/15] drm/i915/tv: Filter out >1024 wide modes that would need vertical scaling " Ville Syrjala
2019-01-23 13:49   ` Imre Deak

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=20190123163817.GC20097@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.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