From: Michael Tretter <m.tretter@pengutronix.de>
To: Andrzej Hajda <a.hajda@samsung.com>
Cc: dri-devel@lists.freedesktop.org,
linux-samsung-soc@vger.kernel.org, jy0922.shim@samsung.com,
b.zolnierkie@samsung.com, narmstrong@baylibre.com,
sw0312.kim@samsung.com, krzk@kernel.org,
Laurent.pinchart@ideasonboard.com, kernel@pengutronix.de,
sylvester.nawrocki@gmail.com
Subject: Re: [PATCH v2 08/16] drm/exynos: add host_ops callback for platform drivers
Date: Tue, 15 Sep 2020 20:02:39 +0200 [thread overview]
Message-ID: <20200915180239.GB16903@pengutronix.de> (raw)
In-Reply-To: <12dda4ee-8595-f534-b818-e97f4dfe6f2b@samsung.com>
On Tue, 15 Sep 2020 19:07:59 +0200, Andrzej Hajda wrote:
>
> W dniu 11.09.2020 o 15:54, Michael Tretter pisze:
> > Platform drivers need to be aware if a mipi dsi device attaches or
> > detaches. Add host_ops to the driver_data for attach and detach
> > callbacks and move the i80 mode selection and the hotplug handling into
> > the callback, because these depend on the drm driver.
> >
> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> > ---
> > v2:
> > - new patch
> > ---
> > drivers/gpu/drm/exynos/exynos_drm_dsi.c | 64 ++++++++++++++++++++-----
> > 1 file changed, 53 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
> > index 1a15ae71205d..684a2fbef08a 100644
> > --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
> > +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
> > @@ -239,6 +239,12 @@ struct exynos_dsi_transfer {
> > #define DSIM_STATE_CMD_LPM BIT(2)
> > #define DSIM_STATE_VIDOUT_AVAILABLE BIT(3)
> >
> > +struct exynos_dsi;
> > +struct exynos_dsi_host_ops {
> > + int (*attach)(struct device *dev, struct mipi_dsi_device *device);
> > + int (*detach)(struct device *dev, struct mipi_dsi_device *device);
> > +};
> > +
> > enum exynos_reg_offset {
> > EXYNOS_REG_OFS,
> > EXYNOS5433_REG_OFS
> > @@ -254,6 +260,7 @@ struct exynos_dsi_driver_data {
> > unsigned int wait_for_reset;
> > unsigned int num_bits_resol;
> > const unsigned int *reg_values;
> > + const struct exynos_dsi_host_ops *host_ops;
> > };
> >
> > struct exynos_dsi {
> > @@ -467,6 +474,41 @@ static const unsigned int exynos5433_reg_values[] = {
> > [PHYTIMING_HS_TRAIL] = 0x0c,
> > };
> >
> > +static int __exynos_dsi_host_attach(struct device *dev,
> > + struct mipi_dsi_device *device)
> > +{
> > + struct exynos_dsi *dsi = dev_get_drvdata(dev);
> > + struct drm_device *drm = dsi->encoder.dev;
>
>
> As I wrote yesterday drm device was guaranteed to be present here only
> if mipi dsi host registration was performed in component bind. In case
> it is performed in probe it will be always NULL, and the code does not
> make sense.
Correct, but if the driver is used as a drm bridge, there won't be an encoder
until bridge_attach. Mipi dsi devices defer their probe until the mipi dsi
host is available. If I move the mipi dsi host registration into
bridge_attach, the driver does not know if the next device is another bridge
or a panel during bridge_attach, but the driver cannot successfully return
from bridge_attach, because then the drm driver expects a connector.
I guess that the encoder should be initialized before registering the mipi dsi
host during probe instead of bind. The probe won't be rolled back on
PROBE_DEFER during bind and the encoder will be available in host_attach.
When splitting the driver into the exynos platform specific code and the more
generic code, there won't be an encoder during host_attach in the generic
code, but the host_ops callback could (and will) use the platform specific
encoder, which is available before bridge_attach.
Does this make sense to you?
Michael
>
>
> Regards
>
> Andrzej
>
>
>
> > + struct exynos_drm_crtc *crtc;
> > +
> > + mutex_lock(&drm->mode_config.mutex);
> > + crtc = exynos_drm_crtc_get_by_type(drm, EXYNOS_DISPLAY_TYPE_LCD);
> > + crtc->i80_mode = !(device->mode_flags & MIPI_DSI_MODE_VIDEO);
> > + mutex_unlock(&drm->mode_config.mutex);
> > +
> > + if (drm->mode_config.poll_enabled)
> > + drm_kms_helper_hotplug_event(drm);
> > +
> > + return 0;
> > +}
> > +
> > +static int __exynos_dsi_host_detach(struct device *dev,
> > + struct mipi_dsi_device *device)
> > +{
> > + struct exynos_dsi *dsi = dev_get_drvdata(dev);
> > + struct drm_device *drm = dsi->encoder.dev;
> > +
> > + if (drm->mode_config.poll_enabled)
> > + drm_kms_helper_hotplug_event(drm);
> > +
> > + return 0;
> > +}
> > +
> > +static const struct exynos_dsi_host_ops exynos_dsi_host_ops = {
> > + .attach = __exynos_dsi_host_attach,
> > + .detach = __exynos_dsi_host_detach,
> > +};
> > +
> > static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = {
> > .reg_ofs = EXYNOS_REG_OFS,
> > .plltmr_reg = 0x50,
> > @@ -477,6 +519,7 @@ static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = {
> > .wait_for_reset = 1,
> > .num_bits_resol = 11,
> > .reg_values = reg_values,
> > + .host_ops = &exynos_dsi_host_ops,
> > };
> >
> > static const struct exynos_dsi_driver_data exynos4_dsi_driver_data = {
> > @@ -489,6 +532,7 @@ static const struct exynos_dsi_driver_data exynos4_dsi_driver_data = {
> > .wait_for_reset = 1,
> > .num_bits_resol = 11,
> > .reg_values = reg_values,
> > + .host_ops = &exynos_dsi_host_ops,
> > };
> >
> > static const struct exynos_dsi_driver_data exynos5_dsi_driver_data = {
> > @@ -499,6 +543,7 @@ static const struct exynos_dsi_driver_data exynos5_dsi_driver_data = {
> > .wait_for_reset = 1,
> > .num_bits_resol = 11,
> > .reg_values = reg_values,
> > + .host_ops = &exynos_dsi_host_ops,
> > };
> >
> > static const struct exynos_dsi_driver_data exynos5433_dsi_driver_data = {
> > @@ -510,6 +555,7 @@ static const struct exynos_dsi_driver_data exynos5433_dsi_driver_data = {
> > .wait_for_reset = 0,
> > .num_bits_resol = 12,
> > .reg_values = exynos5433_reg_values,
> > + .host_ops = &exynos_dsi_host_ops,
> > };
> >
> > static const struct exynos_dsi_driver_data exynos5422_dsi_driver_data = {
> > @@ -521,6 +567,7 @@ static const struct exynos_dsi_driver_data exynos5422_dsi_driver_data = {
> > .wait_for_reset = 1,
> > .num_bits_resol = 12,
> > .reg_values = exynos5422_reg_values,
> > + .host_ops = &exynos_dsi_host_ops,
> > };
> >
> > static const struct of_device_id exynos_dsi_of_match[] = {
> > @@ -1551,8 +1598,8 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host,
> > struct mipi_dsi_device *device)
> > {
> > struct exynos_dsi *dsi = host_to_dsi(host);
> > + const struct exynos_dsi_host_ops *ops = dsi->driver_data->host_ops;
> > struct drm_encoder *encoder = &dsi->encoder;
> > - struct drm_device *drm = encoder->dev;
> > struct drm_bridge *out_bridge;
> >
> > out_bridge = of_drm_find_bridge(device->dev.of_node);
> > @@ -1590,18 +1637,12 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host,
> > return ret;
> > }
> >
> > - mutex_lock(&drm->mode_config.mutex);
> > -
> > dsi->lanes = device->lanes;
> > dsi->format = device->format;
> > dsi->mode_flags = device->mode_flags;
> > - exynos_drm_crtc_get_by_type(drm, EXYNOS_DISPLAY_TYPE_LCD)->i80_mode =
> > - !(dsi->mode_flags & MIPI_DSI_MODE_VIDEO);
> >
> > - mutex_unlock(&drm->mode_config.mutex);
> > -
> > - if (drm->mode_config.poll_enabled)
> > - drm_kms_helper_hotplug_event(drm);
> > + if (ops && ops->attach)
> > + ops->attach(dsi->dsi_host.dev, device);
> >
> > return 0;
> > }
> > @@ -1610,6 +1651,7 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host,
> > struct mipi_dsi_device *device)
> > {
> > struct exynos_dsi *dsi = host_to_dsi(host);
> > + const struct exynos_dsi_host_ops *ops = dsi->driver_data->host_ops;
> > struct drm_device *drm = dsi->encoder.dev;
> >
> > if (dsi->panel) {
> > @@ -1625,8 +1667,8 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host,
> > INIT_LIST_HEAD(&dsi->bridge_chain);
> > }
> >
> > - if (drm->mode_config.poll_enabled)
> > - drm_kms_helper_hotplug_event(drm);
> > + if (ops && ops->detach)
> > + ops->detach(dsi->dsi_host.dev, device);
> >
> > exynos_dsi_unregister_te_irq(dsi);
> >
>
next prev parent reply other threads:[~2020-09-15 18:03 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200911165401epcas1p3c7ee84dd01db93f472d6fa21c1100f29@epcas1p3.samsung.com>
2020-09-11 13:53 ` [PATCH v2 00/16] drm/exynos: Convert driver to drm bridge Michael Tretter
2020-09-11 13:53 ` [PATCH v2 01/16] drm/encoder: remove obsolete documentation of bridge Michael Tretter
2020-11-07 15:07 ` Adam Ford
2020-11-10 8:46 ` Michael Tretter
2020-11-07 22:17 ` Sam Ravnborg
2020-09-11 13:53 ` [PATCH v2 02/16] drm/exynos: remove in_bridge_node from exynos_dsi Michael Tretter
2020-11-07 22:19 ` Sam Ravnborg
2020-09-11 13:54 ` [PATCH v2 03/16] drm/exynos: use exynos_dsi as drvdata Michael Tretter
2020-11-07 22:24 ` Sam Ravnborg
2020-11-09 2:24 ` Inki Dae
2020-09-11 13:54 ` [PATCH v2 04/16] drm/exynos: extract helper functions for probe Michael Tretter
2020-11-07 22:27 ` Sam Ravnborg
2020-11-09 2:52 ` Inki Dae
2020-09-11 13:54 ` [PATCH v2 05/16] drm/exynos: move dsi host registration to probe Michael Tretter
2020-09-11 13:54 ` [PATCH v2 06/16] drm/exynos: shift register values to fields on write Michael Tretter
2020-11-07 22:39 ` Sam Ravnborg
2020-11-10 8:28 ` Michael Tretter
2020-09-11 13:54 ` [PATCH v2 07/16] drm/exynos: use identifier instead of register offsets Michael Tretter
2020-09-11 13:54 ` [PATCH v2 08/16] drm/exynos: add host_ops callback for platform drivers Michael Tretter
2020-09-15 17:07 ` Andrzej Hajda
2020-09-15 18:02 ` Michael Tretter [this message]
2020-09-16 22:01 ` Andrzej Hajda
2020-09-11 13:54 ` [PATCH v2 09/16] drm/exynos: add callback for tearing effect handler Michael Tretter
2020-09-11 13:54 ` [PATCH v2 10/16] drm/exynos: implement a drm bridge Michael Tretter
2020-09-14 8:29 ` Marek Szyprowski
2020-09-14 12:31 ` Marek Szyprowski
2020-09-14 20:01 ` Michael Tretter
2020-09-14 21:19 ` Andrzej Hajda
2020-09-15 19:40 ` Andrzej Hajda
2021-02-01 16:33 ` Michael Tretter
2021-02-03 20:31 ` Michael Tretter
2021-02-04 10:17 ` Daniel Vetter
2021-02-04 10:56 ` Michael Tretter
2021-02-04 16:05 ` Daniel Vetter
2021-02-04 16:28 ` Andrzej Hajda
2021-02-04 17:19 ` Daniel Vetter
2021-02-04 17:26 ` Laurent Pinchart
2021-02-04 17:46 ` Daniel Vetter
2021-02-10 9:10 ` Frieder Schrempf
2021-02-18 8:04 ` Michael Tretter
2021-02-18 16:02 ` Andrzej Hajda
2021-02-23 12:07 ` Daniel Vetter
2021-04-20 11:42 ` Frieder Schrempf
2021-04-20 14:27 ` Laurent Pinchart
2020-09-11 13:54 ` [PATCH v2 11/16] drm/exynos: convert encoder functions to bridge function Michael Tretter
2020-09-11 13:54 ` [PATCH v2 12/16] drm/exynos: configure mode on drm bridge Michael Tretter
2020-09-11 13:54 ` [PATCH v2 13/16] drm/exynos: get encoder from bridge whenever possible Michael Tretter
2020-09-11 13:54 ` [PATCH v2 14/16] drm/exynos: add API functions for platform drivers Michael Tretter
2020-09-11 13:54 ` [PATCH v2 15/16] drm/exynos: split out platform specific code Michael Tretter
2020-11-09 3:15 ` [PATCH v2 00/16] drm/exynos: Convert driver to drm bridge Inki Dae
2020-11-10 8:13 ` Michael Tretter
2020-11-10 12:34 ` Marek Szyprowski
2020-11-10 18:52 ` Sam Ravnborg
2020-11-11 3:04 ` Inki Dae
2020-11-11 3:11 ` Inki Dae
2020-11-11 10:18 ` Michael Tretter
2020-11-13 9:34 ` Inki Dae
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=20200915180239.GB16903@pengutronix.de \
--to=m.tretter@pengutronix.de \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a.hajda@samsung.com \
--cc=b.zolnierkie@samsung.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jy0922.shim@samsung.com \
--cc=kernel@pengutronix.de \
--cc=krzk@kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=narmstrong@baylibre.com \
--cc=sw0312.kim@samsung.com \
--cc=sylvester.nawrocki@gmail.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).