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/font.h>
148c2ecf20Sopenharmony_ci#include <linux/bitrev.h>
158c2ecf20Sopenharmony_ci#include <linux/slab.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include "solo6x10.h"
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define VI_PROG_HSIZE			(1280 - 16)
208c2ecf20Sopenharmony_ci#define VI_PROG_VSIZE			(1024 - 16)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define IRQ_LEVEL			2
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistatic void solo_capture_config(struct solo_dev *solo_dev)
258c2ecf20Sopenharmony_ci{
268c2ecf20Sopenharmony_ci	unsigned long height;
278c2ecf20Sopenharmony_ci	unsigned long width;
288c2ecf20Sopenharmony_ci	void *buf;
298c2ecf20Sopenharmony_ci	int i;
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_CAP_BASE,
328c2ecf20Sopenharmony_ci		       SOLO_CAP_MAX_PAGE((SOLO_CAP_EXT_SIZE(solo_dev)
338c2ecf20Sopenharmony_ci					  - SOLO_CAP_PAGE_SIZE) >> 16)
348c2ecf20Sopenharmony_ci		       | SOLO_CAP_BASE_ADDR(SOLO_CAP_EXT_ADDR(solo_dev) >> 16));
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	/* XXX: Undocumented bits at b17 and b24 */
378c2ecf20Sopenharmony_ci	if (solo_dev->type == SOLO_DEV_6110) {
388c2ecf20Sopenharmony_ci		/* NOTE: Ref driver has (62 << 24) here as well, but it causes
398c2ecf20Sopenharmony_ci		 * wacked out frame timing on 4-port 6110. */
408c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_CAP_BTW,
418c2ecf20Sopenharmony_ci			       (1 << 17) | SOLO_CAP_PROG_BANDWIDTH(2) |
428c2ecf20Sopenharmony_ci			       SOLO_CAP_MAX_BANDWIDTH(36));
438c2ecf20Sopenharmony_ci	} else {
448c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_CAP_BTW,
458c2ecf20Sopenharmony_ci			       (1 << 17) | SOLO_CAP_PROG_BANDWIDTH(2) |
468c2ecf20Sopenharmony_ci			       SOLO_CAP_MAX_BANDWIDTH(32));
478c2ecf20Sopenharmony_ci	}
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	/* Set scale 1, 9 dimension */
508c2ecf20Sopenharmony_ci	width = solo_dev->video_hsize;
518c2ecf20Sopenharmony_ci	height = solo_dev->video_vsize;
528c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_DIM_SCALE1,
538c2ecf20Sopenharmony_ci		       SOLO_DIM_H_MB_NUM(width / 16) |
548c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FRAME(height / 8) |
558c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FIELD(height / 16));
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	/* Set scale 2, 10 dimension */
588c2ecf20Sopenharmony_ci	width = solo_dev->video_hsize / 2;
598c2ecf20Sopenharmony_ci	height = solo_dev->video_vsize;
608c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_DIM_SCALE2,
618c2ecf20Sopenharmony_ci		       SOLO_DIM_H_MB_NUM(width / 16) |
628c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FRAME(height / 8) |
638c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FIELD(height / 16));
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	/* Set scale 3, 11 dimension */
668c2ecf20Sopenharmony_ci	width = solo_dev->video_hsize / 2;
678c2ecf20Sopenharmony_ci	height = solo_dev->video_vsize / 2;
688c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_DIM_SCALE3,
698c2ecf20Sopenharmony_ci		       SOLO_DIM_H_MB_NUM(width / 16) |
708c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FRAME(height / 8) |
718c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FIELD(height / 16));
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	/* Set scale 4, 12 dimension */
748c2ecf20Sopenharmony_ci	width = solo_dev->video_hsize / 3;
758c2ecf20Sopenharmony_ci	height = solo_dev->video_vsize / 3;
768c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_DIM_SCALE4,
778c2ecf20Sopenharmony_ci		       SOLO_DIM_H_MB_NUM(width / 16) |
788c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FRAME(height / 8) |
798c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FIELD(height / 16));
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	/* Set scale 5, 13 dimension */
828c2ecf20Sopenharmony_ci	width = solo_dev->video_hsize / 4;
838c2ecf20Sopenharmony_ci	height = solo_dev->video_vsize / 2;
848c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_DIM_SCALE5,
858c2ecf20Sopenharmony_ci		       SOLO_DIM_H_MB_NUM(width / 16) |
868c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FRAME(height / 8) |
878c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FIELD(height / 16));
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	/* Progressive */
908c2ecf20Sopenharmony_ci	width = VI_PROG_HSIZE;
918c2ecf20Sopenharmony_ci	height = VI_PROG_VSIZE;
928c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_DIM_PROG,
938c2ecf20Sopenharmony_ci		       SOLO_DIM_H_MB_NUM(width / 16) |
948c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FRAME(height / 16) |
958c2ecf20Sopenharmony_ci		       SOLO_DIM_V_MB_NUM_FIELD(height / 16));
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	/* Clear OSD */
988c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_OSD_CH, 0);
998c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_OSD_BASE, SOLO_EOSD_EXT_ADDR >> 16);
1008c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_OSD_CLR,
1018c2ecf20Sopenharmony_ci		       0xF0 << 16 | 0x80 << 8 | 0x80);
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	if (solo_dev->type == SOLO_DEV_6010)
1048c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VE_OSD_OPT,
1058c2ecf20Sopenharmony_ci			       SOLO_VE_OSD_H_SHADOW | SOLO_VE_OSD_V_SHADOW);
1068c2ecf20Sopenharmony_ci	else
1078c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VE_OSD_OPT, SOLO_VE_OSD_V_DOUBLE
1088c2ecf20Sopenharmony_ci			       | SOLO_VE_OSD_H_SHADOW | SOLO_VE_OSD_V_SHADOW);
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci	/* Clear OSG buffer */
1118c2ecf20Sopenharmony_ci	buf = kzalloc(SOLO_EOSD_EXT_SIZE(solo_dev), GFP_KERNEL);
1128c2ecf20Sopenharmony_ci	if (!buf)
1138c2ecf20Sopenharmony_ci		return;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci	for (i = 0; i < solo_dev->nr_chans; i++) {
1168c2ecf20Sopenharmony_ci		solo_p2m_dma(solo_dev, 1, buf,
1178c2ecf20Sopenharmony_ci			     SOLO_EOSD_EXT_ADDR +
1188c2ecf20Sopenharmony_ci			     (SOLO_EOSD_EXT_SIZE(solo_dev) * i),
1198c2ecf20Sopenharmony_ci			     SOLO_EOSD_EXT_SIZE(solo_dev), 0, 0);
1208c2ecf20Sopenharmony_ci	}
1218c2ecf20Sopenharmony_ci	kfree(buf);
1228c2ecf20Sopenharmony_ci}
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define SOLO_OSD_WRITE_SIZE (16 * OSD_TEXT_MAX)
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci/* Should be called with enable_lock held */
1278c2ecf20Sopenharmony_ciint solo_osd_print(struct solo_enc_dev *solo_enc)
1288c2ecf20Sopenharmony_ci{
1298c2ecf20Sopenharmony_ci	struct solo_dev *solo_dev = solo_enc->solo_dev;
1308c2ecf20Sopenharmony_ci	u8 *str = solo_enc->osd_text;
1318c2ecf20Sopenharmony_ci	u8 *buf = solo_enc->osd_buf;
1328c2ecf20Sopenharmony_ci	u32 reg;
1338c2ecf20Sopenharmony_ci	const struct font_desc *vga = find_font("VGA8x16");
1348c2ecf20Sopenharmony_ci	const u8 *vga_data;
1358c2ecf20Sopenharmony_ci	int i, j;
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci	if (WARN_ON_ONCE(!vga))
1388c2ecf20Sopenharmony_ci		return -ENODEV;
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci	reg = solo_reg_read(solo_dev, SOLO_VE_OSD_CH);
1418c2ecf20Sopenharmony_ci	if (!*str) {
1428c2ecf20Sopenharmony_ci		/* Disable OSD on this channel */
1438c2ecf20Sopenharmony_ci		reg &= ~(1 << solo_enc->ch);
1448c2ecf20Sopenharmony_ci		goto out;
1458c2ecf20Sopenharmony_ci	}
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	memset(buf, 0, SOLO_OSD_WRITE_SIZE);
1488c2ecf20Sopenharmony_ci	vga_data = (const u8 *)vga->data;
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	for (i = 0; *str; i++, str++) {
1518c2ecf20Sopenharmony_ci		for (j = 0; j < 16; j++) {
1528c2ecf20Sopenharmony_ci			buf[(j << 1) | (i & 1) | ((i & ~1) << 4)] =
1538c2ecf20Sopenharmony_ci			    bitrev8(vga_data[(*str << 4) | j]);
1548c2ecf20Sopenharmony_ci		}
1558c2ecf20Sopenharmony_ci	}
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci	solo_p2m_dma(solo_dev, 1, buf,
1588c2ecf20Sopenharmony_ci		     SOLO_EOSD_EXT_ADDR_CHAN(solo_dev, solo_enc->ch),
1598c2ecf20Sopenharmony_ci		     SOLO_OSD_WRITE_SIZE, 0, 0);
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci	/* Enable OSD on this channel */
1628c2ecf20Sopenharmony_ci	reg |= (1 << solo_enc->ch);
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ciout:
1658c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_OSD_CH, reg);
1668c2ecf20Sopenharmony_ci	return 0;
1678c2ecf20Sopenharmony_ci}
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci/*
1708c2ecf20Sopenharmony_ci * Set channel Quality Profile (0-3).
1718c2ecf20Sopenharmony_ci */
1728c2ecf20Sopenharmony_civoid solo_s_jpeg_qp(struct solo_dev *solo_dev, unsigned int ch,
1738c2ecf20Sopenharmony_ci		    unsigned int qp)
1748c2ecf20Sopenharmony_ci{
1758c2ecf20Sopenharmony_ci	unsigned long flags;
1768c2ecf20Sopenharmony_ci	unsigned int idx, reg;
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci	if ((ch > 31) || (qp > 3))
1798c2ecf20Sopenharmony_ci		return;
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci	if (solo_dev->type == SOLO_DEV_6010)
1828c2ecf20Sopenharmony_ci		return;
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	if (ch < 16) {
1858c2ecf20Sopenharmony_ci		idx = 0;
1868c2ecf20Sopenharmony_ci		reg = SOLO_VE_JPEG_QP_CH_L;
1878c2ecf20Sopenharmony_ci	} else {
1888c2ecf20Sopenharmony_ci		ch -= 16;
1898c2ecf20Sopenharmony_ci		idx = 1;
1908c2ecf20Sopenharmony_ci		reg = SOLO_VE_JPEG_QP_CH_H;
1918c2ecf20Sopenharmony_ci	}
1928c2ecf20Sopenharmony_ci	ch *= 2;
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	spin_lock_irqsave(&solo_dev->jpeg_qp_lock, flags);
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci	solo_dev->jpeg_qp[idx] &= ~(3 << ch);
1978c2ecf20Sopenharmony_ci	solo_dev->jpeg_qp[idx] |= (qp & 3) << ch;
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, reg, solo_dev->jpeg_qp[idx]);
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&solo_dev->jpeg_qp_lock, flags);
2028c2ecf20Sopenharmony_ci}
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ciint solo_g_jpeg_qp(struct solo_dev *solo_dev, unsigned int ch)
2058c2ecf20Sopenharmony_ci{
2068c2ecf20Sopenharmony_ci	int idx;
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci	if (solo_dev->type == SOLO_DEV_6010)
2098c2ecf20Sopenharmony_ci		return 2;
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci	if (WARN_ON_ONCE(ch > 31))
2128c2ecf20Sopenharmony_ci		return 2;
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci	if (ch < 16) {
2158c2ecf20Sopenharmony_ci		idx = 0;
2168c2ecf20Sopenharmony_ci	} else {
2178c2ecf20Sopenharmony_ci		ch -= 16;
2188c2ecf20Sopenharmony_ci		idx = 1;
2198c2ecf20Sopenharmony_ci	}
2208c2ecf20Sopenharmony_ci	ch *= 2;
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci	return (solo_dev->jpeg_qp[idx] >> ch) & 3;
2238c2ecf20Sopenharmony_ci}
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci#define SOLO_QP_INIT 0xaaaaaaaa
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistatic void solo_jpeg_config(struct solo_dev *solo_dev)
2288c2ecf20Sopenharmony_ci{
2298c2ecf20Sopenharmony_ci	if (solo_dev->type == SOLO_DEV_6010) {
2308c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VE_JPEG_QP_TBL,
2318c2ecf20Sopenharmony_ci			       (2 << 24) | (2 << 16) | (2 << 8) | 2);
2328c2ecf20Sopenharmony_ci	} else {
2338c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VE_JPEG_QP_TBL,
2348c2ecf20Sopenharmony_ci			       (4 << 24) | (3 << 16) | (2 << 8) | 1);
2358c2ecf20Sopenharmony_ci	}
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci	spin_lock_init(&solo_dev->jpeg_qp_lock);
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci	/* Initialize Quality Profile for all channels */
2408c2ecf20Sopenharmony_ci	solo_dev->jpeg_qp[0] = solo_dev->jpeg_qp[1] = SOLO_QP_INIT;
2418c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_JPEG_QP_CH_L, SOLO_QP_INIT);
2428c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_JPEG_QP_CH_H, SOLO_QP_INIT);
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_JPEG_CFG,
2458c2ecf20Sopenharmony_ci		(SOLO_JPEG_EXT_SIZE(solo_dev) & 0xffff0000) |
2468c2ecf20Sopenharmony_ci		((SOLO_JPEG_EXT_ADDR(solo_dev) >> 16) & 0x0000ffff));
2478c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_JPEG_CTRL, 0xffffffff);
2488c2ecf20Sopenharmony_ci	if (solo_dev->type == SOLO_DEV_6110) {
2498c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VE_JPEG_CFG1,
2508c2ecf20Sopenharmony_ci			       (0 << 16) | (30 << 8) | 60);
2518c2ecf20Sopenharmony_ci	}
2528c2ecf20Sopenharmony_ci}
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_cistatic void solo_mp4e_config(struct solo_dev *solo_dev)
2558c2ecf20Sopenharmony_ci{
2568c2ecf20Sopenharmony_ci	int i;
2578c2ecf20Sopenharmony_ci	u32 cfg;
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_CFG0,
2608c2ecf20Sopenharmony_ci		       SOLO_VE_INTR_CTRL(IRQ_LEVEL) |
2618c2ecf20Sopenharmony_ci		       SOLO_VE_BLOCK_SIZE(SOLO_MP4E_EXT_SIZE(solo_dev) >> 16) |
2628c2ecf20Sopenharmony_ci		       SOLO_VE_BLOCK_BASE(SOLO_MP4E_EXT_ADDR(solo_dev) >> 16));
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	cfg = SOLO_VE_BYTE_ALIGN(2) | SOLO_VE_INSERT_INDEX
2668c2ecf20Sopenharmony_ci		| SOLO_VE_MOTION_MODE(0);
2678c2ecf20Sopenharmony_ci	if (solo_dev->type != SOLO_DEV_6010) {
2688c2ecf20Sopenharmony_ci		cfg |= SOLO_VE_MPEG_SIZE_H(
2698c2ecf20Sopenharmony_ci			(SOLO_MP4E_EXT_SIZE(solo_dev) >> 24) & 0x0f);
2708c2ecf20Sopenharmony_ci		cfg |= SOLO_VE_JPEG_SIZE_H(
2718c2ecf20Sopenharmony_ci			(SOLO_JPEG_EXT_SIZE(solo_dev) >> 24) & 0x0f);
2728c2ecf20Sopenharmony_ci	}
2738c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_CFG1, cfg);
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_WMRK_POLY, 0);
2768c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_VMRK_INIT_KEY, 0);
2778c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_WMRK_STRL, 0);
2788c2ecf20Sopenharmony_ci	if (solo_dev->type == SOLO_DEV_6110)
2798c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VE_WMRK_ENABLE, 0);
2808c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_ENCRYP_POLY, 0);
2818c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_ENCRYP_INIT, 0);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci	solo_reg_write(solo_dev, SOLO_VE_ATTR,
2848c2ecf20Sopenharmony_ci		       SOLO_VE_LITTLE_ENDIAN |
2858c2ecf20Sopenharmony_ci		       SOLO_COMP_ATTR_FCODE(1) |
2868c2ecf20Sopenharmony_ci		       SOLO_COMP_TIME_INC(0) |
2878c2ecf20Sopenharmony_ci		       SOLO_COMP_TIME_WIDTH(15) |
2888c2ecf20Sopenharmony_ci		       SOLO_DCT_INTERVAL(solo_dev->type == SOLO_DEV_6010 ? 9 : 10));
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci	for (i = 0; i < solo_dev->nr_chans; i++) {
2918c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VE_CH_REF_BASE(i),
2928c2ecf20Sopenharmony_ci			       (SOLO_EREF_EXT_ADDR(solo_dev) +
2938c2ecf20Sopenharmony_ci			       (i * SOLO_EREF_EXT_SIZE)) >> 16);
2948c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VE_CH_REF_BASE_E(i),
2958c2ecf20Sopenharmony_ci			       (SOLO_EREF_EXT_ADDR(solo_dev) +
2968c2ecf20Sopenharmony_ci			       ((i + 16) * SOLO_EREF_EXT_SIZE)) >> 16);
2978c2ecf20Sopenharmony_ci	}
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci	if (solo_dev->type == SOLO_DEV_6110) {
3008c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_VE_COMPT_MOT, 0x00040008);
3018c2ecf20Sopenharmony_ci	} else {
3028c2ecf20Sopenharmony_ci		for (i = 0; i < solo_dev->nr_chans; i++)
3038c2ecf20Sopenharmony_ci			solo_reg_write(solo_dev, SOLO_VE_CH_MOT(i), 0x100);
3048c2ecf20Sopenharmony_ci	}
3058c2ecf20Sopenharmony_ci}
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ciint solo_enc_init(struct solo_dev *solo_dev)
3088c2ecf20Sopenharmony_ci{
3098c2ecf20Sopenharmony_ci	int i;
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci	solo_capture_config(solo_dev);
3128c2ecf20Sopenharmony_ci	solo_mp4e_config(solo_dev);
3138c2ecf20Sopenharmony_ci	solo_jpeg_config(solo_dev);
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	for (i = 0; i < solo_dev->nr_chans; i++) {
3168c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_CAP_CH_SCALE(i), 0);
3178c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_CAP_CH_COMP_ENA_E(i), 0);
3188c2ecf20Sopenharmony_ci	}
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci	return 0;
3218c2ecf20Sopenharmony_ci}
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_civoid solo_enc_exit(struct solo_dev *solo_dev)
3248c2ecf20Sopenharmony_ci{
3258c2ecf20Sopenharmony_ci	int i;
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci	for (i = 0; i < solo_dev->nr_chans; i++) {
3288c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_CAP_CH_SCALE(i), 0);
3298c2ecf20Sopenharmony_ci		solo_reg_write(solo_dev, SOLO_CAP_CH_COMP_ENA_E(i), 0);
3308c2ecf20Sopenharmony_ci	}
3318c2ecf20Sopenharmony_ci}
332