Skip to contentSkip to conversation

Take Connection state into account. (v2)

PATCH In review Mauro Rossi 4 participants 9 messages Jan 6, 2018 – Feb 2, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Take Connection state into account. (v2)

Porting of original commit 76fb87e675 of Jim Bish in android-ia master to fdo

Original commit message:
"There are various places where we should be really taking connection state into account before querying the properties or assuming it as primary. This patch fixes them."

(v2) checks on connection state are applied for both internal and external connectors, in order to select the correct primary, as opposed to setting, independently from its state, the first connector as primary

This is essential to avoid following logcat errors on integrated and dedicated GPUs:

... 2245  2245 E hwc-drm-resources: Could not find a suitable encoder/crtc for display 2
... 2245  2245 E hwc-drm-resources: Failed CreateDisplayPipe 56 with -19
... 2245  2245 E hwcomposer-drm: Can't initialize Drm object -19

Tested with i965 on Sandybridge and nouveau on GT120, GT610

---
 drmresources.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drmresources.cpp +7 -2
index 32dd376..d582cfe 100644
@@ -159,7 +159,7 @@ int DrmResources::Init() {
 
   // First look for primary amongst internal connectors
   for (auto &conn : connectors_) {
-    if (conn->internal() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->internal() && !found_primary) {
       conn->set_display(0);
       found_primary = true;
     } else {
@@ -170,7 +170,7 @@ int DrmResources::Init() {
 
   // Then look for primary amongst external connectors
   for (auto &conn : connectors_) {
-    if (conn->external() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->external() && !found_primary) {
       conn->set_display(0);
       found_primary = true;
     }
@@ -288,6 +288,11 @@ int DrmResources::TryEncoderForDisplay(int display, DrmEncoder *enc) {
 
 int DrmResources::CreateDisplayPipe(DrmConnector *connector) {
   int display = connector->display();
+
+  // skip not connected
+  if (connector->state() == DRM_MODE_DISCONNECTED)
+    return 0;
+
   /* Try to use current setup first */
   if (connector->encoder()) {
     int ret = TryEncoderForDisplay(display, connector->encoder());
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 1/1 Update external connectors list

DVID, DVII and VGA are required by discrete and integrated GPUs

---
 drmconnector.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drmconnector.cpp +3 -1
index 247f56b..145518f 100644
@@ -73,7 +73,9 @@ bool DrmConnector::internal() const {
 }
 
 bool DrmConnector::external() const {
-  return type_ == DRM_MODE_CONNECTOR_HDMIA;
+  return type_ == DRM_MODE_CONNECTOR_HDMIA || type_ == DRM_MODE_CONNECTOR_DisplayPort ||
+         type_ == DRM_MODE_CONNECTOR_DVID || type_ == DRM_MODE_CONNECTOR_DVII ||
+         type_ == DRM_MODE_CONNECTOR_VGA;
 }
 
 bool DrmConnector::valid_type() const {
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
In reply to Mauro Rossi

Hey Mauro!

Thanks for the v2, I would like to merge this, but the commit message is a little bit wonky still :)

Let me clean it up for you, and if you're fine with me adding your S-o-B I'll push it.

Also, if you want to avoid the slow mailing list back and forth, I would happily help out over IRC too. You can find me on freenode with the nick robertfoss. #dri-devel is also a good channel for this kind of work.

Quoted 11 lines · Mauro Rossi

Porting of original commit 76fb87e675 of Jim Bish in android-ia master to fdo

Original commit message:
"There are various places where we should be really taking connection state into account before querying the properties or assuming it as primary. This patch fixes them."

(v2) checks on connection state are applied for both internal and external connectors, in order to select the correct primary, as opposed to setting, independently from its state, the first connector as primary

Quoted 7 lines

This is essential to avoid following logcat errors on integrated and dedicated GPUs:

... 2245  2245 E hwc-drm-resources: Could not find a suitable encoder/crtc for display 2
... 2245  2245 E hwc-drm-resources: Failed CreateDisplayPipe 56 with -19
... 2245  2245 E hwcomposer-drm: Can't initialize Drm object -19

Tested with i965 on Sandybridge and nouveau on GT120, GT610

This is what I would expect the commit message to look like:

Take Connection state into account

There are various places where we should be really taking connection state into account before querying the properties or assuming it as primary. This patch fixes them.

Checks on connection state are applied for both internal and external connectors, in order to select the correct primary, as opposed to setting, independently from its state, the first connector as primary.

This is essential to avoid following logcat errors on integrated and dedicated GPUs:

... 2245  2245 E hwc-drm-resources: Could not find a suitable encoder/crtc for display 2
... 2245  2245 E hwc-drm-resources: Failed CreateDisplayPipe 56 with -19
... 2245  2245 E hwcomposer-drm: Can't initialize Drm object -19

Tested with i965 on Sandybridge and nouveau on GT120, GT610

Signed-off-by Mauro Rossi <Mauro Rossi <[email protected]>
Quoted 29 lines
---
  drmresources.cpp | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drmresources.cpp +2 -2
index 32dd376..d582cfe 100644
@@ -159,7 +159,7 @@ int DrmResources::Init() {
 
    // First look for primary amongst internal connectors
    for (auto &conn : connectors_) {
-    if (conn->internal() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->internal() && !found_primary) {
        conn->set_display(0);
        found_primary = true;
      } else {
@@ -170,7 +170,7 @@ int DrmResources::Init() {
 
    // Then look for primary amongst external connectors
    for (auto &conn : connectors_) {
-    if (conn->external() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->external() && !found_primary) {
        conn->set_display(0);
        found_primary = true;
      }
@@ -288,6 +288,11 @@ int DrmResources::TryEncoderForDisplay(int display, DrmEncoder *enc) {
 

drmresources.cpp int DrmResources::TryEncoderForDisplay(int display, DrmEncoder *enc) { · line 298

Quoted 10 lines
drmresources.cpp +5 -0
  int DrmResources::CreateDisplayPipe(DrmConnector *connector) {
    int display = connector->display();
+
+  // skip not connected
+  if (connector->state() == DRM_MODE_DISCONNECTED)
+    return 0;
+
    /* Try to use current setup first */
    if (connector->encoder()) {
      int ret = TryEncoderForDisplay(display, connector->encoder());

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

Re: [drm_hwcomposer] [PATCH] Update external connectors list

In reply to Mauro Rossi

Hey Mauro,

This patch looks good to me apart from the commit message formatting. If you tell me I can add your SOB, I'll merge it with the below commit message.

Quoted 1 line · Mauro Rossi

DVID, DVII and VGA are required by discrete and integrated GPUs

I would expect something like:

Update external connectors list

VID, DVII and VGA are required by discrete and integrated GPUs.

Signed-off-by Mauro Rossi <Mauro Rossi <[email protected]>>
Quoted 10 lines
---
  drmconnector.cpp | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drmconnector.cpp +0 -0
index 247f56b..145518f 100644

drmconnector.cpp bool DrmConnector::internal() const { · line 81

Quoted 10 lines
drmconnector.cpp +3 -1
@@ -73,7 +73,9 @@ bool DrmConnector::internal() const {
  }
 
  bool DrmConnector::external() const {
-  return type_ == DRM_MODE_CONNECTOR_HDMIA;
+  return type_ == DRM_MODE_CONNECTOR_HDMIA || type_ == DRM_MODE_CONNECTOR_DisplayPort ||
+         type_ == DRM_MODE_CONNECTOR_DVID || type_ == DRM_MODE_CONNECTOR_DVII ||
+         type_ == DRM_MODE_CONNECTOR_VGA;
  }
 
  bool DrmConnector::valid_type() const {

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
In reply to Mauro Rossi
Quoted 36 lines · Mauro Rossi

Porting of original commit 76fb87e675 of Jim Bish in android-ia master to fdo

Original commit message:
"There are various places where we should be really taking connection state into account before querying the properties or assuming it as primary. This patch fixes them."

(v2) checks on connection state are applied for both internal and external connectors, in order to select the correct primary, as opposed to setting, independently from its state, the first connector as primary

This is essential to avoid following logcat errors on integrated and dedicated GPUs:

... 2245  2245 E hwc-drm-resources: Could not find a suitable encoder/crtc for display 2
... 2245  2245 E hwc-drm-resources: Failed CreateDisplayPipe 56 with -19
... 2245  2245 E hwcomposer-drm: Can't initialize Drm object -19

Tested with i965 on Sandybridge and nouveau on GT120, GT610

---
 drmresources.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drmresources.cpp +1 -1
index 32dd376..d582cfe 100644
@@ -159,7 +159,7 @@ int DrmResources::Init() {
 
   // First look for primary amongst internal connectors
   for (auto &conn : connectors_) {
-    if (conn->internal() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->internal() && !found_primary) {
       conn->set_display(0);
       found_primary = true;
     } else {

drmresources.cpp int DrmResources::Init() { · line 173

Quoted 5 lines
drmresources.cpp +1 -1
@@ -170,7 +170,7 @@ int DrmResources::Init() {
 
   // Then look for primary amongst external connectors
   for (auto &conn : connectors_) {
-    if (conn->external() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->external() && !found_primary) {

These 2 lines exceed the max character limit. Did you run clang-format?

Anyways, I think it'd be nice to add a connected() helper to the connector object which would look cleaner and solve the long lines.

Sean

Quoted 22 lines
drmresources.cpp +5 -0
       conn->set_display(0);
       found_primary = true;
     }
@@ -288,6 +288,11 @@ int DrmResources::TryEncoderForDisplay(int display, DrmEncoder *enc) {
 
 int DrmResources::CreateDisplayPipe(DrmConnector *connector) {
   int display = connector->display();
+
+  // skip not connected
+  if (connector->state() == DRM_MODE_DISCONNECTED)
+    return 0;
+
   /* Try to use current setup first */
   if (connector->encoder()) {
     int ret = TryEncoderForDisplay(display, connector->encoder());
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw
Quoted 29 lines · Sean Paul
Quoted 28 lines · Mauro Rossi

Porting of original commit 76fb87e675 of Jim Bish in android-ia master to fdo

Original commit message:
"There are various places where we should be really taking connection state into account before querying the properties or assuming it as primary. This patch fixes them."

(v2) checks on connection state are applied for both internal and external connectors, in order to select the correct primary, as opposed to setting, independently from its state, the first connector as primary

This is essential to avoid following logcat errors on integrated and dedicated GPUs:

... 2245  2245 E hwc-drm-resources: Could not find a suitable encoder/crtc for display 2
... 2245  2245 E hwc-drm-resources: Failed CreateDisplayPipe 56 with -19
... 2245  2245 E hwcomposer-drm: Can't initialize Drm object -19

Tested with i965 on Sandybridge and nouveau on GT120, GT610

---
 drmresources.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drmresources.cpp +0 -0
index 32dd376..d582cfe 100644
@@ -159,7 +159,7 @@ int DrmResources::Init() {
 
Quoted 4 lines

drmresources.cpp int DrmResources::Init() { · line 162

Quoted 4 lines
drmresources.cpp +1 -1
   // First look for primary amongst internal connectors
   for (auto &conn : connectors_) {
-    if (conn->internal() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->internal() && !found_primary) {

One more thing. How do you know this is the right thing to do? What if the internal panel is not connected initially, but becomes connected in the future? IIUC, you'll end up numbering it incorrectly.

Sean

Quoted 42 lines

drmresources.cpp int DrmResources::Init() { · line 173

Quoted 9 lines
drmresources.cpp +1 -1
       conn->set_display(0);
       found_primary = true;
     } else {
@@ -170,7 +170,7 @@ int DrmResources::Init() {
 
   // Then look for primary amongst external connectors
   for (auto &conn : connectors_) {
-    if (conn->external() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->external() && !found_primary) {

These 2 lines exceed the max character limit. Did you run clang-format?

Anyways, I think it'd be nice to add a connected() helper to the connector object which would look cleaner and solve the long lines.

Sean

Quoted 22 lines
drmresources.cpp +5 -0
       conn->set_display(0);
       found_primary = true;
     }
@@ -288,6 +288,11 @@ int DrmResources::TryEncoderForDisplay(int display, DrmEncoder *enc) {
 
 int DrmResources::CreateDisplayPipe(DrmConnector *connector) {
   int display = connector->display();
+
+  // skip not connected
+  if (connector->state() == DRM_MODE_DISCONNECTED)
+    return 0;
+
   /* Try to use current setup first */
   if (connector->encoder()) {
     int ret = TryEncoderForDisplay(display, connector->encoder());
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

Il 08/gen/2018 09:46 PM, "Sean Paul" <[email protected]> ha scritto:

Quoted 2 lines · Sean Paul
Quoted 1 line · Mauro Rossi

Porting of original commit 76fb87e675 of Jim Bish in android-ia master

to fdo

Quoted 7 lines
Quoted 7 lines

Original commit message:
"There are various places where we should be really taking connection state into account before querying the properties or assuming it as primary. This patch fixes them."

(v2) checks on connection state are applied for both internal and

external

Quoted 1 line
Quoted 1 line

connectors, in order to select the correct primary, as opposed to

setting,

Quoted 3 lines
Quoted 3 lines

independently from its state, the first connector as primary

This is essential to avoid following logcat errors on integrated and

dedicated GPUs:

Quoted 2 lines
Quoted 2 lines

... 2245 2245 E hwc-drm-resources: Could not find a suitable

encoder/crtc for display 2

Quoted 14 lines
Quoted 14 lines

... 2245 2245 E hwc-drm-resources: Failed CreateDisplayPipe 56 with -19 ... 2245 2245 E hwcomposer-drm: Can't initialize Drm object -19

Tested with i965 on Sandybridge and nouveau on GT120, GT610

---
 drmresources.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drmresources.cpp +0 -0
index 32dd376..d582cfe 100644
@@ -159,7 +159,7 @@ int DrmResources::Init() {
 
Quoted 4 lines

drmresources.cpp int DrmResources::Init() {

Quoted 4 lines
drmresources.cpp +1 -1
   // First look for primary amongst internal connectors
   for (auto &conn : connectors_) {
-    if (conn->internal() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->internal() &&

!found_primary) {

One more thing. How do you know this is the right thing to do? What if the internal panel is not connected initially, but becomes connected in the future?
IIUC, you'll end up numbering it incorrectly.

Sean

Unfortunately I don't have knowledge/experience about the drm mode code, but analyzing logs in nouveau with dedicated GPU shows a problem in current code.

You are asking if taking connection state into account will work in dynamic scenario of plugging/unplugging cable/conn,
but let's start from acknowledging that current code results in 'no screen output', because it bails out too soon, and taking connection state into account allows to boot with nouveau, which is the goal of having moved drm_hwcomposer to fd.o

IMHO to bo able to boot Android drm_hwcomposer+gbm_gralloc with nouveau is a substantial improvement

Quoted 9 lines

drmresources.cpp int DrmResources::Init() { · line 173

Quoted 9 lines
drmresources.cpp +1 -1
       conn->set_display(0);
       found_primary = true;
     } else {
@@ -170,7 +170,7 @@ int DrmResources::Init() {
 
   // Then look for primary amongst external connectors
   for (auto &conn : connectors_) {
-    if (conn->external() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->external() &&

!found_primary) {

Quoted 7 lines

These 2 lines exceed the max character limit. Did you run clang-format?

Anyways, I think it'd be nice to add a connected() helper to the connector object which would look cleaner and solve the long lines.

Sean

Thanks for feedback, we will have a look with Robert to improve coding style

Quoted 5 lines

drmresources.cpp int DrmResources::TryEncoderForDisplay(int

Quoted 5 lines
drmresources.cpp +0 -0
       conn->set_display(0);
       found_primary = true;
     }
@@ -288,6 +288,11 @@ int DrmResources::TryEncoderForDisplay(int

display, DrmEncoder *enc) {

Quoted 14 lines
Quoted 14 lines
drmresources.cpp +5 -1
 int DrmResources::CreateDisplayPipe(DrmConnector *connector) {
   int display = connector->display();
+
+  // skip not connected
+  if (connector->state() == DRM_MODE_DISCONNECTED)
+    return 0;
+
   /* Try to use current setup first */
   if (connector->encoder()) {
     int ret = TryEncoderForDisplay(display, connector->encoder());
--

2.14.1

Quoted 7 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Sean Paul, Software Engineer, Google / Chromium OS

--
Sean Paul, Software Engineer, Google / Chromium OS

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
Quoted 62 lines · Mauro Rossi

Il 08/gen/2018 09:46 PM, "Sean Paul" <[email protected]> ha scritto:

Quoted 2 lines · Sean Paul
Quoted 1 line · Mauro Rossi

Porting of original commit 76fb87e675 of Jim Bish in android-ia master

to fdo

Quoted 7 lines
Quoted 7 lines

Original commit message:
"There are various places where we should be really taking connection state into account before querying the properties or assuming it as primary. This patch fixes them."

(v2) checks on connection state are applied for both internal and

external

Quoted 1 line
Quoted 1 line

connectors, in order to select the correct primary, as opposed to

setting,

Quoted 3 lines
Quoted 3 lines

independently from its state, the first connector as primary

This is essential to avoid following logcat errors on integrated and

dedicated GPUs:

Quoted 2 lines
Quoted 2 lines

... 2245 2245 E hwc-drm-resources: Could not find a suitable

encoder/crtc for display 2

Quoted 14 lines
Quoted 14 lines

... 2245 2245 E hwc-drm-resources: Failed CreateDisplayPipe 56 with -19 ... 2245 2245 E hwcomposer-drm: Can't initialize Drm object -19

Tested with i965 on Sandybridge and nouveau on GT120, GT610

---
 drmresources.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drmresources.cpp +0 -0
index 32dd376..d582cfe 100644
@@ -159,7 +159,7 @@ int DrmResources::Init() {
 
Quoted 4 lines

drmresources.cpp int DrmResources::Init() {

Quoted 4 lines
drmresources.cpp +1 -1
   // First look for primary amongst internal connectors
   for (auto &conn : connectors_) {
-    if (conn->internal() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->internal() &&

!found_primary) {

One more thing. How do you know this is the right thing to do? What if the internal panel is not connected initially, but becomes connected in the future?
IIUC, you'll end up numbering it incorrectly.

Sean

Unfortunately I don't have knowledge/experience about the drm mode code, but analyzing logs in nouveau with dedicated GPU shows a problem in current code.

You are asking if taking connection state into account will work in dynamic scenario of plugging/unplugging cable/conn,
but let's start from acknowledging that current code results in 'no screen output', because it bails out too soon, and taking connection state into account allows to boot with nouveau, which is the goal of having moved drm_hwcomposer to fd.o

Quoted 2 lines

IMHO to bo able to boot Android drm_hwcomposer+gbm_gralloc with nouveau is a substantial improvement

I completely agree! However, I don't think it's unreasonable to have discussion around how we fix bugs.

I'm concerned that while this will result in a working setup if everything is plugged on startup, it creates new problems around hotplugging. For instance, by gating CreateDisplayPipe on the display being connected, we're no longer mapping crtc/encoders to displays. I think this will cause problems down the road if a monitor is plugged into one of these skipped displays. So this patch fixes a bug by introducing a regression.

Sean

Quoted 54 lines
Quoted 8 lines
Quoted 8 lines
drmresources.cpp +0 -0
       conn->set_display(0);
       found_primary = true;
     } else {
@@ -170,7 +170,7 @@ int DrmResources::Init() {
 
Quoted 4 lines

drmresources.cpp int DrmResources::Init() {

Quoted 4 lines
drmresources.cpp +1 -1
   // Then look for primary amongst external connectors
   for (auto &conn : connectors_) {
-    if (conn->external() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->external() &&

!found_primary) {

Quoted 7 lines

These 2 lines exceed the max character limit. Did you run clang-format?

Anyways, I think it'd be nice to add a connected() helper to the connector object which would look cleaner and solve the long lines.

Sean

Thanks for feedback, we will have a look with Robert to improve coding style

Quoted 5 lines

drmresources.cpp int DrmResources::TryEncoderForDisplay(int

Quoted 5 lines
drmresources.cpp +0 -0
       conn->set_display(0);
       found_primary = true;
     }
@@ -288,6 +288,11 @@ int DrmResources::TryEncoderForDisplay(int

display, DrmEncoder *enc) {

Quoted 14 lines
Quoted 14 lines
drmresources.cpp +5 -1
 int DrmResources::CreateDisplayPipe(DrmConnector *connector) {
   int display = connector->display();
+
+  // skip not connected
+  if (connector->state() == DRM_MODE_DISCONNECTED)
+    return 0;
+
   /* Try to use current setup first */
   if (connector->encoder()) {
     int ret = TryEncoderForDisplay(display, connector->encoder());
--

2.14.1

Quoted 7 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Sean Paul, Software Engineer, Google / Chromium OS

--
Sean Paul, Software Engineer, Google / Chromium OS

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw
In reply to Sean Paul
Quoted 30 lines · Sean Paul
Quoted 29 lines · Sean Paul
Quoted 28 lines · Mauro Rossi

Porting of original commit 76fb87e675 of Jim Bish in android-ia master to fdo

Original commit message:
"There are various places where we should be really taking connection state into account before querying the properties or assuming it as primary. This patch fixes them."

(v2) checks on connection state are applied for both internal and external connectors, in order to select the correct primary, as opposed to setting, independently from its state, the first connector as primary

This is essential to avoid following logcat errors on integrated and dedicated GPUs:

... 2245  2245 E hwc-drm-resources: Could not find a suitable encoder/crtc for display 2
... 2245  2245 E hwc-drm-resources: Failed CreateDisplayPipe 56 with -19
... 2245  2245 E hwcomposer-drm: Can't initialize Drm object -19

Tested with i965 on Sandybridge and nouveau on GT120, GT610

---
 drmresources.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drmresources.cpp +0 -0
index 32dd376..d582cfe 100644
@@ -159,7 +159,7 @@ int DrmResources::Init() {
 
Quoted 8 lines
Quoted 4 lines

drmresources.cpp int DrmResources::Init() { · line 162

Quoted 4 lines
drmresources.cpp +1 -1
   // First look for primary amongst internal connectors
   for (auto &conn : connectors_) {
-    if (conn->internal() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->internal() && !found_primary) {

One more thing. How do you know this is the right thing to do? What if the internal panel is not connected initially, but becomes connected in the future? IIUC, you'll end up numbering it incorrectly.

I'm not sure how consistent it all is, but the internal panel can report as disconnected when e.g. the lid is closed, on at least some drivers. So sounds like a real scenario to me.

If the panel isn't even there, then the driver shouldn't even register the connector (or it's a driver bug). So maybe just don't filter the internal connectors?
-Daniel

Quoted 52 lines

Sean

Quoted 35 lines

drmresources.cpp int DrmResources::Init() { · line 173

Quoted 9 lines
drmresources.cpp +1 -1
       conn->set_display(0);
       found_primary = true;
     } else {
@@ -170,7 +170,7 @@ int DrmResources::Init() {
 
   // Then look for primary amongst external connectors
   for (auto &conn : connectors_) {
-    if (conn->external() && !found_primary) {
+    if (conn->state() == DRM_MODE_CONNECTED && conn->external() && !found_primary) {

These 2 lines exceed the max character limit. Did you run clang-format?

Anyways, I think it'd be nice to add a connected() helper to the connector object which would look cleaner and solve the long lines.

Sean

Quoted 18 lines
drmresources.cpp +5 -1
       conn->set_display(0);
       found_primary = true;
     }
@@ -288,6 +288,11 @@ int DrmResources::TryEncoderForDisplay(int display, DrmEncoder *enc) {
 
 int DrmResources::CreateDisplayPipe(DrmConnector *connector) {
   int display = connector->display();
+
+  // skip not connected
+  if (connector->state() == DRM_MODE_DISCONNECTED)
+    return 0;
+
   /* Try to use current setup first */
   if (connector->encoder()) {
     int ret = TryEncoderForDisplay(display, connector->encoder());
--

2.14.1

Quoted 7 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Sean Paul, Software Engineer, Google / Chromium OS

--
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel