mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-15 09:34:17 +00:00
drm: of: Add drm_of_lvds_get_data_mapping
Add helper function to convert DT "data-mapping" property string value into media bus format value, and deduplicate the code in panel-lvds.c and lvds-codec.c . Signed-off-by: Marek Vasut <marex@denx.de> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Sam Ravnborg <sam@ravnborg.org> To: dri-devel@lists.freedesktop.org Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20211012224252.29185-1-marex@denx.de
This commit is contained in:
parent
189723fbe9
commit
7c4dd0a266
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include <drm/drm_atomic_helper.h>
|
#include <drm/drm_atomic_helper.h>
|
||||||
#include <drm/drm_bridge.h>
|
#include <drm/drm_bridge.h>
|
||||||
|
#include <drm/drm_of.h>
|
||||||
#include <drm/drm_panel.h>
|
#include <drm/drm_panel.h>
|
||||||
|
|
||||||
struct lvds_codec {
|
struct lvds_codec {
|
||||||
@ -118,7 +119,6 @@ static int lvds_codec_probe(struct platform_device *pdev)
|
|||||||
struct device_node *bus_node;
|
struct device_node *bus_node;
|
||||||
struct drm_panel *panel;
|
struct drm_panel *panel;
|
||||||
struct lvds_codec *lvds_codec;
|
struct lvds_codec *lvds_codec;
|
||||||
const char *mapping;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
lvds_codec = devm_kzalloc(dev, sizeof(*lvds_codec), GFP_KERNEL);
|
lvds_codec = devm_kzalloc(dev, sizeof(*lvds_codec), GFP_KERNEL);
|
||||||
@ -174,22 +174,15 @@ static int lvds_codec_probe(struct platform_device *pdev)
|
|||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = of_property_read_string(bus_node, "data-mapping",
|
ret = drm_of_lvds_get_data_mapping(bus_node);
|
||||||
&mapping);
|
|
||||||
of_node_put(bus_node);
|
of_node_put(bus_node);
|
||||||
if (ret < 0) {
|
if (ret == -ENODEV) {
|
||||||
dev_warn(dev, "missing 'data-mapping' DT property\n");
|
dev_warn(dev, "missing 'data-mapping' DT property\n");
|
||||||
|
} else if (ret) {
|
||||||
|
dev_err(dev, "invalid 'data-mapping' DT property\n");
|
||||||
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
if (!strcmp(mapping, "jeida-18")) {
|
lvds_codec->bus_format = ret;
|
||||||
lvds_codec->bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG;
|
|
||||||
} else if (!strcmp(mapping, "jeida-24")) {
|
|
||||||
lvds_codec->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA;
|
|
||||||
} else if (!strcmp(mapping, "vesa-24")) {
|
|
||||||
lvds_codec->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;
|
|
||||||
} else {
|
|
||||||
dev_err(dev, "invalid 'data-mapping' DT property\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
lvds_codec->bridge.funcs = &funcs_decoder;
|
lvds_codec->bridge.funcs = &funcs_decoder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,3 +402,36 @@ int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
|
|||||||
DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS;
|
DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(drm_of_lvds_get_dual_link_pixel_order);
|
EXPORT_SYMBOL_GPL(drm_of_lvds_get_dual_link_pixel_order);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* drm_of_lvds_get_data_mapping - Get LVDS data mapping
|
||||||
|
* @port: DT port node of the LVDS source or sink
|
||||||
|
*
|
||||||
|
* Convert DT "data-mapping" property string value into media bus format value.
|
||||||
|
*
|
||||||
|
* Return:
|
||||||
|
* * MEDIA_BUS_FMT_RGB666_1X7X3_SPWG - data-mapping is "jeida-18"
|
||||||
|
* * MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA - data-mapping is "jeida-24"
|
||||||
|
* * MEDIA_BUS_FMT_RGB888_1X7X4_SPWG - data-mapping is "vesa-24"
|
||||||
|
* * -EINVAL - the "data-mapping" property is unsupported
|
||||||
|
* * -ENODEV - the "data-mapping" property is missing
|
||||||
|
*/
|
||||||
|
int drm_of_lvds_get_data_mapping(const struct device_node *port)
|
||||||
|
{
|
||||||
|
const char *mapping;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = of_property_read_string(port, "data-mapping", &mapping);
|
||||||
|
if (ret < 0)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
if (!strcmp(mapping, "jeida-18"))
|
||||||
|
return MEDIA_BUS_FMT_RGB666_1X7X3_SPWG;
|
||||||
|
if (!strcmp(mapping, "jeida-24"))
|
||||||
|
return MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA;
|
||||||
|
if (!strcmp(mapping, "vesa-24"))
|
||||||
|
return MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;
|
||||||
|
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(drm_of_lvds_get_data_mapping);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <video/videomode.h>
|
#include <video/videomode.h>
|
||||||
|
|
||||||
#include <drm/drm_crtc.h>
|
#include <drm/drm_crtc.h>
|
||||||
|
#include <drm/drm_of.h>
|
||||||
#include <drm/drm_panel.h>
|
#include <drm/drm_panel.h>
|
||||||
|
|
||||||
struct panel_lvds {
|
struct panel_lvds {
|
||||||
@ -116,7 +117,6 @@ static int panel_lvds_parse_dt(struct panel_lvds *lvds)
|
|||||||
{
|
{
|
||||||
struct device_node *np = lvds->dev->of_node;
|
struct device_node *np = lvds->dev->of_node;
|
||||||
struct display_timing timing;
|
struct display_timing timing;
|
||||||
const char *mapping;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = of_drm_get_panel_orientation(np, &lvds->orientation);
|
ret = of_drm_get_panel_orientation(np, &lvds->orientation);
|
||||||
@ -149,24 +149,14 @@ static int panel_lvds_parse_dt(struct panel_lvds *lvds)
|
|||||||
|
|
||||||
of_property_read_string(np, "label", &lvds->label);
|
of_property_read_string(np, "label", &lvds->label);
|
||||||
|
|
||||||
ret = of_property_read_string(np, "data-mapping", &mapping);
|
ret = drm_of_lvds_get_data_mapping(np);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n",
|
dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n",
|
||||||
np, "data-mapping");
|
np, "data-mapping");
|
||||||
return -ENODEV;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(mapping, "jeida-18")) {
|
lvds->bus_format = ret;
|
||||||
lvds->bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG;
|
|
||||||
} else if (!strcmp(mapping, "jeida-24")) {
|
|
||||||
lvds->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA;
|
|
||||||
} else if (!strcmp(mapping, "vesa-24")) {
|
|
||||||
lvds->bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG;
|
|
||||||
} else {
|
|
||||||
dev_err(lvds->dev, "%pOF: invalid or missing %s DT property\n",
|
|
||||||
np, "data-mapping");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
lvds->data_mirror = of_property_read_bool(np, "data-mirror");
|
lvds->data_mirror = of_property_read_bool(np, "data-mirror");
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
|
|||||||
struct drm_bridge **bridge);
|
struct drm_bridge **bridge);
|
||||||
int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
|
int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
|
||||||
const struct device_node *port2);
|
const struct device_node *port2);
|
||||||
|
int drm_of_lvds_get_data_mapping(const struct device_node *port);
|
||||||
#else
|
#else
|
||||||
static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
|
static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
|
||||||
struct device_node *port)
|
struct device_node *port)
|
||||||
@ -98,6 +99,12 @@ drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
|
|||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
drm_of_lvds_get_data_mapping(const struct device_node *port)
|
||||||
|
{
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user