Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752241AbbBWKKG (ORCPT ); Mon, 23 Feb 2015 05:10:06 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:43403 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752120AbbBWKKE (ORCPT ); Mon, 23 Feb 2015 05:10:04 -0500 X-AuditID: cbfec7f4-b7f126d000001e9a-24-54eafbe70b36 Message-id: <54EAFC64.1050209@samsung.com> Date: Mon, 23 Feb 2015 11:09:40 +0100 From: Andrzej Hajda User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-version: 1.0 Newsgroups: gmane.linux.kernel,gmane.comp.video.dri.devel,gmane.linux.ports.arm.kernel To: Sylvain Rochet , Boris Brezillon , David Airlie , dri-devel@lists.freedesktop.org, Nicolas Ferre , Jean-Christophe Plagniol-Villard , Alexandre Belloni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Vetter , Kevin Hilman , Wenyou Yang Subject: Re: [PATCHv3 1/2] drm: atmel-hlcdc: Add PM suspend/resume support References: <1424627464-16869-1-git-send-email-sylvain.rochet@finsecur.com> <1424627464-16869-2-git-send-email-sylvain.rochet@finsecur.com> In-reply-to: <1424627464-16869-2-git-send-email-sylvain.rochet@finsecur.com> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPLMWRmVeSWpSXmKPExsVy+t/xK7rPf78KMbh4XdKi99xJJouOa4uZ LA68WMhi8X/bRGaLK1/fs1k83fyYyWLT42usFpd3zWGz+Ha5md1i3cMXTBY31/WyWNz+tYHF gcdjwa+tLB57vy1g8fhxZzqjx5NNFxk9Xl24w+KxaVUnm8f2bw9YPe53H2fy2Lyk3uPzJrkA rigum5TUnMyy1CJ9uwSujCfP7zMX7BapOH15OWsD40uBLkZODgkBE4kzWx+yQNhiEhfurWfr YuTiEBJYyiix4Oo9FgjnE6PEnssfGEGqeAW0JFb/2ccGYrMIqEqcvnMCLM4moCnxd/NNsLio QITE/GOvmSHqBSV+TL4HtoEPKH7j4nwmkKEiAk0sEuvebQFrFhbwkph76gkTxLZeRonnWxay giQ4BXwkFn16BlTEwcEsoCdx/6IWSJhZQF5i85q3zBMYBWYh2TELoWoWkqoFjMyrGEVTS5ML ipPScw31ihNzi0vz0vWS83M3MUIi6csOxsXHrA4xCnAwKvHwPih7FSLEmlhWXJl7iFGCg1lJ hFf6J1CINyWxsiq1KD++qDQntfgQIxMHp1QDY9rTTZeubli98MFq9vyKqv7jnjb79y5ssXxY xXPj2j3JXbJTdhos6nHdFXd3x5OMw9lTQ+asZry/M+xGbOaqokkHpXJTJzs8cykSFzBYGbny bpLIwv+CDNO+6O45Xdhl3L908/XHJ7mCVx6bvq9/vbln0UezvMV9kVm/w9XtTs6c8OHf6aD5 hm5KLMUZiYZazEXFiQCsvVIfggIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2780 Lines: 89 On 02/22/2015 06:51 PM, Sylvain Rochet wrote: > On suspend: switch off CRTC if not already suspended with runtime PM > > On resume: switch on CRTC if we were not already suspended from runtime > PM while suspending. > > Signed-off-by: Sylvain Rochet Reviewed-by: Andrzej Hajda Regards Andrzej > --- > drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 47 ++++++++++++++++++++++++++++ > 1 file changed, 47 insertions(+) > > diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c > index 22c3cca..c4bb1f9 100644 > --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c > +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c > @@ -559,6 +559,52 @@ static int atmel_hlcdc_dc_drm_remove(struct platform_device *pdev) > return 0; > } > > +#ifdef CONFIG_PM > +static int atmel_hlcdc_dc_drm_suspend(struct device *dev) > +{ > + struct drm_device *drm_dev = dev_get_drvdata(dev); > + struct drm_crtc *crtc; > + > + if (pm_runtime_suspended(dev)) > + return 0; > + > + drm_modeset_lock_all(drm_dev); > + list_for_each_entry(crtc, &drm_dev->mode_config.crtc_list, head) { > + struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; > + if (crtc->enabled) { > + crtc_funcs->disable(crtc); > + /* save enable state for resume */ > + crtc->enabled = true; > + } > + } > + drm_modeset_unlock_all(drm_dev); > + return 0; > +} > + > +static int atmel_hlcdc_dc_drm_resume(struct device *dev) > +{ > + struct drm_device *drm_dev = dev_get_drvdata(dev); > + struct drm_crtc *crtc; > + > + if (pm_runtime_suspended(dev)) > + return 0; > + > + drm_modeset_lock_all(drm_dev); > + list_for_each_entry(crtc, &drm_dev->mode_config.crtc_list, head) { > + struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; > + if (crtc->enabled) { > + crtc->enabled = false; > + crtc_funcs->enable(crtc); > + } > + } > + drm_modeset_unlock_all(drm_dev); > + return 0; > +} > +#endif > + > +static SIMPLE_DEV_PM_OPS(atmel_hlcdc_dc_drm_pm_ops, > + atmel_hlcdc_dc_drm_suspend, atmel_hlcdc_dc_drm_resume); > + > static const struct of_device_id atmel_hlcdc_dc_of_match[] = { > { .compatible = "atmel,hlcdc-display-controller" }, > { }, > @@ -569,6 +615,7 @@ static struct platform_driver atmel_hlcdc_dc_platform_driver = { > .remove = atmel_hlcdc_dc_drm_remove, > .driver = { > .name = "atmel-hlcdc-display-controller", > + .pm = &atmel_hlcdc_dc_drm_pm_ops, > .of_match_table = atmel_hlcdc_dc_of_match, > }, > }; > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/