From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACE7BC43603 for ; Mon, 16 Dec 2019 17:27:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 894A2206E0 for ; Mon, 16 Dec 2019 17:27:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 894A2206E0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C9F4A6E842; Mon, 16 Dec 2019 17:27:30 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 795B26E842 for ; Mon, 16 Dec 2019 17:27:29 +0000 (UTC) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Dec 2019 09:27:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,322,1571727600"; d="scan'208";a="221541460" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga001.fm.intel.com with SMTP; 16 Dec 2019 09:27:26 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 16 Dec 2019 19:27:25 +0200 Date: Mon, 16 Dec 2019 19:27:25 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Stephan Gerhold Subject: Re: [PATCH v2] drm/modes: Apply video parameters with only reflect option Message-ID: <20191216172725.GZ1208@intel.com> References: <20191216171017.173326-1-stephan@gerhold.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191216171017.173326-1-stephan@gerhold.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, Dec 16, 2019 at 06:10:17PM +0100, Stephan Gerhold wrote: > At the moment, video mode parameters like video=3D540x960,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. > = > One of the reasons for this is that the calculation that > combines the panel_orientation with cmdline->rotation_reflection > does not handle the case when cmdline->rotation_reflection does > not have any rotation set. > (i.e. cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK =3D=3D 0) > = > Example: > *rotation =3D DRM_MODE_ROTATE_0 (no panel_orientation) > cmdline->rotation_reflection =3D DRM_MODE_REFLECT_X (video=3DMODE,refle= ct_x) > = > The current code does: > panel_rot =3D ilog2(*rotation & DRM_MODE_ROTATE_MASK); > cmdline_rot =3D ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_MA= SK); > sum_rot =3D (panel_rot + cmdline_rot) % 4; > = > and therefore: > panel_rot =3D ilog2(DRM_MODE_ROTATE_0) =3D ilog2(1) =3D 0 > cmdline_rot =3D ilog2(0) =3D -1 > sum_rot =3D (0 + -1) % 4 =3D -1 % 4 =3D 3 > ... > *rotation =3D DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X > = > So we incorrectly generate DRM_MODE_ROTATE_270 in this case. > To prevent cmdline_rot from becoming -1, we need to treat > the rotation as DRM_MODE_ROTATE_0. > = > On the other hand, there is no need to go through that calculation > at all if no rotation is set in rotation_reflection. > A simple XOR is enough to combine the reflections. > = > Finally, also allow DRM_MODE_ROTATE_0 in the if statement below. > DRM_MODE_ROTATE_0 means "no rotation" and should therefore not > require any special handling (e.g. specific tiling format). > = > This makes video parameters with only reflect option work correctly. > = > Signed-off-by: Stephan Gerhold > --- > v1: https://lists.freedesktop.org/archives/dri-devel/2019-December/248145= .html > = > Changes in v2: > - Clarified commit message - parameters are parsed correctly, > but not taken into account when applying the mode. > --- > drivers/gpu/drm/drm_client_modeset.c | 27 ++++++++++++++++----------- > 1 file changed, 16 insertions(+), 11 deletions(-) > = > diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_c= lient_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 *modes= et, unsigned int *rotation) > */ > cmdline =3D &connector->cmdline_mode; > if (cmdline->specified && cmdline->rotation_reflection) { > - 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 =3D ilog2(*rotation & DRM_MODE_ROTATE_MASK); > - cmdline_rot =3D ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_M= ASK); > - sum_rot =3D (panel_rot + cmdline_rot) % 4; > + panel_rot =3D ilog2(*rotation & DRM_MODE_ROTATE_MASK); > + cmdline_rot =3D ilog2(cmdline->rotation_reflection & DRM_MODE_ROTATE_= MASK); > + sum_rot =3D (panel_rot + cmdline_rot) % 4; > = > - panel_rest =3D *rotation & ~DRM_MODE_ROTATE_MASK; > - cmdline_rest =3D cmdline->rotation_reflection & ~DRM_MODE_ROTATE_MASK; > - sum_rest =3D panel_rest ^ cmdline_rest; > + panel_rest =3D *rotation & ~DRM_MODE_ROTATE_MASK; > + cmdline_rest =3D cmdline->rotation_reflection & ~DRM_MODE_ROTATE_MASK; > + sum_rest =3D panel_rest ^ cmdline_rest; > = > - *rotation =3D (1 << sum_rot) | sum_rest; > + *rotation =3D (1 << sum_rot) | sum_rest; > + } else { > + *rotation ^=3D 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) !=3D DRM_MODE_ROTATE_180 || > + if (((*rotation & DRM_MODE_ROTATE_MASK) !=3D DRM_MODE_ROTATE_0 && > + (*rotation & DRM_MODE_ROTATE_MASK) !=3D DRM_MODE_ROTATE_180) || > !plane->rotation_property) > return false; > = > -- = > 2.24.1 > = > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- = Ville Syrj=E4l=E4 Intel _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel