[PATCH v2] drm/modes: Apply video parameters with only reflect option

Stephan Gerhold stephan at gerhold.net
Mon Dec 16 18:08:11 UTC 2019


On Mon, Dec 16, 2019 at 07:27:25PM +0200, Ville Syrjälä wrote:
> On Mon, Dec 16, 2019 at 06:10:17PM +0100, Stephan Gerhold wrote:
> > At the moment, video mode parameters like video=540x960,reflect_x,
> > (without rotation set) are not taken into account when applying the
> > mode in drm_client_modeset.c.
> 
> A rotation value without exactly one rotation angle is illegal.
> IMO the code should not generate a value like that in the first
> place.
> 

You're right. I was thinking about this when creating this patch.
But then I was not sure if "mode->rotation_reflection" is supposed to be
a valid rotation value.The zero value is currently used to check
if any rotation/reflection was specified at all:

[...]
> > diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
> > index 895b73f23079..cfebce4f19a5 100644
> > --- a/drivers/gpu/drm/drm_client_modeset.c
> > +++ b/drivers/gpu/drm/drm_client_modeset.c
> > @@ -859,19 +859,23 @@ bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation)
> >  	 */
> >  	cmdline = &connector->cmdline_mode;
> >  	if (cmdline->specified && cmdline->rotation_reflection) {

I can try to make your suggested change in the cmdline parsing code,
but since this sounds like a larger change I would appreciate
some other opinions first.

Thanks,
Stephan

> > 
> > -		unsigned int cmdline_rest, panel_rest;
> > -		unsigned int cmdline_rot, panel_rot;
> > -		unsigned int sum_rot, sum_rest;
> > +		if (cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK) {
> > +			unsigned int cmdline_rest, panel_rest;
> > +			unsigned int cmdline_rot, panel_rot;
> > +			unsigned int sum_rot, sum_rest;
> >  
> > -		panel_rot = ilog2(*rotation & DRM_MODE_ROTATE_MASK);
> > -		cmdline_rot = ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK);
> > -		sum_rot = (panel_rot + cmdline_rot) % 4;
> > +			panel_rot = ilog2(*rotation & DRM_MODE_ROTATE_MASK);
> > +			cmdline_rot = ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK);
> > +			sum_rot = (panel_rot + cmdline_rot) % 4;
> >  
> > -		panel_rest = *rotation & ~DRM_MODE_ROTATE_MASK;
> > -		cmdline_rest = cmdline->rotation_reflection & ~DRM_MODE_ROTATE_MASK;
> > -		sum_rest = panel_rest ^ cmdline_rest;
> > +			panel_rest = *rotation & ~DRM_MODE_ROTATE_MASK;
> > +			cmdline_rest = cmdline->rotation_reflection & ~DRM_MODE_ROTATE_MASK;
> > +			sum_rest = panel_rest ^ cmdline_rest;
> >  
> > -		*rotation = (1 << sum_rot) | sum_rest;
> > +			*rotation = (1 << sum_rot) | sum_rest;
> > +		} else {
> > +			*rotation ^= cmdline->rotation_reflection;
> > +		}
> >  	}
> >  
> >  	/*
> > @@ -879,7 +883,8 @@ bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation)
> >  	 * depending on the hardware this may require the framebuffer
> >  	 * to be in a specific tiling format.
> >  	 */
> > -	if ((*rotation & DRM_MODE_ROTATE_MASK) != DRM_MODE_ROTATE_180 ||
> > +	if (((*rotation & DRM_MODE_ROTATE_MASK) != DRM_MODE_ROTATE_0 &&
> > +	     (*rotation & DRM_MODE_ROTATE_MASK) != DRM_MODE_ROTATE_180) ||
> >  	    !plane->rotation_property)
> >  		return false;
> >  
> > -- 
> > 2.24.1
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Ville Syrjälä
> Intel


More information about the dri-devel mailing list