2019-05-27 08:55:21 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2016-01-04 18:36:34 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 MediaTek Inc.
|
|
|
|
* Author: CK Hu <ck.hu@mediatek.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <drm/drm_atomic.h>
|
|
|
|
#include <drm/drm_atomic_helper.h>
|
2019-12-10 13:05:22 +08:00
|
|
|
#include <drm/drm_atomic_uapi.h>
|
2022-06-13 23:03:12 +03:00
|
|
|
#include <drm/drm_blend.h>
|
2021-02-22 15:17:56 +01:00
|
|
|
#include <drm/drm_fourcc.h>
|
2022-06-14 12:54:49 +03:00
|
|
|
#include <drm/drm_framebuffer.h>
|
2021-02-22 15:17:56 +01:00
|
|
|
#include <drm/drm_gem_atomic_helper.h>
|
2022-11-16 14:33:35 -05:00
|
|
|
#include <linux/align.h>
|
2016-01-04 18:36:34 +01:00
|
|
|
|
2024-03-22 17:12:24 +08:00
|
|
|
#include "mtk_crtc.h"
|
2024-03-22 17:12:26 +08:00
|
|
|
#include "mtk_ddp_comp.h"
|
2016-01-04 18:36:34 +01:00
|
|
|
#include "mtk_drm_drv.h"
|
2024-03-22 17:12:30 +08:00
|
|
|
#include "mtk_gem.h"
|
2024-03-22 17:12:28 +08:00
|
|
|
#include "mtk_plane.h"
|
2016-01-04 18:36:34 +01:00
|
|
|
|
2022-11-16 14:33:35 -05:00
|
|
|
static const u64 modifiers[] = {
|
|
|
|
DRM_FORMAT_MOD_LINEAR,
|
|
|
|
DRM_FORMAT_MOD_ARM_AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 |
|
|
|
|
AFBC_FORMAT_MOD_SPLIT |
|
|
|
|
AFBC_FORMAT_MOD_SPARSE),
|
|
|
|
DRM_FORMAT_MOD_INVALID,
|
|
|
|
};
|
|
|
|
|
2016-01-04 18:36:34 +01:00
|
|
|
static void mtk_plane_reset(struct drm_plane *plane)
|
|
|
|
{
|
|
|
|
struct mtk_plane_state *state;
|
|
|
|
|
|
|
|
if (plane->state) {
|
2016-08-04 10:59:54 +08:00
|
|
|
__drm_atomic_helper_plane_destroy_state(plane->state);
|
2016-01-04 18:36:34 +01:00
|
|
|
|
|
|
|
state = to_mtk_plane_state(plane->state);
|
|
|
|
memset(state, 0, sizeof(*state));
|
|
|
|
} else {
|
|
|
|
state = kzalloc(sizeof(*state), GFP_KERNEL);
|
|
|
|
if (!state)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-13 11:07:22 -05:00
|
|
|
__drm_atomic_helper_plane_reset(plane, &state->base);
|
|
|
|
|
2016-01-04 18:36:34 +01:00
|
|
|
state->base.plane = plane;
|
|
|
|
state->pending.format = DRM_FORMAT_RGB565;
|
2022-11-16 14:33:35 -05:00
|
|
|
state->pending.modifier = DRM_FORMAT_MOD_LINEAR;
|
2016-01-04 18:36:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct drm_plane_state *mtk_plane_duplicate_state(struct drm_plane *plane)
|
|
|
|
{
|
|
|
|
struct mtk_plane_state *old_state = to_mtk_plane_state(plane->state);
|
|
|
|
struct mtk_plane_state *state;
|
|
|
|
|
2022-01-18 14:37:58 +01:00
|
|
|
state = kmalloc(sizeof(*state), GFP_KERNEL);
|
2016-01-04 18:36:34 +01:00
|
|
|
if (!state)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
__drm_atomic_helper_plane_duplicate_state(plane, &state->base);
|
|
|
|
|
|
|
|
WARN_ON(state->base.plane != plane);
|
|
|
|
|
|
|
|
state->pending = old_state->pending;
|
|
|
|
|
|
|
|
return &state->base;
|
|
|
|
}
|
|
|
|
|
2022-11-16 14:33:35 -05:00
|
|
|
static bool mtk_plane_format_mod_supported(struct drm_plane *plane,
|
|
|
|
uint32_t format,
|
|
|
|
uint64_t modifier)
|
|
|
|
{
|
|
|
|
if (modifier == DRM_FORMAT_MOD_LINEAR)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (modifier != DRM_FORMAT_MOD_ARM_AFBC(
|
|
|
|
AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 |
|
|
|
|
AFBC_FORMAT_MOD_SPLIT |
|
|
|
|
AFBC_FORMAT_MOD_SPARSE))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (format != DRM_FORMAT_XRGB8888 &&
|
|
|
|
format != DRM_FORMAT_ARGB8888 &&
|
|
|
|
format != DRM_FORMAT_BGRX8888 &&
|
|
|
|
format != DRM_FORMAT_BGRA8888 &&
|
|
|
|
format != DRM_FORMAT_ABGR8888 &&
|
|
|
|
format != DRM_FORMAT_XBGR8888 &&
|
|
|
|
format != DRM_FORMAT_RGB888 &&
|
|
|
|
format != DRM_FORMAT_BGR888)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-03-22 17:12:21 +08:00
|
|
|
static void mtk_plane_destroy_state(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *state)
|
2016-01-04 18:36:34 +01:00
|
|
|
{
|
2016-05-09 16:34:10 +02:00
|
|
|
__drm_atomic_helper_plane_destroy_state(state);
|
2016-01-04 18:36:34 +01:00
|
|
|
kfree(to_mtk_plane_state(state));
|
|
|
|
}
|
|
|
|
|
2019-12-10 13:05:22 +08:00
|
|
|
static int mtk_plane_atomic_async_check(struct drm_plane *plane,
|
2025-01-27 16:59:39 -03:00
|
|
|
struct drm_atomic_state *state, bool flip)
|
2019-12-10 13:05:22 +08:00
|
|
|
{
|
drm/atomic: Pass the full state to planes async atomic check 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 start convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_async_check and
atomic_async_update.
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 {
...
int (*atomic_async_check)(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_async_update)(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_async_check = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_update = 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_async_check(plane, plane_state)
+ FUNCS->atomic_async_check(plane, state)
...+>
}
@@
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_async_update(plane, plane_state)
+ FUNCS->atomic_async_update(plane, state)
...+>
}
@@
identifier mtk_plane_atomic_async_update;
identifier plane;
symbol new_state, state;
expression e;
@@
void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
{
...
- struct mtk_plane_state *state = e;
+ struct mtk_plane_state *new_plane_state = e;
<+...
- state
+ new_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 *new_plane_state)
{
<...
- state
+ new_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, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *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/...>
@@
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
...+>
}
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 13:00:21 +01:00
|
|
|
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
2019-12-10 13:05:22 +08:00
|
|
|
struct drm_crtc_state *crtc_state;
|
2020-02-13 09:23:52 +08:00
|
|
|
int ret;
|
2019-12-10 13:05:22 +08:00
|
|
|
|
drm/atomic: Pass the full state to planes async atomic check 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 start convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_async_check and
atomic_async_update.
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 {
...
int (*atomic_async_check)(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_async_update)(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_async_check = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_update = 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_async_check(plane, plane_state)
+ FUNCS->atomic_async_check(plane, state)
...+>
}
@@
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_async_update(plane, plane_state)
+ FUNCS->atomic_async_update(plane, state)
...+>
}
@@
identifier mtk_plane_atomic_async_update;
identifier plane;
symbol new_state, state;
expression e;
@@
void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
{
...
- struct mtk_plane_state *state = e;
+ struct mtk_plane_state *new_plane_state = e;
<+...
- state
+ new_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 *new_plane_state)
{
<...
- state
+ new_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, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *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/...>
@@
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
...+>
}
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 13:00:21 +01:00
|
|
|
if (plane != new_plane_state->crtc->cursor)
|
2019-12-10 13:05:22 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!plane->state)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!plane->state->fb)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2024-03-22 17:12:19 +08:00
|
|
|
ret = mtk_crtc_plane_check(new_plane_state->crtc, plane,
|
|
|
|
to_mtk_plane_state(new_plane_state));
|
2020-02-13 09:23:52 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2023-07-14 17:49:08 +08:00
|
|
|
crtc_state = drm_atomic_get_existing_crtc_state(state, new_plane_state->crtc);
|
2019-12-10 13:05:22 +08:00
|
|
|
|
|
|
|
return drm_atomic_helper_check_plane_state(plane->state, crtc_state,
|
2022-07-20 10:30:54 +02:00
|
|
|
DRM_PLANE_NO_SCALING,
|
|
|
|
DRM_PLANE_NO_SCALING,
|
2019-12-10 13:05:22 +08:00
|
|
|
true, true);
|
|
|
|
}
|
|
|
|
|
2021-07-22 09:47:43 +08:00
|
|
|
static void mtk_plane_update_new_state(struct drm_plane_state *new_state,
|
|
|
|
struct mtk_plane_state *mtk_plane_state)
|
|
|
|
{
|
|
|
|
struct drm_framebuffer *fb = new_state->fb;
|
|
|
|
struct drm_gem_object *gem;
|
2024-03-22 17:12:22 +08:00
|
|
|
struct mtk_gem_obj *mtk_gem;
|
2021-07-22 09:47:43 +08:00
|
|
|
unsigned int pitch, format;
|
2022-11-16 14:33:35 -05:00
|
|
|
u64 modifier;
|
2021-07-22 09:47:43 +08:00
|
|
|
dma_addr_t addr;
|
2022-11-16 14:33:35 -05:00
|
|
|
dma_addr_t hdr_addr = 0;
|
|
|
|
unsigned int hdr_pitch = 0;
|
2023-09-07 17:14:25 +08:00
|
|
|
int offset;
|
2021-07-22 09:47:43 +08:00
|
|
|
|
|
|
|
gem = fb->obj[0];
|
|
|
|
mtk_gem = to_mtk_gem_obj(gem);
|
|
|
|
addr = mtk_gem->dma_addr;
|
|
|
|
pitch = fb->pitches[0];
|
|
|
|
format = fb->format->format;
|
2022-11-16 14:33:35 -05:00
|
|
|
modifier = fb->modifier;
|
2021-07-22 09:47:43 +08:00
|
|
|
|
2022-11-16 14:33:35 -05:00
|
|
|
if (modifier == DRM_FORMAT_MOD_LINEAR) {
|
2023-09-07 17:14:25 +08:00
|
|
|
/*
|
|
|
|
* Using dma_addr_t variable to calculate with multiplier of different types,
|
|
|
|
* for example: addr += (new_state->src.x1 >> 16) * fb->format->cpp[0];
|
|
|
|
* may cause coverity issue with unintentional overflow.
|
|
|
|
*/
|
|
|
|
offset = (new_state->src.x1 >> 16) * fb->format->cpp[0];
|
|
|
|
addr += offset;
|
|
|
|
offset = (new_state->src.y1 >> 16) * pitch;
|
|
|
|
addr += offset;
|
2022-11-16 14:33:35 -05:00
|
|
|
} else {
|
|
|
|
int width_in_blocks = ALIGN(fb->width, AFBC_DATA_BLOCK_WIDTH)
|
|
|
|
/ AFBC_DATA_BLOCK_WIDTH;
|
|
|
|
int height_in_blocks = ALIGN(fb->height, AFBC_DATA_BLOCK_HEIGHT)
|
|
|
|
/ AFBC_DATA_BLOCK_HEIGHT;
|
|
|
|
int x_offset_in_blocks = (new_state->src.x1 >> 16) / AFBC_DATA_BLOCK_WIDTH;
|
|
|
|
int y_offset_in_blocks = (new_state->src.y1 >> 16) / AFBC_DATA_BLOCK_HEIGHT;
|
2023-09-07 17:14:25 +08:00
|
|
|
int hdr_size, hdr_offset;
|
2022-11-16 14:33:35 -05:00
|
|
|
|
|
|
|
hdr_pitch = width_in_blocks * AFBC_HEADER_BLOCK_SIZE;
|
|
|
|
pitch = width_in_blocks * AFBC_DATA_BLOCK_WIDTH *
|
|
|
|
AFBC_DATA_BLOCK_HEIGHT * fb->format->cpp[0];
|
|
|
|
|
|
|
|
hdr_size = ALIGN(hdr_pitch * height_in_blocks, AFBC_HEADER_ALIGNMENT);
|
2023-09-07 17:14:25 +08:00
|
|
|
hdr_offset = hdr_pitch * y_offset_in_blocks +
|
|
|
|
AFBC_HEADER_BLOCK_SIZE * x_offset_in_blocks;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Using dma_addr_t variable to calculate with multiplier of different types,
|
|
|
|
* for example: addr += hdr_pitch * y_offset_in_blocks;
|
|
|
|
* may cause coverity issue with unintentional overflow.
|
|
|
|
*/
|
|
|
|
hdr_addr = addr + hdr_offset;
|
2022-11-16 14:33:35 -05:00
|
|
|
|
|
|
|
/* The data plane is offset by 1 additional block. */
|
2023-09-07 17:14:25 +08:00
|
|
|
offset = pitch * y_offset_in_blocks +
|
|
|
|
AFBC_DATA_BLOCK_WIDTH * AFBC_DATA_BLOCK_HEIGHT *
|
|
|
|
fb->format->cpp[0] * (x_offset_in_blocks + 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Using dma_addr_t variable to calculate with multiplier of different types,
|
|
|
|
* for example: addr += pitch * y_offset_in_blocks;
|
|
|
|
* may cause coverity issue with unintentional overflow.
|
|
|
|
*/
|
|
|
|
addr = addr + hdr_size + offset;
|
2022-11-16 14:33:35 -05:00
|
|
|
}
|
2021-07-22 09:47:43 +08:00
|
|
|
|
|
|
|
mtk_plane_state->pending.enable = true;
|
|
|
|
mtk_plane_state->pending.pitch = pitch;
|
2022-11-16 14:33:35 -05:00
|
|
|
mtk_plane_state->pending.hdr_pitch = hdr_pitch;
|
2021-07-22 09:47:43 +08:00
|
|
|
mtk_plane_state->pending.format = format;
|
2022-11-16 14:33:35 -05:00
|
|
|
mtk_plane_state->pending.modifier = modifier;
|
2021-07-22 09:47:43 +08:00
|
|
|
mtk_plane_state->pending.addr = addr;
|
2022-11-16 14:33:35 -05:00
|
|
|
mtk_plane_state->pending.hdr_addr = hdr_addr;
|
2021-07-22 09:47:43 +08:00
|
|
|
mtk_plane_state->pending.x = new_state->dst.x1;
|
|
|
|
mtk_plane_state->pending.y = new_state->dst.y1;
|
|
|
|
mtk_plane_state->pending.width = drm_rect_width(&new_state->dst);
|
|
|
|
mtk_plane_state->pending.height = drm_rect_height(&new_state->dst);
|
|
|
|
mtk_plane_state->pending.rotation = new_state->rotation;
|
2022-06-20 17:19:25 +08:00
|
|
|
mtk_plane_state->pending.color_encoding = new_state->color_encoding;
|
2021-07-22 09:47:43 +08:00
|
|
|
}
|
|
|
|
|
2019-12-10 13:05:22 +08:00
|
|
|
static void mtk_plane_atomic_async_update(struct drm_plane *plane,
|
drm/atomic: Pass the full state to planes async atomic check 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 start convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_async_check and
atomic_async_update.
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 {
...
int (*atomic_async_check)(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_async_update)(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_async_check = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_update = 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_async_check(plane, plane_state)
+ FUNCS->atomic_async_check(plane, state)
...+>
}
@@
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_async_update(plane, plane_state)
+ FUNCS->atomic_async_update(plane, state)
...+>
}
@@
identifier mtk_plane_atomic_async_update;
identifier plane;
symbol new_state, state;
expression e;
@@
void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
{
...
- struct mtk_plane_state *state = e;
+ struct mtk_plane_state *new_plane_state = e;
<+...
- state
+ new_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 *new_plane_state)
{
<...
- state
+ new_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, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *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/...>
@@
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
...+>
}
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 13:00:21 +01:00
|
|
|
struct drm_atomic_state *state)
|
2019-12-10 13:05:22 +08:00
|
|
|
{
|
drm/atomic: Pass the full state to planes async atomic check 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 start convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_async_check and
atomic_async_update.
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 {
...
int (*atomic_async_check)(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_async_update)(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_async_check = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_async_update = 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_async_check(plane, plane_state)
+ FUNCS->atomic_async_check(plane, state)
...+>
}
@@
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_async_update(plane, plane_state)
+ FUNCS->atomic_async_update(plane, state)
...+>
}
@@
identifier mtk_plane_atomic_async_update;
identifier plane;
symbol new_state, state;
expression e;
@@
void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
{
...
- struct mtk_plane_state *state = e;
+ struct mtk_plane_state *new_plane_state = e;
<+...
- state
+ new_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 *new_plane_state)
{
<...
- state
+ new_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, plane_state;
@@
func(struct drm_plane *plane,
- struct drm_plane_state *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/...>
@@
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
...+>
}
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 13:00:21 +01:00
|
|
|
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
|
|
|
|
plane);
|
|
|
|
struct mtk_plane_state *new_plane_state = to_mtk_plane_state(plane->state);
|
2019-12-10 13:05:22 +08:00
|
|
|
|
|
|
|
plane->state->crtc_x = new_state->crtc_x;
|
|
|
|
plane->state->crtc_y = new_state->crtc_y;
|
|
|
|
plane->state->crtc_h = new_state->crtc_h;
|
|
|
|
plane->state->crtc_w = new_state->crtc_w;
|
|
|
|
plane->state->src_x = new_state->src_x;
|
|
|
|
plane->state->src_y = new_state->src_y;
|
|
|
|
plane->state->src_h = new_state->src_h;
|
|
|
|
plane->state->src_w = new_state->src_w;
|
2024-06-20 00:38:41 +08:00
|
|
|
plane->state->dst.x1 = new_state->dst.x1;
|
|
|
|
plane->state->dst.y1 = new_state->dst.y1;
|
2019-12-10 13:05:22 +08:00
|
|
|
|
2021-07-22 09:47:43 +08:00
|
|
|
mtk_plane_update_new_state(new_state, new_plane_state);
|
2023-08-09 20:57:21 +08:00
|
|
|
swap(plane->state->fb, new_state->fb);
|
2021-07-22 09:47:43 +08:00
|
|
|
wmb(); /* Make sure the above parameters are set before update */
|
|
|
|
new_plane_state->pending.async_dirty = true;
|
2024-03-22 17:12:19 +08:00
|
|
|
mtk_crtc_async_update(new_state->crtc, plane, state);
|
2019-12-10 13:05:22 +08:00
|
|
|
}
|
|
|
|
|
2016-01-04 18:36:34 +01:00
|
|
|
static const struct drm_plane_funcs mtk_plane_funcs = {
|
|
|
|
.update_plane = drm_atomic_helper_update_plane,
|
|
|
|
.disable_plane = drm_atomic_helper_disable_plane,
|
|
|
|
.destroy = drm_plane_cleanup,
|
|
|
|
.reset = mtk_plane_reset,
|
|
|
|
.atomic_duplicate_state = mtk_plane_duplicate_state,
|
2024-03-22 17:12:21 +08:00
|
|
|
.atomic_destroy_state = mtk_plane_destroy_state,
|
2022-11-16 14:33:35 -05:00
|
|
|
.format_mod_supported = mtk_plane_format_mod_supported,
|
2016-01-04 18:36:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static int mtk_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)
|
2016-01-04 18:36:34 +01: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);
|
2021-02-19 13:00:22 +01:00
|
|
|
struct drm_framebuffer *fb = new_plane_state->fb;
|
2016-01-04 18:36:34 +01:00
|
|
|
struct drm_crtc_state *crtc_state;
|
2019-11-05 16:10:20 -05:00
|
|
|
int ret;
|
2016-01-04 18:36:34 +01:00
|
|
|
|
|
|
|
if (!fb)
|
|
|
|
return 0;
|
|
|
|
|
2021-02-19 13:00:22 +01:00
|
|
|
if (WARN_ON(!new_plane_state->crtc))
|
2016-01-04 18:36:34 +01:00
|
|
|
return 0;
|
|
|
|
|
2024-03-22 17:12:19 +08:00
|
|
|
ret = mtk_crtc_plane_check(new_plane_state->crtc, plane,
|
|
|
|
to_mtk_plane_state(new_plane_state));
|
2019-11-05 16:10:20 -05:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
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_crtc_state(state,
|
2021-02-19 13:00:22 +01:00
|
|
|
new_plane_state->crtc);
|
2016-01-04 18:36:34 +01:00
|
|
|
if (IS_ERR(crtc_state))
|
|
|
|
return PTR_ERR(crtc_state);
|
|
|
|
|
2021-02-19 13:00:22 +01:00
|
|
|
return drm_atomic_helper_check_plane_state(new_plane_state,
|
|
|
|
crtc_state,
|
2022-07-20 10:30:54 +02:00
|
|
|
DRM_PLANE_NO_SCALING,
|
|
|
|
DRM_PLANE_NO_SCALING,
|
2017-11-01 22:16:19 +02:00
|
|
|
true, true);
|
2016-01-04 18:36:34 +01:00
|
|
|
}
|
|
|
|
|
2020-06-22 23:57:53 +08:00
|
|
|
static void mtk_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)
|
2020-06-22 23:57:53 +08: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);
|
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
|
|
|
struct mtk_plane_state *mtk_plane_state = to_mtk_plane_state(new_state);
|
2025-06-24 19:31:41 +08:00
|
|
|
struct drm_plane_state *old_state = drm_atomic_get_old_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 13:00:28 +01:00
|
|
|
mtk_plane_state->pending.enable = false;
|
2020-06-22 23:57:53 +08:00
|
|
|
wmb(); /* Make sure the above parameter is set before update */
|
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
|
|
|
mtk_plane_state->pending.dirty = true;
|
2025-06-24 19:31:41 +08:00
|
|
|
|
|
|
|
mtk_crtc_plane_disable(old_state->crtc, plane);
|
2020-06-22 23:57:53 +08:00
|
|
|
}
|
|
|
|
|
2016-01-04 18:36:34 +01:00
|
|
|
static void mtk_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)
|
2016-01-04 18:36:34 +01: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);
|
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
|
|
|
struct mtk_plane_state *mtk_plane_state = to_mtk_plane_state(new_state);
|
2016-01-04 18:36:34 +01:00
|
|
|
|
2021-07-22 09:47:43 +08:00
|
|
|
if (!new_state->crtc || WARN_ON(!new_state->fb))
|
2016-01-04 18:36:34 +01:00
|
|
|
return;
|
|
|
|
|
drm: Store new plane state in a variable for atomic_update and disable
In order to store the new plane state in a subsequent helper, let's move
the plane->state dereferences into a variable.
This was done using the following coccinelle script, plus some hand
changes for vmwgfx:
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
(
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_disable = func,
...,
};
|
static const struct drm_plane_helper_funcs helpers = {
...,
.atomic_update = func,
...,
};
)
@ has_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_state)
{
+ struct drm_plane_state *new_state = plane->state;
<+...
- plane->state
+ new_state
...+>
}
@ has_new_state_state @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *state)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_state @
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@
func(struct drm_plane *plane, struct drm_plane_state *state)
{
+ struct drm_plane_state *new_plane_state = plane->state;
<+...
- plane->state
+ new_plane_state
...+>
}
@ has_new_state_old_s @
identifier plane_atomic_func.func;
identifier plane;
identifier new_state;
symbol old_s;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_s)
{
...
struct drm_plane_state *new_state = plane->state;
...
}
@ depends on !has_new_state_old_s @
identifier plane_atomic_func.func;
identifier plane;
symbol old_s;
@@
func(struct drm_plane *plane, struct drm_plane_state *old_s)
{
+ struct drm_plane_state *new_s = plane->state;
<+...
- plane->state
+ new_s
...+>
}
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20210219120032.260676-1-maxime@cerno.tech
2021-02-19 13:00:27 +01:00
|
|
|
if (!new_state->visible) {
|
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
|
|
|
mtk_plane_atomic_disable(plane, state);
|
2020-06-22 23:57:53 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-22 09:47:43 +08:00
|
|
|
mtk_plane_update_new_state(new_state, mtk_plane_state);
|
2016-08-04 10:59:55 +08:00
|
|
|
wmb(); /* Make sure the above parameters are set before update */
|
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
|
|
|
mtk_plane_state->pending.dirty = true;
|
2016-01-04 18:36:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = {
|
|
|
|
.atomic_check = mtk_plane_atomic_check,
|
|
|
|
.atomic_update = mtk_plane_atomic_update,
|
|
|
|
.atomic_disable = mtk_plane_atomic_disable,
|
2019-12-10 13:05:22 +08:00
|
|
|
.atomic_async_update = mtk_plane_atomic_async_update,
|
|
|
|
.atomic_async_check = mtk_plane_atomic_async_check,
|
2016-01-04 18:36:34 +01:00
|
|
|
};
|
|
|
|
|
2016-08-04 10:59:53 +08:00
|
|
|
int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
|
2019-11-05 16:10:21 -05:00
|
|
|
unsigned long possible_crtcs, enum drm_plane_type type,
|
2024-10-09 11:46:46 +08:00
|
|
|
unsigned int supported_rotations, const u32 blend_modes,
|
2025-05-31 20:11:40 +08:00
|
|
|
const u32 *formats, size_t num_formats,
|
|
|
|
bool supports_afbc, unsigned int plane_idx)
|
2016-01-04 18:36:34 +01:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2023-03-09 16:04:14 -05:00
|
|
|
if (!formats || !num_formats) {
|
|
|
|
DRM_ERROR("no formats for plane\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2016-08-04 10:59:53 +08:00
|
|
|
err = drm_universal_plane_init(dev, plane, possible_crtcs,
|
2016-01-04 18:36:34 +01:00
|
|
|
&mtk_plane_funcs, formats,
|
2025-05-31 20:11:40 +08:00
|
|
|
num_formats,
|
|
|
|
supports_afbc ? modifiers : NULL,
|
|
|
|
type, NULL);
|
2016-01-04 18:36:34 +01:00
|
|
|
if (err) {
|
|
|
|
DRM_ERROR("failed to initialize plane\n");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2024-07-18 10:25:07 +02:00
|
|
|
/*
|
|
|
|
* The hardware does not support repositioning planes by muxing: their
|
|
|
|
* Z-position is infact fixed and the only way to change the actual
|
|
|
|
* order is to swap the contents of the entire register set of one
|
|
|
|
* overlay with another, which may be more expensive than desired.
|
|
|
|
*
|
|
|
|
* With no repositioning, the caller of this function guarantees that
|
|
|
|
* the plane_idx is correct. This means that, for example, the PRIMARY
|
|
|
|
* plane fed to this function will always have plane_idx zero.
|
|
|
|
*/
|
|
|
|
err = drm_plane_create_zpos_immutable_property(plane, plane_idx);
|
|
|
|
if (err) {
|
|
|
|
DRM_ERROR("Failed to create zpos property for plane %u\n", plane_idx);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2024-06-20 00:38:48 +08:00
|
|
|
if (supported_rotations) {
|
2019-11-05 16:10:21 -05:00
|
|
|
err = drm_plane_create_rotation_property(plane,
|
|
|
|
DRM_MODE_ROTATE_0,
|
|
|
|
supported_rotations);
|
|
|
|
if (err)
|
|
|
|
DRM_INFO("Create rotation property failed\n");
|
|
|
|
}
|
|
|
|
|
drm/mediatek: Support alpha blending in display driver
Support "Pre-multiplied" and "None" blend mode on MediaTek's chips by
adding correct blend mode property when the planes init.
Before this patch, only the "Coverage" mode (default) is supported.
For more information, there are three pixel blend modes in DRM driver:
"None", "Pre-multiplied", and "Coverage".
To understand the difference between these modes, let's take a look at
the following two approaches to do alpha blending:
1. Straight:
dst.RGB = src.RGB * src.A + dst.RGB * (1 - src.A)
This is straightforward and easy to understand, when the source layer is
compositing with the destination layer, it's alpha will affect the
result. This is also known as "post-multiplied", or "Coverage" mode.
2. Pre-multiplied:
dst.RGB = src.RGB + dst.RGB * (1 - src.A)
Since the source RGB have already multiplied its alpha, only destination
RGB need to multiply it. This is the "Pre-multiplied" mode in DRM.
For the "None" blend mode in DRM, it means the pixel alpha is ignored
when compositing the layers, only the constant alpha for the composited
layer will take effects.
Reviewed-by: CK Hu <ck.hu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hsiao Chien Sung <shawn.sung@mediatek.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20240717-alpha-blending-v4-5-4b1c806c0749@mediatek.com/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
2024-07-17 13:24:45 +08:00
|
|
|
err = drm_plane_create_alpha_property(plane);
|
|
|
|
if (err)
|
|
|
|
DRM_ERROR("failed to create property: alpha\n");
|
|
|
|
|
2024-10-09 11:46:46 +08:00
|
|
|
if (blend_modes) {
|
|
|
|
err = drm_plane_create_blend_mode_property(plane, blend_modes);
|
|
|
|
if (err)
|
|
|
|
DRM_ERROR("failed to create property: blend_mode\n");
|
|
|
|
}
|
drm/mediatek: Support alpha blending in display driver
Support "Pre-multiplied" and "None" blend mode on MediaTek's chips by
adding correct blend mode property when the planes init.
Before this patch, only the "Coverage" mode (default) is supported.
For more information, there are three pixel blend modes in DRM driver:
"None", "Pre-multiplied", and "Coverage".
To understand the difference between these modes, let's take a look at
the following two approaches to do alpha blending:
1. Straight:
dst.RGB = src.RGB * src.A + dst.RGB * (1 - src.A)
This is straightforward and easy to understand, when the source layer is
compositing with the destination layer, it's alpha will affect the
result. This is also known as "post-multiplied", or "Coverage" mode.
2. Pre-multiplied:
dst.RGB = src.RGB + dst.RGB * (1 - src.A)
Since the source RGB have already multiplied its alpha, only destination
RGB need to multiply it. This is the "Pre-multiplied" mode in DRM.
For the "None" blend mode in DRM, it means the pixel alpha is ignored
when compositing the layers, only the constant alpha for the composited
layer will take effects.
Reviewed-by: CK Hu <ck.hu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hsiao Chien Sung <shawn.sung@mediatek.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20240717-alpha-blending-v4-5-4b1c806c0749@mediatek.com/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
2024-07-17 13:24:45 +08:00
|
|
|
|
2016-08-04 10:59:53 +08:00
|
|
|
drm_plane_helper_add(plane, &mtk_plane_helper_funcs);
|
2016-01-04 18:36:34 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|