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  * @irqs_enabled:  the hardware is enabled and can cause interrupts
471  */
472 struct rkisp1_device {
473 	void __iomem *base_addr;
474 	struct device *dev;
475 	unsigned int clk_size;
476 	struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK];
477 	struct v4l2_device v4l2_dev;
478 	struct media_device media_dev;
479 	struct v4l2_async_notifier notifier;
480 	struct v4l2_subdev *source;
481 	struct rkisp1_csi csi;
482 	struct rkisp1_isp isp;
483 	struct rkisp1_resizer resizer_devs[2];
484 	struct rkisp1_capture capture_devs[2];
485 	struct rkisp1_stats stats;
486 	struct rkisp1_params params;
487 	struct media_pipeline pipe;
488 	struct mutex stream_lock; /* serialize {start/stop}_streaming cb between capture devices */
489 	struct rkisp1_debug debug;
490 	const struct rkisp1_info *info;
491 	int irqs[RKISP1_NUM_IRQS];
492 	bool irqs_enabled;
493 };
494 
495 /*
496  * struct rkisp1_mbus_info - ISP media bus info, Translates media bus code to hardware
497  *			     format values
498  *
499  * @mbus_code: media bus code
500  * @pixel_enc: pixel encoding
501  * @mipi_dt:   mipi data type
502  * @yuv_seq:   the order of the Y, Cb, Cr values
503  * @bus_width: bus width
504  * @bayer_pat: bayer pattern
505  * @direction: a bitmask of the flags indicating on which pad the format is supported on
506  */
507 struct rkisp1_mbus_info {
508 	u32 mbus_code;
509 	enum v4l2_pixel_encoding pixel_enc;
510 	u32 mipi_dt;
511 	u32 yuv_seq;
512 	u8 bus_width;
513 	enum rkisp1_fmt_raw_pat_type bayer_pat;
514 	unsigned int direction;
515 };
516 
517 static inline void
518 rkisp1_write(struct rkisp1_device *rkisp1, unsigned int addr, u32 val)
519 {
520 	writel(val, rkisp1->base_addr + addr);
521 }
522 
523 static inline u32 rkisp1_read(struct rkisp1_device *rkisp1, unsigned int addr)
524 {
525 	return readl(rkisp1->base_addr + addr);
526 }
527 
528 /*
529  * rkisp1_cap_enum_mbus_codes - A helper function that return the i'th supported mbus code
530  *				of the capture entity. This is used to enumerate the supported
531  *				mbus codes on the source pad of the resizer.
532  *
533  * @cap:  the capture entity
534  * @code: the mbus code, the function reads the code->index and fills the code->code
535  */
536 int rkisp1_cap_enum_mbus_codes(struct rkisp1_capture *cap,
537 			       struct v4l2_subdev_mbus_code_enum *code);
538 
539 /*
540  * rkisp1_mbus_info_get_by_index - Retrieve the ith supported mbus info
541  *
542  * @index: index of the mbus info to fetch
543  */
544 const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_index(unsigned int index);
545 
546 /*
547  * rkisp1_sd_adjust_crop_rect - adjust a rectangle to fit into another rectangle.
548  *
549  * @crop:   rectangle to adjust.
550  * @bounds: rectangle used as bounds.
551  */
552 void rkisp1_sd_adjust_crop_rect(struct v4l2_rect *crop,
553 				const struct v4l2_rect *bounds);
554 
555 /*
556  * rkisp1_sd_adjust_crop - adjust a rectangle to fit into media bus format
557  *
558  * @crop:   rectangle to adjust.
559  * @bounds: media bus format used as bounds.
560  */
561 void rkisp1_sd_adjust_crop(struct v4l2_rect *crop,
562 			   const struct v4l2_mbus_framefmt *bounds);
563 
564 /*
565  * rkisp1_mbus_info_get_by_code - get the isp info of the media bus code
566  *
567  * @mbus_code: the media bus code
568  */
569 const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_code(u32 mbus_code);
570 
571 /*
572  * rkisp1_params_pre_configure - Configure the params before stream start
573  *
574  * @params:	  pointer to rkisp1_params
575  * @bayer_pat:	  the bayer pattern on the isp video sink pad
576  * @quantization: the quantization configured on the isp's src pad
577  * @ycbcr_encoding: the ycbcr_encoding configured on the isp's src pad
578  *
579  * This function is called by the ISP entity just before the ISP gets started.
580  * It applies the initial ISP parameters from the first params buffer, but
581  * skips LSC as it needs to be configured after the ISP is started.
582  */
583 void rkisp1_params_pre_configure(struct rkisp1_params *params,
584 				 enum rkisp1_fmt_raw_pat_type bayer_pat,
585 				 enum v4l2_quantization quantization,
586 				 enum v4l2_ycbcr_encoding ycbcr_encoding);
587 
588 /*
589  * rkisp1_params_post_configure - Configure the params after stream start
590  *
591  * @params:	  pointer to rkisp1_params
592  *
593  * This function is called by the ISP entity just after the ISP gets started.
594  * It applies the initial ISP LSC parameters from the first params buffer.
595  */
596 void rkisp1_params_post_configure(struct rkisp1_params *params);
597 
598 /* rkisp1_params_disable - disable all parameters.
599  *			   This function is called by the isp entity upon stream start
600  *			   when capturing bayer format.
601  *
602  * @params: pointer to rkisp1_params.
603  */
604 void rkisp1_params_disable(struct rkisp1_params *params);
605 
606 /* irq handlers */
607 irqreturn_t rkisp1_isp_isr(int irq, void *ctx);
608 irqreturn_t rkisp1_csi_isr(int irq, void *ctx);
609 irqreturn_t rkisp1_capture_isr(int irq, void *ctx);
610 void rkisp1_stats_isr(struct rkisp1_stats *stats, u32 isp_ris);
611 void rkisp1_params_isr(struct rkisp1_device *rkisp1);
612 
613 /* register/unregisters functions of the entities */
614 int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1);
615 void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1);
616 
617 int rkisp1_isp_register(struct rkisp1_device *rkisp1);
618 void rkisp1_isp_unregister(struct rkisp1_device *rkisp1);
619 
620 int rkisp1_resizer_devs_register(struct rkisp1_device *rkisp1);
621 void rkisp1_resizer_devs_unregister(struct rkisp1_device *rkisp1);
622 
623 int rkisp1_stats_register(struct rkisp1_device *rkisp1);
624 void rkisp1_stats_unregister(struct rkisp1_device *rkisp1);
625 
626 int rkisp1_params_register(struct rkisp1_device *rkisp1);
627 void rkisp1_params_unregister(struct rkisp1_device *rkisp1);
628 
629 #if IS_ENABLED(CONFIG_DEBUG_FS)
630 void rkisp1_debug_init(struct rkisp1_device *rkisp1);
631 void rkisp1_debug_cleanup(struct rkisp1_device *rkisp1);
632 #else
633 static inline void rkisp1_debug_init(struct rkisp1_device *rkisp1)
634 {
635 }
636 static inline void rkisp1_debug_cleanup(struct rkisp1_device *rkisp1)
637 {
638 }
639 #endif
640 
641 #endif /* _RKISP1_COMMON_H */
642