Linux 4.14.5
[linux/fpc-iii.git] / include / drm / tinydrm / tinydrm.h
blob4774fe3d427393ef7e1809b1512d7b8c3ada6870
1 /*
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.
8 */
10 #ifndef __LINUX_TINYDRM_H
11 #define __LINUX_TINYDRM_H
13 #include <drm/drm_gem_cma_helper.h>
14 #include <drm/drm_fb_cma_helper.h>
15 #include <drm/drm_simple_kms_helper.h>
17 /**
18 * struct tinydrm_device - tinydrm device
19 * @drm: DRM device
20 * @pipe: Display pipe structure
21 * @dirty_lock: Serializes framebuffer flushing
22 * @fbdev_cma: CMA fbdev structure
23 * @suspend_state: Atomic state when suspended
24 * @fb_funcs: Framebuffer functions used when creating framebuffers
26 struct tinydrm_device {
27 struct drm_device *drm;
28 struct drm_simple_display_pipe pipe;
29 struct mutex dirty_lock;
30 struct drm_fbdev_cma *fbdev_cma;
31 struct drm_atomic_state *suspend_state;
32 const struct drm_framebuffer_funcs *fb_funcs;
35 static inline struct tinydrm_device *
36 pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
38 return container_of(pipe, struct tinydrm_device, pipe);
41 /**
42 * TINYDRM_GEM_DRIVER_OPS - default tinydrm gem operations
44 * This macro provides a shortcut for setting the tinydrm GEM operations in
45 * the &drm_driver structure.
47 #define TINYDRM_GEM_DRIVER_OPS \
48 .gem_free_object = tinydrm_gem_cma_free_object, \
49 .gem_vm_ops = &drm_gem_cma_vm_ops, \
50 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \
51 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \
52 .gem_prime_import = drm_gem_prime_import, \
53 .gem_prime_export = drm_gem_prime_export, \
54 .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, \
55 .gem_prime_import_sg_table = tinydrm_gem_cma_prime_import_sg_table, \
56 .gem_prime_vmap = drm_gem_cma_prime_vmap, \
57 .gem_prime_vunmap = drm_gem_cma_prime_vunmap, \
58 .gem_prime_mmap = drm_gem_cma_prime_mmap, \
59 .dumb_create = drm_gem_cma_dumb_create
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
68 * This macro creates a &drm_display_mode for use with tinydrm.
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 */
84 void tinydrm_lastclose(struct drm_device *drm);
85 void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj);
86 struct drm_gem_object *
87 tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,
88 struct dma_buf_attachment *attach,
89 struct sg_table *sgt);
90 int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
91 const struct drm_framebuffer_funcs *fb_funcs,
92 struct drm_driver *driver);
93 int devm_tinydrm_register(struct tinydrm_device *tdev);
94 void tinydrm_shutdown(struct tinydrm_device *tdev);
95 int tinydrm_suspend(struct tinydrm_device *tdev);
96 int tinydrm_resume(struct tinydrm_device *tdev);
98 void tinydrm_display_pipe_update(struct drm_simple_display_pipe *pipe,
99 struct drm_plane_state *old_state);
100 int tinydrm_display_pipe_prepare_fb(struct drm_simple_display_pipe *pipe,
101 struct drm_plane_state *plane_state);
103 tinydrm_display_pipe_init(struct tinydrm_device *tdev,
104 const struct drm_simple_display_pipe_funcs *funcs,
105 int connector_type,
106 const uint32_t *formats,
107 unsigned int format_count,
108 const struct drm_display_mode *mode,
109 unsigned int rotation);
111 #endif /* __LINUX_TINYDRM_H */