2019-06-03 07:44:50 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-01-16 12:51:16 -06:00
|
|
|
/*
|
2020-07-13 14:28:59 +02:00
|
|
|
* Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com/
|
2012-01-16 12:51:16 -06:00
|
|
|
* Author: Rob Clark <rob.clark@linaro.org>
|
|
|
|
*/
|
|
|
|
|
2015-06-16 14:54:51 +03:00
|
|
|
#include <drm/drm_atomic.h>
|
2015-03-05 21:38:16 +02:00
|
|
|
#include <drm/drm_atomic_helper.h>
|
2015-03-05 13:39:56 +02:00
|
|
|
#include <drm/drm_plane_helper.h>
|
2015-03-05 21:38:16 +02:00
|
|
|
|
2012-08-15 15:18:01 -05:00
|
|
|
#include "omap_dmm_tiler.h"
|
2015-03-05 21:31:37 +02:00
|
|
|
#include "omap_drv.h"
|
2012-01-16 12:51:16 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* plane funcs
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define to_omap_plane(x) container_of(x, struct omap_plane, base)
|
|
|
|
|
|
|
|
struct omap_plane {
|
|
|
|
struct drm_plane base;
|
2017-03-24 16:47:54 +02:00
|
|
|
enum omap_plane_id id;
|
2012-12-04 13:59:12 -06:00
|
|
|
const char *name;
|
2012-03-05 10:48:31 -06:00
|
|
|
};
|
2012-01-16 12:51:16 -06:00
|
|
|
|
2015-05-29 11:05:37 +03:00
|
|
|
static int omap_plane_prepare_fb(struct drm_plane *plane,
|
2016-08-18 19:00:16 +01:00
|
|
|
struct drm_plane_state *new_state)
|
2015-05-29 11:05:37 +03:00
|
|
|
{
|
2015-09-02 10:42:40 +02:00
|
|
|
if (!new_state->fb)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return omap_framebuffer_pin(new_state->fb);
|
2015-05-29 11:05:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void omap_plane_cleanup_fb(struct drm_plane *plane,
|
2016-08-18 19:00:16 +01:00
|
|
|
struct drm_plane_state *old_state)
|
2015-05-29 11:05:37 +03:00
|
|
|
{
|
2015-09-02 10:42:40 +02:00
|
|
|
if (old_state->fb)
|
|
|
|
omap_framebuffer_unpin(old_state->fb);
|
2015-05-29 11:05:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void omap_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 13:00:29 +01:00
|
|
|
struct drm_atomic_state *state)
|
2015-03-06 18:35:16 +02:00
|
|
|
{
|
2015-11-05 18:39:52 +02:00
|
|
|
struct omap_drm_private *priv = plane->dev->dev_private;
|
2015-03-06 19:18:56 +02:00
|
|
|
struct omap_plane *omap_plane = to_omap_plane(plane);
|
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 13:00:30 +01:00
|
|
|
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
2015-03-06 19:00:18 +02:00
|
|
|
struct omap_overlay_info info;
|
2012-01-16 12:51:17 -06:00
|
|
|
int ret;
|
2012-01-16 12:51:16 -06:00
|
|
|
|
drm: Rename plane->state variables in atomic update and disable
Some drivers are storing the plane->state pointer in atomic_update and
atomic_disable in a variable simply called state, while the state passed
as an argument is called old_state.
In order to ease subsequent reworks and to avoid confusing or
inconsistent names, let's rename those variables to new_state.
This was done using the following coccinelle script, plus some manual
changes for mtk and tegra.
@ 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,
...,
};
)
@ moves_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *new_state = plane->state;
...
}
@ depends on moves_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
identifier old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
<...
- state
+ new_state
...>
}
@ moves_new_state_oldstate @
identifier plane_atomic_func.func;
identifier plane;
symbol oldstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *oldstate)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *newstate = plane->state;
...
}
@ depends on moves_new_state_oldstate @
identifier plane_atomic_func.func;
identifier plane;
identifier old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
<...
- state
+ newstate
...>
}
@ moves_new_state_old_pstate @
identifier plane_atomic_func.func;
identifier plane;
symbol old_pstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *new_pstate = plane->state;
...
}
@ depends on moves_new_state_old_pstate @
identifier plane_atomic_func.func;
identifier plane;
identifier old_pstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
{
<...
- state
+ new_pstate
...>
}
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://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-8-maxime@cerno.tech
2021-02-19 13:00:28 +01:00
|
|
|
DBG("%s, crtc=%p fb=%p", omap_plane->name, new_state->crtc,
|
|
|
|
new_state->fb);
|
2012-12-04 13:59:12 -06:00
|
|
|
|
2015-03-06 19:00:18 +02:00
|
|
|
memset(&info, 0, sizeof(info));
|
2017-05-03 14:14:27 +03:00
|
|
|
info.rotation_type = OMAP_DSS_ROT_NONE;
|
2017-05-16 11:05:09 +03:00
|
|
|
info.rotation = DRM_MODE_ROTATE_0;
|
drm: Rename plane->state variables in atomic update and disable
Some drivers are storing the plane->state pointer in atomic_update and
atomic_disable in a variable simply called state, while the state passed
as an argument is called old_state.
In order to ease subsequent reworks and to avoid confusing or
inconsistent names, let's rename those variables to new_state.
This was done using the following coccinelle script, plus some manual
changes for mtk and tegra.
@ 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,
...,
};
)
@ moves_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *new_state = plane->state;
...
}
@ depends on moves_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
identifier old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
<...
- state
+ new_state
...>
}
@ moves_new_state_oldstate @
identifier plane_atomic_func.func;
identifier plane;
symbol oldstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *oldstate)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *newstate = plane->state;
...
}
@ depends on moves_new_state_oldstate @
identifier plane_atomic_func.func;
identifier plane;
identifier old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
<...
- state
+ newstate
...>
}
@ moves_new_state_old_pstate @
identifier plane_atomic_func.func;
identifier plane;
symbol old_pstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *new_pstate = plane->state;
...
}
@ depends on moves_new_state_old_pstate @
identifier plane_atomic_func.func;
identifier plane;
identifier old_pstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
{
<...
- state
+ new_pstate
...>
}
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://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-8-maxime@cerno.tech
2021-02-19 13:00:28 +01:00
|
|
|
info.global_alpha = new_state->alpha >> 8;
|
|
|
|
info.zorder = new_state->normalized_zpos;
|
|
|
|
if (new_state->pixel_blend_mode == DRM_MODE_BLEND_PREMULTI)
|
2019-07-11 15:52:19 +02:00
|
|
|
info.pre_mult_alpha = 1;
|
|
|
|
else
|
|
|
|
info.pre_mult_alpha = 0;
|
drm: Rename plane->state variables in atomic update and disable
Some drivers are storing the plane->state pointer in atomic_update and
atomic_disable in a variable simply called state, while the state passed
as an argument is called old_state.
In order to ease subsequent reworks and to avoid confusing or
inconsistent names, let's rename those variables to new_state.
This was done using the following coccinelle script, plus some manual
changes for mtk and tegra.
@ 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,
...,
};
)
@ moves_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *new_state = plane->state;
...
}
@ depends on moves_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
identifier old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
<...
- state
+ new_state
...>
}
@ moves_new_state_oldstate @
identifier plane_atomic_func.func;
identifier plane;
symbol oldstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *oldstate)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *newstate = plane->state;
...
}
@ depends on moves_new_state_oldstate @
identifier plane_atomic_func.func;
identifier plane;
identifier old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
<...
- state
+ newstate
...>
}
@ moves_new_state_old_pstate @
identifier plane_atomic_func.func;
identifier plane;
symbol old_pstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *new_pstate = plane->state;
...
}
@ depends on moves_new_state_old_pstate @
identifier plane_atomic_func.func;
identifier plane;
identifier old_pstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
{
<...
- state
+ new_pstate
...>
}
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://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-8-maxime@cerno.tech
2021-02-19 13:00:28 +01:00
|
|
|
info.color_encoding = new_state->color_encoding;
|
|
|
|
info.color_range = new_state->color_range;
|
2015-03-06 19:00:18 +02:00
|
|
|
|
2012-12-04 13:59:12 -06:00
|
|
|
/* update scanout: */
|
drm: Rename plane->state variables in atomic update and disable
Some drivers are storing the plane->state pointer in atomic_update and
atomic_disable in a variable simply called state, while the state passed
as an argument is called old_state.
In order to ease subsequent reworks and to avoid confusing or
inconsistent names, let's rename those variables to new_state.
This was done using the following coccinelle script, plus some manual
changes for mtk and tegra.
@ 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,
...,
};
)
@ moves_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *new_state = plane->state;
...
}
@ depends on moves_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
identifier old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
<...
- state
+ new_state
...>
}
@ moves_new_state_oldstate @
identifier plane_atomic_func.func;
identifier plane;
symbol oldstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *oldstate)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *newstate = plane->state;
...
}
@ depends on moves_new_state_oldstate @
identifier plane_atomic_func.func;
identifier plane;
identifier old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
<...
- state
+ newstate
...>
}
@ moves_new_state_old_pstate @
identifier plane_atomic_func.func;
identifier plane;
symbol old_pstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *new_pstate = plane->state;
...
}
@ depends on moves_new_state_old_pstate @
identifier plane_atomic_func.func;
identifier plane;
identifier old_pstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
{
<...
- state
+ new_pstate
...>
}
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://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-8-maxime@cerno.tech
2021-02-19 13:00:28 +01:00
|
|
|
omap_framebuffer_update_scanout(new_state->fb, new_state, &info);
|
2012-01-16 12:51:16 -06:00
|
|
|
|
2015-03-06 19:00:18 +02:00
|
|
|
DBG("%dx%d -> %dx%d (%d)", info.width, info.height,
|
|
|
|
info.out_width, info.out_height,
|
|
|
|
info.screen_width);
|
|
|
|
DBG("%d,%d %pad %pad", info.pos_x, info.pos_y,
|
|
|
|
&info.paddr, &info.p_uv_addr);
|
2012-12-04 13:59:12 -06:00
|
|
|
|
|
|
|
/* and finally, update omapdss: */
|
2020-12-15 12:46:26 +02:00
|
|
|
ret = dispc_ovl_setup(priv->dispc, omap_plane->id, &info,
|
drm: Rename plane->state variables in atomic update and disable
Some drivers are storing the plane->state pointer in atomic_update and
atomic_disable in a variable simply called state, while the state passed
as an argument is called old_state.
In order to ease subsequent reworks and to avoid confusing or
inconsistent names, let's rename those variables to new_state.
This was done using the following coccinelle script, plus some manual
changes for mtk and tegra.
@ 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,
...,
};
)
@ moves_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *new_state = plane->state;
...
}
@ depends on moves_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
identifier old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
<...
- state
+ new_state
...>
}
@ moves_new_state_oldstate @
identifier plane_atomic_func.func;
identifier plane;
symbol oldstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *oldstate)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *newstate = plane->state;
...
}
@ depends on moves_new_state_oldstate @
identifier plane_atomic_func.func;
identifier plane;
identifier old_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
<...
- state
+ newstate
...>
}
@ moves_new_state_old_pstate @
identifier plane_atomic_func.func;
identifier plane;
symbol old_pstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
{
...
- struct drm_plane_state *state = plane->state;
+ struct drm_plane_state *new_pstate = plane->state;
...
}
@ depends on moves_new_state_old_pstate @
identifier plane_atomic_func.func;
identifier plane;
identifier old_pstate;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
{
<...
- state
+ new_pstate
...>
}
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://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-8-maxime@cerno.tech
2021-02-19 13:00:28 +01:00
|
|
|
omap_crtc_timings(new_state->crtc), false,
|
|
|
|
omap_crtc_channel(new_state->crtc));
|
2016-06-10 12:44:31 +03:00
|
|
|
if (ret) {
|
|
|
|
dev_err(plane->dev->dev, "Failed to setup plane %s\n",
|
|
|
|
omap_plane->name);
|
2020-12-15 12:46:26 +02:00
|
|
|
dispc_ovl_enable(priv->dispc, omap_plane->id, false);
|
2015-05-29 11:03:15 +03:00
|
|
|
return;
|
2015-05-29 11:06:07 +03:00
|
|
|
}
|
2012-12-04 13:59:12 -06:00
|
|
|
|
2020-12-15 12:46:26 +02:00
|
|
|
dispc_ovl_enable(priv->dispc, omap_plane->id, true);
|
2015-03-05 13:39:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void omap_plane_atomic_disable(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 13:00:29 +01:00
|
|
|
struct drm_atomic_state *state)
|
2012-01-16 12:51:16 -06: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 13:00:30 +01:00
|
|
|
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
2015-11-05 18:39:52 +02:00
|
|
|
struct omap_drm_private *priv = plane->dev->dev_private;
|
2012-08-15 15:18:01 -05:00
|
|
|
struct omap_plane *omap_plane = to_omap_plane(plane);
|
2015-01-12 22:38:16 +02: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 13:00:27 +01:00
|
|
|
new_state->rotation = DRM_MODE_ROTATE_0;
|
|
|
|
new_state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : omap_plane->id;
|
2015-01-12 23:56:57 +02:00
|
|
|
|
2020-12-15 12:46:26 +02:00
|
|
|
dispc_ovl_enable(priv->dispc, omap_plane->id, false);
|
2012-01-16 12:51:16 -06:00
|
|
|
}
|
|
|
|
|
2015-06-16 14:54:51 +03:00
|
|
|
static int omap_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 13:00:24 +01:00
|
|
|
struct drm_atomic_state *state)
|
2015-06-16 14:54:51 +03: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 13:00:24 +01:00
|
|
|
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
2015-06-16 14:54:51 +03:00
|
|
|
struct drm_crtc_state *crtc_state;
|
|
|
|
|
2021-02-19 13:00:22 +01:00
|
|
|
if (!new_plane_state->fb)
|
2015-06-16 14:54:51 +03:00
|
|
|
return 0;
|
|
|
|
|
2021-02-19 13:00:22 +01:00
|
|
|
/* crtc should only be NULL when disabling (i.e., !new_plane_state->fb) */
|
|
|
|
if (WARN_ON(!new_plane_state->crtc))
|
2016-06-10 12:50:53 +03: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 13:00:25 +01:00
|
|
|
crtc_state = drm_atomic_get_existing_crtc_state(state,
|
2021-02-19 13:00:22 +01:00
|
|
|
new_plane_state->crtc);
|
2016-06-10 12:50:53 +03:00
|
|
|
/* we should have a crtc state if the plane is attached to a crtc */
|
|
|
|
if (WARN_ON(!crtc_state))
|
|
|
|
return 0;
|
2015-06-16 14:54:51 +03:00
|
|
|
|
2016-06-10 12:50:39 +03:00
|
|
|
if (!crtc_state->enable)
|
|
|
|
return 0;
|
|
|
|
|
2021-02-19 13:00:22 +01:00
|
|
|
if (new_plane_state->crtc_x < 0 || new_plane_state->crtc_y < 0)
|
2015-06-16 14:54:51 +03:00
|
|
|
return -EINVAL;
|
|
|
|
|
2021-02-19 13:00:22 +01:00
|
|
|
if (new_plane_state->crtc_x + new_plane_state->crtc_w > crtc_state->adjusted_mode.hdisplay)
|
2015-06-16 14:54:51 +03:00
|
|
|
return -EINVAL;
|
|
|
|
|
2021-02-19 13:00:22 +01:00
|
|
|
if (new_plane_state->crtc_y + new_plane_state->crtc_h > crtc_state->adjusted_mode.vdisplay)
|
2015-06-16 14:54:51 +03:00
|
|
|
return -EINVAL;
|
|
|
|
|
2021-02-19 13:00:22 +01:00
|
|
|
if (new_plane_state->rotation != DRM_MODE_ROTATE_0 &&
|
|
|
|
!omap_framebuffer_supports_rotation(new_plane_state->fb))
|
2016-06-10 12:50:53 +03:00
|
|
|
return -EINVAL;
|
2015-08-27 13:09:22 +03:00
|
|
|
|
2015-06-16 14:54:51 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-05 13:39:56 +02:00
|
|
|
static const struct drm_plane_helper_funcs omap_plane_helper_funcs = {
|
|
|
|
.prepare_fb = omap_plane_prepare_fb,
|
|
|
|
.cleanup_fb = omap_plane_cleanup_fb,
|
2015-06-16 14:54:51 +03:00
|
|
|
.atomic_check = omap_plane_atomic_check,
|
2015-03-05 13:39:56 +02:00
|
|
|
.atomic_update = omap_plane_atomic_update,
|
|
|
|
.atomic_disable = omap_plane_atomic_disable,
|
|
|
|
};
|
|
|
|
|
2012-01-16 12:51:16 -06:00
|
|
|
static void omap_plane_destroy(struct drm_plane *plane)
|
|
|
|
{
|
|
|
|
struct omap_plane *omap_plane = to_omap_plane(plane);
|
2012-12-04 13:59:12 -06:00
|
|
|
|
|
|
|
DBG("%s", omap_plane->name);
|
|
|
|
|
2012-01-16 12:51:16 -06:00
|
|
|
drm_plane_cleanup(plane);
|
2012-12-04 13:59:12 -06:00
|
|
|
|
2012-01-16 12:51:16 -06:00
|
|
|
kfree(omap_plane);
|
|
|
|
}
|
|
|
|
|
2012-08-15 15:18:01 -05:00
|
|
|
/* helper to install properties which are common to planes and crtcs */
|
|
|
|
void omap_plane_install_properties(struct drm_plane *plane,
|
|
|
|
struct drm_mode_object *obj)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = plane->dev;
|
|
|
|
struct omap_drm_private *priv = dev->dev_private;
|
|
|
|
|
2012-10-25 17:14:13 -05:00
|
|
|
if (priv->has_dmm) {
|
2016-09-26 19:30:52 +03:00
|
|
|
if (!plane->rotation_property)
|
|
|
|
drm_plane_create_rotation_property(plane,
|
2017-05-19 16:50:17 -04:00
|
|
|
DRM_MODE_ROTATE_0,
|
|
|
|
DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 |
|
|
|
|
DRM_MODE_ROTATE_180 | DRM_MODE_ROTATE_270 |
|
|
|
|
DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y);
|
2016-09-26 19:30:52 +03:00
|
|
|
|
|
|
|
/* Attach the rotation property also to the crtc object */
|
|
|
|
if (plane->rotation_property && obj != &plane->base)
|
|
|
|
drm_object_attach_property(obj, plane->rotation_property,
|
2017-05-19 16:50:17 -04:00
|
|
|
DRM_MODE_ROTATE_0);
|
2012-08-15 15:18:01 -05:00
|
|
|
}
|
2012-08-15 15:18:02 -05:00
|
|
|
|
2015-03-06 17:16:43 +02:00
|
|
|
drm_object_attach_property(obj, priv->zorder_prop, 0);
|
2012-08-15 15:18:01 -05:00
|
|
|
}
|
|
|
|
|
2015-12-15 11:33:23 +02:00
|
|
|
static void omap_plane_reset(struct drm_plane *plane)
|
|
|
|
{
|
|
|
|
struct omap_plane *omap_plane = to_omap_plane(plane);
|
|
|
|
|
2017-05-09 01:27:13 +03:00
|
|
|
drm_atomic_helper_plane_reset(plane);
|
|
|
|
if (!plane->state)
|
2015-12-15 11:33:23 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
2017-05-09 01:27:12 +03:00
|
|
|
* Set the zpos default depending on whether we are a primary or overlay
|
2015-12-15 11:33:23 +02:00
|
|
|
* plane.
|
|
|
|
*/
|
2017-05-09 01:27:13 +03:00
|
|
|
plane->state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY
|
|
|
|
? 0 : omap_plane->id;
|
2020-11-03 10:03:10 +02:00
|
|
|
plane->state->color_encoding = DRM_COLOR_YCBCR_BT601;
|
|
|
|
plane->state->color_range = DRM_COLOR_YCBCR_FULL_RANGE;
|
2015-12-15 11:33:23 +02:00
|
|
|
}
|
|
|
|
|
2015-03-06 18:35:16 +02:00
|
|
|
static int omap_plane_atomic_set_property(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *state,
|
|
|
|
struct drm_property *property,
|
2018-02-11 15:07:33 +02:00
|
|
|
u64 val)
|
2012-08-15 15:18:01 -05:00
|
|
|
{
|
|
|
|
struct omap_drm_private *priv = plane->dev->dev_private;
|
|
|
|
|
2015-03-06 18:35:16 +02:00
|
|
|
if (property == priv->zorder_prop)
|
2017-05-09 01:27:12 +03:00
|
|
|
state->zpos = val;
|
2015-03-06 18:35:16 +02:00
|
|
|
else
|
2015-01-17 19:09:26 +02:00
|
|
|
return -EINVAL;
|
2012-08-15 15:18:01 -05:00
|
|
|
|
2015-03-06 18:35:16 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2015-01-17 19:09:26 +02:00
|
|
|
|
2015-03-06 18:35:16 +02:00
|
|
|
static int omap_plane_atomic_get_property(struct drm_plane *plane,
|
|
|
|
const struct drm_plane_state *state,
|
|
|
|
struct drm_property *property,
|
2018-02-11 15:07:33 +02:00
|
|
|
u64 *val)
|
2015-03-06 18:35:16 +02:00
|
|
|
{
|
|
|
|
struct omap_drm_private *priv = plane->dev->dev_private;
|
|
|
|
|
|
|
|
if (property == priv->zorder_prop)
|
2017-05-09 01:27:12 +03:00
|
|
|
*val = state->zpos;
|
2015-03-06 18:35:16 +02:00
|
|
|
else
|
|
|
|
return -EINVAL;
|
2015-01-17 19:09:26 +02:00
|
|
|
|
2015-03-06 18:35:16 +02:00
|
|
|
return 0;
|
2012-08-15 15:18:01 -05:00
|
|
|
}
|
|
|
|
|
2012-01-16 12:51:16 -06:00
|
|
|
static const struct drm_plane_funcs omap_plane_funcs = {
|
2015-03-05 21:50:00 +02:00
|
|
|
.update_plane = drm_atomic_helper_update_plane,
|
|
|
|
.disable_plane = drm_atomic_helper_disable_plane,
|
2015-03-06 18:35:16 +02:00
|
|
|
.reset = omap_plane_reset,
|
2015-01-11 00:02:07 +02:00
|
|
|
.destroy = omap_plane_destroy,
|
2017-05-09 01:27:13 +03:00
|
|
|
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
|
|
|
|
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
|
2015-03-06 18:35:16 +02:00
|
|
|
.atomic_set_property = omap_plane_atomic_set_property,
|
|
|
|
.atomic_get_property = omap_plane_atomic_get_property,
|
2012-01-16 12:51:16 -06:00
|
|
|
};
|
|
|
|
|
2020-11-03 10:03:10 +02:00
|
|
|
static bool omap_plane_supports_yuv(struct drm_plane *plane)
|
|
|
|
{
|
|
|
|
struct omap_drm_private *priv = plane->dev->dev_private;
|
|
|
|
struct omap_plane *omap_plane = to_omap_plane(plane);
|
2020-12-15 12:46:26 +02:00
|
|
|
const u32 *formats = dispc_ovl_get_color_modes(priv->dispc, omap_plane->id);
|
2020-11-03 10:03:10 +02:00
|
|
|
u32 i;
|
|
|
|
|
|
|
|
for (i = 0; formats[i]; i++)
|
|
|
|
if (formats[i] == DRM_FORMAT_YUYV ||
|
|
|
|
formats[i] == DRM_FORMAT_UYVY ||
|
|
|
|
formats[i] == DRM_FORMAT_NV12)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-24 16:47:55 +02:00
|
|
|
static const char *plane_id_to_name[] = {
|
2015-01-11 00:02:07 +02:00
|
|
|
[OMAP_DSS_GFX] = "gfx",
|
|
|
|
[OMAP_DSS_VIDEO1] = "vid1",
|
|
|
|
[OMAP_DSS_VIDEO2] = "vid2",
|
|
|
|
[OMAP_DSS_VIDEO3] = "vid3",
|
2012-12-04 13:59:12 -06:00
|
|
|
};
|
|
|
|
|
2017-03-24 16:47:55 +02:00
|
|
|
static const enum omap_plane_id plane_idx_to_id[] = {
|
|
|
|
OMAP_DSS_GFX,
|
|
|
|
OMAP_DSS_VIDEO1,
|
|
|
|
OMAP_DSS_VIDEO2,
|
|
|
|
OMAP_DSS_VIDEO3,
|
|
|
|
};
|
|
|
|
|
2012-01-16 12:51:16 -06:00
|
|
|
/* initialize plane */
|
|
|
|
struct drm_plane *omap_plane_init(struct drm_device *dev,
|
2017-03-24 16:47:55 +02:00
|
|
|
int idx, enum drm_plane_type type,
|
2016-12-02 16:07:11 +02:00
|
|
|
u32 possible_crtcs)
|
2012-01-16 12:51:16 -06:00
|
|
|
{
|
2015-11-05 18:39:52 +02:00
|
|
|
struct omap_drm_private *priv = dev->dev_private;
|
2020-12-15 12:46:26 +02:00
|
|
|
unsigned int num_planes = dispc_get_num_ovls(priv->dispc);
|
2015-01-11 00:11:18 +02:00
|
|
|
struct drm_plane *plane;
|
2012-01-16 12:51:16 -06:00
|
|
|
struct omap_plane *omap_plane;
|
2017-03-24 16:47:55 +02:00
|
|
|
enum omap_plane_id id;
|
2015-01-11 00:11:18 +02:00
|
|
|
int ret;
|
2017-05-04 11:27:49 +03:00
|
|
|
u32 nformats;
|
|
|
|
const u32 *formats;
|
2012-01-16 12:51:16 -06:00
|
|
|
|
2017-03-24 16:47:55 +02:00
|
|
|
if (WARN_ON(idx >= ARRAY_SIZE(plane_idx_to_id)))
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
id = plane_idx_to_id[idx];
|
|
|
|
|
|
|
|
DBG("%s: type=%d", plane_id_to_name[id], type);
|
2012-03-05 10:48:35 -06:00
|
|
|
|
2012-01-16 12:51:16 -06:00
|
|
|
omap_plane = kzalloc(sizeof(*omap_plane), GFP_KERNEL);
|
2013-02-11 09:41:29 -08:00
|
|
|
if (!omap_plane)
|
2015-01-11 16:30:44 +02:00
|
|
|
return ERR_PTR(-ENOMEM);
|
2012-01-16 12:51:16 -06:00
|
|
|
|
2020-12-15 12:46:26 +02:00
|
|
|
formats = dispc_ovl_get_color_modes(priv->dispc, id);
|
2017-05-04 11:27:49 +03:00
|
|
|
for (nformats = 0; formats[nformats]; ++nformats)
|
|
|
|
;
|
2012-12-04 13:59:12 -06:00
|
|
|
omap_plane->id = id;
|
2017-03-24 16:47:55 +02:00
|
|
|
omap_plane->name = plane_id_to_name[id];
|
2012-12-04 13:59:12 -06:00
|
|
|
|
2012-01-16 12:51:16 -06:00
|
|
|
plane = &omap_plane->base;
|
|
|
|
|
2016-12-02 16:07:11 +02:00
|
|
|
ret = drm_universal_plane_init(dev, plane, possible_crtcs,
|
2017-05-04 11:27:49 +03:00
|
|
|
&omap_plane_funcs, formats,
|
2017-07-23 20:46:38 -07:00
|
|
|
nformats, NULL, type, NULL);
|
2015-01-11 00:11:18 +02:00
|
|
|
if (ret < 0)
|
|
|
|
goto error;
|
2012-01-16 12:51:16 -06:00
|
|
|
|
2015-03-05 13:39:56 +02:00
|
|
|
drm_plane_helper_add(plane, &omap_plane_helper_funcs);
|
|
|
|
|
2012-08-15 15:18:01 -05:00
|
|
|
omap_plane_install_properties(plane, &plane->base);
|
2017-05-09 01:27:14 +03:00
|
|
|
drm_plane_create_zpos_property(plane, 0, 0, num_planes - 1);
|
2019-07-11 15:52:19 +02:00
|
|
|
drm_plane_create_alpha_property(plane);
|
|
|
|
drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_PREMULTI) |
|
|
|
|
BIT(DRM_MODE_BLEND_COVERAGE));
|
2012-08-15 15:18:01 -05:00
|
|
|
|
2020-11-03 10:03:10 +02:00
|
|
|
if (omap_plane_supports_yuv(plane))
|
|
|
|
drm_plane_create_color_properties(plane,
|
|
|
|
BIT(DRM_COLOR_YCBCR_BT601) |
|
|
|
|
BIT(DRM_COLOR_YCBCR_BT709),
|
|
|
|
BIT(DRM_COLOR_YCBCR_FULL_RANGE) |
|
|
|
|
BIT(DRM_COLOR_YCBCR_LIMITED_RANGE),
|
|
|
|
DRM_COLOR_YCBCR_BT601,
|
|
|
|
DRM_COLOR_YCBCR_FULL_RANGE);
|
|
|
|
|
2012-01-16 12:51:16 -06:00
|
|
|
return plane;
|
2015-01-11 00:11:18 +02:00
|
|
|
|
|
|
|
error:
|
2017-03-24 16:47:55 +02:00
|
|
|
dev_err(dev->dev, "%s(): could not create plane: %s\n",
|
|
|
|
__func__, plane_id_to_name[id]);
|
|
|
|
|
2015-01-11 00:11:18 +02:00
|
|
|
kfree(omap_plane);
|
|
|
|
return NULL;
|
2012-01-16 12:51:16 -06:00
|
|
|
}
|