2019-05-27 06:55:01 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-08-20 02:19:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Freescale Semiconductor, Inc.
|
|
|
|
*
|
|
|
|
* Freescale DCU drm device driver
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
|
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
|
|
|
#include <drm/drm_atomic.h>
|
2015-08-20 02:19:49 +00:00
|
|
|
#include <drm/drm_atomic_helper.h>
|
|
|
|
#include <drm/drm_crtc.h>
|
|
|
|
#include <drm/drm_fb_cma_helper.h>
|
2019-06-30 06:18:57 +00:00
|
|
|
#include <drm/drm_fourcc.h>
|
2015-08-20 02:19:49 +00:00
|
|
|
#include <drm/drm_gem_cma_helper.h>
|
|
|
|
#include <drm/drm_plane_helper.h>
|
2019-01-17 21:03:34 +00:00
|
|
|
#include <drm/drm_probe_helper.h>
|
2015-08-20 02:19:49 +00:00
|
|
|
|
|
|
|
#include "fsl_dcu_drm_drv.h"
|
|
|
|
#include "fsl_dcu_drm_plane.h"
|
|
|
|
|
|
|
|
static int fsl_dcu_drm_plane_index(struct drm_plane *plane)
|
|
|
|
{
|
|
|
|
struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
|
|
|
|
unsigned int total_layer = fsl_dev->soc->total_layer;
|
|
|
|
unsigned int index;
|
|
|
|
|
|
|
|
index = drm_plane_index(plane);
|
|
|
|
if (index < total_layer)
|
|
|
|
return total_layer - index - 1;
|
|
|
|
|
|
|
|
dev_err(fsl_dev->dev, "No more layer left\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fsl_dcu_drm_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)
|
2015-08-20 02:19:49 +00:00
|
|
|
{
|
drm/atomic: Pass the full state to planes atomic_check
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_check.
The conversion was done using the coccinelle script below plus some
manual changes for vmwgfx, built tested on all the drivers.
@@
identifier plane, plane_state;
symbol state;
@@
struct drm_plane_helper_funcs {
...
int (*atomic_check)(struct drm_plane *plane,
- struct drm_plane_state *plane_state);
+ struct drm_atomic_state *state);
...
}
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};
@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<+...
- FUNCS->atomic_check(plane, plane_state)
+ FUNCS->atomic_check(plane, state)
...+>
}
@ ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
... when != new_plane_state
}
@ adds_new_state depends on plane_atomic_func && !ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
{
+ struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
...
}
@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *new_plane_state
+ struct drm_atomic_state *state
)
{ ... }
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-4-maxime@cerno.tech
2021-02-19 12:00:24 +00:00
|
|
|
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
2021-02-19 12:00:22 +00:00
|
|
|
struct drm_framebuffer *fb = new_plane_state->fb;
|
2015-08-20 02:19:49 +00:00
|
|
|
|
2021-02-19 12:00:22 +00:00
|
|
|
if (!new_plane_state->fb || !new_plane_state->crtc)
|
2016-01-06 04:12:05 +00:00
|
|
|
return 0;
|
|
|
|
|
2016-12-14 21:32:55 +00:00
|
|
|
switch (fb->format->format) {
|
2015-08-20 02:19:49 +00:00
|
|
|
case DRM_FORMAT_RGB565:
|
|
|
|
case DRM_FORMAT_RGB888:
|
2015-11-18 22:47:35 +00:00
|
|
|
case DRM_FORMAT_XRGB8888:
|
2015-08-20 02:19:49 +00:00
|
|
|
case DRM_FORMAT_ARGB8888:
|
2015-11-18 22:47:35 +00:00
|
|
|
case DRM_FORMAT_XRGB4444:
|
|
|
|
case DRM_FORMAT_ARGB4444:
|
|
|
|
case DRM_FORMAT_XRGB1555:
|
2015-08-20 02:19:49 +00:00
|
|
|
case DRM_FORMAT_ARGB1555:
|
|
|
|
case DRM_FORMAT_YUV422:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fsl_dcu_drm_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)
|
2015-08-20 02:19:49 +00:00
|
|
|
{
|
|
|
|
struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
|
2015-09-21 13:33:47 +00:00
|
|
|
unsigned int value;
|
2015-11-19 00:50:55 +00:00
|
|
|
int index;
|
2015-08-20 02:19:49 +00:00
|
|
|
|
|
|
|
index = fsl_dcu_drm_plane_index(plane);
|
|
|
|
if (index < 0)
|
|
|
|
return;
|
|
|
|
|
2015-11-19 00:50:55 +00:00
|
|
|
regmap_read(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), &value);
|
2015-08-20 02:19:49 +00:00
|
|
|
value &= ~DCU_LAYER_EN;
|
2015-11-19 00:50:55 +00:00
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), value);
|
2015-08-20 02:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void fsl_dcu_drm_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)
|
2015-08-20 02:19:49 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
|
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);
|
2015-08-20 02:19:49 +00:00
|
|
|
struct drm_framebuffer *fb = plane->state->fb;
|
|
|
|
struct drm_gem_cma_object *gem;
|
2015-11-18 22:47:35 +00:00
|
|
|
unsigned int alpha = DCU_LAYER_AB_NONE, bpp;
|
2015-11-19 00:50:55 +00:00
|
|
|
int index;
|
2015-08-20 02:19:49 +00:00
|
|
|
|
|
|
|
if (!fb)
|
|
|
|
return;
|
|
|
|
|
|
|
|
index = fsl_dcu_drm_plane_index(plane);
|
|
|
|
if (index < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gem = drm_fb_cma_get_gem_obj(fb, 0);
|
|
|
|
|
2016-12-14 21:32:55 +00:00
|
|
|
switch (fb->format->format) {
|
2015-08-20 02:19:49 +00:00
|
|
|
case DRM_FORMAT_RGB565:
|
|
|
|
bpp = FSL_DCU_RGB565;
|
|
|
|
break;
|
|
|
|
case DRM_FORMAT_RGB888:
|
|
|
|
bpp = FSL_DCU_RGB888;
|
|
|
|
break;
|
|
|
|
case DRM_FORMAT_ARGB8888:
|
2015-11-18 22:47:35 +00:00
|
|
|
alpha = DCU_LAYER_AB_WHOLE_FRAME;
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2015-11-18 22:47:35 +00:00
|
|
|
case DRM_FORMAT_XRGB8888:
|
2015-08-20 02:19:49 +00:00
|
|
|
bpp = FSL_DCU_ARGB8888;
|
|
|
|
break;
|
2015-11-18 22:47:35 +00:00
|
|
|
case DRM_FORMAT_ARGB4444:
|
|
|
|
alpha = DCU_LAYER_AB_WHOLE_FRAME;
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2015-11-18 22:47:35 +00:00
|
|
|
case DRM_FORMAT_XRGB4444:
|
2015-08-20 02:19:49 +00:00
|
|
|
bpp = FSL_DCU_ARGB4444;
|
|
|
|
break;
|
|
|
|
case DRM_FORMAT_ARGB1555:
|
2015-11-18 22:47:35 +00:00
|
|
|
alpha = DCU_LAYER_AB_WHOLE_FRAME;
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2015-11-18 22:47:35 +00:00
|
|
|
case DRM_FORMAT_XRGB1555:
|
2015-08-20 02:19:49 +00:00
|
|
|
bpp = FSL_DCU_ARGB1555;
|
|
|
|
break;
|
|
|
|
case DRM_FORMAT_YUV422:
|
|
|
|
bpp = FSL_DCU_YUV422;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-19 00:50:55 +00:00
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 1),
|
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
|
|
|
DCU_LAYER_HEIGHT(new_state->crtc_h) |
|
|
|
|
DCU_LAYER_WIDTH(new_state->crtc_w));
|
2015-11-19 00:50:55 +00:00
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 2),
|
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
|
|
|
DCU_LAYER_POSY(new_state->crtc_y) |
|
|
|
|
DCU_LAYER_POSX(new_state->crtc_x));
|
2015-11-19 00:50:55 +00:00
|
|
|
regmap_write(fsl_dev->regmap,
|
|
|
|
DCU_CTRLDESCLN(index, 3), gem->paddr);
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4),
|
|
|
|
DCU_LAYER_EN |
|
2015-11-18 22:47:35 +00:00
|
|
|
DCU_LAYER_TRANS(0xff) |
|
2015-11-19 00:50:55 +00:00
|
|
|
DCU_LAYER_BPP(bpp) |
|
2015-11-18 22:47:35 +00:00
|
|
|
alpha);
|
2015-11-19 00:50:55 +00:00
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 5),
|
|
|
|
DCU_LAYER_CKMAX_R(0xFF) |
|
|
|
|
DCU_LAYER_CKMAX_G(0xFF) |
|
|
|
|
DCU_LAYER_CKMAX_B(0xFF));
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 6),
|
|
|
|
DCU_LAYER_CKMIN_R(0) |
|
|
|
|
DCU_LAYER_CKMIN_G(0) |
|
|
|
|
DCU_LAYER_CKMIN_B(0));
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 7), 0);
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 8),
|
|
|
|
DCU_LAYER_FG_FCOLOR(0));
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 9),
|
|
|
|
DCU_LAYER_BG_BCOLOR(0));
|
|
|
|
|
2015-08-20 02:19:49 +00:00
|
|
|
if (!strcmp(fsl_dev->soc->name, "ls1021a")) {
|
2015-11-19 00:50:55 +00:00
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 10),
|
|
|
|
DCU_LAYER_POST_SKIP(0) |
|
|
|
|
DCU_LAYER_PRE_SKIP(0));
|
2015-08-20 02:19:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-19 00:50:55 +00:00
|
|
|
return;
|
2015-08-20 02:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct drm_plane_helper_funcs fsl_dcu_drm_plane_helper_funcs = {
|
|
|
|
.atomic_check = fsl_dcu_drm_plane_atomic_check,
|
|
|
|
.atomic_disable = fsl_dcu_drm_plane_atomic_disable,
|
|
|
|
.atomic_update = fsl_dcu_drm_plane_atomic_update,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void fsl_dcu_drm_plane_destroy(struct drm_plane *plane)
|
|
|
|
{
|
|
|
|
drm_plane_cleanup(plane);
|
2015-11-16 23:43:34 +00:00
|
|
|
kfree(plane);
|
2015-08-20 02:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
|
|
|
|
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
|
|
|
|
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
|
|
|
|
.destroy = fsl_dcu_drm_plane_destroy,
|
|
|
|
.disable_plane = drm_atomic_helper_disable_plane,
|
|
|
|
.reset = drm_atomic_helper_plane_reset,
|
|
|
|
.update_plane = drm_atomic_helper_update_plane,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u32 fsl_dcu_drm_plane_formats[] = {
|
|
|
|
DRM_FORMAT_RGB565,
|
|
|
|
DRM_FORMAT_RGB888,
|
2015-11-18 22:47:35 +00:00
|
|
|
DRM_FORMAT_XRGB8888,
|
2015-08-20 02:19:49 +00:00
|
|
|
DRM_FORMAT_ARGB8888,
|
2015-11-18 22:47:35 +00:00
|
|
|
DRM_FORMAT_XRGB4444,
|
2015-08-20 02:19:49 +00:00
|
|
|
DRM_FORMAT_ARGB4444,
|
2015-11-18 22:47:35 +00:00
|
|
|
DRM_FORMAT_XRGB1555,
|
2015-08-20 02:19:49 +00:00
|
|
|
DRM_FORMAT_ARGB1555,
|
|
|
|
DRM_FORMAT_YUV422,
|
|
|
|
};
|
|
|
|
|
2016-02-12 00:51:49 +00:00
|
|
|
void fsl_dcu_drm_init_planes(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < fsl_dev->soc->total_layer; i++) {
|
|
|
|
for (j = 1; j <= fsl_dev->soc->layer_regs; j++)
|
|
|
|
regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(i, j), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-20 02:19:49 +00:00
|
|
|
struct drm_plane *fsl_dcu_drm_primary_create_plane(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_plane *primary;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
primary = kzalloc(sizeof(*primary), GFP_KERNEL);
|
|
|
|
if (!primary) {
|
|
|
|
DRM_DEBUG_KMS("Failed to allocate primary plane\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* possible_crtc's will be filled in later by crtc_init */
|
|
|
|
ret = drm_universal_plane_init(dev, primary, 0,
|
|
|
|
&fsl_dcu_drm_plane_funcs,
|
|
|
|
fsl_dcu_drm_plane_formats,
|
|
|
|
ARRAY_SIZE(fsl_dcu_drm_plane_formats),
|
2017-07-24 03:46:38 +00:00
|
|
|
NULL, DRM_PLANE_TYPE_PRIMARY, NULL);
|
2015-08-20 02:19:49 +00:00
|
|
|
if (ret) {
|
|
|
|
kfree(primary);
|
|
|
|
primary = NULL;
|
|
|
|
}
|
|
|
|
drm_plane_helper_add(primary, &fsl_dcu_drm_plane_helper_funcs);
|
|
|
|
|
|
|
|
return primary;
|
|
|
|
}
|