Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Samsung S5P/Exynos4 SoC series camera interface driver header
0004  *
0005  * Copyright (C) 2010 - 2013 Samsung Electronics Co., Ltd.
0006  * Sylwester Nawrocki <s.nawrocki@samsung.com>
0007  */
0008 
0009 #ifndef S5P_FIMC_H_
0010 #define S5P_FIMC_H_
0011 
0012 #include <media/media-entity.h>
0013 #include <media/v4l2-dev.h>
0014 #include <media/v4l2-mediabus.h>
0015 
0016 /*
0017  * Enumeration of data inputs to the camera subsystem.
0018  */
0019 enum fimc_input {
0020     FIMC_INPUT_PARALLEL_0   = 1,
0021     FIMC_INPUT_PARALLEL_1,
0022     FIMC_INPUT_MIPI_CSI2_0  = 3,
0023     FIMC_INPUT_MIPI_CSI2_1,
0024     FIMC_INPUT_WRITEBACK_A  = 5,
0025     FIMC_INPUT_WRITEBACK_B,
0026     FIMC_INPUT_WRITEBACK_ISP = 5,
0027 };
0028 
0029 /*
0030  * Enumeration of the FIMC data bus types.
0031  */
0032 enum fimc_bus_type {
0033     /* Camera parallel bus */
0034     FIMC_BUS_TYPE_ITU_601 = 1,
0035     /* Camera parallel bus with embedded synchronization */
0036     FIMC_BUS_TYPE_ITU_656,
0037     /* Camera MIPI-CSI2 serial bus */
0038     FIMC_BUS_TYPE_MIPI_CSI2,
0039     /* FIFO link from LCD controller (WriteBack A) */
0040     FIMC_BUS_TYPE_LCD_WRITEBACK_A,
0041     /* FIFO link from LCD controller (WriteBack B) */
0042     FIMC_BUS_TYPE_LCD_WRITEBACK_B,
0043     /* FIFO link from FIMC-IS */
0044     FIMC_BUS_TYPE_ISP_WRITEBACK = FIMC_BUS_TYPE_LCD_WRITEBACK_B,
0045 };
0046 
0047 #define fimc_input_is_parallel(x) ((x) == 1 || (x) == 2)
0048 #define fimc_input_is_mipi_csi(x) ((x) == 3 || (x) == 4)
0049 
0050 /*
0051  * The subdevices' group IDs.
0052  */
0053 #define GRP_ID_SENSOR       (1 << 8)
0054 #define GRP_ID_FIMC_IS_SENSOR   (1 << 9)
0055 #define GRP_ID_WRITEBACK    (1 << 10)
0056 #define GRP_ID_CSIS     (1 << 11)
0057 #define GRP_ID_FIMC     (1 << 12)
0058 #define GRP_ID_FLITE        (1 << 13)
0059 #define GRP_ID_FIMC_IS      (1 << 14)
0060 
0061 /**
0062  * struct fimc_source_info - video source description required for the host
0063  *               interface configuration
0064  *
0065  * @fimc_bus_type: FIMC camera input type
0066  * @sensor_bus_type: image sensor bus type, MIPI, ITU-R BT.601 etc.
0067  * @flags: the parallel sensor bus flags defining signals polarity (V4L2_MBUS_*)
0068  * @mux_id: FIMC camera interface multiplexer index (separate for MIPI and ITU)
0069  */
0070 struct fimc_source_info {
0071     enum fimc_bus_type fimc_bus_type;
0072     enum fimc_bus_type sensor_bus_type;
0073     u16 flags;
0074     u16 mux_id;
0075 };
0076 
0077 /*
0078  * v4l2_device notification id. This is only for internal use in the kernel.
0079  * Sensor subdevs should issue S5P_FIMC_TX_END_NOTIFY notification in single
0080  * frame capture mode when there is only one VSYNC pulse issued by the sensor
0081  * at beginning of the frame transmission.
0082  */
0083 #define S5P_FIMC_TX_END_NOTIFY _IO('e', 0)
0084 
0085 #define FIMC_MAX_PLANES 3
0086 
0087 /**
0088  * struct fimc_fmt - color format data structure
0089  * @mbus_code: media bus pixel code, -1 if not applicable
0090  * @fourcc: fourcc code for this format, 0 if not applicable
0091  * @color: the driver's private color format id
0092  * @memplanes: number of physically non-contiguous data planes
0093  * @colplanes: number of physically contiguous data planes
0094  * @colorspace: v4l2 colorspace (V4L2_COLORSPACE_*)
0095  * @depth: per plane driver's private 'number of bits per pixel'
0096  * @mdataplanes: bitmask indicating meta data plane(s), (1 << plane_no)
0097  * @flags: flags indicating which operation mode format applies to
0098  */
0099 struct fimc_fmt {
0100     u32 mbus_code;
0101     u32 fourcc;
0102     u32 color;
0103     u16 memplanes;
0104     u16 colplanes;
0105     u8  colorspace;
0106     u8  depth[FIMC_MAX_PLANES];
0107     u16 mdataplanes;
0108     u16 flags;
0109 #define FMT_FLAGS_CAM       (1 << 0)
0110 #define FMT_FLAGS_M2M_IN    (1 << 1)
0111 #define FMT_FLAGS_M2M_OUT   (1 << 2)
0112 #define FMT_FLAGS_M2M       (1 << 1 | 1 << 2)
0113 #define FMT_HAS_ALPHA       (1 << 3)
0114 #define FMT_FLAGS_COMPRESSED    (1 << 4)
0115 #define FMT_FLAGS_WRITEBACK (1 << 5)
0116 #define FMT_FLAGS_RAW_BAYER (1 << 6)
0117 #define FMT_FLAGS_YUV       (1 << 7)
0118 };
0119 
0120 struct exynos_media_pipeline;
0121 
0122 /*
0123  * Media pipeline operations to be called from within a video node,  i.e. the
0124  * last entity within the pipeline. Implemented by related media device driver.
0125  */
0126 struct exynos_media_pipeline_ops {
0127     int (*prepare)(struct exynos_media_pipeline *p,
0128                         struct media_entity *me);
0129     int (*unprepare)(struct exynos_media_pipeline *p);
0130     int (*open)(struct exynos_media_pipeline *p, struct media_entity *me,
0131                             bool resume);
0132     int (*close)(struct exynos_media_pipeline *p);
0133     int (*set_stream)(struct exynos_media_pipeline *p, bool state);
0134 };
0135 
0136 struct exynos_video_entity {
0137     struct video_device vdev;
0138     struct exynos_media_pipeline *pipe;
0139 };
0140 
0141 struct exynos_media_pipeline {
0142     struct media_pipeline mp;
0143     const struct exynos_media_pipeline_ops *ops;
0144 };
0145 
0146 static inline struct exynos_video_entity *vdev_to_exynos_video_entity(
0147                     struct video_device *vdev)
0148 {
0149     return container_of(vdev, struct exynos_video_entity, vdev);
0150 }
0151 
0152 #define fimc_pipeline_call(ent, op, args...)                  \
0153     ((!(ent) || !(ent)->pipe) ? -ENOENT : \
0154     (((ent)->pipe->ops && (ent)->pipe->ops->op) ? \
0155     (ent)->pipe->ops->op(((ent)->pipe), ##args) : -ENOIOCTLCMD))      \
0156 
0157 #endif /* S5P_FIMC_H_ */