Skip to content

Commit af74138

Browse files
committed
drm/tinydrm: Use damage helper for dirtyfb
This switches to drm_atomic_helper_dirtyfb() as the framebuffer dirty handler. All flushing will now happen in the pipe functions. Also enable the damage plane property for all except repaper which can only do full updates. ili9225: This change made ili9225_init() equal to mipi_dbi_init() so use it. v3: Include vblank header (Sam) ili9225 and st7586 can't use mipi_dbi_enable_flush() (David) v2: Remove fb check in mipi_dbi_enable_flush() it can't be NULL (kbuild test robot) Cc: David Lechner <david@lechnology.com> Cc: Eric Anholt <eric@anholt.net> Signed-off-by: Noralf Trønnes <noralf@tronnes.org> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Tested-by: David Lechner <david@lechnology.com> Reviewed-by: David Lechner <david@lechnology.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190115043643.2364-5-noralf@tronnes.org
1 parent b051b34 commit af74138

14 files changed

Lines changed: 165 additions & 319 deletions

File tree

‎drivers/gpu/drm/tinydrm/core/tinydrm-core.c‎

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,17 @@
3939
* and registers the DRM device using devm_tinydrm_register().
4040
*/
4141

42-
static struct drm_framebuffer *
43-
tinydrm_fb_create(struct drm_device *drm, struct drm_file *file_priv,
44-
const struct drm_mode_fb_cmd2 *mode_cmd)
45-
{
46-
struct tinydrm_device *tdev = drm->dev_private;
47-
48-
return drm_gem_fb_create_with_funcs(drm, file_priv, mode_cmd,
49-
tdev->fb_funcs);
50-
}
51-
5242
static const struct drm_mode_config_funcs tinydrm_mode_config_funcs = {
53-
.fb_create = tinydrm_fb_create,
43+
.fb_create = drm_gem_fb_create_with_dirty,
5444
.atomic_check = drm_atomic_helper_check,
5545
.atomic_commit = drm_atomic_helper_commit,
5646
};
5747

5848
static int tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
59-
const struct drm_framebuffer_funcs *fb_funcs,
6049
struct drm_driver *driver)
6150
{
6251
struct drm_device *drm;
6352

64-
mutex_init(&tdev->dirty_lock);
65-
tdev->fb_funcs = fb_funcs;
66-
6753
/*
6854
* We don't embed drm_device, because that prevent us from using
6955
* devm_kzalloc() to allocate tinydrm_device in the driver since
@@ -86,7 +72,6 @@ static int tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
8672
static void tinydrm_fini(struct tinydrm_device *tdev)
8773
{
8874
drm_mode_config_cleanup(tdev->drm);
89-
mutex_destroy(&tdev->dirty_lock);
9075
tdev->drm->dev_private = NULL;
9176
drm_dev_put(tdev->drm);
9277
}
@@ -100,7 +85,6 @@ static void devm_tinydrm_release(void *data)
10085
* devm_tinydrm_init - Initialize tinydrm device
10186
* @parent: Parent device object
10287
* @tdev: tinydrm device
103-
* @fb_funcs: Framebuffer functions
10488
* @driver: DRM driver
10589
*
10690
* This function initializes @tdev, the underlying DRM device and it's
@@ -111,12 +95,11 @@ static void devm_tinydrm_release(void *data)
11195
* Zero on success, negative error code on failure.
11296
*/
11397
int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
114-
const struct drm_framebuffer_funcs *fb_funcs,
11598
struct drm_driver *driver)
11699
{
117100
int ret;
118101

119-
ret = tinydrm_init(parent, tdev, fb_funcs, driver);
102+
ret = tinydrm_init(parent, tdev, driver);
120103
if (ret)
121104
return ret;
122105

‎drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c‎

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -17,104 +17,15 @@
1717
#include <drm/drm_device.h>
1818
#include <drm/drm_drv.h>
1919
#include <drm/drm_fourcc.h>
20+
#include <drm/drm_framebuffer.h>
2021
#include <drm/drm_print.h>
2122
#include <drm/drm_rect.h>
22-
#include <drm/tinydrm/tinydrm.h>
2323
#include <drm/tinydrm/tinydrm-helpers.h>
24-
#include <uapi/drm/drm.h>
2524

2625
static unsigned int spi_max;
2726
module_param(spi_max, uint, 0400);
2827
MODULE_PARM_DESC(spi_max, "Set a lower SPI max transfer size");
2928

30-
/**
31-
* tinydrm_merge_clips - Merge clip rectangles
32-
* @dst: Destination clip rectangle
33-
* @src: Source clip rectangle(s)
34-
* @num_clips: Number of @src clip rectangles
35-
* @flags: Dirty fb ioctl flags
36-
* @max_width: Maximum width of @dst
37-
* @max_height: Maximum height of @dst
38-
*
39-
* This function merges @src clip rectangle(s) into @dst. If @src is NULL,
40-
* @max_width and @min_width is used to set a full @dst clip rectangle.
41-
*
42-
* Returns:
43-
* true if it's a full clip, false otherwise
44-
*/
45-
bool tinydrm_merge_clips(struct drm_rect *dst,
46-
struct drm_clip_rect *src, unsigned int num_clips,
47-
unsigned int flags, u32 max_width, u32 max_height)
48-
{
49-
unsigned int i;
50-
51-
if (!src || !num_clips) {
52-
dst->x1 = 0;
53-
dst->x2 = max_width;
54-
dst->y1 = 0;
55-
dst->y2 = max_height;
56-
return true;
57-
}
58-
59-
dst->x1 = ~0;
60-
dst->y1 = ~0;
61-
dst->x2 = 0;
62-
dst->y2 = 0;
63-
64-
for (i = 0; i < num_clips; i++) {
65-
if (flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY)
66-
i++;
67-
dst->x1 = min_t(int, dst->x1, src[i].x1);
68-
dst->x2 = max_t(int, dst->x2, src[i].x2);
69-
dst->y1 = min_t(int, dst->y1, src[i].y1);
70-
dst->y2 = max_t(int, dst->y2, src[i].y2);
71-
}
72-
73-
if (dst->x2 > max_width || dst->y2 > max_height ||
74-
dst->x1 >= dst->x2 || dst->y1 >= dst->y2) {
75-
DRM_DEBUG_KMS("Illegal clip: x1=%u, x2=%u, y1=%u, y2=%u\n",
76-
dst->x1, dst->x2, dst->y1, dst->y2);
77-
dst->x1 = 0;
78-
dst->y1 = 0;
79-
dst->x2 = max_width;
80-
dst->y2 = max_height;
81-
}
82-
83-
return (dst->x2 - dst->x1) == max_width &&
84-
(dst->y2 - dst->y1) == max_height;
85-
}
86-
EXPORT_SYMBOL(tinydrm_merge_clips);
87-
88-
int tinydrm_fb_dirty(struct drm_framebuffer *fb,
89-
struct drm_file *file_priv,
90-
unsigned int flags, unsigned int color,
91-
struct drm_clip_rect *clips,
92-
unsigned int num_clips)
93-
{
94-
struct tinydrm_device *tdev = fb->dev->dev_private;
95-
struct drm_plane *plane = &tdev->pipe.plane;
96-
int ret = 0;
97-
98-
drm_modeset_lock(&plane->mutex, NULL);
99-
100-
/* fbdev can flush even when we're not interested */
101-
if (plane->state->fb == fb) {
102-
mutex_lock(&tdev->dirty_lock);
103-
ret = tdev->fb_dirty(fb, file_priv, flags,
104-
color, clips, num_clips);
105-
mutex_unlock(&tdev->dirty_lock);
106-
}
107-
108-
drm_modeset_unlock(&plane->mutex);
109-
110-
if (ret)
111-
dev_err_once(fb->dev->dev,
112-
"Failed to update display %d\n", ret);
113-
114-
return ret;
115-
}
116-
EXPORT_SYMBOL(tinydrm_fb_dirty);
117-
11829
/**
11930
* tinydrm_memcpy - Copy clip buffer
12031
* @dst: Destination buffer

‎drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c‎

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <drm/drm_gem_framebuffer_helper.h>
1414
#include <drm/drm_modes.h>
1515
#include <drm/drm_print.h>
16-
#include <drm/drm_vblank.h>
1716
#include <drm/tinydrm/tinydrm.h>
1817

1918
struct tinydrm_connector {
@@ -111,36 +110,6 @@ tinydrm_connector_create(struct drm_device *drm,
111110
return connector;
112111
}
113112

114-
/**
115-
* tinydrm_display_pipe_update - Display pipe update helper
116-
* @pipe: Simple display pipe
117-
* @old_state: Old plane state
118-
*
119-
* This function does a full framebuffer flush if the plane framebuffer
120-
* has changed. It also handles vblank events. Drivers can use this as their
121-
* &drm_simple_display_pipe_funcs->update callback.
122-
*/
123-
void tinydrm_display_pipe_update(struct drm_simple_display_pipe *pipe,
124-
struct drm_plane_state *old_state)
125-
{
126-
struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
127-
struct drm_framebuffer *fb = pipe->plane.state->fb;
128-
struct drm_crtc *crtc = &tdev->pipe.crtc;
129-
130-
if (fb && (fb != old_state->fb)) {
131-
if (tdev->fb_dirty)
132-
tdev->fb_dirty(fb, NULL, 0, 0, NULL, 0);
133-
}
134-
135-
if (crtc->state->event) {
136-
spin_lock_irq(&crtc->dev->event_lock);
137-
drm_crtc_send_vblank_event(crtc, crtc->state->event);
138-
spin_unlock_irq(&crtc->dev->event_lock);
139-
crtc->state->event = NULL;
140-
}
141-
}
142-
EXPORT_SYMBOL(tinydrm_display_pipe_update);
143-
144113
static int tinydrm_rotate_mode(struct drm_display_mode *mode,
145114
unsigned int rotation)
146115
{

‎drivers/gpu/drm/tinydrm/hx8357d.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe,
176176
static const struct drm_simple_display_pipe_funcs hx8357d_pipe_funcs = {
177177
.enable = yx240qv29_enable,
178178
.disable = mipi_dbi_pipe_disable,
179-
.update = tinydrm_display_pipe_update,
179+
.update = mipi_dbi_pipe_update,
180180
.prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
181181
};
182182

0 commit comments

Comments
 (0)