1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) Icenowy Zheng <icenowy@aosc.io>
4  *
5  * Based on sun4i_layer.h, which is:
6  *   Copyright (C) 2015 Free Electrons
7  *   Copyright (C) 2015 NextThing Co
8  *
9  *   Maxime Ripard <maxime.ripard@free-electrons.com>
10  */
11 
12 #ifndef _SUN8I_UI_LAYER_H_
13 #define _SUN8I_UI_LAYER_H_
14 
15 #include <drm/drm_plane.h>
16 
17 #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR(base, layer) \
18 			((base) + 0x20 * (layer) + 0x0)
19 #define SUN8I_MIXER_CHAN_UI_LAYER_SIZE(base, layer) \
20 			((base) + 0x20 * (layer) + 0x4)
21 #define SUN8I_MIXER_CHAN_UI_LAYER_COORD(base, layer) \
22 			((base) + 0x20 * (layer) + 0x8)
23 #define SUN8I_MIXER_CHAN_UI_LAYER_PITCH(base, layer) \
24 			((base) + 0x20 * (layer) + 0xc)
25 #define SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR(base, layer) \
26 			((base) + 0x20 * (layer) + 0x10)
27 #define SUN8I_MIXER_CHAN_UI_LAYER_BOT_LADDR(base, layer) \
28 			((base) + 0x20 * (layer) + 0x14)
29 #define SUN8I_MIXER_CHAN_UI_LAYER_FCOLOR(base, layer) \
30 			((base) + 0x20 * (layer) + 0x18)
31 #define SUN8I_MIXER_CHAN_UI_TOP_HADDR(base) \
32 			((base) + 0x80)
33 #define SUN8I_MIXER_CHAN_UI_BOT_HADDR(base) \
34 			((base) + 0x84)
35 #define SUN8I_MIXER_CHAN_UI_OVL_SIZE(base) \
36 			((base) + 0x88)
37 
38 #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN		BIT(0)
39 #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_MASK	GENMASK(2, 1)
40 #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_FBFMT_MASK	GENMASK(12, 8)
41 #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_FBFMT_OFFSET	8
42 #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MASK	GENMASK(31, 24)
43 #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA(x)		((x) << 24)
44 
45 #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_PIXEL		((0) << 1)
46 #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_LAYER		((1) << 1)
47 #define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_COMBINED	((2) << 1)
48 
49 struct sun8i_mixer;
50 struct sun8i_layer;
51 
52 struct sun8i_layer *sun8i_ui_layer_init_one(struct drm_device *drm,
53 					    struct sun8i_mixer *mixer,
54 					    int index);
55 #endif /* _SUN8I_UI_LAYER_H_ */
56