From: Daniel Vetter <daniel@ffwll.ch>
To: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Nicolas Boichat <drinkcat@chromium.org>,
Neil Armstrong <narmstrong@baylibre.com>,
David Airlie <airlied@linux.ie>,
linux-kernel <linux-kernel@vger.kernel.org>,
DRI Development <dri-devel@lists.freedesktop.org>,
Andrzej Hajda <a.hajda@samsung.com>,
boris.brezillon@collabora.com,
Matthias Brugger <matthias.bgg@gmail.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Hsin-Yi Wang <hsinyi@chromium.org>,
Enric Balletbo i Serra <enric.balletbo@collabora.com>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@lists.infradead.org>,
Collabora Kernel ML <kernel@collabora.com>,
Sam Ravnborg <sam@ravnborg.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [RESEND PATCH v2 2/2] drm/mediatek: mtk_dpi: Convert to bridge driver
Date: Thu, 10 Sep 2020 07:48:28 +0200 [thread overview]
Message-ID: <20200910054828.GC438822@phenom.ffwll.local> (raw)
In-Reply-To: <CAAOTY__UwVCDn_J1RWesrm7eTS=Ti4LS9FutaydomFNLBVsF2g@mail.gmail.com>
On Thu, Sep 10, 2020 at 06:35:21AM +0800, Chun-Kuang Hu wrote:
> Hi, Andrzej & Neil:
>
> Enric Balletbo i Serra <enric.balletbo@collabora.com> 於 2020年8月26日 週三 下午4:53寫道:
>
> >
> > Convert mtk_dpi to a bridge driver with built-in encoder support for
> > compatibility with existing component drivers.
> >
>
> This is a DRM-bridge related patch, how do you think about it?
bridge stuff is also maintained in drm-misc, so good to go imo.
For the bigger picture I think it'd be really good if bridges drivers
would use the of bridge lookup, and not hand roll something with
component. So 2nd step of converting this over to a proper bridge driver
would be to replace the component code here too.
Cheers, Daniel
>
> Regards,
> Chun-Kuang.
>
> > Reviewed-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> > Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> > ---
> >
> > Changes in v2:
> > - Maintain error message when attach to bridge fails. (Boris)
> >
> > drivers/gpu/drm/mediatek/mtk_dpi.c | 71 ++++++++++++++++++------------
> > 1 file changed, 42 insertions(+), 29 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
> > index f7372dbdac0e..589ef33a1780 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
> > @@ -64,6 +64,7 @@ enum mtk_dpi_out_color_format {
> > struct mtk_dpi {
> > struct mtk_ddp_comp ddp_comp;
> > struct drm_encoder encoder;
> > + struct drm_bridge bridge;
> > struct drm_bridge *next_bridge;
> > void __iomem *regs;
> > struct device *dev;
> > @@ -83,9 +84,9 @@ struct mtk_dpi {
> > int refcount;
> > };
> >
> > -static inline struct mtk_dpi *mtk_dpi_from_encoder(struct drm_encoder *e)
> > +static inline struct mtk_dpi *bridge_to_dpi(struct drm_bridge *b)
> > {
> > - return container_of(e, struct mtk_dpi, encoder);
> > + return container_of(b, struct mtk_dpi, bridge);
> > }
> >
> > enum mtk_dpi_polarity {
> > @@ -521,50 +522,53 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
> > return 0;
> > }
> >
> > -static bool mtk_dpi_encoder_mode_fixup(struct drm_encoder *encoder,
> > - const struct drm_display_mode *mode,
> > - struct drm_display_mode *adjusted_mode)
> > +static void mtk_dpi_encoder_destroy(struct drm_encoder *encoder)
> > {
> > - return true;
> > + drm_encoder_cleanup(encoder);
> > }
> >
> > -static void mtk_dpi_encoder_mode_set(struct drm_encoder *encoder,
> > - struct drm_display_mode *mode,
> > - struct drm_display_mode *adjusted_mode)
> > +static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = {
> > + .destroy = mtk_dpi_encoder_destroy,
> > +};
> > +
> > +static int mtk_dpi_bridge_attach(struct drm_bridge *bridge,
> > + enum drm_bridge_attach_flags flags)
> > {
> > - struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
> > + struct mtk_dpi *dpi = bridge_to_dpi(bridge);
> > +
> > + return drm_bridge_attach(bridge->encoder, dpi->next_bridge,
> > + &dpi->bridge, flags);
> > +}
> > +
> > +static void mtk_dpi_bridge_mode_set(struct drm_bridge *bridge,
> > + const struct drm_display_mode *mode,
> > + const struct drm_display_mode *adjusted_mode)
> > +{
> > + struct mtk_dpi *dpi = bridge_to_dpi(bridge);
> >
> > drm_mode_copy(&dpi->mode, adjusted_mode);
> > }
> >
> > -static void mtk_dpi_encoder_disable(struct drm_encoder *encoder)
> > +static void mtk_dpi_bridge_disable(struct drm_bridge *bridge)
> > {
> > - struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
> > + struct mtk_dpi *dpi = bridge_to_dpi(bridge);
> >
> > mtk_dpi_power_off(dpi);
> > }
> >
> > -static void mtk_dpi_encoder_enable(struct drm_encoder *encoder)
> > +static void mtk_dpi_bridge_enable(struct drm_bridge *bridge)
> > {
> > - struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
> > + struct mtk_dpi *dpi = bridge_to_dpi(bridge);
> >
> > mtk_dpi_power_on(dpi);
> > mtk_dpi_set_display_mode(dpi, &dpi->mode);
> > }
> >
> > -static int mtk_dpi_atomic_check(struct drm_encoder *encoder,
> > - struct drm_crtc_state *crtc_state,
> > - struct drm_connector_state *conn_state)
> > -{
> > - return 0;
> > -}
> > -
> > -static const struct drm_encoder_helper_funcs mtk_dpi_encoder_helper_funcs = {
> > - .mode_fixup = mtk_dpi_encoder_mode_fixup,
> > - .mode_set = mtk_dpi_encoder_mode_set,
> > - .disable = mtk_dpi_encoder_disable,
> > - .enable = mtk_dpi_encoder_enable,
> > - .atomic_check = mtk_dpi_atomic_check,
> > +static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
> > + .attach = mtk_dpi_bridge_attach,
> > + .mode_set = mtk_dpi_bridge_mode_set,
> > + .disable = mtk_dpi_bridge_disable,
> > + .enable = mtk_dpi_bridge_enable,
> > };
> >
> > static void mtk_dpi_start(struct mtk_ddp_comp *comp)
> > @@ -605,12 +609,11 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
> > dev_err(dev, "Failed to initialize decoder: %d\n", ret);
> > goto err_unregister;
> > }
> > - drm_encoder_helper_add(&dpi->encoder, &mtk_dpi_encoder_helper_funcs);
> >
> > /* Currently DPI0 is fixed to be driven by OVL1 */
> > dpi->encoder.possible_crtcs = BIT(1);
> >
> > - ret = drm_bridge_attach(&dpi->encoder, dpi->next_bridge, NULL, 0);
> > + ret = drm_bridge_attach(&dpi->encoder, &dpi->bridge, NULL, 0);
> > if (ret) {
> > dev_err(dev, "Failed to attach bridge: %d\n", ret);
> > goto err_cleanup;
> > @@ -791,8 +794,15 @@ static int mtk_dpi_probe(struct platform_device *pdev)
> >
> > platform_set_drvdata(pdev, dpi);
> >
> > + dpi->bridge.funcs = &mtk_dpi_bridge_funcs;
> > + dpi->bridge.of_node = dev->of_node;
> > + dpi->bridge.type = DRM_MODE_CONNECTOR_DPI;
> > +
> > + drm_bridge_add(&dpi->bridge);
> > +
> > ret = component_add(dev, &mtk_dpi_component_ops);
> > if (ret) {
> > + drm_bridge_remove(&dpi->bridge);
> > dev_err(dev, "Failed to add component: %d\n", ret);
> > return ret;
> > }
> > @@ -802,7 +812,10 @@ static int mtk_dpi_probe(struct platform_device *pdev)
> >
> > static int mtk_dpi_remove(struct platform_device *pdev)
> > {
> > + struct mtk_dpi *dpi = platform_get_drvdata(pdev);
> > +
> > component_del(&pdev->dev, &mtk_dpi_component_ops);
> > + drm_bridge_remove(&dpi->bridge);
> >
> > return 0;
> > }
> > --
> > 2.28.0
> >
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-09-10 5:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-26 8:53 [RESEND PATCH v2 0/2] Convert mtk-dpi to drm_bridge API Enric Balletbo i Serra
2020-08-26 8:53 ` [RESEND PATCH v2 1/2] drm/mediatek: mtk_dpi: Rename bridge to next_bridge Enric Balletbo i Serra
2020-09-09 22:33 ` Chun-Kuang Hu
2020-08-26 8:53 ` [RESEND PATCH v2 2/2] drm/mediatek: mtk_dpi: Convert to bridge driver Enric Balletbo i Serra
2020-09-09 22:35 ` Chun-Kuang Hu
2020-09-10 5:48 ` Daniel Vetter [this message]
2020-09-13 1:27 ` Chun-Kuang Hu
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=20200910054828.GC438822@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=a.hajda@samsung.com \
--cc=airlied@linux.ie \
--cc=boris.brezillon@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=drinkcat@chromium.org \
--cc=enric.balletbo@collabora.com \
--cc=hsinyi@chromium.org \
--cc=kernel@collabora.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=narmstrong@baylibre.com \
--cc=sam@ravnborg.org \
/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).