From patchwork Thu Jul 24 09:17:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 4615351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 70A5BC0514 for ; Thu, 24 Jul 2014 09:21:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9643F20103 for ; Thu, 24 Jul 2014 09:21:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BBF5920034 for ; Thu, 24 Jul 2014 09:21:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XAFBs-000838-13; Thu, 24 Jul 2014 09:19:56 +0000 Received: from mail-bn1lp0142.outbound.protection.outlook.com ([207.46.163.142] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XAFAk-0006Nm-EW for linux-arm-kernel@lists.infradead.org; Thu, 24 Jul 2014 09:18:47 +0000 Received: from BY2PR03CA055.namprd03.prod.outlook.com (10.141.249.28) by BLUPR03MB341.namprd03.prod.outlook.com (10.141.48.12) with Microsoft SMTP Server (TLS) id 15.0.990.7; Thu, 24 Jul 2014 09:18:23 +0000 Received: from BN1AFFO11FD043.protection.gbl (2a01:111:f400:7c10::105) by BY2PR03CA055.outlook.office365.com (2a01:111:e400:2c5d::28) with Microsoft SMTP Server (TLS) id 15.0.995.14 via Frontend Transport; Thu, 24 Jul 2014 09:18:22 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD043.mail.protection.outlook.com (10.58.52.190) with Microsoft SMTP Server (TLS) id 15.0.980.11 via Frontend Transport; Thu, 24 Jul 2014 09:18:21 +0000 Received: from dragon.ap.freescale.net ([10.192.185.103]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s6O9ICLr017444; Thu, 24 Jul 2014 02:18:13 -0700 From: Shawn Guo To: Russell King Subject: [PATCH] imx-drm: imx-drm-core: add suspend/resume support Date: Thu, 24 Jul 2014 17:17:54 +0800 Message-ID: <1406193474-13695-1-git-send-email-shawn.guo@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(199002)(189002)(50986999)(83322001)(77156001)(88136002)(229853001)(74502001)(62966002)(86362001)(50226001)(102836001)(46102001)(92566001)(93916002)(19580395003)(69596002)(44976005)(87286001)(31966008)(76482001)(33646002)(110136001)(87936001)(83072002)(81342001)(48376002)(77982001)(575784001)(106466001)(92726001)(99396002)(89996001)(105606002)(50466002)(81542001)(85852003)(64706001)(21056001)(4396001)(104166001)(79102001)(6806004)(107046002)(26826002)(84676001)(47776003)(74662001)(95666004)(81156004)(85306003)(68736004)(19580405001)(97736001)(20776003)(36756003)(80022001)(104016003); DIR:OUT; SFP:; SCL:1; SRVR:BLUPR03MB341; H:az84smr01.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 028256169F Received-SPF: Fail (: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=Shawn.Guo@freescale.com; X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140724_021846_650017_D2DAF692 X-CRM114-Status: GOOD ( 10.72 ) X-Spam-Score: -0.0 (/) Cc: David Airlie , Shawn Guo , dri-devel@lists.freedesktop.org, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 HDMI currently stops working after a system suspend/resume cycle. It turns out that the cause is the imx-hdmi encoder .dpms hook doesn't get called from anywhere across suspend/resume cycle. The patch follows what exynos drm driver does to walk the list of connectors and call their .dpms function from suspend/resume hook. And the connectors' .dpms function will in turn filter down to the .dpms hooks of encoders and CRTCs. With this change, HDMI can continue working after a suspend/resume cycle. Signed-off-by: Shawn Guo Tested-by: Philipp Zabel --- Tested with HDMI and LVDS. It'd be great if someone can help test TVE to ensure the patch doesn't break anything. drivers/staging/imx-drm/imx-drm-core.c | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index def8280d7ee6..b0ea1f0ed32f 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -696,6 +696,44 @@ static int imx_drm_platform_remove(struct platform_device *pdev) return 0; } +#if CONFIG_PM_SLEEP +static int imx_drm_suspend(struct device *dev) +{ + struct drm_device *drm_dev = dev_get_drvdata(dev); + struct drm_connector *connector; + + drm_kms_helper_poll_disable(drm_dev); + + drm_modeset_lock_all(drm_dev); + list_for_each_entry(connector, &drm_dev->mode_config.connector_list, head) { + if (connector->funcs->dpms) + connector->funcs->dpms(connector, DRM_MODE_DPMS_OFF); + } + drm_modeset_unlock_all(drm_dev); + + return 0; +} + +static int imx_drm_resume(struct device *dev) +{ + struct drm_device *drm_dev = dev_get_drvdata(dev); + struct drm_connector *connector; + + drm_modeset_lock_all(drm_dev); + list_for_each_entry(connector, &drm_dev->mode_config.connector_list, head) { + if (connector->funcs->dpms) + connector->funcs->dpms(connector, DRM_MODE_DPMS_ON); + } + drm_modeset_unlock_all(drm_dev); + + drm_kms_helper_poll_enable(drm_dev); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(imx_drm_pm_ops, imx_drm_suspend, imx_drm_resume); + static const struct of_device_id imx_drm_dt_ids[] = { { .compatible = "fsl,imx-display-subsystem", }, { /* sentinel */ }, @@ -708,6 +746,7 @@ static struct platform_driver imx_drm_pdrv = { .driver = { .owner = THIS_MODULE, .name = "imx-drm", + .pm = &imx_drm_pm_ops, .of_match_table = imx_drm_dt_ids, }, };