Skip to contentSkip to conversation

drm/virtio: add plane check

PATCH Superseded Gerd Hoffmann 2 participants 7 messages Aug 22, 2019 – Aug 27, 2019

Subsystems (4)
lore
Share & tools
lore

Gerd Hoffmann

author maintainer
#0 lore raw

PATCH v2 1/1 drm/virtio: add plane check

Use drm_atomic_helper_check_plane_state()
to sanity check the plane state.

---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_plane.c +16 -1
index a492ac3f4a7e..fe5efb2de90d 100644
@@ -84,7 +84,22 @@ static const struct drm_plane_funcs virtio_gpu_plane_funcs = {
 static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
 					 struct drm_plane_state *state)
 {
-	return 0;
+	bool is_cursor = plane->type == DRM_PLANE_TYPE_CURSOR;
+	struct drm_crtc_state *crtc_state;
+	int ret;
+
+	if (!state->fb || !state->crtc)
+		return 0;
+
+	crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
+	if (IS_ERR(crtc_state))
+                return PTR_ERR(crtc_state);
+
+	ret = drm_atomic_helper_check_plane_state(state, crtc_state,
+						  DRM_PLANE_HELPER_NO_SCALING,
+						  DRM_PLANE_HELPER_NO_SCALING,
+						  is_cursor, true);
+	return ret;
 }
 
 static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
Signature · 1 line
2.18.1
reviewer
#1 lore raw
Quoted 18 lines · Gerd Hoffmann

Use drm_atomic_helper_check_plane_state()
to sanity check the plane state.

---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_plane.c +0 -1
index a492ac3f4a7e..fe5efb2de90d 100644
@@ -84,7 +84,22 @@ static const struct drm_plane_funcs virtio_gpu_plane_funcs = {
 static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
                                         struct drm_plane_state *state)
 {
-       return 0;

drivers/gpu/drm/virtio/virtgpu_plane.c static const struct drm_plane_funcs virtio_gpu_plane_funcs = { · line 96

Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +10 -0
+       bool is_cursor = plane->type == DRM_PLANE_TYPE_CURSOR;
+       struct drm_crtc_state *crtc_state;
+       int ret;
+
+       if (!state->fb || !state->crtc)
+               return 0;
+
+       crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
+       if (IS_ERR(crtc_state))
+                return PTR_ERR(crtc_state);

Is drm_atomic_get_new_crtc_state better here?

Quoted 16 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +6 -1
+
+       ret = drm_atomic_helper_check_plane_state(state, crtc_state,
+                                                 DRM_PLANE_HELPER_NO_SCALING,
+                                                 DRM_PLANE_HELPER_NO_SCALING,
+                                                 is_cursor, true);
+       return ret;
 }
 
 static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
--

2.18.1

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

author maintainer
#2 lore raw
Quoted 22 lines · Chia-I Wu
Quoted 21 lines · Gerd Hoffmann

Use drm_atomic_helper_check_plane_state()
to sanity check the plane state.

---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_plane.c +3 -1
index a492ac3f4a7e..fe5efb2de90d 100644
@@ -84,7 +84,22 @@ static const struct drm_plane_funcs virtio_gpu_plane_funcs = {
 static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
                                         struct drm_plane_state *state)
 {
-       return 0;
+       bool is_cursor = plane->type == DRM_PLANE_TYPE_CURSOR;
+       struct drm_crtc_state *crtc_state;
+       int ret;
Quoted 8 lines

drivers/gpu/drm/virtio/virtgpu_plane.c static const struct drm_plane_funcs virtio_gpu_plane_funcs = { · line 96

Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +7 -0
+
+       if (!state->fb || !state->crtc)
+               return 0;
+
+       crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
+       if (IS_ERR(crtc_state))
+                return PTR_ERR(crtc_state);

Is drm_atomic_get_new_crtc_state better here?

We don't have to worry about old/new state here. The drm_plane_state we get passed is the state we should check in this callback (and I think this always is the new state).

cheers,
Gerd

author maintainer
#3 lore raw
In reply to Chia-I Wu
Quoted 22 lines · Chia-I Wu
Quoted 21 lines · Gerd Hoffmann

Use drm_atomic_helper_check_plane_state()
to sanity check the plane state.

---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_plane.c +3 -1
index a492ac3f4a7e..fe5efb2de90d 100644
@@ -84,7 +84,22 @@ static const struct drm_plane_funcs virtio_gpu_plane_funcs = {
 static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
                                         struct drm_plane_state *state)
 {
-       return 0;
+       bool is_cursor = plane->type == DRM_PLANE_TYPE_CURSOR;
+       struct drm_crtc_state *crtc_state;
+       int ret;
Quoted 8 lines

drivers/gpu/drm/virtio/virtgpu_plane.c static const struct drm_plane_funcs virtio_gpu_plane_funcs = { · line 96

Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +7 -0
+
+       if (!state->fb || !state->crtc)
+               return 0;
+
+       crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
+       if (IS_ERR(crtc_state))
+                return PTR_ERR(crtc_state);

Is drm_atomic_get_new_crtc_state better here?

We don't have to worry about old/new state here. The drm_plane_state we get passed is the state we should check in this callback (and I think this always is the new state).

cheers,
Gerd

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

reviewer Acked-by
#4 lore raw
Quoted 33 lines · Gerd Hoffmann
Quoted 22 lines · Chia-I Wu
Quoted 21 lines · Gerd Hoffmann

Use drm_atomic_helper_check_plane_state()
to sanity check the plane state.

---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_plane.c +3 -1
index a492ac3f4a7e..fe5efb2de90d 100644
@@ -84,7 +84,22 @@ static const struct drm_plane_funcs virtio_gpu_plane_funcs = {
 static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
                                         struct drm_plane_state *state)
 {
-       return 0;
+       bool is_cursor = plane->type == DRM_PLANE_TYPE_CURSOR;
+       struct drm_crtc_state *crtc_state;
+       int ret;
Quoted 8 lines

drivers/gpu/drm/virtio/virtgpu_plane.c static const struct drm_plane_funcs virtio_gpu_plane_funcs = { · line 96

Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +7 -0
+
+       if (!state->fb || !state->crtc)
+               return 0;
+
+       crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
+       if (IS_ERR(crtc_state))
+                return PTR_ERR(crtc_state);

Is drm_atomic_get_new_crtc_state better here?

Quoted 3 lines

We don't have to worry about old/new state here. The drm_plane_state we get passed is the state we should check in this callback (and I think this always is the new state).

with the atomic code to give an r-b)

Quoted 4 lines

cheers,
Gerd

reviewer Acked-by
#5 lore raw
In reply to Gerd Hoffmann
Quoted 33 lines · Gerd Hoffmann
Quoted 22 lines · Chia-I Wu
Quoted 21 lines · Gerd Hoffmann

Use drm_atomic_helper_check_plane_state()
to sanity check the plane state.

---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_plane.c +3 -1
index a492ac3f4a7e..fe5efb2de90d 100644
@@ -84,7 +84,22 @@ static const struct drm_plane_funcs virtio_gpu_plane_funcs = {
 static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
                                         struct drm_plane_state *state)
 {
-       return 0;
+       bool is_cursor = plane->type == DRM_PLANE_TYPE_CURSOR;
+       struct drm_crtc_state *crtc_state;
+       int ret;
Quoted 8 lines

drivers/gpu/drm/virtio/virtgpu_plane.c static const struct drm_plane_funcs virtio_gpu_plane_funcs = { · line 96

Quoted 7 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +7 -0
+
+       if (!state->fb || !state->crtc)
+               return 0;
+
+       crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
+       if (IS_ERR(crtc_state))
+                return PTR_ERR(crtc_state);

Is drm_atomic_get_new_crtc_state better here?

Quoted 3 lines

We don't have to worry about old/new state here. The drm_plane_state we get passed is the state we should check in this callback (and I think this always is the new state).

with the atomic code to give an r-b)

Quoted 4 lines

cheers,
Gerd

reviewer
#6 lore raw
In reply to Gerd Hoffmann
Quoted 18 lines · Gerd Hoffmann

Use drm_atomic_helper_check_plane_state()
to sanity check the plane state.

---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_plane.c +0 -1
index a492ac3f4a7e..fe5efb2de90d 100644
@@ -84,7 +84,22 @@ static const struct drm_plane_funcs virtio_gpu_plane_funcs = {
 static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
                                         struct drm_plane_state *state)
 {
-       return 0;

drivers/gpu/drm/virtio/virtgpu_plane.c static const struct drm_plane_funcs virtio_gpu_plane_funcs = { · line 96

Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +10 -0
+       bool is_cursor = plane->type == DRM_PLANE_TYPE_CURSOR;
+       struct drm_crtc_state *crtc_state;
+       int ret;
+
+       if (!state->fb || !state->crtc)
+               return 0;
+
+       crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc);
+       if (IS_ERR(crtc_state))
+                return PTR_ERR(crtc_state);

Is drm_atomic_get_new_crtc_state better here?

Quoted 16 lines
drivers/gpu/drm/virtio/virtgpu_plane.c +6 -1
+
+       ret = drm_atomic_helper_check_plane_state(state, crtc_state,
+                                                 DRM_PLANE_HELPER_NO_SCALING,
+                                                 DRM_PLANE_HELPER_NO_SCALING,
+                                                 is_cursor, true);
+       return ret;
 }
 
 static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
--

2.18.1

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