From patchwork Fri Aug 17 17:33:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayan Halder X-Patchwork-Id: 10569263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8864F1390 for ; Fri, 17 Aug 2018 17:33:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 796F32BE2B for ; Fri, 17 Aug 2018 17:33:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68E382BE2E; Fri, 17 Aug 2018 17:33:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1206A2BE2B for ; Fri, 17 Aug 2018 17:33:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3088C6E67B; Fri, 17 Aug 2018 17:33:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40073.outbound.protection.outlook.com [40.107.4.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 31CA96E67B for ; Fri, 17 Aug 2018 17:33:24 +0000 (UTC) Received: from e113505-lin.cambridge.arm.com (217.140.106.49) by AM5PR0801MB1378.eurprd08.prod.outlook.com (2603:10a6:203:1f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.19; Fri, 17 Aug 2018 17:33:21 +0000 From: Ayan Kumar Halder To: ayan.halder@arm.com, liviu.dudau@arm.com, brian.starkey@arm.com, gustavo@padovan.org, maarten.lankhorst@linux.intel.com, seanpaul@chromium.org, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm: Use horizontal and vertical chroma subsampling factor while calculating offsets in the physical address of framebuffer Date: Fri, 17 Aug 2018 18:33:04 +0100 Message-Id: <1534527184-24552-1-git-send-email-ayan.halder@arm.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: PR0P264CA0021.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100::33) To AM5PR0801MB1378.eurprd08.prod.outlook.com (2603:10a6:203:1f::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f5343fd-4c4e-4f55-e07d-08d60467871b X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM5PR0801MB1378; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1378; 3:LHT0iu4f0DFe4ui31tEiB39F3BHSUMCd1K08x/oYauG8LAw5obfHShtPt2SYpvYLdzjIcqRpu13dip1zcNPVUsHyN8acI5FgIM3SwuL4/gTSrIf3/NT+5P68JoPO0eo8YRIkV35ErP65D5qqkxTsdu4Tb7CMLvTwtjuR/xQGJRatYwV7Ee4cdn+6OjWVFO/BkGi+QPqx5eL1b4wZNCjpCi6iwHVFGSmJdxxOFGLdZ8wBBTy8F//8gGQAA0kn0hsE; 25:dlEyKYDZyK0FFzF7PO5wLgpMPcXv+sm9U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muU+Omy6Fn+ZXRCQg1z3TUKq7aogOd/fyD9HztT7hBywYhBkrZqZBJbfxUgMWuntnSQ3cS0KszhMftENicGhx3waVZnM6Np+tJVSO3+iBPt5q0zgn0I5qaMjBe6khWjyNjr6MN/myK3n1HkBvUdjCzCxKYsXWQWH0kb69BjVkgA0FrN5Xs+EAFNoLl1JcC2q+JBBmYyJz3nmbB8wT1kA79Tdlr/5B+vJ4ULDeE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301064)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699016); SRVR:AM5PR0801MB1378; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB1378; X-Forefront-PRVS: 076777155F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(396003)(366004)(39860400002)(136003)(376002)(189003)(199004)(25786009)(476003)(486006)(6666003)(2616005)(81166006)(956004)(316002)(16586007)(53936002)(6486002)(47776003)(8936002)(68736007)(8676002)(386003)(52116002)(16526019)(26005)(51416003)(7696005)(4326008)(1857600001)(2906002)(7736002)(305945005)(36756003)(575784001)(86362001)(81156014)(478600001)(72206003)(97736004)(105586002)(106356001)(48376002)(50466002)(3846002)(6116002)(5660300001)(66066001)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0801MB1378; H:e113505-lin.cambridge.arm.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0801MB1378; 23:hakeitnnuRC0r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gRCSYerXnI+BSihnRW52LgoLpt/zQS/bguZU=; 7:Hz9YXMsmdCMqnuD/bv/2ow6QxlidWoTZT67L2RP8fvoMrXZ6kpf8p23JkeeLzJJluu8BjfAVIWR3WSQN5xQPmSj5egdkpk+40k+ZE+ox5FJmFfcj6XQzmotWplR2+kqbvx5mDu40Y8eKfHvhw3QfcyhcVvLm7FklxikjitI4zArh7ccr4yruEGFl6B+pOqidK5Vh9qZacj4RyLE9YKFR98G9TlLucP2eYbwURHysxc2iLxmTv2JFBqobUp4lPsje SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2018 17:33:21.1655 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f5343fd-4c4e-4f55-e07d-08d60467871b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1378 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP For multi-planar formats, while calculating offsets in planes with index greater than 0 (ie second plane, third plane, etc), one needs to divide (src_x * cpp) with horizontal chroma subsampling factor and (src_y * pitch) with vertical chroma subsampling factor. The reason being that the planes contain subsampled (ie reduced) data (by a factor of 2) and thus the while calculating the byte position coresponding to the x and y co-ordinates, one needs to be divide it with the sampling factor. Signed-off-by: Ayan Kumar halder Reviewed-by: Liviu Dudau --- drivers/gpu/drm/drm_fb_cma_helper.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index b127061..47e0e2f 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -86,14 +86,21 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb, { struct drm_gem_cma_object *obj; dma_addr_t paddr; + u8 h_div = 1, v_div = 1; obj = drm_fb_cma_get_gem_obj(fb, plane); if (!obj) return 0; paddr = obj->paddr + fb->offsets[plane]; - paddr += fb->format->cpp[plane] * (state->src_x >> 16); - paddr += fb->pitches[plane] * (state->src_y >> 16); + + if (plane > 0) { + h_div = fb->format->hsub; + v_div = fb->format->vsub; + } + + paddr += (fb->format->cpp[plane] * (state->src_x >> 16)) / h_div; + paddr += (fb->pitches[plane] * (state->src_y >> 16)) / v_div; return paddr; }