From patchwork Tue Jul 14 00:05:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hunter X-Patchwork-Id: 6782841 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0665FC05AC for ; Tue, 14 Jul 2015 00:06:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14F23205DE for ; Tue, 14 Jul 2015 00:06:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A453C205DA for ; Tue, 14 Jul 2015 00:06:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D2236E352; Mon, 13 Jul 2015 17:06:08 -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 354446E352 for ; Mon, 13 Jul 2015 17:06:07 -0700 (PDT) Received: from debian.localdomain (unknown [59.108.92.109]) by mailfront01 (Coremail) with SMTP id x4FpogBXvGpoUqRVyCaIAQ--.24552S2; Tue, 14 Jul 2015 08:06:00 +0800 (CST) From: John Hunter To: dri-devel@lists.freedesktop.org Subject: [PATCH v3] drm: add a drm_atomic_helper_plane_check_update Date: Tue, 14 Jul 2015 08:05:51 +0800 Message-Id: <1436832351-3697-1-git-send-email-zhjwpku@gmail.com> X-Mailer: git-send-email 1.7.10.4 X-CM-TRANSID: x4FpogBXvGpoUqRVyCaIAQ--.24552S2 X-Coremail-Antispam: 1UD129KBjvJXoW3Xw4rAw1rZryrtF4ftF1UZFb_yoW7Xr4DpF ZrCryrKw4Yya97J3srJa1Ivw43Wa1fC342grykJrnIvF15KrZ3u3Z0qry7urW7JrWDKw1f tw12y3s8uw1YkFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkYb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI 64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8Jw Am72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc2xSY4AK67AK6w1l42xK82IY c2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s 026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF 0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0x vE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2 jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU5_Ks5UUUUU== 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. v4: -get rid of IS_ERR, IS_ERR actually doesn't catch NULL pointers Cc: Maarten Lankhorst Cc: Daniel Vetter Signed-off-by: Zhao Junwang --- 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..e492ff8 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(!crtc_state)) + return -EBUSY; + + 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,