All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: eben@raspberrypi.org, David Airlie <airlied@linux.ie>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	dri-devel@lists.freedesktop.org,
	Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Sean Paul <seanpaul@chromium.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Daniel Vetter <daniel.vetter@intel.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 4/5] drm/modes: Parse overscan properties
Date: Mon, 15 Apr 2019 18:45:16 +0200	[thread overview]
Message-ID: <20190415164516.GJ2665@phenom.ffwll.local> (raw)
In-Reply-To: <af8bf60b421190a7c43d90d68cea92c02ebeebce.1554988934.git-series.maxime.ripard@bootlin.com>

On Thu, Apr 11, 2019 at 03:22:42PM +0200, Maxime Ripard wrote:
> Properly configuring the overscan properties might be needed for the
> initial setup of the framebuffer for display that still have overscan.
> Let's allow for more properties on the kernel command line to setup each
> margin.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> ---
>  drivers/gpu/drm/drm_fb_helper.c | 47 ++++++++++++++++++++++++++++++++++-
>  drivers/gpu/drm/drm_modes.c     | 44 ++++++++++++++++++++++++++++++++-
>  include/drm/drm_connector.h     |  1 +-
>  3 files changed, 92 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 8781897559b2..4e403fe1f451 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -2567,6 +2567,51 @@ static void drm_setup_crtc_rotation(struct drm_fb_helper *fb_helper,
>  	fb_helper->sw_rotations |= DRM_MODE_ROTATE_0;
>  }
>  
> +static void drm_setup_connector_margins(struct drm_connector *connector)
> +{
> +	struct drm_cmdline_mode *cmdline = &connector->cmdline_mode;
> +	struct drm_modeset_acquire_ctx ctx;
> +	struct drm_atomic_state *state;
> +	struct drm_device *dev = connector->dev;
> +	int ret;
> +
> +	if (!drm_drv_uses_atomic_modeset(dev))
> +		return;
> +
> +	drm_modeset_acquire_init(&ctx, 0);

You can't do more than one atomic commit, and you need to restore
everything (since userspace might have changed stuff) every time. That's
why all the atomic code goes through restore_fbdev_mode_atomic eventually.
See also how rotation is handled already.

I guess you can omit handling this for non-atomic, since no one cares.

> +
> +	state = drm_atomic_state_alloc(dev);
> +	state->acquire_ctx = &ctx;
> +
> +retry:
> +	drm_atomic_set_property(state, &connector->base,
> +				dev->mode_config.tv_left_margin_property,
> +				cmdline->overscan_left);
> +
> +	drm_atomic_set_property(state, &connector->base,
> +				dev->mode_config.tv_right_margin_property,
> +				cmdline->overscan_right);
> +
> +	drm_atomic_set_property(state, &connector->base,
> +				dev->mode_config.tv_top_margin_property,
> +				cmdline->overscan_top);
> +
> +	drm_atomic_set_property(state, &connector->base,
> +				dev->mode_config.tv_bottom_margin_property,
> +				cmdline->overscan_bottom);
> +
> +	ret = drm_atomic_commit(state);
> +	if (ret == -EDEADLK) {
> +		drm_atomic_state_clear(state);
> +		drm_modeset_backoff(&ctx);
> +		goto retry;
> +	}
> +
> +	drm_atomic_state_put(state);
> +	drm_modeset_drop_locks(&ctx);
> +	drm_modeset_acquire_fini(&ctx);
> +}
> +
>  static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,
>  			    u32 width, u32 height)
>  {
> @@ -2680,6 +2725,8 @@ static void drm_setup_crtcs_fb(struct drm_fb_helper *fb_helper)
>  		struct drm_connector *connector =
>  					fb_helper->connector_info[i]->connector;
>  
> +		drm_setup_connector_margins(connector);
> +
>  		/* use first connected connector for the physical dimensions */
>  		if (connector->status == connector_status_connected) {
>  			info->var.width = connector->display_info.width_mm;
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index ac8d70b92b62..493ba3ccde70 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -1586,6 +1586,50 @@ static int drm_mode_parse_cmdline_options(char *str, size_t len,
>  		} else if (!strncmp(option, "reflect_y", delim - option)) {
>  			rotation |= DRM_MODE_REFLECT_Y;
>  			sep = delim;
> +		} else if (!strncmp(option, "overscan_right", delim - option)) {
> +			const char *value = delim + 1;
> +			unsigned int margin;
> +
> +			margin = simple_strtol(value, &sep, 10);
> +
> +			/* Make sure we have parsed something */
> +			if (sep == value)
> +				return -EINVAL;
> +
> +			mode->overscan_right = margin;
> +		} else if (!strncmp(option, "overscan_left", delim - option)) {
> +			const char *value = delim + 1;
> +			unsigned int margin;
> +
> +			margin = simple_strtol(value, &sep, 10);
> +
> +			/* Make sure we have parsed something */
> +			if (sep == value)
> +				return -EINVAL;
> +
> +			mode->overscan_left = margin;
> +		} else if (!strncmp(option, "overscan_top", delim - option)) {
> +			const char *value = delim + 1;
> +			unsigned int margin;
> +
> +			margin = simple_strtol(value, &sep, 10);
> +
> +			/* Make sure we have parsed something */
> +			if (sep == value)
> +				return -EINVAL;
> +
> +			mode->overscan_top = margin;
> +		} else if (!strncmp(option, "overscan_bottom", delim - option)) {
> +			const char *value = delim + 1;
> +			unsigned int margin;
> +
> +			margin = simple_strtol(value, &sep, 10);
> +
> +			/* Make sure we have parsed something */
> +			if (sep == value)
> +				return -EINVAL;
> +
> +			mode->overscan_bottom = margin;
>  		} else {
>  			return -EINVAL;
>  		}

This will conflict quite a bit with Noralf's series to extract the modeset
code from fb helpers. Cross review might be a good idea.
-Daniel

> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index dfe7f2304b35..44d9885dd401 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -903,6 +903,7 @@ struct drm_cmdline_mode {
>  	int xres, yres;
>  	int bpp;
>  	int refresh;
> +	int overscan_right, overscan_top, overscan_left, overscan_bottom;
>  	bool rb;
>  	bool interlace;
>  	bool cvt;
> -- 
> git-series 0.9.1
> _______________________________________________
> 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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: eben@raspberrypi.org, David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org,
	Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Sean Paul <seanpaul@chromium.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Daniel Vetter <daniel.vetter@intel.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 4/5] drm/modes: Parse overscan properties
Date: Mon, 15 Apr 2019 18:45:16 +0200	[thread overview]
Message-ID: <20190415164516.GJ2665@phenom.ffwll.local> (raw)
In-Reply-To: <af8bf60b421190a7c43d90d68cea92c02ebeebce.1554988934.git-series.maxime.ripard@bootlin.com>

On Thu, Apr 11, 2019 at 03:22:42PM +0200, Maxime Ripard wrote:
> Properly configuring the overscan properties might be needed for the
> initial setup of the framebuffer for display that still have overscan.
> Let's allow for more properties on the kernel command line to setup each
> margin.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> ---
>  drivers/gpu/drm/drm_fb_helper.c | 47 ++++++++++++++++++++++++++++++++++-
>  drivers/gpu/drm/drm_modes.c     | 44 ++++++++++++++++++++++++++++++++-
>  include/drm/drm_connector.h     |  1 +-
>  3 files changed, 92 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 8781897559b2..4e403fe1f451 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -2567,6 +2567,51 @@ static void drm_setup_crtc_rotation(struct drm_fb_helper *fb_helper,
>  	fb_helper->sw_rotations |= DRM_MODE_ROTATE_0;
>  }
>  
> +static void drm_setup_connector_margins(struct drm_connector *connector)
> +{
> +	struct drm_cmdline_mode *cmdline = &connector->cmdline_mode;
> +	struct drm_modeset_acquire_ctx ctx;
> +	struct drm_atomic_state *state;
> +	struct drm_device *dev = connector->dev;
> +	int ret;
> +
> +	if (!drm_drv_uses_atomic_modeset(dev))
> +		return;
> +
> +	drm_modeset_acquire_init(&ctx, 0);

You can't do more than one atomic commit, and you need to restore
everything (since userspace might have changed stuff) every time. That's
why all the atomic code goes through restore_fbdev_mode_atomic eventually.
See also how rotation is handled already.

I guess you can omit handling this for non-atomic, since no one cares.

> +
> +	state = drm_atomic_state_alloc(dev);
> +	state->acquire_ctx = &ctx;
> +
> +retry:
> +	drm_atomic_set_property(state, &connector->base,
> +				dev->mode_config.tv_left_margin_property,
> +				cmdline->overscan_left);
> +
> +	drm_atomic_set_property(state, &connector->base,
> +				dev->mode_config.tv_right_margin_property,
> +				cmdline->overscan_right);
> +
> +	drm_atomic_set_property(state, &connector->base,
> +				dev->mode_config.tv_top_margin_property,
> +				cmdline->overscan_top);
> +
> +	drm_atomic_set_property(state, &connector->base,
> +				dev->mode_config.tv_bottom_margin_property,
> +				cmdline->overscan_bottom);
> +
> +	ret = drm_atomic_commit(state);
> +	if (ret == -EDEADLK) {
> +		drm_atomic_state_clear(state);
> +		drm_modeset_backoff(&ctx);
> +		goto retry;
> +	}
> +
> +	drm_atomic_state_put(state);
> +	drm_modeset_drop_locks(&ctx);
> +	drm_modeset_acquire_fini(&ctx);
> +}
> +
>  static void drm_setup_crtcs(struct drm_fb_helper *fb_helper,
>  			    u32 width, u32 height)
>  {
> @@ -2680,6 +2725,8 @@ static void drm_setup_crtcs_fb(struct drm_fb_helper *fb_helper)
>  		struct drm_connector *connector =
>  					fb_helper->connector_info[i]->connector;
>  
> +		drm_setup_connector_margins(connector);
> +
>  		/* use first connected connector for the physical dimensions */
>  		if (connector->status == connector_status_connected) {
>  			info->var.width = connector->display_info.width_mm;
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index ac8d70b92b62..493ba3ccde70 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -1586,6 +1586,50 @@ static int drm_mode_parse_cmdline_options(char *str, size_t len,
>  		} else if (!strncmp(option, "reflect_y", delim - option)) {
>  			rotation |= DRM_MODE_REFLECT_Y;
>  			sep = delim;
> +		} else if (!strncmp(option, "overscan_right", delim - option)) {
> +			const char *value = delim + 1;
> +			unsigned int margin;
> +
> +			margin = simple_strtol(value, &sep, 10);
> +
> +			/* Make sure we have parsed something */
> +			if (sep == value)
> +				return -EINVAL;
> +
> +			mode->overscan_right = margin;
> +		} else if (!strncmp(option, "overscan_left", delim - option)) {
> +			const char *value = delim + 1;
> +			unsigned int margin;
> +
> +			margin = simple_strtol(value, &sep, 10);
> +
> +			/* Make sure we have parsed something */
> +			if (sep == value)
> +				return -EINVAL;
> +
> +			mode->overscan_left = margin;
> +		} else if (!strncmp(option, "overscan_top", delim - option)) {
> +			const char *value = delim + 1;
> +			unsigned int margin;
> +
> +			margin = simple_strtol(value, &sep, 10);
> +
> +			/* Make sure we have parsed something */
> +			if (sep == value)
> +				return -EINVAL;
> +
> +			mode->overscan_top = margin;
> +		} else if (!strncmp(option, "overscan_bottom", delim - option)) {
> +			const char *value = delim + 1;
> +			unsigned int margin;
> +
> +			margin = simple_strtol(value, &sep, 10);
> +
> +			/* Make sure we have parsed something */
> +			if (sep == value)
> +				return -EINVAL;
> +
> +			mode->overscan_bottom = margin;
>  		} else {
>  			return -EINVAL;
>  		}

This will conflict quite a bit with Noralf's series to extract the modeset
code from fb helpers. Cross review might be a good idea.
-Daniel

> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index dfe7f2304b35..44d9885dd401 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -903,6 +903,7 @@ struct drm_cmdline_mode {
>  	int xres, yres;
>  	int bpp;
>  	int refresh;
> +	int overscan_right, overscan_top, overscan_left, overscan_bottom;
>  	bool rb;
>  	bool interlace;
>  	bool cvt;
> -- 
> git-series 0.9.1
> _______________________________________________
> 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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-04-15 16:45 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 13:22 [PATCH v2 0/5] drm/vc4: Allow for more boot-time configuration Maxime Ripard
2019-04-11 13:22 ` Maxime Ripard
2019-04-11 13:22 ` [PATCH v2 1/5] drm/modes: Rewrite the command line parser Maxime Ripard
2019-04-11 13:22   ` Maxime Ripard
2019-04-12 16:02   ` kbuild test robot
2019-04-12 16:02     ` kbuild test robot
2019-04-11 13:22 ` [PATCH v2 2/5] drm/modes: Support modes names on the command line Maxime Ripard
2019-04-11 13:22   ` Maxime Ripard
2019-04-11 13:22 ` [PATCH v2 3/5] drm/modes: Allow to specify rotation and reflection on the commandline Maxime Ripard
2019-04-11 13:22   ` Maxime Ripard
2019-04-15 16:39   ` Daniel Vetter
2019-04-15 16:39     ` Daniel Vetter
2019-04-16 14:50   ` Noralf Trønnes
2019-04-16 14:50     ` Noralf Trønnes
2019-04-17 14:30     ` Maxime Ripard
2019-04-17 14:30       ` Maxime Ripard
2019-04-17 14:58       ` Noralf Trønnes
2019-04-17 14:58         ` Noralf Trønnes
2019-04-18  7:43         ` Maxime Ripard
2019-04-18  7:43           ` Maxime Ripard
2019-04-11 13:22 ` [PATCH v2 4/5] drm/modes: Parse overscan properties Maxime Ripard
2019-04-11 13:22   ` Maxime Ripard
2019-04-15 16:45   ` Daniel Vetter [this message]
2019-04-15 16:45     ` Daniel Vetter
2019-04-16 14:52   ` Noralf Trønnes
2019-04-16 14:52     ` Noralf Trønnes
2019-04-17 14:07     ` Maxime Ripard
2019-04-17 14:07       ` Maxime Ripard
2019-04-17 15:30       ` Noralf Trønnes
2019-04-17 15:30         ` Noralf Trønnes
2019-04-17 15:38         ` Noralf Trønnes
2019-04-17 15:38           ` Noralf Trønnes
2019-04-11 13:22 ` [PATCH v2 5/5] drm/selftests: Add command line parser selftests Maxime Ripard
2019-04-11 13:22   ` Maxime Ripard
2019-04-12  7:18   ` kbuild test robot
2019-04-12  7:18     ` kbuild test robot
2019-04-12  9:55   ` kbuild test robot
2019-04-12  9:55     ` kbuild test robot

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=20190415164516.GJ2665@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eben@raspberrypi.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=seanpaul@chromium.org \
    --cc=thomas.petazzoni@bootlin.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.