From: Sandor Yu <sandor.yu@nxp.com>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"andrzej.hajda@intel.com" <andrzej.hajda@intel.com>,
"narmstrong@baylibre.com" <narmstrong@baylibre.com>,
"robert.foss@linaro.org" <robert.foss@linaro.org>,
"Laurent.pinchart@ideasonboard.com"
<Laurent.pinchart@ideasonboard.com>,
"jonas@kwiboo.se" <jonas@kwiboo.se>,
"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>
Cc: "S.J. Wang" <shengjiu.wang@nxp.com>,
"cai.huoqing@linux.dev" <cai.huoqing@linux.dev>,
"maxime@cerno.tech" <maxime@cerno.tech>,
"harry.wentland@amd.com" <harry.wentland@amd.com>,
"amuel@sholland.org" <amuel@sholland.org>
Subject: RE: [EXT] Re: [PATCH v1 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume function
Date: Thu, 7 Apr 2022 08:30:27 +0000 [thread overview]
Message-ID: <DB7PR04MB5450C501F54725378FEC08CAF4E69@DB7PR04MB5450.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <cf89f24f-292a-44ae-c018-3db6081635b9@xs4all.nl>
Hi,
> -----Original Message-----
> From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Sent: 2022年4月6日 17:47
> To: Sandor Yu <sandor.yu@nxp.com>; dri-devel@lists.freedesktop.org;
> linux-kernel@vger.kernel.org; andrzej.hajda@intel.com;
> narmstrong@baylibre.com; robert.foss@linaro.org;
> Laurent.pinchart@ideasonboard.com; jonas@kwiboo.se;
> jernej.skrabec@gmail.com
> Cc: S.J. Wang <shengjiu.wang@nxp.com>; cai.huoqing@linux.dev;
> maxime@cerno.tech; harry.wentland@amd.com; amuel@sholland.org
> Subject: [EXT] Re: [PATCH v1 1/5] drm: bridge: dw_hdmi: cec: Add cec
> suspend/resume function
>
> Caution: EXT Email
>
> Hi Sandor,
>
> On 06/04/2022 10:48, Sandor.yu@nxp.com wrote:
> > From: Sandor Yu <Sandor.yu@nxp.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@nxp.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.
Agree, I will use it later.
>
> > + 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.
If call cec->ops->disable/enable in suspend/resume, CEC stack will be reset.
CEC user such as EARC/ARC, the CEC link is expect keep in active after device resume.
So I prefer only save those registers for better user experience.
>
> Regards,
>
> Hans
>
Thanks
Sandor
> > +
> > + 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);
next prev parent reply other threads:[~2022-04-07 8:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-06 8:48 [PATCH v1 0/5] DRM: Bridge: DW_HDMI: Add new features and bug fix Sandor.yu
2022-04-06 8:48 ` [PATCH v1 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume function Sandor.yu
2022-04-06 9:46 ` Hans Verkuil
2022-04-07 8:30 ` Sandor Yu [this message]
2022-04-06 8:48 ` [PATCH v1 2/5] drm: bridge: dw_hdmi: enable overflow workaround for v2.13a Sandor.yu
2022-04-06 9:17 ` Neil Armstrong
2022-04-07 8:30 ` [EXT] " Sandor Yu
2022-04-06 8:48 ` [PATCH v1 3/5] drm: bridge: dw_hdmi: Enable GCP only for Deep Color Sandor.yu
2022-04-06 9:20 ` Neil Armstrong
2022-04-07 8:31 ` [EXT] " Sandor Yu
2022-04-06 8:48 ` [PATCH v1 4/5] drm: bridge: dw_hdmi: add reset function for PHY GEN1 Sandor.yu
2022-04-06 8:48 ` [PATCH v1 5/5] drm: bridge: dw_hdmi: Audio: Add General Parallel Audio (GPA) driver Sandor.yu
2022-04-06 9:27 ` Neil Armstrong
2022-04-07 8:31 ` [EXT] " Sandor Yu
2022-04-07 8:43 ` [PATCH v1 0/5] DRM: Bridge: DW_HDMI: Add new features and bug fix Philipp Zabel
2022-04-07 11:46 ` [EXT] " Sandor Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DB7PR04MB5450C501F54725378FEC08CAF4E69@DB7PR04MB5450.eurprd04.prod.outlook.com \
--to=sandor.yu@nxp.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=amuel@sholland.org \
--cc=andrzej.hajda@intel.com \
--cc=cai.huoqing@linux.dev \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime@cerno.tech \
--cc=narmstrong@baylibre.com \
--cc=robert.foss@linaro.org \
--cc=shengjiu.wang@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).