Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Copyright (C) 2016 Noralf Trønnes
3 *
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.
8 */
9
10#ifndef __LINUX_TINYDRM_H
11#define __LINUX_TINYDRM_H
12
13#include <linux/mutex.h>
14#include <drm/drm_simple_kms_helper.h>
15
16struct drm_clip_rect;
17struct drm_driver;
18struct drm_file;
19struct drm_framebuffer;
20struct drm_framebuffer_funcs;
21
22/**
23 * struct tinydrm_device - tinydrm device
24 */
25struct tinydrm_device {
26 /**
27 * @drm: DRM device
28 */
29 struct drm_device *drm;
30
31 /**
32 * @pipe: Display pipe structure
33 */
34 struct drm_simple_display_pipe pipe;
35
36 /**
37 * @dirty_lock: Serializes framebuffer flushing
38 */
39 struct mutex dirty_lock;
40
41 /**
42 * @fb_funcs: Framebuffer functions used when creating framebuffers
43 */
44 const struct drm_framebuffer_funcs *fb_funcs;
45
46 /**
47 * @fb_dirty: Framebuffer dirty callback
48 */
49 int (*fb_dirty)(struct drm_framebuffer *framebuffer,
50 struct drm_file *file_priv, unsigned flags,
51 unsigned color, struct drm_clip_rect *clips,
52 unsigned num_clips);
53};
54
55static inline struct tinydrm_device *
56pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
57{
58 return container_of(pipe, struct tinydrm_device, pipe);
59}
60
61/**
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
67 *
68 * This macro creates a &drm_display_mode for use with tinydrm.
69 */
70#define TINYDRM_MODE(hd, vd, hd_mm, vd_mm) \
71 .hdisplay = (hd), \
72 .hsync_start = (hd), \
73 .hsync_end = (hd), \
74 .htotal = (hd), \
75 .vdisplay = (vd), \
76 .vsync_start = (vd), \
77 .vsync_end = (vd), \
78 .vtotal = (vd), \
79 .width_mm = (hd_mm), \
80 .height_mm = (vd_mm), \
81 .type = DRM_MODE_TYPE_DRIVER, \
82 .clock = 1 /* pass validation */
83
84int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
85 const struct drm_framebuffer_funcs *fb_funcs,
86 struct drm_driver *driver);
87int devm_tinydrm_register(struct tinydrm_device *tdev);
88void tinydrm_shutdown(struct tinydrm_device *tdev);
89
90void tinydrm_display_pipe_update(struct drm_simple_display_pipe *pipe,
91 struct drm_plane_state *old_state);
92int
93tinydrm_display_pipe_init(struct tinydrm_device *tdev,
94 const struct drm_simple_display_pipe_funcs *funcs,
95 int connector_type,
96 const uint32_t *formats,
97 unsigned int format_count,
98 const struct drm_display_mode *mode,
99 unsigned int rotation);
100
101#endif /* __LINUX_TINYDRM_H */