diff options
Diffstat (limited to 'backend/drm/util.c')
-rw-r--r-- | backend/drm/util.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/backend/drm/util.c b/backend/drm/util.c index baacbfa8..050da2a6 100644 --- a/backend/drm/util.c +++ b/backend/drm/util.c @@ -144,6 +144,9 @@ const char *conn_get_name(uint32_t type_id) { case DRM_MODE_CONNECTOR_eDP: return "eDP"; case DRM_MODE_CONNECTOR_VIRTUAL: return "Virtual"; case DRM_MODE_CONNECTOR_DSI: return "DSI"; +#ifdef DRM_MODE_CONNECTOR_DPI + case DRM_MODE_CONNECTOR_DPI: return "DPI"; +#endif default: return "Unknown"; } } @@ -225,9 +228,6 @@ static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_ st->replaced = replaced; memcpy(st->best, st->res, sizeof(st->best[0]) * st->num_res); - if (st->score == st->num_objs && st->replaced == 0) { - st->exit_early = true; - } st->exit_early = (st->score == st->num_res - skips || st->score == st->num_objs) && st->replaced == 0; @@ -247,37 +247,44 @@ static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_ * Attempt to use the current solution first, to try and avoid * recalculating everything */ - if (st->orig[i] != UNMATCHED && !is_taken(i, st->res, st->orig[i])) { st->res[i] = st->orig[i]; if (match_obj_(st, skips, score + 1, replaced, i + 1)) { return true; } } + if (st->orig[i] == UNMATCHED) { + st->res[i] = UNMATCHED; + match_obj_(st, skips, score, replaced, i + 1); + if (st->exit_early) { + return true; + } + } if (st->orig[i] != UNMATCHED) { ++replaced; } - bool is_best = false; - for (st->res[i] = 0; st->res[i] < st->num_objs; ++st->res[i]) { + bool has_best = false; + for (size_t candidate = 0; candidate < st->num_objs; ++candidate) { // We tried this earlier - if (st->res[i] == st->orig[i]) { + if (candidate == st->orig[i]) { continue; } // Not compatible - if (!(st->objs[st->res[i]] & (1 << i))) { + if (!(st->objs[candidate] & (1 << i))) { continue; } // Already taken - if (is_taken(i, st->res, st->res[i])) { + if (is_taken(i, st->res, candidate)) { continue; } + st->res[i] = candidate; if (match_obj_(st, skips, score + 1, replaced, i + 1)) { - is_best = true; + has_best = true; } if (st->exit_early) { @@ -285,7 +292,7 @@ static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_ } } - if (is_best) { + if (has_best) { return true; } @@ -298,6 +305,9 @@ size_t match_obj(size_t num_objs, const uint32_t objs[static restrict num_objs], size_t num_res, const uint32_t res[static restrict num_res], uint32_t out[static restrict num_res]) { uint32_t solution[num_res]; + for (size_t i = 0; i < num_res; ++i) { + solution[i] = UNMATCHED; + } struct match_state st = { .num_objs = num_objs, |