Git Product home page Git Product logo

Comments (5)

clopez avatar clopez commented on May 27, 2024

The following patch fixes the issue

diff --git a/platform/drm/cog-platform-drm.c b/platform/drm/cog-platform-drm.c
index be8521b..25a4f22 100644
--- a/platform/drm/cog-platform-drm.c
+++ b/platform/drm/cog-platform-drm.c
@@ -359,6 +359,7 @@ find_crtc_for_encoder(const drmModeRes *resources, const drmModeEncoder *encoder
         const uint32_t crtc_mask = 1 << i;
         const uint32_t crtc_id = resources->crtcs[i];
         if (encoder->possible_crtcs & crtc_mask) {
+            //g_assert (encoder->crtc_id == crtc_id); // should this two values match? should be an if instead of an assert?
             return crtc_id;
         }
     }
@@ -517,6 +518,9 @@ init_drm(void)
             continue;
         }
 
+        if (drm_data.encoder->encoder_id != drm_data.connector.obj->encoder_id)
+            continue;
+
         const int32_t crtc_id = find_crtc_for_encoder(drm_data.base_resources, drm_data.encoder);
         if (crtc_id != -1) {
             drm_data.crtc.obj_id = crtc_id;

But I'm not sure if is the best approach because I'm not very familiar with this DRM code.

Some notes:

  • The commented assert on the patch above won't trigger in the RPi4 case, so is safe to keep the assert. Maybe it should be an if instead of an assert.

  • See the following debug output produced with this patch: http://ix.io/4Jg0

Encoder[0]: has drm_data.encoder->encoder_id=31 and drm_data.connector.obj->encoder_id=41 and drm_data.encoder->crtc_id 0!
Encoder[1]: has drm_data.encoder->encoder_id=41 and drm_data.connector.obj->encoder_id=41 and drm_data.encoder->crtc_id 107!
Encoder[2]: has drm_data.encoder->encoder_id=58 and drm_data.connector.obj->encoder_id=41 and drm_data.encoder->crtc_id 0!

I have 6 crts with the following crt_ids
	 crt_number=0 has crt_id=57
	 crt_number=1 has crt_id=74
	 crt_number=2 has crt_id=85
	 crt_number=3 has crt_id=96
	 crt_number=4 has crt_id=107
	 crt_number=5 has crt_id=118

As you see, in this case (RPi4) I have 3 encoders and only one of those has a non-zero value for the crtc_id. So maybe checking for drm_data.encoder->crtc_id != 0 is a god idea?

from cog.

clopez avatar clopez commented on May 27, 2024

As you see, in this case (RPi4) I have 3 encoders and only one of those has a non-zero value for the crtc_id. So maybe checking for drm_data.encoder->crtc_id != 0 is a god idea?

Following that, I can see this alternative patch also fixes the issue on the RPi4

diff --git a/platform/drm/cog-platform-drm.c b/platform/drm/cog-platform-drm.c
index be8521b..b32d6a4 100644
--- a/platform/drm/cog-platform-drm.c
+++ b/platform/drm/cog-platform-drm.c
@@ -359,6 +359,7 @@ find_crtc_for_encoder(const drmModeRes *resources, const drmModeEncoder *encoder
         const uint32_t crtc_mask = 1 << i;
         const uint32_t crtc_id = resources->crtcs[i];
         if (encoder->possible_crtcs & crtc_mask) {
+            //g_assert (encoder->crtc_id == crtc_id); // should this two values match? should be an if instead of an assert?
             return crtc_id;
         }
     }
@@ -517,6 +518,9 @@ init_drm(void)
             continue;
         }
 
+        if (!drm_data.encoder->crtc_id)
+            continue;
+
         const int32_t crtc_id = find_crtc_for_encoder(drm_data.base_resources, drm_data.encoder);
         if (crtc_id != -1) {
             drm_data.crtc.obj_id = crtc_id;

Basically we have to call the function find_crtc_for_encoder() only with an encoder that has valid crtc_id value (non-zero) .. Otherwise that function does not work as expected and returns something that causes issues later.

Not sure if is better this second patch or the previous one.

Comments?

from cog.

clopez avatar clopez commented on May 27, 2024

Interesting, this other patch fixes the issue as well:

diff --git a/platform/drm/cog-platform-drm.c b/platform/drm/cog-platform-drm.c
index be8521b..7516eec 100644
--- a/platform/drm/cog-platform-drm.c
+++ b/platform/drm/cog-platform-drm.c
@@ -359,7 +359,8 @@ find_crtc_for_encoder(const drmModeRes *resources, const drmModeEncoder *encoder
         const uint32_t crtc_mask = 1 << i;
         const uint32_t crtc_id = resources->crtcs[i];
         if (encoder->possible_crtcs & crtc_mask) {
-            return crtc_id;
+            if (encoder->crtc_id == crtc_id)
+                return crtc_id;
         }
     }

Basically turn the previous commented assertion into an if and do not check in the previous loop the value of the crtc_id of the encoder.

Looks like a winner to me this last one.

I would like to know if this also works on the imx6 use case

from cog.

WebReflection avatar WebReflection commented on May 27, 2024

I wonder if this is the same bug/issue I am seeing here: #611

from cog.

clopez avatar clopez commented on May 27, 2024

Just merged a fix for this in #680

from cog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.