From patchwork Tue Jul 18 14:43:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 9848643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B77E9602A7 for ; Tue, 18 Jul 2017 14:44:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A75B62624A for ; Tue, 18 Jul 2017 14:44:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C44E26785; Tue, 18 Jul 2017 14:44:24 +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=-4.2 required=2.0 tests=BAYES_00, 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 5E1E32624A for ; Tue, 18 Jul 2017 14:44:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 89BF66E387; Tue, 18 Jul 2017 14:43:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 509B86E36D for ; Tue, 18 Jul 2017 14:43:26 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CA3BCAE21; Tue, 18 Jul 2017 14:43:23 +0000 (UTC) From: Takashi Iwai To: dri-devel@lists.freedesktop.org Subject: [PATCH 14/14] drm/mgag200: Implement basic PM support Date: Tue, 18 Jul 2017 16:43:20 +0200 Message-Id: <20170718144320.8354-15-tiwai@suse.de> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170718144320.8354-1-tiwai@suse.de> References: <20170718144320.8354-1-tiwai@suse.de> Cc: Egbert Eich , Dave Airlie , Mathieu Larouche , 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-Virus-Scanned: ClamAV using ClamSMTP Add a basic PM support to mgag200 driver. As there is no hardware specific init codes for this device, the callbacks are written in a fairly simple way. Signed-off-by: Takashi Iwai --- drivers/gpu/drm/mgag200/mgag200_drv.c | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c index 7a71ac729a81..8ae36c1ab4d2 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "mgag200_drv.h" @@ -81,6 +82,45 @@ static void mga_pci_remove(struct pci_dev *pdev) drm_put_dev(dev); } +#ifdef CONFIG_PM_SLEEP +static int mgag200_pm_suspend(struct device *dev) +{ + struct drm_device *drm_dev = dev_get_drvdata(dev); + struct mga_device *mdev = drm_dev->dev_private; + + drm_kms_helper_poll_disable(drm_dev); + + if (mdev->mfbdev) { + console_lock(); + drm_fb_helper_set_suspend(&mdev->mfbdev->helper, 1); + console_unlock(); + } + + return 0; +} + +static int mgag200_pm_resume(struct device *dev) +{ + struct drm_device *drm_dev = dev_get_drvdata(dev); + struct mga_device *mdev = drm_dev->dev_private; + + drm_helper_resume_force_mode(drm_dev); + + if (mdev->mfbdev) { + console_lock(); + drm_fb_helper_set_suspend(&mdev->mfbdev->helper, 0); + console_unlock(); + } + + drm_kms_helper_poll_enable(drm_dev); + return 0; +} +#endif + +static const struct dev_pm_ops mgag200_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(mgag200_pm_suspend, mgag200_pm_resume) +}; + static const struct file_operations mgag200_driver_fops = { .owner = THIS_MODULE, .open = drm_open, @@ -116,6 +156,7 @@ static struct pci_driver mgag200_pci_driver = { .id_table = pciidlist, .probe = mga_pci_probe, .remove = mga_pci_remove, + .driver.pm = &mgag200_pm_ops, }; static int __init mgag200_init(void)