18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2010-2013 Bluecherry, LLC <https://www.bluecherrydvr.com>
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Original author:
68c2ecf20Sopenharmony_ci * Ben Collins <bcollins@ubuntu.com>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Additional work by:
98c2ecf20Sopenharmony_ci * John Brooks <john.brooks@bluecherry.net>
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/kernel.h>
138c2ecf20Sopenharmony_ci#include <linux/module.h>
148c2ecf20Sopenharmony_ci#include <linux/videodev2.h>
158c2ecf20Sopenharmony_ci#include <media/v4l2-ioctl.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include "solo6x10.h"
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define SOLO_VCLK_DELAY			3
208c2ecf20Sopenharmony_ci#define SOLO_PROGRESSIVE_VSIZE		1024
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define SOLO_MOT_THRESH_W		64
238c2ecf20Sopenharmony_ci#define SOLO_MOT_THRESH_H		64
248c2ecf20Sopenharmony_ci#define SOLO_MOT_THRESH_SIZE		8192
258c2ecf20Sopenharmony_ci#define SOLO_MOT_THRESH_REAL		(SOLO_MOT_THRESH_W * SOLO_MOT_THRESH_H)
268c2ecf20Sopenharmony_ci#define SOLO_MOT_FLAG_SIZE		1024
278c2ecf20Sopenharmony_ci#define SOLO_MOT_FLAG_AREA		(SOLO_MOT_FLAG_SIZE * 16)
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cistatic void solo_vin_config(struct solo_dev *solo_dev)
308c2ecf20Sopenharmony_ci{
318c2ecf20Sopenharmony_ci	solo_dev->vin_hstart = 8;
328c2ecf20Sopenharmony_ci	solo_dev->vin_vstart = 2;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_SYS_VCLK,
358c2ecf20Sopenharmony_ci		       SOLO_VCLK_SELECT(2) |
368c2ecf20Sopenharmony_ci		       SOLO_VCLK_VIN1415_DELAY(SOLO_VCLK_DELAY) |
378c2ecf20Sopenharmony_ci		       SOLO_VCLK_VIN1213_DELAY(SOLO_VCLK_DELAY) |
388c2ecf20Sopenharmony_ci		       SOLO_VCLK_VIN1011_DELAY(SOLO_VCLK_DELAY) |
398c2ecf20Sopenharmony_ci		       SOLO_VCLK_VIN0809_DELAY(SOLO_VCLK_DELAY) |
408c2ecf20Sopenharmony_ci		       SOLO_VCLK_VIN0607_DELAY(SOLO_VCLK_DELAY) |
418c2ecf20Sopenharmony_ci		       SOLO_VCLK_VIN0405_DELAY(SOLO_VCLK_DELAY) |
428c2ecf20Sopenharmony_ci		       SOLO_VCLK_VIN0203_DELAY(SOLO_VCLK_DELAY) |
438c2ecf20Sopenharmony_ci		       SOLO_VCLK_VIN0001_DELAY(SOLO_VCLK_DELAY));
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_ACT_I_P,
468c2ecf20Sopenharmony_ci		       SOLO_VI_H_START(solo_dev->vin_hstart) |
478c2ecf20Sopenharmony_ci		       SOLO_VI_V_START(solo_dev->vin_vstart) |
488c2ecf20Sopenharmony_ci		       SOLO_VI_V_STOP(solo_dev->vin_vstart +
498c2ecf20Sopenharmony_ci				      solo_dev->video_vsize));
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_ACT_I_S,
528c2ecf20Sopenharmony_ci		       SOLO_VI_H_START(solo_dev->vout_hstart) |
538c2ecf20Sopenharmony_ci		       SOLO_VI_V_START(solo_dev->vout_vstart) |
548c2ecf20Sopenharmony_ci		       SOLO_VI_V_STOP(solo_dev->vout_vstart +
558c2ecf20Sopenharmony_ci				      solo_dev->video_vsize));
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_ACT_P,
588c2ecf20Sopenharmony_ci		       SOLO_VI_H_START(0) |
598c2ecf20Sopenharmony_ci		       SOLO_VI_V_START(1) |
608c2ecf20Sopenharmony_ci		       SOLO_VI_V_STOP(SOLO_PROGRESSIVE_VSIZE));
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_CH_FORMAT,
638c2ecf20Sopenharmony_ci		       SOLO_VI_FD_SEL_MASK(0) | SOLO_VI_PROG_MASK(0));
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	/* On 6110, initialize mozaic darkness strength */
668c2ecf20Sopenharmony_ci	if (solo_dev->type == SOLO_DEV_6010)
678c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_FMT_CFG, 0);
688c2ecf20Sopenharmony_ci	else
698c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_FMT_CFG, 16 << 22);
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_PAGE_SW, 2);
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	if (solo_dev->video_type == SOLO_VO_FMT_TYPE_NTSC) {
748c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_PB_CONFIG,
758c2ecf20Sopenharmony_ci			       SOLO_VI_PB_USER_MODE);
768c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_PB_RANGE_HV,
778c2ecf20Sopenharmony_ci			       SOLO_VI_PB_HSIZE(858) | SOLO_VI_PB_VSIZE(246));
788c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_PB_ACT_V,
798c2ecf20Sopenharmony_ci			       SOLO_VI_PB_VSTART(4) |
808c2ecf20Sopenharmony_ci			       SOLO_VI_PB_VSTOP(4 + 240));
818c2ecf20Sopenharmony_ci	} else {
828c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_PB_CONFIG,
838c2ecf20Sopenharmony_ci			       SOLO_VI_PB_USER_MODE | SOLO_VI_PB_PAL);
848c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_PB_RANGE_HV,
858c2ecf20Sopenharmony_ci			       SOLO_VI_PB_HSIZE(864) | SOLO_VI_PB_VSIZE(294));
868c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_PB_ACT_V,
878c2ecf20Sopenharmony_ci			       SOLO_VI_PB_VSTART(4) |
888c2ecf20Sopenharmony_ci			       SOLO_VI_PB_VSTOP(4 + 288));
898c2ecf20Sopenharmony_ci	}
908c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_PB_ACT_H, SOLO_VI_PB_HSTART(16) |
918c2ecf20Sopenharmony_ci		       SOLO_VI_PB_HSTOP(16 + 720));
928c2ecf20Sopenharmony_ci}
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_cistatic void solo_vout_config_cursor(struct solo_dev *dev)
958c2ecf20Sopenharmony_ci{
968c2ecf20Sopenharmony_ci	int i;
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	/* Load (blank) cursor bitmap mask (2bpp) */
998c2ecf20Sopenharmony_ci	for (i = 0; i < 20; i++)
1008c2ecf20Sopenharmony_ci		solo_reg_write(dev, SOLO_VO_CURSOR_MASK(i), 0);
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci	solo_reg_write(dev, SOLO_VO_CURSOR_POS, 0);
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci	solo_reg_write(dev, SOLO_VO_CURSOR_CLR,
1058c2ecf20Sopenharmony_ci		       (0x80 << 24) | (0x80 << 16) | (0x10 << 8) | 0x80);
1068c2ecf20Sopenharmony_ci	solo_reg_write(dev, SOLO_VO_CURSOR_CLR2, (0xe0 << 8) | 0x80);
1078c2ecf20Sopenharmony_ci}
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cistatic void solo_vout_config(struct solo_dev *solo_dev)
1108c2ecf20Sopenharmony_ci{
1118c2ecf20Sopenharmony_ci	solo_dev->vout_hstart = 6;
1128c2ecf20Sopenharmony_ci	solo_dev->vout_vstart = 8;
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_FMT_ENC,
1158c2ecf20Sopenharmony_ci		       solo_dev->video_type |
1168c2ecf20Sopenharmony_ci		       SOLO_VO_USER_COLOR_SET_NAV |
1178c2ecf20Sopenharmony_ci		       SOLO_VO_USER_COLOR_SET_NAH |
1188c2ecf20Sopenharmony_ci		       SOLO_VO_NA_COLOR_Y(0) |
1198c2ecf20Sopenharmony_ci		       SOLO_VO_NA_COLOR_CB(0) |
1208c2ecf20Sopenharmony_ci		       SOLO_VO_NA_COLOR_CR(0));
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_ACT_H,
1238c2ecf20Sopenharmony_ci		       SOLO_VO_H_START(solo_dev->vout_hstart) |
1248c2ecf20Sopenharmony_ci		       SOLO_VO_H_STOP(solo_dev->vout_hstart +
1258c2ecf20Sopenharmony_ci				      solo_dev->video_hsize));
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_ACT_V,
1288c2ecf20Sopenharmony_ci		       SOLO_VO_V_START(solo_dev->vout_vstart) |
1298c2ecf20Sopenharmony_ci		       SOLO_VO_V_STOP(solo_dev->vout_vstart +
1308c2ecf20Sopenharmony_ci				      solo_dev->video_vsize));
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_RANGE_HV,
1338c2ecf20Sopenharmony_ci		       SOLO_VO_H_LEN(solo_dev->video_hsize) |
1348c2ecf20Sopenharmony_ci		       SOLO_VO_V_LEN(solo_dev->video_vsize));
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	/* Border & background colors */
1378c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_BORDER_LINE_COLOR,
1388c2ecf20Sopenharmony_ci		       (0xa0 << 24) | (0x88 << 16) | (0xa0 << 8) | 0x88);
1398c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_BORDER_FILL_COLOR,
1408c2ecf20Sopenharmony_ci		       (0x10 << 24) | (0x8f << 16) | (0x10 << 8) | 0x8f);
1418c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_BKG_COLOR,
1428c2ecf20Sopenharmony_ci		       (16 << 24) | (128 << 16) | (16 << 8) | 128);
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_DISP_ERASE, SOLO_VO_DISP_ERASE_ON);
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_WIN_SW, 0);
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_ZOOM_CTRL, 0);
1498c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_FREEZE_CTRL, 0);
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_DISP_CTRL, SOLO_VO_DISP_ON |
1528c2ecf20Sopenharmony_ci		       SOLO_VO_DISP_ERASE_COUNT(8) |
1538c2ecf20Sopenharmony_ci		       SOLO_VO_DISP_BASE(SOLO_DISP_EXT_ADDR));
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci	solo_vout_config_cursor(solo_dev);
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci	/* Enable channels we support */
1598c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_CH_ENA,
1608c2ecf20Sopenharmony_ci		       (1 << solo_dev->nr_chans) - 1);
1618c2ecf20Sopenharmony_ci}
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cistatic int solo_dma_vin_region(struct solo_dev *solo_dev, u32 off,
1648c2ecf20Sopenharmony_ci			       u16 val, int reg_size)
1658c2ecf20Sopenharmony_ci{
1668c2ecf20Sopenharmony_ci	__le16 *buf;
1678c2ecf20Sopenharmony_ci	const int n = 64, size = n * sizeof(*buf);
1688c2ecf20Sopenharmony_ci	int i, ret = 0;
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	buf = kmalloc(size, GFP_KERNEL);
1718c2ecf20Sopenharmony_ci	if (!buf)
1728c2ecf20Sopenharmony_ci		return -ENOMEM;
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	for (i = 0; i < n; i++)
1758c2ecf20Sopenharmony_ci		buf[i] = cpu_to_le16(val);
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci	for (i = 0; i < reg_size; i += size) {
1788c2ecf20Sopenharmony_ci		ret = solo_p2m_dma(solo_dev, 1, buf,
1798c2ecf20Sopenharmony_ci				   SOLO_MOTION_EXT_ADDR(solo_dev) + off + i,
1808c2ecf20Sopenharmony_ci				   size, 0, 0);
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci		if (ret)
1838c2ecf20Sopenharmony_ci			break;
1848c2ecf20Sopenharmony_ci	}
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci	kfree(buf);
1878c2ecf20Sopenharmony_ci	return ret;
1888c2ecf20Sopenharmony_ci}
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ciint solo_set_motion_threshold(struct solo_dev *solo_dev, u8 ch, u16 val)
1918c2ecf20Sopenharmony_ci{
1928c2ecf20Sopenharmony_ci	if (ch > solo_dev->nr_chans)
1938c2ecf20Sopenharmony_ci		return -EINVAL;
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci	return solo_dma_vin_region(solo_dev, SOLO_MOT_FLAG_AREA +
1968c2ecf20Sopenharmony_ci				   (ch * SOLO_MOT_THRESH_SIZE * 2),
1978c2ecf20Sopenharmony_ci				   val, SOLO_MOT_THRESH_SIZE);
1988c2ecf20Sopenharmony_ci}
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ciint solo_set_motion_block(struct solo_dev *solo_dev, u8 ch,
2018c2ecf20Sopenharmony_ci		const u16 *thresholds)
2028c2ecf20Sopenharmony_ci{
2038c2ecf20Sopenharmony_ci	const unsigned size = sizeof(u16) * 64;
2048c2ecf20Sopenharmony_ci	u32 off = SOLO_MOT_FLAG_AREA + ch * SOLO_MOT_THRESH_SIZE * 2;
2058c2ecf20Sopenharmony_ci	__le16 *buf;
2068c2ecf20Sopenharmony_ci	int x, y;
2078c2ecf20Sopenharmony_ci	int ret = 0;
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci	buf = kzalloc(size, GFP_KERNEL);
2108c2ecf20Sopenharmony_ci	if (buf == NULL)
2118c2ecf20Sopenharmony_ci		return -ENOMEM;
2128c2ecf20Sopenharmony_ci	for (y = 0; y < SOLO_MOTION_SZ; y++) {
2138c2ecf20Sopenharmony_ci		for (x = 0; x < SOLO_MOTION_SZ; x++)
2148c2ecf20Sopenharmony_ci			buf[x] = cpu_to_le16(thresholds[y * SOLO_MOTION_SZ + x]);
2158c2ecf20Sopenharmony_ci		ret |= solo_p2m_dma(solo_dev, 1, buf,
2168c2ecf20Sopenharmony_ci			SOLO_MOTION_EXT_ADDR(solo_dev) + off + y * size,
2178c2ecf20Sopenharmony_ci			size, 0, 0);
2188c2ecf20Sopenharmony_ci	}
2198c2ecf20Sopenharmony_ci	kfree(buf);
2208c2ecf20Sopenharmony_ci	return ret;
2218c2ecf20Sopenharmony_ci}
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci/* First 8k is motion flag (512 bytes * 16). Following that is an 8k+8k
2248c2ecf20Sopenharmony_ci * threshold and working table for each channel. At least that's what the
2258c2ecf20Sopenharmony_ci * spec says. However, this code (taken from rdk) has some mystery 8k
2268c2ecf20Sopenharmony_ci * block right after the flag area, before the first thresh table. */
2278c2ecf20Sopenharmony_cistatic void solo_motion_config(struct solo_dev *solo_dev)
2288c2ecf20Sopenharmony_ci{
2298c2ecf20Sopenharmony_ci	int i;
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci	for (i = 0; i < solo_dev->nr_chans; i++) {
2328c2ecf20Sopenharmony_ci		/* Clear motion flag area */
2338c2ecf20Sopenharmony_ci		solo_dma_vin_region(solo_dev, i * SOLO_MOT_FLAG_SIZE, 0x0000,
2348c2ecf20Sopenharmony_ci				    SOLO_MOT_FLAG_SIZE);
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci		/* Clear working cache table */
2378c2ecf20Sopenharmony_ci		solo_dma_vin_region(solo_dev, SOLO_MOT_FLAG_AREA +
2388c2ecf20Sopenharmony_ci				    (i * SOLO_MOT_THRESH_SIZE * 2) +
2398c2ecf20Sopenharmony_ci				    SOLO_MOT_THRESH_SIZE, 0x0000,
2408c2ecf20Sopenharmony_ci				    SOLO_MOT_THRESH_SIZE);
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci		/* Set default threshold table */
2438c2ecf20Sopenharmony_ci		solo_set_motion_threshold(solo_dev, i, SOLO_DEF_MOT_THRESH);
2448c2ecf20Sopenharmony_ci	}
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci	/* Default motion settings */
2478c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_MOT_ADR, SOLO_VI_MOTION_EN(0) |
2488c2ecf20Sopenharmony_ci		       (SOLO_MOTION_EXT_ADDR(solo_dev) >> 16));
2498c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_MOT_CTRL,
2508c2ecf20Sopenharmony_ci		       SOLO_VI_MOTION_FRAME_COUNT(3) |
2518c2ecf20Sopenharmony_ci		       SOLO_VI_MOTION_SAMPLE_LENGTH(solo_dev->video_hsize / 16)
2528c2ecf20Sopenharmony_ci		       /* | SOLO_VI_MOTION_INTR_START_STOP */
2538c2ecf20Sopenharmony_ci		       | SOLO_VI_MOTION_SAMPLE_COUNT(10));
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_MOTION_BORDER, 0);
2568c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VI_MOTION_BAR, 0);
2578c2ecf20Sopenharmony_ci}
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ciint solo_disp_init(struct solo_dev *solo_dev)
2608c2ecf20Sopenharmony_ci{
2618c2ecf20Sopenharmony_ci	int i;
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci	solo_dev->video_hsize = 704;
2648c2ecf20Sopenharmony_ci	if (solo_dev->video_type == SOLO_VO_FMT_TYPE_NTSC) {
2658c2ecf20Sopenharmony_ci		solo_dev->video_vsize = 240;
2668c2ecf20Sopenharmony_ci		solo_dev->fps = 30;
2678c2ecf20Sopenharmony_ci	} else {
2688c2ecf20Sopenharmony_ci		solo_dev->video_vsize = 288;
2698c2ecf20Sopenharmony_ci		solo_dev->fps = 25;
2708c2ecf20Sopenharmony_ci	}
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci	solo_vin_config(solo_dev);
2738c2ecf20Sopenharmony_ci	solo_motion_config(solo_dev);
2748c2ecf20Sopenharmony_ci	solo_vout_config(solo_dev);
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	for (i = 0; i < solo_dev->nr_chans; i++)
2778c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_WIN_ON(i), 1);
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci	return 0;
2808c2ecf20Sopenharmony_ci}
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_civoid solo_disp_exit(struct solo_dev *solo_dev)
2838c2ecf20Sopenharmony_ci{
2848c2ecf20Sopenharmony_ci	int i;
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_DISP_CTRL, 0);
2878c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_ZOOM_CTRL, 0);
2888c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_FREEZE_CTRL, 0);
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci	for (i = 0; i < solo_dev->nr_chans; i++) {
2918c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_WIN_CTRL0(i), 0);
2928c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_WIN_CTRL1(i), 0);
2938c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VI_WIN_ON(i), 0);
2948c2ecf20Sopenharmony_ci	}
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci	/* Set default border */
2978c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++)
2988c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VO_BORDER_X(i), 0);
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	for (i = 0; i < 5; i++)
3018c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VO_BORDER_Y(i), 0);
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_BORDER_LINE_MASK, 0);
3048c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_BORDER_FILL_MASK, 0);
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_RECTANGLE_CTRL(0), 0);
3078c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_RECTANGLE_START(0), 0);
3088c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_RECTANGLE_STOP(0), 0);
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_RECTANGLE_CTRL(1), 0);
3118c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_RECTANGLE_START(1), 0);
3128c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VO_RECTANGLE_STOP(1), 0);
3138c2ecf20Sopenharmony_ci}
314