2019-06-04 08:11:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2016-09-22 11:52:39 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Linaro Ltd.
|
|
|
|
* Copyright 2016 ZTE Corporation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <drm/drm_atomic.h>
|
|
|
|
#include <drm/drm_atomic_helper.h>
|
|
|
|
#include <drm/drm_fb_cma_helper.h>
|
2019-07-16 06:42:05 +00:00
|
|
|
#include <drm/drm_fourcc.h>
|
2016-09-22 11:52:39 +00:00
|
|
|
#include <drm/drm_gem_cma_helper.h>
|
|
|
|
#include <drm/drm_modeset_helper_vtables.h>
|
|
|
|
#include <drm/drm_plane_helper.h>
|
|
|
|
|
2017-04-06 15:01:08 +00:00
|
|
|
#include "zx_common_regs.h"
|
2016-09-22 11:52:39 +00:00
|
|
|
#include "zx_drm_drv.h"
|
|
|
|
#include "zx_plane.h"
|
|
|
|
#include "zx_plane_regs.h"
|
|
|
|
#include "zx_vou.h"
|
|
|
|
|
|
|
|
static const uint32_t gl_formats[] = {
|
|
|
|
DRM_FORMAT_ARGB8888,
|
|
|
|
DRM_FORMAT_XRGB8888,
|
|
|
|
DRM_FORMAT_RGB888,
|
|
|
|
DRM_FORMAT_RGB565,
|
|
|
|
DRM_FORMAT_ARGB1555,
|
|
|
|
DRM_FORMAT_ARGB4444,
|
|
|
|
};
|
|
|
|
|
2016-11-16 06:43:59 +00:00
|
|
|
static const uint32_t vl_formats[] = {
|
|
|
|
DRM_FORMAT_NV12, /* Semi-planar YUV420 */
|
|
|
|
DRM_FORMAT_YUV420, /* Planar YUV420 */
|
|
|
|
DRM_FORMAT_YUYV, /* Packed YUV422 */
|
|
|
|
DRM_FORMAT_YVYU,
|
|
|
|
DRM_FORMAT_UYVY,
|
|
|
|
DRM_FORMAT_VYUY,
|
|
|
|
DRM_FORMAT_YUV444, /* YUV444 8bit */
|
|
|
|
/*
|
|
|
|
* TODO: add formats below that HW supports:
|
|
|
|
* - YUV420 P010
|
|
|
|
* - YUV420 Hantro
|
|
|
|
* - YUV444 10bit
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
|
|
|
#define FRAC_16_16(mult, div) (((mult) << 16) / (div))
|
|
|
|
|
|
|
|
static int zx_vl_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)
|
2016-11-16 06:43:59 +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 *plane_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
2016-11-16 06:43:59 +00:00
|
|
|
struct drm_framebuffer *fb = plane_state->fb;
|
|
|
|
struct drm_crtc *crtc = plane_state->crtc;
|
|
|
|
struct drm_crtc_state *crtc_state;
|
|
|
|
int min_scale = FRAC_16_16(1, 8);
|
|
|
|
int max_scale = FRAC_16_16(8, 1);
|
|
|
|
|
2019-12-13 17:26:12 +00:00
|
|
|
if (!crtc || WARN_ON(!fb))
|
2016-11-16 06:43:59 +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_existing_crtc_state(state,
|
2016-11-16 06:43:59 +00:00
|
|
|
crtc);
|
|
|
|
if (WARN_ON(!crtc_state))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* nothing to check when disabling or disabled */
|
|
|
|
if (!crtc_state->enable)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* plane must be enabled */
|
|
|
|
if (!plane_state->crtc)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2017-11-01 20:16:19 +00:00
|
|
|
return drm_atomic_helper_check_plane_state(plane_state, crtc_state,
|
2018-01-23 17:08:57 +00:00
|
|
|
min_scale, max_scale,
|
2017-11-01 20:16:19 +00:00
|
|
|
true, true);
|
2016-11-16 06:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int zx_vl_get_fmt(uint32_t format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case DRM_FORMAT_NV12:
|
|
|
|
return VL_FMT_YUV420;
|
|
|
|
case DRM_FORMAT_YUV420:
|
|
|
|
return VL_YUV420_PLANAR | VL_FMT_YUV420;
|
|
|
|
case DRM_FORMAT_YUYV:
|
|
|
|
return VL_YUV422_YUYV | VL_FMT_YUV422;
|
|
|
|
case DRM_FORMAT_YVYU:
|
|
|
|
return VL_YUV422_YVYU | VL_FMT_YUV422;
|
|
|
|
case DRM_FORMAT_UYVY:
|
|
|
|
return VL_YUV422_UYVY | VL_FMT_YUV422;
|
|
|
|
case DRM_FORMAT_VYUY:
|
|
|
|
return VL_YUV422_VYUY | VL_FMT_YUV422;
|
|
|
|
case DRM_FORMAT_YUV444:
|
|
|
|
return VL_FMT_YUV444_8BIT;
|
|
|
|
default:
|
|
|
|
WARN_ONCE(1, "invalid pixel format %d\n", format);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void zx_vl_set_update(struct zx_plane *zplane)
|
|
|
|
{
|
|
|
|
void __iomem *layer = zplane->layer;
|
|
|
|
|
|
|
|
zx_writel_mask(layer + VL_CTRL0, VL_UPDATE, VL_UPDATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void zx_vl_rsz_set_update(struct zx_plane *zplane)
|
|
|
|
{
|
|
|
|
zx_writel(zplane->rsz + RSZ_VL_ENABLE_CFG, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int zx_vl_rsz_get_fmt(uint32_t format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case DRM_FORMAT_NV12:
|
|
|
|
case DRM_FORMAT_YUV420:
|
|
|
|
return RSZ_VL_FMT_YCBCR420;
|
|
|
|
case DRM_FORMAT_YUYV:
|
|
|
|
case DRM_FORMAT_YVYU:
|
|
|
|
case DRM_FORMAT_UYVY:
|
|
|
|
case DRM_FORMAT_VYUY:
|
|
|
|
return RSZ_VL_FMT_YCBCR422;
|
|
|
|
case DRM_FORMAT_YUV444:
|
|
|
|
return RSZ_VL_FMT_YCBCR444;
|
|
|
|
default:
|
|
|
|
WARN_ONCE(1, "invalid pixel format %d\n", format);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 rsz_step_value(u32 src, u32 dst)
|
|
|
|
{
|
|
|
|
u32 val = 0;
|
|
|
|
|
|
|
|
if (src == dst)
|
|
|
|
val = 0;
|
|
|
|
else if (src < dst)
|
|
|
|
val = RSZ_PARA_STEP((src << 16) / dst);
|
|
|
|
else if (src > dst)
|
|
|
|
val = RSZ_DATA_STEP(src / dst) |
|
|
|
|
RSZ_PARA_STEP(((src << 16) / dst) & 0xffff);
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zx_vl_rsz_setup(struct zx_plane *zplane, uint32_t format,
|
|
|
|
u32 src_w, u32 src_h, u32 dst_w, u32 dst_h)
|
|
|
|
{
|
|
|
|
void __iomem *rsz = zplane->rsz;
|
|
|
|
u32 src_chroma_w = src_w;
|
|
|
|
u32 src_chroma_h = src_h;
|
2017-02-20 13:49:11 +00:00
|
|
|
int fmt;
|
2016-11-16 06:43:59 +00:00
|
|
|
|
|
|
|
/* Set up source and destination resolution */
|
|
|
|
zx_writel(rsz + RSZ_SRC_CFG, RSZ_VER(src_h - 1) | RSZ_HOR(src_w - 1));
|
|
|
|
zx_writel(rsz + RSZ_DEST_CFG, RSZ_VER(dst_h - 1) | RSZ_HOR(dst_w - 1));
|
|
|
|
|
|
|
|
/* Configure data format for VL RSZ */
|
|
|
|
fmt = zx_vl_rsz_get_fmt(format);
|
|
|
|
if (fmt >= 0)
|
|
|
|
zx_writel_mask(rsz + RSZ_VL_CTRL_CFG, RSZ_VL_FMT_MASK, fmt);
|
|
|
|
|
|
|
|
/* Calculate Chroma height and width */
|
|
|
|
if (fmt == RSZ_VL_FMT_YCBCR420) {
|
|
|
|
src_chroma_w = src_w >> 1;
|
|
|
|
src_chroma_h = src_h >> 1;
|
|
|
|
} else if (fmt == RSZ_VL_FMT_YCBCR422) {
|
|
|
|
src_chroma_w = src_w >> 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up Luma and Chroma step registers */
|
|
|
|
zx_writel(rsz + RSZ_VL_LUMA_HOR, rsz_step_value(src_w, dst_w));
|
|
|
|
zx_writel(rsz + RSZ_VL_LUMA_VER, rsz_step_value(src_h, dst_h));
|
|
|
|
zx_writel(rsz + RSZ_VL_CHROMA_HOR, rsz_step_value(src_chroma_w, dst_w));
|
|
|
|
zx_writel(rsz + RSZ_VL_CHROMA_VER, rsz_step_value(src_chroma_h, dst_h));
|
|
|
|
|
|
|
|
zx_vl_rsz_set_update(zplane);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zx_vl_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)
|
2016-11-16 06:43:59 +00:00
|
|
|
{
|
|
|
|
struct zx_plane *zplane = to_zx_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 12:00:30 +00:00
|
|
|
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
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 12:00:28 +00:00
|
|
|
struct drm_framebuffer *fb = new_state->fb;
|
|
|
|
struct drm_rect *src = &new_state->src;
|
|
|
|
struct drm_rect *dst = &new_state->dst;
|
2016-11-16 06:43:59 +00:00
|
|
|
struct drm_gem_cma_object *cma_obj;
|
|
|
|
void __iomem *layer = zplane->layer;
|
|
|
|
void __iomem *hbsc = zplane->hbsc;
|
|
|
|
void __iomem *paddr_reg;
|
|
|
|
dma_addr_t paddr;
|
|
|
|
u32 src_x, src_y, src_w, src_h;
|
|
|
|
u32 dst_x, dst_y, dst_w, dst_h;
|
|
|
|
uint32_t format;
|
2017-02-20 13:49:11 +00:00
|
|
|
int fmt;
|
2016-11-16 06:43:59 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!fb)
|
|
|
|
return;
|
|
|
|
|
2017-01-31 22:26:33 +00:00
|
|
|
format = fb->format->format;
|
2016-11-16 06:43:59 +00:00
|
|
|
|
|
|
|
src_x = src->x1 >> 16;
|
|
|
|
src_y = src->y1 >> 16;
|
|
|
|
src_w = drm_rect_width(src) >> 16;
|
|
|
|
src_h = drm_rect_height(src) >> 16;
|
|
|
|
|
|
|
|
dst_x = dst->x1;
|
|
|
|
dst_y = dst->y1;
|
|
|
|
dst_w = drm_rect_width(dst);
|
|
|
|
dst_h = drm_rect_height(dst);
|
|
|
|
|
|
|
|
/* Set up data address registers for Y, Cb and Cr planes */
|
|
|
|
paddr_reg = layer + VL_Y;
|
2019-05-16 10:31:47 +00:00
|
|
|
for (i = 0; i < fb->format->num_planes; i++) {
|
2016-11-16 06:43:59 +00:00
|
|
|
cma_obj = drm_fb_cma_get_gem_obj(fb, i);
|
|
|
|
paddr = cma_obj->paddr + fb->offsets[i];
|
|
|
|
paddr += src_y * fb->pitches[i];
|
2019-05-16 10:31:52 +00:00
|
|
|
paddr += src_x * fb->format->cpp[i];
|
2016-11-16 06:43:59 +00:00
|
|
|
zx_writel(paddr_reg, paddr);
|
|
|
|
paddr_reg += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up source height/width register */
|
|
|
|
zx_writel(layer + VL_SRC_SIZE, GL_SRC_W(src_w) | GL_SRC_H(src_h));
|
|
|
|
|
|
|
|
/* Set up start position register */
|
|
|
|
zx_writel(layer + VL_POS_START, GL_POS_X(dst_x) | GL_POS_Y(dst_y));
|
|
|
|
|
|
|
|
/* Set up end position register */
|
|
|
|
zx_writel(layer + VL_POS_END,
|
|
|
|
GL_POS_X(dst_x + dst_w) | GL_POS_Y(dst_y + dst_h));
|
|
|
|
|
|
|
|
/* Strides of Cb and Cr planes should be identical */
|
|
|
|
zx_writel(layer + VL_STRIDE, LUMA_STRIDE(fb->pitches[0]) |
|
|
|
|
CHROMA_STRIDE(fb->pitches[1]));
|
|
|
|
|
|
|
|
/* Set up video layer data format */
|
|
|
|
fmt = zx_vl_get_fmt(format);
|
|
|
|
if (fmt >= 0)
|
|
|
|
zx_writel(layer + VL_CTRL1, fmt);
|
|
|
|
|
|
|
|
/* Always use scaler since it exists (set for not bypass) */
|
|
|
|
zx_writel_mask(layer + VL_CTRL2, VL_SCALER_BYPASS_MODE,
|
|
|
|
VL_SCALER_BYPASS_MODE);
|
|
|
|
|
|
|
|
zx_vl_rsz_setup(zplane, format, src_w, src_h, dst_w, dst_h);
|
|
|
|
|
|
|
|
/* Enable HBSC block */
|
|
|
|
zx_writel_mask(hbsc + HBSC_CTRL0, HBSC_CTRL_EN, HBSC_CTRL_EN);
|
|
|
|
|
|
|
|
zx_vou_layer_enable(plane);
|
|
|
|
|
|
|
|
zx_vl_set_update(zplane);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zx_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 12:00:29 +00:00
|
|
|
struct drm_atomic_state *state)
|
2016-11-16 06:43:59 +00:00
|
|
|
{
|
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_plane_state *old_state = drm_atomic_get_old_plane_state(state,
|
|
|
|
plane);
|
2016-11-16 06:43:59 +00:00
|
|
|
struct zx_plane *zplane = to_zx_plane(plane);
|
|
|
|
void __iomem *hbsc = zplane->hbsc;
|
|
|
|
|
2018-03-26 12:14:42 +00:00
|
|
|
zx_vou_layer_disable(plane, old_state);
|
2016-11-16 06:43:59 +00:00
|
|
|
|
|
|
|
/* Disable HBSC block */
|
|
|
|
zx_writel_mask(hbsc + HBSC_CTRL0, HBSC_CTRL_EN, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct drm_plane_helper_funcs zx_vl_plane_helper_funcs = {
|
|
|
|
.atomic_check = zx_vl_plane_atomic_check,
|
|
|
|
.atomic_update = zx_vl_plane_atomic_update,
|
|
|
|
.atomic_disable = zx_plane_atomic_disable,
|
|
|
|
};
|
|
|
|
|
2016-09-22 11:52:39 +00:00
|
|
|
static int zx_gl_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)
|
2016-09-22 11:52:39 +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 *plane_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
2016-09-22 11:52:39 +00:00
|
|
|
struct drm_framebuffer *fb = plane_state->fb;
|
|
|
|
struct drm_crtc *crtc = plane_state->crtc;
|
|
|
|
struct drm_crtc_state *crtc_state;
|
|
|
|
|
2019-12-13 17:26:12 +00:00
|
|
|
if (!crtc || WARN_ON(!fb))
|
2016-09-22 11:52:39 +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_existing_crtc_state(state,
|
2016-09-22 11:52:39 +00:00
|
|
|
crtc);
|
|
|
|
if (WARN_ON(!crtc_state))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* nothing to check when disabling or disabled */
|
|
|
|
if (!crtc_state->enable)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* plane must be enabled */
|
|
|
|
if (!plane_state->crtc)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2017-11-01 20:16:19 +00:00
|
|
|
return drm_atomic_helper_check_plane_state(plane_state, crtc_state,
|
|
|
|
DRM_PLANE_HELPER_NO_SCALING,
|
|
|
|
DRM_PLANE_HELPER_NO_SCALING,
|
|
|
|
false, true);
|
2016-09-22 11:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int zx_gl_get_fmt(uint32_t format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case DRM_FORMAT_ARGB8888:
|
|
|
|
case DRM_FORMAT_XRGB8888:
|
|
|
|
return GL_FMT_ARGB8888;
|
|
|
|
case DRM_FORMAT_RGB888:
|
|
|
|
return GL_FMT_RGB888;
|
|
|
|
case DRM_FORMAT_RGB565:
|
|
|
|
return GL_FMT_RGB565;
|
|
|
|
case DRM_FORMAT_ARGB1555:
|
|
|
|
return GL_FMT_ARGB1555;
|
|
|
|
case DRM_FORMAT_ARGB4444:
|
|
|
|
return GL_FMT_ARGB4444;
|
|
|
|
default:
|
|
|
|
WARN_ONCE(1, "invalid pixel format %d\n", format);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void zx_gl_set_update(struct zx_plane *zplane)
|
|
|
|
{
|
|
|
|
void __iomem *layer = zplane->layer;
|
|
|
|
|
|
|
|
zx_writel_mask(layer + GL_CTRL0, GL_UPDATE, GL_UPDATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void zx_gl_rsz_set_update(struct zx_plane *zplane)
|
|
|
|
{
|
|
|
|
zx_writel(zplane->rsz + RSZ_ENABLE_CFG, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zx_gl_rsz_setup(struct zx_plane *zplane, u32 src_w, u32 src_h,
|
|
|
|
u32 dst_w, u32 dst_h)
|
|
|
|
{
|
|
|
|
void __iomem *rsz = zplane->rsz;
|
|
|
|
|
|
|
|
zx_writel(rsz + RSZ_SRC_CFG, RSZ_VER(src_h - 1) | RSZ_HOR(src_w - 1));
|
|
|
|
zx_writel(rsz + RSZ_DEST_CFG, RSZ_VER(dst_h - 1) | RSZ_HOR(dst_w - 1));
|
|
|
|
|
|
|
|
zx_gl_rsz_set_update(zplane);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zx_gl_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)
|
2016-09-22 11:52:39 +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);
|
2016-09-22 11:52:39 +00:00
|
|
|
struct zx_plane *zplane = to_zx_plane(plane);
|
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;
|
2016-09-22 11:52:39 +00:00
|
|
|
struct drm_gem_cma_object *cma_obj;
|
|
|
|
void __iomem *layer = zplane->layer;
|
|
|
|
void __iomem *csc = zplane->csc;
|
|
|
|
void __iomem *hbsc = zplane->hbsc;
|
|
|
|
u32 src_x, src_y, src_w, src_h;
|
|
|
|
u32 dst_x, dst_y, dst_w, dst_h;
|
2016-11-11 00:03:15 +00:00
|
|
|
unsigned int bpp;
|
2016-09-22 11:52:39 +00:00
|
|
|
uint32_t format;
|
|
|
|
dma_addr_t paddr;
|
|
|
|
u32 stride;
|
|
|
|
int fmt;
|
|
|
|
|
|
|
|
if (!fb)
|
|
|
|
return;
|
|
|
|
|
2016-12-14 21:32:55 +00:00
|
|
|
format = fb->format->format;
|
2016-09-22 11:52:39 +00:00
|
|
|
stride = fb->pitches[0];
|
|
|
|
|
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
|
|
|
src_x = new_state->src_x >> 16;
|
|
|
|
src_y = new_state->src_y >> 16;
|
|
|
|
src_w = new_state->src_w >> 16;
|
|
|
|
src_h = new_state->src_h >> 16;
|
2016-09-22 11:52:39 +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
|
|
|
dst_x = new_state->crtc_x;
|
|
|
|
dst_y = new_state->crtc_y;
|
|
|
|
dst_w = new_state->crtc_w;
|
|
|
|
dst_h = new_state->crtc_h;
|
2016-09-22 11:52:39 +00:00
|
|
|
|
2016-12-14 21:30:57 +00:00
|
|
|
bpp = fb->format->cpp[0];
|
2016-09-22 11:52:39 +00:00
|
|
|
|
|
|
|
cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
|
|
|
|
paddr = cma_obj->paddr + fb->offsets[0];
|
|
|
|
paddr += src_y * stride + src_x * bpp / 8;
|
|
|
|
zx_writel(layer + GL_ADDR, paddr);
|
|
|
|
|
|
|
|
/* Set up source height/width register */
|
|
|
|
zx_writel(layer + GL_SRC_SIZE, GL_SRC_W(src_w) | GL_SRC_H(src_h));
|
|
|
|
|
|
|
|
/* Set up start position register */
|
|
|
|
zx_writel(layer + GL_POS_START, GL_POS_X(dst_x) | GL_POS_Y(dst_y));
|
|
|
|
|
|
|
|
/* Set up end position register */
|
|
|
|
zx_writel(layer + GL_POS_END,
|
|
|
|
GL_POS_X(dst_x + dst_w) | GL_POS_Y(dst_y + dst_h));
|
|
|
|
|
|
|
|
/* Set up stride register */
|
|
|
|
zx_writel(layer + GL_STRIDE, stride & 0xffff);
|
|
|
|
|
|
|
|
/* Set up graphic layer data format */
|
|
|
|
fmt = zx_gl_get_fmt(format);
|
|
|
|
if (fmt >= 0)
|
|
|
|
zx_writel_mask(layer + GL_CTRL1, GL_DATA_FMT_MASK,
|
|
|
|
fmt << GL_DATA_FMT_SHIFT);
|
|
|
|
|
|
|
|
/* Initialize global alpha with a sane value */
|
|
|
|
zx_writel_mask(layer + GL_CTRL2, GL_GLOBAL_ALPHA_MASK,
|
|
|
|
0xff << GL_GLOBAL_ALPHA_SHIFT);
|
|
|
|
|
|
|
|
/* Setup CSC for the GL */
|
|
|
|
if (dst_h > 720)
|
|
|
|
zx_writel_mask(csc + CSC_CTRL0, CSC_COV_MODE_MASK,
|
|
|
|
CSC_BT709_IMAGE_RGB2YCBCR << CSC_COV_MODE_SHIFT);
|
|
|
|
else
|
|
|
|
zx_writel_mask(csc + CSC_CTRL0, CSC_COV_MODE_MASK,
|
|
|
|
CSC_BT601_IMAGE_RGB2YCBCR << CSC_COV_MODE_SHIFT);
|
|
|
|
zx_writel_mask(csc + CSC_CTRL0, CSC_WORK_ENABLE, CSC_WORK_ENABLE);
|
|
|
|
|
|
|
|
/* Always use scaler since it exists (set for not bypass) */
|
|
|
|
zx_writel_mask(layer + GL_CTRL3, GL_SCALER_BYPASS_MODE,
|
|
|
|
GL_SCALER_BYPASS_MODE);
|
|
|
|
|
|
|
|
zx_gl_rsz_setup(zplane, src_w, src_h, dst_w, dst_h);
|
|
|
|
|
|
|
|
/* Enable HBSC block */
|
|
|
|
zx_writel_mask(hbsc + HBSC_CTRL0, HBSC_CTRL_EN, HBSC_CTRL_EN);
|
|
|
|
|
2016-12-29 00:03:03 +00:00
|
|
|
zx_vou_layer_enable(plane);
|
|
|
|
|
2016-09-22 11:52:39 +00:00
|
|
|
zx_gl_set_update(zplane);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct drm_plane_helper_funcs zx_gl_plane_helper_funcs = {
|
|
|
|
.atomic_check = zx_gl_plane_atomic_check,
|
|
|
|
.atomic_update = zx_gl_plane_atomic_update,
|
2016-12-29 00:03:03 +00:00
|
|
|
.atomic_disable = zx_plane_atomic_disable,
|
2016-09-22 11:52:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct drm_plane_funcs zx_plane_funcs = {
|
|
|
|
.update_plane = drm_atomic_helper_update_plane,
|
|
|
|
.disable_plane = drm_atomic_helper_disable_plane,
|
2018-01-17 21:15:18 +00:00
|
|
|
.destroy = drm_plane_cleanup,
|
2016-09-22 11:52:39 +00:00
|
|
|
.reset = drm_atomic_helper_plane_reset,
|
|
|
|
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
|
|
|
|
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
|
|
|
|
};
|
|
|
|
|
2016-11-16 06:43:59 +00:00
|
|
|
void zx_plane_set_update(struct drm_plane *plane)
|
|
|
|
{
|
|
|
|
struct zx_plane *zplane = to_zx_plane(plane);
|
|
|
|
|
|
|
|
/* Do nothing if the plane is not enabled */
|
|
|
|
if (!plane->state->crtc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (plane->type) {
|
|
|
|
case DRM_PLANE_TYPE_PRIMARY:
|
|
|
|
zx_gl_rsz_set_update(zplane);
|
|
|
|
zx_gl_set_update(zplane);
|
|
|
|
break;
|
|
|
|
case DRM_PLANE_TYPE_OVERLAY:
|
|
|
|
zx_vl_rsz_set_update(zplane);
|
|
|
|
zx_vl_set_update(zplane);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN_ONCE(1, "unsupported plane type %d\n", plane->type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 11:52:39 +00:00
|
|
|
static void zx_plane_hbsc_init(struct zx_plane *zplane)
|
|
|
|
{
|
|
|
|
void __iomem *hbsc = zplane->hbsc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize HBSC block with a sane configuration per recommedation
|
|
|
|
* from ZTE BSP code.
|
|
|
|
*/
|
|
|
|
zx_writel(hbsc + HBSC_SATURATION, 0x200);
|
|
|
|
zx_writel(hbsc + HBSC_HUE, 0x0);
|
|
|
|
zx_writel(hbsc + HBSC_BRIGHT, 0x0);
|
|
|
|
zx_writel(hbsc + HBSC_CONTRAST, 0x200);
|
|
|
|
|
|
|
|
zx_writel(hbsc + HBSC_THRESHOLD_COL1, (0x3ac << 16) | 0x40);
|
|
|
|
zx_writel(hbsc + HBSC_THRESHOLD_COL2, (0x3c0 << 16) | 0x40);
|
|
|
|
zx_writel(hbsc + HBSC_THRESHOLD_COL3, (0x3c0 << 16) | 0x40);
|
|
|
|
}
|
|
|
|
|
2016-12-28 06:41:37 +00:00
|
|
|
int zx_plane_init(struct drm_device *drm, struct zx_plane *zplane,
|
|
|
|
enum drm_plane_type type)
|
2016-09-22 11:52:39 +00:00
|
|
|
{
|
|
|
|
const struct drm_plane_helper_funcs *helper;
|
2016-12-28 06:41:37 +00:00
|
|
|
struct drm_plane *plane = &zplane->plane;
|
|
|
|
struct device *dev = zplane->dev;
|
2016-09-22 11:52:39 +00:00
|
|
|
const uint32_t *formats;
|
|
|
|
unsigned int format_count;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
zx_plane_hbsc_init(zplane);
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case DRM_PLANE_TYPE_PRIMARY:
|
|
|
|
helper = &zx_gl_plane_helper_funcs;
|
|
|
|
formats = gl_formats;
|
|
|
|
format_count = ARRAY_SIZE(gl_formats);
|
|
|
|
break;
|
|
|
|
case DRM_PLANE_TYPE_OVERLAY:
|
2016-11-16 06:43:59 +00:00
|
|
|
helper = &zx_vl_plane_helper_funcs;
|
|
|
|
formats = vl_formats;
|
|
|
|
format_count = ARRAY_SIZE(vl_formats);
|
2016-09-22 11:52:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
2016-12-28 06:41:37 +00:00
|
|
|
return -ENODEV;
|
2016-09-22 11:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = drm_universal_plane_init(drm, plane, VOU_CRTC_MASK,
|
|
|
|
&zx_plane_funcs, formats, format_count,
|
2017-07-24 03:46:38 +00:00
|
|
|
NULL, type, NULL);
|
2016-09-22 11:52:39 +00:00
|
|
|
if (ret) {
|
|
|
|
DRM_DEV_ERROR(dev, "failed to init universal plane: %d\n", ret);
|
2016-12-28 06:41:37 +00:00
|
|
|
return ret;
|
2016-09-22 11:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
drm_plane_helper_add(plane, helper);
|
|
|
|
|
2016-12-28 06:41:37 +00:00
|
|
|
return 0;
|
2016-09-22 11:52:39 +00:00
|
|
|
}
|