drm: fetch formats for all planes
We were stopping at the primary plane, but we can also scanout on the overlay planes.
This commit is contained in:
parent
8828f7218b
commit
5d12da3d22
1 changed files with 18 additions and 15 deletions
31
src/drm.cpp
31
src/drm.cpp
|
@ -186,39 +186,35 @@ static uint32_t pick_plane_format( const struct wlr_drm_format_set *formats )
|
||||||
/* Pick a primary plane that can be connected to the chosen CRTC. */
|
/* Pick a primary plane that can be connected to the chosen CRTC. */
|
||||||
static struct plane *find_primary_plane(struct drm_t *drm)
|
static struct plane *find_primary_plane(struct drm_t *drm)
|
||||||
{
|
{
|
||||||
struct plane *ret = nullptr;
|
struct plane *primary = nullptr;
|
||||||
|
|
||||||
for (size_t i = 0; i < drm->planes.size() && ret == nullptr; i++) {
|
for (size_t i = 0; i < drm->planes.size(); i++) {
|
||||||
struct plane *plane = &drm->planes[i];
|
struct plane *plane = &drm->planes[i];
|
||||||
|
|
||||||
if (!(plane->plane->possible_crtcs & (1 << drm->crtc_index)))
|
if (!(plane->plane->possible_crtcs & (1 << drm->crtc_index)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!get_plane_formats(drm, plane, &drm->formats)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t plane_type = drm->planes[i].initial_prop_values["type"];
|
uint64_t plane_type = drm->planes[i].initial_prop_values["type"];
|
||||||
if (plane_type == DRM_PLANE_TYPE_PRIMARY) {
|
if (plane_type == DRM_PLANE_TYPE_PRIMARY) {
|
||||||
/* found our primary plane, let's use that */
|
primary = plane;
|
||||||
ret = plane;
|
break;
|
||||||
|
|
||||||
if (!get_plane_formats(drm, plane, &drm->plane_formats)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ret == nullptr )
|
if (primary == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
if (!get_plane_formats(drm, primary, &drm->plane_formats)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
g_nDRMFormat = pick_plane_format(&drm->plane_formats);
|
g_nDRMFormat = pick_plane_format(&drm->plane_formats);
|
||||||
if ( g_nDRMFormat == DRM_FORMAT_INVALID ) {
|
if ( g_nDRMFormat == DRM_FORMAT_INVALID ) {
|
||||||
fprintf( stderr, "Primary plane doesn't support XRGB8888 nor ARGB8888\n" );
|
fprintf( stderr, "Primary plane doesn't support XRGB8888 nor ARGB8888\n" );
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drm_free_fb( struct drm_t *drm, struct fb *fb );
|
static void drm_free_fb( struct drm_t *drm, struct fb *fb );
|
||||||
|
@ -558,6 +554,13 @@ int init_drm(struct drm_t *drm, const char *device)
|
||||||
fprintf(stderr, "failed to disable CRTC %" PRIu32 ": %s", drm->crtcs[i].id, strerror(-ret));
|
fprintf(stderr, "failed to disable CRTC %" PRIu32 ": %s", drm->crtcs[i].id, strerror(-ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch formats which can be scanned out
|
||||||
|
for (size_t i = 0; i < drm->planes.size(); i++) {
|
||||||
|
struct plane *plane = &drm->planes[i];
|
||||||
|
if (!get_plane_formats(drm, plane, &drm->formats))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
drm->plane = find_primary_plane( drm );
|
drm->plane = find_primary_plane( drm );
|
||||||
if ( drm->plane == nullptr ) {
|
if ( drm->plane == nullptr ) {
|
||||||
fprintf(stderr, "could not find a suitable primary plane\n");
|
fprintf(stderr, "could not find a suitable primary plane\n");
|
||||||
|
|
Loading…
Reference in a new issue