[PATCH v3 2/5] drm/bridge: Add .get_edid callback for anx7688 driver

From: Pin-yen Lin
Date: Sat Feb 18 2023 - 06:17:51 EST


Allow the driver to read EDID when ddc-i2c-bus phandle is present in
the device node.

Signed-off-by: Pin-yen Lin <treapking@xxxxxxxxxxxx>
---

Changes in v3:
- New in v3

drivers/gpu/drm/bridge/cros-ec-anx7688.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/bridge/cros-ec-anx7688.c b/drivers/gpu/drm/bridge/cros-ec-anx7688.c
index fa91bdeddef0..a16294c87940 100644
--- a/drivers/gpu/drm/bridge/cros-ec-anx7688.c
+++ b/drivers/gpu/drm/bridge/cros-ec-anx7688.c
@@ -6,6 +6,7 @@
*/

#include <drm/drm_bridge.h>
+#include <drm/drm_edid.h>
#include <drm/drm_print.h>
#include <linux/i2c.h>
#include <linux/module.h>
@@ -91,14 +92,24 @@ static bool cros_ec_anx7688_bridge_mode_fixup(struct drm_bridge *bridge,
return totalbw >= requiredbw;
}

+static struct edid *cros_ec_anx7688_get_edid(struct drm_bridge *bridge,
+ struct drm_connector *connector)
+{
+ struct cros_ec_anx7688 *anx7688 = bridge_to_cros_ec_anx7688(bridge);
+
+ return drm_get_edid(connector, anx7688->bridge.ddc);
+}
+
static const struct drm_bridge_funcs cros_ec_anx7688_bridge_funcs = {
.mode_fixup = cros_ec_anx7688_bridge_mode_fixup,
+ .get_edid = cros_ec_anx7688_get_edid,
};

static int cros_ec_anx7688_bridge_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct cros_ec_anx7688 *anx7688;
+ struct device_node *phandle;
u16 vendor, device, fw_version;
u8 buffer[4];
int ret;
@@ -153,6 +164,19 @@ static int cros_ec_anx7688_bridge_probe(struct i2c_client *client)
DRM_WARN("Old ANX7688 FW version (0x%04x), not filtering\n",
fw_version);

+
+ phandle = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
+ if (phandle) {
+ anx7688->bridge.ddc = of_get_i2c_adapter_by_node(phandle);
+ of_node_put(phandle);
+ if (!anx7688->bridge.ddc)
+ return -EPROBE_DEFER;
+ } else {
+ dev_dbg(dev, "No I2C bus specified, disabling EDID readout\n");
+ }
+ if (anx7688->bridge.ddc)
+ anx7688->bridge.ops |= DRM_BRIDGE_OP_EDID;
+
anx7688->bridge.funcs = &cros_ec_anx7688_bridge_funcs;
drm_bridge_add(&anx7688->bridge);

--
2.39.2.637.g21b0678d19-goog