1 /* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
2 /*
3  * Rockchip ISP1 Driver - Common definitions
4  *
5  * Copyright (C) 2019 Collabora, Ltd.
6  *
7  * Based on Rockchip ISP1 driver by Rockchip Electronics Co., Ltd.
8  * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
9  */
10 
11 #ifndef _RKISP1_COMMON_H
12 #define _RKISP1_COMMON_H
13 
14 #include <linux/clk.h>
15 #include <linux/interrupt.h>
16 #include <linux/mutex.h>
17 #include <linux/rkisp1-config.h>
18 #include <media/media-device.h>
19 #include <media/media-entity.h>
20 #include <media/v4l2-ctrls.h>
21 #include <media/v4l2-device.h>
22 #include <media/videobuf2-v4l2.h>
23 
24 #include "rkisp1-regs.h"
25 
26 struct dentry;
27 
28 /*
29  * flags on the 'direction' field in struct rkisp1_mbus_info' that indicate
30  * on which pad the media bus format is supported
31  */
32 #define RKISP1_ISP_SD_SRC			BIT(0)
33 #define RKISP1_ISP_SD_SINK			BIT(1)
34 
35 /* min and max values for the widths and heights of the entities */
36 #define RKISP1_ISP_MAX_WIDTH			4032
37 #define RKISP1_ISP_MAX_HEIGHT			3024
38 #define RKISP1_ISP_MIN_WIDTH			32
39 #define RKISP1_ISP_MIN_HEIGHT			32
40 
41 #define RKISP1_RSZ_MP_SRC_MAX_WIDTH		4416
42 #define RKISP1_RSZ_MP_SRC_MAX_HEIGHT		3312
43 #define RKISP1_RSZ_SP_SRC_MAX_WIDTH		1920
44 #define RKISP1_RSZ_SP_SRC_MAX_HEIGHT		1920
45 #define RKISP1_RSZ_SRC_MIN_WIDTH		32
46 #define RKISP1_RSZ_SRC_MIN_HEIGHT		16
47 
48 /* the default width and height of all the entities */
49 #define RKISP1_DEFAULT_WIDTH			800
50 #define RKISP1_DEFAULT_HEIGHT			600
51 
52 #define RKISP1_DRIVER_NAME			"rkisp1"
53 #define RKISP1_BUS_INFO				"platform:" RKISP1_DRIVER_NAME
54 
55 /* maximum number of clocks */
56 #define RKISP1_MAX_BUS_CLK			8
57 
58 /* a bitmask of the ready stats */
59 #define RKISP1_STATS_MEAS_MASK			(RKISP1_CIF_ISP_AWB_DONE |	\
60 						 RKISP1_CIF_ISP_AFM_FIN |	\
61 						 RKISP1_CIF_ISP_EXP_END |	\
62 						 RKISP1_CIF_ISP_HIST_MEASURE_RDY)
63 
64 /* IRQ lines */
65 enum rkisp1_irq_line {
66 	RKISP1_IRQ_ISP = 0,
67 	RKISP1_IRQ_MI,
68 	RKISP1_IRQ_MIPI,
69 	RKISP1_NUM_IRQS,
70 };
71 
72 /* enum for the resizer pads */
73 enum rkisp1_rsz_pad {
74 	RKISP1_RSZ_PAD_SINK,
75 	RKISP1_RSZ_PAD_SRC,
76 	RKISP1_RSZ_PAD_MAX
77 };
78 
79 /* enum for the csi receiver pads */
80 enum rkisp1_csi_pad {
81 	RKISP1_CSI_PAD_SINK,
82 	RKISP1_CSI_PAD_SRC,
83 	RKISP1_CSI_PAD_NUM
84 };
85 
86 /* enum for the capture id */
87 enum rkisp1_stream_id {
88 	RKISP1_MAINPATH,
89 	RKISP1_SELFPATH,
90 };
91 
92 /* bayer patterns */
93 enum rkisp1_fmt_raw_pat_type {
94 	RKISP1_RAW_RGGB = 0,
95 	RKISP1_RAW_GRBG,
96 	RKISP1_RAW_GBRG,
97 	RKISP1_RAW_BGGR,
98 };
99 
100 /* enum for the isp pads */
101 enum rkisp1_isp_pad {
102 	RKISP1_ISP_PAD_SINK_VIDEO,
103 	RKISP1_ISP_PAD_SINK_PARAMS,
104 	RKISP1_ISP_PAD_SOURCE_VIDEO,
105 	RKISP1_ISP_PAD_SOURCE_STATS,
106 	RKISP1_ISP_PAD_MAX
107 };
108 
109 /*
110  * enum rkisp1_feature - ISP features
111  *
112  * @RKISP1_FEATURE_MIPI_CSI2: The ISP has an internal MIPI CSI-2 receiver
113  *
114  * The ISP features are stored in a bitmask in &rkisp1_info.features and allow
115  * the driver to implement support for features present in some ISP versions
116  * only.
117  */
118 enum rkisp1_feature {
119 	RKISP1_FEATURE_MIPI_CSI2 = BIT(0),
120 };
121 
122 /*
123  * struct rkisp1_info - Model-specific ISP Information
124  *
125  * @clks: array of ISP clock names
126  * @clk_size: number of entries in the @clks array
127  * @isrs: array of ISP interrupt descriptors
128  * @isr_size: number of entries in the @isrs array
129  * @isp_ver: ISP version
130  * @features: bitmask of rkisp1_feature features implemented by the ISP
131  *
132  * This structure contains information about the ISP specific to a particular
133  * ISP model, version, or integration in a particular SoC.
134  */
135 struct rkisp1_info {
136 	const char * const *clks;
137 	unsigned int clk_size;
138 	const struct rkisp1_isr_data *isrs;
139 	unsigned int isr_size;
140 	enum rkisp1_cif_isp_version isp_ver;
141 	unsigned int features;
142 };
143 
144 /*
145  * struct rkisp1_sensor_async - A container for the v4l2_async_subdev to add to the notifier
146  *				of the v4l2-async API
147  *
148  * @asd:		async_subdev variable for the sensor
149  * @index:		index of the sensor (counting sensor found in DT)
150  * @source_ep:		fwnode for the sensor source endpoint
151  * @lanes:		number of lanes
152  * @mbus_type:		type of bus (currently only CSI2 is supported)
153  * @mbus_flags:		media bus (V4L2_MBUS_*) flags
154  * @sd:			a pointer to v4l2_subdev struct of the sensor
155  * @pixel_rate_ctrl:	pixel rate of the sensor, used to initialize the phy
156  * @port:		port number (0: MIPI, 1: Parallel)
157  */
158 struct rkisp1_sensor_async {
159 	struct v4l2_async_connection asd;
160 	unsigned int index;
161 	struct fwnode_handle *source_ep;
162 	unsigned int lanes;
163 	enum v4l2_mbus_type mbus_type;
164 	unsigned int mbus_flags;
165 	struct v4l2_subdev *sd;
166 	struct v4l2_ctrl *pixel_rate_ctrl;
167 	unsigned int port;
168 };
169 
170 /*
171  * struct rkisp1_csi - CSI receiver subdev
172  *
173  * @rkisp1: pointer to the rkisp1 device
174  * @dphy: a pointer to the phy
175  * @is_dphy_errctrl_disabled: if dphy errctrl is disabled (avoid endless interrupt)
176  * @sd: v4l2_subdev variable
177  * @pads: media pads
178  * @pad_cfg: configurations for the pads
179  * @sink_fmt: input format
180  * @lock: protects pad_cfg and sink_fmt
181  * @source: source in-use, set when starting streaming
182  */
183 struct rkisp1_csi {
184 	struct rkisp1_device *rkisp1;
185 	struct phy *dphy;
186 	bool is_dphy_errctrl_disabled;
187 	struct v4l2_subdev sd;
188 	struct media_pad pads[RKISP1_CSI_PAD_NUM];
189 	struct v4l2_subdev_pad_config pad_cfg[RKISP1_CSI_PAD_NUM];
190 	const struct rkisp1_mbus_info *sink_fmt;
191 	struct mutex lock;
192 	struct v4l2_subdev *source;
193 };
194 
195 /*
196  * struct rkisp1_isp - ISP subdev entity
197  *
198  * @sd:				v4l2_subdev variable
199  * @rkisp1:			pointer to rkisp1_device
200  * @pads:			media pads
201  * @pad_cfg:			pads configurations
202  * @sink_fmt:			input format
203  * @src_fmt:			output format
204  * @ops_lock:			ops serialization
205  * @frame_sequence:		used to synchronize frame_id between video devices.
206  */
207 struct rkisp1_isp {
208 	struct v4l2_subdev sd;
209 	struct rkisp1_device *rkisp1;
210 	struct media_pad pads[RKISP1_ISP_PAD_MAX];
211 	struct v4l2_subdev_pad_config pad_cfg[RKISP1_ISP_PAD_MAX];
212 	const struct rkisp1_mbus_info *sink_fmt;
213 	const struct rkisp1_mbus_info *src_fmt;
214 	struct mutex ops_lock; /* serialize the subdevice ops */
215 	__u32 frame_sequence;
216 };
217 
218 /*
219  * struct rkisp1_vdev_node - Container for the video nodes: params, stats, mainpath, selfpath
220  *
221  * @buf_queue:	queue of buffers
222  * @vlock:	lock of the video node
223  * @vdev:	video node
224  * @pad:	media pad
225  */
226 struct rkisp1_vdev_node {
227 	struct vb2_queue buf_queue;
228 	struct mutex vlock; /* ioctl serialization mutex */
229 	struct video_device vdev;
230 	struct media_pad pad;
231 };
232 
233 /*
234  * struct rkisp1_buffer - A container for the vb2 buffers used by the video devices:
235  *			  params, stats, mainpath, selfpath
236  *
237  * @vb:		vb2 buffer
238  * @queue:	entry of the buffer in the queue
239  * @buff_addr:	dma addresses of each plane, used only by the capture devices: selfpath, mainpath
240  */
241 struct rkisp1_buffer {
242 	struct vb2_v4l2_buffer vb;
243 	struct list_head queue;
244 	u32 buff_addr[VIDEO_MAX_PLANES];
245 };
246 
247 /*
248  * struct rkisp1_dummy_buffer - A buffer to write the next frame to in case
249  *				there are no vb2 buffers available.
250  *
251  * @vaddr:	return value of call to dma_alloc_attrs.
252  * @dma_addr:	dma address of the buffer.
253  * @size:	size of the buffer.
254  */
255 struct rkisp1_dummy_buffer {
256 	void *vaddr;
257 	dma_addr_t dma_addr;
258 	u32 size;
259 };
260 
261 struct rkisp1_device;
262 
263 /*
264  * struct rkisp1_capture - ISP capture video device
265  *
266  * @vnode:	  video node
267  * @rkisp1:	  pointer to rkisp1_device
268  * @id:		  id of the capture, one of RKISP1_SELFPATH, RKISP1_MAINPATH
269  * @ops:	  list of callbacks to configure the capture device.
270  * @config:	  a pointer to the list of registers to configure the capture format.
271  * @is_streaming: device is streaming
272  * @is_stopping:  stop_streaming callback was called and the device is in the process of
273  *		  stopping the streaming.
274  * @done:	  when stop_streaming callback is called, the device waits for the next irq
275  *		  handler to stop the streaming by waiting on the 'done' wait queue.
276  *		  If the irq handler is not called, the stream is stopped by the callback
277  *		  after timeout.
278  * @sp_y_stride:  the selfpath allows to configure a y stride that is longer than the image width.
279  * @buf.lock:	  lock to protect buf.queue
280  * @buf.queue:	  queued buffer list
281  * @buf.dummy:	  dummy space to store dropped data
282  *
283  * rkisp1 uses shadow registers, so it needs two buffers at a time
284  * @buf.curr:	  the buffer used for current frame
285  * @buf.next:	  the buffer used for next frame
286  * @pix.cfg:	  pixel configuration
287  * @pix.info:	  a pointer to the v4l2_format_info of the pixel format
288  * @pix.fmt:	  buffer format
289  */
290 struct rkisp1_capture {
291 	struct rkisp1_vdev_node vnode;
292 	struct rkisp1_device *rkisp1;
293 	enum rkisp1_stream_id id;
294 	const struct rkisp1_capture_ops *ops;
295 	const struct rkisp1_capture_config *config;
296 	bool is_streaming;
297 	bool is_stopping;
298 	wait_queue_head_t done;
299 	unsigned int sp_y_stride;
300 	struct {
301 		/* protects queue, curr and next */
302 		spinlock_t lock;
303 		struct list_head queue;
304 		struct rkisp1_dummy_buffer dummy;
305 		struct rkisp1_buffer *curr;
306 		struct rkisp1_buffer *next;
307 	} buf;
308 	struct {
309 		const struct rkisp1_capture_fmt_cfg *cfg;
310 		const struct v4l2_format_info *info;
311 		struct v4l2_pix_format_mplane fmt;
312 	} pix;
313 };
314 
315 struct rkisp1_stats;
316 struct rkisp1_stats_ops {
317 	void (*get_awb_meas)(struct rkisp1_stats *stats,
318 			     struct rkisp1_stat_buffer *pbuf);
319 	void (*get_aec_meas)(struct rkisp1_stats *stats,
320 			     struct rkisp1_stat_buffer *pbuf);
321 	void (*get_hst_meas)(struct rkisp1_stats *stats,
322 			     struct rkisp1_stat_buffer *pbuf);
323 };
324 
325 /*
326  * struct rkisp1_stats - ISP Statistics device
327  *
328  * @vnode:	  video node
329  * @rkisp1:	  pointer to the rkisp1 device
330  * @lock:	  locks the buffer list 'stat'
331  * @stat:	  queue of rkisp1_buffer
332  * @vdev_fmt:	  v4l2_format of the metadata format
333  */
334 struct rkisp1_stats {
335 	struct rkisp1_vdev_node vnode;
336 	struct rkisp1_device *rkisp1;
337 	const struct rkisp1_stats_ops *ops;
338 
339 	spinlock_t lock; /* locks the buffers list 'stats' */
340 	struct list_head stat;
341 	struct v4l2_format vdev_fmt;
342 };
343 
344 struct rkisp1_params;
345 struct rkisp1_params_ops {
346 	void (*lsc_matrix_config)(struct rkisp1_params *params,
347 				  const struct rkisp1_cif_isp_lsc_config *pconfig);
348 	void (*goc_config)(struct rkisp1_params *params,
349 			   const struct rkisp1_cif_isp_goc_config *arg);
350 	void (*awb_meas_config)(struct rkisp1_params *params,
351 				const struct rkisp1_cif_isp_awb_meas_config *arg);
352 	void (*awb_meas_enable)(struct rkisp1_params *params,
353 				const struct rkisp1_cif_isp_awb_meas_config *arg,
354 				bool en);
355 	void (*awb_gain_config)(struct rkisp1_params *params,
356 				const struct rkisp1_cif_isp_awb_gain_config *arg);
357 	void (*aec_config)(struct rkisp1_params *params,
358 			   const struct rkisp1_cif_isp_aec_config *arg);
359 	void (*hst_config)(struct rkisp1_params *params,
360 			   const struct rkisp1_cif_isp_hst_config *arg);
361 	void (*hst_enable)(struct rkisp1_params *params,
362 			   const struct rkisp1_cif_isp_hst_config *arg, bool en);
363 	void (*afm_config)(struct rkisp1_params *params,
364 			   const struct rkisp1_cif_isp_afc_config *arg);
365 };
366 
367 /*
368  * struct rkisp1_params - ISP input parameters device
369  *
370  * @vnode:		video node
371  * @rkisp1:		pointer to the rkisp1 device
372  * @ops:		pointer to the variant-specific operations
373  * @config_lock:	locks the buffer list 'params'
374  * @params:		queue of rkisp1_buffer
375  * @vdev_fmt:		v4l2_format of the metadata format
376  * @quantization:	the quantization configured on the isp's src pad
377  * @raw_type:		the bayer pattern on the isp video sink pad
378  */
379 struct rkisp1_params {
380 	struct rkisp1_vdev_node vnode;
381 	struct rkisp1_device *rkisp1;
382 	const struct rkisp1_params_ops *ops;
383 
384 	spinlock_t config_lock; /* locks the buffers list 'params' */
385 	struct list_head params;
386 	struct v4l2_format vdev_fmt;
387 
388 	enum v4l2_quantization quantization;
389 	enum v4l2_ycbcr_encoding ycbcr_encoding;
390 	enum rkisp1_fmt_raw_pat_type raw_type;
391 };
392 
393 /*
394  * struct rkisp1_resizer - Resizer subdev
395  *
396  * @sd:	       v4l2_subdev variable
397  * @regs_base: base register address offset
398  * @id:	       id of the resizer, one of RKISP1_SELFPATH, RKISP1_MAINPATH
399  * @rkisp1:    pointer to the rkisp1 device
400  * @pads:      media pads
401  * @pad_cfg:   configurations for the pads
402  * @config:    the set of registers to configure the resizer
403  * @pixel_enc: pixel encoding of the resizer
404  * @ops_lock:  a lock for the subdev ops
405  */
406 struct rkisp1_resizer {
407 	struct v4l2_subdev sd;
408 	u32 regs_base;
409 	enum rkisp1_stream_id id;
410 	struct rkisp1_device *rkisp1;
411 	struct media_pad pads[RKISP1_RSZ_PAD_MAX];
412 	struct v4l2_subdev_pad_config pad_cfg[RKISP1_RSZ_PAD_MAX];
413 	const struct rkisp1_rsz_config *config;
414 	enum v4l2_pixel_encoding pixel_enc;
415 	struct mutex ops_lock; /* serialize the subdevice ops */
416 };
417 
418 /*
419  * struct rkisp1_debug - Values to be exposed on debugfs.
420  *			 The parameters are counters of the number of times the
421  *			 event occurred since the driver was loaded.
422  *
423  * @data_loss:			  loss of data occurred within a line, processing failure
424  * @outform_size_error:		  size error is generated in outmux submodule
425  * @img_stabilization_size_error: size error is generated in image stabilization submodule
426  * @inform_size_err:		  size error is generated in inform submodule
427  * @mipi_error:			  mipi error occurred
428  * @stats_error:		  writing to the 'Interrupt clear register' did not clear
429  *				  it in the register 'Masked interrupt status'
430  * @stop_timeout:		  upon stream stop, the capture waits 1 second for the isr to stop
431  *				  the stream. This param is incremented in case of timeout.
432  * @frame_drop:			  a frame was ready but the buffer queue was empty so the frame
433  *				  was not sent to userspace
434  */
435 struct rkisp1_debug {
436 	struct dentry *debugfs_dir;
437 	unsigned long data_loss;
438 	unsigned long outform_size_error;
439 	unsigned long img_stabilization_size_error;
440 	unsigned long inform_size_error;
441 	unsigned long irq_delay;
442 	unsigned long mipi_error;
443 	unsigned long stats_error;
444 	unsigned long stop_timeout[2];
445 	unsigned long frame_drop[2];
446 };
447 
448 /*
449  * struct rkisp1_device - ISP platform device
450  *
451  * @base_addr:	   base register address
452  * @dev:	   a pointer to the struct device
453  * @clk_size:	   number of clocks
454  * @clks:	   array of clocks
455  * @v4l2_dev:	   v4l2_device variable
456  * @media_dev:	   media_device variable
457  * @notifier:	   a notifier to register on the v4l2-async API to be notified on the sensor
458  * @source:        source subdev in-use, set when starting streaming
459  * @csi:	   internal CSI-2 receiver
460  * @isp:	   ISP sub-device
461  * @resizer_devs:  resizer sub-devices
462  * @capture_devs:  capture devices
463  * @stats:	   ISP statistics metadata capture device
464  * @params:	   ISP parameters metadata output device
465  * @pipe:	   media pipeline
466  * @stream_lock:   serializes {start/stop}_streaming callbacks between the capture devices.
467  * @debug:	   debug params to be exposed on debugfs
468  * @info:	   version-specific ISP information
469  * @irqs:          IRQ line numbers
470  */
471 struct rkisp1_device {
472 	void __iomem *base_addr;
473 	struct device *dev;
474 	unsigned int clk_size;
475 	struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK];
476 	struct v4l2_device v4l2_dev;
477 	struct media_device media_dev;
478 	struct v4l2_async_notifier notifier;
479 	struct v4l2_subdev *source;
480 	struct rkisp1_csi csi;
481 	struct rkisp1_isp isp;
482 	struct rkisp1_resizer resizer_devs[2];
483 	struct rkisp1_capture capture_devs[2];
484 	struct rkisp1_stats stats;
485 	struct rkisp1_params params;
486 	struct media_pipeline pipe;
487 	struct mutex stream_lock; /* serialize {start/stop}_streaming cb between capture devices */
488 	struct rkisp1_debug debug;
489 	const struct rkisp1_info *info;
490 	int irqs[RKISP1_NUM_IRQS];
491 };
492 
493 /*
494  * struct rkisp1_mbus_info - ISP media bus info, Translates media bus code to hardware
495  *			     format values
496  *
497  * @mbus_code: media bus code
498  * @pixel_enc: pixel encoding
499  * @mipi_dt:   mipi data type
500  * @yuv_seq:   the order of the Y, Cb, Cr values
501  * @bus_width: bus width
502  * @bayer_pat: bayer pattern
503  * @direction: a bitmask of the flags indicating on which pad the format is supported on
504  */
505 struct rkisp1_mbus_info {
506 	u32 mbus_code;
507 	enum v4l2_pixel_encoding pixel_enc;
508 	u32 mipi_dt;
509 	u32 yuv_seq;
510 	u8 bus_width;
511 	enum rkisp1_fmt_raw_pat_type bayer_pat;
512 	unsigned int direction;
513 };
514 
515 static inline void
rkisp1_write(struct rkisp1_device * rkisp1,unsigned int addr,u32 val)516 rkisp1_write(struct rkisp1_device *rkisp1, unsigned int addr, u32 val)
517 {
518 	writel(val, rkisp1->base_addr + addr);
519 }
520 
rkisp1_read(struct rkisp1_device * rkisp1,unsigned int addr)521 static inline u32 rkisp1_read(struct rkisp1_device *rkisp1, unsigned int addr)
522 {
523 	return readl(rkisp1->base_addr + addr);
524 }
525 
526 /*
527  * rkisp1_cap_enum_mbus_codes - A helper function that return the i'th supported mbus code
528  *				of the capture entity. This is used to enumerate the supported
529  *				mbus codes on the source pad of the resizer.
530  *
531  * @cap:  the capture entity
532  * @code: the mbus code, the function reads the code->index and fills the code->code
533  */
534 int rkisp1_cap_enum_mbus_codes(struct rkisp1_capture *cap,
535 			       struct v4l2_subdev_mbus_code_enum *code);
536 
537 /*
538  * rkisp1_mbus_info_get_by_index - Retrieve the ith supported mbus info
539  *
540  * @index: index of the mbus info to fetch
541  */
542 const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_index(unsigned int index);
543 
544 /*
545  * rkisp1_sd_adjust_crop_rect - adjust a rectangle to fit into another rectangle.
546  *
547  * @crop:   rectangle to adjust.
548  * @bounds: rectangle used as bounds.
549  */
550 void rkisp1_sd_adjust_crop_rect(struct v4l2_rect *crop,
551 				const struct v4l2_rect *bounds);
552 
553 /*
554  * rkisp1_sd_adjust_crop - adjust a rectangle to fit into media bus format
555  *
556  * @crop:   rectangle to adjust.
557  * @bounds: media bus format used as bounds.
558  */
559 void rkisp1_sd_adjust_crop(struct v4l2_rect *crop,
560 			   const struct v4l2_mbus_framefmt *bounds);
561 
562 /*
563  * rkisp1_mbus_info_get_by_code - get the isp info of the media bus code
564  *
565  * @mbus_code: the media bus code
566  */
567 const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_code(u32 mbus_code);
568 
569 /*
570  * rkisp1_params_pre_configure - Configure the params before stream start
571  *
572  * @params:	  pointer to rkisp1_params
573  * @bayer_pat:	  the bayer pattern on the isp video sink pad
574  * @quantization: the quantization configured on the isp's src pad
575  * @ycbcr_encoding: the ycbcr_encoding configured on the isp's src pad
576  *
577  * This function is called by the ISP entity just before the ISP gets started.
578  * It applies the initial ISP parameters from the first params buffer, but
579  * skips LSC as it needs to be configured after the ISP is started.
580  */
581 void rkisp1_params_pre_configure(struct rkisp1_params *params,
582 				 enum rkisp1_fmt_raw_pat_type bayer_pat,
583 				 enum v4l2_quantization quantization,
584 				 enum v4l2_ycbcr_encoding ycbcr_encoding);
585 
586 /*
587  * rkisp1_params_post_configure - Configure the params after stream start
588  *
589  * @params:	  pointer to rkisp1_params
590  *
591  * This function is called by the ISP entity just after the ISP gets started.
592  * It applies the initial ISP LSC parameters from the first params buffer.
593  */
594 void rkisp1_params_post_configure(struct rkisp1_params *params);
595 
596 /* rkisp1_params_disable - disable all parameters.
597  *			   This function is called by the isp entity upon stream start
598  *			   when capturing bayer format.
599  *
600  * @params: pointer to rkisp1_params.
601  */
602 void rkisp1_params_disable(struct rkisp1_params *params);
603 
604 /* irq handlers */
605 irqreturn_t rkisp1_isp_isr(int irq, void *ctx);
606 irqreturn_t rkisp1_csi_isr(int irq, void *ctx);
607 irqreturn_t rkisp1_capture_isr(int irq, void *ctx);
608 void rkisp1_stats_isr(struct rkisp1_stats *stats, u32 isp_ris);
609 void rkisp1_params_isr(struct rkisp1_device *rkisp1);
610 
611 /* register/unregisters functions of the entities */
612 int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1);
613 void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1);
614 
615 int rkisp1_isp_register(struct rkisp1_device *rkisp1);
616 void rkisp1_isp_unregister(struct rkisp1_device *rkisp1);
617 
618 int rkisp1_resizer_devs_register(struct rkisp1_device *rkisp1);
619 void rkisp1_resizer_devs_unregister(struct rkisp1_device *rkisp1);
620 
621 int rkisp1_stats_register(struct rkisp1_device *rkisp1);
622 void rkisp1_stats_unregister(struct rkisp1_device *rkisp1);
623 
624 int rkisp1_params_register(struct rkisp1_device *rkisp1);
625 void rkisp1_params_unregister(struct rkisp1_device *rkisp1);
626 
627 #if IS_ENABLED(CONFIG_DEBUG_FS)
628 void rkisp1_debug_init(struct rkisp1_device *rkisp1);
629 void rkisp1_debug_cleanup(struct rkisp1_device *rkisp1);
630 #else
rkisp1_debug_init(struct rkisp1_device * rkisp1)631 static inline void rkisp1_debug_init(struct rkisp1_device *rkisp1)
632 {
633 }
rkisp1_debug_cleanup(struct rkisp1_device * rkisp1)634 static inline void rkisp1_debug_cleanup(struct rkisp1_device *rkisp1)
635 {
636 }
637 #endif
638 
639 #endif /* _RKISP1_COMMON_H */
640