linux/drivers/media/platform/samsung/exynos4-is/fimc-reg.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Samsung camera host interface (FIMC) registers definition
 *
 * Copyright (C) 2010 - 2012 Samsung Electronics Co., Ltd.
 */

#ifndef FIMC_REG_H_
#define FIMC_REG_H_

#include <linux/bitops.h>

#include "fimc-core.h"

/* Input source format */
#define FIMC_REG_CISRCFMT
#define FIMC_REG_CISRCFMT_ITU601_8BIT
#define FIMC_REG_CISRCFMT_ITU601_16BIT
#define FIMC_REG_CISRCFMT_ORDER422_YCBYCR
#define FIMC_REG_CISRCFMT_ORDER422_YCRYCB
#define FIMC_REG_CISRCFMT_ORDER422_CBYCRY
#define FIMC_REG_CISRCFMT_ORDER422_CRYCBY

/* Window offset */
#define FIMC_REG_CIWDOFST
#define FIMC_REG_CIWDOFST_OFF_EN
#define FIMC_REG_CIWDOFST_CLROVFIY
#define FIMC_REG_CIWDOFST_CLROVRLB
#define FIMC_REG_CIWDOFST_HOROFF_MASK
#define FIMC_REG_CIWDOFST_CLROVFICB
#define FIMC_REG_CIWDOFST_CLROVFICR
#define FIMC_REG_CIWDOFST_VEROFF_MASK

/* Global control */
#define FIMC_REG_CIGCTRL
#define FIMC_REG_CIGCTRL_SWRST
#define FIMC_REG_CIGCTRL_CAMRST_A
#define FIMC_REG_CIGCTRL_SELCAM_ITU_A
#define FIMC_REG_CIGCTRL_TESTPAT_NORMAL
#define FIMC_REG_CIGCTRL_TESTPAT_COLOR_BAR
#define FIMC_REG_CIGCTRL_TESTPAT_HOR_INC
#define FIMC_REG_CIGCTRL_TESTPAT_VER_INC
#define FIMC_REG_CIGCTRL_TESTPAT_MASK
#define FIMC_REG_CIGCTRL_TESTPAT_SHIFT
#define FIMC_REG_CIGCTRL_INVPOLPCLK
#define FIMC_REG_CIGCTRL_INVPOLVSYNC
#define FIMC_REG_CIGCTRL_INVPOLHREF
#define FIMC_REG_CIGCTRL_IRQ_OVFEN
#define FIMC_REG_CIGCTRL_HREF_MASK
#define FIMC_REG_CIGCTRL_IRQ_LEVEL
#define FIMC_REG_CIGCTRL_IRQ_CLR
#define FIMC_REG_CIGCTRL_IRQ_ENABLE
#define FIMC_REG_CIGCTRL_SHDW_DISABLE
/* 0 - selects Writeback A (LCD), 1 - selects Writeback B (LCD/ISP) */
#define FIMC_REG_CIGCTRL_SELWB_A
#define FIMC_REG_CIGCTRL_CAM_JPEG
#define FIMC_REG_CIGCTRL_SELCAM_MIPI_A
#define FIMC_REG_CIGCTRL_CAMIF_SELWB
/* 0 - ITU601; 1 - ITU709 */
#define FIMC_REG_CIGCTRL_CSC_ITU601_709
#define FIMC_REG_CIGCTRL_INVPOLHSYNC
#define FIMC_REG_CIGCTRL_SELCAM_MIPI
#define FIMC_REG_CIGCTRL_INVPOLFIELD
#define FIMC_REG_CIGCTRL_INTERLACE

/* Window offset 2 */
#define FIMC_REG_CIWDOFST2
#define FIMC_REG_CIWDOFST2_HOROFF_MASK
#define FIMC_REG_CIWDOFST2_VEROFF_MASK

/* Output DMA Y/Cb/Cr plane start addresses */
#define FIMC_REG_CIOYSA(n)
#define FIMC_REG_CIOCBSA(n)
#define FIMC_REG_CIOCRSA(n)

/* Target image format */
#define FIMC_REG_CITRGFMT
#define FIMC_REG_CITRGFMT_INROT90
#define FIMC_REG_CITRGFMT_YCBCR420
#define FIMC_REG_CITRGFMT_YCBCR422
#define FIMC_REG_CITRGFMT_YCBCR422_1P
#define FIMC_REG_CITRGFMT_RGB
#define FIMC_REG_CITRGFMT_FMT_MASK
#define FIMC_REG_CITRGFMT_HSIZE_MASK
#define FIMC_REG_CITRGFMT_FLIP_SHIFT
#define FIMC_REG_CITRGFMT_FLIP_NORMAL
#define FIMC_REG_CITRGFMT_FLIP_X_MIRROR
#define FIMC_REG_CITRGFMT_FLIP_Y_MIRROR
#define FIMC_REG_CITRGFMT_FLIP_180
#define FIMC_REG_CITRGFMT_FLIP_MASK
#define FIMC_REG_CITRGFMT_OUTROT90
#define FIMC_REG_CITRGFMT_VSIZE_MASK

/* Output DMA control */
#define FIMC_REG_CIOCTRL
#define FIMC_REG_CIOCTRL_ORDER422_MASK
#define FIMC_REG_CIOCTRL_ORDER422_YCBYCR
#define FIMC_REG_CIOCTRL_ORDER422_YCRYCB
#define FIMC_REG_CIOCTRL_ORDER422_CBYCRY
#define FIMC_REG_CIOCTRL_ORDER422_CRYCBY
#define FIMC_REG_CIOCTRL_LASTIRQ_ENABLE
#define FIMC_REG_CIOCTRL_YCBCR_3PLANE
#define FIMC_REG_CIOCTRL_YCBCR_2PLANE
#define FIMC_REG_CIOCTRL_YCBCR_PLANE_MASK
#define FIMC_REG_CIOCTRL_ALPHA_OUT_MASK
#define FIMC_REG_CIOCTRL_RGB16FMT_MASK
#define FIMC_REG_CIOCTRL_RGB565
#define FIMC_REG_CIOCTRL_ARGB1555
#define FIMC_REG_CIOCTRL_ARGB4444
#define FIMC_REG_CIOCTRL_ORDER2P_SHIFT
#define FIMC_REG_CIOCTRL_ORDER2P_MASK
#define FIMC_REG_CIOCTRL_ORDER422_2P_LSB_CRCB

/* Pre-scaler control 1 */
#define FIMC_REG_CISCPRERATIO

#define FIMC_REG_CISCPREDST

/* Main scaler control */
#define FIMC_REG_CISCCTRL
#define FIMC_REG_CISCCTRL_SCALERBYPASS
#define FIMC_REG_CISCCTRL_SCALEUP_H
#define FIMC_REG_CISCCTRL_SCALEUP_V
#define FIMC_REG_CISCCTRL_CSCR2Y_WIDE
#define FIMC_REG_CISCCTRL_CSCY2R_WIDE
#define FIMC_REG_CISCCTRL_LCDPATHEN_FIFO
#define FIMC_REG_CISCCTRL_INTERLACE
#define FIMC_REG_CISCCTRL_SCALERSTART
#define FIMC_REG_CISCCTRL_INRGB_FMT_RGB565
#define FIMC_REG_CISCCTRL_INRGB_FMT_RGB666
#define FIMC_REG_CISCCTRL_INRGB_FMT_RGB888
#define FIMC_REG_CISCCTRL_INRGB_FMT_MASK
#define FIMC_REG_CISCCTRL_OUTRGB_FMT_RGB565
#define FIMC_REG_CISCCTRL_OUTRGB_FMT_RGB666
#define FIMC_REG_CISCCTRL_OUTRGB_FMT_RGB888
#define FIMC_REG_CISCCTRL_OUTRGB_FMT_MASK
#define FIMC_REG_CISCCTRL_RGB_EXT
#define FIMC_REG_CISCCTRL_ONE2ONE
#define FIMC_REG_CISCCTRL_MHRATIO(x)
#define FIMC_REG_CISCCTRL_MVRATIO(x)
#define FIMC_REG_CISCCTRL_MHRATIO_MASK
#define FIMC_REG_CISCCTRL_MVRATIO_MASK
#define FIMC_REG_CISCCTRL_MHRATIO_EXT(x)
#define FIMC_REG_CISCCTRL_MVRATIO_EXT(x)

/* Target area */
#define FIMC_REG_CITAREA
#define FIMC_REG_CITAREA_MASK

/* General status */
#define FIMC_REG_CISTATUS
#define FIMC_REG_CISTATUS_OVFIY
#define FIMC_REG_CISTATUS_OVFICB
#define FIMC_REG_CISTATUS_OVFICR
#define FIMC_REG_CISTATUS_VSYNC
#define FIMC_REG_CISTATUS_FRAMECNT_MASK
#define FIMC_REG_CISTATUS_FRAMECNT_SHIFT
#define FIMC_REG_CISTATUS_WINOFF_EN
#define FIMC_REG_CISTATUS_IMGCPT_EN
#define FIMC_REG_CISTATUS_IMGCPT_SCEN
#define FIMC_REG_CISTATUS_VSYNC_A
#define FIMC_REG_CISTATUS_VSYNC_B
#define FIMC_REG_CISTATUS_OVRLB
#define FIMC_REG_CISTATUS_FRAME_END
#define FIMC_REG_CISTATUS_LASTCAPT_END
#define FIMC_REG_CISTATUS_VVALID_A
#define FIMC_REG_CISTATUS_VVALID_B

/* Indexes to the last and the currently processed buffer. */
#define FIMC_REG_CISTATUS2

/* Image capture control */
#define FIMC_REG_CIIMGCPT
#define FIMC_REG_CIIMGCPT_IMGCPTEN
#define FIMC_REG_CIIMGCPT_IMGCPTEN_SC
#define FIMC_REG_CIIMGCPT_CPT_FREN_ENABLE
#define FIMC_REG_CIIMGCPT_CPT_FRMOD_CNT

/* Frame capture sequence */
#define FIMC_REG_CICPTSEQ

/* Image effect */
#define FIMC_REG_CIIMGEFF
#define FIMC_REG_CIIMGEFF_IE_ENABLE
#define FIMC_REG_CIIMGEFF_IE_SC_BEFORE
#define FIMC_REG_CIIMGEFF_IE_SC_AFTER
#define FIMC_REG_CIIMGEFF_FIN_BYPASS
#define FIMC_REG_CIIMGEFF_FIN_ARBITRARY
#define FIMC_REG_CIIMGEFF_FIN_NEGATIVE
#define FIMC_REG_CIIMGEFF_FIN_ARTFREEZE
#define FIMC_REG_CIIMGEFF_FIN_EMBOSSING
#define FIMC_REG_CIIMGEFF_FIN_SILHOUETTE
#define FIMC_REG_CIIMGEFF_FIN_MASK
#define FIMC_REG_CIIMGEFF_PAT_CBCR_MASK

/* Input DMA Y/Cb/Cr plane start address 0/1 */
#define FIMC_REG_CIIYSA(n)
#define FIMC_REG_CIICBSA(n)
#define FIMC_REG_CIICRSA(n)

/* Real input DMA image size */
#define FIMC_REG_CIREAL_ISIZE
#define FIMC_REG_CIREAL_ISIZE_AUTOLOAD_EN
#define FIMC_REG_CIREAL_ISIZE_ADDR_CH_DIS

/* Input DMA control */
#define FIMC_REG_MSCTRL
#define FIMC_REG_MSCTRL_IN_BURST_COUNT_MASK
#define FIMC_REG_MSCTRL_2P_IN_ORDER_MASK
#define FIMC_REG_MSCTRL_2P_IN_ORDER_SHIFT
#define FIMC_REG_MSCTRL_C_INT_IN_3PLANE
#define FIMC_REG_MSCTRL_C_INT_IN_2PLANE
#define FIMC_REG_MSCTRL_C_INT_IN_MASK
#define FIMC_REG_MSCTRL_FLIP_SHIFT
#define FIMC_REG_MSCTRL_FLIP_MASK
#define FIMC_REG_MSCTRL_FLIP_NORMAL
#define FIMC_REG_MSCTRL_FLIP_X_MIRROR
#define FIMC_REG_MSCTRL_FLIP_Y_MIRROR
#define FIMC_REG_MSCTRL_FLIP_180
#define FIMC_REG_MSCTRL_FIFO_CTRL_FULL
#define FIMC_REG_MSCTRL_ORDER422_SHIFT
#define FIMC_REG_MSCTRL_ORDER422_CRYCBY
#define FIMC_REG_MSCTRL_ORDER422_YCRYCB
#define FIMC_REG_MSCTRL_ORDER422_CBYCRY
#define FIMC_REG_MSCTRL_ORDER422_YCBYCR
#define FIMC_REG_MSCTRL_ORDER422_MASK
#define FIMC_REG_MSCTRL_INPUT_EXTCAM
#define FIMC_REG_MSCTRL_INPUT_MEMORY
#define FIMC_REG_MSCTRL_INPUT_MASK
#define FIMC_REG_MSCTRL_INFORMAT_YCBCR420
#define FIMC_REG_MSCTRL_INFORMAT_YCBCR422
#define FIMC_REG_MSCTRL_INFORMAT_YCBCR422_1P
#define FIMC_REG_MSCTRL_INFORMAT_RGB
#define FIMC_REG_MSCTRL_INFORMAT_MASK
#define FIMC_REG_MSCTRL_ENVID
#define FIMC_REG_MSCTRL_IN_BURST_COUNT(x)

/* Output DMA Y/Cb/Cr offset */
#define FIMC_REG_CIOYOFF
#define FIMC_REG_CIOCBOFF
#define FIMC_REG_CIOCROFF

/* Input DMA Y/Cb/Cr offset */
#define FIMC_REG_CIIYOFF
#define FIMC_REG_CIICBOFF
#define FIMC_REG_CIICROFF

/* Input DMA original image size */
#define FIMC_REG_ORGISIZE

/* Output DMA original image size */
#define FIMC_REG_ORGOSIZE

/* Real output DMA image size (extension register) */
#define FIMC_REG_CIEXTEN
#define FIMC_REG_CIEXTEN_MHRATIO_EXT(x)
#define FIMC_REG_CIEXTEN_MVRATIO_EXT(x)
#define FIMC_REG_CIEXTEN_MHRATIO_EXT_MASK
#define FIMC_REG_CIEXTEN_MVRATIO_EXT_MASK

#define FIMC_REG_CIDMAPARAM
#define FIMC_REG_CIDMAPARAM_R_LINEAR
#define FIMC_REG_CIDMAPARAM_R_64X32
#define FIMC_REG_CIDMAPARAM_W_LINEAR
#define FIMC_REG_CIDMAPARAM_W_64X32
#define FIMC_REG_CIDMAPARAM_TILE_MASK

/* MIPI CSI image format */
#define FIMC_REG_CSIIMGFMT
#define FIMC_REG_CSIIMGFMT_YCBCR422_8BIT
#define FIMC_REG_CSIIMGFMT_RAW8
#define FIMC_REG_CSIIMGFMT_RAW10
#define FIMC_REG_CSIIMGFMT_RAW12
/* User defined formats. x = 0...16. */
#define FIMC_REG_CSIIMGFMT_USER(x)

/* Output frame buffer sequence mask */
#define FIMC_REG_CIFCNTSEQ

/* SYSREG ISP Writeback register address offsets */
#define SYSREG_ISPBLK
#define SYSREG_ISPBLK_FIFORST_CAM_BLK

#define SYSREG_CAMBLK
#define SYSREG_CAMBLK_FIFORST_ISP
#define SYSREG_CAMBLK_ISPWB_FULL_EN

/*
 * Function declarations
 */
void fimc_hw_reset(struct fimc_dev *fimc);
void fimc_hw_set_rotation(struct fimc_ctx *ctx);
void fimc_hw_set_target_format(struct fimc_ctx *ctx);
void fimc_hw_set_out_dma(struct fimc_ctx *ctx);
void fimc_hw_en_lastirq(struct fimc_dev *fimc, int enable);
void fimc_hw_en_irq(struct fimc_dev *fimc, int enable);
void fimc_hw_set_prescaler(struct fimc_ctx *ctx);
void fimc_hw_set_mainscaler(struct fimc_ctx *ctx);
void fimc_hw_enable_capture(struct fimc_ctx *ctx);
void fimc_hw_set_effect(struct fimc_ctx *ctx);
void fimc_hw_set_rgb_alpha(struct fimc_ctx *ctx);
void fimc_hw_set_in_dma(struct fimc_ctx *ctx);
void fimc_hw_set_input_path(struct fimc_ctx *ctx);
void fimc_hw_set_output_path(struct fimc_ctx *ctx);
void fimc_hw_set_input_addr(struct fimc_dev *fimc, const struct fimc_addr *addr);
void fimc_hw_set_output_addr(struct fimc_dev *fimc, const struct fimc_addr *addr,
			     int index);
int fimc_hw_set_camera_source(struct fimc_dev *fimc,
			      struct fimc_source_info *cam);
void fimc_hw_set_camera_offset(struct fimc_dev *fimc, const struct fimc_frame *f);
int fimc_hw_set_camera_polarity(struct fimc_dev *fimc,
				const struct fimc_source_info *cam);
int fimc_hw_set_camera_type(struct fimc_dev *fimc,
			    const struct fimc_source_info *cam);
void fimc_hw_clear_irq(struct fimc_dev *dev);
void fimc_hw_enable_scaler(struct fimc_dev *dev, bool on);
void fimc_hw_activate_input_dma(struct fimc_dev *dev, bool on);
void fimc_hw_disable_capture(struct fimc_dev *dev);
s32 fimc_hw_get_frame_index(struct fimc_dev *dev);
s32 fimc_hw_get_prev_frame_index(struct fimc_dev *dev);
int fimc_hw_camblk_cfg_writeback(struct fimc_dev *fimc);
void fimc_activate_capture(struct fimc_ctx *ctx);
void fimc_deactivate_capture(struct fimc_dev *fimc);

/**
 * fimc_hw_set_dma_seq - configure output DMA buffer sequence
 * @dev: fimc device
 * @mask: bitmask for the DMA output buffer registers, set to 0 to skip buffer
 * This function masks output DMA ring buffers, it allows to select which of
 * the 32 available output buffer address registers will be used by the DMA
 * engine.
 */
static inline void fimc_hw_set_dma_seq(struct fimc_dev *dev, u32 mask)
{}

#endif /* FIMC_REG_H_ */