*/
int gralloc_drm_init_kms(struct gralloc_drm_t *drm)
{
- drmModeConnectorPtr lvds;
- int i, ret;
-
if (drm->resources)
return 0;
drm->output_capacity = drm->resources->count_connectors;
drm->output_count = 0;
- drm->outputs = malloc(sizeof(*drm->outputs) * drm->output_capacity);
- memset(drm->outputs, 0, sizeof(*drm->outputs) * drm->output_capacity);
+ drm->outputs = calloc(sizeof(*drm->outputs), drm->output_capacity);
/* find the crtc/connector/mode to use */
- lvds = fetch_connector(drm, DRM_MODE_CONNECTOR_LVDS);
- if (lvds) {
- drm_kms_init_with_new_connector(drm, lvds);
- drmModeFreeConnector(lvds);
+ uint32_t internal_connectors[] = {
+ DRM_MODE_CONNECTOR_LVDS,
+ DRM_MODE_CONNECTOR_DSI,
+ };
+ for (size_t i = 0; i < sizeof(internal_connectors) / sizeof(uint32_t); i++) {
+ drmModeConnectorPtr connector;
+ connector = fetch_connector(drm, internal_connectors[i]);
+ if (connector) {
+ drm_kms_init_with_new_connector(drm, connector);
+ drmModeFreeConnector(connector);
+ break;
+ }
}
/* if still no connector, find first connected connector and try it */
if (!drm->primary) {
+ int i;
ALOGI("Try to find the first connected connector");
for (i = 0; i < drm->resources->count_connectors; i++) {