From 7991d1b79d2136e31af944f33f1640c9ba83a5f3 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 8 Mar 2020 15:53:40 +0100 Subject: [PATCH] intel_extreme: fix assigning pipes to displays The previous code did not handle correctly the case where a display requested a fixed mapping, and cloud end up assigning the same pipe to multiple displays. But we want a separate pipe for each display, allowing multihead support later on. Rewrite the algorithm to first assign pipes to devices with fixed constraints, and in a second pass assing the remaining pipes to other displays. --- .../accelerants/intel_extreme/accelerant.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/add-ons/accelerants/intel_extreme/accelerant.cpp b/src/add-ons/accelerants/intel_extreme/accelerant.cpp index 2849d59eaa..ad9414f436 100644 --- a/src/add-ons/accelerants/intel_extreme/accelerant.cpp +++ b/src/add-ons/accelerants/intel_extreme/accelerant.cpp @@ -433,20 +433,36 @@ assign_pipes() // assigned when the count is > 1; uint32 current = 0; + + bool assigned[gInfo->pipe_count]; + memset(assigned, 0, gInfo->pipe_count); + + // Some ports need to be assigned to a fixed pipe on old hardware (or due + // to limitations in the current driver on current hardware). Assign those + // first for (uint32 i = 0; i < gInfo->port_count; i++) { if (gInfo->ports[i] == NULL) continue; pipe_index preference = gInfo->ports[i]->PipePreference(); if (preference != INTEL_PIPE_ANY) { - // Some ports *really* need to be assigned a pipe due to - // implementation bugs. int index = (preference == INTEL_PIPE_B) ? 1 : 0; + if (assigned[index]) { + TRACE("Pipe %d is already assigned, it will drive multiple " + "displays\n", index); + } gInfo->ports[i]->SetPipe(gInfo->pipes[index]); + assigned[index] = true; continue; } + } + // In a second pass, assign the remaining ports to the remaining pipes + for (uint32 i = 0; i < gInfo->port_count; i++) { if (gInfo->ports[i]->IsConnected()) { + while (current < gInfo->pipe_count && assigned[current]) + current++; + if (current >= gInfo->pipe_count) { ERROR("%s: No pipes left to assign to port %s!\n", __func__, gInfo->ports[i]->PortName()); @@ -454,7 +470,6 @@ assign_pipes() } gInfo->ports[i]->SetPipe(gInfo->pipes[current]); - current++; } }