Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp937282pxb; Mon, 25 Oct 2021 22:58:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9BHUvdY3k026iSLxySgpbdHVvsq5bECt9rCzppBrD7+KaxvtszjWDDxdaipCiw7ie1RKi X-Received: by 2002:a17:90b:1646:: with SMTP id il6mr25419532pjb.129.1635227924779; Mon, 25 Oct 2021 22:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635227924; cv=none; d=google.com; s=arc-20160816; b=j2eqfFIGTKWKFOrTMnALu48GBsbi2bte2Lt4twmja9yENMXgRv9/pF+P6ZjkchOZVa BPMYed2SL6Bp+HZpRLIVdAp4eaMDA4Mrzjc3LZEDn8z18H1EF8qxJghr6YzdHdVFZJ6+ r+io7AFp2UtLcu3OwPlWiTl9srfOtr/+T0bWrfuJEv2gxvRmFOIENwrxPIg0vaZ7tfGY sOGCVo/N//2DFtaEnTD0qtV/7lUXa1FQsIUnQHlkrCofohyMDPr3tGv1MOR78o1sIB2V K5uQ0BqGK3uPf36t6yGf0SdACU0oZPdyJS7tgqg9RvrUP4NdoJt/IC+1tkbY67L6pSKh Le0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=10z83rn1dQLyIYsIkVAoxSDw4ZTZcNGKVFgCWqQpaRI=; b=fYgjN3+VyLkbJY3KcWeChTseU7pkMGO90ShwF5JSdJwvGyKskr/GYplcixCe1QGQU0 3hz+Zde/6rbgGn1HTiBsLJJwKXH2LXjqFhqLz/bK3wWtTIDcjZ2uwXsNv1oczDRI9vNG t3XE6wIva9pVaiZTehj2NvZ4KjeLzAMG+RWL+YERHBCznsHf1BgaAmXpvzjQvhAWYnuK iDdAVczyoGPySbErbNihkHNNWK3bDsAUz117QfcDhZBHYbZPFF2hBqGCSnPpzkbRQuvt E5IU5AUKtC8WCkxdE7TnqyyVat5YyRYlz3CFc+jRl2YJ5BoUmIwMBo1rnBkmSG7zEluI vjig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=O7FUpJ+L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si25389653pll.90.2021.10.25.22.58.32; Mon, 25 Oct 2021 22:58:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=O7FUpJ+L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234576AbhJZBOV (ORCPT + 99 others); Mon, 25 Oct 2021 21:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232827AbhJZBOU (ORCPT ); Mon, 25 Oct 2021 21:14:20 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62D7DC061745 for ; Mon, 25 Oct 2021 18:11:57 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id bm16so756415qkb.11 for ; Mon, 25 Oct 2021 18:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=10z83rn1dQLyIYsIkVAoxSDw4ZTZcNGKVFgCWqQpaRI=; b=O7FUpJ+Lf4ouk0CQSS6+rtrpb05h/csYBf6gBMi8eubWIEhWnUqA2KK+OMs0E5hnyP OJ75tTKAku67GQiKymEqwhHgdANicgK7TGgeRl0hNPvfBSPr2wbtOTHyeXdQlcI+6gYw RS5iVhKU1qq6NGWT+SlV4cuWiasAzrbr4gvXoXT1fYxzFZ3buCfJ+9gjYFyOAE/wmY16 yPZS3+kP60A/CO28QONPKM/1WT2ZuOADXMEBrHoBMepZamFHQu0kEXfYu/qTcDtEnRqW +ia5+lP0mHkpRKx5xZvkTm2zIoMbSXw6Ny6QPbtIeV3Sfbj4SWJ1XP/M2BEKSKpPBm5N aqeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=10z83rn1dQLyIYsIkVAoxSDw4ZTZcNGKVFgCWqQpaRI=; b=hZFtReT22BYUFRRGKahnqJbudYtQMOYi8Cgkv0uXx1GMffB4ezRNvk+zftaSfIi81L EhnpLURVbA9fc8bfr1jDWocmJ8KaCcSdQdj7pLFJyZoJJLZLgOP3A/NjK37DVb/bw4Kl TGK0w2tVMeKRksrSWCvG0ClnsoKNGhPiZXejDQO3tKGGBJUD9M3IbZGihoXVrngwU6DW BP/3bp7ZczhB+9jZOy+BdApmUsIw/FduQVoFqNtea4i4catB0LFgy+ZhavHeQ5VHgdPR mdezXTvVcNJPr5VIz8M6hplzRwl4skCIx6dYcuM7RHdlXgwqwtbm2xKIBP99SEuTW849 mp8w== X-Gm-Message-State: AOAM532CCXvQHH58kWl38Seyv6HaTCTIF25j67lW8+w9zZr3EpL0+n1y 0eGwdSu2v4U9gY24b24YuOCiyw== X-Received: by 2002:a05:620a:f0b:: with SMTP id v11mr16051354qkl.429.1635210716577; Mon, 25 Oct 2021 18:11:56 -0700 (PDT) Received: from localhost ([167.100.64.199]) by smtp.gmail.com with ESMTPSA id 14sm10381079qtp.97.2021.10.25.18.11.55 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Oct 2021 18:11:56 -0700 (PDT) Date: Mon, 25 Oct 2021 21:11:54 -0400 From: Sean Paul To: Mark Yacoub Cc: linux-mediatek@lists.infradead.org, seanpaul@chromium.org, Mark Yacoub , Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/mediatek: Set Rotation default value to 1. Message-ID: <20211026011154.GE2515@art_vandelay> References: <20211022165409.178281-1-markyacoub@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211022165409.178281-1-markyacoub@chromium.org> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 22, 2021 at 12:54:02PM -0400, Mark Yacoub wrote: > From: Mark Yacoub > > [Why] > The Rotation prob is a bitmask value. It must always have a valid value. nit: s/prob/prop/ > A default NO rotation is equal to 1 not 0. > > [How] > 1. At the reset hook, call __drm_atomic_helper_plane_reset which is > called at the initialization of the plane and sets the default value of > all planes to DRM_MODE_ROTATE_0 which is equal to 1. > 2. At the ovl layer check, do no overwrite the state->rotation value 0 > if DRM_MODE_ROTATE_0 is set. We should not change the value that the > userspace has set, especially if it's an unsupported value. nit: I would probably split these into 2 patches since they're related but different Sean > > Tested on Jacuzzi(MTK). > Fixes IGT@kms_properties@plane-properties-{legacy,atomic} and > IGT@kms_properties@get_properties-sanity-{atomic,non-atomic} > > Signed-off-by: Mark Yacoub > --- > drivers/gpu/drm/mediatek/mtk_disp_drv.h | 2 +- > drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 20 +++++++------------- > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 5 ++--- > drivers/gpu/drm/mediatek/mtk_drm_plane.c | 3 ++- > 4 files changed, 12 insertions(+), 18 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/mediatek/mtk_disp_drv.h > index 86c3068894b11..2fc566964f68e 100644 > --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h > +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h > @@ -64,7 +64,7 @@ void mtk_ovl_config(struct device *dev, unsigned int w, > unsigned int h, unsigned int vrefresh, > unsigned int bpc, struct cmdq_pkt *cmdq_pkt); > int mtk_ovl_layer_check(struct device *dev, unsigned int idx, > - struct mtk_plane_state *mtk_state); > + const struct mtk_plane_state *mtk_state); > void mtk_ovl_layer_config(struct device *dev, unsigned int idx, > struct mtk_plane_state *state, > struct cmdq_pkt *cmdq_pkt); > diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c > index ea5760f856ec6..13999564304bc 100644 > --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c > +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c > @@ -190,19 +190,15 @@ unsigned int mtk_ovl_supported_rotations(struct device *dev) > } > > int mtk_ovl_layer_check(struct device *dev, unsigned int idx, > - struct mtk_plane_state *mtk_state) > + const struct mtk_plane_state *mtk_state) > { > - struct drm_plane_state *state = &mtk_state->base; > - unsigned int rotation = 0; > + const struct drm_plane_state *state = &mtk_state->base; > + unsigned int rotation = drm_rotation_simplify( > + state->rotation, > + DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y); > > - rotation = drm_rotation_simplify(state->rotation, > - DRM_MODE_ROTATE_0 | > - DRM_MODE_REFLECT_X | > - DRM_MODE_REFLECT_Y); > - rotation &= ~DRM_MODE_ROTATE_0; > - > - /* We can only do reflection, not rotation */ > - if ((rotation & DRM_MODE_ROTATE_MASK) != 0) > + /* We can only do reflection, not non-zero rotation */ > + if (((rotation & ~DRM_MODE_ROTATE_0) & DRM_MODE_ROTATE_MASK) != 0) > return -EINVAL; > > /* > @@ -212,8 +208,6 @@ int mtk_ovl_layer_check(struct device *dev, unsigned int idx, > if (state->fb->format->is_yuv && rotation != 0) > return -EINVAL; > > - state->rotation = rotation; > - > return 0; > } > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h > index 1b582262b682b..530bdd031933f 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h > +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h > @@ -53,9 +53,8 @@ struct mtk_ddp_comp_funcs { > void (*disable_vblank)(struct device *dev); > unsigned int (*supported_rotations)(struct device *dev); > unsigned int (*layer_nr)(struct device *dev); > - int (*layer_check)(struct device *dev, > - unsigned int idx, > - struct mtk_plane_state *state); > + int (*layer_check)(struct device *dev, unsigned int idx, > + const struct mtk_plane_state *state); > void (*layer_config)(struct device *dev, unsigned int idx, > struct mtk_plane_state *state, > struct cmdq_pkt *cmdq_pkt); > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c > index e6dcb34d30522..accd26481b9fb 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c > @@ -44,9 +44,10 @@ static void mtk_plane_reset(struct drm_plane *plane) > state = kzalloc(sizeof(*state), GFP_KERNEL); > if (!state) > return; > - plane->state = &state->base; > } > > + __drm_atomic_helper_plane_reset(plane, &state->base); > + > state->base.plane = plane; > state->pending.format = DRM_FORMAT_RGB565; > } > -- > 2.33.0.1079.g6e70778dc9-goog > -- Sean Paul, Software Engineer, Google / Chromium OS