]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/drm/tinydrm/tinydrm.h
Merge branch 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[mirror_ubuntu-artful-kernel.git] / include / drm / tinydrm / tinydrm.h
CommitLineData
fa201ac2
NT
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 <drm/drm_gem_cma_helper.h>
14#include <drm/drm_fb_cma_helper.h>
15#include <drm/drm_simple_kms_helper.h>
16
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
25 */
26struct 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;
33};
34
35static inline struct tinydrm_device *
36pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
37{
38 return container_of(pipe, struct tinydrm_device, pipe);
39}
40
41/**
42 * TINYDRM_GEM_DRIVER_OPS - default tinydrm gem operations
43 *
44 * This macro provides a shortcut for setting the tinydrm GEM operations in
45 * the &drm_driver structure.
46 */
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, \
60 .dumb_map_offset = drm_gem_cma_dumb_map_offset, \
79b85d2b 61 .dumb_destroy = drm_gem_dumb_destroy
fa201ac2
NT
62
63/**
64 * TINYDRM_MODE - tinydrm display mode
65 * @hd: Horizontal resolution, width
66 * @vd: Vertical resolution, height
67 * @hd_mm: Display width in millimeters
68 * @vd_mm: Display height in millimeters
69 *
70 * This macro creates a &drm_display_mode for use with tinydrm.
71 */
72#define TINYDRM_MODE(hd, vd, hd_mm, vd_mm) \
73 .hdisplay = (hd), \
74 .hsync_start = (hd), \
75 .hsync_end = (hd), \
76 .htotal = (hd), \
77 .vdisplay = (vd), \
78 .vsync_start = (vd), \
79 .vsync_end = (vd), \
80 .vtotal = (vd), \
81 .width_mm = (hd_mm), \
82 .height_mm = (vd_mm), \
83 .type = DRM_MODE_TYPE_DRIVER, \
84 .clock = 1 /* pass validation */
85
fa201ac2
NT
86void tinydrm_lastclose(struct drm_device *drm);
87void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj);
88struct drm_gem_object *
89tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,
90 struct dma_buf_attachment *attach,
91 struct sg_table *sgt);
92int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
93 const struct drm_framebuffer_funcs *fb_funcs,
94 struct drm_driver *driver);
95int devm_tinydrm_register(struct tinydrm_device *tdev);
96void tinydrm_shutdown(struct tinydrm_device *tdev);
97int tinydrm_suspend(struct tinydrm_device *tdev);
98int tinydrm_resume(struct tinydrm_device *tdev);
99
100void tinydrm_display_pipe_update(struct drm_simple_display_pipe *pipe,
101 struct drm_plane_state *old_state);
102int tinydrm_display_pipe_prepare_fb(struct drm_simple_display_pipe *pipe,
103 struct drm_plane_state *plane_state);
104int
105tinydrm_display_pipe_init(struct tinydrm_device *tdev,
106 const struct drm_simple_display_pipe_funcs *funcs,
107 int connector_type,
108 const uint32_t *formats,
109 unsigned int format_count,
110 const struct drm_display_mode *mode,
111 unsigned int rotation);
112
113#endif /* __LINUX_TINYDRM_H */