Commit | Line | Data |
---|---|---|
9bbf86fe BG |
1 | /* |
2 | * Copyright (C) STMicroelectronics SA 2014 | |
3 | * Author: Benjamin Gaignard <benjamin.gaignard@st.com> for STMicroelectronics. | |
4 | * License terms: GNU General Public License (GPL), version 2 | |
5 | */ | |
6 | ||
9e1f05b2 VA |
7 | #ifndef _STI_PLANE_H_ |
8 | #define _STI_PLANE_H_ | |
9bbf86fe BG |
9 | |
10 | #include <drm/drmP.h> | |
11 | ||
871bcdfe VA |
12 | #define to_sti_plane(x) container_of(x, struct sti_plane, drm_plane) |
13 | ||
14 | #define STI_PLANE_TYPE_SHIFT 8 | |
15 | #define STI_PLANE_TYPE_MASK (~((1 << STI_PLANE_TYPE_SHIFT) - 1)) | |
16 | ||
17 | enum sti_plane_type { | |
18 | STI_GDP = 1 << STI_PLANE_TYPE_SHIFT, | |
19 | STI_VDP = 2 << STI_PLANE_TYPE_SHIFT, | |
20 | STI_CUR = 3 << STI_PLANE_TYPE_SHIFT, | |
21 | STI_BCK = 4 << STI_PLANE_TYPE_SHIFT | |
22 | }; | |
23 | ||
24 | enum sti_plane_id_of_type { | |
25 | STI_ID_0 = 0, | |
26 | STI_ID_1 = 1, | |
27 | STI_ID_2 = 2, | |
28 | STI_ID_3 = 3 | |
29 | }; | |
30 | ||
31 | enum sti_plane_desc { | |
32 | STI_GDP_0 = STI_GDP | STI_ID_0, | |
33 | STI_GDP_1 = STI_GDP | STI_ID_1, | |
34 | STI_GDP_2 = STI_GDP | STI_ID_2, | |
35 | STI_GDP_3 = STI_GDP | STI_ID_3, | |
36 | STI_HQVDP_0 = STI_VDP | STI_ID_0, | |
37 | STI_CURSOR = STI_CUR, | |
38 | STI_BACK = STI_BCK | |
39 | }; | |
40 | ||
41 | /** | |
42 | * STI plane structure | |
43 | * | |
44 | * @plane: drm plane it is bound to (if any) | |
45 | * @fb: drm fb it is bound to | |
46 | * @mode: display mode | |
47 | * @desc: plane type & id | |
48 | * @ops: plane functions | |
49 | * @zorder: plane z-order | |
50 | * @mixer_id: id of the mixer used to display the plane | |
51 | * @enabled: to know if the plane is active or not | |
52 | * @src_x src_y: coordinates of the input (fb) area | |
53 | * @src_w src_h: size of the input (fb) area | |
54 | * @dst_x dst_y: coordinates of the output (crtc) area | |
55 | * @dst_w dst_h: size of the output (crtc) area | |
56 | * @format: format | |
57 | * @pitches: pitch of 'planes' (eg: Y, U, V) | |
58 | * @offsets: offset of 'planes' | |
59 | * @vaddr: virtual address of the input buffer | |
60 | * @paddr: physical address of the input buffer | |
61 | */ | |
62 | struct sti_plane { | |
63 | struct drm_plane drm_plane; | |
64 | struct drm_framebuffer *fb; | |
65 | struct drm_display_mode *mode; | |
66 | enum sti_plane_desc desc; | |
67 | const struct sti_plane_funcs *ops; | |
68 | int zorder; | |
69 | int mixer_id; | |
70 | bool enabled; | |
71 | int src_x, src_y; | |
72 | int src_w, src_h; | |
73 | int dst_x, dst_y; | |
74 | int dst_w, dst_h; | |
75 | uint32_t format; | |
76 | unsigned int pitches[4]; | |
77 | unsigned int offsets[4]; | |
78 | void *vaddr; | |
79 | dma_addr_t paddr; | |
80 | }; | |
81 | ||
82 | /** | |
83 | * STI plane functions structure | |
84 | * | |
85 | * @get_formats: get plane supported formats | |
86 | * @get_nb_formats: get number of format supported | |
87 | * @prepare: prepare plane before rendering | |
88 | * @commit: set plane for rendering | |
89 | * @disable: disable plane | |
90 | */ | |
91 | struct sti_plane_funcs { | |
92 | const uint32_t* (*get_formats)(struct sti_plane *plane); | |
93 | unsigned int (*get_nb_formats)(struct sti_plane *plane); | |
94 | int (*prepare)(struct sti_plane *plane, bool first_prepare); | |
95 | int (*commit)(struct sti_plane *plane); | |
96 | int (*disable)(struct sti_plane *plane); | |
97 | }; | |
9bbf86fe | 98 | |
9e1f05b2 VA |
99 | struct drm_plane *sti_plane_init(struct drm_device *dev, |
100 | struct sti_plane *sti_plane, | |
101 | unsigned int possible_crtcs, | |
102 | enum drm_plane_type type); | |
871bcdfe VA |
103 | const char *sti_plane_to_str(struct sti_plane *plane); |
104 | ||
9bbf86fe | 105 | #endif |