From: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
To: Jacopo Mondi <jacopo+renesas@jmondi.org>,
<architt@codeaurora.org>, <a.hajda@samsung.com>,
<Laurent.pinchart@ideasonboard.com>, <airlied@linux.ie>,
<horms@verge.net.au>, <magnus.damm@gmail.com>,
<geert@linux-m68k.org>, <niklas.soderlund@ragnatech.se>,
<sergei.shtylyov@cogentembedded.com>, <robh+dt@kernel.org>,
<mark.rutland@arm.com>
Cc: <dri-devel@lists.freedesktop.org>,
<linux-renesas-soc@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] drm: bridge: Add LVDS decoder driver
Date: Tue, 20 Mar 2018 17:42:59 +0200 [thread overview]
Message-ID: <dc468964-dc9c-65fb-7ec8-e180409ffa03@mentor.com> (raw)
In-Reply-To: <1520603500-15218-3-git-send-email-jacopo+renesas@jmondi.org>
Hi Jacopo,
On 03/09/2018 03:51 PM, Jacopo Mondi wrote:
> Add transparent LVDS decoder driver.
>
> A transparent LVDS decoder is a DRM bridge device that does not require
> any configuration and converts LVDS input to digital CMOS/TTL parallel
> data output.
>
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
> drivers/gpu/drm/bridge/Kconfig | 8 +++
> drivers/gpu/drm/bridge/Makefile | 1 +
> drivers/gpu/drm/bridge/lvds-decoder.c | 129 ++++++++++++++++++++++++++++++++++
> 3 files changed, 138 insertions(+)
> create mode 100644 drivers/gpu/drm/bridge/lvds-decoder.c
>
> diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
> index 3b99d5a..e52a5af 100644
> --- a/drivers/gpu/drm/bridge/Kconfig
> +++ b/drivers/gpu/drm/bridge/Kconfig
> @@ -32,6 +32,14 @@ config DRM_DUMB_VGA_DAC
> help
> Support for RGB to VGA DAC based bridges
>
> +config DRM_LVDS_DECODER
> + tristate "Transparent LVDS to parallel decoder support"
> + depends on OF
> + select DRM_PANEL_BRIDGE
> + help
> + Support for transparent LVDS to parallel decoders that don't require
> + any configuration.
> +
> config DRM_LVDS_ENCODER
> tristate "Transparent parallel to LVDS encoder support"
> depends on OF
> diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
> index 373eb28..edc2332 100644
> --- a/drivers/gpu/drm/bridge/Makefile
> +++ b/drivers/gpu/drm/bridge/Makefile
> @@ -1,6 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0
> obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
> obj-$(CONFIG_DRM_DUMB_VGA_DAC) += dumb-vga-dac.o
> +obj-$(CONFIG_DRM_LVDS_DECODER) += lvds-decoder.o
> obj-$(CONFIG_DRM_LVDS_ENCODER) += lvds-encoder.o
> obj-$(CONFIG_DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW) += megachips-stdpxxxx-ge-b850v3-fw.o
> obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o
> diff --git a/drivers/gpu/drm/bridge/lvds-decoder.c b/drivers/gpu/drm/bridge/lvds-decoder.c
> new file mode 100644
> index 0000000..319f4d5
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/lvds-decoder.c
> @@ -0,0 +1,129 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * LVDS to parallel data DRM bridge driver.
> + *
> + * Copyright (C) 2018 Jacopo Mondi <jacopo+renesas@jmondi.org>
> + */
> +
> +#include <drm/drmP.h>
> +#include <drm/drm_bridge.h>
> +#include <drm/drm_panel.h>
> +
> +#include <linux/of_graph.h>
> +
> +struct lvds_decoder {
> + struct device *dev;
> +
> + struct drm_bridge bridge;
> + struct drm_bridge *next;
> + struct drm_encoder *bridge_encoder;
> +};
> +
> +static inline struct lvds_decoder *to_lvds_decoder(struct drm_bridge *bridge)
> +{
> + return container_of(bridge, struct lvds_decoder, bridge);
> +}
> +
> +static int lvds_decoder_attach(struct drm_bridge *bridge)
> +{
> + struct lvds_decoder *lvds = to_lvds_decoder(bridge);
> +
> + return drm_bridge_attach(bridge->encoder, lvds->next, bridge);
> +}
> +
> +struct drm_bridge_funcs lvds_dec_bridge_func = {
static const struct drm_bridge_funcs lvds_dec_bridge_func
> + .attach = lvds_decoder_attach,
> +};
> +
> +static int lvds_decoder_parse_dt(struct lvds_decoder *lvds)
> +{
> + struct device_node *lvds_output;
> + struct device_node *remote;
> + int ret = 0;
> +
> + lvds_output = of_graph_get_endpoint_by_regs(lvds->dev->of_node, 1, -1);
> + if (!lvds_output) {
> + dev_err(lvds->dev, "Missing endpoint in Port@1\n");
> + return -ENODEV;
> + }
> +
> + remote = of_graph_get_remote_port_parent(lvds_output);
Add of_node_put(lvds_output) right here to get rid of error_put_lvds_node
goto label.
> + if (!remote) {
> + dev_err(lvds->dev, "Endpoint in Port@1 unconnected\n");
> + ret = -ENODEV;
> + goto error_put_lvds_node;
> + }
> +
> + if (!of_device_is_available(remote)) {
> + dev_err(lvds->dev, "Port@1 remote endpoint is disabled\n");
> + ret = -ENODEV;
> + goto error_put_remote_node;
> + }
> +
> + lvds->next = of_drm_find_bridge(remote);
> + if (!lvds->next)
> + ret = -EPROBE_DEFER;
> +
> +error_put_remote_node:
> + of_node_put(remote);
> +error_put_lvds_node:
> + of_node_put(lvds_output);
> +
> + return ret;
> +}
> +
> +static int lvds_decoder_probe(struct platform_device *pdev)
> +{
> + struct lvds_decoder *lvds;
> + int ret;
> +
> + lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL);
> + if (!lvds)
> + return -ENOMEM;
> +
> + lvds->dev = &pdev->dev;
> + platform_set_drvdata(pdev, lvds);
> +
> + ret = lvds_decoder_parse_dt(lvds);
> + if (ret)
> + return ret;
> +
> + lvds->bridge.driver_private = lvds;
> + lvds->bridge.of_node = pdev->dev.of_node;
> + lvds->bridge.funcs = &lvds_dec_bridge_func;
> +
> + drm_bridge_add(&lvds->bridge);
> +
> + return 0;
> +}
> +
> +static int lvds_decoder_remove(struct platform_device *pdev)
> +{
> + struct lvds_decoder *lvds = platform_get_drvdata(pdev);
> +
> + drm_bridge_remove(&lvds->bridge);
> +
> + return 0;
> +}
> +
> +#ifdef CONFIG_OF
> +static const struct of_device_id lvds_decoder_match[] = {
> + { .compatible = "lvds-decoder", },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, lvds_decoder_match);
> +#endif
> +
I would say "#ifdef CONFIG_OF" is redundant, because the driver "depends on OF".
> +static struct platform_driver lvds_decoder_driver = {
> + .probe = lvds_decoder_probe,
> + .remove = lvds_decoder_remove,
> + .driver = {
> + .name = "lvds_decoder",
> + .of_match_table = lvds_decoder_match,
> + },
> +};
> +module_platform_driver(lvds_decoder_driver);
> +
> +MODULE_AUTHOR("Jacopo Mondi <jacopo@jmondi.org>");
> +MODULE_DESCRIPTION("Transparent LVDS to parallel data decoder");
> +MODULE_LICENSE("GPL v2");
--
With best wishes,
Vladimir
next prev parent reply other threads:[~2018-03-20 15:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180309135207epcas3p32a7d3a0e9c9dae5af8fc855ff3c0e03b@epcas3p3.samsung.com>
2018-03-09 13:51 ` [PATCH v2 0/3] drm: Add LVDS decoder bridge Jacopo Mondi
2018-03-09 13:51 ` [PATCH v2 1/3] dt-bindings: display: bridge: Document LVDS to parallel decoder Jacopo Mondi
2018-03-09 13:51 ` [PATCH v2 2/3] drm: bridge: Add LVDS decoder driver Jacopo Mondi
2018-03-12 8:26 ` Andrzej Hajda
2018-03-20 15:42 ` Vladimir Zapolskiy [this message]
2018-03-09 13:51 ` [PATCH v2 3/3] arm64: dts: renesas: Add LVDS decoder to R-Car V3M Eagle Jacopo Mondi
2018-03-09 14:49 ` Simon Horman
2018-03-09 17:30 ` Sergei Shtylyov
2018-03-10 17:22 ` jacopo mondi
2018-03-10 5:53 ` [PATCH v2 0/3] drm: Add LVDS decoder bridge Archit Taneja
2018-03-10 18:00 ` jacopo mondi
2018-03-20 12:19 ` Laurent Pinchart
2018-03-12 9:07 ` Andrzej Hajda
2018-03-12 12:30 ` jacopo mondi
2018-03-12 13:47 ` Andrzej Hajda
2018-03-12 14:11 ` jacopo mondi
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=dc468964-dc9c-65fb-7ec8-e180409ffa03@mentor.com \
--to=vladimir_zapolskiy@mentor.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a.hajda@samsung.com \
--cc=airlied@linux.ie \
--cc=architt@codeaurora.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert@linux-m68k.org \
--cc=horms@verge.net.au \
--cc=jacopo+renesas@jmondi.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mark.rutland@arm.com \
--cc=niklas.soderlund@ragnatech.se \
--cc=robh+dt@kernel.org \
--cc=sergei.shtylyov@cogentembedded.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