aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/util.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-09-16 10:02:50 -0400
committerGitHub <noreply@github.com>2018-09-16 10:02:50 -0400
commit83397e69992aa407e3eae559fb41a991f1a68752 (patch)
tree753d2bff7a91a0fcf4fc3f3a9796b34d8b983979 /backend/drm/util.c
parentdf991a55ab23017d4c5d90d344d472e904dc682f (diff)
parentf8a50e4fe75ac01a86c94bfedf6cfbaf07c391b2 (diff)
Merge pull request #1237 from emersion/disabled-crtc
Steal CRTCs from disabled outputs
Diffstat (limited to 'backend/drm/util.c')
-rw-r--r--backend/drm/util.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/backend/drm/util.c b/backend/drm/util.c
index 050da2a6..f9637c33 100644
--- a/backend/drm/util.c
+++ b/backend/drm/util.c
@@ -223,7 +223,8 @@ struct match_state {
static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_t replaced, size_t i) {
// Finished
if (i >= st->num_res) {
- if (score > st->score || (score == st->score && replaced < st->replaced)) {
+ if (score > st->score ||
+ (score == st->score && replaced < st->replaced)) {
st->score = score;
st->replaced = replaced;
memcpy(st->best, st->res, sizeof(st->best[0]) * st->num_res);
@@ -243,29 +244,33 @@ static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_
return match_obj_(st, skips + 1, score, replaced, i + 1);
}
+ bool has_best = false;
+
/*
* 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;
+ size_t obj_score = st->objs[st->res[i]] != 0 ? 1 : 0;
+ if (match_obj_(st, skips, score + obj_score, replaced, i + 1)) {
+ has_best = 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 (match_obj_(st, skips, score, replaced, i + 1)) {
+ has_best = true;
}
}
+ if (st->exit_early) {
+ return true;
+ }
if (st->orig[i] != UNMATCHED) {
++replaced;
}
- bool has_best = false;
for (size_t candidate = 0; candidate < st->num_objs; ++candidate) {
// We tried this earlier
if (candidate == st->orig[i]) {
@@ -283,7 +288,8 @@ static bool match_obj_(struct match_state *st, size_t skips, size_t score, size_
}
st->res[i] = candidate;
- if (match_obj_(st, skips, score + 1, replaced, i + 1)) {
+ size_t obj_score = st->objs[candidate] != 0 ? 1 : 0;
+ if (match_obj_(st, skips, score + obj_score, replaced, i + 1)) {
has_best = true;
}