2 * Copyright (C) 2016 Noralf Trønnes
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
10 #ifndef __LINUX_TINYDRM_H
11 #define __LINUX_TINYDRM_H
13 #include <linux/mutex.h>
14 #include <drm/drm_simple_kms_helper.h>
19 struct drm_framebuffer;
20 struct drm_framebuffer_funcs;
23 * struct tinydrm_device - tinydrm device
25 struct tinydrm_device {
29 struct drm_device *drm;
32 * @pipe: Display pipe structure
34 struct drm_simple_display_pipe pipe;
37 * @dirty_lock: Serializes framebuffer flushing
39 struct mutex dirty_lock;
42 * @fb_funcs: Framebuffer functions used when creating framebuffers
44 const struct drm_framebuffer_funcs *fb_funcs;
47 * @fb_dirty: Framebuffer dirty callback
49 int (*fb_dirty)(struct drm_framebuffer *framebuffer,
50 struct drm_file *file_priv, unsigned flags,
51 unsigned color, struct drm_clip_rect *clips,
55 static inline struct tinydrm_device *
56 pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
58 return container_of(pipe, struct tinydrm_device, pipe);
62 * TINYDRM_MODE - tinydrm display mode
63 * @hd: Horizontal resolution, width
64 * @vd: Vertical resolution, height
65 * @hd_mm: Display width in millimeters
66 * @vd_mm: Display height in millimeters
68 * This macro creates a &drm_display_mode for use with tinydrm.
70 #define TINYDRM_MODE(hd, vd, hd_mm, vd_mm) \
72 .hsync_start = (hd), \
76 .vsync_start = (vd), \
79 .width_mm = (hd_mm), \
80 .height_mm = (vd_mm), \
81 .type = DRM_MODE_TYPE_DRIVER, \
82 .clock = 1 /* pass validation */
84 int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
85 const struct drm_framebuffer_funcs *fb_funcs,
86 struct drm_driver *driver);
87 int devm_tinydrm_register(struct tinydrm_device *tdev);
88 void tinydrm_shutdown(struct tinydrm_device *tdev);
90 void tinydrm_display_pipe_update(struct drm_simple_display_pipe *pipe,
91 struct drm_plane_state *old_state);
93 tinydrm_display_pipe_init(struct tinydrm_device *tdev,
94 const struct drm_simple_display_pipe_funcs *funcs,
96 const uint32_t *formats,
97 unsigned int format_count,
98 const struct drm_display_mode *mode,
99 unsigned int rotation);
101 #endif /* __LINUX_TINYDRM_H */