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=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT 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 5C863C4741C for ; Fri, 13 Dec 2019 21:24:58 +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 C909524681 for ; Fri, 13 Dec 2019 21:24:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C909524681 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.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 EB9276EA6E; Fri, 13 Dec 2019 15:59:33 +0000 (UTC) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED5CC6E9B2 for ; Fri, 13 Dec 2019 15:59:25 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 028AD292C92 From: Andrzej Pietrasiewicz To: dri-devel@lists.freedesktop.org Subject: [PATCHv4 13/36] drm/komeda: Provide and use komeda_fb_get_pixel_addr variant not requiring a fb Date: Fri, 13 Dec 2019 16:58:44 +0100 Message-Id: <20191213155907.16581-14-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191213155907.16581-1-andrzej.p@collabora.com> References: <20191213155907.16581-1-andrzej.p@collabora.com> 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: Ayan Halder , kernel@collabora.com, David Airlie , Liviu Dudau , Sandy Huang , Andrzej Pietrasiewicz , James Wang , Mihail Atanassov , Sean Paul MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a variant of the function which doesn't need neither struct drm_framebuffer nor container_of it. Maintain current interface for existing users. Signed-off-by: Andrzej Pietrasiewicz --- .../arm/display/komeda/komeda_framebuffer.c | 68 +++++++++++++++---- .../arm/display/komeda/komeda_framebuffer.h | 7 ++ 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c index 4fa01b2e3f1c..00860a66ebf1 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c @@ -124,7 +124,12 @@ komeda_fb_none_afbc_size_check(struct komeda_dev *mdev, return -EINVAL; } - min_size = komeda_fb_get_pixel_addr(kfb, 0, fb->height, i) + min_size = komeda_fb_get_pixel_addr_nofb(info, + mode_cmd->modifier[0], + mode_cmd->pitches, + mode_cmd->offsets, + obj, + 0, mode_cmd->height, i) - to_drm_gem_cma_obj(obj)->paddr; if (obj->size < min_size) { DRM_DEBUG_KMS("The fb->obj[%d] size: 0x%zx lower than the minimum requirement: 0x%llx.\n", @@ -238,12 +243,56 @@ int komeda_fb_check_src_coords(const struct komeda_fb *kfb, return 0; } +dma_addr_t +komeda_fb_get_pixel_addr_impl(const struct drm_format_info *format, + u64 modifier, + const unsigned int *pitches, + const unsigned int *offsets, + const struct drm_gem_cma_object *obj, + int x, int y, int plane) +{ + u32 offset, plane_x, plane_y, block_w, block_sz; + + offset = offsets[plane]; + if (modifier) { + block_w = drm_format_info_block_width(format, plane); + block_sz = format->char_per_block[plane]; + plane_x = x / (plane ? format->hsub : 1); + plane_y = y / (plane ? format->vsub : 1); + + offset += (plane_x / block_w) * block_sz + + plane_y * pitches[plane]; + } + + return obj->paddr + offset; +} + +dma_addr_t +komeda_fb_get_pixel_addr_nofb(const struct drm_format_info *format, + u64 modifier, + const unsigned int *pitches, + const unsigned int *offsets, + struct drm_gem_object *obj, + int x, int y, int plane) +{ + const struct drm_gem_cma_object *cma_obj; + + if (plane >= format->num_planes) { + DRM_DEBUG_KMS("Out of max plane num.\n"); + return -EINVAL; + } + + cma_obj = to_drm_gem_cma_obj(obj); + + return komeda_fb_get_pixel_addr_impl(format, modifier, pitches, offsets, + cma_obj, x, y, plane); +} + dma_addr_t komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane) { struct drm_framebuffer *fb = &kfb->base; const struct drm_gem_cma_object *obj; - u32 offset, plane_x, plane_y, block_w, block_sz; if (plane >= fb->format->num_planes) { DRM_DEBUG_KMS("Out of max plane num.\n"); @@ -252,18 +301,9 @@ komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane) obj = drm_fb_cma_get_gem_obj(fb, plane); - offset = fb->offsets[plane]; - if (!fb->modifier) { - block_w = drm_format_info_block_width(fb->format, plane); - block_sz = fb->format->char_per_block[plane]; - plane_x = x / (plane ? fb->format->hsub : 1); - plane_y = y / (plane ? fb->format->vsub : 1); - - offset += (plane_x / block_w) * block_sz - + plane_y * fb->pitches[plane]; - } - - return obj->paddr + offset; + return komeda_fb_get_pixel_addr_impl(fb->format, fb->modifier, + fb->pitches, fb->offsets, + obj, x, y, plane); } /* if the fb can be supported by a specific layer */ diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h index c61ca98a3a63..2f1f421d3e7f 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h +++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h @@ -42,6 +42,13 @@ int komeda_fb_check_src_coords(const struct komeda_fb *kfb, u32 src_x, u32 src_y, u32 src_w, u32 src_h); dma_addr_t komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane); +dma_addr_t +komeda_fb_get_pixel_addr_nofb(const struct drm_format_info *format, + u64 modifier, + const unsigned int *pitches, + const unsigned int *offsets, + struct drm_gem_object *obj, + int x, int y, int plane); bool komeda_fb_is_layer_supported(struct komeda_fb *kfb, u32 layer_type, u32 rot); -- 2.17.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel