Lines Matching +full:ddc +full:- +full:i2c

1 // SPDX-License-Identifier: GPL-2.0
7 #include <linux/i2c.h>
9 #include <linux/media-bus-format.h>
39 return flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR ? 0 : -EINVAL; in display_connector_attach()
47 if (conn->hpd_gpio) { in display_connector_detect()
48 if (gpiod_get_value_cansleep(conn->hpd_gpio)) in display_connector_detect()
54 if (conn->bridge.ddc && drm_probe_ddc(conn->bridge.ddc)) in display_connector_detect()
57 switch (conn->bridge.type) { in display_connector_detect()
64 * For DVI and HDMI connectors a DDC probe failure indicates in display_connector_detect()
74 * Composite and S-Video connectors have no other detection in display_connector_detect()
76 * an I2C bus, we can't assume that the cable is disconnected in display_connector_detect()
77 * if drm_probe_ddc fails, as some cables don't wire the DDC in display_connector_detect()
89 return drm_edid_read_ddc(connector, conn->bridge.ddc); in display_connector_edid_read()
108 if (!prev_bridge || !prev_bridge->funcs->atomic_get_output_bus_fmts) { in display_connector_get_output_bus_fmts()
109 struct drm_connector *conn = conn_state->connector; in display_connector_get_output_bus_fmts()
117 if (conn->display_info.num_bus_formats && in display_connector_get_output_bus_fmts()
118 conn->display_info.bus_formats) in display_connector_get_output_bus_fmts()
119 out_bus_fmts[0] = conn->display_info.bus_formats[0]; in display_connector_get_output_bus_fmts()
126 prev_bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state, in display_connector_get_output_bus_fmts()
129 return prev_bridge->funcs->atomic_get_output_bus_fmts(prev_bridge, prev_bridge_state, in display_connector_get_output_bus_fmts()
151 if (!prev_bridge || !prev_bridge->funcs->atomic_get_input_bus_fmts) { in display_connector_get_input_bus_fmts()
164 prev_bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state, in display_connector_get_input_bus_fmts()
167 return prev_bridge->funcs->atomic_get_input_bus_fmts(prev_bridge, prev_bridge_state, in display_connector_get_input_bus_fmts()
186 struct drm_bridge *bridge = &conn->bridge; in display_connector_hpd_irq()
197 conn->supply = devm_regulator_get_optional(&pdev->dev, name); in display_connector_get_supply()
199 if (conn->supply == ERR_PTR(-ENODEV)) in display_connector_get_supply()
200 conn->supply = NULL; in display_connector_get_supply()
202 return PTR_ERR_OR_ZERO(conn->supply); in display_connector_get_supply()
212 conn = devm_kzalloc(&pdev->dev, sizeof(*conn), GFP_KERNEL); in display_connector_probe()
214 return -ENOMEM; in display_connector_probe()
218 type = (uintptr_t)of_device_get_match_data(&pdev->dev); in display_connector_probe()
225 analog = of_property_read_bool(pdev->dev.of_node, "analog"); in display_connector_probe()
226 digital = of_property_read_bool(pdev->dev.of_node, "digital"); in display_connector_probe()
228 conn->bridge.type = DRM_MODE_CONNECTOR_DVIA; in display_connector_probe()
230 conn->bridge.type = DRM_MODE_CONNECTOR_DVID; in display_connector_probe()
232 conn->bridge.type = DRM_MODE_CONNECTOR_DVII; in display_connector_probe()
234 dev_err(&pdev->dev, "DVI connector with no type\n"); in display_connector_probe()
235 return -EINVAL; in display_connector_probe()
243 ret = of_property_read_string(pdev->dev.of_node, "type", in display_connector_probe()
246 dev_err(&pdev->dev, "HDMI connector with no type\n"); in display_connector_probe()
247 return -EINVAL; in display_connector_probe()
252 conn->bridge.type = DRM_MODE_CONNECTOR_HDMIA; in display_connector_probe()
254 conn->bridge.type = DRM_MODE_CONNECTOR_HDMIB; in display_connector_probe()
256 dev_err(&pdev->dev, in display_connector_probe()
259 return -EINVAL; in display_connector_probe()
266 conn->bridge.type = type; in display_connector_probe()
271 conn->bridge.interlace_allowed = true; in display_connector_probe()
274 of_property_read_string(pdev->dev.of_node, "label", &label); in display_connector_probe()
283 conn->hpd_gpio = devm_gpiod_get_optional(&pdev->dev, "hpd", in display_connector_probe()
285 if (IS_ERR(conn->hpd_gpio)) in display_connector_probe()
286 return dev_err_probe(&pdev->dev, PTR_ERR(conn->hpd_gpio), in display_connector_probe()
289 conn->hpd_irq = gpiod_to_irq(conn->hpd_gpio); in display_connector_probe()
291 conn->hpd_irq = -EINVAL; in display_connector_probe()
294 if (conn->hpd_irq >= 0) { in display_connector_probe()
295 ret = devm_request_threaded_irq(&pdev->dev, conn->hpd_irq, in display_connector_probe()
302 dev_info(&pdev->dev, in display_connector_probe()
304 conn->hpd_irq = -EINVAL; in display_connector_probe()
308 /* Retrieve the DDC I2C adapter for DVI, HDMI and VGA connectors. */ in display_connector_probe()
314 phandle = of_parse_phandle(pdev->dev.of_node, "ddc-i2c-bus", 0); in display_connector_probe()
316 conn->bridge.ddc = of_get_i2c_adapter_by_node(phandle); in display_connector_probe()
318 if (!conn->bridge.ddc) in display_connector_probe()
319 return -EPROBE_DEFER; in display_connector_probe()
321 dev_dbg(&pdev->dev, in display_connector_probe()
322 "No I2C bus specified, disabling EDID readout\n"); in display_connector_probe()
330 ret = display_connector_get_supply(pdev, conn, "dp-pwr"); in display_connector_probe()
332 return dev_err_probe(&pdev->dev, ret, "failed to get DP PWR regulator\n"); in display_connector_probe()
335 /* enable DDC */ in display_connector_probe()
339 conn->ddc_en = devm_gpiod_get_optional(&pdev->dev, "ddc-en", in display_connector_probe()
342 if (IS_ERR(conn->ddc_en)) { in display_connector_probe()
343 dev_err(&pdev->dev, "Couldn't get ddc-en gpio\n"); in display_connector_probe()
344 return PTR_ERR(conn->ddc_en); in display_connector_probe()
347 ret = display_connector_get_supply(pdev, conn, "hdmi-pwr"); in display_connector_probe()
349 return dev_err_probe(&pdev->dev, ret, "failed to get HDMI +5V Power regulator\n"); in display_connector_probe()
352 if (conn->supply) { in display_connector_probe()
353 ret = regulator_enable(conn->supply); in display_connector_probe()
355 dev_err(&pdev->dev, "failed to enable PWR regulator: %d\n", ret); in display_connector_probe()
360 conn->bridge.funcs = &display_connector_bridge_funcs; in display_connector_probe()
361 conn->bridge.of_node = pdev->dev.of_node; in display_connector_probe()
363 if (conn->bridge.ddc) in display_connector_probe()
364 conn->bridge.ops |= DRM_BRIDGE_OP_EDID in display_connector_probe()
366 if (conn->hpd_gpio) in display_connector_probe()
367 conn->bridge.ops |= DRM_BRIDGE_OP_DETECT; in display_connector_probe()
368 if (conn->hpd_irq >= 0) in display_connector_probe()
369 conn->bridge.ops |= DRM_BRIDGE_OP_HPD; in display_connector_probe()
371 dev_dbg(&pdev->dev, in display_connector_probe()
372 "Found %s display connector '%s' %s DDC bus and %s HPD GPIO (ops 0x%x)\n", in display_connector_probe()
373 drm_get_connector_type_name(conn->bridge.type), in display_connector_probe()
375 conn->bridge.ddc ? "with" : "without", in display_connector_probe()
376 conn->hpd_gpio ? "with" : "without", in display_connector_probe()
377 conn->bridge.ops); in display_connector_probe()
379 drm_bridge_add(&conn->bridge); in display_connector_probe()
388 if (conn->ddc_en) in display_connector_remove()
389 gpiod_set_value(conn->ddc_en, 0); in display_connector_remove()
391 if (conn->supply) in display_connector_remove()
392 regulator_disable(conn->supply); in display_connector_remove()
394 drm_bridge_remove(&conn->bridge); in display_connector_remove()
396 if (!IS_ERR(conn->bridge.ddc)) in display_connector_remove()
397 i2c_put_adapter(conn->bridge.ddc); in display_connector_remove()
402 .compatible = "composite-video-connector",
405 .compatible = "dvi-connector",
408 .compatible = "hdmi-connector",
411 .compatible = "svideo-connector",
414 .compatible = "vga-connector",
417 .compatible = "dp-connector",
428 .name = "display-connector",