GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
# Copyright (C) 2018 BayLibre, SAS
|
||||
#
|
||||
# Author: Neil Armstrong <narmstrong@baylibre.com>
|
||||
|
||||
config VIDEO_MESON
|
||||
bool "Enable Amlogic Meson video support"
|
||||
depends on DM_VIDEO
|
||||
select DISPLAY
|
||||
help
|
||||
Enable Amlogic Meson Video Processing Unit video support.
|
||||
@@ -0,0 +1,9 @@
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
# Copyright (C) 2018 BayLibre, SAS
|
||||
#
|
||||
# Author: Neil Armstrong <narmstrong@baylibre.com>
|
||||
|
||||
obj-$(CONFIG_VIDEO_MESON) = meson_vpu.o meson_vpu_init.o meson_canvas.o
|
||||
obj-$(CONFIG_VIDEO_MESON) += meson_plane.o meson_venc.o meson_vclk.o
|
||||
obj-$(CONFIG_VIDEO_MESON) += meson_dw_hdmi.o simplefb_common.o ../dw_hdmi.o
|
||||
@@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Amlogic Meson Video Processing Unit driver
|
||||
*
|
||||
* Copyright (c) 2018 BayLibre, SAS.
|
||||
* Author: Neil Armstrong <narmstrong@baylibre.com>
|
||||
*/
|
||||
|
||||
#include "meson_vpu.h"
|
||||
|
||||
/* DMC Registers */
|
||||
#define DMC_CAV_LUT_DATAL 0x48 /* 0x12 offset in data sheet */
|
||||
#define CANVAS_WIDTH_LBIT 29
|
||||
#define CANVAS_WIDTH_LWID 3
|
||||
#define DMC_CAV_LUT_DATAH 0x4c /* 0x13 offset in data sheet */
|
||||
#define CANVAS_WIDTH_HBIT 0
|
||||
#define CANVAS_HEIGHT_BIT 9
|
||||
#define CANVAS_BLKMODE_BIT 24
|
||||
#define DMC_CAV_LUT_ADDR 0x50 /* 0x14 offset in data sheet */
|
||||
#define CANVAS_LUT_WR_EN (0x2 << 8)
|
||||
#define CANVAS_LUT_RD_EN (0x1 << 8)
|
||||
|
||||
void meson_canvas_setup(struct meson_vpu_priv *priv,
|
||||
u32 canvas_index, u32 addr,
|
||||
u32 stride, u32 height,
|
||||
unsigned int wrap,
|
||||
unsigned int blkmode)
|
||||
{
|
||||
dmc_write(DMC_CAV_LUT_DATAL,
|
||||
(((addr + 7) >> 3)) |
|
||||
(((stride + 7) >> 3) << CANVAS_WIDTH_LBIT));
|
||||
|
||||
dmc_write(DMC_CAV_LUT_DATAH,
|
||||
((((stride + 7) >> 3) >> CANVAS_WIDTH_LWID) <<
|
||||
CANVAS_WIDTH_HBIT) |
|
||||
(height << CANVAS_HEIGHT_BIT) |
|
||||
(wrap << 22) |
|
||||
(blkmode << CANVAS_BLKMODE_BIT));
|
||||
|
||||
dmc_write(DMC_CAV_LUT_ADDR,
|
||||
CANVAS_LUT_WR_EN | canvas_index);
|
||||
|
||||
/* Force a read-back to make sure everything is flushed. */
|
||||
dmc_read(DMC_CAV_LUT_DATAH);
|
||||
}
|
||||
@@ -0,0 +1,508 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (C) 2018 BayLibre, SAS
|
||||
* Author: Jorge Ramirez-Ortiz <jramirez@baylibre.com>
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <display.h>
|
||||
#include <dm.h>
|
||||
#include <edid.h>
|
||||
#include <asm/io.h>
|
||||
#include <dw_hdmi.h>
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
#include <power/regulator.h>
|
||||
#include <clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <reset.h>
|
||||
#include <media_bus_format.h>
|
||||
#include "meson_dw_hdmi.h"
|
||||
#include "meson_vpu.h"
|
||||
|
||||
/* TOP Block Communication Channel */
|
||||
#define HDMITX_TOP_ADDR_REG 0x0
|
||||
#define HDMITX_TOP_DATA_REG 0x4
|
||||
#define HDMITX_TOP_CTRL_REG 0x8
|
||||
#define HDMITX_TOP_G12A_OFFSET 0x8000
|
||||
|
||||
/* Controller Communication Channel */
|
||||
#define HDMITX_DWC_ADDR_REG 0x10
|
||||
#define HDMITX_DWC_DATA_REG 0x14
|
||||
#define HDMITX_DWC_CTRL_REG 0x18
|
||||
|
||||
/* HHI Registers */
|
||||
#define HHI_MEM_PD_REG0 0x100 /* 0x40 */
|
||||
#define HHI_HDMI_CLK_CNTL 0x1cc /* 0x73 */
|
||||
#define HHI_HDMI_PHY_CNTL0 0x3a0 /* 0xe8 */
|
||||
#define HHI_HDMI_PHY_CNTL1 0x3a4 /* 0xe9 */
|
||||
#define HHI_HDMI_PHY_CNTL2 0x3a8 /* 0xea */
|
||||
#define HHI_HDMI_PHY_CNTL3 0x3ac /* 0xeb */
|
||||
#define HHI_HDMI_PHY_CNTL4 0x3b0 /* 0xec */
|
||||
#define HHI_HDMI_PHY_CNTL5 0x3b4 /* 0xed */
|
||||
|
||||
struct meson_dw_hdmi {
|
||||
struct udevice *dev;
|
||||
struct dw_hdmi hdmi;
|
||||
void __iomem *hhi_base;
|
||||
};
|
||||
|
||||
enum hdmi_compatible {
|
||||
HDMI_COMPATIBLE_GXBB = 0,
|
||||
HDMI_COMPATIBLE_GXL = 1,
|
||||
HDMI_COMPATIBLE_GXM = 2,
|
||||
HDMI_COMPATIBLE_G12A = 3,
|
||||
};
|
||||
|
||||
static inline bool meson_hdmi_is_compatible(struct meson_dw_hdmi *priv,
|
||||
enum hdmi_compatible family)
|
||||
{
|
||||
enum hdmi_compatible compat = dev_get_driver_data(priv->dev);
|
||||
|
||||
return compat == family;
|
||||
}
|
||||
|
||||
static unsigned int dw_hdmi_top_read(struct dw_hdmi *hdmi, unsigned int addr)
|
||||
{
|
||||
struct meson_dw_hdmi *priv = container_of(hdmi, struct meson_dw_hdmi,
|
||||
hdmi);
|
||||
unsigned int data;
|
||||
|
||||
if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
|
||||
return readl(hdmi->ioaddr +
|
||||
HDMITX_TOP_G12A_OFFSET + (addr << 2));
|
||||
|
||||
/* ADDR must be written twice */
|
||||
writel(addr & 0xffff, hdmi->ioaddr + HDMITX_TOP_ADDR_REG);
|
||||
writel(addr & 0xffff, hdmi->ioaddr + HDMITX_TOP_ADDR_REG);
|
||||
|
||||
/* Read needs a second DATA read */
|
||||
data = readl(hdmi->ioaddr + HDMITX_TOP_DATA_REG);
|
||||
data = readl(hdmi->ioaddr + HDMITX_TOP_DATA_REG);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static inline void dw_hdmi_top_write(struct dw_hdmi *hdmi,
|
||||
unsigned int addr, unsigned int data)
|
||||
{
|
||||
struct meson_dw_hdmi *priv = container_of(hdmi, struct meson_dw_hdmi,
|
||||
hdmi);
|
||||
|
||||
if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A)) {
|
||||
writel(data, hdmi->ioaddr +
|
||||
HDMITX_TOP_G12A_OFFSET + (addr << 2));
|
||||
return;
|
||||
}
|
||||
|
||||
/* ADDR must be written twice */
|
||||
writel(addr & 0xffff, hdmi->ioaddr + HDMITX_TOP_ADDR_REG);
|
||||
writel(addr & 0xffff, hdmi->ioaddr + HDMITX_TOP_ADDR_REG);
|
||||
|
||||
/* Write needs single DATA write */
|
||||
writel(data, hdmi->ioaddr + HDMITX_TOP_DATA_REG);
|
||||
}
|
||||
|
||||
static inline void dw_hdmi_top_write_bits(struct dw_hdmi *hdmi,
|
||||
unsigned int addr,
|
||||
unsigned int mask,
|
||||
unsigned int val)
|
||||
{
|
||||
unsigned int data = dw_hdmi_top_read(hdmi, addr);
|
||||
|
||||
data &= ~mask;
|
||||
data |= val;
|
||||
dw_hdmi_top_write(hdmi, addr, data);
|
||||
}
|
||||
|
||||
static u8 dw_hdmi_dwc_read(struct dw_hdmi *hdmi, int addr)
|
||||
{
|
||||
unsigned int data;
|
||||
|
||||
/* ADDR must be written twice */
|
||||
writel(addr & 0xffff, hdmi->ioaddr + HDMITX_DWC_ADDR_REG);
|
||||
writel(addr & 0xffff, hdmi->ioaddr + HDMITX_DWC_ADDR_REG);
|
||||
|
||||
/* Read needs a second DATA read */
|
||||
data = readl(hdmi->ioaddr + HDMITX_DWC_DATA_REG);
|
||||
data = readl(hdmi->ioaddr + HDMITX_DWC_DATA_REG);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static inline void dw_hdmi_dwc_write(struct dw_hdmi *hdmi, u8 data, int addr)
|
||||
{
|
||||
/* ADDR must be written twice */
|
||||
writel(addr & 0xffff, hdmi->ioaddr + HDMITX_DWC_ADDR_REG);
|
||||
writel(addr & 0xffff, hdmi->ioaddr + HDMITX_DWC_ADDR_REG);
|
||||
|
||||
/* Write needs single DATA write */
|
||||
writel(data, hdmi->ioaddr + HDMITX_DWC_DATA_REG);
|
||||
}
|
||||
|
||||
static inline void dw_hdmi_dwc_write_bits(struct dw_hdmi *hdmi,
|
||||
unsigned int addr,
|
||||
unsigned int mask,
|
||||
unsigned int val)
|
||||
{
|
||||
u8 data = dw_hdmi_dwc_read(hdmi, addr);
|
||||
|
||||
data &= ~mask;
|
||||
data |= val;
|
||||
|
||||
dw_hdmi_dwc_write(hdmi, data, addr);
|
||||
}
|
||||
|
||||
static inline void dw_hdmi_hhi_write(struct meson_dw_hdmi *priv,
|
||||
unsigned int addr, unsigned int data)
|
||||
{
|
||||
hhi_write(addr, data);
|
||||
}
|
||||
|
||||
__attribute__((unused))
|
||||
static unsigned int dw_hdmi_hhi_read(struct meson_dw_hdmi *priv,
|
||||
unsigned int addr)
|
||||
{
|
||||
return hhi_read(addr);
|
||||
}
|
||||
|
||||
static inline void dw_hdmi_hhi_update_bits(struct meson_dw_hdmi *priv,
|
||||
unsigned int addr,
|
||||
unsigned int mask,
|
||||
unsigned int val)
|
||||
{
|
||||
hhi_update_bits(addr, mask, val);
|
||||
}
|
||||
|
||||
static int meson_dw_hdmi_read_edid(struct udevice *dev, u8 *buf, int buf_size)
|
||||
{
|
||||
#if defined DEBUG
|
||||
struct display_timing timing;
|
||||
int panel_bits_per_colour;
|
||||
#endif
|
||||
struct meson_dw_hdmi *priv = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
ret = dw_hdmi_read_edid(&priv->hdmi, buf, buf_size);
|
||||
|
||||
#if defined DEBUG
|
||||
if (!ret)
|
||||
return ret;
|
||||
|
||||
edid_print_info((struct edid1_info *)buf);
|
||||
edid_get_timing(buf, ret, &timing, &panel_bits_per_colour);
|
||||
debug("Display timing:\n");
|
||||
debug(" hactive %04d, hfrontp %04d, hbackp %04d hsync %04d\n"
|
||||
" vactive %04d, vfrontp %04d, vbackp %04d vsync %04d\n",
|
||||
timing.hactive.typ, timing.hfront_porch.typ,
|
||||
timing.hback_porch.typ, timing.hsync_len.typ,
|
||||
timing.vactive.typ, timing.vfront_porch.typ,
|
||||
timing.vback_porch.typ, timing.vsync_len.typ);
|
||||
debug(" flags: ");
|
||||
if (timing.flags & DISPLAY_FLAGS_INTERLACED)
|
||||
debug("interlaced ");
|
||||
if (timing.flags & DISPLAY_FLAGS_DOUBLESCAN)
|
||||
debug("doublescan ");
|
||||
if (timing.flags & DISPLAY_FLAGS_DOUBLECLK)
|
||||
debug("doubleclk ");
|
||||
if (timing.flags & DISPLAY_FLAGS_HSYNC_LOW)
|
||||
debug("hsync_low ");
|
||||
if (timing.flags & DISPLAY_FLAGS_HSYNC_HIGH)
|
||||
debug("hsync_high ");
|
||||
if (timing.flags & DISPLAY_FLAGS_VSYNC_LOW)
|
||||
debug("vsync_low ");
|
||||
if (timing.flags & DISPLAY_FLAGS_VSYNC_HIGH)
|
||||
debug("vsync_high ");
|
||||
debug("\n");
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void meson_dw_hdmi_phy_reset(struct meson_dw_hdmi *priv)
|
||||
{
|
||||
/* Enable and software reset */
|
||||
dw_hdmi_hhi_update_bits(priv, HHI_HDMI_PHY_CNTL1, 0xf, 0xf);
|
||||
|
||||
mdelay(2);
|
||||
|
||||
/* Enable and unreset */
|
||||
dw_hdmi_hhi_update_bits(priv, HHI_HDMI_PHY_CNTL1, 0xf, 0xe);
|
||||
|
||||
mdelay(2);
|
||||
}
|
||||
|
||||
static void meson_dw_hdmi_phy_setup_mode(struct meson_dw_hdmi *priv,
|
||||
uint pixel_clock)
|
||||
{
|
||||
pixel_clock = pixel_clock / 1000;
|
||||
|
||||
if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_GXL) ||
|
||||
meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_GXM)) {
|
||||
if (pixel_clock >= 371250) {
|
||||
/* 5.94Gbps, 3.7125Gbps */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0x333d3282);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL3, 0x2136315b);
|
||||
} else if (pixel_clock >= 297000) {
|
||||
/* 2.97Gbps */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0x33303382);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL3, 0x2036315b);
|
||||
} else if (pixel_clock >= 148500) {
|
||||
/* 1.485Gbps */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0x33303362);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL3, 0x2016315b);
|
||||
} else {
|
||||
/* 742.5Mbps, and below */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0x33604142);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL3, 0x0016315b);
|
||||
}
|
||||
} else if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_GXBB)) {
|
||||
if (pixel_clock >= 371250) {
|
||||
/* 5.94Gbps, 3.7125Gbps */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0x33353245);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL3, 0x2100115b);
|
||||
} else if (pixel_clock >= 297000) {
|
||||
/* 2.97Gbps */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0x33634283);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL3, 0xb000115b);
|
||||
} else {
|
||||
/* 1.485Gbps, and below */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0x33632122);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL3, 0x2000115b);
|
||||
}
|
||||
} else if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A)) {
|
||||
if (pixel_clock >= 371250) {
|
||||
/* 5.94Gbps, 3.7125Gbps */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0x37eb65c4);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL3, 0x2ab0ff3b);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL5, 0x0000080b);
|
||||
} else if (pixel_clock >= 297000) {
|
||||
/* 2.97Gbps */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0x33eb6262);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL3, 0x2ab0ff3b);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL5, 0x00000003);
|
||||
} else {
|
||||
/* 1.485Gbps, and below */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0x33eb4242);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL3, 0x2ab0ff3b);
|
||||
hhi_write(HHI_HDMI_PHY_CNTL5, 0x00000003);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int meson_dw_hdmi_phy_init(struct dw_hdmi *hdmi, uint pixel_clock)
|
||||
{
|
||||
struct meson_dw_hdmi *priv = container_of(hdmi, struct meson_dw_hdmi,
|
||||
hdmi);
|
||||
/* Enable clocks */
|
||||
dw_hdmi_hhi_update_bits(priv, HHI_HDMI_CLK_CNTL, 0xffff, 0x100);
|
||||
|
||||
/* Bring HDMITX MEM output of power down */
|
||||
dw_hdmi_hhi_update_bits(priv, HHI_MEM_PD_REG0, 0xff << 8, 0);
|
||||
|
||||
/* Bring out of reset */
|
||||
dw_hdmi_top_write(hdmi, HDMITX_TOP_SW_RESET, 0);
|
||||
|
||||
/* Enable internal pixclk, tmds_clk, spdif_clk, i2s_clk, cecclk */
|
||||
dw_hdmi_top_write_bits(hdmi, HDMITX_TOP_CLK_CNTL, 0x3, 0x3);
|
||||
dw_hdmi_top_write_bits(hdmi, HDMITX_TOP_CLK_CNTL, 0x3 << 4, 0x3 << 4);
|
||||
|
||||
/* Enable normal output to PHY */
|
||||
dw_hdmi_top_write(hdmi, HDMITX_TOP_BIST_CNTL, BIT(12));
|
||||
|
||||
/* TMDS pattern setup (TOFIX pattern for 4k2k scrambling) */
|
||||
dw_hdmi_top_write(hdmi, HDMITX_TOP_TMDS_CLK_PTTN_01, 0x001f001f);
|
||||
dw_hdmi_top_write(hdmi, HDMITX_TOP_TMDS_CLK_PTTN_23, 0x001f001f);
|
||||
|
||||
/* Load TMDS pattern */
|
||||
dw_hdmi_top_write(hdmi, HDMITX_TOP_TMDS_CLK_PTTN_CNTL, 0x1);
|
||||
mdelay(20);
|
||||
dw_hdmi_top_write(hdmi, HDMITX_TOP_TMDS_CLK_PTTN_CNTL, 0x2);
|
||||
|
||||
/* Setup PHY parameters */
|
||||
meson_dw_hdmi_phy_setup_mode(priv, pixel_clock);
|
||||
|
||||
/* Setup PHY */
|
||||
dw_hdmi_hhi_update_bits(priv, HHI_HDMI_PHY_CNTL1,
|
||||
0xffff << 16, 0x0390 << 16);
|
||||
|
||||
/* BIT_INVERT */
|
||||
if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_GXL) ||
|
||||
meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_GXM) ||
|
||||
meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
|
||||
dw_hdmi_hhi_update_bits(priv, HHI_HDMI_PHY_CNTL1, BIT(17), 0);
|
||||
else
|
||||
dw_hdmi_hhi_update_bits(priv, HHI_HDMI_PHY_CNTL1,
|
||||
BIT(17), BIT(17));
|
||||
|
||||
/* Disable clock, fifo, fifo_wr */
|
||||
dw_hdmi_hhi_update_bits(priv, HHI_HDMI_PHY_CNTL1, 0xf, 0);
|
||||
|
||||
mdelay(100);
|
||||
|
||||
/* Reset PHY 3 times in a row */
|
||||
meson_dw_hdmi_phy_reset(priv);
|
||||
meson_dw_hdmi_phy_reset(priv);
|
||||
meson_dw_hdmi_phy_reset(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int meson_dw_hdmi_enable(struct udevice *dev, int panel_bpp,
|
||||
const struct display_timing *edid)
|
||||
{
|
||||
struct meson_dw_hdmi *priv = dev_get_priv(dev);
|
||||
|
||||
/* will back into meson_dw_hdmi_phy_init */
|
||||
return dw_hdmi_enable(&priv->hdmi, edid);
|
||||
}
|
||||
|
||||
static int meson_dw_hdmi_wait_hpd(struct dw_hdmi *hdmi)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Poll 1 second for HPD signal */
|
||||
for (i = 0; i < 10; ++i) {
|
||||
if (dw_hdmi_top_read(hdmi, HDMITX_TOP_STAT0))
|
||||
return 0;
|
||||
|
||||
mdelay(100);
|
||||
}
|
||||
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static int meson_dw_hdmi_probe(struct udevice *dev)
|
||||
{
|
||||
struct meson_dw_hdmi *priv = dev_get_priv(dev);
|
||||
struct reset_ctl_bulk resets;
|
||||
struct clk_bulk clocks;
|
||||
struct udevice *supply;
|
||||
int ret;
|
||||
|
||||
priv->dev = dev;
|
||||
|
||||
priv->hdmi.ioaddr = (ulong)dev_remap_addr_index(dev, 0);
|
||||
if (!priv->hdmi.ioaddr)
|
||||
return -EINVAL;
|
||||
|
||||
priv->hhi_base = dev_remap_addr_index(dev, 1);
|
||||
if (!priv->hhi_base)
|
||||
return -EINVAL;
|
||||
|
||||
priv->hdmi.hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
|
||||
priv->hdmi.hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_YUV8_1X24;
|
||||
priv->hdmi.phy_set = meson_dw_hdmi_phy_init;
|
||||
if (meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A))
|
||||
priv->hdmi.reg_io_width = 1;
|
||||
else {
|
||||
priv->hdmi.write_reg = dw_hdmi_dwc_write;
|
||||
priv->hdmi.read_reg = dw_hdmi_dwc_read;
|
||||
}
|
||||
priv->hdmi.i2c_clk_high = 0x67;
|
||||
priv->hdmi.i2c_clk_low = 0x78;
|
||||
|
||||
#if CONFIG_IS_ENABLED(DM_REGULATOR)
|
||||
ret = device_get_supply_regulator(dev, "hdmi-supply", &supply);
|
||||
if (ret && ret != -ENOENT) {
|
||||
pr_err("Failed to get HDMI regulator\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
ret = regulator_set_enable(supply, true);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
uclass_get_device_by_phandle(UCLASS_I2C, dev, "ddc-i2c-bus",
|
||||
&priv->hdmi.ddc_bus);
|
||||
|
||||
ret = reset_get_bulk(dev, &resets);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = clk_get_bulk(dev, &clocks);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = clk_enable_bulk(&clocks);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Enable clocks */
|
||||
dw_hdmi_hhi_update_bits(priv, HHI_HDMI_CLK_CNTL, 0xffff, 0x100);
|
||||
|
||||
/* Bring HDMITX MEM output of power down */
|
||||
dw_hdmi_hhi_update_bits(priv, HHI_MEM_PD_REG0, 0xff << 8, 0);
|
||||
|
||||
/* Reset HDMITX APB & TX & PHY: cycle needed for EDID */
|
||||
ret = reset_deassert_bulk(&resets);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = reset_assert_bulk(&resets);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = reset_deassert_bulk(&resets);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!meson_hdmi_is_compatible(priv, HDMI_COMPATIBLE_G12A)) {
|
||||
/* Enable APB3 fail on error */
|
||||
writel_bits(BIT(15), BIT(15),
|
||||
priv->hdmi.ioaddr + HDMITX_TOP_CTRL_REG);
|
||||
writel_bits(BIT(15), BIT(15),
|
||||
priv->hdmi.ioaddr + HDMITX_DWC_CTRL_REG);
|
||||
}
|
||||
|
||||
/* Bring out of reset */
|
||||
dw_hdmi_top_write(&priv->hdmi, HDMITX_TOP_SW_RESET, 0);
|
||||
mdelay(20);
|
||||
dw_hdmi_top_write(&priv->hdmi, HDMITX_TOP_CLK_CNTL, 0xff);
|
||||
|
||||
dw_hdmi_init(&priv->hdmi);
|
||||
dw_hdmi_phy_init(&priv->hdmi);
|
||||
|
||||
/* wait for connector */
|
||||
ret = meson_dw_hdmi_wait_hpd(&priv->hdmi);
|
||||
if (ret)
|
||||
debug("hdmi can not get hpd signal\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool meson_dw_hdmi_mode_valid(struct udevice *dev,
|
||||
const struct display_timing *timing)
|
||||
{
|
||||
return meson_venc_hdmi_supported_mode(timing);
|
||||
}
|
||||
|
||||
static const struct dm_display_ops meson_dw_hdmi_ops = {
|
||||
.read_edid = meson_dw_hdmi_read_edid,
|
||||
.enable = meson_dw_hdmi_enable,
|
||||
.mode_valid = meson_dw_hdmi_mode_valid,
|
||||
};
|
||||
|
||||
static const struct udevice_id meson_dw_hdmi_ids[] = {
|
||||
{ .compatible = "amlogic,meson-gxbb-dw-hdmi",
|
||||
.data = HDMI_COMPATIBLE_GXBB },
|
||||
{ .compatible = "amlogic,meson-gxl-dw-hdmi",
|
||||
.data = HDMI_COMPATIBLE_GXL },
|
||||
{ .compatible = "amlogic,meson-gxm-dw-hdmi",
|
||||
.data = HDMI_COMPATIBLE_GXM },
|
||||
{ .compatible = "amlogic,meson-g12a-dw-hdmi",
|
||||
.data = HDMI_COMPATIBLE_G12A },
|
||||
{ }
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(meson_dw_hdmi) = {
|
||||
.name = "meson_dw_hdmi",
|
||||
.id = UCLASS_DISPLAY,
|
||||
.of_match = meson_dw_hdmi_ids,
|
||||
.ops = &meson_dw_hdmi_ops,
|
||||
.probe = meson_dw_hdmi_probe,
|
||||
.priv_auto_alloc_size = sizeof(struct meson_dw_hdmi),
|
||||
};
|
||||
@@ -0,0 +1,134 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (C) 2016 BayLibre, SAS
|
||||
* Author: Neil Armstrong <narmstrong@baylibre.com>
|
||||
* Copyright (C) 2015 Amlogic, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __MESON_DW_HDMI_H
|
||||
#define __MESON_DW_HDMI_H
|
||||
|
||||
/*
|
||||
* Bit 7 RW Reserved. Default 1.
|
||||
* Bit 6 RW Reserved. Default 1.
|
||||
* Bit 5 RW Reserved. Default 1.
|
||||
* Bit 4 RW sw_reset_phyif: PHY interface. 1=Apply reset; 0=Release from reset.
|
||||
* Default 1.
|
||||
* Bit 3 RW sw_reset_intr: interrupt module. 1=Apply reset;
|
||||
* 0=Release from reset.
|
||||
* Default 1.
|
||||
* Bit 2 RW sw_reset_mem: KSV/REVOC mem. 1=Apply reset; 0=Release from reset.
|
||||
* Default 1.
|
||||
* Bit 1 RW sw_reset_rnd: random number interface to HDCP. 1=Apply reset;
|
||||
* 0=Release from reset. Default 1.
|
||||
* Bit 0 RW sw_reset_core: connects to IP's ~irstz. 1=Apply reset;
|
||||
* 0=Release from reset. Default 1.
|
||||
*/
|
||||
#define HDMITX_TOP_SW_RESET (0x000)
|
||||
|
||||
/*
|
||||
* Bit 12 RW i2s_ws_inv:1=Invert i2s_ws; 0=No invert. Default 0.
|
||||
* Bit 11 RW i2s_clk_inv: 1=Invert i2s_clk; 0=No invert. Default 0.
|
||||
* Bit 10 RW spdif_clk_inv: 1=Invert spdif_clk; 0=No invert. Default 0.
|
||||
* Bit 9 RW tmds_clk_inv: 1=Invert tmds_clk; 0=No invert. Default 0.
|
||||
* Bit 8 RW pixel_clk_inv: 1=Invert pixel_clk; 0=No invert. Default 0.
|
||||
* Bit 4 RW cec_clk_en: 1=enable cec_clk; 0=disable. Default 0.
|
||||
* Bit 3 RW i2s_clk_en: 1=enable i2s_clk; 0=disable. Default 0.
|
||||
* Bit 2 RW spdif_clk_en: 1=enable spdif_clk; 0=disable. Default 0.
|
||||
* Bit 1 RW tmds_clk_en: 1=enable tmds_clk; 0=disable. Default 0.
|
||||
* Bit 0 RW pixel_clk_en: 1=enable pixel_clk; 0=disable. Default 0.
|
||||
*/
|
||||
#define HDMITX_TOP_CLK_CNTL (0x001)
|
||||
|
||||
/*
|
||||
* Bit 11: 0 RW hpd_valid_width: filter out width <= M*1024. Default 0.
|
||||
* Bit 15:12 RW hpd_glitch_width: filter out glitch <= N. Default 0.
|
||||
*/
|
||||
#define HDMITX_TOP_HPD_FILTER (0x002)
|
||||
|
||||
/*
|
||||
* intr_maskn: MASK_N, one bit per interrupt source.
|
||||
* 1=Enable interrupt source; 0=Disable interrupt source. Default 0.
|
||||
* [ 4] hdcp22_rndnum_err
|
||||
* [ 3] nonce_rfrsh_rise
|
||||
* [ 2] hpd_fall_intr
|
||||
* [ 1] hpd_rise_intr
|
||||
* [ 0] core_intr
|
||||
*/
|
||||
#define HDMITX_TOP_INTR_MASKN (0x003)
|
||||
|
||||
/*
|
||||
* Bit 30: 0 RW intr_stat: For each bit, write 1 to manually set the interrupt
|
||||
* bit, read back the interrupt status.
|
||||
* Bit 31 R IP interrupt status
|
||||
* Bit 2 RW hpd_fall
|
||||
* Bit 1 RW hpd_rise
|
||||
* Bit 0 RW IP interrupt
|
||||
*/
|
||||
#define HDMITX_TOP_INTR_STAT (0x004)
|
||||
|
||||
/*
|
||||
* [4] hdcp22_rndnum_err
|
||||
* [3] nonce_rfrsh_rise
|
||||
* [2] hpd_fall
|
||||
* [1] hpd_rise
|
||||
* [0] core_intr_rise
|
||||
*/
|
||||
#define HDMITX_TOP_INTR_STAT_CLR (0x005)
|
||||
|
||||
#define HDMITX_TOP_INTR_CORE BIT(0)
|
||||
#define HDMITX_TOP_INTR_HPD_RISE BIT(1)
|
||||
#define HDMITX_TOP_INTR_HPD_FALL BIT(2)
|
||||
|
||||
/* Bit 14:12 RW tmds_sel: 3'b000=Output zero; 3'b001=Output normal TMDS data;
|
||||
* 3'b010=Output PRBS data; 3'b100=Output shift pattern. Default 0.
|
||||
* Bit 11: 9 RW shift_pttn_repeat: 0=New pattern every clk cycle; 1=New pattern
|
||||
* every 2 clk cycles; ...; 7=New pattern every 8 clk cycles. Default 0.
|
||||
* Bit 8 RW shift_pttn_en: 1= Enable shift pattern generator; 0=Disable.
|
||||
* Default 0.
|
||||
* Bit 4: 3 RW prbs_pttn_mode: 0=PRBS11; 1=PRBS15; 2=PRBS7; 3=PRBS31. Default 0.
|
||||
* Bit 2: 1 RW prbs_pttn_width: 0=idle; 1=output 8-bit pattern;
|
||||
* 2=Output 1-bit pattern; 3=output 10-bit pattern. Default 0.
|
||||
* Bit 0 RW prbs_pttn_en: 1=Enable PRBS generator; 0=Disable. Default 0.
|
||||
*/
|
||||
#define HDMITX_TOP_BIST_CNTL (0x006)
|
||||
|
||||
/* Bit 29:20 RW shift_pttn_data[59:50]. Default 0. */
|
||||
/* Bit 19:10 RW shift_pttn_data[69:60]. Default 0. */
|
||||
/* Bit 9: 0 RW shift_pttn_data[79:70]. Default 0. */
|
||||
#define HDMITX_TOP_SHIFT_PTTN_012 (0x007)
|
||||
|
||||
/* Bit 29:20 RW shift_pttn_data[29:20]. Default 0. */
|
||||
/* Bit 19:10 RW shift_pttn_data[39:30]. Default 0. */
|
||||
/* Bit 9: 0 RW shift_pttn_data[49:40]. Default 0. */
|
||||
#define HDMITX_TOP_SHIFT_PTTN_345 (0x008)
|
||||
|
||||
/* Bit 19:10 RW shift_pttn_data[ 9: 0]. Default 0. */
|
||||
/* Bit 9: 0 RW shift_pttn_data[19:10]. Default 0. */
|
||||
#define HDMITX_TOP_SHIFT_PTTN_67 (0x009)
|
||||
|
||||
/* Bit 25:16 RW tmds_clk_pttn[19:10]. Default 0. */
|
||||
/* Bit 9: 0 RW tmds_clk_pttn[ 9: 0]. Default 0. */
|
||||
#define HDMITX_TOP_TMDS_CLK_PTTN_01 (0x00A)
|
||||
|
||||
/* Bit 25:16 RW tmds_clk_pttn[39:30]. Default 0. */
|
||||
/* Bit 9: 0 RW tmds_clk_pttn[29:20]. Default 0. */
|
||||
#define HDMITX_TOP_TMDS_CLK_PTTN_23 (0x00B)
|
||||
|
||||
/* Bit 1 RW shift_tmds_clk_pttn:1=Enable shifting clk pattern,
|
||||
* used when TMDS CLK rate = TMDS character rate /4. Default 0.
|
||||
* Bit 0 R Reserved. Default 0.
|
||||
* [ 1] shift_tmds_clk_pttn
|
||||
* [ 0] load_tmds_clk_pttn
|
||||
*/
|
||||
#define HDMITX_TOP_TMDS_CLK_PTTN_CNTL (0x00C)
|
||||
|
||||
/* Bit 0 RW revocmem_wr_fail: Read back 1 to indicate Host write REVOC MEM
|
||||
* failure, write 1 to clear the failure flag. Default 0.
|
||||
*/
|
||||
#define HDMITX_TOP_REVOCMEM_STAT (0x00D)
|
||||
|
||||
/* Bit 0 R filtered HPD status. */
|
||||
#define HDMITX_TOP_STAT0 (0x00E)
|
||||
|
||||
#endif /* __MESON_DW_HDMI_H */
|
||||
@@ -0,0 +1,210 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Amlogic Meson Video Processing Unit driver
|
||||
*
|
||||
* Copyright (c) 2018 BayLibre, SAS.
|
||||
* Author: Neil Armstrong <narmstrong@baylibre.com>
|
||||
*/
|
||||
|
||||
#include "meson_vpu.h"
|
||||
|
||||
/* OSDx_BLKx_CFG */
|
||||
#define OSD_CANVAS_SEL 16
|
||||
|
||||
#define OSD_ENDIANNESS_LE BIT(15)
|
||||
#define OSD_ENDIANNESS_BE (0)
|
||||
|
||||
#define OSD_BLK_MODE_422 (0x03 << 8)
|
||||
#define OSD_BLK_MODE_16 (0x04 << 8)
|
||||
#define OSD_BLK_MODE_32 (0x05 << 8)
|
||||
#define OSD_BLK_MODE_24 (0x07 << 8)
|
||||
|
||||
#define OSD_OUTPUT_COLOR_RGB BIT(7)
|
||||
#define OSD_OUTPUT_COLOR_YUV (0)
|
||||
|
||||
#define OSD_COLOR_MATRIX_32_RGBA (0x00 << 2)
|
||||
#define OSD_COLOR_MATRIX_32_ARGB (0x01 << 2)
|
||||
#define OSD_COLOR_MATRIX_32_ABGR (0x02 << 2)
|
||||
#define OSD_COLOR_MATRIX_32_BGRA (0x03 << 2)
|
||||
|
||||
#define OSD_COLOR_MATRIX_24_RGB (0x00 << 2)
|
||||
|
||||
#define OSD_COLOR_MATRIX_16_RGB655 (0x00 << 2)
|
||||
#define OSD_COLOR_MATRIX_16_RGB565 (0x04 << 2)
|
||||
|
||||
#define OSD_INTERLACE_ENABLED BIT(1)
|
||||
#define OSD_INTERLACE_ODD BIT(0)
|
||||
#define OSD_INTERLACE_EVEN (0)
|
||||
|
||||
/* OSDx_CTRL_STAT */
|
||||
#define OSD_ENABLE BIT(21)
|
||||
#define OSD_BLK0_ENABLE BIT(0)
|
||||
|
||||
#define OSD_GLOBAL_ALPHA_SHIFT 12
|
||||
|
||||
/* OSDx_CTRL_STAT2 */
|
||||
#define OSD_REPLACE_EN BIT(14)
|
||||
#define OSD_REPLACE_SHIFT 6
|
||||
|
||||
/*
|
||||
* When the output is interlaced, the OSD must switch between
|
||||
* each field using the INTERLACE_SEL_ODD (0) of VIU_OSD1_BLK0_CFG_W0
|
||||
* at each vsync.
|
||||
* But the vertical scaler can provide such funtionnality if
|
||||
* is configured for 2:1 scaling with interlace options enabled.
|
||||
*/
|
||||
static void meson_vpp_setup_interlace_vscaler_osd1(struct meson_vpu_priv *priv,
|
||||
struct video_priv *uc_priv)
|
||||
{
|
||||
writel(BIT(3) /* Enable scaler */ |
|
||||
BIT(2), /* Select OSD1 */
|
||||
priv->io_base + _REG(VPP_OSD_SC_CTRL0));
|
||||
|
||||
writel(((uc_priv->xsize - 1) << 16) | (uc_priv->ysize - 1),
|
||||
priv->io_base + _REG(VPP_OSD_SCI_WH_M1));
|
||||
/* 2:1 scaling */
|
||||
writel((0 << 16) | uc_priv->xsize,
|
||||
priv->io_base + _REG(VPP_OSD_SCO_H_START_END));
|
||||
writel(((0 >> 1) << 16) | (uc_priv->ysize >> 1),
|
||||
priv->io_base + _REG(VPP_OSD_SCO_V_START_END));
|
||||
|
||||
/* 2:1 scaling values */
|
||||
writel(BIT(16), priv->io_base + _REG(VPP_OSD_VSC_INI_PHASE));
|
||||
writel(BIT(25), priv->io_base + _REG(VPP_OSD_VSC_PHASE_STEP));
|
||||
|
||||
writel(0, priv->io_base + _REG(VPP_OSD_HSC_CTRL0));
|
||||
|
||||
writel((4 << 0) /* osd_vsc_bank_length */ |
|
||||
(4 << 3) /* osd_vsc_top_ini_rcv_num0 */ |
|
||||
(1 << 8) /* osd_vsc_top_rpt_p0_num0 */ |
|
||||
(6 << 11) /* osd_vsc_bot_ini_rcv_num0 */ |
|
||||
(2 << 16) /* osd_vsc_bot_rpt_p0_num0 */ |
|
||||
BIT(23) /* osd_prog_interlace */ |
|
||||
BIT(24), /* Enable vertical scaler */
|
||||
priv->io_base + _REG(VPP_OSD_VSC_CTRL0));
|
||||
}
|
||||
|
||||
static void
|
||||
meson_vpp_disable_interlace_vscaler_osd1(struct meson_vpu_priv *priv)
|
||||
{
|
||||
writel(0, priv->io_base + _REG(VPP_OSD_SC_CTRL0));
|
||||
writel(0, priv->io_base + _REG(VPP_OSD_VSC_CTRL0));
|
||||
writel(0, priv->io_base + _REG(VPP_OSD_HSC_CTRL0));
|
||||
}
|
||||
|
||||
void meson_vpu_setup_plane(struct udevice *dev, bool is_interlaced)
|
||||
{
|
||||
struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
|
||||
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
|
||||
struct meson_vpu_priv *priv = dev_get_priv(dev);
|
||||
u32 osd1_ctrl_stat;
|
||||
u32 osd1_blk0_cfg[5];
|
||||
bool osd1_interlace;
|
||||
unsigned int src_x1, src_x2, src_y1, src_y2;
|
||||
unsigned int dest_x1, dest_x2, dest_y1, dest_y2;
|
||||
|
||||
dest_x1 = src_x1 = 0;
|
||||
dest_x2 = src_x2 = uc_priv->xsize;
|
||||
dest_y1 = src_y1 = 0;
|
||||
dest_y2 = src_y2 = uc_priv->ysize;
|
||||
|
||||
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
|
||||
/* VD1 Preblend vertical start/end */
|
||||
writel(FIELD_PREP(GENMASK(11, 0), 2303),
|
||||
priv->io_base + _REG(VPP_PREBLEND_VD1_V_START_END));
|
||||
|
||||
/* Setup Blender */
|
||||
writel(uc_priv->xsize |
|
||||
uc_priv->ysize << 16,
|
||||
priv->io_base + _REG(VPP_POSTBLEND_H_SIZE));
|
||||
|
||||
writel(0 << 16 |
|
||||
(uc_priv->xsize - 1),
|
||||
priv->io_base + _REG(VPP_OSD1_BLD_H_SCOPE));
|
||||
writel(0 << 16 |
|
||||
(uc_priv->ysize - 1),
|
||||
priv->io_base + _REG(VPP_OSD1_BLD_V_SCOPE));
|
||||
writel(uc_priv->xsize << 16 |
|
||||
uc_priv->ysize,
|
||||
priv->io_base + _REG(VPP_OUT_H_V_SIZE));
|
||||
} else {
|
||||
/* Enable VPP Postblend */
|
||||
writel(uc_priv->xsize,
|
||||
priv->io_base + _REG(VPP_POSTBLEND_H_SIZE));
|
||||
|
||||
writel_bits(VPP_POSTBLEND_ENABLE, VPP_POSTBLEND_ENABLE,
|
||||
priv->io_base + _REG(VPP_MISC));
|
||||
}
|
||||
|
||||
/* uc_plat->base is the framebuffer */
|
||||
|
||||
/* Enable OSD and BLK0, set max global alpha */
|
||||
osd1_ctrl_stat = OSD_ENABLE | (0xFF << OSD_GLOBAL_ALPHA_SHIFT) |
|
||||
OSD_BLK0_ENABLE;
|
||||
|
||||
/* Set up BLK0 to point to the right canvas */
|
||||
osd1_blk0_cfg[0] = ((MESON_CANVAS_ID_OSD1 << OSD_CANVAS_SEL) |
|
||||
OSD_ENDIANNESS_LE);
|
||||
|
||||
/* On GXBB, Use the old non-HDR RGB2YUV converter */
|
||||
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXBB))
|
||||
osd1_blk0_cfg[0] |= OSD_OUTPUT_COLOR_RGB;
|
||||
|
||||
/* For XRGB, replace the pixel's alpha by 0xFF */
|
||||
writel_bits(OSD_REPLACE_EN, OSD_REPLACE_EN,
|
||||
priv->io_base + _REG(VIU_OSD1_CTRL_STAT2));
|
||||
osd1_blk0_cfg[0] |= OSD_BLK_MODE_32 |
|
||||
OSD_COLOR_MATRIX_32_ARGB;
|
||||
|
||||
if (is_interlaced) {
|
||||
osd1_interlace = true;
|
||||
dest_y1 /= 2;
|
||||
dest_y2 /= 2;
|
||||
} else {
|
||||
osd1_interlace = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* The format of these registers is (x2 << 16 | x1),
|
||||
* where x2 is exclusive.
|
||||
* e.g. +30x1920 would be (1919 << 16) | 30
|
||||
*/
|
||||
osd1_blk0_cfg[1] = ((src_x2 - 1) << 16) | src_x1;
|
||||
osd1_blk0_cfg[2] = ((src_y2 - 1) << 16) | src_y1;
|
||||
osd1_blk0_cfg[3] = ((dest_x2 - 1) << 16) | dest_x1;
|
||||
osd1_blk0_cfg[4] = ((dest_y2 - 1) << 16) | dest_y1;
|
||||
|
||||
writel(osd1_ctrl_stat, priv->io_base + _REG(VIU_OSD1_CTRL_STAT));
|
||||
writel(osd1_blk0_cfg[0], priv->io_base + _REG(VIU_OSD1_BLK0_CFG_W0));
|
||||
writel(osd1_blk0_cfg[1], priv->io_base + _REG(VIU_OSD1_BLK0_CFG_W1));
|
||||
writel(osd1_blk0_cfg[2], priv->io_base + _REG(VIU_OSD1_BLK0_CFG_W2));
|
||||
writel(osd1_blk0_cfg[3], priv->io_base + _REG(VIU_OSD1_BLK0_CFG_W3));
|
||||
writel(osd1_blk0_cfg[4], priv->io_base + _REG(VIU_OSD1_BLK0_CFG_W4));
|
||||
|
||||
/* If output is interlace, make use of the Scaler */
|
||||
if (osd1_interlace)
|
||||
meson_vpp_setup_interlace_vscaler_osd1(priv, uc_priv);
|
||||
else
|
||||
meson_vpp_disable_interlace_vscaler_osd1(priv);
|
||||
|
||||
meson_canvas_setup(priv, MESON_CANVAS_ID_OSD1,
|
||||
uc_plat->base, uc_priv->xsize * 4,
|
||||
uc_priv->ysize, MESON_CANVAS_WRAP_NONE,
|
||||
MESON_CANVAS_BLKMODE_LINEAR);
|
||||
|
||||
/* Enable OSD1 */
|
||||
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
|
||||
writel(((dest_x2 - 1) << 16) | dest_x1,
|
||||
priv->io_base + _REG(VIU_OSD_BLEND_DIN0_SCOPE_H));
|
||||
writel(((dest_y2 - 1) << 16) | dest_y1,
|
||||
priv->io_base + _REG(VIU_OSD_BLEND_DIN0_SCOPE_V));
|
||||
writel(uc_priv->xsize << 16 | uc_priv->ysize,
|
||||
priv->io_base + _REG(VIU_OSD_BLEND_BLEND0_SIZE));
|
||||
writel(uc_priv->xsize << 16 | uc_priv->ysize,
|
||||
priv->io_base + _REG(VIU_OSD_BLEND_BLEND1_SIZE));
|
||||
writel_bits(3 << 8, 3 << 8,
|
||||
priv->io_base + _REG(OSD1_BLEND_SRC_CTRL));
|
||||
} else
|
||||
writel_bits(VPP_OSD1_POSTBLEND, VPP_OSD1_POSTBLEND,
|
||||
priv->io_base + _REG(VPP_MISC));
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,202 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Amlogic Meson Video Processing Unit driver
|
||||
*
|
||||
* Copyright (c) 2018 BayLibre, SAS.
|
||||
* Author: Neil Armstrong <narmstrong@baylibre.com>
|
||||
*/
|
||||
|
||||
#include "meson_vpu.h"
|
||||
#include <efi_loader.h>
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
#include <fdt_support.h>
|
||||
#include <linux/sizes.h>
|
||||
#include <asm/arch/mem.h>
|
||||
#include "meson_registers.h"
|
||||
#include "simplefb_common.h"
|
||||
|
||||
#define MESON_VPU_OVERSCAN SZ_64K
|
||||
|
||||
/* Static variable for use in meson_vpu_rsv_fb() */
|
||||
static struct meson_framebuffer {
|
||||
u64 base;
|
||||
u64 fb_size;
|
||||
unsigned int xsize;
|
||||
unsigned int ysize;
|
||||
bool is_cvbs;
|
||||
} meson_fb = { 0 };
|
||||
|
||||
static int meson_vpu_setup_mode(struct udevice *dev, struct udevice *disp)
|
||||
{
|
||||
struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
|
||||
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
|
||||
struct display_timing timing;
|
||||
bool is_cvbs = false;
|
||||
int ret = 0;
|
||||
|
||||
if (disp) {
|
||||
ret = display_read_timing(disp, &timing);
|
||||
if (ret) {
|
||||
debug("%s: Failed to read timings\n", __func__);
|
||||
goto cvbs;
|
||||
}
|
||||
|
||||
uc_priv->xsize = timing.hactive.typ;
|
||||
uc_priv->ysize = timing.vactive.typ;
|
||||
|
||||
ret = display_enable(disp, 0, &timing);
|
||||
if (ret)
|
||||
goto cvbs;
|
||||
} else {
|
||||
cvbs:
|
||||
/* CVBS has a fixed 720x480i (NTSC) and 720x576i (PAL) */
|
||||
is_cvbs = true;
|
||||
timing.flags = DISPLAY_FLAGS_INTERLACED;
|
||||
uc_priv->xsize = 720;
|
||||
uc_priv->ysize = 576;
|
||||
}
|
||||
|
||||
uc_priv->bpix = VPU_MAX_LOG2_BPP;
|
||||
|
||||
meson_fb.is_cvbs = is_cvbs;
|
||||
meson_fb.xsize = uc_priv->xsize;
|
||||
meson_fb.ysize = uc_priv->ysize;
|
||||
|
||||
/* Move the framebuffer to the end of addressable ram */
|
||||
meson_fb.fb_size = ALIGN(meson_fb.xsize * meson_fb.ysize *
|
||||
((1 << VPU_MAX_LOG2_BPP) / 8) +
|
||||
MESON_VPU_OVERSCAN, EFI_PAGE_SIZE);
|
||||
meson_fb.base = gd->bd->bi_dram[0].start +
|
||||
gd->bd->bi_dram[0].size - meson_fb.fb_size;
|
||||
|
||||
/* Override the framebuffer address */
|
||||
uc_plat->base = meson_fb.base;
|
||||
|
||||
meson_vpu_setup_plane(dev, timing.flags & DISPLAY_FLAGS_INTERLACED);
|
||||
meson_vpu_setup_venc(dev, &timing, is_cvbs);
|
||||
meson_vpu_setup_vclk(dev, &timing, is_cvbs);
|
||||
|
||||
video_set_flush_dcache(dev, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct udevice_id meson_vpu_ids[] = {
|
||||
{ .compatible = "amlogic,meson-gxbb-vpu", .data = VPU_COMPATIBLE_GXBB },
|
||||
{ .compatible = "amlogic,meson-gxl-vpu", .data = VPU_COMPATIBLE_GXL },
|
||||
{ .compatible = "amlogic,meson-gxm-vpu", .data = VPU_COMPATIBLE_GXM },
|
||||
{ .compatible = "amlogic,meson-g12a-vpu", .data = VPU_COMPATIBLE_G12A },
|
||||
{ }
|
||||
};
|
||||
|
||||
static int meson_vpu_probe(struct udevice *dev)
|
||||
{
|
||||
struct meson_vpu_priv *priv = dev_get_priv(dev);
|
||||
struct udevice *disp;
|
||||
int ret;
|
||||
|
||||
/* Before relocation we don't need to do anything */
|
||||
if (!(gd->flags & GD_FLG_RELOC))
|
||||
return 0;
|
||||
|
||||
priv->dev = dev;
|
||||
|
||||
priv->io_base = dev_remap_addr_index(dev, 0);
|
||||
if (!priv->io_base)
|
||||
return -EINVAL;
|
||||
|
||||
priv->hhi_base = dev_remap_addr_index(dev, 1);
|
||||
if (!priv->hhi_base)
|
||||
return -EINVAL;
|
||||
|
||||
priv->dmc_base = dev_remap_addr_index(dev, 2);
|
||||
if (!priv->dmc_base)
|
||||
return -EINVAL;
|
||||
|
||||
meson_vpu_init(dev);
|
||||
|
||||
/* probe the display */
|
||||
ret = uclass_get_device(UCLASS_DISPLAY, 0, &disp);
|
||||
|
||||
return meson_vpu_setup_mode(dev, ret ? NULL : disp);
|
||||
}
|
||||
|
||||
static int meson_vpu_bind(struct udevice *dev)
|
||||
{
|
||||
struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
|
||||
|
||||
plat->size = VPU_MAX_WIDTH * VPU_MAX_HEIGHT *
|
||||
(1 << VPU_MAX_LOG2_BPP) / 8;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_VIDEO_DT_SIMPLEFB)
|
||||
static void meson_vpu_setup_simplefb(void *fdt)
|
||||
{
|
||||
const char *pipeline = NULL;
|
||||
u64 mem_start, mem_size;
|
||||
int offset, ret;
|
||||
|
||||
if (meson_fb.is_cvbs)
|
||||
pipeline = "vpu-cvbs";
|
||||
else
|
||||
pipeline = "vpu-hdmi";
|
||||
|
||||
offset = meson_simplefb_fdt_match(fdt, pipeline);
|
||||
if (offset < 0) {
|
||||
eprintf("Cannot setup simplefb: node not found\n");
|
||||
|
||||
/* If simplefb is missing, add it as reserved memory */
|
||||
meson_board_add_reserved_memory(fdt, meson_fb.base,
|
||||
meson_fb.fb_size);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* SimpleFB will try to iomap the framebuffer, so we can't use
|
||||
* fdt_add_mem_rsv on the memory area. Instead, the FB is stored
|
||||
* at the end of the RAM and we strip this portion from the kernel
|
||||
* allowed region
|
||||
*/
|
||||
mem_start = gd->bd->bi_dram[0].start;
|
||||
mem_size = gd->bd->bi_dram[0].size - meson_fb.fb_size;
|
||||
ret = fdt_fixup_memory_banks(fdt, &mem_start, &mem_size, 1);
|
||||
if (ret) {
|
||||
eprintf("Cannot setup simplefb: Error reserving memory\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = fdt_setup_simplefb_node(fdt, offset, meson_fb.base,
|
||||
meson_fb.xsize, meson_fb.ysize,
|
||||
meson_fb.xsize * 4, "x8r8g8b8");
|
||||
if (ret)
|
||||
eprintf("Cannot setup simplefb: Error setting properties\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
void meson_vpu_rsv_fb(void *fdt)
|
||||
{
|
||||
if (!meson_fb.base || !meson_fb.xsize || !meson_fb.ysize)
|
||||
return;
|
||||
|
||||
#if defined(CONFIG_EFI_LOADER)
|
||||
efi_add_memory_map(meson_fb.base, meson_fb.fb_size >> EFI_PAGE_SHIFT,
|
||||
EFI_RESERVED_MEMORY_TYPE, false);
|
||||
#endif
|
||||
#if defined(CONFIG_VIDEO_DT_SIMPLEFB)
|
||||
meson_vpu_setup_simplefb(fdt);
|
||||
#endif
|
||||
}
|
||||
|
||||
U_BOOT_DRIVER(meson_vpu) = {
|
||||
.name = "meson_vpu",
|
||||
.id = UCLASS_VIDEO,
|
||||
.of_match = meson_vpu_ids,
|
||||
.probe = meson_vpu_probe,
|
||||
.bind = meson_vpu_bind,
|
||||
.priv_auto_alloc_size = sizeof(struct meson_vpu_priv),
|
||||
.flags = DM_FLAG_PRE_RELOC,
|
||||
};
|
||||
@@ -0,0 +1,99 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Amlogic Meson Video Processing Unit driver
|
||||
*
|
||||
* Copyright (c) 2018 BayLibre, SAS.
|
||||
* Author: Neil Armstrong <narmstrong@baylibre.com>
|
||||
*/
|
||||
|
||||
#ifndef __MESON_VPU_H__
|
||||
#define __MESON_VPU_H__
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <video.h>
|
||||
#include <display.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/bitfield.h>
|
||||
#include "meson_registers.h"
|
||||
|
||||
enum {
|
||||
/* Maximum size we support */
|
||||
VPU_MAX_WIDTH = 3840,
|
||||
VPU_MAX_HEIGHT = 2160,
|
||||
VPU_MAX_LOG2_BPP = VIDEO_BPP32,
|
||||
};
|
||||
|
||||
enum vpu_compatible {
|
||||
VPU_COMPATIBLE_GXBB = 0,
|
||||
VPU_COMPATIBLE_GXL = 1,
|
||||
VPU_COMPATIBLE_GXM = 2,
|
||||
VPU_COMPATIBLE_G12A = 3,
|
||||
};
|
||||
|
||||
struct meson_vpu_priv {
|
||||
struct udevice *dev;
|
||||
void __iomem *io_base;
|
||||
void __iomem *hhi_base;
|
||||
void __iomem *dmc_base;
|
||||
};
|
||||
|
||||
static inline bool meson_vpu_is_compatible(struct meson_vpu_priv *priv,
|
||||
enum vpu_compatible family)
|
||||
{
|
||||
enum vpu_compatible compat = dev_get_driver_data(priv->dev);
|
||||
|
||||
return compat == family;
|
||||
}
|
||||
|
||||
#define hhi_update_bits(offset, mask, value) \
|
||||
writel_bits(mask, value, priv->hhi_base + offset)
|
||||
|
||||
#define hhi_write(offset, value) \
|
||||
writel(value, priv->hhi_base + offset)
|
||||
|
||||
#define hhi_read(offset) \
|
||||
readl(priv->hhi_base + offset)
|
||||
|
||||
#define dmc_update_bits(offset, mask, value) \
|
||||
writel_bits(mask, value, priv->dmc_base + offset)
|
||||
|
||||
#define dmc_write(offset, value) \
|
||||
writel(value, priv->dmc_base + offset)
|
||||
|
||||
#define dmc_read(offset) \
|
||||
readl(priv->dmc_base + offset)
|
||||
|
||||
#define MESON_CANVAS_ID_OSD1 0x4e
|
||||
|
||||
/* Canvas configuration. */
|
||||
#define MESON_CANVAS_WRAP_NONE 0x00
|
||||
#define MESON_CANVAS_WRAP_X 0x01
|
||||
#define MESON_CANVAS_WRAP_Y 0x02
|
||||
|
||||
#define MESON_CANVAS_BLKMODE_LINEAR 0x00
|
||||
#define MESON_CANVAS_BLKMODE_32x32 0x01
|
||||
#define MESON_CANVAS_BLKMODE_64x64 0x02
|
||||
|
||||
void meson_canvas_setup(struct meson_vpu_priv *priv,
|
||||
u32 canvas_index, u32 addr,
|
||||
u32 stride, u32 height,
|
||||
unsigned int wrap,
|
||||
unsigned int blkmode);
|
||||
|
||||
/* Mux VIU/VPP to ENCI */
|
||||
#define MESON_VIU_VPP_MUX_ENCI 0x5
|
||||
/* Mux VIU/VPP to ENCP */
|
||||
#define MESON_VIU_VPP_MUX_ENCP 0xA
|
||||
|
||||
void meson_vpp_setup_mux(struct meson_vpu_priv *priv, unsigned int mux);
|
||||
void meson_vpu_init(struct udevice *dev);
|
||||
void meson_vpu_setup_plane(struct udevice *dev, bool is_interlaced);
|
||||
bool meson_venc_hdmi_supported_mode(const struct display_timing *mode);
|
||||
void meson_vpu_setup_venc(struct udevice *dev,
|
||||
const struct display_timing *mode, bool is_cvbs);
|
||||
bool meson_vclk_dmt_supported_freq(struct meson_vpu_priv *priv,
|
||||
unsigned int freq);
|
||||
void meson_vpu_setup_vclk(struct udevice *dev,
|
||||
const struct display_timing *mode, bool is_cvbs);
|
||||
#endif
|
||||
@@ -0,0 +1,557 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Amlogic Meson Video Processing Unit driver
|
||||
*
|
||||
* Copyright (c) 2018 BayLibre, SAS.
|
||||
* Author: Neil Armstrong <narmstrong@baylibre.com>
|
||||
*/
|
||||
|
||||
#define DEBUG
|
||||
|
||||
#include "meson_vpu.h"
|
||||
|
||||
/* HHI Registers */
|
||||
#define HHI_VDAC_CNTL0 0x2F4 /* 0xbd offset in data sheet */
|
||||
#define HHI_VDAC_CNTL0_G12A 0x2EC /* 0xbd offset in data sheet */
|
||||
#define HHI_VDAC_CNTL1 0x2F8 /* 0xbe offset in data sheet */
|
||||
#define HHI_VDAC_CNTL1_G12A 0x2F0 /* 0xbe offset in data sheet */
|
||||
#define HHI_HDMI_PHY_CNTL0 0x3a0 /* 0xe8 offset in data sheet */
|
||||
|
||||
/* OSDx_CTRL_STAT2 */
|
||||
#define OSD_REPLACE_EN BIT(14)
|
||||
#define OSD_REPLACE_SHIFT 6
|
||||
|
||||
void meson_vpp_setup_mux(struct meson_vpu_priv *priv, unsigned int mux)
|
||||
{
|
||||
writel(mux, priv->io_base + _REG(VPU_VIU_VENC_MUX_CTRL));
|
||||
}
|
||||
|
||||
static unsigned int vpp_filter_coefs_4point_bspline[] = {
|
||||
0x15561500, 0x14561600, 0x13561700, 0x12561800,
|
||||
0x11551a00, 0x11541b00, 0x10541c00, 0x0f541d00,
|
||||
0x0f531e00, 0x0e531f00, 0x0d522100, 0x0c522200,
|
||||
0x0b522300, 0x0b512400, 0x0a502600, 0x0a4f2700,
|
||||
0x094e2900, 0x084e2a00, 0x084d2b00, 0x074c2c01,
|
||||
0x074b2d01, 0x064a2f01, 0x06493001, 0x05483201,
|
||||
0x05473301, 0x05463401, 0x04453601, 0x04433702,
|
||||
0x04423802, 0x03413a02, 0x03403b02, 0x033f3c02,
|
||||
0x033d3d03
|
||||
};
|
||||
|
||||
static void meson_vpp_write_scaling_filter_coefs(struct meson_vpu_priv *priv,
|
||||
const unsigned int *coefs,
|
||||
bool is_horizontal)
|
||||
{
|
||||
int i;
|
||||
|
||||
writel(is_horizontal ? VPP_SCALE_HORIZONTAL_COEF : 0,
|
||||
priv->io_base + _REG(VPP_OSD_SCALE_COEF_IDX));
|
||||
for (i = 0; i < 33; i++)
|
||||
writel(coefs[i],
|
||||
priv->io_base + _REG(VPP_OSD_SCALE_COEF));
|
||||
}
|
||||
|
||||
static const u32 vpp_filter_coefs_bicubic[] = {
|
||||
0x00800000, 0x007f0100, 0xff7f0200, 0xfe7f0300,
|
||||
0xfd7e0500, 0xfc7e0600, 0xfb7d0800, 0xfb7c0900,
|
||||
0xfa7b0b00, 0xfa7a0dff, 0xf9790fff, 0xf97711ff,
|
||||
0xf87613ff, 0xf87416fe, 0xf87218fe, 0xf8701afe,
|
||||
0xf76f1dfd, 0xf76d1ffd, 0xf76b21fd, 0xf76824fd,
|
||||
0xf76627fc, 0xf76429fc, 0xf7612cfc, 0xf75f2ffb,
|
||||
0xf75d31fb, 0xf75a34fb, 0xf75837fa, 0xf7553afa,
|
||||
0xf8523cfa, 0xf8503ff9, 0xf84d42f9, 0xf84a45f9,
|
||||
0xf84848f8
|
||||
};
|
||||
|
||||
static void meson_vpp_write_vd_scaling_filter_coefs(struct meson_vpu_priv *priv,
|
||||
const unsigned int *coefs,
|
||||
bool is_horizontal)
|
||||
{
|
||||
int i;
|
||||
|
||||
writel(is_horizontal ? VPP_SCALE_HORIZONTAL_COEF : 0,
|
||||
priv->io_base + _REG(VPP_SCALE_COEF_IDX));
|
||||
for (i = 0; i < 33; i++)
|
||||
writel(coefs[i],
|
||||
priv->io_base + _REG(VPP_SCALE_COEF));
|
||||
}
|
||||
|
||||
/* OSD csc defines */
|
||||
|
||||
enum viu_matrix_sel_e {
|
||||
VIU_MATRIX_OSD_EOTF = 0,
|
||||
VIU_MATRIX_OSD,
|
||||
};
|
||||
|
||||
enum viu_lut_sel_e {
|
||||
VIU_LUT_OSD_EOTF = 0,
|
||||
VIU_LUT_OSD_OETF,
|
||||
};
|
||||
|
||||
#define COEFF_NORM(a) ((int)((((a) * 2048.0) + 1) / 2))
|
||||
#define MATRIX_5X3_COEF_SIZE 24
|
||||
|
||||
#define EOTF_COEFF_NORM(a) ((int)((((a) * 4096.0) + 1) / 2))
|
||||
#define EOTF_COEFF_SIZE 10
|
||||
#define EOTF_COEFF_RIGHTSHIFT 1
|
||||
|
||||
static int RGB709_to_YUV709l_coeff[MATRIX_5X3_COEF_SIZE] = {
|
||||
0, 0, 0, /* pre offset */
|
||||
COEFF_NORM(0.181873), COEFF_NORM(0.611831), COEFF_NORM(0.061765),
|
||||
COEFF_NORM(-0.100251), COEFF_NORM(-0.337249), COEFF_NORM(0.437500),
|
||||
COEFF_NORM(0.437500), COEFF_NORM(-0.397384), COEFF_NORM(-0.040116),
|
||||
0, 0, 0, /* 10'/11'/12' */
|
||||
0, 0, 0, /* 20'/21'/22' */
|
||||
64, 512, 512, /* offset */
|
||||
0, 0, 0 /* mode, right_shift, clip_en */
|
||||
};
|
||||
|
||||
/* eotf matrix: bypass */
|
||||
static int eotf_bypass_coeff[EOTF_COEFF_SIZE] = {
|
||||
EOTF_COEFF_NORM(1.0), EOTF_COEFF_NORM(0.0), EOTF_COEFF_NORM(0.0),
|
||||
EOTF_COEFF_NORM(0.0), EOTF_COEFF_NORM(1.0), EOTF_COEFF_NORM(0.0),
|
||||
EOTF_COEFF_NORM(0.0), EOTF_COEFF_NORM(0.0), EOTF_COEFF_NORM(1.0),
|
||||
EOTF_COEFF_RIGHTSHIFT /* right shift */
|
||||
};
|
||||
|
||||
static void meson_viu_set_g12a_osd1_matrix(struct meson_vpu_priv *priv,
|
||||
int *m, bool csc_on)
|
||||
{
|
||||
/* VPP WRAP OSD1 matrix */
|
||||
writel(((m[0] & 0xfff) << 16) | (m[1] & 0xfff),
|
||||
priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_PRE_OFFSET0_1));
|
||||
writel(m[2] & 0xfff,
|
||||
priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_PRE_OFFSET2));
|
||||
writel(((m[3] & 0x1fff) << 16) | (m[4] & 0x1fff),
|
||||
priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_COEF00_01));
|
||||
writel(((m[5] & 0x1fff) << 16) | (m[6] & 0x1fff),
|
||||
priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_COEF02_10));
|
||||
writel(((m[7] & 0x1fff) << 16) | (m[8] & 0x1fff),
|
||||
priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_COEF11_12));
|
||||
writel(((m[9] & 0x1fff) << 16) | (m[10] & 0x1fff),
|
||||
priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_COEF20_21));
|
||||
writel((m[11] & 0x1fff) << 16,
|
||||
priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_COEF22));
|
||||
|
||||
writel(((m[18] & 0xfff) << 16) | (m[19] & 0xfff),
|
||||
priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_OFFSET0_1));
|
||||
writel(m[20] & 0xfff,
|
||||
priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_OFFSET2));
|
||||
|
||||
writel_bits(BIT(0), csc_on ? BIT(0) : 0,
|
||||
priv->io_base + _REG(VPP_WRAP_OSD1_MATRIX_EN_CTRL));
|
||||
}
|
||||
|
||||
static void meson_viu_set_osd_matrix(struct meson_vpu_priv *priv,
|
||||
enum viu_matrix_sel_e m_select,
|
||||
int *m, bool csc_on)
|
||||
{
|
||||
if (m_select == VIU_MATRIX_OSD) {
|
||||
/* osd matrix, VIU_MATRIX_0 */
|
||||
writel(((m[0] & 0xfff) << 16) | (m[1] & 0xfff),
|
||||
priv->io_base + _REG(VIU_OSD1_MATRIX_PRE_OFFSET0_1));
|
||||
writel(m[2] & 0xfff,
|
||||
priv->io_base + _REG(VIU_OSD1_MATRIX_PRE_OFFSET2));
|
||||
writel(((m[3] & 0x1fff) << 16) | (m[4] & 0x1fff),
|
||||
priv->io_base + _REG(VIU_OSD1_MATRIX_COEF00_01));
|
||||
writel(((m[5] & 0x1fff) << 16) | (m[6] & 0x1fff),
|
||||
priv->io_base + _REG(VIU_OSD1_MATRIX_COEF02_10));
|
||||
writel(((m[7] & 0x1fff) << 16) | (m[8] & 0x1fff),
|
||||
priv->io_base + _REG(VIU_OSD1_MATRIX_COEF11_12));
|
||||
writel(((m[9] & 0x1fff) << 16) | (m[10] & 0x1fff),
|
||||
priv->io_base + _REG(VIU_OSD1_MATRIX_COEF20_21));
|
||||
|
||||
if (m[21]) {
|
||||
writel(((m[11] & 0x1fff) << 16) | (m[12] & 0x1fff),
|
||||
priv->io_base +
|
||||
_REG(VIU_OSD1_MATRIX_COEF22_30));
|
||||
writel(((m[13] & 0x1fff) << 16) | (m[14] & 0x1fff),
|
||||
priv->io_base +
|
||||
_REG(VIU_OSD1_MATRIX_COEF31_32));
|
||||
writel(((m[15] & 0x1fff) << 16) | (m[16] & 0x1fff),
|
||||
priv->io_base +
|
||||
_REG(VIU_OSD1_MATRIX_COEF40_41));
|
||||
writel(m[17] & 0x1fff, priv->io_base +
|
||||
_REG(VIU_OSD1_MATRIX_COLMOD_COEF42));
|
||||
} else {
|
||||
writel((m[11] & 0x1fff) << 16, priv->io_base +
|
||||
_REG(VIU_OSD1_MATRIX_COEF22_30));
|
||||
}
|
||||
|
||||
writel(((m[18] & 0xfff) << 16) | (m[19] & 0xfff),
|
||||
priv->io_base + _REG(VIU_OSD1_MATRIX_OFFSET0_1));
|
||||
writel(m[20] & 0xfff,
|
||||
priv->io_base + _REG(VIU_OSD1_MATRIX_OFFSET2));
|
||||
|
||||
writel_bits(3 << 30, m[21] << 30,
|
||||
priv->io_base +
|
||||
_REG(VIU_OSD1_MATRIX_COLMOD_COEF42));
|
||||
writel_bits(7 << 16, m[22] << 16,
|
||||
priv->io_base +
|
||||
_REG(VIU_OSD1_MATRIX_COLMOD_COEF42));
|
||||
|
||||
/* 23 reserved for clipping control */
|
||||
writel_bits(BIT(0), csc_on ? BIT(0) : 0,
|
||||
priv->io_base + _REG(VIU_OSD1_MATRIX_CTRL));
|
||||
writel_bits(BIT(1), 0,
|
||||
priv->io_base + _REG(VIU_OSD1_MATRIX_CTRL));
|
||||
} else if (m_select == VIU_MATRIX_OSD_EOTF) {
|
||||
int i;
|
||||
|
||||
/* osd eotf matrix, VIU_MATRIX_OSD_EOTF */
|
||||
for (i = 0; i < 5; i++)
|
||||
writel(((m[i * 2] & 0x1fff) << 16) |
|
||||
(m[i * 2 + 1] & 0x1fff), priv->io_base +
|
||||
_REG(VIU_OSD1_EOTF_CTL + i + 1));
|
||||
|
||||
writel_bits(BIT(30), csc_on ? BIT(30) : 0,
|
||||
priv->io_base + _REG(VIU_OSD1_EOTF_CTL));
|
||||
writel_bits(BIT(31), csc_on ? BIT(31) : 0,
|
||||
priv->io_base + _REG(VIU_OSD1_EOTF_CTL));
|
||||
}
|
||||
}
|
||||
|
||||
#define OSD_EOTF_LUT_SIZE 33
|
||||
#define OSD_OETF_LUT_SIZE 41
|
||||
|
||||
static void meson_viu_set_osd_lut(struct meson_vpu_priv *priv,
|
||||
enum viu_lut_sel_e lut_sel,
|
||||
unsigned int *r_map, unsigned int *g_map,
|
||||
unsigned int *b_map,
|
||||
bool csc_on)
|
||||
{
|
||||
unsigned int addr_port;
|
||||
unsigned int data_port;
|
||||
unsigned int ctrl_port;
|
||||
int i;
|
||||
|
||||
if (lut_sel == VIU_LUT_OSD_EOTF) {
|
||||
addr_port = VIU_OSD1_EOTF_LUT_ADDR_PORT;
|
||||
data_port = VIU_OSD1_EOTF_LUT_DATA_PORT;
|
||||
ctrl_port = VIU_OSD1_EOTF_CTL;
|
||||
} else if (lut_sel == VIU_LUT_OSD_OETF) {
|
||||
addr_port = VIU_OSD1_OETF_LUT_ADDR_PORT;
|
||||
data_port = VIU_OSD1_OETF_LUT_DATA_PORT;
|
||||
ctrl_port = VIU_OSD1_OETF_CTL;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lut_sel == VIU_LUT_OSD_OETF) {
|
||||
writel(0, priv->io_base + _REG(addr_port));
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
writel(r_map[i * 2] | (r_map[i * 2 + 1] << 16),
|
||||
priv->io_base + _REG(data_port));
|
||||
|
||||
writel(r_map[OSD_OETF_LUT_SIZE - 1] | (g_map[0] << 16),
|
||||
priv->io_base + _REG(data_port));
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
writel(g_map[i * 2 + 1] | (g_map[i * 2 + 2] << 16),
|
||||
priv->io_base + _REG(data_port));
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
writel(b_map[i * 2] | (b_map[i * 2 + 1] << 16),
|
||||
priv->io_base + _REG(data_port));
|
||||
|
||||
writel(b_map[OSD_OETF_LUT_SIZE - 1],
|
||||
priv->io_base + _REG(data_port));
|
||||
|
||||
if (csc_on)
|
||||
writel_bits(0x7 << 29, 7 << 29,
|
||||
priv->io_base + _REG(ctrl_port));
|
||||
else
|
||||
writel_bits(0x7 << 29, 0,
|
||||
priv->io_base + _REG(ctrl_port));
|
||||
} else if (lut_sel == VIU_LUT_OSD_EOTF) {
|
||||
writel(0, priv->io_base + _REG(addr_port));
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
writel(r_map[i * 2] | (r_map[i * 2 + 1] << 16),
|
||||
priv->io_base + _REG(data_port));
|
||||
|
||||
writel(r_map[OSD_EOTF_LUT_SIZE - 1] | (g_map[0] << 16),
|
||||
priv->io_base + _REG(data_port));
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
writel(g_map[i * 2 + 1] | (g_map[i * 2 + 2] << 16),
|
||||
priv->io_base + _REG(data_port));
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
writel(b_map[i * 2] | (b_map[i * 2 + 1] << 16),
|
||||
priv->io_base + _REG(data_port));
|
||||
|
||||
writel(b_map[OSD_EOTF_LUT_SIZE - 1],
|
||||
priv->io_base + _REG(data_port));
|
||||
|
||||
if (csc_on)
|
||||
writel_bits(7 << 27, 7 << 27,
|
||||
priv->io_base + _REG(ctrl_port));
|
||||
else
|
||||
writel_bits(7 << 27, 0,
|
||||
priv->io_base + _REG(ctrl_port));
|
||||
|
||||
writel_bits(BIT(31), BIT(31),
|
||||
priv->io_base + _REG(ctrl_port));
|
||||
}
|
||||
}
|
||||
|
||||
/* eotf lut: linear */
|
||||
static unsigned int eotf_33_linear_mapping[OSD_EOTF_LUT_SIZE] = {
|
||||
0x0000, 0x0200, 0x0400, 0x0600,
|
||||
0x0800, 0x0a00, 0x0c00, 0x0e00,
|
||||
0x1000, 0x1200, 0x1400, 0x1600,
|
||||
0x1800, 0x1a00, 0x1c00, 0x1e00,
|
||||
0x2000, 0x2200, 0x2400, 0x2600,
|
||||
0x2800, 0x2a00, 0x2c00, 0x2e00,
|
||||
0x3000, 0x3200, 0x3400, 0x3600,
|
||||
0x3800, 0x3a00, 0x3c00, 0x3e00,
|
||||
0x4000
|
||||
};
|
||||
|
||||
/* osd oetf lut: linear */
|
||||
static unsigned int oetf_41_linear_mapping[OSD_OETF_LUT_SIZE] = {
|
||||
0, 0, 0, 0,
|
||||
0, 32, 64, 96,
|
||||
128, 160, 196, 224,
|
||||
256, 288, 320, 352,
|
||||
384, 416, 448, 480,
|
||||
512, 544, 576, 608,
|
||||
640, 672, 704, 736,
|
||||
768, 800, 832, 864,
|
||||
896, 928, 960, 992,
|
||||
1023, 1023, 1023, 1023,
|
||||
1023
|
||||
};
|
||||
|
||||
static void meson_viu_load_matrix(struct meson_vpu_priv *priv)
|
||||
{
|
||||
/* eotf lut bypass */
|
||||
meson_viu_set_osd_lut(priv, VIU_LUT_OSD_EOTF,
|
||||
eotf_33_linear_mapping, /* R */
|
||||
eotf_33_linear_mapping, /* G */
|
||||
eotf_33_linear_mapping, /* B */
|
||||
false);
|
||||
|
||||
/* eotf matrix bypass */
|
||||
meson_viu_set_osd_matrix(priv, VIU_MATRIX_OSD_EOTF,
|
||||
eotf_bypass_coeff,
|
||||
false);
|
||||
|
||||
/* oetf lut bypass */
|
||||
meson_viu_set_osd_lut(priv, VIU_LUT_OSD_OETF,
|
||||
oetf_41_linear_mapping, /* R */
|
||||
oetf_41_linear_mapping, /* G */
|
||||
oetf_41_linear_mapping, /* B */
|
||||
false);
|
||||
|
||||
/* osd matrix RGB709 to YUV709 limit */
|
||||
meson_viu_set_osd_matrix(priv, VIU_MATRIX_OSD,
|
||||
RGB709_to_YUV709l_coeff,
|
||||
true);
|
||||
}
|
||||
|
||||
static inline uint32_t meson_viu_osd_burst_length_reg(uint32_t length)
|
||||
{
|
||||
u32 val = (((length & 0x80) % 24) / 12);
|
||||
|
||||
return (((val & 0x3) << 10) | (((val & 0x4) >> 2) << 31));
|
||||
}
|
||||
|
||||
void meson_vpu_init(struct udevice *dev)
|
||||
{
|
||||
struct meson_vpu_priv *priv = dev_get_priv(dev);
|
||||
u32 reg;
|
||||
|
||||
/*
|
||||
* Slave dc0 and dc5 connected to master port 1.
|
||||
* By default other slaves are connected to master port 0.
|
||||
*/
|
||||
reg = VPU_RDARB_SLAVE_TO_MASTER_PORT(0, 1) |
|
||||
VPU_RDARB_SLAVE_TO_MASTER_PORT(5, 1);
|
||||
writel(reg, priv->io_base + _REG(VPU_RDARB_MODE_L1C1));
|
||||
|
||||
/* Slave dc0 connected to master port 1 */
|
||||
reg = VPU_RDARB_SLAVE_TO_MASTER_PORT(0, 1);
|
||||
writel(reg, priv->io_base + _REG(VPU_RDARB_MODE_L1C2));
|
||||
|
||||
/* Slave dc4 and dc7 connected to master port 1 */
|
||||
reg = VPU_RDARB_SLAVE_TO_MASTER_PORT(4, 1) |
|
||||
VPU_RDARB_SLAVE_TO_MASTER_PORT(7, 1);
|
||||
writel(reg, priv->io_base + _REG(VPU_RDARB_MODE_L2C1));
|
||||
|
||||
/* Slave dc1 connected to master port 1 */
|
||||
reg = VPU_RDARB_SLAVE_TO_MASTER_PORT(1, 1);
|
||||
writel(reg, priv->io_base + _REG(VPU_WRARB_MODE_L2C1));
|
||||
|
||||
/* Disable CVBS VDAC */
|
||||
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
|
||||
hhi_write(HHI_VDAC_CNTL0_G12A, 0);
|
||||
hhi_write(HHI_VDAC_CNTL1_G12A, 8);
|
||||
} else {
|
||||
hhi_write(HHI_VDAC_CNTL0, 0);
|
||||
hhi_write(HHI_VDAC_CNTL1, 8);
|
||||
}
|
||||
|
||||
/* Power Down Dacs */
|
||||
writel(0xff, priv->io_base + _REG(VENC_VDAC_SETTING));
|
||||
|
||||
/* Disable HDMI PHY */
|
||||
hhi_write(HHI_HDMI_PHY_CNTL0, 0);
|
||||
|
||||
/* Disable HDMI */
|
||||
writel_bits(VPU_HDMI_ENCI_DATA_TO_HDMI |
|
||||
VPU_HDMI_ENCP_DATA_TO_HDMI, 0,
|
||||
priv->io_base + _REG(VPU_HDMI_SETTING));
|
||||
|
||||
/* Disable all encoders */
|
||||
writel(0, priv->io_base + _REG(ENCI_VIDEO_EN));
|
||||
writel(0, priv->io_base + _REG(ENCP_VIDEO_EN));
|
||||
writel(0, priv->io_base + _REG(ENCL_VIDEO_EN));
|
||||
|
||||
/* Disable VSync IRQ */
|
||||
writel(0, priv->io_base + _REG(VENC_INTCTRL));
|
||||
|
||||
/* set dummy data default YUV black */
|
||||
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXL)) {
|
||||
writel(0x108080, priv->io_base + _REG(VPP_DUMMY_DATA1));
|
||||
} else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM)) {
|
||||
writel_bits(0xff << 16, 0xff << 16,
|
||||
priv->io_base + _REG(VIU_MISC_CTRL1));
|
||||
writel(VPP_PPS_DUMMY_DATA_MODE,
|
||||
priv->io_base + _REG(VPP_DOLBY_CTRL));
|
||||
writel(0x1020080,
|
||||
priv->io_base + _REG(VPP_DUMMY_DATA1));
|
||||
} else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
|
||||
writel(0xf, priv->io_base + _REG(DOLBY_PATH_CTRL));
|
||||
|
||||
/* Initialize vpu fifo control registers */
|
||||
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
|
||||
writel(VPP_OFIFO_SIZE_DEFAULT,
|
||||
priv->io_base + _REG(VPP_OFIFO_SIZE));
|
||||
else
|
||||
writel_bits(VPP_OFIFO_SIZE_MASK, 0x77f,
|
||||
priv->io_base + _REG(VPP_OFIFO_SIZE));
|
||||
writel(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(VPP_PREBLEND_ENABLE, 0,
|
||||
priv->io_base + _REG(VPP_MISC));
|
||||
|
||||
/* Turn off POSTBLEND */
|
||||
writel_bits(VPP_POSTBLEND_ENABLE, 0,
|
||||
priv->io_base + _REG(VPP_MISC));
|
||||
|
||||
/* Force all planes off */
|
||||
writel_bits(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(4096,
|
||||
priv->io_base + _REG(VPP_PREBLEND_VD1_H_START_END));
|
||||
writel(4096,
|
||||
priv->io_base + _REG(VPP_BLEND_VD2_H_START_END));
|
||||
}
|
||||
|
||||
/* Disable Scalers */
|
||||
writel(0, priv->io_base + _REG(VPP_OSD_SC_CTRL0));
|
||||
writel(0, priv->io_base + _REG(VPP_OSD_VSC_CTRL0));
|
||||
writel(0, priv->io_base + _REG(VPP_OSD_HSC_CTRL0));
|
||||
|
||||
writel(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(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);
|
||||
|
||||
/* Disable OSDs */
|
||||
writel_bits(VIU_OSD1_OSD_BLK_ENABLE | VIU_OSD1_OSD_ENABLE, 0,
|
||||
priv->io_base + _REG(VIU_OSD1_CTRL_STAT));
|
||||
writel_bits(VIU_OSD1_OSD_BLK_ENABLE | VIU_OSD1_OSD_ENABLE, 0,
|
||||
priv->io_base + _REG(VIU_OSD2_CTRL_STAT));
|
||||
|
||||
/* On GXL/GXM, Use the 10bit HDR conversion matrix */
|
||||
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM) ||
|
||||
meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXL))
|
||||
meson_viu_load_matrix(priv);
|
||||
else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
|
||||
meson_viu_set_g12a_osd1_matrix(priv, RGB709_to_YUV709l_coeff,
|
||||
true);
|
||||
|
||||
/* Initialize OSD1 fifo control register */
|
||||
reg = VIU_OSD_DDR_PRIORITY_URGENT |
|
||||
VIU_OSD_HOLD_FIFO_LINES(4) |
|
||||
VIU_OSD_FIFO_DEPTH_VAL(32) | /* fifo_depth_val: 32*8=256 */
|
||||
VIU_OSD_WORDS_PER_BURST(4) | /* 4 words in 1 burst */
|
||||
VIU_OSD_FIFO_LIMITS(2); /* fifo_lim: 2*16=32 */
|
||||
|
||||
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A))
|
||||
reg |= meson_viu_osd_burst_length_reg(32);
|
||||
else
|
||||
reg |= meson_viu_osd_burst_length_reg(64);
|
||||
|
||||
writel(reg, priv->io_base + _REG(VIU_OSD1_FIFO_CTRL_STAT));
|
||||
writel(reg, priv->io_base + _REG(VIU_OSD2_FIFO_CTRL_STAT));
|
||||
|
||||
/* Set OSD alpha replace value */
|
||||
writel_bits(0xff << OSD_REPLACE_SHIFT,
|
||||
0xff << OSD_REPLACE_SHIFT,
|
||||
priv->io_base + _REG(VIU_OSD1_CTRL_STAT2));
|
||||
writel_bits(0xff << OSD_REPLACE_SHIFT,
|
||||
0xff << OSD_REPLACE_SHIFT,
|
||||
priv->io_base + _REG(VIU_OSD2_CTRL_STAT2));
|
||||
|
||||
/* Disable VD1 AFBC */
|
||||
/* di_mif0_en=0 mif0_to_vpp_en=0 di_mad_en=0 and afbc vd1 set=0*/
|
||||
writel_bits(VIU_CTRL0_VD1_AFBC_MASK, 0,
|
||||
priv->io_base + _REG(VIU_MISC_CTRL0));
|
||||
writel(0, priv->io_base + _REG(AFBC_ENABLE));
|
||||
|
||||
writel(0x00FF00C0,
|
||||
priv->io_base + _REG(VD1_IF0_LUMA_FIFO_SIZE));
|
||||
writel(0x00FF00C0,
|
||||
priv->io_base + _REG(VD2_IF0_LUMA_FIFO_SIZE));
|
||||
|
||||
if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
|
||||
writel(VIU_OSD_BLEND_REORDER(0, 1) |
|
||||
VIU_OSD_BLEND_REORDER(1, 0) |
|
||||
VIU_OSD_BLEND_REORDER(2, 0) |
|
||||
VIU_OSD_BLEND_REORDER(3, 0) |
|
||||
VIU_OSD_BLEND_DIN_EN(1) |
|
||||
VIU_OSD_BLEND1_DIN3_BYPASS_TO_DOUT1 |
|
||||
VIU_OSD_BLEND1_DOUT_BYPASS_TO_BLEND2 |
|
||||
VIU_OSD_BLEND_DIN0_BYPASS_TO_DOUT0 |
|
||||
VIU_OSD_BLEND_BLEN2_PREMULT_EN(1) |
|
||||
VIU_OSD_BLEND_HOLD_LINES(4),
|
||||
priv->io_base + _REG(VIU_OSD_BLEND_CTRL));
|
||||
writel(OSD_BLEND_PATH_SEL_ENABLE,
|
||||
priv->io_base + _REG(OSD1_BLEND_SRC_CTRL));
|
||||
writel(OSD_BLEND_PATH_SEL_ENABLE,
|
||||
priv->io_base + _REG(OSD2_BLEND_SRC_CTRL));
|
||||
writel(0, priv->io_base + _REG(VD1_BLEND_SRC_CTRL));
|
||||
writel(0, priv->io_base + _REG(VD2_BLEND_SRC_CTRL));
|
||||
writel(0, priv->io_base + _REG(VIU_OSD_BLEND_DUMMY_DATA0));
|
||||
writel(0, priv->io_base + _REG(VIU_OSD_BLEND_DUMMY_ALPHA));
|
||||
writel_bits(DOLBY_BYPASS_EN(0xc), DOLBY_BYPASS_EN(0xc),
|
||||
priv->io_base + _REG(DOLBY_PATH_CTRL));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Common code for Amlogic SimpleFB with pipeline.
|
||||
*
|
||||
* (C) Copyright 2013-2014 Luc Verhaegen <libv@skynet.be>
|
||||
* (C) Copyright 2014-2015 Hans de Goede <hdegoede@redhat.com>
|
||||
* (C) Copyright 2017 Icenowy Zheng <icenowy@aosc.io>
|
||||
*/
|
||||
|
||||
#include <fdtdec.h>
|
||||
|
||||
int meson_simplefb_fdt_match(void *blob, const char *pipeline)
|
||||
{
|
||||
int offset, ret;
|
||||
|
||||
/* Find a prefilled simpefb node, matching out pipeline config */
|
||||
offset = fdt_node_offset_by_compatible(blob, -1,
|
||||
"amlogic,simple-framebuffer");
|
||||
while (offset >= 0) {
|
||||
ret = fdt_stringlist_search(blob, offset, "amlogic,pipeline",
|
||||
pipeline);
|
||||
if (ret == 0)
|
||||
break;
|
||||
offset = fdt_node_offset_by_compatible(blob, offset,
|
||||
"amlogic,simple-framebuffer");
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* (C) Copyright 2017 Icenowy Zheng <icenowy@aosc.io>
|
||||
*/
|
||||
|
||||
#ifndef __SIMPLEFB_COMMON_H
|
||||
#define __SIMPLEFB_COMMON_H
|
||||
|
||||
/**
|
||||
* meson_simplefb_fdt_match() - match a meson simplefb node
|
||||
*
|
||||
* Match a meson simplefb device node with a specified pipeline, and
|
||||
* return its offset.
|
||||
*
|
||||
* @blob: device tree blob
|
||||
* @pipeline: display pipeline
|
||||
* @return device node offset in blob, or negative values if failed
|
||||
*/
|
||||
int meson_simplefb_fdt_match(void *blob, const char *pipeline);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user