/*
 * Realtek Semiconductor Corp.
 *
 * rts_mcu.h
 *
 * Copyright (C) 2018      Ming Qian<ming_qian@realsil.com.cn>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#ifndef _RTS_MCU_H
#define _RTS_MCU_H

#include "linux/rts_camera_soc.h"

#define RTS_CMDCODE_GET_SENSOR_ID		((0x01 << 8) | 0x8c)

#define RTS_CMDCODE_SET_TIMER_STATUS		((0x0a << 8) | 0x1e)
#define RTS_CMDCODE_GET_TIMER_STATUS		((0x0a << 8) | 0x9e)
#define RTS_CMDCODE_GET_TIMER_VALUE		((0x0a << 8) | 0x9f)

#define RTS_CMDCODE_SET_GPIO_DIR		((0x0c << 8) | 0x02)
#define RTS_CMDCODE_GET_GPIO_DIR		((0x0c << 8) | 0x82)
#define RTS_CMDCODE_SET_GPIO_VALUE		((0x0c << 8) | 0x03)
#define RTS_CMDCODE_GET_GPIO_VALUE		((0x0c << 8) | 0x83)
#define RTS_CMDCODE_GET_GPIO_USE_STATUS		((0x0c << 8) | 0x81)

#define RTS_CMDCODE_GET_DEVICE_DES		((0x01 << 8) | 0x81)
#define RTS_CMDCODE_GET_ISP_PROCESS_DES		((0x01 << 8) | 0x84)
#define RTS_CMDCODE_GET_CAMERA_DES		((0x01 << 8) | 0x85)
#define RTS_CMDCODE_GET_RTK_EXT_CTL_DES		((0x01 << 8) | 0x86)
#define RTS_CMDCODE_GET_FRAME_INTERVAL_DES	((0x01 << 8) | 0x82)
#define RTS_CMDCODE_GET_VS_FMT_DES		((0x01 << 8) | 0x83)

#define RTS_CMDCODE_GET_SNR_FMT			((0x06 << 8) | 0x81)
#define RTS_CMDCODE_GET_ISP_FMT_WIDTH_HEIGHT	((0x0a << 8) | 0xab)
#define RTS_CMDCODE_GET_TPNR_MODE		((0x0a << 8) | 0x9c)

#define RTS_CMDCODE_SET_ISP_FUNC		((0x0a << 8) | 0x01)
#define RTS_CMDCODE_GET_ISP_FUNC		((0x0a << 8) | 0x81)

#define RTSCAM_MCU_ISP_FUNC_TD_BIT		0
#define RTSCAM_MCU_TD_INDEX			5
#define RTSCAM_MCU_MD_INDEX			7
#define RTSCAM_MCU_MTD_INT_NUM			7

enum rts_tpnr_mode_e {
	RTS_TPNR_MODE_YUV = 0,
	RTS_TPNR_MODE_Y,
	RTS_TPNR_MODE_YUV_DOWN_SAMPLE,
	RTS_TPNR_MODE_Y_DOWN_SAMPLE,
	RTS_TPNR_MODE_YUV_420
};

#ifndef RTS_MCU_GPIO_NUM
#define RTS_MCU_GPIO_NUM            8
#endif

enum {
	RTS_MCU_GPIO_IDLE = 0,
	RTS_MCU_GPIO_INUSE = 1
};

enum {
	RTS_MCU_GPIO_INPUT = 0,
	RTS_MCU_GPIO_OUTPUT = 1
};

enum {
	RTS_MCU_GPIO_LOW = 0,
	RTS_MCU_GPIO_HIGH = 1
};

void *rtscam_get_mcu(void);
void rtscam_put_mcu(void *inst);
int rtscam_exec_mcu_cmd(void *inst, struct rtscam_soc_cmd_stru *cmd);
u32 rtscam_read_mcu_reg(void *inst, off_t reg);
void rtscam_write_mcu_reg(void *inst, u32 value, off_t reg);

#endif
