18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (C) 2017 Jernej Skrabec <jernej.skrabec@siol.net>
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public
58c2ecf20Sopenharmony_ci * License version 2.  This program is licensed "as is" without any
68c2ecf20Sopenharmony_ci * warranty of any kind, whether express or implied.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _SUN8I_UI_SCALER_H_
108c2ecf20Sopenharmony_ci#define _SUN8I_UI_SCALER_H_
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include "sun8i_mixer.h"
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define DE2_UI_SCALER_UNIT_SIZE 0x10000
158c2ecf20Sopenharmony_ci#define DE3_UI_SCALER_UNIT_SIZE 0x08000
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* this two macros assumes 16 fractional bits which is standard in DRM */
188c2ecf20Sopenharmony_ci#define SUN8I_UI_SCALER_SCALE_MIN		1
198c2ecf20Sopenharmony_ci#define SUN8I_UI_SCALER_SCALE_MAX		((1UL << 20) - 1)
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define SUN8I_UI_SCALER_SCALE_FRAC		20
228c2ecf20Sopenharmony_ci#define SUN8I_UI_SCALER_PHASE_FRAC		20
238c2ecf20Sopenharmony_ci#define SUN8I_UI_SCALER_COEFF_COUNT		16
248c2ecf20Sopenharmony_ci#define SUN8I_UI_SCALER_SIZE(w, h)		(((h) - 1) << 16 | ((w) - 1))
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define SUN8I_SCALER_GSU_CTRL(base)		((base) + 0x0)
278c2ecf20Sopenharmony_ci#define SUN8I_SCALER_GSU_OUTSIZE(base)		((base) + 0x40)
288c2ecf20Sopenharmony_ci#define SUN8I_SCALER_GSU_INSIZE(base)		((base) + 0x80)
298c2ecf20Sopenharmony_ci#define SUN8I_SCALER_GSU_HSTEP(base)		((base) + 0x88)
308c2ecf20Sopenharmony_ci#define SUN8I_SCALER_GSU_VSTEP(base)		((base) + 0x8c)
318c2ecf20Sopenharmony_ci#define SUN8I_SCALER_GSU_HPHASE(base)		((base) + 0x90)
328c2ecf20Sopenharmony_ci#define SUN8I_SCALER_GSU_VPHASE(base)		((base) + 0x98)
338c2ecf20Sopenharmony_ci#define SUN8I_SCALER_GSU_HCOEFF(base, index)	((base) + 0x200 + 0x4 * (index))
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define SUN8I_SCALER_GSU_CTRL_EN		BIT(0)
368c2ecf20Sopenharmony_ci#define SUN8I_SCALER_GSU_CTRL_COEFF_RDY		BIT(4)
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_civoid sun8i_ui_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable);
398c2ecf20Sopenharmony_civoid sun8i_ui_scaler_setup(struct sun8i_mixer *mixer, int layer,
408c2ecf20Sopenharmony_ci			   u32 src_w, u32 src_h, u32 dst_w, u32 dst_h,
418c2ecf20Sopenharmony_ci			   u32 hscale, u32 vscale, u32 hphase, u32 vphase);
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#endif
44