Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2017 Jernej Skrabec <jernej.skrabec@siol.net>
0003  *
0004  * This file is licensed under the terms of the GNU General Public
0005  * License version 2.  This program is licensed "as is" without any
0006  * warranty of any kind, whether express or implied.
0007  */
0008 
0009 #ifndef _SUN8I_VI_SCALER_H_
0010 #define _SUN8I_VI_SCALER_H_
0011 
0012 #include <drm/drm_fourcc.h>
0013 #include "sun8i_mixer.h"
0014 
0015 #define DE2_VI_SCALER_UNIT_BASE 0x20000
0016 #define DE2_VI_SCALER_UNIT_SIZE 0x20000
0017 
0018 #define DE3_VI_SCALER_UNIT_BASE 0x20000
0019 #define DE3_VI_SCALER_UNIT_SIZE 0x08000
0020 
0021 /* this two macros assumes 16 fractional bits which is standard in DRM */
0022 #define SUN8I_VI_SCALER_SCALE_MIN       1
0023 #define SUN8I_VI_SCALER_SCALE_MAX       ((1UL << 20) - 1)
0024 
0025 #define SUN8I_VI_SCALER_SCALE_FRAC      20
0026 #define SUN8I_VI_SCALER_PHASE_FRAC      20
0027 #define SUN8I_VI_SCALER_COEFF_COUNT     32
0028 #define SUN8I_VI_SCALER_SIZE(w, h)      (((h) - 1) << 16 | ((w) - 1))
0029 
0030 #define SUN8I_SCALER_VSU_CTRL(base)     ((base) + 0x0)
0031 #define SUN50I_SCALER_VSU_SCALE_MODE(base)      ((base) + 0x10)
0032 #define SUN50I_SCALER_VSU_DIR_THR(base)     ((base) + 0x20)
0033 #define SUN50I_SCALER_VSU_EDGE_THR(base)        ((base) + 0x24)
0034 #define SUN50I_SCALER_VSU_EDSCL_CTRL(base)      ((base) + 0x28)
0035 #define SUN50I_SCALER_VSU_ANGLE_THR(base)       ((base) + 0x2c)
0036 #define SUN8I_SCALER_VSU_OUTSIZE(base)      ((base) + 0x40)
0037 #define SUN8I_SCALER_VSU_YINSIZE(base)      ((base) + 0x80)
0038 #define SUN8I_SCALER_VSU_YHSTEP(base)       ((base) + 0x88)
0039 #define SUN8I_SCALER_VSU_YVSTEP(base)       ((base) + 0x8c)
0040 #define SUN8I_SCALER_VSU_YHPHASE(base)      ((base) + 0x90)
0041 #define SUN8I_SCALER_VSU_YVPHASE(base)      ((base) + 0x98)
0042 #define SUN8I_SCALER_VSU_CINSIZE(base)      ((base) + 0xc0)
0043 #define SUN8I_SCALER_VSU_CHSTEP(base)       ((base) + 0xc8)
0044 #define SUN8I_SCALER_VSU_CVSTEP(base)       ((base) + 0xcc)
0045 #define SUN8I_SCALER_VSU_CHPHASE(base)      ((base) + 0xd0)
0046 #define SUN8I_SCALER_VSU_CVPHASE(base)      ((base) + 0xd8)
0047 #define SUN8I_SCALER_VSU_YHCOEFF0(base, i)  ((base) + 0x200 + 0x4 * (i))
0048 #define SUN8I_SCALER_VSU_YHCOEFF1(base, i)  ((base) + 0x300 + 0x4 * (i))
0049 #define SUN8I_SCALER_VSU_YVCOEFF(base, i)   ((base) + 0x400 + 0x4 * (i))
0050 #define SUN8I_SCALER_VSU_CHCOEFF0(base, i)  ((base) + 0x600 + 0x4 * (i))
0051 #define SUN8I_SCALER_VSU_CHCOEFF1(base, i)  ((base) + 0x700 + 0x4 * (i))
0052 #define SUN8I_SCALER_VSU_CVCOEFF(base, i)   ((base) + 0x800 + 0x4 * (i))
0053 
0054 #define SUN8I_SCALER_VSU_CTRL_EN        BIT(0)
0055 #define SUN8I_SCALER_VSU_CTRL_COEFF_RDY     BIT(4)
0056 
0057 #define SUN50I_SCALER_VSU_SUB_ZERO_DIR_THR(x)   (((x) << 24) & 0xFF)
0058 #define SUN50I_SCALER_VSU_ZERO_DIR_THR(x)       (((x) << 16) & 0xFF)
0059 #define SUN50I_SCALER_VSU_HORZ_DIR_THR(x)       (((x) << 8) & 0xFF)
0060 #define SUN50I_SCALER_VSU_VERT_DIR_THR(x)       ((x) & 0xFF)
0061 
0062 #define SUN50I_SCALER_VSU_SCALE_MODE_UI     0
0063 #define SUN50I_SCALER_VSU_SCALE_MODE_NORMAL 1
0064 #define SUN50I_SCALER_VSU_SCALE_MODE_ED_SCALE   2
0065 
0066 #define SUN50I_SCALER_VSU_EDGE_SHIFT(x)     (((x) << 16) & 0xF)
0067 #define SUN50I_SCALER_VSU_EDGE_OFFSET(x)        ((x) & 0xFF)
0068 
0069 #define SUN50I_SCALER_VSU_ANGLE_SHIFT(x)        (((x) << 16) & 0xF)
0070 #define SUN50I_SCALER_VSU_ANGLE_OFFSET(x)       ((x) & 0xFF)
0071 
0072 void sun8i_vi_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable);
0073 void sun8i_vi_scaler_setup(struct sun8i_mixer *mixer, int layer,
0074                u32 src_w, u32 src_h, u32 dst_w, u32 dst_h,
0075                u32 hscale, u32 vscale, u32 hphase, u32 vphase,
0076                const struct drm_format_info *format);
0077 
0078 #endif