18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org> 48c2ecf20Sopenharmony_ci * Parts of this file were based on sources as follows: 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2006-2008 Intel Corporation 78c2ecf20Sopenharmony_ci * Copyright (C) 2007 Amos Lee <amos_lee@storlinksemi.com> 88c2ecf20Sopenharmony_ci * Copyright (C) 2007 Dave Airlie <airlied@linux.ie> 98c2ecf20Sopenharmony_ci * Copyright (C) 2011 Texas Instruments 108c2ecf20Sopenharmony_ci * Copyright (C) 2017 Eric Anholt 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/clk.h> 148c2ecf20Sopenharmony_ci#include <linux/version.h> 158c2ecf20Sopenharmony_ci#include <linux/dma-buf.h> 168c2ecf20Sopenharmony_ci#include <linux/of_graph.h> 178c2ecf20Sopenharmony_ci#include <linux/delay.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#include <drm/drm_fb_cma_helper.h> 208c2ecf20Sopenharmony_ci#include <drm/drm_fourcc.h> 218c2ecf20Sopenharmony_ci#include <drm/drm_gem_cma_helper.h> 228c2ecf20Sopenharmony_ci#include <drm/drm_gem_framebuffer_helper.h> 238c2ecf20Sopenharmony_ci#include <drm/drm_panel.h> 248c2ecf20Sopenharmony_ci#include <drm/drm_vblank.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#include "tve200_drm.h" 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ciirqreturn_t tve200_irq(int irq, void *data) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci struct tve200_drm_dev_private *priv = data; 318c2ecf20Sopenharmony_ci u32 stat; 328c2ecf20Sopenharmony_ci u32 val; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci stat = readl(priv->regs + TVE200_INT_STAT); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci if (!stat) 378c2ecf20Sopenharmony_ci return IRQ_NONE; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci /* 408c2ecf20Sopenharmony_ci * Vblank IRQ 418c2ecf20Sopenharmony_ci * 428c2ecf20Sopenharmony_ci * The hardware is a bit tilted: the line stays high after clearing 438c2ecf20Sopenharmony_ci * the vblank IRQ, firing many more interrupts. We counter this 448c2ecf20Sopenharmony_ci * by toggling the IRQ back and forth from firing at vblank and 458c2ecf20Sopenharmony_ci * firing at start of active image, which works around the problem 468c2ecf20Sopenharmony_ci * since those occur strictly in sequence, and we get two IRQs for each 478c2ecf20Sopenharmony_ci * frame, one at start of Vblank (that we make call into the CRTC) and 488c2ecf20Sopenharmony_ci * another one at the start of the image (that we discard). 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_ci if (stat & TVE200_INT_V_STATUS) { 518c2ecf20Sopenharmony_ci val = readl(priv->regs + TVE200_CTRL); 528c2ecf20Sopenharmony_ci /* We have an actual start of vsync */ 538c2ecf20Sopenharmony_ci if (!(val & TVE200_VSTSTYPE_BITS)) { 548c2ecf20Sopenharmony_ci drm_crtc_handle_vblank(&priv->pipe.crtc); 558c2ecf20Sopenharmony_ci /* Toggle trigger to start of active image */ 568c2ecf20Sopenharmony_ci val |= TVE200_VSTSTYPE_VAI; 578c2ecf20Sopenharmony_ci } else { 588c2ecf20Sopenharmony_ci /* Toggle trigger back to start of vsync */ 598c2ecf20Sopenharmony_ci val &= ~TVE200_VSTSTYPE_BITS; 608c2ecf20Sopenharmony_ci } 618c2ecf20Sopenharmony_ci writel(val, priv->regs + TVE200_CTRL); 628c2ecf20Sopenharmony_ci } else 638c2ecf20Sopenharmony_ci dev_err(priv->drm->dev, "stray IRQ %08x\n", stat); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci /* Clear the interrupt once done */ 668c2ecf20Sopenharmony_ci writel(stat, priv->regs + TVE200_INT_CLR); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci return IRQ_HANDLED; 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_cistatic int tve200_display_check(struct drm_simple_display_pipe *pipe, 728c2ecf20Sopenharmony_ci struct drm_plane_state *pstate, 738c2ecf20Sopenharmony_ci struct drm_crtc_state *cstate) 748c2ecf20Sopenharmony_ci{ 758c2ecf20Sopenharmony_ci const struct drm_display_mode *mode = &cstate->mode; 768c2ecf20Sopenharmony_ci struct drm_framebuffer *old_fb = pipe->plane.state->fb; 778c2ecf20Sopenharmony_ci struct drm_framebuffer *fb = pstate->fb; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci /* 808c2ecf20Sopenharmony_ci * We support these specific resolutions and nothing else. 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ci if (!(mode->hdisplay == 352 && mode->vdisplay == 240) && /* SIF(525) */ 838c2ecf20Sopenharmony_ci !(mode->hdisplay == 352 && mode->vdisplay == 288) && /* CIF(625) */ 848c2ecf20Sopenharmony_ci !(mode->hdisplay == 640 && mode->vdisplay == 480) && /* VGA */ 858c2ecf20Sopenharmony_ci !(mode->hdisplay == 720 && mode->vdisplay == 480) && /* D1 */ 868c2ecf20Sopenharmony_ci !(mode->hdisplay == 720 && mode->vdisplay == 576)) { /* D1 */ 878c2ecf20Sopenharmony_ci DRM_DEBUG_KMS("unsupported display mode (%u x %u)\n", 888c2ecf20Sopenharmony_ci mode->hdisplay, mode->vdisplay); 898c2ecf20Sopenharmony_ci return -EINVAL; 908c2ecf20Sopenharmony_ci } 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci if (fb) { 938c2ecf20Sopenharmony_ci u32 offset = drm_fb_cma_get_gem_addr(fb, pstate, 0); 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci /* FB base address must be dword aligned. */ 968c2ecf20Sopenharmony_ci if (offset & 3) { 978c2ecf20Sopenharmony_ci DRM_DEBUG_KMS("FB not 32-bit aligned\n"); 988c2ecf20Sopenharmony_ci return -EINVAL; 998c2ecf20Sopenharmony_ci } 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci /* 1028c2ecf20Sopenharmony_ci * There's no pitch register, the mode's hdisplay 1038c2ecf20Sopenharmony_ci * controls this. 1048c2ecf20Sopenharmony_ci */ 1058c2ecf20Sopenharmony_ci if (fb->pitches[0] != mode->hdisplay * fb->format->cpp[0]) { 1068c2ecf20Sopenharmony_ci DRM_DEBUG_KMS("can't handle pitches\n"); 1078c2ecf20Sopenharmony_ci return -EINVAL; 1088c2ecf20Sopenharmony_ci } 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci /* 1118c2ecf20Sopenharmony_ci * We can't change the FB format in a flicker-free 1128c2ecf20Sopenharmony_ci * manner (and only update it during CRTC enable). 1138c2ecf20Sopenharmony_ci */ 1148c2ecf20Sopenharmony_ci if (old_fb && old_fb->format != fb->format) 1158c2ecf20Sopenharmony_ci cstate->mode_changed = true; 1168c2ecf20Sopenharmony_ci } 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci return 0; 1198c2ecf20Sopenharmony_ci} 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_cistatic void tve200_display_enable(struct drm_simple_display_pipe *pipe, 1228c2ecf20Sopenharmony_ci struct drm_crtc_state *cstate, 1238c2ecf20Sopenharmony_ci struct drm_plane_state *plane_state) 1248c2ecf20Sopenharmony_ci{ 1258c2ecf20Sopenharmony_ci struct drm_crtc *crtc = &pipe->crtc; 1268c2ecf20Sopenharmony_ci struct drm_plane *plane = &pipe->plane; 1278c2ecf20Sopenharmony_ci struct drm_device *drm = crtc->dev; 1288c2ecf20Sopenharmony_ci struct tve200_drm_dev_private *priv = drm->dev_private; 1298c2ecf20Sopenharmony_ci const struct drm_display_mode *mode = &cstate->mode; 1308c2ecf20Sopenharmony_ci struct drm_framebuffer *fb = plane->state->fb; 1318c2ecf20Sopenharmony_ci struct drm_connector *connector = priv->connector; 1328c2ecf20Sopenharmony_ci u32 format = fb->format->format; 1338c2ecf20Sopenharmony_ci u32 ctrl1 = 0; 1348c2ecf20Sopenharmony_ci int retries; 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci clk_prepare_enable(priv->clk); 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci /* Reset the TVE200 and wait for it to come back online */ 1398c2ecf20Sopenharmony_ci writel(TVE200_CTRL_4_RESET, priv->regs + TVE200_CTRL_4); 1408c2ecf20Sopenharmony_ci for (retries = 0; retries < 5; retries++) { 1418c2ecf20Sopenharmony_ci usleep_range(30000, 50000); 1428c2ecf20Sopenharmony_ci if (readl(priv->regs + TVE200_CTRL_4) & TVE200_CTRL_4_RESET) 1438c2ecf20Sopenharmony_ci continue; 1448c2ecf20Sopenharmony_ci else 1458c2ecf20Sopenharmony_ci break; 1468c2ecf20Sopenharmony_ci } 1478c2ecf20Sopenharmony_ci if (retries == 5 && 1488c2ecf20Sopenharmony_ci readl(priv->regs + TVE200_CTRL_4) & TVE200_CTRL_4_RESET) { 1498c2ecf20Sopenharmony_ci dev_err(drm->dev, "can't get hardware out of reset\n"); 1508c2ecf20Sopenharmony_ci return; 1518c2ecf20Sopenharmony_ci } 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci /* Function 1 */ 1548c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_CSMODE; 1558c2ecf20Sopenharmony_ci /* Interlace mode for CCIR656: parameterize? */ 1568c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_NONINTERLACE; 1578c2ecf20Sopenharmony_ci /* 32 words per burst */ 1588c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_BURST_32_WORDS; 1598c2ecf20Sopenharmony_ci /* 16 retries */ 1608c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_RETRYCNT_16; 1618c2ecf20Sopenharmony_ci /* NTSC mode: parametrize? */ 1628c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_NTSC; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci /* Vsync IRQ at start of Vsync at first */ 1658c2ecf20Sopenharmony_ci ctrl1 |= TVE200_VSTSTYPE_VSYNC; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci if (connector->display_info.bus_flags & 1688c2ecf20Sopenharmony_ci DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE) 1698c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_TVCLKP; 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci if ((mode->hdisplay == 352 && mode->vdisplay == 240) || /* SIF(525) */ 1728c2ecf20Sopenharmony_ci (mode->hdisplay == 352 && mode->vdisplay == 288)) { /* CIF(625) */ 1738c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_IPRESOL_CIF; 1748c2ecf20Sopenharmony_ci dev_info(drm->dev, "CIF mode\n"); 1758c2ecf20Sopenharmony_ci } else if (mode->hdisplay == 640 && mode->vdisplay == 480) { 1768c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_IPRESOL_VGA; 1778c2ecf20Sopenharmony_ci dev_info(drm->dev, "VGA mode\n"); 1788c2ecf20Sopenharmony_ci } else if ((mode->hdisplay == 720 && mode->vdisplay == 480) || 1798c2ecf20Sopenharmony_ci (mode->hdisplay == 720 && mode->vdisplay == 576)) { 1808c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_IPRESOL_D1; 1818c2ecf20Sopenharmony_ci dev_info(drm->dev, "D1 mode\n"); 1828c2ecf20Sopenharmony_ci } 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci if (format & DRM_FORMAT_BIG_ENDIAN) { 1858c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_BBBP; 1868c2ecf20Sopenharmony_ci format &= ~DRM_FORMAT_BIG_ENDIAN; 1878c2ecf20Sopenharmony_ci } 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci switch (format) { 1908c2ecf20Sopenharmony_ci case DRM_FORMAT_XRGB8888: 1918c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_RGB888; 1928c2ecf20Sopenharmony_ci break; 1938c2ecf20Sopenharmony_ci case DRM_FORMAT_RGB565: 1948c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_RGB565; 1958c2ecf20Sopenharmony_ci break; 1968c2ecf20Sopenharmony_ci case DRM_FORMAT_XRGB1555: 1978c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_RGB555; 1988c2ecf20Sopenharmony_ci break; 1998c2ecf20Sopenharmony_ci case DRM_FORMAT_XBGR8888: 2008c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_RGB888 | TVE200_BGR; 2018c2ecf20Sopenharmony_ci break; 2028c2ecf20Sopenharmony_ci case DRM_FORMAT_BGR565: 2038c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_RGB565 | TVE200_BGR; 2048c2ecf20Sopenharmony_ci break; 2058c2ecf20Sopenharmony_ci case DRM_FORMAT_XBGR1555: 2068c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_RGB555 | TVE200_BGR; 2078c2ecf20Sopenharmony_ci break; 2088c2ecf20Sopenharmony_ci case DRM_FORMAT_YUYV: 2098c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_YUV422; 2108c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_YCBCRODR_CR0Y1CB0Y0; 2118c2ecf20Sopenharmony_ci break; 2128c2ecf20Sopenharmony_ci case DRM_FORMAT_YVYU: 2138c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_YUV422; 2148c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_YCBCRODR_CB0Y1CR0Y0; 2158c2ecf20Sopenharmony_ci break; 2168c2ecf20Sopenharmony_ci case DRM_FORMAT_UYVY: 2178c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_YUV422; 2188c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_YCBCRODR_Y1CR0Y0CB0; 2198c2ecf20Sopenharmony_ci break; 2208c2ecf20Sopenharmony_ci case DRM_FORMAT_VYUY: 2218c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_YUV422; 2228c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_YCBCRODR_Y1CB0Y0CR0; 2238c2ecf20Sopenharmony_ci break; 2248c2ecf20Sopenharmony_ci case DRM_FORMAT_YUV420: 2258c2ecf20Sopenharmony_ci ctrl1 |= TVE200_CTRL_YUV420; 2268c2ecf20Sopenharmony_ci ctrl1 |= TVE200_IPDMOD_YUV420; 2278c2ecf20Sopenharmony_ci break; 2288c2ecf20Sopenharmony_ci default: 2298c2ecf20Sopenharmony_ci dev_err(drm->dev, "Unknown FB format 0x%08x\n", 2308c2ecf20Sopenharmony_ci fb->format->format); 2318c2ecf20Sopenharmony_ci break; 2328c2ecf20Sopenharmony_ci } 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci ctrl1 |= TVE200_TVEEN; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci /* Turn it on */ 2378c2ecf20Sopenharmony_ci writel(ctrl1, priv->regs + TVE200_CTRL); 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci drm_crtc_vblank_on(crtc); 2408c2ecf20Sopenharmony_ci} 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_cistatic void tve200_display_disable(struct drm_simple_display_pipe *pipe) 2438c2ecf20Sopenharmony_ci{ 2448c2ecf20Sopenharmony_ci struct drm_crtc *crtc = &pipe->crtc; 2458c2ecf20Sopenharmony_ci struct drm_device *drm = crtc->dev; 2468c2ecf20Sopenharmony_ci struct tve200_drm_dev_private *priv = drm->dev_private; 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci drm_crtc_vblank_off(crtc); 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci /* Disable put into reset and Power Down */ 2518c2ecf20Sopenharmony_ci writel(0, priv->regs + TVE200_CTRL); 2528c2ecf20Sopenharmony_ci writel(TVE200_CTRL_4_RESET, priv->regs + TVE200_CTRL_4); 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci clk_disable_unprepare(priv->clk); 2558c2ecf20Sopenharmony_ci} 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_cistatic void tve200_display_update(struct drm_simple_display_pipe *pipe, 2588c2ecf20Sopenharmony_ci struct drm_plane_state *old_pstate) 2598c2ecf20Sopenharmony_ci{ 2608c2ecf20Sopenharmony_ci struct drm_crtc *crtc = &pipe->crtc; 2618c2ecf20Sopenharmony_ci struct drm_device *drm = crtc->dev; 2628c2ecf20Sopenharmony_ci struct tve200_drm_dev_private *priv = drm->dev_private; 2638c2ecf20Sopenharmony_ci struct drm_pending_vblank_event *event = crtc->state->event; 2648c2ecf20Sopenharmony_ci struct drm_plane *plane = &pipe->plane; 2658c2ecf20Sopenharmony_ci struct drm_plane_state *pstate = plane->state; 2668c2ecf20Sopenharmony_ci struct drm_framebuffer *fb = pstate->fb; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci if (fb) { 2698c2ecf20Sopenharmony_ci /* For RGB, the Y component is used as base address */ 2708c2ecf20Sopenharmony_ci writel(drm_fb_cma_get_gem_addr(fb, pstate, 0), 2718c2ecf20Sopenharmony_ci priv->regs + TVE200_Y_FRAME_BASE_ADDR); 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci /* For three plane YUV we need two more addresses */ 2748c2ecf20Sopenharmony_ci if (fb->format->format == DRM_FORMAT_YUV420) { 2758c2ecf20Sopenharmony_ci writel(drm_fb_cma_get_gem_addr(fb, pstate, 1), 2768c2ecf20Sopenharmony_ci priv->regs + TVE200_U_FRAME_BASE_ADDR); 2778c2ecf20Sopenharmony_ci writel(drm_fb_cma_get_gem_addr(fb, pstate, 2), 2788c2ecf20Sopenharmony_ci priv->regs + TVE200_V_FRAME_BASE_ADDR); 2798c2ecf20Sopenharmony_ci } 2808c2ecf20Sopenharmony_ci } 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci if (event) { 2838c2ecf20Sopenharmony_ci crtc->state->event = NULL; 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci spin_lock_irq(&crtc->dev->event_lock); 2868c2ecf20Sopenharmony_ci if (crtc->state->active && drm_crtc_vblank_get(crtc) == 0) 2878c2ecf20Sopenharmony_ci drm_crtc_arm_vblank_event(crtc, event); 2888c2ecf20Sopenharmony_ci else 2898c2ecf20Sopenharmony_ci drm_crtc_send_vblank_event(crtc, event); 2908c2ecf20Sopenharmony_ci spin_unlock_irq(&crtc->dev->event_lock); 2918c2ecf20Sopenharmony_ci } 2928c2ecf20Sopenharmony_ci} 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_cistatic int tve200_display_enable_vblank(struct drm_simple_display_pipe *pipe) 2958c2ecf20Sopenharmony_ci{ 2968c2ecf20Sopenharmony_ci struct drm_crtc *crtc = &pipe->crtc; 2978c2ecf20Sopenharmony_ci struct drm_device *drm = crtc->dev; 2988c2ecf20Sopenharmony_ci struct tve200_drm_dev_private *priv = drm->dev_private; 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci /* Clear any IRQs and enable */ 3018c2ecf20Sopenharmony_ci writel(0xFF, priv->regs + TVE200_INT_CLR); 3028c2ecf20Sopenharmony_ci writel(TVE200_INT_V_STATUS, priv->regs + TVE200_INT_EN); 3038c2ecf20Sopenharmony_ci return 0; 3048c2ecf20Sopenharmony_ci} 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_cistatic void tve200_display_disable_vblank(struct drm_simple_display_pipe *pipe) 3078c2ecf20Sopenharmony_ci{ 3088c2ecf20Sopenharmony_ci struct drm_crtc *crtc = &pipe->crtc; 3098c2ecf20Sopenharmony_ci struct drm_device *drm = crtc->dev; 3108c2ecf20Sopenharmony_ci struct tve200_drm_dev_private *priv = drm->dev_private; 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci writel(0, priv->regs + TVE200_INT_EN); 3138c2ecf20Sopenharmony_ci} 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_cistatic const struct drm_simple_display_pipe_funcs tve200_display_funcs = { 3168c2ecf20Sopenharmony_ci .check = tve200_display_check, 3178c2ecf20Sopenharmony_ci .enable = tve200_display_enable, 3188c2ecf20Sopenharmony_ci .disable = tve200_display_disable, 3198c2ecf20Sopenharmony_ci .update = tve200_display_update, 3208c2ecf20Sopenharmony_ci .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb, 3218c2ecf20Sopenharmony_ci .enable_vblank = tve200_display_enable_vblank, 3228c2ecf20Sopenharmony_ci .disable_vblank = tve200_display_disable_vblank, 3238c2ecf20Sopenharmony_ci}; 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ciint tve200_display_init(struct drm_device *drm) 3268c2ecf20Sopenharmony_ci{ 3278c2ecf20Sopenharmony_ci struct tve200_drm_dev_private *priv = drm->dev_private; 3288c2ecf20Sopenharmony_ci int ret; 3298c2ecf20Sopenharmony_ci static const u32 formats[] = { 3308c2ecf20Sopenharmony_ci DRM_FORMAT_XRGB8888, 3318c2ecf20Sopenharmony_ci DRM_FORMAT_XBGR8888, 3328c2ecf20Sopenharmony_ci DRM_FORMAT_RGB565, 3338c2ecf20Sopenharmony_ci DRM_FORMAT_BGR565, 3348c2ecf20Sopenharmony_ci DRM_FORMAT_XRGB1555, 3358c2ecf20Sopenharmony_ci DRM_FORMAT_XBGR1555, 3368c2ecf20Sopenharmony_ci /* 3378c2ecf20Sopenharmony_ci * The controller actually supports any YCbCr ordering, 3388c2ecf20Sopenharmony_ci * for packed YCbCr. This just lists the orderings that 3398c2ecf20Sopenharmony_ci * DRM supports. 3408c2ecf20Sopenharmony_ci */ 3418c2ecf20Sopenharmony_ci DRM_FORMAT_YUYV, 3428c2ecf20Sopenharmony_ci DRM_FORMAT_YVYU, 3438c2ecf20Sopenharmony_ci DRM_FORMAT_UYVY, 3448c2ecf20Sopenharmony_ci DRM_FORMAT_VYUY, 3458c2ecf20Sopenharmony_ci /* This uses three planes */ 3468c2ecf20Sopenharmony_ci DRM_FORMAT_YUV420, 3478c2ecf20Sopenharmony_ci }; 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci ret = drm_simple_display_pipe_init(drm, &priv->pipe, 3508c2ecf20Sopenharmony_ci &tve200_display_funcs, 3518c2ecf20Sopenharmony_ci formats, ARRAY_SIZE(formats), 3528c2ecf20Sopenharmony_ci NULL, 3538c2ecf20Sopenharmony_ci priv->connector); 3548c2ecf20Sopenharmony_ci if (ret) 3558c2ecf20Sopenharmony_ci return ret; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci return 0; 3588c2ecf20Sopenharmony_ci} 359