This source file includes following definitions.
- edp_connector_detect
- edp_connector_destroy
- edp_connector_get_modes
- edp_connector_mode_valid
- msm_edp_connector_init
1
2
3
4
5
6 #include "drm/drm_edid.h"
7 #include "msm_kms.h"
8 #include "edp.h"
9
10 struct edp_connector {
11 struct drm_connector base;
12 struct msm_edp *edp;
13 };
14 #define to_edp_connector(x) container_of(x, struct edp_connector, base)
15
16 static enum drm_connector_status edp_connector_detect(
17 struct drm_connector *connector, bool force)
18 {
19 struct edp_connector *edp_connector = to_edp_connector(connector);
20 struct msm_edp *edp = edp_connector->edp;
21
22 DBG("");
23 return msm_edp_ctrl_panel_connected(edp->ctrl) ?
24 connector_status_connected : connector_status_disconnected;
25 }
26
27 static void edp_connector_destroy(struct drm_connector *connector)
28 {
29 struct edp_connector *edp_connector = to_edp_connector(connector);
30
31 DBG("");
32
33 drm_connector_cleanup(connector);
34
35 kfree(edp_connector);
36 }
37
38 static int edp_connector_get_modes(struct drm_connector *connector)
39 {
40 struct edp_connector *edp_connector = to_edp_connector(connector);
41 struct msm_edp *edp = edp_connector->edp;
42
43 struct edid *drm_edid = NULL;
44 int ret = 0;
45
46 DBG("");
47 ret = msm_edp_ctrl_get_panel_info(edp->ctrl, connector, &drm_edid);
48 if (ret)
49 return ret;
50
51 drm_connector_update_edid_property(connector, drm_edid);
52 if (drm_edid)
53 ret = drm_add_edid_modes(connector, drm_edid);
54
55 return ret;
56 }
57
58 static int edp_connector_mode_valid(struct drm_connector *connector,
59 struct drm_display_mode *mode)
60 {
61 struct edp_connector *edp_connector = to_edp_connector(connector);
62 struct msm_edp *edp = edp_connector->edp;
63 struct msm_drm_private *priv = connector->dev->dev_private;
64 struct msm_kms *kms = priv->kms;
65 long actual, requested;
66
67 requested = 1000 * mode->clock;
68 actual = kms->funcs->round_pixclk(kms,
69 requested, edp_connector->edp->encoder);
70
71 DBG("requested=%ld, actual=%ld", requested, actual);
72 if (actual != requested)
73 return MODE_CLOCK_RANGE;
74
75 if (!msm_edp_ctrl_pixel_clock_valid(
76 edp->ctrl, mode->clock, NULL, NULL))
77 return MODE_CLOCK_RANGE;
78
79
80 if (connector->display_info.bpc > 8)
81 return MODE_BAD;
82
83 return MODE_OK;
84 }
85
86 static const struct drm_connector_funcs edp_connector_funcs = {
87 .detect = edp_connector_detect,
88 .fill_modes = drm_helper_probe_single_connector_modes,
89 .destroy = edp_connector_destroy,
90 .reset = drm_atomic_helper_connector_reset,
91 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
92 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
93 };
94
95 static const struct drm_connector_helper_funcs edp_connector_helper_funcs = {
96 .get_modes = edp_connector_get_modes,
97 .mode_valid = edp_connector_mode_valid,
98 };
99
100
101 struct drm_connector *msm_edp_connector_init(struct msm_edp *edp)
102 {
103 struct drm_connector *connector = NULL;
104 struct edp_connector *edp_connector;
105 int ret;
106
107 edp_connector = kzalloc(sizeof(*edp_connector), GFP_KERNEL);
108 if (!edp_connector)
109 return ERR_PTR(-ENOMEM);
110
111 edp_connector->edp = edp;
112
113 connector = &edp_connector->base;
114
115 ret = drm_connector_init(edp->dev, connector, &edp_connector_funcs,
116 DRM_MODE_CONNECTOR_eDP);
117 if (ret)
118 return ERR_PTR(ret);
119
120 drm_connector_helper_add(connector, &edp_connector_helper_funcs);
121
122
123 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
124
125
126 connector->interlace_allowed = false;
127 connector->doublescan_allowed = false;
128
129 drm_connector_attach_encoder(connector, edp->encoder);
130
131 return connector;
132 }