if (conn->hpd_gpio) { if (gpiod_get_value_cansleep(conn->hpd_gpio)) return connector_status_connected; else return connector_status_disconnected;
}
if (conn->bridge.ddc && drm_probe_ddc(conn->bridge.ddc)) return connector_status_connected;
switch (conn->bridge.type) { case DRM_MODE_CONNECTOR_DVIA: case DRM_MODE_CONNECTOR_DVID: case DRM_MODE_CONNECTOR_DVII: case DRM_MODE_CONNECTOR_HDMIA: case DRM_MODE_CONNECTOR_HDMIB: /* * For DVI and HDMI connectors a DDC probe failure indicates * that no cable is connected.
*/ return connector_status_disconnected;
case DRM_MODE_CONNECTOR_Composite: case DRM_MODE_CONNECTOR_SVIDEO: case DRM_MODE_CONNECTOR_VGA: default: /* * Composite and S-Video connectors have no other detection * mean than the HPD GPIO. For VGA connectors, even if we have * an I2C bus, we can't assume that the cable is disconnected * if drm_probe_ddc fails, as some cables don't wire the DDC * pins.
*/ return connector_status_unknown;
}
}
/* * Since this bridge is tied to the connector, it acts like a passthrough, * so concerning the output bus formats, either pass the bus formats from the * previous bridge or return fallback data like done in the bridge function: * drm_atomic_bridge_chain_select_bus_fmts(). * This supports negotiation if the bridge chain has all bits in place.
*/ static u32 *display_connector_get_output_bus_fmts(struct drm_bridge *bridge, struct drm_bridge_state *bridge_state, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state, unsignedint *num_output_fmts)
{ struct drm_bridge *prev_bridge = drm_bridge_get_prev_bridge(bridge); struct drm_bridge_state *prev_bridge_state;
/* * Since this bridge is tied to the connector, it acts like a passthrough, * so concerning the input bus formats, either pass the bus formats from the * previous bridge or MEDIA_BUS_FMT_FIXED (like select_bus_fmt_recursive()) * when atomic_get_input_bus_fmts is not supported. * This supports negotiation if the bridge chain has all bits in place.
*/ static u32 *display_connector_get_input_bus_fmts(struct drm_bridge *bridge, struct drm_bridge_state *bridge_state, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state,
u32 output_fmt, unsignedint *num_input_fmts)
{ struct drm_bridge *prev_bridge = drm_bridge_get_prev_bridge(bridge); struct drm_bridge_state *prev_bridge_state;
if (!prev_bridge || !prev_bridge->funcs->atomic_get_input_bus_fmts) {
u32 *in_bus_fmts;
type = (uintptr_t)of_device_get_match_data(&pdev->dev);
/* Get the exact connector type. */ switch (type) { case DRM_MODE_CONNECTOR_DVII: { bool analog, digital;
analog = of_property_read_bool(pdev->dev.of_node, "analog");
digital = of_property_read_bool(pdev->dev.of_node, "digital"); if (analog && !digital) {
conn->bridge.type = DRM_MODE_CONNECTOR_DVIA;
} elseif (!analog && digital) {
conn->bridge.type = DRM_MODE_CONNECTOR_DVID;
} elseif (analog && digital) {
conn->bridge.type = DRM_MODE_CONNECTOR_DVII;
} else {
dev_err(&pdev->dev, "DVI connector with no type\n"); return -EINVAL;
} break;
}
case DRM_MODE_CONNECTOR_HDMIA: { constchar *hdmi_type;
ret = of_property_read_string(pdev->dev.of_node, "type",
&hdmi_type); if (ret < 0) {
dev_err(&pdev->dev, "HDMI connector with no type\n"); return -EINVAL;
}
/* All the supported connector types support interlaced modes. */
conn->bridge.interlace_allowed = true;
if (type == DRM_MODE_CONNECTOR_HDMIA ||
type == DRM_MODE_CONNECTOR_DisplayPort)
conn->bridge.ycbcr_420_allowed = true;
/* Get the optional connector label. */
of_property_read_string(pdev->dev.of_node, "label", &label);
/* * Get the HPD GPIO for DVI, HDMI and DP connectors. If the GPIO can provide * edge interrupts, register an interrupt handler.
*/ if (type == DRM_MODE_CONNECTOR_DVII ||
type == DRM_MODE_CONNECTOR_HDMIA ||
type == DRM_MODE_CONNECTOR_DisplayPort) {
conn->hpd_gpio = devm_gpiod_get_optional(&pdev->dev, "hpd",
GPIOD_IN); if (IS_ERR(conn->hpd_gpio)) return dev_err_probe(&pdev->dev, PTR_ERR(conn->hpd_gpio), "Unable to retrieve HPD GPIO\n");
if (conn->hpd_irq >= 0) {
ret = devm_request_threaded_irq(&pdev->dev, conn->hpd_irq,
NULL, display_connector_hpd_irq,
IRQF_TRIGGER_RISING |
IRQF_TRIGGER_FALLING |
IRQF_ONESHOT, "HPD", conn); if (ret) {
dev_info(&pdev->dev, "Failed to request HPD edge interrupt, falling back to polling\n");
conn->hpd_irq = -EINVAL;
}
}
/* Retrieve the DDC I2C adapter for DVI, HDMI and VGA connectors. */ if (type == DRM_MODE_CONNECTOR_DVII ||
type == DRM_MODE_CONNECTOR_HDMIA ||
type == DRM_MODE_CONNECTOR_VGA) { struct device_node *phandle;
phandle = of_parse_phandle(pdev->dev.of_node, "ddc-i2c-bus", 0); if (phandle) {
conn->bridge.ddc = of_get_i2c_adapter_by_node(phandle);
of_node_put(phandle); if (!conn->bridge.ddc) return -EPROBE_DEFER;
} else {
dev_dbg(&pdev->dev, "No I2C bus specified, disabling EDID readout\n");
}
}
/* Get the DP PWR for DP connector. */ if (type == DRM_MODE_CONNECTOR_DisplayPort) { int ret;
ret = display_connector_get_supply(pdev, conn, "dp-pwr"); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "failed to get DP PWR regulator\n");
}
/* enable DDC */ if (type == DRM_MODE_CONNECTOR_HDMIA) { int ret;
if (IS_ERR(conn->ddc_en)) {
dev_err(&pdev->dev, "Couldn't get ddc-en gpio\n"); return PTR_ERR(conn->ddc_en);
}
ret = display_connector_get_supply(pdev, conn, "hdmi-pwr"); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "failed to get HDMI +5V Power regulator\n");
}
if (conn->supply) {
ret = regulator_enable(conn->supply); if (ret) {
dev_err(&pdev->dev, "failed to enable PWR regulator: %d\n", ret); return ret;
}
}
conn->bridge.of_node = pdev->dev.of_node;
if (conn->bridge.ddc)
conn->bridge.ops |= DRM_BRIDGE_OP_EDID
| DRM_BRIDGE_OP_DETECT; /* Detecting the monitor requires reading DPCD */ if (conn->hpd_gpio && type != DRM_MODE_CONNECTOR_DisplayPort)
conn->bridge.ops |= DRM_BRIDGE_OP_DETECT; if (conn->hpd_irq >= 0)
conn->bridge.ops |= DRM_BRIDGE_OP_HPD;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.