2019-02-06 14:01:16 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2018-05-16 23:56:21 +00:00
|
|
|
|
2022-02-04 17:05:41 +00:00
|
|
|
#include <linux/iosys-map.h>
|
2020-11-03 09:30:11 +00:00
|
|
|
|
2018-07-24 16:30:22 +00:00
|
|
|
#include <drm/drm_atomic.h>
|
2018-05-16 23:56:21 +00:00
|
|
|
#include <drm/drm_atomic_helper.h>
|
2019-06-30 06:19:01 +00:00
|
|
|
#include <drm/drm_fourcc.h>
|
2021-02-22 14:17:56 +00:00
|
|
|
#include <drm/drm_gem_atomic_helper.h>
|
2018-07-24 16:29:23 +00:00
|
|
|
#include <drm/drm_gem_framebuffer_helper.h>
|
2019-06-30 06:19:01 +00:00
|
|
|
#include <drm/drm_plane_helper.h>
|
|
|
|
|
|
|
|
#include "vkms_drv.h"
|
2018-05-16 23:56:21 +00:00
|
|
|
|
2019-06-06 22:27:45 +00:00
|
|
|
static const u32 vkms_formats[] = {
|
|
|
|
DRM_FORMAT_XRGB8888,
|
|
|
|
};
|
|
|
|
|
2021-04-24 08:25:31 +00:00
|
|
|
static const u32 vkms_plane_formats[] = {
|
2019-06-06 22:27:45 +00:00
|
|
|
DRM_FORMAT_ARGB8888,
|
2021-04-24 08:25:31 +00:00
|
|
|
DRM_FORMAT_XRGB8888
|
2019-06-06 22:27:45 +00:00
|
|
|
};
|
|
|
|
|
2018-08-02 01:08:22 +00:00
|
|
|
static struct drm_plane_state *
|
|
|
|
vkms_plane_duplicate_state(struct drm_plane *plane)
|
|
|
|
{
|
|
|
|
struct vkms_plane_state *vkms_state;
|
2019-06-26 01:37:05 +00:00
|
|
|
struct vkms_composer *composer;
|
2018-08-02 01:08:22 +00:00
|
|
|
|
|
|
|
vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL);
|
|
|
|
if (!vkms_state)
|
|
|
|
return NULL;
|
|
|
|
|
2019-06-26 01:37:05 +00:00
|
|
|
composer = kzalloc(sizeof(*composer), GFP_KERNEL);
|
|
|
|
if (!composer) {
|
|
|
|
DRM_DEBUG_KMS("Couldn't allocate composer\n");
|
2018-11-28 10:10:33 +00:00
|
|
|
kfree(vkms_state);
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-08-02 01:10:26 +00:00
|
|
|
|
2019-06-26 01:37:05 +00:00
|
|
|
vkms_state->composer = composer;
|
2018-08-02 01:10:26 +00:00
|
|
|
|
2021-07-05 07:46:31 +00:00
|
|
|
__drm_gem_duplicate_shadow_plane_state(plane, &vkms_state->base);
|
2018-08-02 01:08:22 +00:00
|
|
|
|
2021-07-05 07:46:31 +00:00
|
|
|
return &vkms_state->base.base;
|
2018-08-02 01:08:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void vkms_plane_destroy_state(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *old_state)
|
|
|
|
{
|
|
|
|
struct vkms_plane_state *vkms_state = to_vkms_plane_state(old_state);
|
2021-07-05 07:46:31 +00:00
|
|
|
struct drm_crtc *crtc = vkms_state->base.base.crtc;
|
2018-08-02 01:10:26 +00:00
|
|
|
|
|
|
|
if (crtc) {
|
|
|
|
/* dropping the reference we acquired in
|
|
|
|
* vkms_primary_plane_update()
|
|
|
|
*/
|
2019-06-26 01:37:05 +00:00
|
|
|
if (drm_framebuffer_read_refcount(&vkms_state->composer->fb))
|
|
|
|
drm_framebuffer_put(&vkms_state->composer->fb);
|
2018-08-02 01:10:26 +00:00
|
|
|
}
|
|
|
|
|
2019-06-26 01:37:05 +00:00
|
|
|
kfree(vkms_state->composer);
|
|
|
|
vkms_state->composer = NULL;
|
2018-08-02 01:08:22 +00:00
|
|
|
|
2021-07-05 07:46:31 +00:00
|
|
|
__drm_gem_destroy_shadow_plane_state(&vkms_state->base);
|
2018-08-02 01:08:22 +00:00
|
|
|
kfree(vkms_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vkms_plane_reset(struct drm_plane *plane)
|
|
|
|
{
|
|
|
|
struct vkms_plane_state *vkms_state;
|
|
|
|
|
2021-07-05 07:46:31 +00:00
|
|
|
if (plane->state) {
|
2018-08-02 01:08:22 +00:00
|
|
|
vkms_plane_destroy_state(plane, plane->state);
|
2021-07-05 07:46:31 +00:00
|
|
|
plane->state = NULL; /* must be set to NULL here */
|
|
|
|
}
|
2018-08-02 01:08:22 +00:00
|
|
|
|
|
|
|
vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL);
|
|
|
|
if (!vkms_state) {
|
|
|
|
DRM_ERROR("Cannot allocate vkms_plane_state\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-05 07:46:31 +00:00
|
|
|
__drm_gem_reset_shadow_plane(plane, &vkms_state->base);
|
2018-08-02 01:08:22 +00:00
|
|
|
}
|
|
|
|
|
2018-05-16 23:56:21 +00:00
|
|
|
static const struct drm_plane_funcs vkms_plane_funcs = {
|
|
|
|
.update_plane = drm_atomic_helper_update_plane,
|
|
|
|
.disable_plane = drm_atomic_helper_disable_plane,
|
2018-08-02 01:08:22 +00:00
|
|
|
.reset = vkms_plane_reset,
|
|
|
|
.atomic_duplicate_state = vkms_plane_duplicate_state,
|
|
|
|
.atomic_destroy_state = vkms_plane_destroy_state,
|
2018-05-16 23:56:21 +00:00
|
|
|
};
|
|
|
|
|
2018-09-06 05:17:16 +00:00
|
|
|
static void vkms_plane_atomic_update(struct drm_plane *plane,
|
drm/atomic: Pass the full state to planes atomic disable and update
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's convert the remaining helpers to provide a consistent interface,
this time with the planes atomic_update and atomic_disable.
The conversion was done using the coccinelle script below, built tested on
all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
void (*atomic_update)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
void (*atomic_disable)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_update = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
)
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier crtc_state;
identifier plane, plane_state, state;
expression e;
@@
f(struct drm_crtc_state *crtc_state)
{
...
struct drm_atomic_state *state = e;
<+...
(
- FUNCS->atomic_disable(plane, plane_state)
+ FUNCS->atomic_disable(plane, state)
|
- FUNCS->atomic_update(plane, plane_state)
+ FUNCS->atomic_update(plane, state)
)
...+>
}
@@
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *state)
+ struct drm_plane_state *old_plane_state)
{
<...
- state
+ old_plane_state
...>
}
@ ignores_old_state @
identifier plane_atomic_func.func;
identifier plane, old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
... when != old_state
}
@ adds_old_state depends on plane_atomic_func && !ignores_old_state @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *plane_state)
{
+ struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_old_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
...
struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
<+...
- plane_state->state
+ state
...+>
}
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-9-maxime@cerno.tech
2021-02-19 12:00:29 +00:00
|
|
|
struct drm_atomic_state *state)
|
2018-07-12 13:41:02 +00:00
|
|
|
{
|
drm: Use state helper instead of the plane state pointer
Many drivers reference the plane->state pointer in order to get the
current plane state in their atomic_update or atomic_disable hooks,
which would be the new plane state in the global atomic state since
_swap_state happened when those hooks are run.
Use the drm_atomic_get_new_plane_state helper to get that state to make it
more obvious.
This was made using the coccinelle script below:
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_update = func,
...,
};
)
@ adds_new_state @
identifier plane_atomic_func.func;
identifier plane, state;
identifier new_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state)
{
...
- struct drm_plane_state *new_state = plane->state;
+ struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane);
...
}
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 12:00:30 +00:00
|
|
|
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
2018-08-02 01:10:26 +00:00
|
|
|
struct vkms_plane_state *vkms_plane_state;
|
2021-07-05 07:46:33 +00:00
|
|
|
struct drm_shadow_plane_state *shadow_plane_state;
|
drm: Store new plane state in a variable for atomic_update and disable
In order to store the new plane state in a subsequent helper, let's move
the plane->state dereferences into a variable.
This was done using the following coccinelle script, plus some hand
changes for vmwgfx:
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_update = func,
...,
};
)
@ has_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
+ struct drm_plane_state *new_state = plane->state;
<+...
- plane->state
+ new_state
...+>
}
@ has_new_state_state @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *state)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_state @
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *state)
{
+ struct drm_plane_state *new_plane_state = plane->state;
<+...
- plane->state
+ new_plane_state
...+>
}
@ has_new_state_old_s @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol old_s;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_s)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_old_s @
identifier plane_atomic_func.func;
identifier plane;
symbol old_s;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_s)
{
+ struct drm_plane_state *new_s = plane->state;
<+...
- plane->state
+ new_s
...+>
}
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 12:00:27 +00:00
|
|
|
struct drm_framebuffer *fb = new_state->fb;
|
2019-06-26 01:37:05 +00:00
|
|
|
struct vkms_composer *composer;
|
2018-08-02 01:10:26 +00:00
|
|
|
|
drm: Store new plane state in a variable for atomic_update and disable
In order to store the new plane state in a subsequent helper, let's move
the plane->state dereferences into a variable.
This was done using the following coccinelle script, plus some hand
changes for vmwgfx:
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_update = func,
...,
};
)
@ has_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
+ struct drm_plane_state *new_state = plane->state;
<+...
- plane->state
+ new_state
...+>
}
@ has_new_state_state @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *state)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_state @
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *state)
{
+ struct drm_plane_state *new_plane_state = plane->state;
<+...
- plane->state
+ new_plane_state
...+>
}
@ has_new_state_old_s @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol old_s;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_s)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_old_s @
identifier plane_atomic_func.func;
identifier plane;
symbol old_s;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_s)
{
+ struct drm_plane_state *new_s = plane->state;
<+...
- plane->state
+ new_s
...+>
}
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 12:00:27 +00:00
|
|
|
if (!new_state->crtc || !fb)
|
2018-08-02 01:10:26 +00:00
|
|
|
return;
|
|
|
|
|
drm: Store new plane state in a variable for atomic_update and disable
In order to store the new plane state in a subsequent helper, let's move
the plane->state dereferences into a variable.
This was done using the following coccinelle script, plus some hand
changes for vmwgfx:
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_update = func,
...,
};
)
@ has_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
+ struct drm_plane_state *new_state = plane->state;
<+...
- plane->state
+ new_state
...+>
}
@ has_new_state_state @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *state)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_state @
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *state)
{
+ struct drm_plane_state *new_plane_state = plane->state;
<+...
- plane->state
+ new_plane_state
...+>
}
@ has_new_state_old_s @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol old_s;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_s)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_old_s @
identifier plane_atomic_func.func;
identifier plane;
symbol old_s;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_s)
{
+ struct drm_plane_state *new_s = plane->state;
<+...
- plane->state
+ new_s
...+>
}
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 12:00:27 +00:00
|
|
|
vkms_plane_state = to_vkms_plane_state(new_state);
|
2021-07-05 07:46:33 +00:00
|
|
|
shadow_plane_state = &vkms_plane_state->base;
|
2018-09-06 05:18:26 +00:00
|
|
|
|
2019-06-26 01:37:05 +00:00
|
|
|
composer = vkms_plane_state->composer;
|
drm: Store new plane state in a variable for atomic_update and disable
In order to store the new plane state in a subsequent helper, let's move
the plane->state dereferences into a variable.
This was done using the following coccinelle script, plus some hand
changes for vmwgfx:
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_update = func,
...,
};
)
@ has_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
+ struct drm_plane_state *new_state = plane->state;
<+...
- plane->state
+ new_state
...+>
}
@ has_new_state_state @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *state)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_state @
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *state)
{
+ struct drm_plane_state *new_plane_state = plane->state;
<+...
- plane->state
+ new_plane_state
...+>
}
@ has_new_state_old_s @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol old_s;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_s)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_old_s @
identifier plane_atomic_func.func;
identifier plane;
symbol old_s;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_s)
{
+ struct drm_plane_state *new_s = plane->state;
<+...
- plane->state
+ new_s
...+>
}
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 12:00:27 +00:00
|
|
|
memcpy(&composer->src, &new_state->src, sizeof(struct drm_rect));
|
|
|
|
memcpy(&composer->dst, &new_state->dst, sizeof(struct drm_rect));
|
2019-06-26 01:37:05 +00:00
|
|
|
memcpy(&composer->fb, fb, sizeof(struct drm_framebuffer));
|
2021-08-03 12:59:28 +00:00
|
|
|
memcpy(&composer->map, &shadow_plane_state->data, sizeof(composer->map));
|
2019-06-26 01:37:05 +00:00
|
|
|
drm_framebuffer_get(&composer->fb);
|
|
|
|
composer->offset = fb->offsets[0];
|
|
|
|
composer->pitch = fb->pitches[0];
|
|
|
|
composer->cpp = fb->format->cpp[0];
|
2018-07-12 13:41:02 +00:00
|
|
|
}
|
|
|
|
|
2018-07-24 16:30:22 +00:00
|
|
|
static int vkms_plane_atomic_check(struct drm_plane *plane,
|
drm/atomic: Pass the full state to planes atomic_check
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_check.
The conversion was done using the coccinelle script below plus some
manual changes for vmwgfx, built tested on all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
int (*atomic_check)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_check(plane, plane_state)
+ FUNCS->atomic_check(plane, state)
...+>
}
@ ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
... when != new_plane_state
}
@ adds_new_state depends on plane_atomic_func && !ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
+ struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *new_plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-4-maxime@cerno.tech
2021-02-19 12:00:24 +00:00
|
|
|
struct drm_atomic_state *state)
|
2018-07-24 16:30:22 +00:00
|
|
|
{
|
drm/atomic: Pass the full state to planes atomic_check
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_check.
The conversion was done using the coccinelle script below plus some
manual changes for vmwgfx, built tested on all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
int (*atomic_check)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_check(plane, plane_state)
+ FUNCS->atomic_check(plane, state)
...+>
}
@ ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
... when != new_plane_state
}
@ adds_new_state depends on plane_atomic_func && !ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
+ struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *new_plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-4-maxime@cerno.tech
2021-02-19 12:00:24 +00:00
|
|
|
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
2018-07-24 16:30:22 +00:00
|
|
|
struct drm_crtc_state *crtc_state;
|
2018-09-06 05:17:16 +00:00
|
|
|
bool can_position = false;
|
2018-07-24 16:30:22 +00:00
|
|
|
int ret;
|
|
|
|
|
2021-02-19 12:00:22 +00:00
|
|
|
if (!new_plane_state->fb || WARN_ON(!new_plane_state->crtc))
|
2018-07-24 16:30:22 +00:00
|
|
|
return 0;
|
|
|
|
|
drm: Use the state pointer directly in planes atomic_check
Now that atomic_check takes the global atomic state as a parameter, we
don't need to go through the pointer in the plane state.
This was done using the following coccinelle script:
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
static struct drm_plane_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};
@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
...
- struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
<... when != plane_state
- plane_state->state
+ state
...>
}
@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
...
struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
<...
- plane_state->state
+ state
...>
}
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-5-maxime@cerno.tech
2021-02-19 12:00:25 +00:00
|
|
|
crtc_state = drm_atomic_get_crtc_state(state,
|
2021-02-19 12:00:22 +00:00
|
|
|
new_plane_state->crtc);
|
2018-07-24 16:30:22 +00:00
|
|
|
if (IS_ERR(crtc_state))
|
|
|
|
return PTR_ERR(crtc_state);
|
|
|
|
|
2021-04-24 08:26:10 +00:00
|
|
|
if (plane->type != DRM_PLANE_TYPE_PRIMARY)
|
2018-09-06 05:17:16 +00:00
|
|
|
can_position = true;
|
|
|
|
|
2021-02-19 12:00:22 +00:00
|
|
|
ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state,
|
2018-07-24 16:30:22 +00:00
|
|
|
DRM_PLANE_HELPER_NO_SCALING,
|
|
|
|
DRM_PLANE_HELPER_NO_SCALING,
|
2018-09-06 05:17:16 +00:00
|
|
|
can_position, true);
|
2018-07-24 16:30:22 +00:00
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* for now primary plane must be visible and full screen */
|
2021-02-19 12:00:22 +00:00
|
|
|
if (!new_plane_state->visible && !can_position)
|
2018-07-24 16:30:22 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-12 13:41:02 +00:00
|
|
|
static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = {
|
2018-09-06 05:17:16 +00:00
|
|
|
.atomic_update = vkms_plane_atomic_update,
|
2018-07-24 16:30:22 +00:00
|
|
|
.atomic_check = vkms_plane_atomic_check,
|
2021-07-05 07:46:32 +00:00
|
|
|
DRM_GEM_SHADOW_PLANE_HELPER_FUNCS,
|
2018-07-12 13:41:02 +00:00
|
|
|
};
|
|
|
|
|
2021-04-24 08:23:27 +00:00
|
|
|
struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
|
|
|
|
enum drm_plane_type type, int index)
|
2018-05-16 23:56:21 +00:00
|
|
|
{
|
|
|
|
struct drm_device *dev = &vkmsdev->drm;
|
2018-09-06 05:17:16 +00:00
|
|
|
const struct drm_plane_helper_funcs *funcs;
|
2021-04-24 08:23:27 +00:00
|
|
|
struct vkms_plane *plane;
|
2018-05-16 23:56:21 +00:00
|
|
|
const u32 *formats;
|
2021-04-24 08:23:27 +00:00
|
|
|
int nformats;
|
2018-05-16 23:56:21 +00:00
|
|
|
|
2021-04-24 08:26:10 +00:00
|
|
|
switch (type) {
|
|
|
|
case DRM_PLANE_TYPE_PRIMARY:
|
|
|
|
formats = vkms_formats;
|
|
|
|
nformats = ARRAY_SIZE(vkms_formats);
|
|
|
|
funcs = &vkms_primary_helper_funcs;
|
|
|
|
break;
|
|
|
|
case DRM_PLANE_TYPE_CURSOR:
|
|
|
|
case DRM_PLANE_TYPE_OVERLAY:
|
2021-04-24 08:25:31 +00:00
|
|
|
formats = vkms_plane_formats;
|
|
|
|
nformats = ARRAY_SIZE(vkms_plane_formats);
|
2018-09-06 05:17:16 +00:00
|
|
|
funcs = &vkms_primary_helper_funcs;
|
2021-04-24 08:26:10 +00:00
|
|
|
break;
|
|
|
|
default:
|
2018-09-06 05:17:16 +00:00
|
|
|
formats = vkms_formats;
|
|
|
|
nformats = ARRAY_SIZE(vkms_formats);
|
|
|
|
funcs = &vkms_primary_helper_funcs;
|
2021-04-24 08:26:10 +00:00
|
|
|
break;
|
2018-09-06 05:17:16 +00:00
|
|
|
}
|
2018-05-16 23:56:21 +00:00
|
|
|
|
2021-04-24 08:23:27 +00:00
|
|
|
plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 1 << index,
|
|
|
|
&vkms_plane_funcs,
|
|
|
|
formats, nformats,
|
|
|
|
NULL, type, NULL);
|
|
|
|
if (IS_ERR(plane))
|
|
|
|
return plane;
|
2018-05-16 23:56:21 +00:00
|
|
|
|
2021-04-24 08:23:27 +00:00
|
|
|
drm_plane_helper_add(&plane->base, funcs);
|
2018-07-12 13:41:02 +00:00
|
|
|
|
2018-05-16 23:56:21 +00:00
|
|
|
return plane;
|
|
|
|
}
|