From patchwork Mon Jul 1 03:24:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11024741 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 440D6746 for ; Mon, 1 Jul 2019 03:24:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3452D2849B for ; Mon, 1 Jul 2019 03:24:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26DD8284C9; Mon, 1 Jul 2019 03:24:18 +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 AFA8C2849B for ; Mon, 1 Jul 2019 03:24:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B12C088EF2; Mon, 1 Jul 2019 03:24:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by gabe.freedesktop.org (Postfix) with ESMTPS id D1EF489D77 for ; Mon, 1 Jul 2019 03:24:15 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id x47so13122842qtk.11 for ; Sun, 30 Jun 2019 20:24:15 -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=K3NuKdFEgq5BVV5xPgHvrMD/faP4K7WOl8ZJ9WIj/Xk=; b=JvcZOhxIm6cABy43zx3B7sAfBiXCEGkRtivXzpb8UWH6Oa7kF7bbNvWuElzqCoeqnr YJEnutAHmFxoZDolKj+C5EXt0+ORZASPfzPmg6/29ZRojofOrCB2GQDGb4cy5uJGoe5q duA9bMWo8MLUHIvvoPT0gYLgEdRk1gYSqP5bF5jFoTgtpLnRUZrq+pMOyaJwS2RRzEd2 oA7MVxtn0ggXhXc3iAPos07xsUToh5cRVKkXHCwhDI56WcG5JtnVeEu0N5/cCKIu3aQK 5WTPtcjNghSLRJa+HrGHTX62/LRREnnHhF2ssHeXGqksa8MSgPkHzlAFvGKWAMwtd7HN 0Y3Q== X-Gm-Message-State: APjAAAW9dzGisept4cui5Vi2j/L8991jWzZQMvm9rXKYWPyanM0Fsehl 3qMngA/RCi3lqFlZD5TJIwY= X-Google-Smtp-Source: APXvYqzoNHdmQbwyteQnjItCSSCXAPmKX7z63t8UiKZy+sQ9oeM6hrklQWS1C2vZ3eHIPWlgspHSDw== X-Received: by 2002:a05:6214:10c5:: with SMTP id r5mr18310561qvs.224.1561951454954; Sun, 30 Jun 2019 20:24:14 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.22]) by smtp.gmail.com with ESMTPSA id f19sm667745qtq.5.2019.06.30.20.24.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 30 Jun 2019 20:24:14 -0700 (PDT) Date: Mon, 1 Jul 2019 00:24:10 -0300 From: Rodrigo Siqueira To: Daniel Vetter , Haneen Mohammed , David Airlie , Simon Ser Subject: [PATCH 1/2] drm/vkms: Add enable/disable functions per connector Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=K3NuKdFEgq5BVV5xPgHvrMD/faP4K7WOl8ZJ9WIj/Xk=; b=IvWQhGsm+FpCtynl/Y11txgTCNs/79JiJ3qwpzrawy3ctdoxx71HYmtq5iuDvf3HjM XVahi85PQv/zWxtzctSAZ0W8gplW2mEHBS7NgoZb8BrP4MyRLqt0Eri1Njxp1IKAj7gr BWCLifrNNigi87hshqwmhgyLgn4XwfpjI9xt3LGhCgaemkICwhk7RmT+mvZnDMyExooo bMhJEaM8154joJ1MB7ZqvPNV5yBmqWdwFJcQKDAA8wLjtr3lHuaSJEeQIzV0Di+KKT8A HXMQfwrDmgcqHXcecfeTnYpgzyxXhjoCQvucC5f9RC9K/TSpyqThOvE+CcDfMZhUUOY1 THbA== 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, virtual and writeback connectors have the code responsible for initialization and cleanup spread around different places in vkms. This patch creates an enable and disable function per connector which allows vkms to hotplug connectors easily. Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/vkms/vkms_drv.h | 5 ++ drivers/gpu/drm/vkms/vkms_output.c | 84 +++++++++++++++++---------- drivers/gpu/drm/vkms/vkms_writeback.c | 31 ++++++++-- 3 files changed, 83 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 9ff2cd4ebf81..a1ca5c658355 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -152,7 +152,12 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name, /* Composer Support */ void vkms_composer_worker(struct work_struct *work); +/* Virtual connector */ +int enable_virtual_connector(struct vkms_device *vkmsdev); +void disable_virtual_connector(struct vkms_device *vkmsdev); + /* Writeback */ int enable_writeback_connector(struct vkms_device *vkmsdev); +void disable_writeback_connector(struct vkms_device *connector); #endif /* _VKMS_DRV_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index aea1d4410864..26ecab52e82e 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -6,6 +6,7 @@ static void vkms_connector_destroy(struct drm_connector *connector) { + drm_connector_unregister(connector); drm_connector_cleanup(connector); } @@ -35,37 +36,19 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { .get_modes = vkms_conn_get_modes, }; -int vkms_output_init(struct vkms_device *vkmsdev, int index) +int enable_virtual_connector(struct vkms_device *vkmsdev) { struct vkms_output *output = &vkmsdev->output; - struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector = &output->connector; struct drm_encoder *encoder = &output->encoder; - struct drm_crtc *crtc = &output->crtc; - struct drm_plane *primary, *cursor = NULL; + struct drm_device *dev = &vkmsdev->drm; int ret; - primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index); - if (IS_ERR(primary)) - return PTR_ERR(primary); - - if (enable_cursor) { - cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); - if (IS_ERR(cursor)) { - ret = PTR_ERR(cursor); - goto err_cursor; - } - } - - ret = vkms_crtc_init(dev, crtc, primary, cursor); - if (ret) - goto err_crtc; - ret = drm_connector_init(dev, connector, &vkms_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL); if (ret) { DRM_ERROR("Failed to init connector\n"); - goto err_connector; + return ret; } drm_connector_helper_add(connector, &vkms_conn_helper_funcs); @@ -84,17 +67,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) goto err_attach; } - if (enable_writeback) { - ret = enable_writeback_connector(vkmsdev); - if (!ret) { - output->composer_enabled = true; - DRM_INFO("Writeback connector enabled"); - } else { - DRM_ERROR("Failed to init writeback connector\n"); - } - } - - drm_mode_config_reset(dev); + drm_connector_register(connector); return 0; @@ -104,6 +77,53 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) err_encoder: drm_connector_cleanup(connector); + return ret; +} + +void disable_virtual_connector(struct vkms_device *vkmsdev) +{ + struct vkms_output *output = &vkmsdev->output; + + drm_connector_unregister(&output->connector); + drm_connector_cleanup(&output->connector); + drm_encoder_cleanup(&output->encoder); +} + +int vkms_output_init(struct vkms_device *vkmsdev, int index) +{ + struct vkms_output *output = &vkmsdev->output; + struct drm_device *dev = &vkmsdev->drm; + struct drm_crtc *crtc = &output->crtc; + struct drm_plane *primary, *cursor = NULL; + int ret; + + primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index); + if (IS_ERR(primary)) + return PTR_ERR(primary); + + if (enable_cursor) { + cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); + if (IS_ERR(cursor)) { + ret = PTR_ERR(cursor); + goto err_cursor; + } + } + + ret = vkms_crtc_init(dev, crtc, primary, cursor); + if (ret) + goto err_crtc; + + ret = enable_virtual_connector(vkmsdev); + if (ret) + goto err_connector; + + if (enable_writeback) + enable_writeback_connector(vkmsdev); + + drm_mode_config_reset(dev); + + return 0; + err_connector: drm_crtc_cleanup(crtc); diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index 34dad37a0236..6a3f37d60c1d 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -125,17 +125,38 @@ static const struct drm_connector_helper_funcs vkms_wb_conn_helper_funcs = { .atomic_commit = vkms_wb_atomic_commit, }; +void disable_writeback_connector(struct vkms_device *vkmsdev) +{ + struct vkms_output *output = &vkmsdev->output; + + output->composer_enabled = false; + drm_connector_unregister(&output->wb_connector.base); + drm_connector_cleanup(&output->wb_connector.base); + drm_encoder_cleanup(&output->wb_connector.encoder); +} + int enable_writeback_connector(struct vkms_device *vkmsdev) { struct drm_writeback_connector *wb = &vkmsdev->output.wb_connector; + int ret; vkmsdev->output.wb_connector.encoder.possible_crtcs = 1; drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs); - return drm_writeback_connector_init(&vkmsdev->drm, wb, - &vkms_wb_connector_funcs, - &vkms_wb_encoder_helper_funcs, - vkms_wb_formats, - ARRAY_SIZE(vkms_wb_formats)); + ret = drm_writeback_connector_init(&vkmsdev->drm, wb, + &vkms_wb_connector_funcs, + &vkms_wb_encoder_helper_funcs, + vkms_wb_formats, + ARRAY_SIZE(vkms_wb_formats)); + if (!ret) { + vkmsdev->output.composer_enabled = true; + DRM_INFO("Writeback connector enabled"); + } else { + DRM_ERROR("Failed to init writeback connector\n"); + } + + drm_connector_register(&wb->base); + + return ret; }