From patchwork Mon Aug 6 03:57:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 10556619 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 49B3814E5 for ; Mon, 6 Aug 2018 08:22:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36F632915E for ; Mon, 6 Aug 2018 08:22:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AC8C2922D; Mon, 6 Aug 2018 08:22:13 +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=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 BD8622915E for ; Mon, 6 Aug 2018 08:22:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 879B36E23F; Mon, 6 Aug 2018 08:20:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 479246E185 for ; Mon, 6 Aug 2018 04:16:51 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id d17-v6so5588002pgv.10 for ; Sun, 05 Aug 2018 21:16:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=LekZ702HUcc4E/SzxI0KmezcezoHMukbDgR9lX2IdIc=; b=PS4Qu4AlTxI1R75Oacpbw9mc0erUuJTTF7+izqy3GAE/B2QpQxRDkiMNNDOeogz76p X0Fux3gklIbnFHSucuvJ7c9wyx1zU1PMp7kJgMNc6OJVfFKClNcXdX51HxbvssgSYDBR gJD0OsYgYS7OSxYTrQGlUOhuOIewc/CgTZXhSwOIN2U4VULPlsE31dnc4YkpRXBSqVMF 10NFKxgQprU8Na6NhA2T/rVocue5sVFDrOsQCOAE61ifloLRY5zoNNoB99y5TARsEwJo Y54TVUKe8gJRxZmQVW2RAXBNB4ZOTauwXPoQsG4sGp/DF87/YTCxvP/ijV8cupu8aOaQ 7Rxw== X-Gm-Message-State: AOUpUlGMTk9RDZcFeIUNurUmbL8bF/QKsbCf+bUef33Z7mCDH/+z8dhB LggLUdSEcCmkBBGv4tvL3tCWc1+V X-Google-Smtp-Source: AAOMgpcGSmmOkwLyLggldVWJOZ8rPtjAWAK6o+q6eh8y2Ct7hi30Yd1lnvq5Tnd5uvxksxIqII4IYQ== X-Received: by 2002:a63:de10:: with SMTP id f16-v6mr12795683pgg.97.1533529010701; Sun, 05 Aug 2018 21:16:50 -0700 (PDT) Received: from haneenDRM ([64.77.242.50]) by smtp.gmail.com with ESMTPSA id n83-v6sm24271652pfk.19.2018.08.05.21.16.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Aug 2018 21:16:50 -0700 (PDT) Date: Mon, 6 Aug 2018 06:57:30 +0300 From: Haneen Mohammed To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/vkms: Add cursor plane support Message-ID: <7c97707407270eaef064216a7da01df6c9896c9c.1533526327.git.hamohammed.sa@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Mailman-Approved-At: Mon, 06 Aug 2018 08:20:19 +0000 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: hamohammed.sa@gmail.com, rodrigosiqueiramelo@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add cursor plane support and update vkms_plane_atomic_check to enable positioning cursor plane. Signed-off-by: Haneen Mohammed --- drivers/gpu/drm/vkms/vkms_drv.h | 11 +++++++--- drivers/gpu/drm/vkms/vkms_output.c | 16 ++++++++++++--- drivers/gpu/drm/vkms/vkms_plane.c | 33 +++++++++++++++++++++--------- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index f156c930366a..36e524f791fe 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -7,8 +7,8 @@ #include #include -#define XRES_MIN 32 -#define YRES_MIN 32 +#define XRES_MIN 20 +#define YRES_MIN 20 #define XRES_DEF 1024 #define YRES_DEF 768 @@ -20,6 +20,10 @@ static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, }; +static const u32 vkms_cursor_formats[] = { + DRM_FORMAT_ARGB8888, +}; + struct vkms_crc_data { struct drm_rect src; struct drm_framebuffer fb; @@ -100,7 +104,8 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, int vkms_output_init(struct vkms_device *vkmsdev); -struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev); +struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, + enum drm_plane_type type); /* Gem stuff */ struct drm_gem_object *vkms_gem_create(struct drm_device *dev, diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 901012cb1af1..7cf2867c93f8 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -49,14 +49,20 @@ int vkms_output_init(struct vkms_device *vkmsdev) struct drm_connector *connector = &output->connector; struct drm_encoder *encoder = &output->encoder; struct drm_crtc *crtc = &output->crtc; - struct drm_plane *primary; + struct drm_plane *primary, *cursor; int ret; - primary = vkms_plane_init(vkmsdev); + primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY); if (IS_ERR(primary)) return PTR_ERR(primary); - ret = vkms_crtc_init(dev, crtc, primary, NULL); + cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR); + if (IS_ERR(cursor)) { + ret = PTR_ERR(cursor); + goto err_cursor; + } + + ret = vkms_crtc_init(dev, crtc, primary, cursor); if (ret) goto err_crtc; @@ -106,6 +112,10 @@ int vkms_output_init(struct vkms_device *vkmsdev) drm_crtc_cleanup(crtc); err_crtc: + drm_plane_cleanup(cursor); + +err_cursor: drm_plane_cleanup(primary); + return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index c91661631c76..428247d403dc 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -81,8 +81,8 @@ static const struct drm_plane_funcs vkms_plane_funcs = { .atomic_destroy_state = vkms_plane_destroy_state, }; -static void vkms_primary_plane_update(struct drm_plane *plane, - struct drm_plane_state *old_state) +static void vkms_plane_atomic_update(struct drm_plane *plane, + struct drm_plane_state *old_state) { struct vkms_plane_state *vkms_plane_state; struct vkms_crc_data *crc_data; @@ -101,6 +101,7 @@ static int vkms_plane_atomic_check(struct drm_plane *plane, struct drm_plane_state *state) { struct drm_crtc_state *crtc_state; + bool can_position = false; int ret; if (!state->fb | !state->crtc) @@ -110,15 +111,18 @@ static int vkms_plane_atomic_check(struct drm_plane *plane, if (IS_ERR(crtc_state)) return PTR_ERR(crtc_state); + if (plane->type == DRM_PLANE_TYPE_CURSOR) + can_position = true; + ret = drm_atomic_helper_check_plane_state(state, crtc_state, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, - false, true); + can_position, true); if (ret != 0) return ret; /* for now primary plane must be visible and full screen */ - if (!state->visible) + if (!state->visible && !can_position) return -EINVAL; return 0; @@ -156,15 +160,17 @@ static void vkms_cleanup_fb(struct drm_plane *plane, } static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = { - .atomic_update = vkms_primary_plane_update, + .atomic_update = vkms_plane_atomic_update, .atomic_check = vkms_plane_atomic_check, .prepare_fb = vkms_prepare_fb, .cleanup_fb = vkms_cleanup_fb, }; -struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev) +struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, + enum drm_plane_type type) { struct drm_device *dev = &vkmsdev->drm; + const struct drm_plane_helper_funcs *funcs; struct drm_plane *plane; const u32 *formats; int ret, nformats; @@ -173,19 +179,26 @@ struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev) if (!plane) return ERR_PTR(-ENOMEM); - formats = vkms_formats; - nformats = ARRAY_SIZE(vkms_formats); + if (type == DRM_PLANE_TYPE_CURSOR) { + formats = vkms_cursor_formats; + nformats = ARRAY_SIZE(vkms_cursor_formats); + funcs = &vkms_primary_helper_funcs; + } else { + formats = vkms_formats; + nformats = ARRAY_SIZE(vkms_formats); + funcs = &vkms_primary_helper_funcs; + } ret = drm_universal_plane_init(dev, plane, 0, &vkms_plane_funcs, formats, nformats, - NULL, DRM_PLANE_TYPE_PRIMARY, NULL); + NULL, type, NULL); if (ret) { kfree(plane); return ERR_PTR(ret); } - drm_plane_helper_add(plane, &vkms_primary_helper_funcs); + drm_plane_helper_add(plane, funcs); return plane; }