summaryrefslogtreecommitdiff
path: root/drivers/video/simple_panel.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/simple_panel.c')
-rw-r--r--drivers/video/simple_panel.c102
1 files changed, 76 insertions, 26 deletions
diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c
index efb122b534a..76a30427a59 100644
--- a/drivers/video/simple_panel.c
+++ b/drivers/video/simple_panel.c
@@ -7,31 +7,22 @@
#include <common.h>
#include <backlight.h>
#include <dm.h>
+#include <edid.h>
+#include <i2c.h>
#include <log.h>
#include <mipi_dsi.h>
#include <panel.h>
#include <asm/gpio.h>
#include <power/regulator.h>
+#define EDID_I2C_ADDR 0x50
+
struct simple_panel_priv {
struct udevice *reg;
struct udevice *backlight;
struct gpio_desc enable;
};
-/* List of supported DSI panels */
-enum {
- PANEL_NON_DSI,
- PANASONIC_VVX10F004B00,
-};
-
-static const struct mipi_dsi_panel_plat panasonic_vvx10f004b00 = {
- .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
- MIPI_DSI_CLOCK_NON_CONTINUOUS,
- .format = MIPI_DSI_FMT_RGB888,
- .lanes = 4,
-};
-
static int simple_panel_enable_backlight(struct udevice *dev)
{
struct simple_panel_priv *priv = dev_get_priv(dev);
@@ -62,13 +53,71 @@ static int simple_panel_set_backlight(struct udevice *dev, int percent)
return 0;
}
+#if CONFIG_IS_ENABLED(I2C_EDID) && CONFIG_IS_ENABLED(DM_I2C)
+static int simple_panel_get_edid_timing(struct udevice *dev,
+ struct display_timing *timings)
+{
+ struct udevice *panel_ddc, *panel_edid;
+ struct display_timing edid_timing;
+ u8 edid_buf[EDID_SIZE] = { 0 };
+ int ret, bpc;
+ /* Check for DDC i2c if no timings are provided */
+ ret = uclass_get_device_by_phandle(UCLASS_I2C, dev,
+ "ddc-i2c-bus",
+ &panel_ddc);
+ if (ret) {
+ log_debug("%s: cannot get DDC i2c bus: error %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = dm_i2c_probe(panel_ddc, EDID_I2C_ADDR, 0, &panel_edid);
+ if (ret) {
+ log_debug("%s: cannot probe EDID: error %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = dm_i2c_read(panel_edid, 0, edid_buf, sizeof(edid_buf));
+ if (ret) {
+ log_debug("%s: cannot dump EDID buffer: error %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = edid_get_timing(edid_buf, sizeof(edid_buf),
+ &edid_timing, &bpc);
+ if (ret) {
+ log_debug("%s: cannot decode EDID info: error %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ memcpy(timings, &edid_timing, sizeof(*timings));
+
+ return 0;
+}
+#else
+static int simple_panel_get_edid_timing(struct udevice *dev,
+ struct display_timing *timings)
+{
+ return -ENOTSUPP;
+}
+#endif
+
static int simple_panel_get_display_timing(struct udevice *dev,
struct display_timing *timings)
{
const void *blob = gd->fdt_blob;
+ int ret;
+
+ /* Check for timing subnode if panel node first */
+ ret = fdtdec_decode_display_timing(blob, dev_of_offset(dev),
+ 0, timings);
+ if (!ret)
+ return ret;
- return fdtdec_decode_display_timing(blob, dev_of_offset(dev),
- 0, timings);
+ return simple_panel_get_edid_timing(dev, timings);
}
static int simple_panel_of_to_plat(struct udevice *dev)
@@ -111,7 +160,8 @@ static int simple_panel_probe(struct udevice *dev)
{
struct simple_panel_priv *priv = dev_get_priv(dev);
struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
- const u32 dsi_data = dev_get_driver_data(dev);
+ struct mipi_dsi_panel_plat *dsi_data =
+ (struct mipi_dsi_panel_plat *)dev_get_driver_data(dev);
int ret;
ret = regulator_set_enable_if_allowed(priv->reg, true);
@@ -121,15 +171,8 @@ static int simple_panel_probe(struct udevice *dev)
return ret;
}
- switch (dsi_data) {
- case PANASONIC_VVX10F004B00:
- memcpy(plat, &panasonic_vvx10f004b00,
- sizeof(panasonic_vvx10f004b00));
- break;
- case PANEL_NON_DSI:
- default:
- break;
- }
+ if (dsi_data)
+ memcpy(plat, dsi_data, sizeof(struct mipi_dsi_panel_plat));
return 0;
}
@@ -140,6 +183,13 @@ static const struct panel_ops simple_panel_ops = {
.get_display_timing = simple_panel_get_display_timing,
};
+static const struct mipi_dsi_panel_plat panasonic_vvx10f004b00 = {
+ .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
+ MIPI_DSI_CLOCK_NON_CONTINUOUS,
+ .format = MIPI_DSI_FMT_RGB888,
+ .lanes = 4,
+};
+
static const struct udevice_id simple_panel_ids[] = {
{ .compatible = "simple-panel" },
{ .compatible = "auo,b133xtn01" },
@@ -150,7 +200,7 @@ static const struct udevice_id simple_panel_ids[] = {
{ .compatible = "sharp,lq123p1jx31" },
{ .compatible = "boe,nv101wxmn51" },
{ .compatible = "panasonic,vvx10f004b00",
- .data = PANASONIC_VVX10F004B00 },
+ .data = (ulong)&panasonic_vvx10f004b00 },
{ }
};