From patchwork Mon Jul 13 11:50:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hunter X-Patchwork-Id: 6778641 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C004A9F380 for ; Mon, 13 Jul 2015 11:51:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C7EEA2067A for ; Mon, 13 Jul 2015 11:51:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 03C5A2065F for ; Mon, 13 Jul 2015 11:51:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D26B6E837; Mon, 13 Jul 2015 04:51:34 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pku.edu.cn (mx13.pku.edu.cn [162.105.129.176]) by gabe.freedesktop.org (Postfix) with ESMTP id E27466E837 for ; Mon, 13 Jul 2015 04:51:32 -0700 (PDT) Received: from localhost.localdomain (unknown [59.108.92.109]) by mailfront04 (Coremail) with SMTP id 9IFpogCHctk+pqNVqdkjAA--.44089S2; Mon, 13 Jul 2015 19:51:26 +0800 (CST) From: John Hunter To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm: add a drm_atomic_helper_plane_check_update Date: Mon, 13 Jul 2015 19:50:42 +0800 Message-Id: <1436788242-19788-1-git-send-email-zhjwpku@gmail.com> X-Mailer: git-send-email 1.7.10.4 X-CM-TRANSID: 9IFpogCHctk+pqNVqdkjAA--.44089S2 X-Coremail-Antispam: 1UD129KBjvJXoW3Xw48tr18Gry8uF1DtFy7Jrb_yoW7Gw18pF ZrCryrKw4Yyan7J3srJw4Ivw43Wa1fC342grykJrnavF15KrZ3u3Z0qry7ur47JrWDKw1f tw12y3s8uw1YkFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUk2b7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI 64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVW8JVWxJw Am72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc2xSY4AK67AK6r4kMxAIw28I cxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2 IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI 42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42 IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E 87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUyManUUUUU X-CM-SenderInfo: p2km411nx6wzxdlohudrp/ Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Zhao Junwang This is the equivalent helper to drm_plane_helper_check_update for legacy drivers, but using atomic state to check things. Motivated by the atomic conversion of the bochs driver. v2: according to Daniel's comment -polish the kerneldoc comment to match the signatures -crtc->mode is legacy state, we need to look at crtc_state instead according to Maarten's comment -there is no need for can_update_disabled in the atomic world, so, we can delete that parameter v3: according to Daniel's comment -this function call can't fail, add a WARN_ON -use drm_atomic_get_existing_crtc_state according to Maarten's comment -kill off the plane parameter and rename state to plane_state -do not handling NULL, i.e. no need to check plane_state in atomic. Cc: Maarten Lankhorst Cc: Daniel Vetter Signed-off-by: Zhao Junwang Reviewed-by: Maarten Lankhorst --- drivers/gpu/drm/drm_atomic_helper.c | 56 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_plane_helper.c | 6 ++++ include/drm/drm_atomic_helper.h | 5 ++++ 3 files changed, 67 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 536ae4d..eaef689 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1336,6 +1336,62 @@ void drm_atomic_helper_swap_state(struct drm_device *dev, EXPORT_SYMBOL(drm_atomic_helper_swap_state); /** + * drm_atomic_helper_plane_check_update + * @plane_state: drm plane state + * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point + * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point + * @can_position: is it legal to position the plane such that it + * doesn't cover the entire crtc? This will generally + * only be false for primary planes. + * + * This provides a helper to be used in a driver's plane atomic_check + * callback. It is the atomic equivalent of + * drm_plane_helper_check_update() and has the exact same semantics, + * except that it looks at the atomic CRTC state in the atomic update + * instead of legacy state directly embedded in struct &drm_crtc. + * + * RETURNS: + * Zero on success, error code on failure + */ +int drm_atomic_helper_plane_check_update(struct drm_plane_state *plane_state, + int min_scale, + int max_scale, + bool can_position, + bool *visible) +{ + struct drm_crtc_state *crtc_state; + crtc_state = drm_atomic_get_existing_crtc_state(plane_state->state, + plane_state->crtc); + if (WARN_ON(IS_ERR(crtc_state))) + return PTR_ERR(crtc_state); + + struct drm_rect src = { + .x1 = plane_state->src_x, + .y1 = plane_state->src_y, + .x2 = plane_state->src_x + plane_state->src_w, + .y2 = plane_state->src_y + plane_state->src_h, + }; + struct drm_rect dest = { + .x1 = plane_state->crtc_x, + .y1 = plane_state->crtc_y, + .x2 = plane_state->crtc_x + plane_state->crtc_w, + .y2 = plane_state->crtc_y + plane_state->crtc_h, + }; + const struct drm_rect clip = { + .x2 = crtc_state->mode.hdisplay, + .y2 = crtc_state->mode.vdisplay, + }; + + return drm_plane_helper_check_update(plane_state->plane, + plane_state->crtc, + plane_state->fb, + &src, &dest, &clip, + min_scale, max_scale, + can_position, true, visible); +} +EXPORT_SYMBOL(drm_atomic_helper_plane_check_update); + +/** * drm_atomic_helper_update_plane - Helper for primary plane update using atomic * @plane: plane object to update * @crtc: owning CRTC of owning plane diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c index 10be2d2..e346fe2 100644 --- a/drivers/gpu/drm/drm_plane_helper.c +++ b/drivers/gpu/drm/drm_plane_helper.c @@ -125,6 +125,12 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc, * still wish to call this function to avoid duplication of error checking * code. * + * Note: When converting over to atomic drivers you need to switch + * over to using drm_atomic_helper_plane_check_update() since only + * that correctly checks atomic state - this function here only looks + * at legacy state and hence will check against stale values in + * atomic updates. + * * RETURNS: * Zero if update appears valid, error code on failure */ diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index cc1fee8..eaa2544 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -64,6 +64,11 @@ void drm_atomic_helper_swap_state(struct drm_device *dev, struct drm_atomic_state *state); /* implementations for legacy interfaces */ +int drm_atomic_helper_plane_check_update(struct drm_plane_state *plane_state, + int min_scale, + int max_scale, + bool can_position, + bool *visible); int drm_atomic_helper_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,