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
14 #define to_sti_layer(x) container_of(x, struct sti_layer, plane)
16 #define STI_LAYER_TYPE_SHIFT 8
17 #define STI_LAYER_TYPE_MASK (~((1<<STI_LAYER_TYPE_SHIFT)-1))
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 STI_VDP
= 5 << STI_LAYER_TYPE_SHIFT
29 enum sti_layer_id_of_type
{
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
,
43 STI_HQVDP_0
= STI_VDP
| STI_ID_0
,
49 * STI layer functions structure
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
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
);
70 * @plane: drm plane it is bound to (if any)
71 * @fb: drm fb it is bound to
72 * @crtc: crtc it is bound to
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
86 * @pitches: pitch of 'planes' (eg: Y, U, V)
87 * @offsets: offset of 'planes'
88 * @vaddr: virtual address of the input buffer
89 * @paddr: physical address of the input buffer
92 struct drm_plane plane
;
93 struct drm_framebuffer
*fb
;
94 struct drm_crtc
*crtc
;
95 struct drm_display_mode
*mode
;
96 enum sti_layer_desc desc
;
99 const struct sti_layer_funcs
*ops
;
108 unsigned int pitches
[4];
109 unsigned int offsets
[4];
114 struct sti_layer
*sti_layer_create(struct device
*dev
, int desc
,
115 void __iomem
*baseaddr
);
116 int sti_layer_prepare(struct sti_layer
*layer
,
117 struct drm_crtc
*crtc
,
118 struct drm_framebuffer
*fb
,
119 struct drm_display_mode
*mode
,
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
);