Received: by 10.213.65.68 with SMTP id h4csp1684406imn; Thu, 5 Apr 2018 01:51:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx48EK4FQGFJbXkWl4HFnd5rJfZx8SQ/6a1Bq7Tc920z4MdlPMYD7QgeFd4yrhlM53L2simsU X-Received: by 2002:a17:902:3225:: with SMTP id y34-v6mr22757401plb.180.1522918267054; Thu, 05 Apr 2018 01:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522918267; cv=none; d=google.com; s=arc-20160816; b=hROadQkjIHDKwTPZ2cVA3ppnvrTqayoj6GILm97Xjqv/zUPFK05FpIo947qnGDVzo2 6pE6hir17nKoKJUMbf4fTskWiclEjMdCbjnCVWG4eAPk3i/bB+pkMxe6L/5aWWIsEhRH a8cJ2uoTyPaY8wZUO3nHKn3JNInBX0k1sA3uhcUGFfiRrsrud47h3iZgAkiS/uMiGBLq cdzguqbQUn5Fk9oVUA5vD1G70Ayv/2OMWLLEWML+RHfNrGweKdeu4//ig2eFTMrJaQzN /mAZ//WEggMsG3ipYYvw5ixkQH3Mg4JsWDl8gWXgIovKpwpIHcQMk/osGSyfbjy8Jahf GZjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature:arc-authentication-results; bh=CzcqVKeyjukmAU6O2D0ErkgpqMxr8e5jtooVNAmelDc=; b=0OqvtxdjfJuwp4jhfTI2XwEMh8CnUlRmGeA86Ay2UYwTi6Hr+5oYAQd0lXRLmf0sBq KdISi048lWEE3qJsKo0NMrWPhWyAiITjAUw5omc2ORyTvzmWBSejJcZM7vD3teTULiw6 P26AOI/PGj71u0xcCj7qM9tpekXpZkQBrhcoSdF6hSJDtaG5+Y735TX84syMw7pjpFvH DNDs3BFmrMHSyZ+jeCujawkpovqmlhZcD7flxPpQ37L4RgdGK7FWIpHBP4azMugyUjrw E9HtCMfDQwuF1lyaAdI5u1vKH7WtNL/ddE/YuqRhwBvDfwyfmBDqqP7tg1tPeeRXhMW/ ad5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@onevmw.onmicrosoft.com header.s=selector1-vmware-com header.b=Pvk1kIvG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z73si5096421pgz.559.2018.04.05.01.50.52; Thu, 05 Apr 2018 01:51:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@onevmw.onmicrosoft.com header.s=selector1-vmware-com header.b=Pvk1kIvG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751332AbeDEIth (ORCPT + 99 others); Thu, 5 Apr 2018 04:49:37 -0400 Received: from mail-by2nam03on0084.outbound.protection.outlook.com ([104.47.42.84]:60576 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751097AbeDEItd (ORCPT ); Thu, 5 Apr 2018 04:49:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onevmw.onmicrosoft.com; s=selector1-vmware-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=CzcqVKeyjukmAU6O2D0ErkgpqMxr8e5jtooVNAmelDc=; b=Pvk1kIvGN2TUBFnoQEJSrp6WXRFQ4ThpR6euBxpz1zc8qsBuk4exwTRu8mi4gpbHuge5bzbOx9aP5pbLrrlForgDyIMqs8TLPI4N2MvHBLOZAUHqeaP/wgylEZHL5i7X7xdxv8p0YsENfTdFnvmrq74di2sF09Qd0+H+AgAREbo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; Received: from localhost.localdomain (155.4.205.56) by CO2PR05MB763.namprd05.prod.outlook.com (10.141.227.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.675.3; Thu, 5 Apr 2018 08:49:24 +0000 Subject: Re: [RFC 2/3] drm: Add helper iterator functions to iterate over plane damage. To: Deepak Rawat , dri-devel@lists.freedesktop.org, syeh@vmware.com, linux-graphics-maintainer@vmware.com, ville.syrjala@linux.intel.com, lukasz.spintzyk@displaylink.com, noralf@tronnes.org, robdclark@gmail.com, gustavo@padovan.org, maarten.lankhorst@linux.intel.com, seanpaul@chromium.org, airlied@linux.ie, linux-kernel@vger.kernel.org References: <1522885748-67122-1-git-send-email-drawat@vmware.com> <1522885748-67122-3-git-send-email-drawat@vmware.com> <20180405075205.GQ3881@phenom.ffwll.local> From: Thomas Hellstrom Message-ID: <0edfe662-6463-a143-e00a-d3d4bc06a229@vmware.com> Date: Thu, 5 Apr 2018 10:49:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180405075205.GQ3881@phenom.ffwll.local> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [155.4.205.56] X-ClientProxiedBy: CWXP265CA0027.GBRP265.PROD.OUTLOOK.COM (10.166.154.143) To CO2PR05MB763.namprd05.prod.outlook.com (10.141.227.15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6ae8ced9-e2de-49da-0c81-08d59ad22388 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:CO2PR05MB763; X-Microsoft-Exchange-Diagnostics: 1;CO2PR05MB763;3:u1ZhEWY2CdTYLvizYSUTRI5ChX4Isno52eMKTw+p3K8gB/bGo/1UlFRHSpjW7G1NYscYQ1G3P/wdIFiDCPHiuYVT2WCa37fm1BQGHvILPuzDVku1oY41hMzG1bQVUUNxQZQ1xQrYtBYuR/hTkQn5yZPrLn7rGGttTYUg/WNrXMfUTEFLrcaDPI3C7aS2L7FWJdXTTXB821A2cMbsq1Oom9C8Vg5beHF5Aj431iebbismItNaAasxgET7civVtRuO;25:ZuxdRSACKp6LTA6t946xsI0zM4mDhXyzcaAQsL8SPGOP/e0335i32LpBmWuUowGXFBY5GKS9eQnPHxpJSstE5SYE0yvzFmf/S1P7I6s4ZPIoDdzhwhjSYwivcyVWthMM903zsIjkbZdGXSVGfa1KdTNd67GlADoMJcfvi1L1rXTfRnRdXkaMhYaJ5RtMvGwNbz4zxzu1PgNwVLJb8ZM/61C8pbj3YRjxXxtKDVKBfal39sLEdtG6DBi2ijBvkJbLbNrvcheo+D2b210z/beLRim/xQ4oQbySsrMVqFHXwRxWWBYHxsf+hOmBb1zcXpZfjjiOsg65bvwMl9L/Ax3u4A==;31:1LF2Dj2P7Hl3v6wUvxs/waPM1j06UX4Cbw//1BAUnevp4OYdNVq7485TL4UYh2lWFHC29sK2n8j4KRGtHE9wetCkhye+W/vKuo7gDQGHxJwAgeGT891vR7/muXW5ft1jXJKWoKJWU8ACfRGk739OZ7EY2hO5OUrW9QT0QqgoSFP55HToRnIPkMZ9IrehvjPdRslwC58KDynZwxL+vnf2KFZ9WZx6mpWPgh4rPBxWMkI= X-MS-TrafficTypeDiagnostic: CO2PR05MB763: X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;CO2PR05MB763;20:3V76FArvLAr2dNi0YO0Fbw1211D80f7j0XrGbVP0316gNXYm8qUobf+eHkBN8ZICBQBYumC825dzEvZEpOgjdZPZstZ6EfUfbRVlvBXQvc5md1Ya+TT06liByvkHaCmnW09ZEy6Am3zZiM177+AkMxOzObYQ53/nMem1L74N/QIvxlgxkobOMvMDcc8yVJuBOU/nzjelX+KVcyzvc7GleRRGJ7l04OcjsK2kYTAka7J65Up8mUciXJoXkBWURlER+lI/mQObZjnag+QgrINi7K9hZSRVWGAiJH/IQURUrPe1MarczFmODdbfFiP/N95N/VicT5VG528+Tp+DH4i5TEvLUvNZlj+cZ2oKbUagJ5u/qXHzEiG2w57ljUhswf+2dZB4l/KGz1HfqWxzERsnUxSD/8WzuPpaHf2GUBZ7J7hBIbS82nPG5WAgWDMUbCflo9GcxTV3W8gqv/DQ/5kHbsfjZATvWvKKGx1YGLqoU8m+rRdu7vDKwUufq+1fY49A;4:fQHdMWDRVOMqu3k7ZnYDlPhue0L5nqq+HRl6RUkxwZ5VAxclCPTLphtsVxLTBXt/R14dpnG0cEDmoeHDmP796iHow7ibxp9LIZ/mk0IiAa7GjsGkwTFRWAaqzofCvtmTsZRzk9NbH2RN/0KVAEuOjfeaYL7ym/idad3CdjqF64BrF/Lo7uD+6OPdNL2uOMujtyEFd/SXXphroVQflm2tSg5wnqmtqQFrt8vd/2lwGXdb+JuuHJGoysK2enlr4+xnVP6a1mWbClQ/Y2F1yOhoRmODXZDq1Yh3ZiK5ZSJ3YN9f/BnEqF/ltfzyxpnjj1xj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:CO2PR05MB763;BCL:0;PCL:0;RULEID:;SRVR:CO2PR05MB763; X-Forefront-PRVS: 06339BAE63 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(366004)(346002)(376002)(396003)(39860400002)(39380400002)(189003)(199004)(6666003)(47776003)(229853002)(31686004)(230700001)(65956001)(65806001)(66066001)(36756003)(186003)(97736004)(31696002)(478600001)(39060400002)(486006)(316002)(26005)(2616005)(956004)(11346002)(446003)(7520500002)(68736007)(58126008)(476003)(105586002)(2906002)(16526019)(3846002)(6116002)(65826007)(8936002)(6512007)(50466002)(67846002)(7416002)(5660300001)(6486002)(86362001)(52146003)(64126003)(2486003)(386003)(76176011)(23676004)(81156014)(305945005)(53546011)(81166006)(6506007)(7736002)(53936002)(59450400001)(8676002)(25786009)(106356001)(6246003)(52116002)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR05MB763;H:localhost.localdomain;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDTzJQUjA1TUI3NjM7MjM6bHRpaWVFNDl6ZTg2OVhOd1ZwS0M1YjU3cjNN?= =?utf-8?B?VkU1VTRZTDFVYXpzL2ZXL3FUUStwTTNhZE9sc3hCUWdubjNDSEJiUnJDNTY1?= =?utf-8?B?K1BpTjdFR3o5d2JkTExoK0ZHVXFMVUFIbjhXK0xSRGVjREVoaUl6UlNxaGVn?= =?utf-8?B?TTR2aU8wT1d6OHZvc3VyQ0djSXk0N1N4NzYvUEN4MXNIbkwrb0N0QmloV0tu?= =?utf-8?B?YWltOFhKUm0yZGZkNllnNDRYaTQrSVZsclpiYWlVTEJmNmJ4VWl1SzA3a2Rs?= =?utf-8?B?VlJZN1hKZi8waUtqa0pTbG9HTWtielVaUzd3am5Pck55TzlYaDhEVTNaa2tn?= =?utf-8?B?aU9JQm5xKzk2Y0xlNFMwZWxyVUhkbU1vUjY5ekF3djBwZXhB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8VQIbLsv9Ey4Sf6B2UgT7Vk/ywBK7EFPgwVf7376qSRahetLA0BPJHqYTnLCnf213A/dGpPS0h0DajgQHS/xGBVN1hO1d8gEed65wz052pF8qNgPOtSAkOV6n;20:k7Ne/1ZapM1lrKWitDjaQ8WUXjRMOf4hp2WMlhnIQOMfX07aht+nRcIhuMt2oEfhl64A9dACGJvnad1y3TptmrRy54Q6OrgNo27mMPTdRgS94ppQt3LmPy8nBStMC3cAFHpeIzECk/peskLe+DDjPdvCo9nq9TTyalN7UW8tsvk= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2018 08:49:24.5169 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ae8ced9-e2de-49da-0c81-08d59ad22388 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR05MB763 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/05/2018 09:52 AM, Daniel Vetter wrote: > On Wed, Apr 04, 2018 at 04:49:07PM -0700, Deepak Rawat wrote: >> With damage property in drm_plane_state, this patch adds helper iterator >> to traverse the damage clips. Iterator will return the damage rectangles >> in framebuffer, plane or crtc coordinates as need by driver >> implementation. >> >> Signed-off-by: Deepak Rawat > I'd really like selftest/unittests for this stuff. There's an awful lot of > cornercases in this here (for any of the transformed iterators at least), > and unit tests is the best way to make sure we handle them all correctly. > > Bonus points if you integrate the new selftests into igt so intel CI can > run them, seel igt/tests/drm_mm.c for an example. drm_mm selftest is also > the framework I'd copy for this stuff. > >> --- >> drivers/gpu/drm/drm_atomic_helper.c | 122 ++++++++++++++++++++++++++++++++++++ >> include/drm/drm_atomic_helper.h | 39 ++++++++++++ >> 2 files changed, 161 insertions(+) >> >> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c >> index 55b44e3..355b514 100644 >> --- a/drivers/gpu/drm/drm_atomic_helper.c >> +++ b/drivers/gpu/drm/drm_atomic_helper.c >> @@ -3865,3 +3865,125 @@ void __drm_atomic_helper_private_obj_duplicate_state(struct drm_private_obj *obj >> memcpy(state, obj->state, sizeof(*state)); >> } >> EXPORT_SYMBOL(__drm_atomic_helper_private_obj_duplicate_state); >> + >> +/** >> + * drm_atomic_helper_damage_iter_init - initialize the damage iterator >> + * @iter: The iterator to initialize. >> + * @type: Coordinate type caller is interested in. >> + * @state: plane_state from which to iterate the damage clips. >> + * @hdisplay: Width of crtc on which plane is scanned out. >> + * @vdisplay: Height of crtc on which plane is scanned out. >> + * >> + * Initialize an iterator that is used to translate and clip a set of damage >> + * rectangles in framebuffer coordinates to plane and crtc coordinates. The type >> + * argument specify which type of coordinate to iterate in. >> + * >> + * Returns: 0 on success and negative error code on error. If an error code is >> + * returned then it means the plane state should not update. >> + */ >> +int >> +drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, >> + enum drm_atomic_helper_damage_clip_type type, >> + const struct drm_plane_state *state, >> + uint32_t hdisplay, uint32_t vdisplay) >> +{ >> + if (!state || !state->crtc || !state->fb) >> + return -EINVAL; >> + >> + memset(iter, 0, sizeof(*iter)); >> + iter->clips = (struct drm_rect *)state->damage_clips->data; >> + iter->num_clips = state->num_clips; >> + iter->type = type; >> + >> + /* >> + * Full update in case of scaling or rotation. In future support for >> + * scaling/rotating damage clips can be added >> + */ >> + if (state->crtc_w != (state->src_w >> 16) || >> + state->crtc_h != state->src_h >> 16 || state->rotation != 0) { >> + iter->curr_clip = iter->num_clips; >> + return 0; > Given there's no user of this I have no idea how this manages to provoke a > full clip rect. selftest code would be perfect for stuff like this. > > Also, I think we should provide a full clip for the case of num_clips == > 0, so that driver code can simply iterate over all clips and doesn't ever > have to handle the "no clip rects provided" case as a special case itself. > >> + } >> + >> + iter->fb_src.x1 = 0; >> + iter->fb_src.y1 = 0; >> + iter->fb_src.x2 = state->fb->width; >> + iter->fb_src.y2 = state->fb->height; >> + >> + iter->plane_src.x1 = state->src_x >> 16; >> + iter->plane_src.y1 = state->src_y >> 16; >> + iter->plane_src.x2 = iter->plane_src.x1 + (state->src_w >> 16); >> + iter->plane_src.y2 = iter->plane_src.y1 + (state->src_h >> 16); >> + iter->translate_plane_x = -iter->plane_src.x1; >> + iter->translate_plane_y = -iter->plane_src.y1; >> + >> + /* Clip plane src rect to fb dimensions */ >> + drm_rect_intersect(&iter->plane_src, &iter->fb_src); > This smells like driver bug. Also, see Ville's recent efforts to improve > the atomic plane clipping, I think drm_plane_state already has all the > clip rects you want. > >> + >> + iter->crtc_src.x1 = 0; >> + iter->crtc_src.y1 = 0; >> + iter->crtc_src.x2 = hdisplay; >> + iter->crtc_src.y2 = vdisplay; >> + iter->translate_crtc_x = -(iter->plane_src.x1 - state->crtc_x); >> + iter->translate_crtc_x = -(iter->plane_src.y1 - state->crtc_y); >> + >> + /* Clip crtc src rect to plane dimensions */ >> + drm_rect_translate(&iter->crtc_src, -iter->translate_crtc_x, >> + -iter->translate_crtc_x); > We can also scale. I suggest we leave out scaling for now until someone actually needs it. > >> + drm_rect_intersect(&iter->crtc_src, &iter->plane_src); >> + >> + return 0; >> +} >> +EXPORT_SYMBOL(drm_atomic_helper_damage_iter_init); >> + >> +/** >> + * drm_atomic_helper_damage_iter_next - advance the damage iterator >> + * @iter: The iterator to advance. >> + * @rect: Return a rectangle in coordinate specified during iterator init. >> + * >> + * Returns: true if the output is valid, false if we've reached the end of the >> + * rectangle list. If the first call return false, means need full update. >> + */ >> +bool >> +drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter, >> + struct drm_rect *rect) >> +{ >> + const struct drm_rect *curr_clip; >> + >> +next_clip: >> + if (iter->curr_clip >= iter->num_clips) >> + return false; >> + >> + curr_clip = &iter->clips[iter->curr_clip]; >> + iter->curr_clip++; >> + >> + rect->x1 = curr_clip->x1; >> + rect->x2 = curr_clip->x2; >> + rect->y1 = curr_clip->y1; >> + rect->y2 = curr_clip->y2; >> + >> + /* Clip damage rect within fb limit */ >> + if (!drm_rect_intersect(rect, &iter->fb_src)) >> + goto next_clip; >> + else if (iter->type & DRM_ATOMIC_HELPER_DAMAGE_CLIP_TYPE_FB) >> + return true; >> + >> + /* Clip damage rect within plane limit */ >> + if (!drm_rect_intersect(rect, &iter->plane_src)) >> + goto next_clip; >> + else if (iter->type & DRM_ATOMIC_HELPER_DAMAGE_CLIP_TYPE_PLANE) { >> + drm_rect_translate(rect, iter->translate_plane_x, >> + iter->translate_plane_y); >> + return true; >> + } >> + >> + /* Clip damage rect within crtc limit */ >> + if (!drm_rect_intersect(rect, &iter->crtc_src)) >> + goto next_clip; >> + >> + drm_rect_translate(rect, iter->translate_crtc_x, >> + iter->translate_crtc_y); >> + >> + return true; >> +} >> +EXPORT_SYMBOL(drm_atomic_helper_damage_iter_next); >> diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h >> index 26aaba5..ebd4b66 100644 >> --- a/include/drm/drm_atomic_helper.h >> +++ b/include/drm/drm_atomic_helper.h >> @@ -36,6 +36,37 @@ struct drm_atomic_state; >> struct drm_private_obj; >> struct drm_private_state; >> >> +/** >> + * enum drm_atomic_helper_damage_clip_type - type of clips to iterator over >> + * >> + * While using drm_atomic_helper_damage_iter the type of clip coordinates caller >> + * is interested in. >> + */ >> +enum drm_atomic_helper_damage_clip_type { >> + DRM_ATOMIC_HELPER_DAMAGE_CLIP_TYPE_FB = 0x0, >> + DRM_ATOMIC_HELPER_DAMAGE_CLIP_TYPE_PLANE = 0x1, >> + DRM_ATOMIC_HELPER_DAMAGE_CLIP_TYPE_CRTC = 0x2, > I'm confused with what exactly these different types of iterators are > supposed to achieve. TYPE_FB makes sense, that's what vmwgfx and other > virtual drivers need to figure out which parts of a buffer to upload to > the host. > > TYPE_PLANE I have no idea who needs that. I suggest we just drop it. > > TYPE_CRTC is what I'd want to use for manual upload hw, were instead of > compositing the entire screen we can limit the uploaded area to 1 or 2 > rectangles (depending upon how the hw works). But those drivers want all > the crtc clip rects for _all_ the planes combined, not for each plane > individually. > > My suggestion is to drop TYPE_CRTC until someone needs it for a driver. > And most likely the only iterator we want for TYPE_CRTC is one that gives > you the overall damage area, including alpha/ctm/gamma/everything else, > coalesced into just 1 clip rect. So probably an entirely different > function. Actually for vmwgfx, the display part of the hardware comes in different versions and we'd typically expect both the FB coordinates and the CRTC coordinates. In the latest version the surface backing the screen needs to exactly fit the CRTC scanout area, and if the FB doesn't do that, we need to create a surface that does and copy in the kernel driver. After that, as a second step, we need to notify the display system of the damaged area in CRTC coordinates. > Summarizing all this, I'd simplify the iterator to: > > drm_atomic_helper_damage_iter_init(iter, plane_state); > > And leave the other 2 use-cases to the next patch series. For crtc damage > we probably want: > > drm_atomic_helper_crtc_damage(drm_atomic_state, rect) > > Which internally loops over all planes and also takes all the other state > changes into account. That way you also don't have to fix the scaling > issue, since your current code only handles translation. > > Another bit: drm_atomic_helper.c is huge, I'd vote to put all this stuff > into a new drm_damage_helper.[hc], including new section in drm-kms.rst > and all that. Splitting up drm_atomic_helper.[hc] is somewhere on my todo > ... > > Cheers, Daniel /Thomas