Commit 0d60131a authored by Fabrizio Castro's avatar Fabrizio Castro Committed by Neil Armstrong

drm/bridge: Repurpose lvds-encoder.c

lvds-encoder.c implementation is also suitable for LVDS decoders,
not just LVDS encoders.
Instead of creating a new driver for addressing support for
transparent LVDS decoders, repurpose lvds-encoder.c for the greater
good with this patch.

This patch only "rebrands" the lvds-encoder.c driver, to make it
suitable for hosting LVDS decoders support. The actual support for
LVDS decoders will come with a later patch.
Signed-off-by: default avatarFabrizio Castro <fabrizio.castro@bp.renesas.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1573660292-10629-6-git-send-email-fabrizio.castro@bp.renesas.com
parent 4788f4e1
...@@ -35,14 +35,14 @@ config DRM_DUMB_VGA_DAC ...@@ -35,14 +35,14 @@ config DRM_DUMB_VGA_DAC
Support for non-programmable RGB to VGA DAC bridges, such as ADI Support for non-programmable RGB to VGA DAC bridges, such as ADI
ADV7123, TI THS8134 and THS8135 or passive resistor ladder DACs. ADV7123, TI THS8134 and THS8135 or passive resistor ladder DACs.
config DRM_LVDS_ENCODER config DRM_LVDS_CODEC
tristate "Transparent parallel to LVDS encoder support" tristate "Transparent LVDS encoders and decoders support"
depends on OF depends on OF
select DRM_KMS_HELPER select DRM_KMS_HELPER
select DRM_PANEL_BRIDGE select DRM_PANEL_BRIDGE
help help
Support for transparent parallel to LVDS encoders that don't require Support for transparent LVDS encoders and decoders that don't
any configuration. require any configuration.
config DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW config DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW
tristate "MegaChips stdp4028-ge-b850v3-fw and stdp2690-ge-b850v3-fw" tristate "MegaChips stdp4028-ge-b850v3-fw and stdp2690-ge-b850v3-fw"
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o
obj-$(CONFIG_DRM_DUMB_VGA_DAC) += dumb-vga-dac.o obj-$(CONFIG_DRM_DUMB_VGA_DAC) += dumb-vga-dac.o
obj-$(CONFIG_DRM_LVDS_ENCODER) += lvds-encoder.o obj-$(CONFIG_DRM_LVDS_CODEC) += lvds-codec.o
obj-$(CONFIG_DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW) += megachips-stdpxxxx-ge-b850v3-fw.o obj-$(CONFIG_DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW) += megachips-stdpxxxx-ge-b850v3-fw.o
obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o
obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o
......
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Copyright (C) 2019 Renesas Electronics Corporation
* Copyright (C) 2016 Laurent Pinchart <laurent.pinchart@ideasonboard.com> * Copyright (C) 2016 Laurent Pinchart <laurent.pinchart@ideasonboard.com>
*/ */
...@@ -12,65 +13,62 @@ ...@@ -12,65 +13,62 @@
#include <drm/drm_bridge.h> #include <drm/drm_bridge.h>
#include <drm/drm_panel.h> #include <drm/drm_panel.h>
struct lvds_encoder { struct lvds_codec {
struct drm_bridge bridge; struct drm_bridge bridge;
struct drm_bridge *panel_bridge; struct drm_bridge *panel_bridge;
struct gpio_desc *powerdown_gpio; struct gpio_desc *powerdown_gpio;
}; };
static int lvds_encoder_attach(struct drm_bridge *bridge) static int lvds_codec_attach(struct drm_bridge *bridge)
{ {
struct lvds_encoder *lvds_encoder = container_of(bridge, struct lvds_codec *lvds_codec = container_of(bridge,
struct lvds_encoder, struct lvds_codec, bridge);
bridge);
return drm_bridge_attach(bridge->encoder, lvds_encoder->panel_bridge, return drm_bridge_attach(bridge->encoder, lvds_codec->panel_bridge,
bridge); bridge);
} }
static void lvds_encoder_enable(struct drm_bridge *bridge) static void lvds_codec_enable(struct drm_bridge *bridge)
{ {
struct lvds_encoder *lvds_encoder = container_of(bridge, struct lvds_codec *lvds_codec = container_of(bridge,
struct lvds_encoder, struct lvds_codec, bridge);
bridge);
if (lvds_encoder->powerdown_gpio) if (lvds_codec->powerdown_gpio)
gpiod_set_value_cansleep(lvds_encoder->powerdown_gpio, 0); gpiod_set_value_cansleep(lvds_codec->powerdown_gpio, 0);
} }
static void lvds_encoder_disable(struct drm_bridge *bridge) static void lvds_codec_disable(struct drm_bridge *bridge)
{ {
struct lvds_encoder *lvds_encoder = container_of(bridge, struct lvds_codec *lvds_codec = container_of(bridge,
struct lvds_encoder, struct lvds_codec, bridge);
bridge);
if (lvds_encoder->powerdown_gpio) if (lvds_codec->powerdown_gpio)
gpiod_set_value_cansleep(lvds_encoder->powerdown_gpio, 1); gpiod_set_value_cansleep(lvds_codec->powerdown_gpio, 1);
} }
static struct drm_bridge_funcs funcs = { static struct drm_bridge_funcs funcs = {
.attach = lvds_encoder_attach, .attach = lvds_codec_attach,
.enable = lvds_encoder_enable, .enable = lvds_codec_enable,
.disable = lvds_encoder_disable, .disable = lvds_codec_disable,
}; };
static int lvds_encoder_probe(struct platform_device *pdev) static int lvds_codec_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *port; struct device_node *port;
struct device_node *endpoint; struct device_node *endpoint;
struct device_node *panel_node; struct device_node *panel_node;
struct drm_panel *panel; struct drm_panel *panel;
struct lvds_encoder *lvds_encoder; struct lvds_codec *lvds_codec;
lvds_encoder = devm_kzalloc(dev, sizeof(*lvds_encoder), GFP_KERNEL); lvds_codec = devm_kzalloc(dev, sizeof(*lvds_codec), GFP_KERNEL);
if (!lvds_encoder) if (!lvds_codec)
return -ENOMEM; return -ENOMEM;
lvds_encoder->powerdown_gpio = devm_gpiod_get_optional(dev, "powerdown", lvds_codec->powerdown_gpio = devm_gpiod_get_optional(dev, "powerdown",
GPIOD_OUT_HIGH); GPIOD_OUT_HIGH);
if (IS_ERR(lvds_encoder->powerdown_gpio)) { if (IS_ERR(lvds_codec->powerdown_gpio)) {
int err = PTR_ERR(lvds_encoder->powerdown_gpio); int err = PTR_ERR(lvds_codec->powerdown_gpio);
if (err != -EPROBE_DEFER) if (err != -EPROBE_DEFER)
dev_err(dev, "powerdown GPIO failure: %d\n", err); dev_err(dev, "powerdown GPIO failure: %d\n", err);
...@@ -105,51 +103,52 @@ static int lvds_encoder_probe(struct platform_device *pdev) ...@@ -105,51 +103,52 @@ static int lvds_encoder_probe(struct platform_device *pdev)
return PTR_ERR(panel); return PTR_ERR(panel);
} }
lvds_encoder->panel_bridge = lvds_codec->panel_bridge =
devm_drm_panel_bridge_add_typed(dev, panel, devm_drm_panel_bridge_add_typed(dev, panel,
DRM_MODE_CONNECTOR_LVDS); DRM_MODE_CONNECTOR_LVDS);
if (IS_ERR(lvds_encoder->panel_bridge)) if (IS_ERR(lvds_codec->panel_bridge))
return PTR_ERR(lvds_encoder->panel_bridge); return PTR_ERR(lvds_codec->panel_bridge);
/* The panel_bridge bridge is attached to the panel's of_node, /*
* The panel_bridge bridge is attached to the panel's of_node,
* but we need a bridge attached to our of_node for our user * but we need a bridge attached to our of_node for our user
* to look up. * to look up.
*/ */
lvds_encoder->bridge.of_node = dev->of_node; lvds_codec->bridge.of_node = dev->of_node;
lvds_encoder->bridge.funcs = &funcs; lvds_codec->bridge.funcs = &funcs;
drm_bridge_add(&lvds_encoder->bridge); drm_bridge_add(&lvds_codec->bridge);
platform_set_drvdata(pdev, lvds_encoder); platform_set_drvdata(pdev, lvds_codec);
return 0; return 0;
} }
static int lvds_encoder_remove(struct platform_device *pdev) static int lvds_codec_remove(struct platform_device *pdev)
{ {
struct lvds_encoder *lvds_encoder = platform_get_drvdata(pdev); struct lvds_codec *lvds_codec = platform_get_drvdata(pdev);
drm_bridge_remove(&lvds_encoder->bridge); drm_bridge_remove(&lvds_codec->bridge);
return 0; return 0;
} }
static const struct of_device_id lvds_encoder_match[] = { static const struct of_device_id lvds_codec_match[] = {
{ .compatible = "lvds-encoder" }, { .compatible = "lvds-encoder" },
{ .compatible = "thine,thc63lvdm83d" }, { .compatible = "thine,thc63lvdm83d" },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, lvds_encoder_match); MODULE_DEVICE_TABLE(of, lvds_codec_match);
static struct platform_driver lvds_encoder_driver = { static struct platform_driver lvds_codec_driver = {
.probe = lvds_encoder_probe, .probe = lvds_codec_probe,
.remove = lvds_encoder_remove, .remove = lvds_codec_remove,
.driver = { .driver = {
.name = "lvds-encoder", .name = "lvds-codec",
.of_match_table = lvds_encoder_match, .of_match_table = lvds_codec_match,
}, },
}; };
module_platform_driver(lvds_encoder_driver); module_platform_driver(lvds_codec_driver);
MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>"); MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
MODULE_DESCRIPTION("Transparent parallel to LVDS encoder"); MODULE_DESCRIPTION("LVDS encoders and decoders");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment