All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sui Jingfeng <sui.jingfeng@linux.dev>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
	Sui Jingfeng <suijingfeng@loongson.cn>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Phong LE <ple@baylibre.com>, Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH 8/8] drm/bridge: it66121: Allow link this driver as a lib
Date: Thu, 16 Nov 2023 18:12:55 +0800	[thread overview]
Message-ID: <121163c9-0d56-47ad-a12e-e67390fef2b4@linux.dev> (raw)
In-Reply-To: <CAA8EJpom5kAbDkacOdqp6BR7YPfmCSXaQfDYRVcLf9eGmi64CQ@mail.gmail.com>

Hi,


On 2023/11/16 17:30, Dmitry Baryshkov wrote:
> On Thu, 16 Nov 2023 at 11:14, Sui Jingfeng <sui.jingfeng@linux.dev> wrote:
>> Hi,
>>
>> Thanks a lot for reviewing!
>>
>>
>> On 2023/11/15 00:30, Dmitry Baryshkov wrote:
>>> On Tue, 14 Nov 2023 at 17:09, Sui Jingfeng <sui.jingfeng@linux.dev> wrote:
>>>> From: Sui Jingfeng <suijingfeng@loongson.cn>
>>>>
>>>> The it66121_create_bridge() and it66121_destroy_bridge() are added to
>>>> export the core functionalities. Create a connector manually by using
>>>> bridge connector helpers when link as a lib.
>>>>
>>>> Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
>>>> ---
>>>>    drivers/gpu/drm/bridge/ite-it66121.c | 134 +++++++++++++++++++--------
>>>>    include/drm/bridge/ite-it66121.h     |  17 ++++
>>>>    2 files changed, 113 insertions(+), 38 deletions(-)
>>>>    create mode 100644 include/drm/bridge/ite-it66121.h
>>>>
>>>> diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
>>>> index 8971414a2a60..f5968b679c5d 100644
>>>> --- a/drivers/gpu/drm/bridge/ite-it66121.c
>>>> +++ b/drivers/gpu/drm/bridge/ite-it66121.c
>>>> @@ -22,6 +22,7 @@
>>>>
>>>>    #include <drm/drm_atomic_helper.h>
>>>>    #include <drm/drm_bridge.h>
>>>> +#include <drm/drm_bridge_connector.h>
>>>>    #include <drm/drm_edid.h>
>>>>    #include <drm/drm_modes.h>
>>>>    #include <drm/drm_print.h>
>>>> @@ -703,14 +704,32 @@ static int it66121_bridge_attach(struct drm_bridge *bridge,
>>>>                                    enum drm_bridge_attach_flags flags)
>>>>    {
>>>>           struct it66121_ctx *ctx = bridge_to_it66121(bridge);
>>>> +       struct drm_bridge *next_bridge = ctx->next_bridge;
>>>> +       struct drm_encoder *encoder = bridge->encoder;
>>>>           int ret;
>>>>
>>>> -       if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
>>>> -               return -EINVAL;
>>>> +       if (next_bridge) {
>>>> +               if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
>>>> +                       WARN_ON(1);
>>> Why? At least use WARN() instead
>> Originally I want to
>>
>>
>>
>>
>>>> +                       flags |= DRM_BRIDGE_ATTACH_NO_CONNECTOR;
>>>> +               }
>>>> +               ret = drm_bridge_attach(encoder, next_bridge, bridge, flags);
>>>> +               if (ret)
>>>> +                       return ret;
>>>> +       } else {
>>>> +               struct drm_connector *connector;
>>>>
>>>> -       ret = drm_bridge_attach(bridge->encoder, ctx->next_bridge, bridge, flags);
>>>> -       if (ret)
>>>> -               return ret;
>>>> +               if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
>>>> +                       WARN_ON(1);
>>> No. It is perfectly fine to create attach a bridge with no next_bridge
>>> and with the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
>>>
>> The document say when DRM_BRIDGE_ATTACH_NO_CONNECTOR flag is set
>> the bridge shall not create a drm_connector. So I think if a display
>> bridge driver don't have a next bridge attached (Currently, this is
>> told by the DT), it says that this is a non-DT environment. On such
>> a case, this display bridge driver(it66121.ko) should behavior like
>> a *agent*. Because the upstream port of it66121 is the DVO port of
>> the display controller, the downstream port of it66121 is the HDMI
>> connector. it66121 is on the middle. So I think the it66121.ko should
>> handle all of troubles on behalf of the display controller drivers.
> No. Don't make decisions for the other drivers. They might have different needs.

[...]


>
>> Therefore (when in non-DT use case), the display controller drivers
>> side should not set DRM_BRIDGE_ATTACH_NO_CONNECTOR flag anymore.
>> Which is to hint that the it66121 should totally in charge of those
>> tasks (either by using bridge connector helper or create a connector
>> manually). I don't understand on such a case, why bother display
>> controller drivers anymore.
> This is the reason why we had introduced this flag. It allows the
> driver to customise the connector. It even allows the driver to
> implement a connector on its own, completely ignoring the
> drm_bridge_connector.


I know what you said is right in the sense of the universe cases,
but I think the most frequent(majority) use case is that there is
only one display bridge on the middle. Therefore, I don't want to
movethe connector things into device driver if there is only one display 
bridge(say it66121) in the middle. After all, there is no *direct 
physical connection* from the perspective of the hardware. I means that 
there is no hardware wires connectthe HDMI connector and the DVO port. So display controller drivers 
should not interact with anything related with the connector on a 
perfect abstract on the software side. Especially for such a simple use 
case. It probably make senses to make a  decision for themost frequently use case, please also note
that this patch didn't introduce any-restriction for the more advance
uses cases(multiple bridges in the middle).


>>
>>>> +
>>>> +               connector = drm_bridge_connector_init(bridge->dev, encoder);
>>>> +               if (IS_ERR(connector))
>>>> +                       return PTR_ERR(connector);
>>>> +
>>>> +               drm_connector_attach_encoder(connector, encoder);
>>> This goes into your device driver.
>>>
>>>> +
>>>> +               ctx->connector = connector;
>>>> +       }
>>>>
>>>>           if (ctx->info->id == ID_IT66121) {
>>>>                   ret = regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
>>>> @@ -1632,16 +1651,13 @@ static const char * const it66121_supplies[] = {
>>>>           "vcn33", "vcn18", "vrf12"
>>>>    };
>
>

WARNING: multiple messages have this Message-ID (diff)
From: Sui Jingfeng <sui.jingfeng@linux.dev>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Phong LE <ple@baylibre.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Maxime Ripard <mripard@kernel.org>,
	Sui Jingfeng <suijingfeng@loongson.cn>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: Re: [PATCH 8/8] drm/bridge: it66121: Allow link this driver as a lib
Date: Thu, 16 Nov 2023 18:12:55 +0800	[thread overview]
Message-ID: <121163c9-0d56-47ad-a12e-e67390fef2b4@linux.dev> (raw)
In-Reply-To: <CAA8EJpom5kAbDkacOdqp6BR7YPfmCSXaQfDYRVcLf9eGmi64CQ@mail.gmail.com>

Hi,


On 2023/11/16 17:30, Dmitry Baryshkov wrote:
> On Thu, 16 Nov 2023 at 11:14, Sui Jingfeng <sui.jingfeng@linux.dev> wrote:
>> Hi,
>>
>> Thanks a lot for reviewing!
>>
>>
>> On 2023/11/15 00:30, Dmitry Baryshkov wrote:
>>> On Tue, 14 Nov 2023 at 17:09, Sui Jingfeng <sui.jingfeng@linux.dev> wrote:
>>>> From: Sui Jingfeng <suijingfeng@loongson.cn>
>>>>
>>>> The it66121_create_bridge() and it66121_destroy_bridge() are added to
>>>> export the core functionalities. Create a connector manually by using
>>>> bridge connector helpers when link as a lib.
>>>>
>>>> Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
>>>> ---
>>>>    drivers/gpu/drm/bridge/ite-it66121.c | 134 +++++++++++++++++++--------
>>>>    include/drm/bridge/ite-it66121.h     |  17 ++++
>>>>    2 files changed, 113 insertions(+), 38 deletions(-)
>>>>    create mode 100644 include/drm/bridge/ite-it66121.h
>>>>
>>>> diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
>>>> index 8971414a2a60..f5968b679c5d 100644
>>>> --- a/drivers/gpu/drm/bridge/ite-it66121.c
>>>> +++ b/drivers/gpu/drm/bridge/ite-it66121.c
>>>> @@ -22,6 +22,7 @@
>>>>
>>>>    #include <drm/drm_atomic_helper.h>
>>>>    #include <drm/drm_bridge.h>
>>>> +#include <drm/drm_bridge_connector.h>
>>>>    #include <drm/drm_edid.h>
>>>>    #include <drm/drm_modes.h>
>>>>    #include <drm/drm_print.h>
>>>> @@ -703,14 +704,32 @@ static int it66121_bridge_attach(struct drm_bridge *bridge,
>>>>                                    enum drm_bridge_attach_flags flags)
>>>>    {
>>>>           struct it66121_ctx *ctx = bridge_to_it66121(bridge);
>>>> +       struct drm_bridge *next_bridge = ctx->next_bridge;
>>>> +       struct drm_encoder *encoder = bridge->encoder;
>>>>           int ret;
>>>>
>>>> -       if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
>>>> -               return -EINVAL;
>>>> +       if (next_bridge) {
>>>> +               if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
>>>> +                       WARN_ON(1);
>>> Why? At least use WARN() instead
>> Originally I want to
>>
>>
>>
>>
>>>> +                       flags |= DRM_BRIDGE_ATTACH_NO_CONNECTOR;
>>>> +               }
>>>> +               ret = drm_bridge_attach(encoder, next_bridge, bridge, flags);
>>>> +               if (ret)
>>>> +                       return ret;
>>>> +       } else {
>>>> +               struct drm_connector *connector;
>>>>
>>>> -       ret = drm_bridge_attach(bridge->encoder, ctx->next_bridge, bridge, flags);
>>>> -       if (ret)
>>>> -               return ret;
>>>> +               if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
>>>> +                       WARN_ON(1);
>>> No. It is perfectly fine to create attach a bridge with no next_bridge
>>> and with the DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.
>>>
>> The document say when DRM_BRIDGE_ATTACH_NO_CONNECTOR flag is set
>> the bridge shall not create a drm_connector. So I think if a display
>> bridge driver don't have a next bridge attached (Currently, this is
>> told by the DT), it says that this is a non-DT environment. On such
>> a case, this display bridge driver(it66121.ko) should behavior like
>> a *agent*. Because the upstream port of it66121 is the DVO port of
>> the display controller, the downstream port of it66121 is the HDMI
>> connector. it66121 is on the middle. So I think the it66121.ko should
>> handle all of troubles on behalf of the display controller drivers.
> No. Don't make decisions for the other drivers. They might have different needs.

[...]


>
>> Therefore (when in non-DT use case), the display controller drivers
>> side should not set DRM_BRIDGE_ATTACH_NO_CONNECTOR flag anymore.
>> Which is to hint that the it66121 should totally in charge of those
>> tasks (either by using bridge connector helper or create a connector
>> manually). I don't understand on such a case, why bother display
>> controller drivers anymore.
> This is the reason why we had introduced this flag. It allows the
> driver to customise the connector. It even allows the driver to
> implement a connector on its own, completely ignoring the
> drm_bridge_connector.


I know what you said is right in the sense of the universe cases,
but I think the most frequent(majority) use case is that there is
only one display bridge on the middle. Therefore, I don't want to
movethe connector things into device driver if there is only one display 
bridge(say it66121) in the middle. After all, there is no *direct 
physical connection* from the perspective of the hardware. I means that 
there is no hardware wires connectthe HDMI connector and the DVO port. So display controller drivers 
should not interact with anything related with the connector on a 
perfect abstract on the software side. Especially for such a simple use 
case. It probably make senses to make a  decision for themost frequently use case, please also note
that this patch didn't introduce any-restriction for the more advance
uses cases(multiple bridges in the middle).


>>
>>>> +
>>>> +               connector = drm_bridge_connector_init(bridge->dev, encoder);
>>>> +               if (IS_ERR(connector))
>>>> +                       return PTR_ERR(connector);
>>>> +
>>>> +               drm_connector_attach_encoder(connector, encoder);
>>> This goes into your device driver.
>>>
>>>> +
>>>> +               ctx->connector = connector;
>>>> +       }
>>>>
>>>>           if (ctx->info->id == ID_IT66121) {
>>>>                   ret = regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
>>>> @@ -1632,16 +1651,13 @@ static const char * const it66121_supplies[] = {
>>>>           "vcn33", "vcn18", "vrf12"
>>>>    };
>
>

  reply	other threads:[~2023-11-16 10:13 UTC|newest]

Thread overview: 127+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14 15:01 [PATCH 0/8] Allow link the it66121 display bridge driver as a lib Sui Jingfeng
2023-11-14 15:01 ` Sui Jingfeng
2023-11-14 15:01 ` [PATCH 1/8] drm/bridge: it66121: Use dev replace ctx->dev in the it66121_probe() Sui Jingfeng
2023-11-14 15:01   ` Sui Jingfeng
2023-11-14 16:01   ` Dmitry Baryshkov
2023-11-14 16:01     ` Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 2/8] drm/bridge: it66121: Add bridge_to_it66121() helper and use it Sui Jingfeng
2023-11-14 15:01   ` Sui Jingfeng
2023-11-14 16:01   ` Dmitry Baryshkov
2023-11-14 16:01     ` Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 3/8] drm/bridge: it66121: Add a helper function to read bus width Sui Jingfeng
2023-11-14 15:01   ` Sui Jingfeng
2023-11-14 16:03   ` Dmitry Baryshkov
2023-11-14 16:03     ` Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 4/8] drm/bridge: it66121: Add a helper function to get the next bridge Sui Jingfeng
2023-11-14 15:01   ` Sui Jingfeng
2023-11-14 16:05   ` Dmitry Baryshkov
2023-11-14 16:05     ` Dmitry Baryshkov
2023-11-23  5:25     ` Sui Jingfeng
2023-11-23  5:25       ` Sui Jingfeng
2023-11-23  7:54       ` Dmitry Baryshkov
2023-11-23  7:54         ` Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 5/8] drm/bridge: it66121: Add a helper function to read chip id Sui Jingfeng
2023-11-14 15:01   ` Sui Jingfeng
2023-11-14 16:06   ` Dmitry Baryshkov
2023-11-14 16:06     ` Dmitry Baryshkov
2023-11-16 12:18     ` Sui Jingfeng
2023-11-16 12:18       ` Sui Jingfeng
2023-11-16 13:00       ` Dmitry Baryshkov
2023-11-16 13:00         ` Dmitry Baryshkov
2023-11-16 18:29         ` Sui Jingfeng
2023-11-16 18:29           ` Sui Jingfeng
2023-11-16 22:00           ` Dmitry Baryshkov
2023-11-16 22:00             ` Dmitry Baryshkov
2023-11-23  5:37         ` Sui Jingfeng
2023-11-23  5:37           ` Sui Jingfeng
2023-11-23  7:48           ` Dmitry Baryshkov
2023-11-23  7:48             ` Dmitry Baryshkov
2023-11-23 13:03             ` Sui Jingfeng
2023-11-23 13:03               ` Sui Jingfeng
2023-11-14 15:01 ` [PATCH 6/8] drm/bridge: it66121: Add a helper to initialize the DRM bridge structure Sui Jingfeng
2023-11-14 15:01   ` Sui Jingfeng
2023-11-14 16:10   ` Dmitry Baryshkov
2023-11-14 16:10     ` Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 7/8] drm/bridge: it66121: Add another implementation for getting match data Sui Jingfeng
2023-11-14 15:01   ` Sui Jingfeng
2023-11-14 16:00   ` Dmitry Baryshkov
2023-11-14 16:00     ` Dmitry Baryshkov
2023-11-14 15:01 ` [PATCH 8/8] drm/bridge: it66121: Allow link this driver as a lib Sui Jingfeng
2023-11-14 15:01   ` Sui Jingfeng
2023-11-14 16:30   ` Dmitry Baryshkov
2023-11-14 16:30     ` Dmitry Baryshkov
2023-11-16  9:14     ` Sui Jingfeng
2023-11-16  9:14       ` Sui Jingfeng
2023-11-16  9:30       ` Dmitry Baryshkov
2023-11-16  9:30         ` Dmitry Baryshkov
2023-11-16 10:12         ` Sui Jingfeng [this message]
2023-11-16 10:12           ` Sui Jingfeng
2023-11-16 11:19           ` Dmitry Baryshkov
2023-11-16 11:19             ` Dmitry Baryshkov
2023-11-23  5:05             ` Sui Jingfeng
2023-11-23  5:05               ` Sui Jingfeng
2023-11-23  8:08               ` Dmitry Baryshkov
2023-11-23  8:08                 ` Dmitry Baryshkov
2023-11-23 13:39                 ` Neil Armstrong
2023-11-23 13:39                   ` Neil Armstrong
2023-11-23 16:20                   ` Sui Jingfeng
2023-11-23 16:20                     ` Sui Jingfeng
2023-11-23 15:41                 ` Sui Jingfeng
2023-11-23 15:41                   ` Sui Jingfeng
2023-11-23 16:06                   ` Dmitry Baryshkov
2023-11-23 16:06                     ` Dmitry Baryshkov
2023-11-23 16:29                     ` Sui Jingfeng
2023-11-23 16:29                       ` Sui Jingfeng
2023-11-23 17:04                 ` Sui Jingfeng
2023-11-23 17:04                   ` Sui Jingfeng
2023-11-23 17:39                   ` Dmitry Baryshkov
2023-11-23 17:39                     ` Dmitry Baryshkov
2023-11-23 17:52                 ` Sui Jingfeng
2023-11-23 17:52                   ` Sui Jingfeng
2023-11-24  7:38                   ` Maxime Ripard
2023-11-24  7:38                     ` Maxime Ripard
2023-11-24  7:51                     ` Sui Jingfeng
2023-11-24  7:51                       ` Sui Jingfeng
2023-11-24  8:13                       ` Maxime Ripard
2023-11-24  8:13                         ` Maxime Ripard
2023-11-24  8:48                         ` Sui Jingfeng
2023-11-24  8:48                           ` Sui Jingfeng
2023-11-25  2:30                         ` Sui Jingfeng
2023-11-25  2:30                           ` Sui Jingfeng
2023-11-16 10:29     ` Sui Jingfeng
2023-11-16 10:29       ` Sui Jingfeng
2023-11-16 11:11       ` Dmitry Baryshkov
2023-11-16 11:11         ` Dmitry Baryshkov
2023-11-16 11:15         ` Jani Nikula
2023-11-16 11:18     ` Sui Jingfeng
2023-11-16 11:18       ` Sui Jingfeng
2023-11-16 11:29       ` Dmitry Baryshkov
2023-11-16 11:29         ` Dmitry Baryshkov
2023-11-16 11:53         ` Sui Jingfeng
2023-11-16 11:53           ` Sui Jingfeng
2023-11-16 12:07           ` Sui Jingfeng
2023-11-16 12:07             ` Sui Jingfeng
2023-11-16 15:23             ` Dmitry Baryshkov
2023-11-16 15:23               ` Dmitry Baryshkov
2023-11-16 17:18               ` Sui Jingfeng
2023-11-16 17:18                 ` Sui Jingfeng
2023-11-17  9:52                 ` Maxime Ripard
2023-11-17  9:52                   ` Maxime Ripard
2023-11-17  4:24               ` Sui Jingfeng
2023-11-17  4:24                 ` Sui Jingfeng
2023-11-17  9:03                 ` Dmitry Baryshkov
2023-11-17  9:03                   ` Dmitry Baryshkov
2023-11-17 17:14                   ` Sui Jingfeng
2023-11-17 17:14                     ` Sui Jingfeng
2023-11-20  8:23                     ` Neil Armstrong
2023-11-20  8:23                       ` Neil Armstrong
2023-11-17 17:35                   ` Sui Jingfeng
2023-11-17 17:35                     ` Sui Jingfeng
2023-11-20 10:06                     ` Dmitry Baryshkov
2023-11-20 10:06                       ` Dmitry Baryshkov
2023-11-17 12:13                 ` Maxime Ripard
2023-11-17 12:13                   ` Maxime Ripard
2023-11-15 13:02   ` kernel test robot
2023-11-15 13:02     ` kernel test robot
2023-11-20  9:08   ` kernel test robot
2023-11-20  9:08     ` kernel test robot

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=121163c9-0d56-47ad-a12e-e67390fef2b4@linux.dev \
    --to=sui.jingfeng@linux.dev \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=ple@baylibre.com \
    --cc=suijingfeng@loongson.cn \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.