diff options
author | Chris Michael <cp.michael@samsung.com> | 2016-10-11 11:22:40 -0400 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2016-10-11 11:30:49 -0400 |
commit | fb112b8fab68f8926604650539b5621ef3c9fbe8 (patch) | |
tree | 7fc3b090bc12a94d108e51ee5276e6440e8991a6 /src/lib/ecore_drm2 | |
parent | 304ca158be0706802407ec1c5a0d2d7634226c64 (diff) |
ecore-drm2: Use Atomic Modesetting for resolution changes
Since we have atomic properties now, we can use those to set given
Output modes (resolutions).
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_drm2')
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2_outputs.c | 123 | ||||
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2_private.h | 1 |
2 files changed, 103 insertions, 21 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c b/src/lib/ecore_drm2/ecore_drm2_outputs.c index 8171d11d16..84a6076418 100644 --- a/src/lib/ecore_drm2/ecore_drm2_outputs.c +++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c | |||
@@ -1229,11 +1229,83 @@ ecore_drm2_output_mode_info_get(Ecore_Drm2_Output_Mode *mode, int *w, int *h, un | |||
1229 | if (flags) *flags = mode->flags; | 1229 | if (flags) *flags = mode->flags; |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | #ifdef HAVE_ATOMIC_DRM | ||
1233 | static Eina_Bool | ||
1234 | _output_mode_atomic_set(Ecore_Drm2_Output *output, Ecore_Drm2_Output_Mode *mode) | ||
1235 | { | ||
1236 | Ecore_Drm2_Crtc_State *cstate; | ||
1237 | drmModeAtomicReq *req = NULL; | ||
1238 | int ret = 0; | ||
1239 | |||
1240 | cstate = output->crtc_state; | ||
1241 | |||
1242 | if (mode) | ||
1243 | { | ||
1244 | if (mode->id) | ||
1245 | drmModeDestroyPropertyBlob(output->fd, mode->id); | ||
1246 | |||
1247 | ret = | ||
1248 | drmModeCreatePropertyBlob(output->fd, &mode->info, | ||
1249 | sizeof(drmModeModeInfo), &mode->id); | ||
1250 | if (ret < 0) | ||
1251 | { | ||
1252 | ERR("Failed to create Mode Property Blob"); | ||
1253 | return EINA_FALSE; | ||
1254 | } | ||
1255 | } | ||
1256 | |||
1257 | req = drmModeAtomicAlloc(); | ||
1258 | if (!req) return EINA_FALSE; | ||
1259 | |||
1260 | drmModeAtomicSetCursor(req, 0); | ||
1261 | |||
1262 | if (mode) | ||
1263 | { | ||
1264 | cstate->active.value = 1; | ||
1265 | cstate->mode.value = mode->id; | ||
1266 | } | ||
1267 | else | ||
1268 | cstate->active.value = 0; | ||
1269 | |||
1270 | ret = drmModeAtomicAddProperty(req, cstate->obj_id, cstate->mode.id, | ||
1271 | cstate->mode.value); | ||
1272 | if (ret < 0) | ||
1273 | { | ||
1274 | ERR("Could not add atomic property"); | ||
1275 | ret = EINA_FALSE; | ||
1276 | goto err; | ||
1277 | } | ||
1278 | |||
1279 | ret = drmModeAtomicAddProperty(req, cstate->obj_id, | ||
1280 | cstate->active.id, cstate->active.value); | ||
1281 | if (ret < 0) | ||
1282 | { | ||
1283 | ERR("Could not add atomic property"); | ||
1284 | ret = EINA_FALSE; | ||
1285 | goto err; | ||
1286 | } | ||
1287 | |||
1288 | ret = drmModeAtomicCommit(output->fd, req, DRM_MODE_ATOMIC_ALLOW_MODESET, | ||
1289 | output->user_data); | ||
1290 | if (ret < 0) | ||
1291 | { | ||
1292 | ERR("Failed to commit atomic Mode: %m"); | ||
1293 | ret = EINA_FALSE; | ||
1294 | goto err; | ||
1295 | } | ||
1296 | else | ||
1297 | ret = EINA_TRUE; | ||
1298 | |||
1299 | err: | ||
1300 | drmModeAtomicFree(req); | ||
1301 | return ret; | ||
1302 | } | ||
1303 | #endif | ||
1304 | |||
1232 | EAPI Eina_Bool | 1305 | EAPI Eina_Bool |
1233 | ecore_drm2_output_mode_set(Ecore_Drm2_Output *output, Ecore_Drm2_Output_Mode *mode, int x, int y) | 1306 | ecore_drm2_output_mode_set(Ecore_Drm2_Output *output, Ecore_Drm2_Output_Mode *mode, int x, int y) |
1234 | { | 1307 | { |
1235 | Eina_Bool ret = EINA_TRUE; | 1308 | Eina_Bool ret = EINA_TRUE; |
1236 | unsigned int buffer = 0; | ||
1237 | 1309 | ||
1238 | EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE); | 1310 | EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE); |
1239 | EINA_SAFETY_ON_TRUE_RETURN_VAL((output->fd < 0), EINA_FALSE); | 1311 | EINA_SAFETY_ON_TRUE_RETURN_VAL((output->fd < 0), EINA_FALSE); |
@@ -1242,30 +1314,39 @@ ecore_drm2_output_mode_set(Ecore_Drm2_Output *output, Ecore_Drm2_Output_Mode *mo | |||
1242 | output->y = y; | 1314 | output->y = y; |
1243 | output->current_mode = mode; | 1315 | output->current_mode = mode; |
1244 | 1316 | ||
1245 | if (mode) | 1317 | #ifdef HAVE_ATOMIC_DRM |
1318 | if (_ecore_drm2_use_atomic) | ||
1319 | ret = _output_mode_atomic_set(output, mode); | ||
1320 | else | ||
1321 | #endif | ||
1246 | { | 1322 | { |
1247 | if (output->current) | 1323 | if (mode) |
1248 | buffer = output->current->id; | ||
1249 | else if (output->next) | ||
1250 | buffer = output->next->id; | ||
1251 | else | ||
1252 | buffer = output->ocrtc->buffer_id; | ||
1253 | |||
1254 | if (drmModeSetCrtc(output->fd, output->crtc_id, buffer, | ||
1255 | x, y, &output->conn_id, 1, &mode->info) < 0) | ||
1256 | { | 1324 | { |
1257 | ERR("Failed to set Mode %dx%d for Output %s: %m", | 1325 | unsigned int buffer = 0; |
1258 | mode->width, mode->height, output->name); | 1326 | |
1259 | ret = EINA_FALSE; | 1327 | if (output->current) |
1328 | buffer = output->current->id; | ||
1329 | else if (output->next) | ||
1330 | buffer = output->next->id; | ||
1331 | else | ||
1332 | buffer = output->ocrtc->buffer_id; | ||
1333 | |||
1334 | if (drmModeSetCrtc(output->fd, output->crtc_id, buffer, | ||
1335 | x, y, &output->conn_id, 1, &mode->info) < 0) | ||
1336 | { | ||
1337 | ERR("Failed to set Mode %dx%d for Output %s: %m", | ||
1338 | mode->width, mode->height, output->name); | ||
1339 | ret = EINA_FALSE; | ||
1340 | } | ||
1260 | } | 1341 | } |
1261 | } | 1342 | else |
1262 | else | ||
1263 | { | ||
1264 | if (drmModeSetCrtc(output->fd, output->crtc_id, 0, | ||
1265 | 0, 0, 0, 0, NULL) < 0) | ||
1266 | { | 1343 | { |
1267 | ERR("Failed to turn off Output %s: %m", output->name); | 1344 | if (drmModeSetCrtc(output->fd, output->crtc_id, 0, |
1268 | ret = EINA_FALSE; | 1345 | 0, 0, 0, 0, NULL) < 0) |
1346 | { | ||
1347 | ERR("Failed to turn off Output %s: %m", output->name); | ||
1348 | ret = EINA_FALSE; | ||
1349 | } | ||
1269 | } | 1350 | } |
1270 | } | 1351 | } |
1271 | 1352 | ||
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h index 04dcd1b459..e02018d2bc 100644 --- a/src/lib/ecore_drm2/ecore_drm2_private.h +++ b/src/lib/ecore_drm2/ecore_drm2_private.h | |||
@@ -161,6 +161,7 @@ struct _Ecore_Drm2_Fb | |||
161 | 161 | ||
162 | struct _Ecore_Drm2_Output_Mode | 162 | struct _Ecore_Drm2_Output_Mode |
163 | { | 163 | { |
164 | uint32_t id; | ||
164 | uint32_t flags; | 165 | uint32_t flags; |
165 | int32_t width, height; | 166 | int32_t width, height; |
166 | uint32_t refresh; | 167 | uint32_t refresh; |