• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) STMicroelectronics SA 2014
3  * Authors: Benjamin Gaignard <benjamin.gaignard@st.com>
4  *          Fabien Dessenne <fabien.dessenne@st.com>
5  *          for STMicroelectronics.
6  * License terms:  GNU General Public License (GPL), version 2
7  */
8 
9 #ifndef _STI_LAYER_H_
10 #define _STI_LAYER_H_
11 
12 #include <drm/drmP.h>
13 
14 #define to_sti_layer(x) container_of(x, struct sti_layer, plane)
15 
16 #define STI_LAYER_TYPE_SHIFT 8
17 #define STI_LAYER_TYPE_MASK (~((1<<STI_LAYER_TYPE_SHIFT)-1))
18 
19 struct sti_layer;
20 
21 enum sti_layer_type {
22 	STI_GDP = 1 << STI_LAYER_TYPE_SHIFT,
23 	STI_VID = 2 << STI_LAYER_TYPE_SHIFT,
24 	STI_CUR = 3 << STI_LAYER_TYPE_SHIFT,
25 	STI_BCK = 4 << STI_LAYER_TYPE_SHIFT
26 };
27 
28 enum sti_layer_id_of_type {
29 	STI_ID_0 = 0,
30 	STI_ID_1 = 1,
31 	STI_ID_2 = 2,
32 	STI_ID_3 = 3
33 };
34 
35 enum sti_layer_desc {
36 	STI_GDP_0       = STI_GDP | STI_ID_0,
37 	STI_GDP_1       = STI_GDP | STI_ID_1,
38 	STI_GDP_2       = STI_GDP | STI_ID_2,
39 	STI_GDP_3       = STI_GDP | STI_ID_3,
40 	STI_VID_0       = STI_VID | STI_ID_0,
41 	STI_VID_1       = STI_VID | STI_ID_1,
42 	STI_CURSOR      = STI_CUR,
43 	STI_BACK        = STI_BCK
44 };
45 
46 /**
47  * STI layer functions structure
48  *
49  * @get_formats:	get layer supported formats
50  * @get_nb_formats:	get number of format supported
51  * @init:               initialize the layer
52  * @prepare:		prepare layer before rendering
53  * @commit:		set layer for rendering
54  * @disable:		disable layer
55  */
56 struct sti_layer_funcs {
57 	const uint32_t* (*get_formats)(struct sti_layer *layer);
58 	unsigned int (*get_nb_formats)(struct sti_layer *layer);
59 	void (*init)(struct sti_layer *layer);
60 	int (*prepare)(struct sti_layer *layer, bool first_prepare);
61 	int (*commit)(struct sti_layer *layer);
62 	int (*disable)(struct sti_layer *layer);
63 };
64 
65 /**
66  * STI layer structure
67  *
68  * @plane:              drm plane it is bound to (if any)
69  * @fb:                 drm fb it is bound to
70  * @mode:               display mode
71  * @desc:               layer type & id
72  * @device:		driver device
73  * @regs:		layer registers
74  * @ops:                layer functions
75  * @zorder:             layer z-order
76  * @mixer_id:           id of the mixer used to display the layer
77  * @enabled:            to know if the layer is active or not
78  * @src_x src_y:        coordinates of the input (fb) area
79  * @src_w src_h:        size of the input (fb) area
80  * @dst_x dst_y:        coordinates of the output (crtc) area
81  * @dst_w dst_h:        size of the output (crtc) area
82  * @format:             format
83  * @pitches:            pitch of 'planes' (eg: Y, U, V)
84  * @offsets:            offset of 'planes'
85  * @paddr:              physical address of the input buffer
86  */
87 struct sti_layer {
88 	struct drm_plane plane;
89 	struct drm_framebuffer *fb;
90 	struct drm_display_mode *mode;
91 	enum sti_layer_desc desc;
92 	struct device *dev;
93 	void __iomem *regs;
94 	const struct sti_layer_funcs *ops;
95 	int zorder;
96 	int mixer_id;
97 	bool enabled;
98 	int src_x, src_y;
99 	int src_w, src_h;
100 	int dst_x, dst_y;
101 	int dst_w, dst_h;
102 	uint32_t format;
103 	unsigned int pitches[4];
104 	unsigned int offsets[4];
105 	dma_addr_t paddr;
106 };
107 
108 struct sti_layer *sti_layer_create(struct device *dev, int desc,
109 			void __iomem *baseaddr);
110 int sti_layer_prepare(struct sti_layer *layer, struct drm_framebuffer *fb,
111 			struct drm_display_mode *mode,
112 			int mixer_id,
113 			int dest_x, int dest_y,
114 			int dest_w, int dest_h,
115 			int src_x, int src_y,
116 			int src_w, int src_h);
117 int sti_layer_commit(struct sti_layer *layer);
118 int sti_layer_disable(struct sti_layer *layer);
119 const uint32_t *sti_layer_get_formats(struct sti_layer *layer);
120 unsigned int sti_layer_get_nb_formats(struct sti_layer *layer);
121 const char *sti_layer_to_str(struct sti_layer *layer);
122 
123 #endif
124