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