Commit | Line | Data |
---|---|---|
ba2d53fb BG |
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, | |
4fdbc678 BG |
25 | STI_BCK = 4 << STI_LAYER_TYPE_SHIFT, |
26 | STI_VDP = 5 << STI_LAYER_TYPE_SHIFT | |
ba2d53fb BG |
27 | }; |
28 | ||
29 | enum sti_layer_id_of_type { | |
30 | STI_ID_0 = 0, | |
31 | STI_ID_1 = 1, | |
32 | STI_ID_2 = 2, | |
33 | STI_ID_3 = 3 | |
34 | }; | |
35 | ||
36 | enum sti_layer_desc { | |
37 | STI_GDP_0 = STI_GDP | STI_ID_0, | |
38 | STI_GDP_1 = STI_GDP | STI_ID_1, | |
39 | STI_GDP_2 = STI_GDP | STI_ID_2, | |
40 | STI_GDP_3 = STI_GDP | STI_ID_3, | |
41 | STI_VID_0 = STI_VID | STI_ID_0, | |
42 | STI_VID_1 = STI_VID | STI_ID_1, | |
4fdbc678 | 43 | STI_HQVDP_0 = STI_VDP | STI_ID_0, |
ba2d53fb BG |
44 | STI_CURSOR = STI_CUR, |
45 | STI_BACK = STI_BCK | |
46 | }; | |
47 | ||
48 | /** | |
49 | * STI layer functions structure | |
50 | * | |
51 | * @get_formats: get layer supported formats | |
52 | * @get_nb_formats: get number of format supported | |
53 | * @init: initialize the layer | |
54 | * @prepare: prepare layer before rendering | |
55 | * @commit: set layer for rendering | |
56 | * @disable: disable layer | |
57 | */ | |
58 | struct sti_layer_funcs { | |
59 | const uint32_t* (*get_formats)(struct sti_layer *layer); | |
60 | unsigned int (*get_nb_formats)(struct sti_layer *layer); | |
61 | void (*init)(struct sti_layer *layer); | |
62 | int (*prepare)(struct sti_layer *layer, bool first_prepare); | |
63 | int (*commit)(struct sti_layer *layer); | |
64 | int (*disable)(struct sti_layer *layer); | |
65 | }; | |
66 | ||
67 | /** | |
68 | * STI layer structure | |
69 | * | |
70 | * @plane: drm plane it is bound to (if any) | |
71 | * @fb: drm fb it is bound to | |
4fdbc678 | 72 | * @crtc: crtc it is bound to |
ba2d53fb BG |
73 | * @mode: display mode |
74 | * @desc: layer type & id | |
75 | * @device: driver device | |
76 | * @regs: layer registers | |
77 | * @ops: layer functions | |
78 | * @zorder: layer z-order | |
79 | * @mixer_id: id of the mixer used to display the layer | |
80 | * @enabled: to know if the layer is active or not | |
81 | * @src_x src_y: coordinates of the input (fb) area | |
82 | * @src_w src_h: size of the input (fb) area | |
83 | * @dst_x dst_y: coordinates of the output (crtc) area | |
84 | * @dst_w dst_h: size of the output (crtc) area | |
85 | * @format: format | |
86 | * @pitches: pitch of 'planes' (eg: Y, U, V) | |
87 | * @offsets: offset of 'planes' | |
96006a77 | 88 | * @vaddr: virtual address of the input buffer |
ba2d53fb BG |
89 | * @paddr: physical address of the input buffer |
90 | */ | |
91 | struct sti_layer { | |
92 | struct drm_plane plane; | |
93 | struct drm_framebuffer *fb; | |
4fdbc678 | 94 | struct drm_crtc *crtc; |
ba2d53fb BG |
95 | struct drm_display_mode *mode; |
96 | enum sti_layer_desc desc; | |
97 | struct device *dev; | |
98 | void __iomem *regs; | |
99 | const struct sti_layer_funcs *ops; | |
100 | int zorder; | |
101 | int mixer_id; | |
102 | bool enabled; | |
103 | int src_x, src_y; | |
104 | int src_w, src_h; | |
105 | int dst_x, dst_y; | |
106 | int dst_w, dst_h; | |
107 | uint32_t format; | |
108 | unsigned int pitches[4]; | |
109 | unsigned int offsets[4]; | |
96006a77 | 110 | void *vaddr; |
ba2d53fb BG |
111 | dma_addr_t paddr; |
112 | }; | |
113 | ||
114 | struct sti_layer *sti_layer_create(struct device *dev, int desc, | |
115 | void __iomem *baseaddr); | |
4fdbc678 BG |
116 | int sti_layer_prepare(struct sti_layer *layer, |
117 | struct drm_crtc *crtc, | |
118 | struct drm_framebuffer *fb, | |
ba2d53fb BG |
119 | struct drm_display_mode *mode, |
120 | int mixer_id, | |
121 | int dest_x, int dest_y, | |
122 | int dest_w, int dest_h, | |
123 | int src_x, int src_y, | |
124 | int src_w, int src_h); | |
125 | int sti_layer_commit(struct sti_layer *layer); | |
126 | int sti_layer_disable(struct sti_layer *layer); | |
127 | const uint32_t *sti_layer_get_formats(struct sti_layer *layer); | |
128 | unsigned int sti_layer_get_nb_formats(struct sti_layer *layer); | |
129 | const char *sti_layer_to_str(struct sti_layer *layer); | |
130 | ||
131 | #endif |