|
23 | 23 | #include <drm/drm_bridge.h> |
24 | 24 | #include <drm/drm_edid.h> |
25 | 25 | #include <drm/drm_mipi_dsi.h> |
| 26 | +#include <drm/drm_of.h> |
26 | 27 | #include <drm/drm_print.h> |
27 | 28 | #include <drm/drm_probe_helper.h> |
28 | 29 |
|
|
34 | 35 | struct lt9611uxc { |
35 | 36 | struct device *dev; |
36 | 37 | struct drm_bridge bridge; |
37 | | - struct drm_connector connector; |
| 38 | + struct drm_bridge *next_bridge; |
38 | 39 |
|
39 | 40 | struct regmap *regmap; |
40 | 41 | /* Protects all accesses to registers by stopping the on-chip MCU */ |
@@ -120,11 +121,6 @@ static struct lt9611uxc *bridge_to_lt9611uxc(struct drm_bridge *bridge) |
120 | 121 | return container_of(bridge, struct lt9611uxc, bridge); |
121 | 122 | } |
122 | 123 |
|
123 | | -static struct lt9611uxc *connector_to_lt9611uxc(struct drm_connector *connector) |
124 | | -{ |
125 | | - return container_of(connector, struct lt9611uxc, connector); |
126 | | -} |
127 | | - |
128 | 124 | static void lt9611uxc_lock(struct lt9611uxc *lt9611uxc) |
129 | 125 | { |
130 | 126 | mutex_lock(<9611uxc->ocm_lock); |
@@ -171,20 +167,14 @@ static void lt9611uxc_hpd_work(struct work_struct *work) |
171 | 167 | struct lt9611uxc *lt9611uxc = container_of(work, struct lt9611uxc, work); |
172 | 168 | bool connected; |
173 | 169 |
|
174 | | - if (lt9611uxc->connector.dev) { |
175 | | - if (lt9611uxc->connector.dev->mode_config.funcs) |
176 | | - drm_kms_helper_hotplug_event(lt9611uxc->connector.dev); |
177 | | - } else { |
178 | | - |
179 | | - mutex_lock(<9611uxc->ocm_lock); |
180 | | - connected = lt9611uxc->hdmi_connected; |
181 | | - mutex_unlock(<9611uxc->ocm_lock); |
| 170 | + mutex_lock(<9611uxc->ocm_lock); |
| 171 | + connected = lt9611uxc->hdmi_connected; |
| 172 | + mutex_unlock(<9611uxc->ocm_lock); |
182 | 173 |
|
183 | | - drm_bridge_hpd_notify(<9611uxc->bridge, |
184 | | - connected ? |
185 | | - connector_status_connected : |
186 | | - connector_status_disconnected); |
187 | | - } |
| 174 | + drm_bridge_hpd_notify(<9611uxc->bridge, |
| 175 | + connected ? |
| 176 | + connector_status_connected : |
| 177 | + connector_status_disconnected); |
188 | 178 | } |
189 | 179 |
|
190 | 180 | static void lt9611uxc_reset(struct lt9611uxc *lt9611uxc) |
@@ -289,82 +279,13 @@ static struct mipi_dsi_device *lt9611uxc_attach_dsi(struct lt9611uxc *lt9611uxc, |
289 | 279 | return dsi; |
290 | 280 | } |
291 | 281 |
|
292 | | -static int lt9611uxc_connector_get_modes(struct drm_connector *connector) |
293 | | -{ |
294 | | - struct lt9611uxc *lt9611uxc = connector_to_lt9611uxc(connector); |
295 | | - const struct drm_edid *drm_edid; |
296 | | - int count; |
297 | | - |
298 | | - drm_edid = drm_bridge_edid_read(<9611uxc->bridge, connector); |
299 | | - drm_edid_connector_update(connector, drm_edid); |
300 | | - count = drm_edid_connector_add_modes(connector); |
301 | | - drm_edid_free(drm_edid); |
302 | | - |
303 | | - return count; |
304 | | -} |
305 | | - |
306 | | -static enum drm_connector_status lt9611uxc_connector_detect(struct drm_connector *connector, |
307 | | - bool force) |
308 | | -{ |
309 | | - struct lt9611uxc *lt9611uxc = connector_to_lt9611uxc(connector); |
310 | | - |
311 | | - return lt9611uxc->bridge.funcs->detect(<9611uxc->bridge); |
312 | | -} |
313 | | - |
314 | | -static enum drm_mode_status lt9611uxc_connector_mode_valid(struct drm_connector *connector, |
315 | | - struct drm_display_mode *mode) |
316 | | -{ |
317 | | - struct lt9611uxc_mode *lt9611uxc_mode = lt9611uxc_find_mode(mode); |
318 | | - |
319 | | - return lt9611uxc_mode ? MODE_OK : MODE_BAD; |
320 | | -} |
321 | | - |
322 | | -static const struct drm_connector_helper_funcs lt9611uxc_bridge_connector_helper_funcs = { |
323 | | - .get_modes = lt9611uxc_connector_get_modes, |
324 | | - .mode_valid = lt9611uxc_connector_mode_valid, |
325 | | -}; |
326 | | - |
327 | | -static const struct drm_connector_funcs lt9611uxc_bridge_connector_funcs = { |
328 | | - .fill_modes = drm_helper_probe_single_connector_modes, |
329 | | - .detect = lt9611uxc_connector_detect, |
330 | | - .destroy = drm_connector_cleanup, |
331 | | - .reset = drm_atomic_helper_connector_reset, |
332 | | - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, |
333 | | - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, |
334 | | -}; |
335 | | - |
336 | | -static int lt9611uxc_connector_init(struct drm_bridge *bridge, struct lt9611uxc *lt9611uxc) |
337 | | -{ |
338 | | - int ret; |
339 | | - |
340 | | - lt9611uxc->connector.polled = DRM_CONNECTOR_POLL_HPD; |
341 | | - |
342 | | - drm_connector_helper_add(<9611uxc->connector, |
343 | | - <9611uxc_bridge_connector_helper_funcs); |
344 | | - ret = drm_connector_init(bridge->dev, <9611uxc->connector, |
345 | | - <9611uxc_bridge_connector_funcs, |
346 | | - DRM_MODE_CONNECTOR_HDMIA); |
347 | | - if (ret) { |
348 | | - DRM_ERROR("Failed to initialize connector with drm\n"); |
349 | | - return ret; |
350 | | - } |
351 | | - |
352 | | - return drm_connector_attach_encoder(<9611uxc->connector, bridge->encoder); |
353 | | -} |
354 | | - |
355 | 282 | static int lt9611uxc_bridge_attach(struct drm_bridge *bridge, |
356 | 283 | enum drm_bridge_attach_flags flags) |
357 | 284 | { |
358 | 285 | struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge); |
359 | | - int ret; |
360 | | - |
361 | | - if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) { |
362 | | - ret = lt9611uxc_connector_init(bridge, lt9611uxc); |
363 | | - if (ret < 0) |
364 | | - return ret; |
365 | | - } |
366 | 286 |
|
367 | | - return 0; |
| 287 | + return drm_bridge_attach(bridge->encoder, lt9611uxc->next_bridge, |
| 288 | + bridge, flags); |
368 | 289 | } |
369 | 290 |
|
370 | 291 | static enum drm_mode_status |
@@ -525,7 +446,7 @@ static int lt9611uxc_parse_dt(struct device *dev, |
525 | 446 |
|
526 | 447 | lt9611uxc->dsi1_node = of_graph_get_remote_node(dev->of_node, 1, -1); |
527 | 448 |
|
528 | | - return 0; |
| 449 | + return drm_of_find_panel_or_bridge(dev->of_node, 2, -1, NULL, <9611uxc->next_bridge); |
529 | 450 | } |
530 | 451 |
|
531 | 452 | static int lt9611uxc_gpio_init(struct lt9611uxc *lt9611uxc) |
|
0 commit comments