gl/gbm: Improve logging output

* List all connectors, modes, and encoders, even after picking one
* Add missing DRM_MODE_CONNECTOR_DPI string for logging and improve
  existing strings
* Make sure the names matches modetest/modeprint from DRM utilities

Related to #490
This commit is contained in:
Carlos Rafael Giani 2018-10-04 00:22:02 +02:00 committed by Nicolas Dufresne
parent 48460f5ace
commit 3663ad787d
2 changed files with 43 additions and 28 deletions

View file

@ -26,7 +26,6 @@
GST_DEBUG_CATEGORY_EXTERN (gst_gl_gbm_debug); GST_DEBUG_CATEGORY_EXTERN (gst_gl_gbm_debug);
#define GST_CAT_DEFAULT gst_gl_gbm_debug #define GST_CAT_DEFAULT gst_gl_gbm_debug
const gchar * const gchar *
gst_gl_gbm_get_name_for_drm_connector (drmModeConnector * connector) gst_gl_gbm_get_name_for_drm_connector (drmModeConnector * connector)
{ {
@ -54,7 +53,7 @@ gst_gl_gbm_get_name_for_drm_connector (drmModeConnector * connector)
case DRM_MODE_CONNECTOR_9PinDIN: case DRM_MODE_CONNECTOR_9PinDIN:
return "9-Pin DIN"; return "9-Pin DIN";
case DRM_MODE_CONNECTOR_DisplayPort: case DRM_MODE_CONNECTOR_DisplayPort:
return "DisplayPort"; return "DP";
case DRM_MODE_CONNECTOR_HDMIA: case DRM_MODE_CONNECTOR_HDMIA:
return "HDMI-A"; return "HDMI-A";
case DRM_MODE_CONNECTOR_HDMIB: case DRM_MODE_CONNECTOR_HDMIB:
@ -67,6 +66,8 @@ gst_gl_gbm_get_name_for_drm_connector (drmModeConnector * connector)
return "Virtual"; return "Virtual";
case DRM_MODE_CONNECTOR_DSI: case DRM_MODE_CONNECTOR_DSI:
return "DSI"; return "DSI";
case DRM_MODE_CONNECTOR_DPI:
return "DPI";
default: default:
return "<unknown>"; return "<unknown>";
} }

View file

@ -160,32 +160,41 @@ gst_gl_display_gbm_setup_drm (GstGLDisplayGBM * display_gbm)
* finally sent to, and typically connects to some form of display, like an * finally sent to, and typically connects to some form of display, like an
* HDMI TV, an LVDS panel etc. */ * HDMI TV, an LVDS panel etc. */
{ {
drmModeConnector *connector = NULL; drmModeConnector *connected_connector = NULL;
GST_DEBUG ("Checking %d DRM connector(s)", GST_DEBUG ("Checking %d DRM connector(s)",
display_gbm->drm_mode_resources->count_connectors); display_gbm->drm_mode_resources->count_connectors);
for (i = 0; i < display_gbm->drm_mode_resources->count_connectors; ++i) { for (i = 0; i < display_gbm->drm_mode_resources->count_connectors; ++i) {
connector = drmModeGetConnector (display_gbm->drm_fd, drmModeConnector *candidate_connector =
drmModeGetConnector (display_gbm->drm_fd,
display_gbm->drm_mode_resources->connectors[i]); display_gbm->drm_mode_resources->connectors[i]);
const gchar *candidate_name =
gst_gl_gbm_get_name_for_drm_connector (candidate_connector);
GST_DEBUG ("Found DRM connector #%d \"%s\" with ID %" G_GUINT32_FORMAT, i, GST_DEBUG ("Found DRM connector #%d \"%s\" with ID %" G_GUINT32_FORMAT, i,
gst_gl_gbm_get_name_for_drm_connector (connector), candidate_name, candidate_connector->connector_id);
connector->connector_id);
if (connector->connection == DRM_MODE_CONNECTED) { /* If we already picked a connector, and connected_connector is therefore
GST_DEBUG ("DRM connector #%d is connected", i); * non-NULL, then are just printing information about the other connectors
break; * for logging purposes by now, so don't actually do anything with this
* connector. Just loop instead. */
if (connected_connector != NULL) {
drmModeFreeConnector (candidate_connector);
continue;
} }
drmModeFreeConnector (connector); if (candidate_connector->connection == DRM_MODE_CONNECTED) {
connector = NULL; GST_DEBUG ("Picking DRM connector #%d because it is connected", i);
connected_connector = candidate_connector;
} else
drmModeFreeConnector (candidate_connector);
} }
if (connector == NULL) { if (connected_connector == NULL) {
GST_ERROR ("No connected DRM connector found"); GST_ERROR ("No connected DRM connector found");
goto cleanup; goto cleanup;
} }
display_gbm->drm_mode_connector = connector; display_gbm->drm_mode_connector = connected_connector;
} }
/* Check out what modes are supported by the chosen connector, /* Check out what modes are supported by the chosen connector,
@ -194,6 +203,7 @@ gst_gl_display_gbm_setup_drm (GstGLDisplayGBM * display_gbm)
{ {
int selected_mode_index = -1; int selected_mode_index = -1;
int selected_mode_area = -1; int selected_mode_area = -1;
gboolean preferred_mode_found = FALSE;
GST_DEBUG ("Checking %d DRM mode(s) from selected connector", GST_DEBUG ("Checking %d DRM mode(s) from selected connector",
display_gbm->drm_mode_connector->count_modes); display_gbm->drm_mode_connector->count_modes);
@ -215,14 +225,15 @@ gst_gl_display_gbm_setup_drm (GstGLDisplayGBM * display_gbm)
current_mode->vscan, current_mode->vrefresh, current_mode->vscan, current_mode->vrefresh,
(current_mode->type & DRM_MODE_TYPE_PREFERRED) ? TRUE : FALSE); (current_mode->type & DRM_MODE_TYPE_PREFERRED) ? TRUE : FALSE);
if ((current_mode->type & DRM_MODE_TYPE_PREFERRED) || if (!preferred_mode_found
(current_mode_area > selected_mode_area)) { && ((current_mode->type & DRM_MODE_TYPE_PREFERRED)
|| (current_mode_area > selected_mode_area))) {
display_gbm->drm_mode_info = current_mode; display_gbm->drm_mode_info = current_mode;
selected_mode_area = current_mode_area; selected_mode_area = current_mode_area;
selected_mode_index = i; selected_mode_index = i;
if (current_mode->type & DRM_MODE_TYPE_PREFERRED) if (current_mode->type & DRM_MODE_TYPE_PREFERRED)
break; preferred_mode_found = TRUE;
} }
} }
@ -231,7 +242,8 @@ gst_gl_display_gbm_setup_drm (GstGLDisplayGBM * display_gbm)
goto cleanup; goto cleanup;
} }
GST_DEBUG ("Selected DRM mode #%d", selected_mode_index); GST_DEBUG ("Selected DRM mode #%d (is preferred: %d)", selected_mode_index,
preferred_mode_found);
} }
/* Find an encoder that is attached to the chosen connector. Also find the /* Find an encoder that is attached to the chosen connector. Also find the
@ -245,34 +257,36 @@ gst_gl_display_gbm_setup_drm (GstGLDisplayGBM * display_gbm)
* used by the DRM to refer to the CRTC universally. (We need the CRTC * used by the DRM to refer to the CRTC universally. (We need the CRTC
* information for page flipping and DRM scanout framebuffer configuration.) */ * information for page flipping and DRM scanout framebuffer configuration.) */
{ {
drmModeEncoder *encoder = NULL; drmModeEncoder *selected_encoder = NULL;
GST_DEBUG ("Checking %d DRM encoder(s)", GST_DEBUG ("Checking %d DRM encoder(s)",
display_gbm->drm_mode_resources->count_encoders); display_gbm->drm_mode_resources->count_encoders);
for (i = 0; i < display_gbm->drm_mode_resources->count_encoders; ++i) { for (i = 0; i < display_gbm->drm_mode_resources->count_encoders; ++i) {
encoder = drmModeGetEncoder (display_gbm->drm_fd, drmModeEncoder *candidate_encoder =
drmModeGetEncoder (display_gbm->drm_fd,
display_gbm->drm_mode_resources->encoders[i]); display_gbm->drm_mode_resources->encoders[i]);
GST_DEBUG ("Found DRM encoder #%d \"%s\"", i, GST_DEBUG ("Found DRM encoder #%d \"%s\"", i,
gst_gl_gbm_get_name_for_drm_encoder (encoder)); gst_gl_gbm_get_name_for_drm_encoder (candidate_encoder));
if (encoder->encoder_id == display_gbm->drm_mode_connector->encoder_id) { if ((selected_encoder == NULL) &&
(candidate_encoder->encoder_id ==
display_gbm->drm_mode_connector->encoder_id)) {
selected_encoder = candidate_encoder;
GST_DEBUG ("DRM encoder #%d corresponds to selected DRM connector " GST_DEBUG ("DRM encoder #%d corresponds to selected DRM connector "
"-> selected", i); "-> selected", i);
break; } else
} drmModeFreeEncoder (candidate_encoder);
drmModeFreeEncoder (encoder);
encoder = NULL;
} }
if (encoder == NULL) { if (selected_encoder == NULL) {
GST_DEBUG ("No encoder found; searching for CRTC ID in the connector"); GST_DEBUG ("No encoder found; searching for CRTC ID in the connector");
display_gbm->crtc_id = display_gbm->crtc_id =
gst_gl_gbm_find_crtc_id_for_connector (display_gbm); gst_gl_gbm_find_crtc_id_for_connector (display_gbm);
} else { } else {
GST_DEBUG ("Using CRTC ID from selected encoder"); GST_DEBUG ("Using CRTC ID from selected encoder");
display_gbm->crtc_id = encoder->crtc_id; display_gbm->crtc_id = selected_encoder->crtc_id;
drmModeFreeEncoder (encoder); drmModeFreeEncoder (selected_encoder);
} }
if (display_gbm->crtc_id == INVALID_CRTC) { if (display_gbm->crtc_id == INVALID_CRTC) {