drm/sun4i: Rework DE2 register defines
[linux-block.git] / drivers / gpu / drm / sun4i / sun8i_vi_scaler.h
1 /*
2  * Copyright (C) 2017 Jernej Skrabec <jernej.skrabec@siol.net>
3  *
4  * This file is licensed under the terms of the GNU General Public
5  * License version 2.  This program is licensed "as is" without any
6  * warranty of any kind, whether express or implied.
7  */
8
9 #ifndef _SUN8I_VI_SCALER_H_
10 #define _SUN8I_VI_SCALER_H_
11
12 #include <drm/drm_fourcc.h>
13 #include "sun8i_mixer.h"
14
15 #define DE2_VI_SCALER_UNIT_BASE 0x20000
16 #define DE2_VI_SCALER_UNIT_SIZE 0x20000
17
18 /* this two macros assumes 16 fractional bits which is standard in DRM */
19 #define SUN8I_VI_SCALER_SCALE_MIN               1
20 #define SUN8I_VI_SCALER_SCALE_MAX               ((1UL << 20) - 1)
21
22 #define SUN8I_VI_SCALER_SCALE_FRAC              20
23 #define SUN8I_VI_SCALER_PHASE_FRAC              20
24 #define SUN8I_VI_SCALER_COEFF_COUNT             32
25 #define SUN8I_VI_SCALER_SIZE(w, h)              (((h) - 1) << 16 | ((w) - 1))
26
27 #define SUN8I_SCALER_VSU_CTRL(base)             ((base) + 0x0)
28 #define SUN8I_SCALER_VSU_OUTSIZE(base)          ((base) + 0x40)
29 #define SUN8I_SCALER_VSU_YINSIZE(base)          ((base) + 0x80)
30 #define SUN8I_SCALER_VSU_YHSTEP(base)           ((base) + 0x88)
31 #define SUN8I_SCALER_VSU_YVSTEP(base)           ((base) + 0x8c)
32 #define SUN8I_SCALER_VSU_YHPHASE(base)          ((base) + 0x90)
33 #define SUN8I_SCALER_VSU_YVPHASE(base)          ((base) + 0x98)
34 #define SUN8I_SCALER_VSU_CINSIZE(base)          ((base) + 0xc0)
35 #define SUN8I_SCALER_VSU_CHSTEP(base)           ((base) + 0xc8)
36 #define SUN8I_SCALER_VSU_CVSTEP(base)           ((base) + 0xcc)
37 #define SUN8I_SCALER_VSU_CHPHASE(base)          ((base) + 0xd0)
38 #define SUN8I_SCALER_VSU_CVPHASE(base)          ((base) + 0xd8)
39 #define SUN8I_SCALER_VSU_YHCOEFF0(base, i)      ((base) + 0x200 + 0x4 * (i))
40 #define SUN8I_SCALER_VSU_YHCOEFF1(base, i)      ((base) + 0x300 + 0x4 * (i))
41 #define SUN8I_SCALER_VSU_YVCOEFF(base, i)       ((base) + 0x400 + 0x4 * (i))
42 #define SUN8I_SCALER_VSU_CHCOEFF0(base, i)      ((base) + 0x600 + 0x4 * (i))
43 #define SUN8I_SCALER_VSU_CHCOEFF1(base, i)      ((base) + 0x700 + 0x4 * (i))
44 #define SUN8I_SCALER_VSU_CVCOEFF(base, i)       ((base) + 0x800 + 0x4 * (i))
45
46 #define SUN8I_SCALER_VSU_CTRL_EN                BIT(0)
47 #define SUN8I_SCALER_VSU_CTRL_COEFF_RDY         BIT(4)
48
49 void sun8i_vi_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable);
50 void sun8i_vi_scaler_setup(struct sun8i_mixer *mixer, int layer,
51                            u32 src_w, u32 src_h, u32 dst_w, u32 dst_h,
52                            u32 hscale, u32 vscale, u32 hphase, u32 vphase,
53                            const struct drm_format_info *format);
54
55 #endif