dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sebastian Reichel <sebastian.reichel@collabora.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 24/29] drm/omap: Factor out common mode validation code
Date: Mon, 10 Dec 2018 10:27:05 +0200	[thread overview]
Message-ID: <2794318.Kr71UN0F2L@avalon> (raw)
In-Reply-To: <20181209221922.l2dvvxckv62zwwvm@earth.universe>

Hi Sebastian,

On Monday, 10 December 2018 00:19:22 EET Sebastian Reichel wrote:
> Hi,
> 
> On Wed, Dec 05, 2018 at 05:00:17PM +0200, Laurent Pinchart wrote:
> > The encoder .atomic_check() and connector .mode_valid() operations both
> > walk through the dss devices in the pipeline to validate the mode.
> > Factor out the common code in a new omap_drm_connector_mode_fixup()
> > function.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> 
> This is a bit tricky to review. It would probably be easier to
> review, if the changes were split into two commits:
> 
> 1. introduce common function
> 2. move drm_display_mode/videomode conversion further up the stack

I agree that the connector changes are not very nicely formatted. I however 
don't like splitting patches, especially when small, in such a way.

One issue preventing a better diff formatting is the change from int to enum 
drm_mode_status for the omap_connector_mode_valid() function. Without that 
change, the patch can be better formatted with

git diff --anchored="static int omap_connector_mode_valid"

I agree it's still not perfect.

If you think the above change is worth it I'll submit a split version, 
otherwise I'll leave it as is.

> Anyways:
> 
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> 
> -- Sebastian
> 
> >  drivers/gpu/drm/omapdrm/omap_connector.c | 55 +++++++++++++-----------
> >  drivers/gpu/drm/omapdrm/omap_connector.h |  5 +++
> >  drivers/gpu/drm/omapdrm/omap_encoder.c   | 30 ++++---------
> >  3 files changed, 45 insertions(+), 45 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c
> > b/drivers/gpu/drm/omapdrm/omap_connector.c index
> > dd1e0f2e8ffc..9882a4b1402b 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_connector.c
> > +++ b/drivers/gpu/drm/omapdrm/omap_connector.c
> > @@ -241,50 +241,57 @@ static int omap_connector_get_modes(struct
> > drm_connector *connector)> 
> >  	return 0;
> >  
> >  }
> > 
> > -static int omap_connector_mode_valid(struct drm_connector *connector,
> > -				 struct drm_display_mode *mode)
> > +enum drm_mode_status omap_connector_mode_fixup(struct omap_dss_device
> > *dssdev, +					const struct drm_display_mode *mode,
> > +					struct drm_display_mode *adjusted_mode)
> > 
> >  {
> > 
> > -	struct omap_connector *omap_connector = to_omap_connector(connector);
> > -	struct omap_dss_device *dssdev;
> > -	struct videomode vm = {0};
> > -	struct drm_device *dev = connector->dev;
> > -	struct drm_display_mode *new_mode;
> > -	int r, ret = MODE_BAD;
> > +	struct videomode vm = { 0 };
> > +	int ret;
> > 
> >  	drm_display_mode_to_videomode(mode, &vm);
> > 
> > -	mode->vrefresh = drm_mode_vrefresh(mode);
> > 
> > -	for (dssdev = omap_connector->output; dssdev; dssdev = dssdev->next) {
> > +	for (; dssdev; dssdev = dssdev->next) {
> > 
> >  		if (!dssdev->ops->check_timings)
> >  		
> >  			continue;
> > 
> > -		r = dssdev->ops->check_timings(dssdev, &vm);
> > -		if (r)
> > -			goto done;
> > +		ret = dssdev->ops->check_timings(dssdev, &vm);
> > +		if (ret)
> > +			return MODE_BAD;
> > 
> >  	}
> > 
> > -	/* check if vrefresh is still valid */
> > -	new_mode = drm_mode_duplicate(dev, mode);
> > -	if (!new_mode)
> > -		return MODE_BAD;
> > +	if (adjusted_mode)
> > +		drm_display_mode_from_videomode(&vm, adjusted_mode);
> > 
> > -	new_mode->clock = vm.pixelclock / 1000;
> > -	new_mode->vrefresh = 0;
> > -	if (mode->vrefresh == drm_mode_vrefresh(new_mode))
> > -		ret = MODE_OK;
> > -	drm_mode_destroy(dev, new_mode);
> > +	return MODE_OK;
> > +}
> > +
> > +static enum drm_mode_status omap_connector_mode_valid(struct
> > drm_connector *connector, +				 struct drm_display_mode *mode)
> > +{
> > +	struct omap_connector *omap_connector = to_omap_connector(connector);
> > +	struct drm_display_mode new_mode = { { 0 } };
> > +	enum drm_mode_status status;
> > +
> > +	status = omap_connector_mode_fixup(omap_connector->output, mode,
> > +					   &new_mode);
> > +	if (status != MODE_OK)
> > +		goto done;
> > +
> > +	/* Check if vrefresh is still valid. */
> > +	if (drm_mode_vrefresh(mode) != drm_mode_vrefresh(&new_mode))
> > +		status = MODE_NOCLOCK;
> > 
> >  done:
> >  	DBG("connector: mode %s: "
> >  	
> >  			"%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
> > 
> > -			(ret == MODE_OK) ? "valid" : "invalid",
> > +			(status == MODE_OK) ? "valid" : "invalid",
> > 
> >  			mode->base.id, mode->name, mode->vrefresh, mode->clock,
> >  			mode->hdisplay, mode->hsync_start,
> >  			mode->hsync_end, mode->htotal,
> >  			mode->vdisplay, mode->vsync_start,
> >  			mode->vsync_end, mode->vtotal, mode->type, mode->flags);
> > 
> > -	return ret;
> > +	return status;
> > 
> >  }
> >  
> >  static const struct drm_connector_funcs omap_connector_funcs = {
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/omap_connector.h
> > b/drivers/gpu/drm/omapdrm/omap_connector.h index
> > 4a1dcd0f031b..6b7d4d95e32b 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_connector.h
> > +++ b/drivers/gpu/drm/omapdrm/omap_connector.h
> > @@ -22,6 +22,8 @@
> > 
> >  #include <linux/types.h>
> > 
> > +enum drm_mode_status;
> > +
> > 
> >  struct drm_connector;
> >  struct drm_device;
> >  struct drm_encoder;
> > 
> > @@ -34,5 +36,8 @@ struct drm_connector *omap_connector_init(struct
> > drm_device *dev,> 
> >  bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
> >  void omap_connector_enable_hpd(struct drm_connector *connector);
> >  void omap_connector_disable_hpd(struct drm_connector *connector);
> > 
> > +enum drm_mode_status omap_connector_mode_fixup(struct omap_dss_device
> > *dssdev, +					const struct drm_display_mode *mode,
> > +					struct drm_display_mode *adjusted_mode);
> > 
> >  #endif /* __OMAPDRM_CONNECTOR_H__ */
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c
> > b/drivers/gpu/drm/omapdrm/omap_encoder.c index 7d01df6fa723..086963088201
> > 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_encoder.c
> > +++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
> > @@ -198,29 +198,17 @@ static int omap_encoder_atomic_check(struct
> > drm_encoder *encoder,> 
> >  				     struct drm_connector_state *conn_state)
> >  
> >  {
> >  
> >  	struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
> > 
> > -	struct drm_device *dev = encoder->dev;
> > -	struct omap_dss_device *dssdev;
> > -	struct videomode vm = { 0 };
> > -	int ret;
> > -
> > -	drm_display_mode_to_videomode(&crtc_state->mode, &vm);
> > -
> > -	for (dssdev = omap_encoder->output; dssdev; dssdev = dssdev->next) {
> > -		if (!dssdev->ops->check_timings)
> > -			continue;
> > -
> > -		ret = dssdev->ops->check_timings(dssdev, &vm);
> > -		if (ret)
> > -			goto done;
> > +	enum drm_mode_status status;
> > +
> > +	status = omap_connector_mode_fixup(omap_encoder->output,
> > +					   &crtc_state->mode,
> > +					   &crtc_state->adjusted_mode);
> > +	if (status != MODE_OK) {
> > +		dev_err(encoder->dev->dev, "invalid timings: %d\n", status);
> > +		return -EINVAL;
> > 
> >  	}
> > 
> > -	drm_display_mode_from_videomode(&vm, &crtc_state->adjusted_mode);
> > -
> > -done:
> > -	if (ret)
> > -		dev_err(dev->dev, "invalid timings: %d\n", ret);
> > -
> > -	return ret;
> > +	return 0;
> > 
> >  }
> >  
> >  static const struct drm_encoder_helper_funcs omap_encoder_helper_funcs =
> >  {


-- 
Regards,

Laurent Pinchart



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

  reply	other threads:[~2018-12-10  8:26 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05 14:59 [PATCH 00/29] omapdrm: Last large refactoring for drm_bridge transition Laurent Pinchart
2018-12-05 14:59 ` [PATCH 01/29] drm/omap: Remove declaration of nonexisting function Laurent Pinchart
2018-12-09 21:44   ` Sebastian Reichel
2018-12-05 14:59 ` [PATCH 02/29] drm/omap: Remove unused kobj field from struct omap_dss_device Laurent Pinchart
2018-12-09 21:44   ` Sebastian Reichel
2018-12-05 14:59 ` [PATCH 03/29] drm/omap: venc: Remove wss_data field from venc_device structure Laurent Pinchart
2018-12-09 21:45   ` Sebastian Reichel
2018-12-05 14:59 ` [PATCH 04/29] drm/omap: Use atomic suspend/resume helpers Laurent Pinchart
2018-12-09 21:53   ` Sebastian Reichel
2018-12-10  6:49     ` Laurent Pinchart
2018-12-10  8:01       ` [PATCH v1.1 " Laurent Pinchart
2018-12-10 13:08         ` Sebastian Reichel
2018-12-05 14:59 ` [PATCH 05/29] drm/omap: Move common display enable/disable code to encoder Laurent Pinchart
2018-12-09 21:53   ` Sebastian Reichel
2018-12-05 14:59 ` [PATCH 06/29] drm/omap: Remove connection checks from internal encoders .enable() Laurent Pinchart
2018-12-09 21:54   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 07/29] drm/omap: Remove connection checks from display .enable() and .remove() Laurent Pinchart
2018-12-09 21:54   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 08/29] drm/omap: Remove enable " Laurent Pinchart
2018-12-09 21:55   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 09/29] drm/omap: Reverse direction of the DSS device enable/disable operations Laurent Pinchart
2018-12-09 21:59   ` Sebastian Reichel
2018-12-10  1:01   ` [PATCH v1.1 " Laurent Pinchart
2018-12-05 15:00 ` [PATCH 10/29] drm/omap: Remove omap_dss_device dst field Laurent Pinchart
2018-12-09 22:00   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 11/29] drm/omap: Factor out common init/cleanup code for output devices Laurent Pinchart
2018-12-09 22:01   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 12/29] drm/omap: Expose DRM modes instead of timings in display devices Laurent Pinchart
2018-12-09 22:02   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 13/29] drm/omap: Merge display .get_modes() and .get_size() operations Laurent Pinchart
2018-12-09 22:02   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 14/29] drm/omap: Add a dss device operation flag for .get_modes() Laurent Pinchart
2018-12-09 22:02   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 15/29] drm/omap: venc: List both PAL and NTSC modes Laurent Pinchart
2018-12-09 22:03   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 16/29] drm/omap: Don't pass display pointer to encoder init function Laurent Pinchart
2018-12-09 22:03   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 17/29] drm/omap: Move display alias ID to omap_drm_pipeline Laurent Pinchart
2018-12-09 22:03   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 18/29] drm/omap: Don't store display pointer in omap_connector structure Laurent Pinchart
2018-12-09 22:04   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 19/29] drm/omap: panel-dsi-cm: Store source pointer internally Laurent Pinchart
2018-12-09 22:04   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 20/29] drm/omap: Notify all devices in the pipeline of output disconnection Laurent Pinchart
2018-12-09 22:04   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 21/29] drm/omap: Remove src field from omap_dss_device structure Laurent Pinchart
2018-12-09 22:04   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 22/29] drm/omap: Move DISPC timing checks to CRTC .mode_valid() operation Laurent Pinchart
2018-12-09 22:07   ` Sebastian Reichel
2018-12-10  7:50     ` Laurent Pinchart
2018-12-10 13:14       ` Sebastian Reichel
2018-12-11  1:07         ` Sebastian Reichel
2018-12-11  8:06           ` Laurent Pinchart
2019-02-11 20:30             ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 23/29] drm/omap: venc: Simplify mode setting by caching configuration Laurent Pinchart
2018-12-09 22:08   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 24/29] drm/omap: Factor out common mode validation code Laurent Pinchart
2018-12-09 22:19   ` Sebastian Reichel
2018-12-10  8:27     ` Laurent Pinchart [this message]
2018-12-10 13:16       ` Sebastian Reichel
2018-12-10  8:27     ` [PATCH] " Laurent Pinchart
2018-12-05 15:00 ` [PATCH 25/29] drm/omap: Pass drm_display_mode to .check_timings() and .set_timings() Laurent Pinchart
2018-12-09 22:26   ` Sebastian Reichel
2018-12-10  8:07     ` Laurent Pinchart
2018-12-05 15:00 ` [PATCH 26/29] drm/omap: venc: Use drm_display_mode natively Laurent Pinchart
2018-12-06 16:23   ` [PATCH v1.1 " Laurent Pinchart
2018-12-09 22:27     ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 27/29] drm/omap: Store pixel clock instead of full mode in DPI and SDI encoders Laurent Pinchart
2018-12-09 22:27   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 28/29] drm/omap: Simplify OF lookup of DSS devices Laurent Pinchart
2018-12-09 22:27   ` Sebastian Reichel
2018-12-05 15:00 ` [PATCH 29/29] drm/omap: Refactor initialization sequence Laurent Pinchart
2018-12-09 22:27   ` Sebastian Reichel
2018-12-10 12:28 ` [PATCH 30/29] drm/omap: Merge omap_dss_device type and output_type fields Laurent Pinchart
2018-12-10 13:20   ` Sebastian Reichel

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=2794318.Kr71UN0F2L@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=tomi.valkeinen@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox