xref: /linux/drivers/gpu/drm/logicvc/logicvc_layer.h (revision 8a922b7728a93d837954315c98b84f6b78de0c4f)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2019-2022 Bootlin
4  * Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
5  */
6 
7 #ifndef _LOGICVC_LAYER_H_
8 #define _LOGICVC_LAYER_H_
9 
10 #include <linux/of.h>
11 #include <linux/types.h>
12 #include <drm/drm_plane.h>
13 
14 #define LOGICVC_LAYER_COLORSPACE_RGB		0
15 #define LOGICVC_LAYER_COLORSPACE_YUV		1
16 
17 #define LOGICVC_LAYER_ALPHA_LAYER		0
18 #define LOGICVC_LAYER_ALPHA_PIXEL		1
19 
20 struct logicvc_layer_buffer_setup {
21 	u8 buffer_sel;
22 	u16 voffset;
23 	u16 hoffset;
24 };
25 
26 struct logicvc_layer_config {
27 	u32 colorspace;
28 	u32 depth;
29 	u32 alpha_mode;
30 	u32 base_offset;
31 	u32 buffer_offset;
32 	bool primary;
33 };
34 
35 struct logicvc_layer_formats {
36 	u32 colorspace;
37 	u32 depth;
38 	bool alpha;
39 	uint32_t *formats;
40 };
41 
42 struct logicvc_layer {
43 	struct logicvc_layer_config config;
44 	struct logicvc_layer_formats *formats;
45 	struct device_node *of_node;
46 
47 	struct drm_plane drm_plane;
48 	struct list_head list;
49 	u32 index;
50 };
51 
52 int logicvc_layer_buffer_find_setup(struct logicvc_drm *logicvc,
53 				    struct logicvc_layer *layer,
54 				    struct drm_plane_state *state,
55 				    struct logicvc_layer_buffer_setup *setup);
56 struct logicvc_layer *logicvc_layer_get_from_index(struct logicvc_drm *logicvc,
57 						   u32 index);
58 struct logicvc_layer *logicvc_layer_get_from_type(struct logicvc_drm *logicvc,
59 						  enum drm_plane_type type);
60 struct logicvc_layer *logicvc_layer_get_primary(struct logicvc_drm *logicvc);
61 void logicvc_layers_attach_crtc(struct logicvc_drm *logicvc);
62 int logicvc_layers_init(struct logicvc_drm *logicvc);
63 
64 #endif
65