[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cf89f24f-292a-44ae-c018-3db6081635b9@xs4all.nl>
Date: Wed, 6 Apr 2022 11:46:46 +0200
From: Hans Verkuil <hverkuil-cisco@...all.nl>
To: Sandor.yu@....com, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, andrzej.hajda@...el.com,
narmstrong@...libre.com, robert.foss@...aro.org,
Laurent.pinchart@...asonboard.com, jonas@...boo.se,
jernej.skrabec@...il.com
Cc: shengjiu.wang@....com, cai.huoqing@...ux.dev, maxime@...no.tech,
harry.wentland@....com, amuel@...lland.org
Subject: Re: [PATCH v1 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume
function
Hi Sandor,
On 06/04/2022 10:48, Sandor.yu@....com wrote:
> From: Sandor Yu <Sandor.yu@....com>
>
> CEC interrupt status/mask and logical address registers
> will be reset when device enter suspend.
> It will cause cec fail to work after device resume.
> Add CEC suspend/resume functions, save these registers status
> when suspend and restore them when resume.
>
> Signed-off-by: Sandor Yu <Sandor.yu@....com>
> ---
> drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 35 +++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
> index c8f44bcb298a..ceb619b32fde 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
> @@ -18,6 +18,8 @@
>
> #include "dw-hdmi-cec.h"
>
> +static u8 cec_saved_regs[5];
Ewww, not a global. Just save it in struct dw_hdmi_cec.
> +
> enum {
> HDMI_IH_CEC_STAT0 = 0x0106,
> HDMI_IH_MUTE_CEC_STAT0 = 0x0186,
> @@ -306,11 +308,44 @@ static int dw_hdmi_cec_remove(struct platform_device *pdev)
> return 0;
> }
>
> +static int __maybe_unused dw_hdmi_cec_resume(struct device *dev)
> +{
> + struct dw_hdmi_cec *cec = dev_get_drvdata(dev);
> +
> + /* Restore logical address and interrupt status/mask register */
> + dw_hdmi_write(cec, cec_saved_regs[0], HDMI_CEC_ADDR_L);
> + dw_hdmi_write(cec, cec_saved_regs[1], HDMI_CEC_ADDR_H);
No need to store HDMI_CEC_ADDR_L/R, just use cec->addresses.
> + dw_hdmi_write(cec, cec_saved_regs[2], HDMI_CEC_POLARITY);
> + dw_hdmi_write(cec, cec_saved_regs[3], HDMI_CEC_MASK);
> + dw_hdmi_write(cec, cec_saved_regs[4], HDMI_IH_MUTE_CEC_STAT0);
This doesn't call cec->ops->disable/enable. It might be better to just call
dw_hdmi_cec_enable() and store the enable state in struct dw_hdmi_cec.
Regards,
Hans
> +
> + return 0;
> +}
> +
> +static int __maybe_unused dw_hdmi_cec_suspend(struct device *dev)
> +{
> + struct dw_hdmi_cec *cec = dev_get_drvdata(dev);
> +
> + /* store logical address and interrupt status/mask register */
> + cec_saved_regs[0] = dw_hdmi_read(cec, HDMI_CEC_ADDR_L);
> + cec_saved_regs[1] = dw_hdmi_read(cec, HDMI_CEC_ADDR_H);
> + cec_saved_regs[2] = dw_hdmi_read(cec, HDMI_CEC_POLARITY);
> + cec_saved_regs[3] = dw_hdmi_read(cec, HDMI_CEC_MASK);
> + cec_saved_regs[4] = dw_hdmi_read(cec, HDMI_IH_MUTE_CEC_STAT0);
> +
> + return 0;
> +}
> +
> +static const struct dev_pm_ops dw_hdmi_cec_pm = {
> + SET_SYSTEM_SLEEP_PM_OPS(dw_hdmi_cec_suspend, dw_hdmi_cec_resume)
> +};
> +
> static struct platform_driver dw_hdmi_cec_driver = {
> .probe = dw_hdmi_cec_probe,
> .remove = dw_hdmi_cec_remove,
> .driver = {
> .name = "dw-hdmi-cec",
> + .pm = &dw_hdmi_cec_pm,
> },
> };
> module_platform_driver(dw_hdmi_cec_driver);
Powered by blists - more mailing lists