All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Keith Zhao <keith.zhao@starfivetech.com>
Cc: Alex Bee <knaerzche@gmail.com>,
	"andrzej.hajda@intel.com" <andrzej.hajda@intel.com>,
	"neil.armstrong@linaro.org" <neil.armstrong@linaro.org>,
	"rfoss@kernel.org" <rfoss@kernel.org>,
	"jonas@kwiboo.se" <jonas@kwiboo.se>,
	"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>,
	"maarten.lankhorst@linux.intel.com"
	<maarten.lankhorst@linux.intel.com>,
	"mripard@kernel.org" <mripard@kernel.org>,
	"tzimmermann@suse.de" <tzimmermann@suse.de>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"robh@kernel.org" <robh@kernel.org>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"hjc@rock-chips.com" <hjc@rock-chips.com>,
	"heiko@sntech.de" <heiko@sntech.de>,
	"andy.yan@rock-chips.com" <andy.yan@rock-chips.com>,
	Xingyu Wu <xingyu.wu@starfivetech.com>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	Jack Zhu <jack.zhu@starfivetech.com>,
	Shengyang Chen <shengyang.chen@starfivetech.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v4 02/10] drm/bridge: add common api for inno hdmi
Date: Wed, 22 May 2024 10:32:53 +0300	[thread overview]
Message-ID: <20240522073253.GF8863@pendragon.ideasonboard.com> (raw)
In-Reply-To: <NTZPR01MB1050CA92FFE17AE1C9E38BF8EEEB2@NTZPR01MB1050.CHNPR01.prod.partner.outlook.cn>

Hi Keith,

On Wed, May 22, 2024 at 05:58:00AM +0000, Keith Zhao wrote:
> Hi Alex, Laurent:
> 
> I want to make as few changes as possible on the current basis, and add bridge_fun, 
> 
> On 2024年5月21日 23:42, Laurent Pinchart wrote:
> > On Tue, May 21, 2024 at 05:36:43PM +0200, Alex Bee wrote:
> > > Hi Keith,
> > >
> > > thanks a lot for working on this. See some general remarks below
> > >
> > > Am 21.05.24 um 12:58 schrieb keith:
> > > > Add INNO common api so that it can be used by vendor drivers which
> > > > implement vendor specific extensions to Innosilicon HDMI.
> > > >
> > > > Signed-off-by: keith <keith.zhao@starfivetech.com>
> > > > ---
> > > >   MAINTAINERS                                   |   2 +
> > > >   drivers/gpu/drm/bridge/Kconfig                |   2 +
> > > >   drivers/gpu/drm/bridge/Makefile               |   1 +
> > > >   drivers/gpu/drm/bridge/innosilicon/Kconfig    |   6 +
> > > >   drivers/gpu/drm/bridge/innosilicon/Makefile   |   2 +
> > > >   .../gpu/drm/bridge/innosilicon/inno-hdmi.c    | 587 ++++++++++++++++++
> > > >   .../gpu/drm/bridge/innosilicon/inno-hdmi.h    |  97 +++
> > > >   include/drm/bridge/inno_hdmi.h                |  69 ++
> > > >   8 files changed, 766 insertions(+)
> > > >   create mode 100644 drivers/gpu/drm/bridge/innosilicon/Kconfig
> > > >   create mode 100644 drivers/gpu/drm/bridge/innosilicon/Makefile
> > > >   create mode 100644 drivers/gpu/drm/bridge/innosilicon/inno-hdmi.c
> > > >   create mode 100644 drivers/gpu/drm/bridge/innosilicon/inno-hdmi.h
> > > >   create mode 100644 include/drm/bridge/inno_hdmi.h
> > > >
> > > ....
> > >
> > > > +	drm_encoder_helper_add(encoder, pdata->helper_private);
> > > > +
> > > > +	hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD;
> > > > +
> > > > +	drm_connector_helper_add(&hdmi->connector,
> > > > +				 &inno_hdmi_connector_helper_funcs);
> > > > +
> > > > +	drmm_connector_init(drm, &hdmi->connector,
> > > > +			    &inno_hdmi_connector_funcs,
> > > > +			    DRM_MODE_CONNECTOR_HDMIA,
> > > > +			    hdmi->ddc);
> > > > +
> > >
> > > I really don't want to anticipate bridge maintainer's feedback, but
> > > new bridge drivers must not contain connector creation. That must
> > > happen somewhere else.
> > 
> > You're absolutely right :-) Connector creation should be handled by the
> > drm_bridge_connector helper. The HDMI bridge driver should focus on the
> > HDMI bridge itself.
> 
> static int inno_bridge_attach(struct drm_bridge *bridge,
> 				 enum drm_bridge_attach_flags flags)
> {
> 	struct inno_hdmi *hdmi = bridge_to_inno(bridge);
> 
> 	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
> 		DRM_ERROR("Fix bridge driver to make connector optional!");
> 		return -EINVAL;
> 	}

This kind of code was added to existing bridge drivers when we
transitioned to the new model where bridges don't create the connectors,
because we couldn't fix all the existing bridges in one go. New bridges
must do the opposite. See imx8qxp-pixel-link.c for instance, it has this
code instead in its attach function:

	if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
		DRM_DEV_ERROR(pl->dev,
			      "do not support creating a drm_connector\n");
		return -EINVAL;
	}

(I would personally drop the DRM_DEV_ERROR message)

> 	hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD;
> 
> 	drm_connector_helper_add(&hdmi->connector,
> 				 &inno_hdmi_connector_helper_funcs);
> 
> 	drmm_connector_init(drm, &hdmi->connector,
> 			    &inno_hdmi_connector_funcs,
> 			    DRM_MODE_CONNECTOR_HDMIA,
> 			    hdmi->ddc);
> 
> 	drm_connector_attach_encoder(&hdmi->connector, encoder);
> }
> 
> static const struct drm_bridge_funcs inno_bridge_attach = {
> 	.attach = inno_bridge_attach,
> };
> 
> Connector creation is handled by the drm_bridge_funcs ->attach.
> Is it ok?

No, the connector should be created by the display controller driver by
calling drm_brige_connector_init(). It should not be created by the
bridge driver. The bridge driver should provide the bridge functions
(drm_bridge_funcs), but not create any connector.

> > > Also I'm neither seeing any drm_brige struct nor drm_bridge_funcs,
> > > which are both essential for a bridge driver. I don't think moving a
> > > part of a driver to .../drm/bridge/ makes it a bridge driver.
> > >
> > > > +	drm_connector_attach_encoder(&hdmi->connector, encoder);
> > > > +
> > > > +	return 0;
> > > > +}
> > > > +
> > > ....
> > >

-- 
Regards,

Laurent Pinchart

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Keith Zhao <keith.zhao@starfivetech.com>
Cc: Alex Bee <knaerzche@gmail.com>,
	"andrzej.hajda@intel.com" <andrzej.hajda@intel.com>,
	"neil.armstrong@linaro.org" <neil.armstrong@linaro.org>,
	"rfoss@kernel.org" <rfoss@kernel.org>,
	"jonas@kwiboo.se" <jonas@kwiboo.se>,
	"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>,
	"maarten.lankhorst@linux.intel.com"
	<maarten.lankhorst@linux.intel.com>,
	"mripard@kernel.org" <mripard@kernel.org>,
	"tzimmermann@suse.de" <tzimmermann@suse.de>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"robh@kernel.org" <robh@kernel.org>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"hjc@rock-chips.com" <hjc@rock-chips.com>,
	"heiko@sntech.de" <heiko@sntech.de>,
	"andy.yan@rock-chips.com" <andy.yan@rock-chips.com>,
	Xingyu Wu <xingyu.wu@starfivetech.com>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	Jack Zhu <jack.zhu@starfivetech.com>,
	Shengyang Chen <shengyang.chen@starfivetech.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v4 02/10] drm/bridge: add common api for inno hdmi
Date: Wed, 22 May 2024 10:32:53 +0300	[thread overview]
Message-ID: <20240522073253.GF8863@pendragon.ideasonboard.com> (raw)
In-Reply-To: <NTZPR01MB1050CA92FFE17AE1C9E38BF8EEEB2@NTZPR01MB1050.CHNPR01.prod.partner.outlook.cn>

Hi Keith,

On Wed, May 22, 2024 at 05:58:00AM +0000, Keith Zhao wrote:
> Hi Alex, Laurent:
> 
> I want to make as few changes as possible on the current basis, and add bridge_fun, 
> 
> On 2024年5月21日 23:42, Laurent Pinchart wrote:
> > On Tue, May 21, 2024 at 05:36:43PM +0200, Alex Bee wrote:
> > > Hi Keith,
> > >
> > > thanks a lot for working on this. See some general remarks below
> > >
> > > Am 21.05.24 um 12:58 schrieb keith:
> > > > Add INNO common api so that it can be used by vendor drivers which
> > > > implement vendor specific extensions to Innosilicon HDMI.
> > > >
> > > > Signed-off-by: keith <keith.zhao@starfivetech.com>
> > > > ---
> > > >   MAINTAINERS                                   |   2 +
> > > >   drivers/gpu/drm/bridge/Kconfig                |   2 +
> > > >   drivers/gpu/drm/bridge/Makefile               |   1 +
> > > >   drivers/gpu/drm/bridge/innosilicon/Kconfig    |   6 +
> > > >   drivers/gpu/drm/bridge/innosilicon/Makefile   |   2 +
> > > >   .../gpu/drm/bridge/innosilicon/inno-hdmi.c    | 587 ++++++++++++++++++
> > > >   .../gpu/drm/bridge/innosilicon/inno-hdmi.h    |  97 +++
> > > >   include/drm/bridge/inno_hdmi.h                |  69 ++
> > > >   8 files changed, 766 insertions(+)
> > > >   create mode 100644 drivers/gpu/drm/bridge/innosilicon/Kconfig
> > > >   create mode 100644 drivers/gpu/drm/bridge/innosilicon/Makefile
> > > >   create mode 100644 drivers/gpu/drm/bridge/innosilicon/inno-hdmi.c
> > > >   create mode 100644 drivers/gpu/drm/bridge/innosilicon/inno-hdmi.h
> > > >   create mode 100644 include/drm/bridge/inno_hdmi.h
> > > >
> > > ....
> > >
> > > > +	drm_encoder_helper_add(encoder, pdata->helper_private);
> > > > +
> > > > +	hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD;
> > > > +
> > > > +	drm_connector_helper_add(&hdmi->connector,
> > > > +				 &inno_hdmi_connector_helper_funcs);
> > > > +
> > > > +	drmm_connector_init(drm, &hdmi->connector,
> > > > +			    &inno_hdmi_connector_funcs,
> > > > +			    DRM_MODE_CONNECTOR_HDMIA,
> > > > +			    hdmi->ddc);
> > > > +
> > >
> > > I really don't want to anticipate bridge maintainer's feedback, but
> > > new bridge drivers must not contain connector creation. That must
> > > happen somewhere else.
> > 
> > You're absolutely right :-) Connector creation should be handled by the
> > drm_bridge_connector helper. The HDMI bridge driver should focus on the
> > HDMI bridge itself.
> 
> static int inno_bridge_attach(struct drm_bridge *bridge,
> 				 enum drm_bridge_attach_flags flags)
> {
> 	struct inno_hdmi *hdmi = bridge_to_inno(bridge);
> 
> 	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
> 		DRM_ERROR("Fix bridge driver to make connector optional!");
> 		return -EINVAL;
> 	}

This kind of code was added to existing bridge drivers when we
transitioned to the new model where bridges don't create the connectors,
because we couldn't fix all the existing bridges in one go. New bridges
must do the opposite. See imx8qxp-pixel-link.c for instance, it has this
code instead in its attach function:

	if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
		DRM_DEV_ERROR(pl->dev,
			      "do not support creating a drm_connector\n");
		return -EINVAL;
	}

(I would personally drop the DRM_DEV_ERROR message)

> 	hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD;
> 
> 	drm_connector_helper_add(&hdmi->connector,
> 				 &inno_hdmi_connector_helper_funcs);
> 
> 	drmm_connector_init(drm, &hdmi->connector,
> 			    &inno_hdmi_connector_funcs,
> 			    DRM_MODE_CONNECTOR_HDMIA,
> 			    hdmi->ddc);
> 
> 	drm_connector_attach_encoder(&hdmi->connector, encoder);
> }
> 
> static const struct drm_bridge_funcs inno_bridge_attach = {
> 	.attach = inno_bridge_attach,
> };
> 
> Connector creation is handled by the drm_bridge_funcs ->attach.
> Is it ok?

No, the connector should be created by the display controller driver by
calling drm_brige_connector_init(). It should not be created by the
bridge driver. The bridge driver should provide the bridge functions
(drm_bridge_funcs), but not create any connector.

> > > Also I'm neither seeing any drm_brige struct nor drm_bridge_funcs,
> > > which are both essential for a bridge driver. I don't think moving a
> > > part of a driver to .../drm/bridge/ makes it a bridge driver.
> > >
> > > > +	drm_connector_attach_encoder(&hdmi->connector, encoder);
> > > > +
> > > > +	return 0;
> > > > +}
> > > > +
> > > ....
> > >

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2024-05-22  7:33 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 10:58 [PATCH v4 00/10] drm/verisilicon : support DC8200 and inno hdmi keith
2024-05-21 10:58 ` keith
2024-05-21  7:18 ` Krzysztof Kozlowski
2024-05-21  7:18   ` Krzysztof Kozlowski
2024-05-21  8:03 ` Heiko Stübner
2024-05-21  8:03   ` Heiko Stübner
2024-05-21 14:55   ` Alex Bee
2024-05-21 14:55     ` Alex Bee
2024-05-21 10:58 ` [PATCH v4 01/10] dt-bindings: display: Add YAML schema for JH7110 display pipeline keith
2024-05-21 10:58   ` keith
2024-05-21  7:30   ` Krzysztof Kozlowski
2024-05-21  7:30     ` Krzysztof Kozlowski
2024-05-21  9:50     ` Keith Zhao
2024-05-21  9:50       ` Keith Zhao
2024-05-21 10:58 ` [PATCH v4 02/10] drm/bridge: add common api for inno hdmi keith
2024-05-21 10:58   ` keith
2024-05-21  9:30   ` Krzysztof Kozlowski
2024-05-21  9:30     ` Krzysztof Kozlowski
2024-05-21 15:36   ` Alex Bee
2024-05-21 15:36     ` Alex Bee
2024-05-21 15:42     ` Laurent Pinchart
2024-05-21 15:42       ` Laurent Pinchart
2024-05-22  5:58       ` Keith Zhao
2024-05-22  5:58         ` Keith Zhao
2024-05-22  7:32         ` Laurent Pinchart [this message]
2024-05-22  7:32           ` Laurent Pinchart
2024-06-23 18:42   ` Markus Elfring
2024-05-21 10:58 ` [PATCH v4 03/10] drm/rockchip:hdmi: migrate to use inno-hdmi bridge driver keith
2024-05-21 10:58   ` keith
2024-05-22  7:24   ` Maxime Ripard
2024-05-22  7:24     ` Maxime Ripard
2024-06-23  7:17     ` Keith Zhao
2024-06-24  9:25       ` Maxime Ripard
2024-05-21 10:58 ` [PATCH v4 04/10] drm/vs: Add hardware funcs for vs keith
2024-05-21 10:58   ` keith
2024-05-21 20:50   ` kernel test robot
2024-05-21 20:50     ` kernel test robot
2024-05-21 20:50   ` Dmitry Baryshkov
2024-05-21 20:50     ` Dmitry Baryshkov
2024-06-23  7:16     ` Keith Zhao
2024-06-23 20:51       ` Dmitry Baryshkov
2024-06-25  8:32         ` Keith Zhao
2024-05-21 21:01   ` kernel test robot
2024-05-21 21:01     ` kernel test robot
2024-05-22  1:34   ` kernel test robot
2024-05-22  1:34     ` kernel test robot
2024-05-21 10:58 ` [PATCH v4 05/10] drm/vs: add vs mode config init keith
2024-05-21 10:58   ` keith
2024-05-21 20:52   ` Dmitry Baryshkov
2024-05-21 20:52     ` Dmitry Baryshkov
2024-06-23  7:17     ` Keith Zhao
2024-06-23 20:52       ` Dmitry Baryshkov
2024-05-21 10:58 ` [PATCH v4 06/10] drm/vs: add vs plane api keith
2024-05-21 10:58   ` keith
2024-05-21 20:39   ` kernel test robot
2024-05-21 20:39     ` kernel test robot
2024-05-21 21:06   ` Dmitry Baryshkov
2024-05-21 21:06     ` Dmitry Baryshkov
2024-06-23  7:17     ` Keith Zhao
2024-06-23 20:54       ` Dmitry Baryshkov
2024-05-21 10:58 ` [PATCH v4 07/10] drm/vs: add ctrc fun keith
2024-05-21 10:58   ` keith
2024-05-21 21:08   ` Dmitry Baryshkov
2024-05-21 21:08     ` Dmitry Baryshkov
2024-06-23  7:17     ` Keith Zhao
2024-06-23 20:56       ` Dmitry Baryshkov
2024-05-21 10:58 ` [PATCH v4 08/10] drm/vs: add vs drm master driver keith
2024-05-21 10:58   ` keith
2024-05-21 21:14   ` Dmitry Baryshkov
2024-05-21 21:14     ` Dmitry Baryshkov
2024-06-23  7:16     ` Keith Zhao
2024-06-23 21:07       ` Dmitry Baryshkov
2024-06-25  8:34         ` Keith Zhao
2024-05-21 10:58 ` [PATCH v4 09/10] drm/vs: Innosilicon HDMI support keith
2024-05-21 10:58   ` keith
2024-05-21  9:31   ` Krzysztof Kozlowski
2024-05-21  9:31     ` Krzysztof Kozlowski
2024-05-21 10:58 ` [PATCH v4 10/10] drm/vs: add simple dsi encoder keith
2024-05-21 10:58   ` keith
2024-05-21 15:25   ` Dmitry Baryshkov
2024-05-21 15:25     ` Dmitry Baryshkov
2024-06-23  7:17     ` Keith Zhao
2024-06-23 21:11       ` Dmitry Baryshkov
2024-06-25  8:33         ` Keith Zhao
2024-06-25 10:59           ` Dmitry Baryshkov
2024-05-22  7:29   ` Maxime Ripard
2024-05-22  7:29     ` Maxime Ripard

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=20240522073253.GF8863@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=andy.yan@rock-chips.com \
    --cc=conor+dt@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=jack.zhu@starfivetech.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=keith.zhao@starfivetech.com \
    --cc=knaerzche@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=p.zabel@pengutronix.de \
    --cc=rfoss@kernel.org \
    --cc=robh@kernel.org \
    --cc=shengyang.chen@starfivetech.com \
    --cc=tzimmermann@suse.de \
    --cc=xingyu.wu@starfivetech.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 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.