1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Medifield PNW Camera Imaging ISP subsystem. 4 * 5 * Copyright (c) 2010 Intel Corporation. All Rights Reserved. 6 */ 7 #ifndef ATOMISP_PLATFORM_H_ 8 #define ATOMISP_PLATFORM_H_ 9 10 #include <asm/cpu_device_id.h> 11 #include <asm/processor.h> 12 13 #include <linux/i2c.h> 14 #include <media/v4l2-subdev.h> 15 #include "atomisp.h" 16 17 #define MAX_SENSORS_PER_PORT 4 18 #define MAX_STREAMS_PER_CHANNEL 2 19 20 #define CAMERA_MODULE_ID_LEN 64 21 22 enum atomisp_bayer_order { 23 atomisp_bayer_order_grbg, 24 atomisp_bayer_order_rggb, 25 atomisp_bayer_order_bggr, 26 atomisp_bayer_order_gbrg 27 }; 28 29 enum atomisp_input_stream_id { 30 ATOMISP_INPUT_STREAM_GENERAL = 0, 31 ATOMISP_INPUT_STREAM_CAPTURE = 0, 32 ATOMISP_INPUT_STREAM_POSTVIEW, 33 ATOMISP_INPUT_STREAM_PREVIEW, 34 ATOMISP_INPUT_STREAM_VIDEO, 35 ATOMISP_INPUT_STREAM_NUM 36 }; 37 38 enum atomisp_input_format { 39 ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY,/* 8 bits per subpixel (legacy) */ 40 ATOMISP_INPUT_FORMAT_YUV420_8, /* 8 bits per subpixel */ 41 ATOMISP_INPUT_FORMAT_YUV420_10,/* 10 bits per subpixel */ 42 ATOMISP_INPUT_FORMAT_YUV420_16,/* 16 bits per subpixel */ 43 ATOMISP_INPUT_FORMAT_YUV422_8, /* UYVY..UVYV, 8 bits per subpixel */ 44 ATOMISP_INPUT_FORMAT_YUV422_10,/* UYVY..UVYV, 10 bits per subpixel */ 45 ATOMISP_INPUT_FORMAT_YUV422_16,/* UYVY..UVYV, 16 bits per subpixel */ 46 ATOMISP_INPUT_FORMAT_RGB_444, /* BGR..BGR, 4 bits per subpixel */ 47 ATOMISP_INPUT_FORMAT_RGB_555, /* BGR..BGR, 5 bits per subpixel */ 48 ATOMISP_INPUT_FORMAT_RGB_565, /* BGR..BGR, 5 bits B and R, 6 bits G */ 49 ATOMISP_INPUT_FORMAT_RGB_666, /* BGR..BGR, 6 bits per subpixel */ 50 ATOMISP_INPUT_FORMAT_RGB_888, /* BGR..BGR, 8 bits per subpixel */ 51 ATOMISP_INPUT_FORMAT_RAW_6, /* RAW data, 6 bits per pixel */ 52 ATOMISP_INPUT_FORMAT_RAW_7, /* RAW data, 7 bits per pixel */ 53 ATOMISP_INPUT_FORMAT_RAW_8, /* RAW data, 8 bits per pixel */ 54 ATOMISP_INPUT_FORMAT_RAW_10, /* RAW data, 10 bits per pixel */ 55 ATOMISP_INPUT_FORMAT_RAW_12, /* RAW data, 12 bits per pixel */ 56 ATOMISP_INPUT_FORMAT_RAW_14, /* RAW data, 14 bits per pixel */ 57 ATOMISP_INPUT_FORMAT_RAW_16, /* RAW data, 16 bits per pixel */ 58 ATOMISP_INPUT_FORMAT_BINARY_8, /* Binary byte stream. */ 59 60 /* CSI2-MIPI specific format: Generic short packet data. It is used to 61 * keep the timing information for the opening/closing of shutters, 62 * triggering of flashes and etc. 63 */ 64 ATOMISP_INPUT_FORMAT_GENERIC_SHORT1, /* Generic Short Packet Code 1 */ 65 ATOMISP_INPUT_FORMAT_GENERIC_SHORT2, /* Generic Short Packet Code 2 */ 66 ATOMISP_INPUT_FORMAT_GENERIC_SHORT3, /* Generic Short Packet Code 3 */ 67 ATOMISP_INPUT_FORMAT_GENERIC_SHORT4, /* Generic Short Packet Code 4 */ 68 ATOMISP_INPUT_FORMAT_GENERIC_SHORT5, /* Generic Short Packet Code 5 */ 69 ATOMISP_INPUT_FORMAT_GENERIC_SHORT6, /* Generic Short Packet Code 6 */ 70 ATOMISP_INPUT_FORMAT_GENERIC_SHORT7, /* Generic Short Packet Code 7 */ 71 ATOMISP_INPUT_FORMAT_GENERIC_SHORT8, /* Generic Short Packet Code 8 */ 72 73 /* CSI2-MIPI specific format: YUV data. 74 */ 75 ATOMISP_INPUT_FORMAT_YUV420_8_SHIFT, /* YUV420 8-bit (Chroma Shifted 76 Pixel Sampling) */ 77 ATOMISP_INPUT_FORMAT_YUV420_10_SHIFT, /* YUV420 8-bit (Chroma Shifted 78 Pixel Sampling) */ 79 80 /* CSI2-MIPI specific format: Generic long packet data 81 */ 82 ATOMISP_INPUT_FORMAT_EMBEDDED, /* Embedded 8-bit non Image Data */ 83 84 /* CSI2-MIPI specific format: User defined byte-based data. For example, 85 * the data transmitter (e.g. the SoC sensor) can keep the JPEG data as 86 * the User Defined Data Type 4 and the MPEG data as the 87 * User Defined Data Type 7. 88 */ 89 ATOMISP_INPUT_FORMAT_USER_DEF1, /* User defined 8-bit data type 1 */ 90 ATOMISP_INPUT_FORMAT_USER_DEF2, /* User defined 8-bit data type 2 */ 91 ATOMISP_INPUT_FORMAT_USER_DEF3, /* User defined 8-bit data type 3 */ 92 ATOMISP_INPUT_FORMAT_USER_DEF4, /* User defined 8-bit data type 4 */ 93 ATOMISP_INPUT_FORMAT_USER_DEF5, /* User defined 8-bit data type 5 */ 94 ATOMISP_INPUT_FORMAT_USER_DEF6, /* User defined 8-bit data type 6 */ 95 ATOMISP_INPUT_FORMAT_USER_DEF7, /* User defined 8-bit data type 7 */ 96 ATOMISP_INPUT_FORMAT_USER_DEF8, /* User defined 8-bit data type 8 */ 97 }; 98 99 #define N_ATOMISP_INPUT_FORMAT (ATOMISP_INPUT_FORMAT_USER_DEF8 + 1) 100 101 struct intel_v4l2_subdev_table { 102 enum atomisp_camera_port port; 103 unsigned int lanes; 104 struct v4l2_subdev *subdev; 105 }; 106 107 /* 108 * Sensor of external ISP can send multiple streams with different mipi data 109 * type in the same virtual channel. This information needs to come from the 110 * sensor or external ISP 111 */ 112 struct atomisp_isys_config_info { 113 u8 input_format; 114 u16 width; 115 u16 height; 116 }; 117 118 struct atomisp_input_stream_info { 119 enum atomisp_input_stream_id stream; 120 u8 enable; 121 /* Sensor driver fills ch_id with the id 122 of the virtual channel. */ 123 u8 ch_id; 124 /* Tells how many streams in this virtual channel. If 0 ignore rest 125 * and the input format will be from mipi_info */ 126 u8 isys_configs; 127 /* 128 * if more isys_configs is more than 0, sensor needs to configure the 129 * input format differently. width and height can be 0. If width and 130 * height is not zero, then the corresponding data needs to be set 131 */ 132 struct atomisp_isys_config_info isys_info[MAX_STREAMS_PER_CHANNEL]; 133 }; 134 135 struct camera_sensor_platform_data { 136 int (*flisclk_ctrl)(struct v4l2_subdev *subdev, int flag); 137 int (*csi_cfg)(struct v4l2_subdev *subdev, int flag); 138 139 /* 140 * New G-Min power and GPIO interface to control individual 141 * lines as implemented on all known camera modules. 142 */ 143 int (*gpio0_ctrl)(struct v4l2_subdev *subdev, int on); 144 int (*gpio1_ctrl)(struct v4l2_subdev *subdev, int on); 145 int (*v1p8_ctrl)(struct v4l2_subdev *subdev, int on); 146 int (*v2p8_ctrl)(struct v4l2_subdev *subdev, int on); 147 int (*v1p2_ctrl)(struct v4l2_subdev *subdev, int on); 148 }; 149 150 struct camera_mipi_info { 151 enum atomisp_camera_port port; 152 unsigned int num_lanes; 153 enum atomisp_input_format input_format; 154 enum atomisp_bayer_order raw_bayer_order; 155 enum atomisp_input_format metadata_format; 156 u32 metadata_width; 157 u32 metadata_height; 158 const u32 *metadata_effective_width; 159 }; 160 161 const struct intel_v4l2_subdev_table *atomisp_platform_get_subdevs(void); 162 int atomisp_register_sensor_no_gmin(struct v4l2_subdev *subdev, u32 lanes, 163 enum atomisp_input_format format, 164 enum atomisp_bayer_order bayer_order); 165 void atomisp_unregister_subdev(struct v4l2_subdev *subdev); 166 167 /* API from old platform_camera.h, new CPUID implementation */ 168 #define __IS_SOC(x) (boot_cpu_data.x86_vfm == x) 169 #define __IS_SOCS(x, y) (boot_cpu_data.x86_vfm == x || boot_cpu_data.x86_vfm == y) 170 171 #define IS_MFLD __IS_SOC(INTEL_ATOM_SALTWELL_MID) 172 #define IS_BYT __IS_SOC(INTEL_ATOM_SILVERMONT) 173 #define IS_CHT __IS_SOC(INTEL_ATOM_AIRMONT) 174 #define IS_MRFD __IS_SOC(INTEL_ATOM_SILVERMONT_MID) 175 #define IS_MOFD __IS_SOC(INTEL_ATOM_AIRMONT_MID) 176 177 /* Both CHT and MOFD come with ISP2401 */ 178 #define IS_ISP2401 __IS_SOCS(INTEL_ATOM_AIRMONT, \ 179 INTEL_ATOM_AIRMONT_MID) 180 181 #endif /* ATOMISP_PLATFORM_H_ */ 182