// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright ( C ) 2016 BayLibre , SAS
* Author : Neil Armstrong < narmstrong @ baylibre . com >
* Copyright ( C ) 2015 Amlogic , Inc . All rights reserved .
* Copyright ( C ) 2014 Endless Mobile
*/
#include <linux/export.h>
#include "meson_drv.h"
#include "meson_registers.h"
#include "meson_vpp.h"
/**
* DOC : Video Post Processing
*
* VPP Handles all the Post Processing after the Scanout from the VIU
* We handle the following post processings :
*
* - Postblend , Blends the OSD1 only
* We exclude OSD2 , VS1 , VS1 and Preblend output
* - Vertical OSD Scaler for OSD1 only , we disable vertical scaler and
* use it only for interlace scanout
* - Intermediate FIFO with default Amlogic values
*
* What is missing :
*
* - Preblend for video overlay pre - scaling
* - OSD2 support for cursor framebuffer
* - Video pre - scaling before postblend
* - Full Vertical / Horizontal OSD scaling to support TV overscan
* - HDR conversion
*/
void meson_vpp_setup_mux(struct meson_drm *priv, unsigned int mux)
{
writel(mux, priv->io_base + _REG(VPU_VIU_VENC_MUX_CTRL));
}
static unsigned int vpp_filter_coefs_4point_bspline[] = {
0 x15561500, 0 x14561600, 0 x13561700, 0 x12561800,
0 x11551a00, 0 x11541b00, 0 x10541c00, 0 x0f541d00,
0 x0f531e00, 0 x0e531f00, 0 x0d522100, 0 x0c522200,
0 x0b522300, 0 x0b512400, 0 x0a502600, 0 x0a4f2700,
0 x094e2900, 0 x084e2a00, 0 x084d2b00, 0 x074c2c01,
0 x074b2d01, 0 x064a2f01, 0 x06493001, 0 x05483201,
0 x05473301, 0 x05463401, 0 x04453601, 0 x04433702,
0 x04423802, 0 x03413a02, 0 x03403b02, 0 x033f3c02,
0 x033d3d03
};
static void meson_vpp_write_scaling_filter_coefs(struct meson_drm *priv,
const unsigned int *coefs,
bool is_horizontal)
{
int i;
writel_relaxed(is_horizontal ? VPP_SCALE_HORIZONTAL_COEF : 0 ,
priv->io_base + _REG(VPP_OSD_SCALE_COEF_IDX));
for (i = 0 ; i < 33 ; i++)
writel_relaxed(coefs[i],
priv->io_base + _REG(VPP_OSD_SCALE_COEF));
}
static const uint32_t vpp_filter_coefs_bicubic[] = {
0 x00800000, 0 x007f0100, 0 xff7f0200, 0 xfe7f0300,
0 xfd7e0500, 0 xfc7e0600, 0 xfb7d0800, 0 xfb7c0900,
0 xfa7b0b00, 0 xfa7a0dff, 0 xf9790fff, 0 xf97711ff,
0 xf87613ff, 0 xf87416fe, 0 xf87218fe, 0 xf8701afe,
0 xf76f1dfd, 0 xf76d1ffd, 0 xf76b21fd, 0 xf76824fd,
0 xf76627fc, 0 xf76429fc, 0 xf7612cfc, 0 xf75f2ffb,
0 xf75d31fb, 0 xf75a34fb, 0 xf75837fa, 0 xf7553afa,
0 xf8523cfa, 0 xf8503ff9, 0 xf84d42f9, 0 xf84a45f9,
0 xf84848f8
};
static void meson_vpp_write_vd_scaling_filter_coefs(struct meson_drm *priv,
const unsigned int *coefs,
bool is_horizontal)
{
int i;
writel_relaxed(is_horizontal ? VPP_SCALE_HORIZONTAL_COEF : 0 ,
priv->io_base + _REG(VPP_SCALE_COEF_IDX));
for (i = 0 ; i < 33 ; i++)
writel_relaxed(coefs[i],
priv->io_base + _REG(VPP_SCALE_COEF));
}
void meson_vpp_init(struct meson_drm *priv)
{
/* set dummy data default YUV black */
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXL))
writel_relaxed(0 x108080, priv->io_base + _REG(VPP_DUMMY_DATA1));
else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM)) {
writel_bits_relaxed(0 xff << 16 , 0 xff << 16 ,
priv->io_base + _REG(VIU_MISC_CTRL1));
writel_relaxed(VPP_PPS_DUMMY_DATA_MODE,
priv->io_base + _REG(VPP_DOLBY_CTRL));
writel_relaxed(0 x1020080,
priv->io_base + _REG(VPP_DUMMY_DATA1));
writel_relaxed(0 x42020,
priv->io_base + _REG(VPP_DUMMY_DATA));
} else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
writel_relaxed(0 xf, priv->io_base + _REG(DOLBY_PATH_CTRL));
/* Initialize vpu fifo control registers */
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
writel_relaxed(VPP_OFIFO_SIZE_DEFAULT,
priv->io_base + _REG(VPP_OFIFO_SIZE));
else
writel_bits_relaxed(VPP_OFIFO_SIZE_MASK, 0 x77f,
priv->io_base + _REG(VPP_OFIFO_SIZE));
writel_relaxed(VPP_POSTBLEND_HOLD_LINES(4 ) | VPP_PREBLEND_HOLD_LINES(4 ),
priv->io_base + _REG(VPP_HOLD_LINES));
if (!meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
/* Turn off preblend */
writel_bits_relaxed(VPP_PREBLEND_ENABLE, 0 ,
priv->io_base + _REG(VPP_MISC));
/* Turn off POSTBLEND */
writel_bits_relaxed(VPP_POSTBLEND_ENABLE, 0 ,
priv->io_base + _REG(VPP_MISC));
/* Force all planes off */
writel_bits_relaxed(VPP_OSD1_POSTBLEND | VPP_OSD2_POSTBLEND |
VPP_VD1_POSTBLEND | VPP_VD2_POSTBLEND |
VPP_VD1_PREBLEND | VPP_VD2_PREBLEND, 0 ,
priv->io_base + _REG(VPP_MISC));
/* Setup default VD settings */
writel_relaxed(4096 ,
priv->io_base + _REG(VPP_PREBLEND_VD1_H_START_END));
writel_relaxed(4096 ,
priv->io_base + _REG(VPP_BLEND_VD2_H_START_END));
}
/* Disable Scalers */
writel_relaxed(0 , priv->io_base + _REG(VPP_OSD_SC_CTRL0));
writel_relaxed(0 , priv->io_base + _REG(VPP_OSD_VSC_CTRL0));
writel_relaxed(0 , priv->io_base + _REG(VPP_OSD_HSC_CTRL0));
/* Set horizontal/vertical bank length and enable video scale out */
writel_relaxed(VPP_VSC_BANK_LENGTH(4 ) | VPP_HSC_BANK_LENGTH(4 ) |
VPP_SC_VD_EN_ENABLE,
priv->io_base + _REG(VPP_SC_MISC));
/* Enable minus black level for vadj1 */
writel_relaxed(VPP_MINUS_BLACK_LVL_VADJ1_ENABLE,
priv->io_base + _REG(VPP_VADJ_CTRL));
/* Write in the proper filter coefficients. */
meson_vpp_write_scaling_filter_coefs(priv,
vpp_filter_coefs_4point_bspline, false );
meson_vpp_write_scaling_filter_coefs(priv,
vpp_filter_coefs_4point_bspline, true );
/* Write the VD proper filter coefficients. */
meson_vpp_write_vd_scaling_filter_coefs(priv, vpp_filter_coefs_bicubic,
false );
meson_vpp_write_vd_scaling_filter_coefs(priv, vpp_filter_coefs_bicubic,
true );
}
Messung V0.5 in Prozent C=92 H=91 G=91
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-10-01)
¤
*© Formatika GbR, Deutschland