1 2 /* 3 * mipi subdev driver module 4 * 5 * Copyright (c) 2017 by Allwinnertech Co., Ltd. http://www.allwinnertech.com 6 * 7 * Authors: Zhao Wei <zhaowei@allwinnertech.com> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 as 11 * published by the Free Software Foundation. 12 */ 13 14 #ifndef _SUNXI_MIPI__H_ 15 #define _SUNXI_MIPI__H_ 16 17 #include "../platform/platform_cfg.h" 18 #include "combo_rx/combo_rx_reg.h" 19 #include "combo_csi/combo_csi_reg.h" 20 21 enum mipi_pad { 22 MIPI_PAD_SINK, 23 MIPI_PAD_SOURCE, 24 MIPI_PAD_NUM, 25 }; 26 27 struct combo_config { 28 enum lvds_lane_num lvds_ln; 29 enum mipi_lane_num mipi_ln; 30 unsigned int lane_num; 31 unsigned int total_rx_ch; 32 }; 33 34 struct combo_format { 35 u32 code; 36 enum lvds_bit_width bit_width; 37 enum cmb_mipi_yuv_seq yuv_seq; 38 }; 39 40 struct mipi_dev { 41 struct v4l2_subdev subdev; 42 struct media_pad mipi_pads[MIPI_PAD_NUM]; 43 struct platform_device *pdev; 44 struct mutex subdev_lock; 45 struct mipi_para csi2_cfg; 46 struct mipi_fmt_cfg csi2_fmt; 47 struct combo_config cmb_cfg; 48 struct combo_format *cmb_fmt; 49 struct combo_sync_code sync_code; 50 struct combo_lane_map lvds_map; 51 struct combo_wdr_cfg wdr_cfg; 52 struct combo_csi_cfg cmb_csi_cfg; 53 struct v4l2_mbus_framefmt format; 54 void __iomem *base; 55 void __iomem *port_base; 56 char if_name[20]; 57 unsigned char id; 58 unsigned char if_type; 59 unsigned char cmb_mode; 60 unsigned char pyha_offset; 61 unsigned char time_hs; 62 unsigned char terminal_resistance; 63 unsigned char sensor_flags; /*0 means choose phy0,1 means choose phy1*/ 64 unsigned int settle_time; 65 }; 66 67 void sunxi_combo_set_sync_code(struct v4l2_subdev *sd, 68 struct combo_sync_code *sync); 69 void sunxi_combo_set_lane_map(struct v4l2_subdev *sd, 70 struct combo_lane_map *map); 71 void sunxi_combo_wdr_config(struct v4l2_subdev *sd, 72 struct combo_wdr_cfg *wdr); 73 struct v4l2_subdev *sunxi_mipi_get_subdev(int id); 74 int sunxi_mipi_platform_register(void); 75 void sunxi_mipi_platform_unregister(void); 76 77 #endif /*_SUNXI_MIPI__H_*/ 78