From: Archit Taneja <architt@codeaurora.org>
To: Boris Brezillon <boris.brezillon@free-electrons.com>,
Philippe CORNU <philippe.cornu@st.com>
Cc: Eric Anholt <eric@anholt.net>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
Andrzej Hajda <a.hajda@samsung.com>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
CK Hu <ck.hu@mediatek.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Yannick FERTRE <yannick.fertre@st.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 5/7] drm/ltdc: Use the panel-bridge helper.
Date: Wed, 31 May 2017 13:31:16 +0530 [thread overview]
Message-ID: <b2be18f4-eb2b-c47c-744a-0f4f85e17ce1@codeaurora.org> (raw)
In-Reply-To: <20170531082627.5953f75b@bbrezillon>
Hi Boris,
On 05/31/2017 11:56 AM, Boris Brezillon wrote:
> Hi Philippe,
>
> Le Tue, 30 May 2017 16:55:42 +0000,
> Philippe CORNU <philippe.cornu@st.com> a écrit :
>
>> Hi Eric,
>>
>> I took your patch for the panel-bridge and it works perfectly in both
>> DPI mode (panel RGB //) and DSI mode (bridge dw mipi dsi), bravo :-)
>
> I still don't understand how it can work without a call to
> drm_bridge_attach() (which is used to link the RGB encoder to the DPI
> connector). I'm probably missing something obvious. Maybe someone can
> point it out :-).
I think the expectation is that there will be a follow-up patch that
would add bridge support. Philippe had posted a patch for adding bridges
to ltdc before:
https://patchwork.kernel.org/patch/9724835/
He can now redo his patch over Eric's panel-bridge patch-set.
Thanks,
Archit
>
> Thanks,
>
> Boris
>
>>
>> ~160 lines have been removed from ltdc.c thanks to your panel-bridge code!
>>
>> Many thanks
>> Philippe
>>
>> On 05/11/2017 08:31 PM, Eric Anholt wrote:
>>> Another 100 lines of boilerplate gone. Bridges aren't supported yet,
>>> but will be trivial to add later.
>>>
>>> Signed-off-by: Eric Anholt <eric@anholt.net>
>>> ---
>>>
>>> Also untested.
>>>
>>> drivers/gpu/drm/stm/ltdc.c | 128 +++++----------------------------------------
>>> drivers/gpu/drm/stm/ltdc.h | 2 +-
>>> 2 files changed, 13 insertions(+), 117 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
>>> index a40418cda74a..41a1c5d68f5b 100644
>>> --- a/drivers/gpu/drm/stm/ltdc.c
>>> +++ b/drivers/gpu/drm/stm/ltdc.c
>>> @@ -269,11 +269,6 @@ static inline struct ltdc_device *encoder_to_ltdc(struct drm_encoder *enc)
>>> return (struct ltdc_device *)enc->dev->dev_private;
>>> }
>>>
>>> -static inline struct ltdc_device *connector_to_ltdc(struct drm_connector *con)
>>> -{
>>> - return (struct ltdc_device *)con->dev->dev_private;
>>> -}
>>> -
>>> static inline enum ltdc_pix_fmt to_ltdc_pixelformat(u32 drm_fmt)
>>> {
>>> enum ltdc_pix_fmt pf;
>>> @@ -815,22 +810,12 @@ static int ltdc_crtc_init(struct drm_device *ddev, struct drm_crtc *crtc)
>>>
>>> static void ltdc_rgb_encoder_enable(struct drm_encoder *encoder)
>>> {
>>> - struct ltdc_device *ldev = encoder_to_ltdc(encoder);
>>> -
>>> DRM_DEBUG_DRIVER("\n");
>>> -
>>> - drm_panel_prepare(ldev->panel);
>>> - drm_panel_enable(ldev->panel);
>>> }
>>>
>>> static void ltdc_rgb_encoder_disable(struct drm_encoder *encoder)
>>> {
>>> - struct ltdc_device *ldev = encoder_to_ltdc(encoder);
>>> -
>>> DRM_DEBUG_DRIVER("\n");
>>> -
>>> - drm_panel_disable(ldev->panel);
>>> - drm_panel_unprepare(ldev->panel);
>>> }
>>>
>>> static const struct drm_encoder_helper_funcs ltdc_rgb_encoder_helper_funcs = {
>>> @@ -863,82 +848,6 @@ static struct drm_encoder *ltdc_rgb_encoder_create(struct drm_device *ddev)
>>> return encoder;
>>> }
>>>
>>> -/*
>>> - * DRM_CONNECTOR
>>> - */
>>> -
>>> -static int ltdc_rgb_connector_get_modes(struct drm_connector *connector)
>>> -{
>>> - struct drm_device *ddev = connector->dev;
>>> - struct ltdc_device *ldev = ddev->dev_private;
>>> - int ret = 0;
>>> -
>>> - DRM_DEBUG_DRIVER("\n");
>>> -
>>> - if (ldev->panel)
>>> - ret = drm_panel_get_modes(ldev->panel);
>>> -
>>> - return ret < 0 ? 0 : ret;
>>> -}
>>> -
>>> -static struct drm_connector_helper_funcs ltdc_rgb_connector_helper_funcs = {
>>> - .get_modes = ltdc_rgb_connector_get_modes,
>>> -};
>>> -
>>> -static enum drm_connector_status
>>> -ltdc_rgb_connector_detect(struct drm_connector *connector, bool force)
>>> -{
>>> - struct ltdc_device *ldev = connector_to_ltdc(connector);
>>> -
>>> - return ldev->panel ? connector_status_connected :
>>> - connector_status_disconnected;
>>> -}
>>> -
>>> -static void ltdc_rgb_connector_destroy(struct drm_connector *connector)
>>> -{
>>> - DRM_DEBUG_DRIVER("\n");
>>> -
>>> - drm_connector_unregister(connector);
>>> - drm_connector_cleanup(connector);
>>> -}
>>> -
>>> -static const struct drm_connector_funcs ltdc_rgb_connector_funcs = {
>>> - .dpms = drm_atomic_helper_connector_dpms,
>>> - .fill_modes = drm_helper_probe_single_connector_modes,
>>> - .detect = ltdc_rgb_connector_detect,
>>> - .destroy = ltdc_rgb_connector_destroy,
>>> - .reset = drm_atomic_helper_connector_reset,
>>> - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
>>> - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
>>> -};
>>> -
>>> -struct drm_connector *ltdc_rgb_connector_create(struct drm_device *ddev)
>>> -{
>>> - struct drm_connector *connector;
>>> - int err;
>>> -
>>> - connector = devm_kzalloc(ddev->dev, sizeof(*connector), GFP_KERNEL);
>>> - if (!connector) {
>>> - DRM_ERROR("Failed to allocate connector\n");
>>> - return NULL;
>>> - }
>>> -
>>> - connector->polled = DRM_CONNECTOR_POLL_HPD;
>>> -
>>> - err = drm_connector_init(ddev, connector, <dc_rgb_connector_funcs,
>>> - DRM_MODE_CONNECTOR_DPI);
>>> - if (err) {
>>> - DRM_ERROR("Failed to initialize connector\n");
>>> - return NULL;
>>> - }
>>> -
>>> - drm_connector_helper_add(connector, <dc_rgb_connector_helper_funcs);
>>> -
>>> - DRM_DEBUG_DRIVER("RGB connector:%d created\n", connector->base.id);
>>> -
>>> - return connector;
>>> -}
>>> -
>>> static int ltdc_get_caps(struct drm_device *ddev)
>>> {
>>> struct ltdc_device *ldev = ddev->dev_private;
>>> @@ -972,7 +881,7 @@ static int ltdc_get_caps(struct drm_device *ddev)
>>> return 0;
>>> }
>>>
>>> -static struct drm_panel *ltdc_get_panel(struct drm_device *ddev)
>>> +static struct drm_bridge *ltdc_get_bridge(struct drm_device *ddev)
>>> {
>>> struct device *dev = ddev->dev;
>>> struct device_node *np = dev->of_node;
>>> @@ -1004,7 +913,10 @@ static struct drm_panel *ltdc_get_panel(struct drm_device *ddev)
>>> }
>>> }
>>>
>>> - return panel;
>>> + if (!panel)
>>> + return ERR_PTR(-ENODEV);
>>> +
>>> + return drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI);
>>> }
>>>
>>> int ltdc_load(struct drm_device *ddev)
>>> @@ -1014,7 +926,6 @@ int ltdc_load(struct drm_device *ddev)
>>> struct device *dev = ddev->dev;
>>> struct device_node *np = dev->of_node;
>>> struct drm_encoder *encoder;
>>> - struct drm_connector *connector = NULL;
>>> struct drm_crtc *crtc;
>>> struct reset_control *rstc;
>>> struct resource res;
>>> @@ -1022,8 +933,8 @@ int ltdc_load(struct drm_device *ddev)
>>>
>>> DRM_DEBUG_DRIVER("\n");
>>>
>>> - ldev->panel = ltdc_get_panel(ddev);
>>> - if (!ldev->panel)
>>> + ldev->bridge = ltdc_get_bridge(ddev);
>>> + if (!ldev->bridge)
>>> return -EPROBE_DEFER;
>>>
>>> rstc = of_reset_control_get(np, NULL);
>>> @@ -1082,28 +993,13 @@ int ltdc_load(struct drm_device *ddev)
>>>
>>> DRM_INFO("ltdc hw version 0x%08x - ready\n", ldev->caps.hw_version);
>>>
>>> - if (ldev->panel) {
>>> + if (ldev->bridge) {
>>> encoder = ltdc_rgb_encoder_create(ddev);
>>> if (!encoder) {
>>> DRM_ERROR("Failed to create RGB encoder\n");
>>> ret = -EINVAL;
>>> goto err;
>>> }
>>> -
>>> - connector = ltdc_rgb_connector_create(ddev);
>>> - if (!connector) {
>>> - DRM_ERROR("Failed to create RGB connector\n");
>>> - ret = -EINVAL;
>>> - goto err;
>>> - }
>>> -
>>> - ret = drm_mode_connector_attach_encoder(connector, encoder);
>>> - if (ret) {
>>> - DRM_ERROR("Failed to attach connector to encoder\n");
>>> - goto err;
>>> - }
>>> -
>>> - drm_panel_attach(ldev->panel, connector);
>>> }
>>>
>>> crtc = devm_kzalloc(dev, sizeof(*crtc), GFP_KERNEL);
>>> @@ -1130,8 +1026,8 @@ int ltdc_load(struct drm_device *ddev)
>>>
>>> return 0;
>>> err:
>>> - if (ldev->panel)
>>> - drm_panel_detach(ldev->panel);
>>> + if (ldev->bridge)
>>> + drm_panel_bridge_remove(ldev->bridge);
>>>
>>> clk_disable_unprepare(ldev->pixel_clk);
>>>
>>> @@ -1146,8 +1042,8 @@ void ltdc_unload(struct drm_device *ddev)
>>>
>>> drm_vblank_cleanup(ddev);
>>>
>>> - if (ldev->panel)
>>> - drm_panel_detach(ldev->panel);
>>> + if (ldev->bridge)
>>> + drm_panel_bridge_remove(ldev->bridge);
>>>
>>> clk_disable_unprepare(ldev->pixel_clk);
>>> }
>>> diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
>>> index d7a9c736ac1e..d78cb0dd3200 100644
>>> --- a/drivers/gpu/drm/stm/ltdc.h
>>> +++ b/drivers/gpu/drm/stm/ltdc.h
>>> @@ -24,7 +24,7 @@ struct ltdc_device {
>>> struct drm_fbdev_cma *fbdev;
>>> void __iomem *regs;
>>> struct clk *pixel_clk; /* lcd pixel clock */
>>> - struct drm_panel *panel;
>>> + struct drm_bridge *bridge;
>>> struct mutex err_lock; /* protecting error_status */
>>> struct ltdc_caps caps;
>>> u32 clut[256]; /* color look up table */
>>>
>
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2017-05-31 8:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-11 18:31 [PATCH v2 1/7] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge Eric Anholt
2017-05-11 18:31 ` [PATCH v2 2/7] drm/vc4: Switch DSI to the panel-bridge layer, and support bridges Eric Anholt
2017-05-12 8:02 ` Boris Brezillon
2017-05-11 18:31 ` [PATCH v2 3/7] drm/vc4: Switch DPI to using the panel-bridge helper Eric Anholt
2017-05-12 8:04 ` Boris Brezillon
2017-05-11 18:31 ` [PATCH v2 4/7] drm/mediatek: Use " Eric Anholt
2017-05-12 8:07 ` Boris Brezillon
2017-05-11 18:31 ` [PATCH v2 5/7] drm/ltdc: " Eric Anholt
2017-05-12 8:17 ` Boris Brezillon
2017-05-30 16:55 ` Philippe CORNU
2017-05-31 6:26 ` Boris Brezillon
2017-05-31 8:01 ` Archit Taneja [this message]
2017-05-31 8:07 ` Boris Brezillon
2017-05-31 8:35 ` Archit Taneja
2017-06-01 9:53 ` Philippe CORNU
2017-05-11 18:31 ` [PATCH v2 6/7] drm/atmel-hlcdc: Drop custom encoder cleanup func Eric Anholt
2017-05-11 19:15 ` Boris Brezillon
2017-05-11 18:31 ` [PATCH v2 7/7] drm/atmel-hlcdc: Replace the panel usage with drm_panel_bridge Eric Anholt
2017-05-11 19:15 ` Boris Brezillon
2017-05-12 7:35 ` Daniel Vetter
2017-06-05 15:36 ` Archit Taneja
2017-06-06 8:57 ` Boris Brezillon
2017-06-06 10:15 ` Archit Taneja
2017-05-12 7:33 ` [PATCH v2 1/7] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge Boris Brezillon
2017-05-12 10:15 ` Archit Taneja
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=b2be18f4-eb2b-c47c-744a-0f4f85e17ce1@codeaurora.org \
--to=architt@codeaurora.org \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a.hajda@samsung.com \
--cc=boris.brezillon@free-electrons.com \
--cc=ck.hu@mediatek.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=eric@anholt.net \
--cc=linux-kernel@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=philippe.cornu@st.com \
--cc=yannick.fertre@st.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
Powered by JetHome