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=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY 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 26436C2D0C1 for ; Thu, 19 Dec 2019 11:56:20 +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 058C9222C2 for ; Thu, 19 Dec 2019 11:56:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 058C9222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75BD86E2E0; Thu, 19 Dec 2019 11:56:19 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id CEA1D6E2E0 for ; Thu, 19 Dec 2019 11:56:18 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2019 03:56:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,331,1571727600"; d="scan'208";a="210438733" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by orsmga008.jf.intel.com with ESMTP; 19 Dec 2019 03:56:15 -0800 Received: from irsmsx111.ger.corp.intel.com (10.108.20.4) by irsmsx110.ger.corp.intel.com (163.33.3.25) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 19 Dec 2019 11:56:02 +0000 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.130]) by irsmsx111.ger.corp.intel.com ([169.254.2.126]) with mapi id 14.03.0439.000; Thu, 19 Dec 2019 11:56:02 +0000 From: "Kahola, Mika" To: "intel-gfx@lists.freedesktop.org" , "Deak, Imre" Thread-Topic: [Intel-gfx] [PATCH 05/15] drm/i915: Add helpers to select correct ccs/aux planes Thread-Index: AQHVtb3Zfgmg3N3Bm0qs7QzGMrDD/6fBWxWA Date: Thu, 19 Dec 2019 11:56:02 +0000 Message-ID: References: <20191218161105.30638-1-imre.deak@intel.com> <20191218161105.30638-6-imre.deak@intel.com> In-Reply-To: <20191218161105.30638-6-imre.deak@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.237.72.159] Content-ID: MIME-Version: 1.0 Subject: Re: [Intel-gfx] [PATCH 05/15] drm/i915: Add helpers to select correct ccs/aux planes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Pandiyan, Dhinakaran" Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Wed, 2019-12-18 at 18:10 +0200, Imre Deak wrote: > Using helpers instead of open coding this to select a CCS plane for a > main plane makes the code cleaner and less error-prone when the > location > of CCS plane can be different based on the format (packed vs. YUV > semiplanar). The same applies to selecting an AUX plane which can be > a > UV plane (for an uncompressed YUV semiplanar format), or a CCS plane. > = > Cc: Dhinakaran Pandiyan > Cc: Ville Syrj=E4l=E4 > Signed-off-by: Imre Deak Reviewed-by: Mika Kahola > --- > drivers/gpu/drm/i915/display/intel_display.c | 63 ++++++++++++++++ > ---- > 1 file changed, 50 insertions(+), 13 deletions(-) > = > diff --git a/drivers/gpu/drm/i915/display/intel_display.c > b/drivers/gpu/drm/i915/display/intel_display.c > index 4b8b44c39724..6bda397ae677 100644 > --- a/drivers/gpu/drm/i915/display/intel_display.c > +++ b/drivers/gpu/drm/i915/display/intel_display.c > @@ -1933,6 +1933,40 @@ static unsigned int intel_tile_size(const > struct drm_i915_private *dev_priv) > return IS_GEN(dev_priv, 2) ? 2048 : 4096; > } > = > +static bool is_ccs_plane(const struct drm_framebuffer *fb, int > plane) > +{ > + if (!is_ccs_modifier(fb->modifier)) > + return false; > + > + return plane >=3D fb->format->num_planes / 2; > +} > + > +static bool is_aux_plane(const struct drm_framebuffer *fb, int > plane) > +{ > + if (is_ccs_modifier(fb->modifier)) > + return is_ccs_plane(fb, plane); > + > + return plane =3D=3D 1; > +} > + > +static int main_to_ccs_plane(const struct drm_framebuffer *fb, int > main_plane) > +{ > + WARN_ON(!is_ccs_modifier(fb->modifier) || > + (main_plane && main_plane >=3D fb->format->num_planes / > 2)); > + > + return fb->format->num_planes / 2 + main_plane; > +} > + > +/* Return either the main plane's CCS or - if not a CCS FB - UV > plane */ > +static int > +intel_main_to_aux_plane(const struct drm_framebuffer *fb, int > main_plane) > +{ > + if (is_ccs_modifier(fb->modifier)) > + return main_to_ccs_plane(fb, main_plane); > + > + return 1; > +} > + > static unsigned int > intel_tile_width_bytes(const struct drm_framebuffer *fb, int > color_plane) > { > @@ -1948,7 +1982,7 @@ intel_tile_width_bytes(const struct > drm_framebuffer *fb, int color_plane) > else > return 512; > case I915_FORMAT_MOD_Y_TILED_CCS: > - if (color_plane =3D=3D 1) > + if (is_ccs_plane(fb, color_plane)) > return 128; > /* fall through */ > case I915_FORMAT_MOD_Y_TILED: > @@ -1957,7 +1991,7 @@ intel_tile_width_bytes(const struct > drm_framebuffer *fb, int color_plane) > else > return 512; > case I915_FORMAT_MOD_Yf_TILED_CCS: > - if (color_plane =3D=3D 1) > + if (is_ccs_plane(fb, color_plane)) > return 128; > /* fall through */ > case I915_FORMAT_MOD_Yf_TILED: > @@ -2074,7 +2108,7 @@ static unsigned int intel_surf_alignment(const > struct drm_framebuffer *fb, > struct drm_i915_private *dev_priv =3D to_i915(fb->dev); > = > /* AUX_DIST needs only 4K alignment */ > - if (color_plane =3D=3D 1) > + if (is_aux_plane(fb, color_plane)) > return 4096; > = > switch (fb->modifier) { > @@ -3457,10 +3491,11 @@ static bool > skl_check_main_ccs_coordinates(struct intel_plane_state *plane_state > const struct drm_framebuffer *fb =3D plane_state->hw.fb; > int hsub =3D fb->format->hsub; > int vsub =3D fb->format->vsub; > - int aux_x =3D plane_state->color_plane[1].x; > - int aux_y =3D plane_state->color_plane[1].y; > - u32 aux_offset =3D plane_state->color_plane[1].offset; > - u32 alignment =3D intel_surf_alignment(fb, 1); > + int ccs_plane =3D main_to_ccs_plane(fb, 0); > + int aux_x =3D plane_state->color_plane[ccs_plane].x; > + int aux_y =3D plane_state->color_plane[ccs_plane].y; > + u32 aux_offset =3D plane_state->color_plane[ccs_plane].offset; > + u32 alignment =3D intel_surf_alignment(fb, ccs_plane); > = > while (aux_offset >=3D main_offset && aux_y <=3D main_y) { > int x, y; > @@ -3473,7 +3508,7 @@ static bool > skl_check_main_ccs_coordinates(struct intel_plane_state *plane_state > = > x =3D aux_x / hsub; > y =3D aux_y / vsub; > - aux_offset =3D intel_plane_adjust_aligned_offset(&x, &y, > plane_state, 1, > + aux_offset =3D intel_plane_adjust_aligned_offset(&x, &y, > plane_state, ccs_plane, > aux_offs > et, aux_offset - alignment); > aux_x =3D x * hsub + aux_x % hsub; > aux_y =3D y * vsub + aux_y % vsub; > @@ -3482,9 +3517,9 @@ static bool > skl_check_main_ccs_coordinates(struct intel_plane_state *plane_state > if (aux_x !=3D main_x || aux_y !=3D main_y) > return false; > = > - plane_state->color_plane[1].offset =3D aux_offset; > - plane_state->color_plane[1].x =3D aux_x; > - plane_state->color_plane[1].y =3D aux_y; > + plane_state->color_plane[ccs_plane].offset =3D aux_offset; > + plane_state->color_plane[ccs_plane].x =3D aux_x; > + plane_state->color_plane[ccs_plane].y =3D aux_y; > = > return true; > } > @@ -3500,7 +3535,8 @@ static int skl_check_main_surface(struct > intel_plane_state *plane_state) > int h =3D drm_rect_height(&plane_state->uapi.src) >> 16; > int max_width; > int max_height; > - u32 alignment, offset, aux_offset =3D plane_state- > >color_plane[1].offset; > + int aux_plane =3D intel_main_to_aux_plane(fb, 0); > + u32 alignment, offset, aux_offset =3D plane_state- > >color_plane[aux_plane].offset; > = > if (INTEL_GEN(dev_priv) >=3D 11) > max_width =3D icl_max_plane_width(fb, 0, rotation); > @@ -3566,7 +3602,8 @@ static int skl_check_main_surface(struct > intel_plane_state *plane_state) > offs > et, offset - alignment); > } > = > - if (x !=3D plane_state->color_plane[1].x || y !=3D > plane_state->color_plane[1].y) { > + if (x !=3D plane_state->color_plane[aux_plane].x || > + y !=3D plane_state->color_plane[aux_plane].y) { > DRM_DEBUG_KMS("Unable to find suitable display > surface offset due to CCS\n"); > return -EINVAL; > } _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx