1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2016 Marek Vasut <marex@denx.de>
6 #include <linux/of_graph.h>
8 #include <drm/drm_atomic.h>
9 #include <drm/drm_atomic_helper.h>
10 #include <drm/drm_crtc.h>
11 #include <drm/drm_fb_cma_helper.h>
12 #include <drm/drm_gem_cma_helper.h>
13 #include <drm/drm_of.h>
14 #include <drm/drm_panel.h>
15 #include <drm/drm_plane_helper.h>
16 #include <drm/drm_probe_helper.h>
17 #include <drm/drm_simple_kms_helper.h>
19 #include "mxsfb_drv.h"
21 static struct mxsfb_drm_private
*
22 drm_connector_to_mxsfb_drm_private(struct drm_connector
*connector
)
24 return container_of(connector
, struct mxsfb_drm_private
,
28 static int mxsfb_panel_get_modes(struct drm_connector
*connector
)
30 struct mxsfb_drm_private
*mxsfb
=
31 drm_connector_to_mxsfb_drm_private(connector
);
34 return drm_panel_get_modes(mxsfb
->panel
, connector
);
40 drm_connector_helper_funcs mxsfb_panel_connector_helper_funcs
= {
41 .get_modes
= mxsfb_panel_get_modes
,
44 static enum drm_connector_status
45 mxsfb_panel_connector_detect(struct drm_connector
*connector
, bool force
)
47 struct mxsfb_drm_private
*mxsfb
=
48 drm_connector_to_mxsfb_drm_private(connector
);
51 return connector_status_connected
;
53 return connector_status_disconnected
;
56 static void mxsfb_panel_connector_destroy(struct drm_connector
*connector
)
58 struct mxsfb_drm_private
*mxsfb
=
59 drm_connector_to_mxsfb_drm_private(connector
);
62 drm_panel_detach(mxsfb
->panel
);
64 drm_connector_unregister(connector
);
65 drm_connector_cleanup(connector
);
68 static const struct drm_connector_funcs mxsfb_panel_connector_funcs
= {
69 .detect
= mxsfb_panel_connector_detect
,
70 .fill_modes
= drm_helper_probe_single_connector_modes
,
71 .destroy
= mxsfb_panel_connector_destroy
,
72 .reset
= drm_atomic_helper_connector_reset
,
73 .atomic_duplicate_state
= drm_atomic_helper_connector_duplicate_state
,
74 .atomic_destroy_state
= drm_atomic_helper_connector_destroy_state
,
77 int mxsfb_create_output(struct drm_device
*drm
)
79 struct mxsfb_drm_private
*mxsfb
= drm
->dev_private
;
82 ret
= drm_of_find_panel_or_bridge(drm
->dev
->of_node
, 0, 0,
83 &mxsfb
->panel
, &mxsfb
->bridge
);
88 mxsfb
->connector
= &mxsfb
->panel_connector
;
89 mxsfb
->connector
->dpms
= DRM_MODE_DPMS_OFF
;
90 mxsfb
->connector
->polled
= 0;
91 drm_connector_helper_add(mxsfb
->connector
,
92 &mxsfb_panel_connector_helper_funcs
);
93 ret
= drm_connector_init(drm
, mxsfb
->connector
,
94 &mxsfb_panel_connector_funcs
,
95 DRM_MODE_CONNECTOR_Unknown
);