Skip to contentSkip to conversation

drm: Use atomic state for FB in legacy ioctls

PATCH Applied Daniel Stone 3 participants 5 messages Dec 13, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Use atomic state for FB in legacy ioctls

If atomic state is available, use this to read the current plane in GetCrtc/GetPlane, rather than the legacy points.

---
 drivers/gpu/drm/drm_crtc.c  | 5 ++++-
 drivers/gpu/drm/drm_plane.c | 8 ++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +4 -1
index e75f62c..14c5807 100644
@@ -357,7 +357,10 @@ int drm_mode_getcrtc(struct drm_device *dev,
 
 	drm_modeset_lock_crtc(crtc, crtc->primary);
 	crtc_resp->gamma_size = crtc->gamma_size;
-	if (crtc->primary->fb)
+
+	if (crtc->primary->state && crtc->primary->state->fb)
+		crtc_resp->fb_id = crtc->primary->state->fb->base.id;
+	else if (!crtc->primary->state && crtc->primary->fb)
 		crtc_resp->fb_id = crtc->primary->fb->base.id;
 	else
 		crtc_resp->fb_id = 0;
drivers/gpu/drm/drm_plane.c +6 -2
index 62b98f3..c2dc8e6 100644
@@ -392,12 +392,16 @@ int drm_mode_getplane(struct drm_device *dev, void *data,
 		return -ENOENT;
 
 	drm_modeset_lock(&plane->mutex, NULL);
-	if (plane->crtc)
+	if (plane->state && plane->state->crtc)
+		plane_resp->crtc_id = plane->state->crtc->base.id;
+	else if (!plane->state && plane->crtc)
 		plane_resp->crtc_id = plane->crtc->base.id;
 	else
 		plane_resp->crtc_id = 0;
 
-	if (plane->fb)
+	if (plane->state && plane->state->fb)
+		plane_resp->fb_id = plane->state->fb->base.id;
+	else if (!plane->state && plane->fb)
 		plane_resp->fb_id = plane->fb->base.id;
 	else
 		plane_resp->fb_id = 0;
Signature · 6 lines
2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 15 lines · Daniel Stone

If atomic state is available, use this to read the current plane in GetCrtc/GetPlane, rather than the legacy points.

---
 drivers/gpu/drm/drm_crtc.c  | 5 ++++-
 drivers/gpu/drm/drm_plane.c | 8 ++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +0 -0
index e75f62c..14c5807 100644

drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 364

Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +4 -1
@@ -357,7 +357,10 @@ int drm_mode_getcrtc(struct drm_device *dev,
 
 	drm_modeset_lock_crtc(crtc, crtc->primary);
 	crtc_resp->gamma_size = crtc->gamma_size;
-	if (crtc->primary->fb)
+
+	if (crtc->primary->state && crtc->primary->state->fb)
+		crtc_resp->fb_id = crtc->primary->state->fb->base.id;
+	else if (!crtc->primary->state && crtc->primary->fb)
 		crtc_resp->fb_id = crtc->primary->fb->base.id;

I think what we do elsewhere is totally ignore the legacy junk if the ->state pointer exists.

Quoted 32 lines
drivers/gpu/drm/drm_crtc.c +0 -0
 	else
 		crtc_resp->fb_id = 0;
drivers/gpu/drm/drm_plane.c +6 -2
index 62b98f3..c2dc8e6 100644
@@ -392,12 +392,16 @@ int drm_mode_getplane(struct drm_device *dev, void *data,
 		return -ENOENT;
 
 	drm_modeset_lock(&plane->mutex, NULL);
-	if (plane->crtc)
+	if (plane->state && plane->state->crtc)
+		plane_resp->crtc_id = plane->state->crtc->base.id;
+	else if (!plane->state && plane->crtc)
 		plane_resp->crtc_id = plane->crtc->base.id;
 	else
 		plane_resp->crtc_id = 0;
 
-	if (plane->fb)
+	if (plane->state && plane->state->fb)
+		plane_resp->fb_id = plane->state->fb->base.id;
+	else if (!plane->state && plane->fb)
 		plane_resp->fb_id = plane->fb->base.id;
 	else
 		plane_resp->fb_id = 0;
Signature · 6 lines
2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Hi,

Quoted 5 lines · Ville Syrjälä
Quoted 4 lines · Daniel Stone
(quoted diff) +0 -0
@@ -357,7 +357,10 @@ int drm_mode_getcrtc(struct drm_device *dev,
 
Quoted 11 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 364

Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +4 -1
   drm_modeset_lock_crtc(crtc, crtc->primary);
   crtc_resp->gamma_size = crtc->gamma_size;
-    if (crtc->primary->fb)
+
+    if (crtc->primary->state && crtc->primary->state->fb)
+        crtc_resp->fb_id = crtc->primary->state->fb->base.id;
+    else if (!crtc->primary->state && crtc->primary->fb)
       crtc_resp->fb_id = crtc->primary->fb->base.id;

I think what we do elsewhere is totally ignore the legacy junk if the ->state pointer exists.

Indeed, hence the negative state check on the second branch; having nested if statements instead seemed unnecessarily unwieldy, but the effect is the same.

[Obligatory mobile formatting apology.]

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

Reviewed-by
#3 lore raw
Quoted 19 lines · Daniel Stone

Hi,

Quoted 5 lines · Ville Syrjälä
Quoted 4 lines · Daniel Stone
(quoted diff) +0 -0
@@ -357,7 +357,10 @@ int drm_mode_getcrtc(struct drm_device *dev,
 
Quoted 11 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 364

Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +4 -1
   drm_modeset_lock_crtc(crtc, crtc->primary);
   crtc_resp->gamma_size = crtc->gamma_size;
-    if (crtc->primary->fb)
+
+    if (crtc->primary->state && crtc->primary->state->fb)
+        crtc_resp->fb_id = crtc->primary->state->fb->base.id;
+    else if (!crtc->primary->state && crtc->primary->fb)
       crtc_resp->fb_id = crtc->primary->fb->base.id;

I think what we do elsewhere is totally ignore the legacy junk if the ->state pointer exists.

Quoted 1 line

Indeed, hence the negative state check on the second branch; having nested if statements instead seemed unnecessarily unwieldy, but the effect is the same.

My bad. You hid it well though ;)

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw
Quoted 20 lines · Ville Syrjälä
Quoted 19 lines · Daniel Stone

Hi,

Quoted 16 lines · Ville Syrjälä

drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 364

Quoted 12 lines · Daniel Stone
drivers/gpu/drm/drm_crtc.c +4 -1
@@ -357,7 +357,10 @@ int drm_mode_getcrtc(struct drm_device *dev,
 
   drm_modeset_lock_crtc(crtc, crtc->primary);
   crtc_resp->gamma_size = crtc->gamma_size;
-    if (crtc->primary->fb)
+
+    if (crtc->primary->state && crtc->primary->state->fb)
+        crtc_resp->fb_id = crtc->primary->state->fb->base.id;
+    else if (!crtc->primary->state && crtc->primary->fb)
       crtc_resp->fb_id = crtc->primary->fb->base.id;

I think what we do elsewhere is totally ignore the legacy junk if the ->state pointer exists.

Quoted 5 lines
Quoted 1 line

Indeed, hence the negative state check on the second branch; having nested if statements instead seemed unnecessarily unwieldy, but the effect is the same.

My bad. You hid it well though ;)

Applied to drm-misc, thanks.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel