From: Martyn Welch <martyn.welch@collabora.co.uk>
To: Peter Senna Tschudin <peter.senna@collabora.com>,
robh+dt@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org,
kernel@pengutronix.de, fabio.estevam@nxp.com,
linux@armlinux.org.uk, airlied@linux.ie, p.zabel@pengutronix.de,
martin.donnelly@ge.com, peter.senna@gmail.com,
treding@nvidia.com, architt@codeaurora.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
dri-devel@lists.freedesktop.org
Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>,
Rob Herring <robh@kernel.org>,
Thierry Reding <thierry.reding@gmail.com>
Subject: Re: [PATCH V4 1/4] drm/imx-ldb: Add support to drm-bridge
Date: Tue, 16 Aug 2016 16:40:40 +0100 [thread overview]
Message-ID: <474dea2a-47c7-13ba-86c1-1184937351fb@collabora.co.uk> (raw)
In-Reply-To: <81f3fd13ea909e6442d6fde8693c8e991a2a50f8.1470346720.git.peter.senna@collabora.com>
On 04/08/16 23:36, Peter Senna Tschudin wrote:
> Add support to attach a drm_bridge to imx-ldb in addition to
> existing support to attach a LVDS panel.
>
> This patch does a simple code refactoring by moving code
> from for_each_child_of_node iterator to a new function named
> imx_ldb_panel_ddc(). This was necessary to allow the panel ddc
> code to run only when the imx_ldb is not attached to a bridge.
>
> Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Thierry Reding <treding@nvidia.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Signed-off-by: Peter Senna Tschudin <peter.senna@collabora.com>
Acked-by: Martyn Welch <martyn.welch@collabora.co.uk>
> ---
> Changes from V3:
> - The connector is created when there is no bridge instead of only when
> there is a pannel
> - Tested on next-20160804
>
> Changes from V2:
> - Updated to be aplied on top of Liu Ying changes that made imx-ldb atomic
> - Tested on next-20160729
>
> Changes from V1:
> - Reanmed ext_bridge to bridge
> - Removed empty entry point imx_ldb_encoder_enable()
> - Adapted the code to apply to the latest linux next: next-20160609
>
> drivers/gpu/drm/imx/imx-ldb.c | 118 ++++++++++++++++++++++++++++--------------
> 1 file changed, 78 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
> index b03919e..4a33077 100644
> --- a/drivers/gpu/drm/imx/imx-ldb.c
> +++ b/drivers/gpu/drm/imx/imx-ldb.c
> @@ -57,7 +57,11 @@ struct imx_ldb_channel {
> struct imx_ldb *ldb;
> struct drm_connector connector;
> struct drm_encoder encoder;
> +
> + /* Defines what is connected to the ldb, only one at a time */
> struct drm_panel *panel;
> + struct drm_bridge *bridge;
> +
> struct device_node *child;
> struct i2c_adapter *ddc;
> int chno;
> @@ -466,10 +470,30 @@ static int imx_ldb_register(struct drm_device *drm,
> drm_encoder_init(drm, encoder, &imx_ldb_encoder_funcs,
> DRM_MODE_ENCODER_LVDS, NULL);
>
> - drm_connector_helper_add(&imx_ldb_ch->connector,
> - &imx_ldb_connector_helper_funcs);
> - drm_connector_init(drm, &imx_ldb_ch->connector,
> - &imx_ldb_connector_funcs, DRM_MODE_CONNECTOR_LVDS);
> + if (imx_ldb_ch->bridge) {
> + imx_ldb_ch->bridge->encoder = encoder;
> +
> + imx_ldb_ch->encoder.bridge = imx_ldb_ch->bridge;
> + ret = drm_bridge_attach(drm, imx_ldb_ch->bridge);
> + if (ret) {
> + DRM_ERROR("Failed to initialize bridge with drm\n");
> + return ret;
> + }
> + } else {
> + /*
> + * We want to add the connector whenever there is no bridge
> + * that brings its own, not only when there is a panel. For
> + * historical reasons, the ldb driver can also work without
> + * a panel.
> + */
> + drm_connector_helper_add(&imx_ldb_ch->connector,
> + &imx_ldb_connector_helper_funcs);
> + drm_connector_init(drm, &imx_ldb_ch->connector,
> + &imx_ldb_connector_funcs,
> + DRM_MODE_CONNECTOR_LVDS);
> + drm_mode_connector_attach_encoder(&imx_ldb_ch->connector,
> + encoder);
> + }
>
> if (imx_ldb_ch->panel) {
> ret = drm_panel_attach(imx_ldb_ch->panel,
> @@ -478,8 +502,6 @@ static int imx_ldb_register(struct drm_device *drm,
> return ret;
> }
>
> - drm_mode_connector_attach_encoder(&imx_ldb_ch->connector, encoder);
> -
> return 0;
> }
>
> @@ -548,6 +570,45 @@ static const struct of_device_id imx_ldb_dt_ids[] = {
> };
> MODULE_DEVICE_TABLE(of, imx_ldb_dt_ids);
>
> +static int imx_ldb_panel_ddc(struct device *dev,
> + struct imx_ldb_channel *channel, struct device_node *child)
> +{
> + struct device_node *ddc_node;
> + const u8 *edidp;
> + int ret;
> +
> + ddc_node = of_parse_phandle(child, "ddc-i2c-bus", 0);
> + if (ddc_node) {
> + channel->ddc = of_find_i2c_adapter_by_node(ddc_node);
> + of_node_put(ddc_node);
> + if (!channel->ddc) {
> + dev_warn(dev, "failed to get ddc i2c adapter\n");
> + return -EPROBE_DEFER;
> + }
> + }
> +
> + if (!channel->ddc) {
> + /* if no DDC available, fallback to hardcoded EDID */
> + dev_dbg(dev, "no ddc available\n");
> +
> + edidp = of_get_property(child, "edid",
> + &channel->edid_len);
> + if (edidp) {
> + channel->edid = kmemdup(edidp,
> + channel->edid_len,
> + GFP_KERNEL);
> + } else if (!channel->panel) {
> + /* fallback to display-timings node */
> + ret = of_get_drm_display_mode(child,
> + &channel->mode,
> + OF_USE_NATIVE_MODE);
> + if (!ret)
> + channel->mode_valid = 1;
> + }
> + }
> + return 0;
> +}
> +
> static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
> {
> struct drm_device *drm = data;
> @@ -555,7 +616,6 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
> const struct of_device_id *of_id =
> of_match_device(imx_ldb_dt_ids, dev);
> struct device_node *child;
> - const u8 *edidp;
> struct imx_ldb *imx_ldb;
> int dual;
> int ret;
> @@ -605,7 +665,6 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
>
> for_each_child_of_node(np, child) {
> struct imx_ldb_channel *channel;
> - struct device_node *ddc_node;
> struct device_node *ep;
> int bus_format;
>
> @@ -638,46 +697,25 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
>
> remote = of_graph_get_remote_port_parent(ep);
> of_node_put(ep);
> - if (remote)
> + if (remote) {
> channel->panel = of_drm_find_panel(remote);
> - else
> + channel->bridge = of_drm_find_bridge(remote);
> + } else
> return -EPROBE_DEFER;
> of_node_put(remote);
> - if (!channel->panel) {
> - dev_err(dev, "panel not found: %s\n",
> - remote->full_name);
> - return -EPROBE_DEFER;
> - }
> - }
>
> - ddc_node = of_parse_phandle(child, "ddc-i2c-bus", 0);
> - if (ddc_node) {
> - channel->ddc = of_find_i2c_adapter_by_node(ddc_node);
> - of_node_put(ddc_node);
> - if (!channel->ddc) {
> - dev_warn(dev, "failed to get ddc i2c adapter\n");
> + if (!channel->panel && !channel->bridge) {
> + dev_err(dev, "panel/bridge not found: %s\n",
> + remote->full_name);
> return -EPROBE_DEFER;
> }
> }
>
> - if (!channel->ddc) {
> - /* if no DDC available, fallback to hardcoded EDID */
> - dev_dbg(dev, "no ddc available\n");
> -
> - edidp = of_get_property(child, "edid",
> - &channel->edid_len);
> - if (edidp) {
> - channel->edid = kmemdup(edidp,
> - channel->edid_len,
> - GFP_KERNEL);
> - } else if (!channel->panel) {
> - /* fallback to display-timings node */
> - ret = of_get_drm_display_mode(child,
> - &channel->mode,
> - OF_USE_NATIVE_MODE);
> - if (!ret)
> - channel->mode_valid = 1;
> - }
> + /* panel ddc only if there is no bridge */
> + if (!channel->bridge) {
> + ret = imx_ldb_panel_ddc(dev, channel, child);
> + if (ret)
> + return ret;
> }
>
> bus_format = of_get_bus_format(dev, child);
>
next prev parent reply other threads:[~2016-08-16 15:40 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-30 16:39 [PATCH 0/5] Add driver for GE B850v3 LVDS/DP++ Bridge Peter Senna Tschudin
2016-05-30 16:39 ` [PATCH 1/5] drm/imx-ldb: Add support to drm-bridge Peter Senna Tschudin
2016-06-02 13:09 ` Philipp Zabel
2016-05-30 16:39 ` [PATCH 2/5] arm/dts/imx6q-b850v3: Configure IPU assignment order Peter Senna Tschudin
2016-05-30 16:49 ` Fabio Estevam
2016-06-02 12:55 ` Philipp Zabel
2016-05-30 16:39 ` [PATCH 3/5] Documentation/devicetree/bindings: Add b850v3_lvds_dp Peter Senna Tschudin
2016-06-02 12:49 ` Philipp Zabel
2016-06-02 23:19 ` Peter Senna Tschudin
2016-06-02 22:57 ` Rob Herring
2016-05-30 16:39 ` [PATCH 4/5] drm/bridge: Add driver for GE B850v3 LVDS/DP++ Bridge Peter Senna Tschudin
2016-05-31 7:48 ` Enric Balletbo Serra
2016-05-30 16:39 ` [PATCH 5/5] arm/dts/imx6q-b850v3: Use " Peter Senna Tschudin
2016-05-30 16:54 ` Fabio Estevam
2016-06-09 16:25 ` [PATCH V2 0/5] Add driver for " Peter Senna Tschudin
2016-06-09 16:25 ` [PATCH V2 1/5] drm/imx-ldb: Add support to drm-bridge Peter Senna Tschudin
2016-06-09 16:25 ` [PATCH V2 2/5] dts/imx6q-b850v3: Configure IPU assignment order Peter Senna Tschudin
2016-06-09 16:25 ` [PATCH V2 3/5] Documentation/devicetree/bindings: b850v3_lvds_dp Peter Senna Tschudin
2016-06-10 17:42 ` Rob Herring
2016-06-10 18:54 ` Javier Martinez Canillas
2016-06-09 16:25 ` [PATCH V2 4/5] drm/bridge: Add driver for GE B850v3 LVDS/DP++ Bridge Peter Senna Tschudin
2016-06-10 7:39 ` Enric Balletbo Serra
2016-06-10 9:44 ` Peter Senna Tschudin
2016-06-10 14:13 ` Daniel Vetter
2016-06-22 8:34 ` Archit Taneja
2016-06-09 16:25 ` [PATCH V2 5/5] dts/imx6q-b850v3: Use " Peter Senna Tschudin
2016-07-31 19:55 ` [PATCH V3 0/5] Add driver for " Peter Senna Tschudin
2016-07-31 19:55 ` [PATCH V3 1/5] drm/imx-ldb: Add support to drm-bridge Peter Senna Tschudin
2016-08-01 10:21 ` Philipp Zabel
2016-08-02 18:46 ` Peter Senna Tschudin
2016-07-31 19:55 ` [PATCH V3 2/5] dts/imx6q-b850v3: Configure IPU assignment order Peter Senna Tschudin
2016-08-01 8:54 ` Lucas Stach
2016-08-01 12:30 ` Peter Senna Tschudin
2016-08-02 13:13 ` Daniel Vetter
2016-07-31 19:55 ` [PATCH V3 3/5] Documentation/devicetree/bindings: b850v3_lvds_dp Peter Senna Tschudin
2016-08-01 16:59 ` Rob Herring
2016-07-31 19:55 ` [PATCH V3 4/5] drm/bridge: Add driver for GE B850v3 LVDS/DP++ Bridge Peter Senna Tschudin
2016-07-31 19:55 ` [PATCH V3 5/5] dts/imx6q-b850v3: Use " Peter Senna Tschudin
2016-08-04 22:36 ` [PATCH V4 0/4] Add driver for " Peter Senna Tschudin
2016-08-04 22:36 ` [PATCH V4 1/4] drm/imx-ldb: Add support to drm-bridge Peter Senna Tschudin
2016-08-16 15:40 ` Martyn Welch [this message]
2016-08-04 22:36 ` [PATCH V4 2/4] Documentation/devicetree/bindings: b850v3_lvds_dp Peter Senna Tschudin
2016-08-05 7:28 ` Enric Balletbo Serra
2016-08-16 15:59 ` Martyn Welch
2016-08-04 22:37 ` [PATCH V4 3/4] drm/bridge: Add driver for GE B850v3 LVDS/DP++ Bridge Peter Senna Tschudin
2016-08-05 7:38 ` Enric Balletbo Serra
2016-08-04 22:37 ` [PATCH V4 4/4] dts/imx6q-b850v3: Use " Peter Senna Tschudin
2016-08-09 16:41 ` [PATCH V5 0/4] Add driver for " Peter Senna Tschudin
2016-08-09 16:41 ` [PATCH V5 1/4] drm/imx-ldb: Add support to drm-bridge Peter Senna Tschudin
2016-08-11 9:38 ` Philipp Zabel
2016-08-09 16:41 ` [PATCH V5 2/4] Documentation/devicetree/bindings: b850v3_lvds_dp Peter Senna Tschudin
2016-09-26 8:26 ` Peter Senna Tschudin
2016-08-09 16:41 ` [PATCH V5 3/4] drm/bridge: Add driver for GE B850v3 LVDS/DP++ Bridge Peter Senna Tschudin
2016-08-16 4:15 ` Archit Taneja
2016-09-26 8:27 ` Peter Senna Tschudin
2016-09-26 8:31 ` Archit Taneja
2016-09-26 8:58 ` Peter Senna Tschudin
2016-09-26 10:28 ` Archit Taneja
2016-09-26 10:29 ` Archit Taneja
2016-09-26 11:54 ` Peter Senna Tschudin
2016-09-26 12:54 ` Archit Taneja
2016-08-09 16:41 ` [PATCH V5 4/4] dts/imx6q-b850v3: Use " Peter Senna Tschudin
2016-09-26 8:27 ` Peter Senna Tschudin
2016-09-29 10:39 ` Shawn Guo
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=474dea2a-47c7-13ba-86c1-1184937351fb@collabora.co.uk \
--to=martyn.welch@collabora.co.uk \
--cc=airlied@linux.ie \
--cc=architt@codeaurora.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=enric.balletbo@collabora.com \
--cc=fabio.estevam@nxp.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=martin.donnelly@ge.com \
--cc=p.zabel@pengutronix.de \
--cc=peter.senna@collabora.com \
--cc=peter.senna@gmail.com \
--cc=robh+dt@kernel.org \
--cc=robh@kernel.org \
--cc=shawnguo@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=treding@nvidia.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).