xref: /linux/include/media/drv-intf/exynos-fimc.h (revision a45ff5994c9cde41af627c46abb9f32beae68943)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Samsung S5P/Exynos4 SoC series camera interface driver header
4  *
5  * Copyright (C) 2010 - 2013 Samsung Electronics Co., Ltd.
6  * Sylwester Nawrocki <s.nawrocki@samsung.com>
7  */
8 
9 #ifndef S5P_FIMC_H_
10 #define S5P_FIMC_H_
11 
12 #include <media/media-entity.h>
13 #include <media/v4l2-dev.h>
14 #include <media/v4l2-mediabus.h>
15 
16 /*
17  * Enumeration of data inputs to the camera subsystem.
18  */
19 enum fimc_input {
20 	FIMC_INPUT_PARALLEL_0	= 1,
21 	FIMC_INPUT_PARALLEL_1,
22 	FIMC_INPUT_MIPI_CSI2_0	= 3,
23 	FIMC_INPUT_MIPI_CSI2_1,
24 	FIMC_INPUT_WRITEBACK_A	= 5,
25 	FIMC_INPUT_WRITEBACK_B,
26 	FIMC_INPUT_WRITEBACK_ISP = 5,
27 };
28 
29 /*
30  * Enumeration of the FIMC data bus types.
31  */
32 enum fimc_bus_type {
33 	/* Camera parallel bus */
34 	FIMC_BUS_TYPE_ITU_601 = 1,
35 	/* Camera parallel bus with embedded synchronization */
36 	FIMC_BUS_TYPE_ITU_656,
37 	/* Camera MIPI-CSI2 serial bus */
38 	FIMC_BUS_TYPE_MIPI_CSI2,
39 	/* FIFO link from LCD controller (WriteBack A) */
40 	FIMC_BUS_TYPE_LCD_WRITEBACK_A,
41 	/* FIFO link from LCD controller (WriteBack B) */
42 	FIMC_BUS_TYPE_LCD_WRITEBACK_B,
43 	/* FIFO link from FIMC-IS */
44 	FIMC_BUS_TYPE_ISP_WRITEBACK = FIMC_BUS_TYPE_LCD_WRITEBACK_B,
45 };
46 
47 #define fimc_input_is_parallel(x) ((x) == 1 || (x) == 2)
48 #define fimc_input_is_mipi_csi(x) ((x) == 3 || (x) == 4)
49 
50 /*
51  * The subdevices' group IDs.
52  */
53 #define GRP_ID_SENSOR		(1 << 8)
54 #define GRP_ID_FIMC_IS_SENSOR	(1 << 9)
55 #define GRP_ID_WRITEBACK	(1 << 10)
56 #define GRP_ID_CSIS		(1 << 11)
57 #define GRP_ID_FIMC		(1 << 12)
58 #define GRP_ID_FLITE		(1 << 13)
59 #define GRP_ID_FIMC_IS		(1 << 14)
60 
61 /**
62  * struct fimc_source_info - video source description required for the host
63  *			     interface configuration
64  *
65  * @fimc_bus_type: FIMC camera input type
66  * @sensor_bus_type: image sensor bus type, MIPI, ITU-R BT.601 etc.
67  * @flags: the parallel sensor bus flags defining signals polarity (V4L2_MBUS_*)
68  * @mux_id: FIMC camera interface multiplexer index (separate for MIPI and ITU)
69  */
70 struct fimc_source_info {
71 	enum fimc_bus_type fimc_bus_type;
72 	enum fimc_bus_type sensor_bus_type;
73 	u16 flags;
74 	u16 mux_id;
75 };
76 
77 /*
78  * v4l2_device notification id. This is only for internal use in the kernel.
79  * Sensor subdevs should issue S5P_FIMC_TX_END_NOTIFY notification in single
80  * frame capture mode when there is only one VSYNC pulse issued by the sensor
81  * at beginning of the frame transmission.
82  */
83 #define S5P_FIMC_TX_END_NOTIFY _IO('e', 0)
84 
85 #define FIMC_MAX_PLANES	3
86 
87 /**
88  * struct fimc_fmt - color format data structure
89  * @mbus_code: media bus pixel code, -1 if not applicable
90  * @name: format description
91  * @fourcc: fourcc code for this format, 0 if not applicable
92  * @color: the driver's private color format id
93  * @memplanes: number of physically non-contiguous data planes
94  * @colplanes: number of physically contiguous data planes
95  * @colorspace: v4l2 colorspace (V4L2_COLORSPACE_*)
96  * @depth: per plane driver's private 'number of bits per pixel'
97  * @mdataplanes: bitmask indicating meta data plane(s), (1 << plane_no)
98  * @flags: flags indicating which operation mode format applies to
99  */
100 struct fimc_fmt {
101 	u32 mbus_code;
102 	char	*name;
103 	u32	fourcc;
104 	u32	color;
105 	u16	memplanes;
106 	u16	colplanes;
107 	u8	colorspace;
108 	u8	depth[FIMC_MAX_PLANES];
109 	u16	mdataplanes;
110 	u16	flags;
111 #define FMT_FLAGS_CAM		(1 << 0)
112 #define FMT_FLAGS_M2M_IN	(1 << 1)
113 #define FMT_FLAGS_M2M_OUT	(1 << 2)
114 #define FMT_FLAGS_M2M		(1 << 1 | 1 << 2)
115 #define FMT_HAS_ALPHA		(1 << 3)
116 #define FMT_FLAGS_COMPRESSED	(1 << 4)
117 #define FMT_FLAGS_WRITEBACK	(1 << 5)
118 #define FMT_FLAGS_RAW_BAYER	(1 << 6)
119 #define FMT_FLAGS_YUV		(1 << 7)
120 };
121 
122 struct exynos_media_pipeline;
123 
124 /*
125  * Media pipeline operations to be called from within a video node,  i.e. the
126  * last entity within the pipeline. Implemented by related media device driver.
127  */
128 struct exynos_media_pipeline_ops {
129 	int (*prepare)(struct exynos_media_pipeline *p,
130 						struct media_entity *me);
131 	int (*unprepare)(struct exynos_media_pipeline *p);
132 	int (*open)(struct exynos_media_pipeline *p, struct media_entity *me,
133 							bool resume);
134 	int (*close)(struct exynos_media_pipeline *p);
135 	int (*set_stream)(struct exynos_media_pipeline *p, bool state);
136 };
137 
138 struct exynos_video_entity {
139 	struct video_device vdev;
140 	struct exynos_media_pipeline *pipe;
141 };
142 
143 struct exynos_media_pipeline {
144 	struct media_pipeline mp;
145 	const struct exynos_media_pipeline_ops *ops;
146 };
147 
148 static inline struct exynos_video_entity *vdev_to_exynos_video_entity(
149 					struct video_device *vdev)
150 {
151 	return container_of(vdev, struct exynos_video_entity, vdev);
152 }
153 
154 #define fimc_pipeline_call(ent, op, args...)				  \
155 	((!(ent) || !(ent)->pipe) ? -ENOENT : \
156 	(((ent)->pipe->ops && (ent)->pipe->ops->op) ? \
157 	(ent)->pipe->ops->op(((ent)->pipe), ##args) : -ENOIOCTLCMD))	  \
158 
159 #endif /* S5P_FIMC_H_ */
160