1
0
mirror of https://github.com/Yours3lf/rpi-vk-driver.git synced 2024-11-29 11:24:14 +01:00

removed unnecessary stuff, filtered out some modes

This commit is contained in:
yours3lf 2020-05-31 14:00:19 +01:00
parent 806a5a5c18
commit 5db9524684
2 changed files with 22 additions and 81 deletions

View File

@ -3,86 +3,6 @@
#include <stdatomic.h>
atomic_int saved_state_guard = 0;
void modeset_enum_planes(int fd, uint32_t* numPlanes, modeset_plane* planes)
{
drmModePlaneResPtr planesPtr = drmModeGetPlaneResources(fd);
uint32_t numDisplays;
modeset_display displays[16];
modeset_enum_displays(controlFd, &numDisplays, displays);
uint32_t tmpNumPlanes = 0;
modeset_plane tmpPlanes[32];
for(uint32_t c = 0; c < planesPtr->count_planes; ++c)
{
tmpPlanes[tmpNumPlanes].plane = drmModeGetPlane(fd, planesPtr->planes[c]);
tmpPlanes[tmpNumPlanes].currentConnectorID = 0;
if(tmpPlanes[tmpNumPlanes].plane->crtc_id)
{
for(uint32_t d = 0; d < numDisplays; ++d)
{
drmModeConnectorPtr connPtr = drmModeGetConnector(fd, displays[d].connectorID);
drmModeEncoderPtr encPtr = drmModeGetEncoder(fd, connPtr->encoder_id);
uint32_t connID = connPtr->connector_id;
uint32_t crtcID = encPtr->crtc_id;
drmModeFreeConnector(connPtr);
drmModeFreeEncoder(encPtr);
if(crtcID == tmpPlanes[tmpNumPlanes].plane->crtc_id)
{
tmpPlanes[tmpNumPlanes].currentConnectorID = connID;
break;
}
}
}
tmpPlanes[tmpNumPlanes].numPossibleConnectors = 0;
for(uint32_t d = 0; d < numDisplays; ++d)
{
drmModeConnectorPtr connPtr = drmModeGetConnector(fd, displays[d].connectorID);
for(uint32_t e = 0; e < connPtr->count_encoders; ++e)
{
drmModeEncoderPtr encPtr = drmModeGetEncoder(fd, connPtr->encoders[e]);
uint32_t possibleCrtcs = encPtr->possible_crtcs;
drmModeFreeEncoder(encPtr);
if(possibleCrtcs & tmpPlanes[tmpNumPlanes].plane->possible_crtcs)
{
tmpPlanes[tmpNumPlanes].possibleConnectors[tmpPlanes[tmpNumPlanes].numPossibleConnectors] = connPtr->connector_id;
tmpPlanes[tmpNumPlanes].numPossibleConnectors++;
break;
}
}
drmModeFreeConnector(connPtr);
}
tmpNumPlanes++;
assert(tmpNumPlanes < 32);
}
drmModeFreePlaneResources(planesPtr);
*numPlanes = tmpNumPlanes;
memcpy(planes, tmpPlanes, tmpNumPlanes * sizeof(modeset_plane));
for(uint32_t c = 0; c < tmpNumPlanes; ++c)
{
memcpy(planes[c].possibleConnectors, tmpPlanes[c].possibleConnectors, tmpPlanes[c].numPossibleConnectors * sizeof(uint32_t));
}
}
void modeset_enum_displays(int fd, uint32_t* numDisplays, modeset_display* displays)
{
drmModeResPtr resPtr = drmModeGetResources(fd);
@ -143,12 +63,34 @@ void modeset_enum_modes_for_display(int fd, uint32_t display, uint32_t* numModes
for(uint32_t c = 0; c < connPtr->count_modes; ++c)
{
uint32_t found = 0;
for(uint32_t d = 0; d < tmpNumModes; ++d)
{
if(tmpModes[d].refreshRate == connPtr->modes[c].vrefresh &&
tmpModes[d].resWidth == connPtr->modes[c].hdisplay &&
tmpModes[d].resHeight == connPtr->modes[c].vdisplay)
{
found = 1;
break;
}
}
if(found)
{
//skip modes that have lower "clock"
//but otherwise same resolution and vrefresh
continue;
}
tmpModes[tmpNumModes].connectorID = display;
tmpModes[tmpNumModes].modeID = c;
tmpModes[tmpNumModes].refreshRate = connPtr->modes[c].vrefresh;
tmpModes[tmpNumModes].resWidth = connPtr->modes[c].hdisplay;
tmpModes[tmpNumModes].resHeight = connPtr->modes[c].vdisplay;
//explained here:
// https://01.org/linuxgraphics/gfx-docs/drm/API-struct-drm-display-mode.html
// char* typestr = 0;
// switch(connPtr->modes[c].type)
// {

View File

@ -56,7 +56,6 @@ typedef struct modeset_saved_state {
modeset_saved_state modeset_saved_states[32];
void modeset_enum_planes(int fd, uint32_t* numPlanes, modeset_plane* planes);
void modeset_enum_displays(int fd, uint32_t* numDisplays, modeset_display* displays);
void modeset_enum_modes_for_display(int fd, uint32_t display, uint32_t* numModes, modeset_display_mode* modes);
void modeset_create_surface_for_mode(int fd, uint32_t display, uint32_t mode, modeset_display_surface* surface);