2 *************************************************************************
3 * Rockchip driver for CIF ISP 1.0
4 * (Based on Intel driver for sofiaxxx)
6 * Copyright (C) 2015 Intel Mobile Communications GmbH
7 * Copyright (C) 2016 Fuzhou Rockchip Electronics Co., Ltd.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *************************************************************************
16 #ifndef _CIF_ISP10_PLATFORM_H
17 #define _CIF_ISP10_PLATFORM_H
18 #include <linux/videodev2.h>
20 #define CIF_ISP10_SOC_RK3288 "rk3288"
21 #define CIF_ISP10_SOC_RK3368 "rk3368"
22 #define CIF_ISP10_SOC_RK3399 "rk3399"
24 #define DRIVER_NAME "rkisp10"
25 #define ISP_VDEV_NAME DRIVER_NAME "_ispdev"
26 #define SP_VDEV_NAME DRIVER_NAME "_selfpath"
27 #define MP_VDEV_NAME DRIVER_NAME "_mainpath"
28 #define DMA_VDEV_NAME DRIVER_NAME "_dmapath"
30 enum pltfrm_cam_signal_polarity {
31 PLTFRM_CAM_SIGNAL_HIGH_LEVEL = 0,
32 PLTFRM_CAM_SIGNAL_LOW_LEVEL = 1,
35 enum pltfrm_cam_sample_type {
36 PLTFRM_CAM_SDR_NEG_EDG = 0x10000001,
37 PLTFRM_CAM_SDR_POS_EDG = 0x10000002,
38 PLTFRM_CAM_DDR = 0x20000000
41 enum pltfrm_cam_itf_type {
42 PLTFRM_CAM_ITF_MIPI = 0x10000000,
43 PLTFRM_CAM_ITF_BT601_8 = 0x20000071,
44 PLTFRM_CAM_ITF_BT656_8 = 0x20000072,
45 PLTFRM_CAM_ITF_BT601_10 = 0x20000091,
46 PLTFRM_CAM_ITF_BT656_10 = 0x20000092,
47 PLTFRM_CAM_ITF_BT601_12 = 0x200000B1,
48 PLTFRM_CAM_ITF_BT656_12 = 0x200000B2,
49 PLTFRM_CAM_ITF_BT601_16 = 0x200000F1,
50 PLTFRM_CAM_ITF_BT656_16 = 0x200000F2
53 #define PLTFRM_CAM_ITF_MAIN_MASK 0xf0000000
54 #define PLTFRM_CAM_ITF_SUB_MASK 0x0000000f
55 #define PLTFRM_CAM_ITF_DVP_BW_MASK 0x000000f0
57 #define PLTFRM_CAM_ITF_IS_MIPI(a) \
58 (((a) & PLTFRM_CAM_ITF_MAIN_MASK) == 0x10000000)
59 #define PLTFRM_CAM_ITF_IS_DVP(a) \
60 (((a) & PLTFRM_CAM_ITF_MAIN_MASK) == 0x20000000)
61 #define PLTFRM_CAM_ITF_IS_BT656(a) (PLTFRM_CAM_ITF_IS_DVP(a) &&\
62 (((a) & PLTFRM_CAM_ITF_SUB_MASK) == 0x02))
63 #define PLTFRM_CAM_ITF_IS_BT601(a) (PLTFRM_CAM_ITF_IS_DVP(a) &&\
64 (((a) & PLTFRM_CAM_ITF_SUB_MASK) == 0x01))
65 #define PLTFRM_CAM_ITF_DVP_BW(a) \
66 ((((a) & PLTFRM_CAM_ITF_DVP_BW_MASK) >> 4) + 1)
68 struct pltfrm_cam_mipi_config {
75 struct pltfrm_cam_dvp_config {
76 enum pltfrm_cam_signal_polarity vsync;
77 enum pltfrm_cam_signal_polarity hsync;
78 enum pltfrm_cam_sample_type pclk;
81 struct pltfrm_cam_itf {
82 enum pltfrm_cam_itf_type type;
85 struct pltfrm_cam_mipi_config mipi;
86 struct pltfrm_cam_dvp_config dvp;
91 #define PLTFRM_CAM_ITF_MIPI_CFG(v, nb, br, mk)\
93 .type = PLTFRM_CAM_ITF_MIPI,\
104 #define PLTFRM_CAM_ITF_DVP_CFG(ty, vs, hs, ck, mk)\
117 #define PLTFRM_CIFCAM_IOCTL_INTERNAL_BASE 0x00
118 #define PLTFRM_CIFCAM_G_ITF_CFG \
119 (PLTFRM_CIFCAM_IOCTL_INTERNAL_BASE + 1)
120 #define PLTFRM_CIFCAM_G_DEFRECT \
121 (PLTFRM_CIFCAM_IOCTL_INTERNAL_BASE + 2)
122 #define PLTFRM_CIFCAM_ATTACH \
123 (PLTFRM_CIFCAM_IOCTL_INTERNAL_BASE + 3)
125 struct pltfrm_cam_defrect {
128 struct v4l2_rect defrect;
131 enum pltfrm_soc_cfg_cmd {
133 PLTFRM_MIPI_DPHY_CFG,
142 enum pltfrm_soc_io_voltage {
147 enum pltfrm_soc_drv_strength {
148 PLTFRM_DRV_STRENGTH_0 = 0,
149 PLTFRM_DRV_STRENGTH_1 = 1,
150 PLTFRM_DRV_STRENGTH_2 = 2,
151 PLTFRM_DRV_STRENGTH_3 = 3
155 struct pltfrm_soc_init_para {
156 struct platform_device *pdev;
157 void __iomem *isp_base;
160 struct pltfrm_soc_mclk_para {
161 enum pltfrm_soc_io_voltage io_voltage;
162 enum pltfrm_soc_drv_strength drv_strength;
165 struct pltfrm_soc_cfg_para {
166 enum pltfrm_soc_cfg_cmd cmd;
170 struct pltfrm_soc_cfg {
172 int (*soc_cfg)(struct pltfrm_soc_cfg_para *cfg);
175 int pltfrm_rk3288_cfg(
176 struct pltfrm_soc_cfg_para *cfg);
177 int pltfrm_rk3399_cfg(
178 struct pltfrm_soc_cfg_para *cfg);