Lines Matching +full:dvi +full:- +full:connector
1 // SPDX-License-Identifier: GPL-2.0-only
9 #include <linux/media-bus-format.h>
26 struct drm_connector connector; member
45 drm_connector_to_tfp410(struct drm_connector *connector) in drm_connector_to_tfp410() argument
47 return container_of(connector, struct tfp410, connector); in drm_connector_to_tfp410()
50 static int tfp410_get_modes(struct drm_connector *connector) in tfp410_get_modes() argument
52 struct tfp410 *dvi = drm_connector_to_tfp410(connector); in tfp410_get_modes() local
56 if (dvi->next_bridge->ops & DRM_BRIDGE_OP_EDID) { in tfp410_get_modes()
57 drm_edid = drm_bridge_edid_read(dvi->next_bridge, connector); in tfp410_get_modes()
64 drm_edid_connector_update(connector, drm_edid); in tfp410_get_modes()
71 ret = drm_add_modes_noedid(connector, 1920, 1200); in tfp410_get_modes()
72 drm_set_preferred_mode(connector, 1024, 768); in tfp410_get_modes()
76 ret = drm_edid_connector_add_modes(connector); in tfp410_get_modes()
88 tfp410_connector_detect(struct drm_connector *connector, bool force) in tfp410_connector_detect() argument
90 struct tfp410 *dvi = drm_connector_to_tfp410(connector); in tfp410_connector_detect() local
92 return drm_bridge_detect(dvi->next_bridge); in tfp410_connector_detect()
106 struct tfp410 *dvi; in tfp410_hpd_work_func() local
108 dvi = container_of(work, struct tfp410, hpd_work.work); in tfp410_hpd_work_func()
110 if (dvi->bridge.dev) in tfp410_hpd_work_func()
111 drm_helper_hpd_irq_event(dvi->bridge.dev); in tfp410_hpd_work_func()
116 struct tfp410 *dvi = arg; in tfp410_hpd_callback() local
118 mod_delayed_work(system_wq, &dvi->hpd_work, in tfp410_hpd_callback()
125 struct tfp410 *dvi = drm_bridge_to_tfp410(bridge); in tfp410_attach() local
128 ret = drm_bridge_attach(bridge->encoder, dvi->next_bridge, bridge, in tfp410_attach()
136 if (dvi->next_bridge->ops & DRM_BRIDGE_OP_DETECT) in tfp410_attach()
137 dvi->connector.polled = DRM_CONNECTOR_POLL_HPD; in tfp410_attach()
139 dvi->connector.polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; in tfp410_attach()
141 if (dvi->next_bridge->ops & DRM_BRIDGE_OP_HPD) { in tfp410_attach()
142 INIT_DELAYED_WORK(&dvi->hpd_work, tfp410_hpd_work_func); in tfp410_attach()
143 drm_bridge_hpd_enable(dvi->next_bridge, tfp410_hpd_callback, in tfp410_attach()
144 dvi); in tfp410_attach()
147 drm_connector_helper_add(&dvi->connector, in tfp410_attach()
149 ret = drm_connector_init_with_ddc(bridge->dev, &dvi->connector, in tfp410_attach()
151 dvi->next_bridge->type, in tfp410_attach()
152 dvi->next_bridge->ddc); in tfp410_attach()
154 dev_err(dvi->dev, "drm_connector_init_with_ddc() failed: %d\n", in tfp410_attach()
159 drm_display_info_set_bus_formats(&dvi->connector.display_info, in tfp410_attach()
160 &dvi->bus_format, 1); in tfp410_attach()
162 drm_connector_attach_encoder(&dvi->connector, bridge->encoder); in tfp410_attach()
169 struct tfp410 *dvi = drm_bridge_to_tfp410(bridge); in tfp410_detach() local
171 if (dvi->connector.dev && dvi->next_bridge->ops & DRM_BRIDGE_OP_HPD) { in tfp410_detach()
172 drm_bridge_hpd_disable(dvi->next_bridge); in tfp410_detach()
173 cancel_delayed_work_sync(&dvi->hpd_work); in tfp410_detach()
179 struct tfp410 *dvi = drm_bridge_to_tfp410(bridge); in tfp410_enable() local
181 gpiod_set_value_cansleep(dvi->powerdown, 0); in tfp410_enable()
186 struct tfp410 *dvi = drm_bridge_to_tfp410(bridge); in tfp410_disable() local
188 gpiod_set_value_cansleep(dvi->powerdown, 1); in tfp410_disable()
195 if (mode->clock < 25000) in tfp410_mode_valid()
198 if (mode->clock > 165000) in tfp410_mode_valid()
211 struct tfp410 *dvi = drm_bridge_to_tfp410(bridge); in tfp410_get_input_bus_fmts() local
221 input_fmts[0] = dvi->bus_format; in tfp410_get_input_bus_fmts()
231 struct tfp410 *dvi = drm_bridge_to_tfp410(bridge); in tfp410_atomic_check() local
237 bridge_state->input_bus_cfg.flags = dvi->timings.input_bus_flags; in tfp410_atomic_check()
262 static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) in tfp410_parse_timings() argument
264 struct drm_bridge_timings *timings = &dvi->timings; in tfp410_parse_timings()
282 * In non-I2C mode, timings are configured through the BSEL, DSEL, DKEN in tfp410_parse_timings()
284 * and vendor-specific properties. in tfp410_parse_timings()
286 ep = of_graph_get_endpoint_by_regs(dvi->dev->of_node, 0, 0); in tfp410_parse_timings()
288 return -EINVAL; in tfp410_parse_timings()
291 of_property_read_u32(ep, "pclk-sample", &pclk_sample); in tfp410_parse_timings()
292 of_property_read_u32(ep, "bus-width", &bus_width); in tfp410_parse_timings()
295 timings->input_bus_flags = DRM_BUS_FLAG_DE_HIGH; in tfp410_parse_timings()
299 timings->input_bus_flags |= DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE in tfp410_parse_timings()
303 timings->input_bus_flags |= DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE in tfp410_parse_timings()
307 return -EINVAL; in tfp410_parse_timings()
312 dvi->bus_format = MEDIA_BUS_FMT_RGB888_2X12_LE; in tfp410_parse_timings()
315 dvi->bus_format = MEDIA_BUS_FMT_RGB888_1X24; in tfp410_parse_timings()
318 return -EINVAL; in tfp410_parse_timings()
321 /* Get the setup and hold time from vendor-specific properties. */ in tfp410_parse_timings()
322 of_property_read_u32(dvi->dev->of_node, "ti,deskew", &deskew); in tfp410_parse_timings()
324 return -EINVAL; in tfp410_parse_timings()
326 timings->setup_time_ps = 1200 - 350 * ((s32)deskew - 4); in tfp410_parse_timings()
327 timings->hold_time_ps = max(0, 1300 + 350 * ((s32)deskew - 4)); in tfp410_parse_timings()
335 struct tfp410 *dvi; in tfp410_init() local
338 if (!dev->of_node) { in tfp410_init()
339 dev_err(dev, "device-tree data is missing\n"); in tfp410_init()
340 return -ENXIO; in tfp410_init()
343 dvi = devm_kzalloc(dev, sizeof(*dvi), GFP_KERNEL); in tfp410_init()
344 if (!dvi) in tfp410_init()
345 return -ENOMEM; in tfp410_init()
347 dvi->dev = dev; in tfp410_init()
348 dev_set_drvdata(dev, dvi); in tfp410_init()
350 dvi->bridge.funcs = &tfp410_bridge_funcs; in tfp410_init()
351 dvi->bridge.of_node = dev->of_node; in tfp410_init()
352 dvi->bridge.timings = &dvi->timings; in tfp410_init()
353 dvi->bridge.type = DRM_MODE_CONNECTOR_DVID; in tfp410_init()
355 ret = tfp410_parse_timings(dvi, i2c); in tfp410_init()
360 node = of_graph_get_remote_node(dev->of_node, 1, -1); in tfp410_init()
362 return -ENODEV; in tfp410_init()
364 dvi->next_bridge = of_drm_find_bridge(node); in tfp410_init()
367 if (!dvi->next_bridge) in tfp410_init()
368 return -EPROBE_DEFER; in tfp410_init()
371 dvi->powerdown = devm_gpiod_get_optional(dev, "powerdown", in tfp410_init()
373 if (IS_ERR(dvi->powerdown)) { in tfp410_init()
375 return PTR_ERR(dvi->powerdown); in tfp410_init()
379 drm_bridge_add(&dvi->bridge); in tfp410_init()
386 struct tfp410 *dvi = dev_get_drvdata(dev); in tfp410_fini() local
388 drm_bridge_remove(&dvi->bridge); in tfp410_fini()
393 return tfp410_init(&pdev->dev, false); in tfp410_probe()
398 tfp410_fini(&pdev->dev); in tfp410_remove()
411 .name = "tfp410-bridge",
422 if (!client->dev.of_node || in tfp410_i2c_probe()
423 of_property_read_u32(client->dev.of_node, "reg", ®)) { in tfp410_i2c_probe()
424 dev_err(&client->dev, in tfp410_i2c_probe()
425 "Can't get i2c reg property from device-tree\n"); in tfp410_i2c_probe()
426 return -ENXIO; in tfp410_i2c_probe()
429 return tfp410_init(&client->dev, true); in tfp410_i2c_probe()
434 tfp410_fini(&client->dev); in tfp410_i2c_remove()
499 MODULE_DESCRIPTION("TI TFP410 DVI bridge driver");