Lines Matching full:plane
39 #define OPT_PREFER_PLANE "prefer-plane="
92 drmModePlane *plane; member
138 drm_plane *plane; member
195 static int drm_plane_get_prop(drm_ctx *ctx, drm_plane *plane, drm_plane_prop p) in drm_plane_get_prop() argument
200 if (plane->prop_ids[p]) in drm_plane_get_prop()
201 return plane->prop_ids[p]; in drm_plane_get_prop()
203 for (i = 0; i < plane->props->count_props; i++) { in drm_plane_get_prop()
204 prop = drmModeGetProperty(ctx->fd, plane->props->props[i]); in drm_plane_get_prop()
207 plane->prop_ids[p] = i; in drm_plane_get_prop()
217 drm_plane *plane, drm_plane_prop p, in drm_atomic_add_plane_prop() argument
220 int prop_idx = drm_plane_get_prop(ctx, plane, p); in drm_atomic_add_plane_prop()
224 return drmModeAtomicAddProperty(request, plane->plane_id, in drm_atomic_add_plane_prop()
225 plane->props->props[prop_idx], value); in drm_atomic_add_plane_prop()
228 static int drm_set_plane(drm_ctx *ctx, drm_crtc *crtc, drm_plane *plane, in drm_set_plane() argument
234 if (plane->cursor_plane || crtc->async_commit || !ctx->atomic) in drm_set_plane()
242 ret |= drm_atomic_add_plane_prop(ctx, req, plane, PLANE_PROP_CRTC_ID, 0); in drm_set_plane()
243 ret |= drm_atomic_add_plane_prop(ctx, req, plane, PLANE_PROP_FB_ID, 0); in drm_set_plane()
245 ret |= drm_atomic_add_plane_prop(ctx, req, plane, in drm_set_plane()
247 ret |= drm_atomic_add_plane_prop(ctx, req, plane, PLANE_PROP_FB_ID, fb); in drm_set_plane()
248 ret |= drm_atomic_add_plane_prop(ctx, req, plane, PLANE_PROP_SRC_X, 0); in drm_set_plane()
249 ret |= drm_atomic_add_plane_prop(ctx, req, plane, PLANE_PROP_SRC_Y, 0); in drm_set_plane()
250 ret |= drm_atomic_add_plane_prop(ctx, req, plane, in drm_set_plane()
253 plane, PLANE_PROP_SRC_H, h << 16); in drm_set_plane()
254 ret |= drm_atomic_add_plane_prop(ctx, req, plane, PLANE_PROP_CRTC_X, x); in drm_set_plane()
255 ret |= drm_atomic_add_plane_prop(ctx, req, plane, PLANE_PROP_CRTC_Y, y); in drm_set_plane()
256 ret |= drm_atomic_add_plane_prop(ctx, req, plane, PLANE_PROP_CRTC_W, w); in drm_set_plane()
257 ret |= drm_atomic_add_plane_prop(ctx, req, plane, PLANE_PROP_CRTC_H, h); in drm_set_plane()
272 return drmModeSetPlane(ctx->fd, plane->plane_id, crtc->crtc_id, fb, 0, in drm_set_plane()
276 static int drm_plane_get_prop_value(drm_ctx *ctx, drm_plane *plane, in drm_plane_get_prop_value() argument
279 int prop_idx = drm_plane_get_prop(ctx, plane, p); in drm_plane_get_prop_value()
283 *value = plane->props->prop_values[prop_idx]; in drm_plane_get_prop_value()
287 static int drm_plane_set_prop_max(drm_ctx *ctx, drm_plane *plane, in drm_plane_set_prop_max() argument
291 int prop_idx = drm_plane_get_prop(ctx, plane, p); in drm_plane_set_prop_max()
295 prop = drmModeGetProperty(ctx->fd, plane->props->props[prop_idx]); in drm_plane_set_prop_max()
296 drmModeObjectSetProperty (ctx->fd, plane->plane_id, in drm_plane_set_prop_max()
298 plane->props->props[prop_idx], in drm_plane_set_prop_max()
300 DRM_DEBUG("set plane %d prop: %s to max: %"PRIu64"\n", in drm_plane_set_prop_max()
301 plane->plane_id, drm_plane_prop_names[p], in drm_plane_set_prop_max()
307 static void drm_free_plane(drm_plane *plane) in drm_free_plane() argument
309 drmModeFreeObjectProperties(plane->props); in drm_free_plane()
310 drmModeFreePlane(plane->plane); in drm_free_plane()
311 free(plane); in drm_free_plane()
314 static void drm_plane_update_format(drm_ctx *ctx, drm_plane *plane) in drm_plane_update_format() argument
323 plane->can_afbc = plane->can_linear = 0; in drm_plane_update_format()
326 for (i = 0; i < plane->plane->count_formats; i++) { in drm_plane_update_format()
327 if (plane->plane->formats[i] == DRM_FORMAT_ARGB8888) in drm_plane_update_format()
330 if (i == plane->plane->count_formats) in drm_plane_update_format()
333 if (drm_plane_get_prop_value(ctx, plane, PLANE_PROP_IN_FORMATS, &value) < 0) { in drm_plane_update_format()
335 plane->can_linear = 1; in drm_plane_update_format()
357 plane->can_linear = 1; in drm_plane_update_format()
371 plane->can_afbc = 1; in drm_plane_update_format()
374 plane->can_linear = 1; in drm_plane_update_format()
383 drm_plane *plane = calloc(1, sizeof(*plane)); in drm_get_plane() local
384 if (!plane) in drm_get_plane()
387 plane->plane_id = plane_id; in drm_get_plane()
388 plane->plane = drmModeGetPlane(ctx->fd, plane_id); in drm_get_plane()
389 if (!plane->plane) in drm_get_plane()
392 plane->props = drmModeObjectGetProperties(ctx->fd, plane_id, in drm_get_plane()
394 if (!plane->props) in drm_get_plane()
397 drm_plane_update_format(ctx, plane); in drm_get_plane()
398 return plane; in drm_get_plane()
400 drm_free_plane(plane); in drm_get_plane()
577 /* Allow specifying prefer plane */ in drm_get_ctx()
606 DRM_DEBUG("found %d CRTC: %d(%d) (%dx%d) prefer plane: %d\n", in drm_get_ctx()
640 drm_plane *plane = drm_get_plane(ctx, ctx->pres->planes[i]); in drm_get_ctx() local
644 if (!plane) in drm_get_ctx()
647 drm_plane_get_prop_value(ctx, plane, PLANE_PROP_type, &value); in drm_get_ctx()
663 DRM_DEBUG("found plane: %d[%s] crtcs: 0x%x %s%s\n", in drm_get_ctx()
664 plane->plane_id, type, plane->plane->possible_crtcs, in drm_get_ctx()
665 plane->can_linear ? "(ARGB)" : "", in drm_get_ctx()
666 plane->can_afbc ? "(AFBC)" : ""); in drm_get_ctx()
668 drm_free_plane(plane); in drm_get_ctx()
688 #define drm_crtc_bind_plane_force(ctx, crtc, plane) \ argument
689 drm_crtc_bind_plane(ctx, crtc, plane, 1)
691 #define drm_crtc_bind_plane_cursor(ctx, crtc, plane) \ argument
692 drm_crtc_bind_plane(ctx, crtc, plane, 0)
697 drm_plane *plane; in drm_crtc_bind_plane() local
702 if (crtc->plane) in drm_crtc_bind_plane()
705 /* Plane already assigned */ in drm_crtc_bind_plane()
707 if (ctx->crtcs[i].plane && ctx->crtcs[i].plane->plane_id == plane_id) in drm_crtc_bind_plane()
711 plane = drm_get_plane(ctx, plane_id); in drm_crtc_bind_plane()
712 if (!plane) in drm_crtc_bind_plane()
716 if (!plane->can_afbc && !plane->can_linear) in drm_crtc_bind_plane()
720 if (!(plane->plane->possible_crtcs & (1 << crtc->crtc_pipe))) in drm_crtc_bind_plane()
724 if (drm_plane_get_prop_value(ctx, plane, PLANE_PROP_type, &value) < 0) in drm_crtc_bind_plane()
730 /* Check for overlay plane */ in drm_crtc_bind_plane()
734 plane->cursor_plane = value == DRM_PLANE_TYPE_CURSOR; in drm_crtc_bind_plane()
735 if (plane->cursor_plane) in drm_crtc_bind_plane()
736 DRM_INFO("CRTC[%d]: using cursor plane\n", crtc->crtc_id); in drm_crtc_bind_plane()
738 if (ctx->prefer_afbc_modifier && plane->can_afbc) in drm_crtc_bind_plane()
740 else if (!plane->can_linear) in drm_crtc_bind_plane()
743 DRM_DEBUG("CRTC[%d]: bind plane: %d%s\n", crtc->crtc_id, plane->plane_id, in drm_crtc_bind_plane()
746 crtc->plane = plane; in drm_crtc_bind_plane()
750 drm_free_plane(plane); in drm_crtc_bind_plane()
840 drm_plane *plane = crtc->plane; in drm_crtc_update_cursor() local
849 drm_set_plane(ctx, crtc, plane, 0, 0, 0, 0, 0); in drm_crtc_update_cursor()
873 DRM_DEBUG("CRTC[%d]: setting fb: %d (%dx%d) on plane: %d at (%d,%d)\n", in drm_crtc_update_cursor()
874 crtc->crtc_id, fb, w, h, plane->plane_id, x, y); in drm_crtc_update_cursor()
876 ret = drm_set_plane(ctx, crtc, plane, fb, x, y, w, h); in drm_crtc_update_cursor()
878 DRM_ERROR("CRTC[%d]: failed to set plane (%d)\n", crtc->crtc_id, errno); in drm_crtc_update_cursor()
940 drm_plane *plane = crtc->plane; in drm_crtc_thread_fn() local
954 if (!plane->cursor_plane) { in drm_crtc_thread_fn()
958 drmModeFreeObjectProperties(plane->props); in drm_crtc_thread_fn()
959 plane->props = drmModeObjectGetProperties(ctx->fd, plane->plane_id, in drm_crtc_thread_fn()
961 if (!plane->props) in drm_crtc_thread_fn()
965 drm_plane_set_prop_max(ctx, plane, PLANE_PROP_zpos); in drm_crtc_thread_fn()
966 drm_plane_set_prop_max(ctx, plane, PLANE_PROP_ZPOS); in drm_crtc_thread_fn()
970 !drm_plane_set_prop_max(ctx, plane, PLANE_PROP_ASYNC_COMMIT); in drm_crtc_thread_fn()
1077 if (crtc->plane) { in drm_crtc_thread_fn()
1078 drm_free_plane(crtc->plane); in drm_crtc_thread_fn()
1079 crtc->plane = NULL; in drm_crtc_thread_fn()
1097 if (crtc->plane) in drm_crtc_prepare()
1100 /* Try specific plane */ in drm_crtc_prepare()
1104 /* Try cursor plane */ in drm_crtc_prepare()
1105 for (i = 0; !crtc->plane && i < ctx->pres->count_planes; i++) in drm_crtc_prepare()
1108 /* Fallback to any available overlay plane */ in drm_crtc_prepare()
1110 for (i = ctx->pres->count_planes; !crtc->plane && i; i--) in drm_crtc_prepare()
1114 if (!crtc->plane) { in drm_crtc_prepare()
1115 DRM_ERROR("CRTC[%d]: failed to find any plane\n", crtc->crtc_id); in drm_crtc_prepare()