summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorMun, Gwan-gyeong <kk.moon@samsung.com>2015-04-29 08:49:06 -0400
committerChris Michael <cp.michael@samsung.com>2015-04-29 08:49:06 -0400
commit648091a1ad423a2b1fcdbe40c64884bc917e6fba (patch)
tree0429ea6aed9d9f9770ee5d61909d0b1f8987a778 /src/modules
parent45abf35ec0167deaabb58fa38edb9d88adeaef50 (diff)
evas-drm: Fix evas-gl_drm picking incorrect resolution/mode for outputs
Summary: Fix evas-gl_drm picking incorrect resolution/mode for outputs reference, commit: d3a207bf9ab1246b5a5299ade7b25ee46a8e3cf7 Reviewers: zmike, cedric, raster, gwanglim, devilhorns Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2447
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/gl_drm/evas_drm.c95
1 files changed, 28 insertions, 67 deletions
diff --git a/src/modules/evas/engines/gl_drm/evas_drm.c b/src/modules/evas/engines/gl_drm/evas_drm.c
index 22d92e3..c049fb9 100644
--- a/src/modules/evas/engines/gl_drm/evas_drm.c
+++ b/src/modules/evas/engines/gl_drm/evas_drm.c
@@ -11,53 +11,6 @@ _evas_drm_fb_destroy_callback(struct gbm_bo *bo, void *data)
11 drmModeRmFB(gbm_device_get_fd(gbm), buffer->fb); 11 drmModeRmFB(gbm_device_get_fd(gbm), buffer->fb);
12} 12}
13 13
14static int
15_evas_drm_crtc_find(int fd, drmModeRes *res, drmModeConnector *conn)
16{
17 int crtc = -1;
18 drmModeEncoder *enc = NULL;
19
20 /* if this connector already has an encoder, get it */
21 if (conn->encoder_id) enc = drmModeGetEncoder(fd, conn->encoder_id);
22
23 /* if this encoder already has a crtc, lets try to use that */
24 if ((enc) && (enc->crtc_id)) crtc = enc->crtc_id;
25
26 if (crtc < 0)
27 {
28 int i = 0, c = 0;
29
30 /* if this connector has no encoder, we need to find one */
31 for (; i < conn->count_encoders; ++i)
32 {
33 /* try to get this encoder */
34 if (!(enc = drmModeGetEncoder(fd, conn->encoders[i])))
35 continue;
36
37 /* loop global crtcs */
38 for (; c < res->count_crtcs; ++c)
39 {
40 /* does this crtc work with this encoder ? */
41 if (!(enc->possible_crtcs & (1 << c))) continue;
42
43 /* FIXME: We could be more proactive here and check that
44 * nobody else is using this crtc */
45
46 /* if it works, let's use it */
47 crtc = res->crtcs[c];
48 break;
49 }
50
51 if (crtc >= 0) break;
52 }
53 }
54
55 /* free the encoder */
56 if (enc) drmModeFreeEncoder(enc);
57
58 return crtc;
59}
60
61static unsigned int 14static unsigned int
62_evas_drm_crtc_buffer_get(int fd, int crtc_id) 15_evas_drm_crtc_buffer_get(int fd, int crtc_id)
63{ 16{
@@ -186,6 +139,8 @@ evas_drm_outbuf_setup(Outbuf *ob)
186 drmModeRes *res; 139 drmModeRes *res;
187 drmModeConnector *conn; 140 drmModeConnector *conn;
188 drmModePlaneResPtr pres; 141 drmModePlaneResPtr pres;
142 drmModeEncoder *enc;
143 drmModeModeInfo crtc_mode;
189 int i = 0; 144 int i = 0;
190 145
191 /* check for valid Output buffer */ 146 /* check for valid Output buffer */
@@ -206,7 +161,7 @@ evas_drm_outbuf_setup(Outbuf *ob)
206 /* loop the connectors */ 161 /* loop the connectors */
207 for (; i < res->count_connectors; ++i) 162 for (; i < res->count_connectors; ++i)
208 { 163 {
209 int crtc = -1; 164 int crtc_id = -1;
210 int m = 0; 165 int m = 0;
211 166
212 /* try to get this connector */ 167 /* try to get this connector */
@@ -232,42 +187,48 @@ evas_drm_outbuf_setup(Outbuf *ob)
232 continue; 187 continue;
233 } 188 }
234 189
235 /* try to find a crtc for this connector */
236 if ((crtc = _evas_drm_crtc_find(ob->priv.fd, res, conn)) < 0)
237 {
238 /* free connector resources */
239 drmModeFreeConnector(conn);
240 continue;
241 }
242
243 /* record the connector id */ 190 /* record the connector id */
244 ob->priv.conn = conn->connector_id; 191 ob->priv.conn = conn->connector_id;
245 192
193 if ((enc = drmModeGetEncoder(ob->priv.fd, conn->encoder_id)))
194 {
195 drmModeCrtc *crtc;
196
197 if ((crtc = drmModeGetCrtc(ob->priv.fd, enc->crtc_id)))
198 {
199 crtc_id = enc->crtc_id;
200 if (crtc->mode_valid) crtc_mode = crtc->mode;
201 drmModeFreeCrtc(crtc);
202 }
203
204 drmModeFreeEncoder(enc);
205 }
206
246 /* record the crtc id */ 207 /* record the crtc id */
247 ob->priv.crtc = crtc; 208 ob->priv.crtc = crtc_id;
248 209
249 /* get the current framebuffer */ 210 /* get the current framebuffer */
250 ob->priv.fb = _evas_drm_crtc_buffer_get(ob->priv.fd, crtc); 211 ob->priv.fb = _evas_drm_crtc_buffer_get(ob->priv.fd, crtc_id);
251 212
252 /* record the current mode */ 213 memset(&ob->priv.mode, 0, sizeof(ob->priv.mode));
253 memcpy(&ob->priv.mode, &conn->modes[0], sizeof(ob->priv.mode));
254 214
255 for (m = 0; m < conn->count_modes; m++) 215 for (m = 0; m < conn->count_modes; m++)
256 { 216 {
257 DBG("Output Available Mode: %d: %d %d %d", ob->priv.conn, 217 DBG("Output Available Mode: %d: %d %d %d", ob->priv.conn,
258 conn->modes[m].hdisplay, conn->modes[m].vdisplay, 218 conn->modes[m].hdisplay, conn->modes[m].vdisplay,
259 conn->modes[m].vrefresh); 219 conn->modes[m].vrefresh);
260 220 if (!memcmp(&crtc_mode, &conn->modes[m], sizeof(crtc_mode)))
261 /* try to find a mode which matches the requested size */
262 if ((conn->modes[m].hdisplay == ob->w) &&
263 (conn->modes[m].vdisplay == ob->h) &&
264 (conn->modes[m].vrefresh == 60))
265 { 221 {
266 memcpy(&ob->priv.mode, &conn->modes[m], 222 /* record the current mode */
267 sizeof(ob->priv.mode)); 223 memcpy(&ob->priv.mode, &conn->modes[m], sizeof(ob->priv.mode));
224 break;
268 } 225 }
226
269 } 227 }
270 228
229 if ((!ob->priv.mode.hdisplay) && (crtc_mode.clock != 0))
230 memcpy(&ob->priv.mode, &crtc_mode, sizeof(ob->priv.mode));
231
271 DBG("Output Current Mode: %d: %d %d", ob->priv.conn, 232 DBG("Output Current Mode: %d: %d %d", ob->priv.conn,
272 ob->priv.mode.hdisplay, ob->priv.mode.vdisplay); 233 ob->priv.mode.hdisplay, ob->priv.mode.vdisplay);
273 234