]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/gpu/drm/arm/display/komeda/komeda_kms.h
Merge tag 'gcc-plugins-v5.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / gpu / drm / arm / display / komeda / komeda_kms.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * (C) COPYRIGHT 2018 ARM Limited. All rights reserved.
4  * Author: James.Qian.Wang <james.qian.wang@arm.com>
5  *
6  */
7 #ifndef _KOMEDA_KMS_H_
8 #define _KOMEDA_KMS_H_
9
10 #include <drm/drm_atomic.h>
11 #include <drm/drm_atomic_helper.h>
12 #include <drm/drm_crtc_helper.h>
13 #include <drm/drm_device.h>
14 #include <drm/drm_writeback.h>
15 #include <video/videomode.h>
16 #include <video/display_timing.h>
17
18 /**
19  * struct komeda_plane - komeda instance of drm_plane
20  */
21 struct komeda_plane {
22         /** @base: &drm_plane */
23         struct drm_plane base;
24         /**
25          * @layer:
26          *
27          * represents available layer input pipelines for this plane.
28          *
29          * NOTE:
30          * the layer is not for a specific Layer, but indicate a group of
31          * Layers with same capabilities.
32          */
33         struct komeda_layer *layer;
34 };
35
36 /**
37  * struct komeda_plane_state
38  *
39  * The plane_state can be split into two data flow (left/right) and handled
40  * by two layers &komeda_plane.layer and &komeda_plane.layer.right
41  */
42 struct komeda_plane_state {
43         /** @base: &drm_plane_state */
44         struct drm_plane_state base;
45
46         /* private properties */
47 };
48
49 /**
50  * struct komeda_wb_connector
51  */
52 struct komeda_wb_connector {
53         /** @base: &drm_writeback_connector */
54         struct drm_writeback_connector base;
55
56         /** @wb_layer: represents associated writeback pipeline of komeda */
57         struct komeda_layer *wb_layer;
58 };
59
60 /**
61  * struct komeda_crtc
62  */
63 struct komeda_crtc {
64         /** @base: &drm_crtc */
65         struct drm_crtc base;
66         /** @master: only master has display output */
67         struct komeda_pipeline *master;
68         /**
69          * @slave: optional
70          *
71          * Doesn't have its own display output, the handled data flow will
72          * merge into the master.
73          */
74         struct komeda_pipeline *slave;
75
76         /** @disable_done: this flip_done is for tracing the disable */
77         struct completion *disable_done;
78 };
79
80 /**
81  * struct komeda_crtc_state
82  */
83 struct komeda_crtc_state {
84         /** @base: &drm_crtc_state */
85         struct drm_crtc_state base;
86
87         /* private properties */
88
89         /* computed state which are used by validate/check */
90         /**
91          * @affected_pipes:
92          * the affected pipelines in once display instance
93          */
94         u32 affected_pipes;
95         /**
96          * @active_pipes:
97          * the active pipelines in once display instance
98          */
99         u32 active_pipes;
100 };
101
102 /** struct komeda_kms_dev - for gather KMS related things */
103 struct komeda_kms_dev {
104         /** @base: &drm_device */
105         struct drm_device base;
106
107         /** @n_crtcs: valid numbers of crtcs in &komeda_kms_dev.crtcs */
108         int n_crtcs;
109         /** @crtcs: crtcs list */
110         struct komeda_crtc crtcs[KOMEDA_MAX_PIPELINES];
111 };
112
113 #define to_kplane(p)    container_of(p, struct komeda_plane, base)
114 #define to_kplane_st(p) container_of(p, struct komeda_plane_state, base)
115 #define to_kconn(p)     container_of(p, struct komeda_wb_connector, base)
116 #define to_kcrtc(p)     container_of(p, struct komeda_crtc, base)
117 #define to_kcrtc_st(p)  container_of(p, struct komeda_crtc_state, base)
118 #define to_kdev(p)      container_of(p, struct komeda_kms_dev, base)
119
120 int komeda_kms_setup_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
121
122 int komeda_kms_add_crtcs(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
123 int komeda_kms_add_planes(struct komeda_kms_dev *kms, struct komeda_dev *mdev);
124 int komeda_kms_add_private_objs(struct komeda_kms_dev *kms,
125                                 struct komeda_dev *mdev);
126 void komeda_kms_cleanup_private_objs(struct komeda_kms_dev *kms);
127
128 void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
129                               struct komeda_events *evts);
130
131 struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev);
132 void komeda_kms_detach(struct komeda_kms_dev *kms);
133
134 #endif /*_KOMEDA_KMS_H_*/