File Index
Files and directories
Sign in
FILE

rkisp1-common.h

File preview with syntax highlighting.

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