const struct simple_bridge_info *info;
- struct i2c_adapter *ddc;
+ struct drm_bridge *next_bridge;
struct regulator *vdd;
struct gpio_desc *enable;
};
struct edid *edid;
int ret;
- if (!sbridge->ddc)
- goto fallback;
+ if (sbridge->next_bridge->ops & DRM_BRIDGE_OP_EDID) {
+ edid = drm_bridge_get_edid(sbridge->next_bridge, connector);
+ if (!edid)
+ DRM_INFO("EDID read failed. Fallback to standard modes\n");
+ } else {
+ edid = NULL;
+ }
- edid = drm_get_edid(connector, sbridge->ddc);
if (!edid) {
- DRM_INFO("EDID readout failed, falling back to standard modes\n");
- goto fallback;
+ /*
+ * In case we cannot retrieve the EDIDs (missing or broken DDC
+ * bus from the next bridge), fallback on the XGA standards and
+ * prefer a mode pretty much anyone can handle.
+ */
+ ret = drm_add_modes_noedid(connector, 1920, 1200);
+ drm_set_preferred_mode(connector, 1024, 768);
+ return ret;
}
drm_connector_update_edid_property(connector, edid);
ret = drm_add_edid_modes(connector, edid);
kfree(edid);
- return ret;
-
-fallback:
- /*
- * In case we cannot retrieve the EDIDs (broken or missing i2c
- * bus), fallback on the XGA standards
- */
- ret = drm_add_modes_noedid(connector, 1920, 1200);
-
- /* And prefer a mode pretty much anyone can handle */
- drm_set_preferred_mode(connector, 1024, 768);
return ret;
}
{
struct simple_bridge *sbridge = drm_connector_to_simple_bridge(connector);
- /*
- * Even if we have an I2C bus, we can't assume that the cable
- * is disconnected if drm_probe_ddc fails. Some cables don't
- * wire the DDC pins, or the I2C bus might not be working at
- * all.
- */
- if (sbridge->ddc && drm_probe_ddc(sbridge->ddc))
- return connector_status_connected;
-
- return connector_status_unknown;
+ return drm_bridge_detect(sbridge->next_bridge);
}
static const struct drm_connector_funcs simple_bridge_con_funcs = {
return -EINVAL;
}
+ ret = drm_bridge_attach(bridge->encoder, sbridge->next_bridge, bridge,
+ DRM_BRIDGE_ATTACH_NO_CONNECTOR);
+ if (ret < 0)
+ return ret;
+
if (!bridge->encoder) {
DRM_ERROR("Missing encoder\n");
return -ENODEV;
ret = drm_connector_init_with_ddc(bridge->dev, &sbridge->connector,
&simple_bridge_con_funcs,
sbridge->info->connector_type,
- sbridge->ddc);
+ sbridge->next_bridge->ddc);
if (ret) {
DRM_ERROR("Failed to initialize connector\n");
return ret;
.disable = simple_bridge_disable,
};
-static struct i2c_adapter *simple_bridge_retrieve_ddc(struct device *dev)
-{
- struct device_node *phandle, *remote;
- struct i2c_adapter *ddc;
-
- remote = of_graph_get_remote_node(dev->of_node, 1, -1);
- if (!remote)
- return ERR_PTR(-EINVAL);
-
- phandle = of_parse_phandle(remote, "ddc-i2c-bus", 0);
- of_node_put(remote);
- if (!phandle)
- return ERR_PTR(-ENODEV);
-
- ddc = of_get_i2c_adapter_by_node(phandle);
- of_node_put(phandle);
- if (!ddc)
- return ERR_PTR(-EPROBE_DEFER);
-
- return ddc;
-}
-
static int simple_bridge_probe(struct platform_device *pdev)
{
struct simple_bridge *sbridge;
+ struct device_node *remote;
sbridge = devm_kzalloc(&pdev->dev, sizeof(*sbridge), GFP_KERNEL);
if (!sbridge)
sbridge->info = of_device_get_match_data(&pdev->dev);
+ /* Get the next bridge in the pipeline. */
+ remote = of_graph_get_remote_node(pdev->dev.of_node, 1, -1);
+ if (!remote)
+ return -EINVAL;
+
+ sbridge->next_bridge = of_drm_find_bridge(remote);
+ of_node_put(remote);
+
+ if (!sbridge->next_bridge) {
+ dev_dbg(&pdev->dev, "Next bridge not found, deferring probe\n");
+ return -EPROBE_DEFER;
+ }
+
+ /* Get the regulator and GPIO resources. */
sbridge->vdd = devm_regulator_get_optional(&pdev->dev, "vdd");
if (IS_ERR(sbridge->vdd)) {
int ret = PTR_ERR(sbridge->vdd);
return PTR_ERR(sbridge->enable);
}
- sbridge->ddc = simple_bridge_retrieve_ddc(&pdev->dev);
- if (IS_ERR(sbridge->ddc)) {
- if (PTR_ERR(sbridge->ddc) == -ENODEV) {
- dev_dbg(&pdev->dev,
- "No i2c bus specified. Disabling EDID readout\n");
- sbridge->ddc = NULL;
- } else {
- dev_err(&pdev->dev, "Couldn't retrieve i2c bus\n");
- return PTR_ERR(sbridge->ddc);
- }
- }
-
+ /* Register the bridge. */
sbridge->bridge.funcs = &simple_bridge_bridge_funcs;
sbridge->bridge.of_node = pdev->dev.of_node;
sbridge->bridge.timings = sbridge->info->timings;
drm_bridge_remove(&sbridge->bridge);
- if (sbridge->ddc)
- i2c_put_adapter(sbridge->ddc);
-
return 0;
}