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 dev_pm_domain_list; 28 struct 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 */ 68 enum 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 */ 76 enum 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 */ 83 enum 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 */ 90 enum rkisp1_stream_id { 91 RKISP1_MAINPATH, 92 RKISP1_SELFPATH, 93 }; 94 95 /* bayer patterns */ 96 enum 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 */ 104 enum 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 */ 127 enum 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 */ 156 struct 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 */ 184 struct 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 */ 206 struct 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 */ 224 struct 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 }; 231 232 /* 233 * struct rkisp1_vdev_node - Container for the video nodes: params, stats, mainpath, selfpath 234 * 235 * @buf_queue: queue of buffers 236 * @vlock: lock of the video node 237 * @vdev: video node 238 * @pad: media pad 239 */ 240 struct rkisp1_vdev_node { 241 struct vb2_queue buf_queue; 242 struct mutex vlock; /* ioctl serialization mutex */ 243 struct video_device vdev; 244 struct media_pad pad; 245 }; 246 247 /* 248 * struct rkisp1_buffer - A container for the vb2 buffers used by the video devices: 249 * stats, mainpath, selfpath 250 * 251 * @vb: vb2 buffer 252 * @queue: entry of the buffer in the queue 253 * @buff_addr: dma addresses of each plane, used only by the capture devices: selfpath, mainpath 254 */ 255 struct rkisp1_buffer { 256 struct vb2_v4l2_buffer vb; 257 struct list_head queue; 258 dma_addr_t buff_addr[VIDEO_MAX_PLANES]; 259 }; 260 261 /* 262 * struct rkisp1_params_buffer - A container for the vb2 buffers used by the 263 * params video device 264 * 265 * @vb: vb2 buffer 266 * @queue: entry of the buffer in the queue 267 * @cfg: scratch buffer used for caching the ISP configuration parameters 268 */ 269 struct rkisp1_params_buffer { 270 struct vb2_v4l2_buffer vb; 271 struct list_head queue; 272 void *cfg; 273 }; 274 275 static inline struct rkisp1_params_buffer * 276 to_rkisp1_params_buffer(struct vb2_v4l2_buffer *vbuf) 277 { 278 return container_of(vbuf, struct rkisp1_params_buffer, vb); 279 } 280 281 /* 282 * struct rkisp1_dummy_buffer - A buffer to write the next frame to in case 283 * there are no vb2 buffers available. 284 * 285 * @vaddr: return value of call to dma_alloc_attrs. 286 * @dma_addr: dma address of the buffer. 287 * @size: size of the buffer. 288 */ 289 struct rkisp1_dummy_buffer { 290 void *vaddr; 291 dma_addr_t dma_addr; 292 u32 size; 293 }; 294 295 struct rkisp1_device; 296 297 /* 298 * struct rkisp1_capture - ISP capture video device 299 * 300 * @vnode: video node 301 * @rkisp1: pointer to rkisp1_device 302 * @id: id of the capture, one of RKISP1_SELFPATH, RKISP1_MAINPATH 303 * @ops: list of callbacks to configure the capture device. 304 * @config: a pointer to the list of registers to configure the capture format. 305 * @is_streaming: device is streaming 306 * @is_stopping: stop_streaming callback was called and the device is in the process of 307 * stopping the streaming. 308 * @done: when stop_streaming callback is called, the device waits for the next irq 309 * handler to stop the streaming by waiting on the 'done' wait queue. 310 * If the irq handler is not called, the stream is stopped by the callback 311 * after timeout. 312 * @stride: the line stride for the first plane, in pixel units 313 * @buf.lock: lock to protect buf.queue 314 * @buf.queue: queued buffer list 315 * @buf.dummy: dummy space to store dropped data 316 * 317 * rkisp1 uses shadow registers, so it needs two buffers at a time 318 * @buf.curr: the buffer used for current frame 319 * @buf.next: the buffer used for next frame 320 * @pix.cfg: pixel configuration 321 * @pix.info: a pointer to the v4l2_format_info of the pixel format 322 * @pix.fmt: buffer format 323 */ 324 struct rkisp1_capture { 325 struct rkisp1_vdev_node vnode; 326 struct rkisp1_device *rkisp1; 327 enum rkisp1_stream_id id; 328 const struct rkisp1_capture_ops *ops; 329 const struct rkisp1_capture_config *config; 330 bool is_streaming; 331 bool is_stopping; 332 wait_queue_head_t done; 333 unsigned int stride; 334 struct { 335 /* protects queue, curr and next */ 336 spinlock_t lock; 337 struct list_head queue; 338 struct rkisp1_dummy_buffer dummy; 339 struct rkisp1_buffer *curr; 340 struct rkisp1_buffer *next; 341 } buf; 342 struct { 343 const struct rkisp1_capture_fmt_cfg *cfg; 344 const struct v4l2_format_info *info; 345 struct v4l2_pix_format_mplane fmt; 346 } pix; 347 }; 348 349 struct rkisp1_stats; 350 struct rkisp1_stats_ops { 351 void (*get_awb_meas)(struct rkisp1_stats *stats, 352 struct rkisp1_stat_buffer *pbuf); 353 void (*get_aec_meas)(struct rkisp1_stats *stats, 354 struct rkisp1_stat_buffer *pbuf); 355 void (*get_hst_meas)(struct rkisp1_stats *stats, 356 struct rkisp1_stat_buffer *pbuf); 357 }; 358 359 /* 360 * struct rkisp1_stats - ISP Statistics device 361 * 362 * @vnode: video node 363 * @rkisp1: pointer to the rkisp1 device 364 * @lock: locks the buffer list 'stat' 365 * @stat: queue of rkisp1_buffer 366 * @vdev_fmt: v4l2_format of the metadata format 367 */ 368 struct rkisp1_stats { 369 struct rkisp1_vdev_node vnode; 370 struct rkisp1_device *rkisp1; 371 const struct rkisp1_stats_ops *ops; 372 373 spinlock_t lock; /* locks the buffers list 'stats' */ 374 struct list_head stat; 375 struct v4l2_format vdev_fmt; 376 }; 377 378 struct rkisp1_params; 379 struct rkisp1_params_ops { 380 void (*lsc_matrix_config)(struct rkisp1_params *params, 381 const struct rkisp1_cif_isp_lsc_config *pconfig); 382 void (*goc_config)(struct rkisp1_params *params, 383 const struct rkisp1_cif_isp_goc_config *arg); 384 void (*awb_meas_config)(struct rkisp1_params *params, 385 const struct rkisp1_cif_isp_awb_meas_config *arg); 386 void (*awb_meas_enable)(struct rkisp1_params *params, 387 const struct rkisp1_cif_isp_awb_meas_config *arg, 388 bool en); 389 void (*awb_gain_config)(struct rkisp1_params *params, 390 const struct rkisp1_cif_isp_awb_gain_config *arg); 391 void (*aec_config)(struct rkisp1_params *params, 392 const struct rkisp1_cif_isp_aec_config *arg); 393 void (*hst_config)(struct rkisp1_params *params, 394 const struct rkisp1_cif_isp_hst_config *arg); 395 void (*hst_enable)(struct rkisp1_params *params, 396 const struct rkisp1_cif_isp_hst_config *arg, bool en); 397 void (*afm_config)(struct rkisp1_params *params, 398 const struct rkisp1_cif_isp_afc_config *arg); 399 }; 400 401 /* 402 * struct rkisp1_params - ISP input parameters device 403 * 404 * @vnode: video node 405 * @rkisp1: pointer to the rkisp1 device 406 * @ops: pointer to the variant-specific operations 407 * @config_lock: locks the buffer list 'params' 408 * @params: queue of rkisp1_buffer 409 * @metafmt the currently enabled metadata format 410 * @quantization: the quantization configured on the isp's src pad 411 * @ycbcr_encoding the YCbCr encoding 412 * @raw_type: the bayer pattern on the isp video sink pad 413 * @enabled_blocks: bitmask of enabled ISP blocks 414 */ 415 struct rkisp1_params { 416 struct rkisp1_vdev_node vnode; 417 struct rkisp1_device *rkisp1; 418 const struct rkisp1_params_ops *ops; 419 420 spinlock_t config_lock; /* locks the buffers list 'params' */ 421 struct list_head params; 422 423 struct v4l2_ctrl_handler ctrls; 424 425 const struct v4l2_meta_format *metafmt; 426 427 enum v4l2_quantization quantization; 428 enum v4l2_ycbcr_encoding ycbcr_encoding; 429 enum rkisp1_fmt_raw_pat_type raw_type; 430 431 u32 enabled_blocks; 432 }; 433 434 /* 435 * struct rkisp1_resizer - Resizer subdev 436 * 437 * @sd: v4l2_subdev variable 438 * @regs_base: base register address offset 439 * @id: id of the resizer, one of RKISP1_SELFPATH, RKISP1_MAINPATH 440 * @rkisp1: pointer to the rkisp1 device 441 * @pads: media pads 442 * @config: the set of registers to configure the resizer 443 */ 444 struct rkisp1_resizer { 445 struct v4l2_subdev sd; 446 u32 regs_base; 447 enum rkisp1_stream_id id; 448 struct rkisp1_device *rkisp1; 449 struct media_pad pads[RKISP1_RSZ_PAD_MAX]; 450 const struct rkisp1_rsz_config *config; 451 }; 452 453 /* 454 * struct rkisp1_debug - Values to be exposed on debugfs. 455 * The parameters are counters of the number of times the 456 * event occurred since the driver was loaded. 457 * 458 * @data_loss: loss of data occurred within a line, processing failure 459 * @outform_size_error: size error is generated in outmux submodule 460 * @img_stabilization_size_error: size error is generated in image stabilization submodule 461 * @inform_size_err: size error is generated in inform submodule 462 * @mipi_error: mipi error occurred 463 * @stats_error: writing to the 'Interrupt clear register' did not clear 464 * it in the register 'Masked interrupt status' 465 * @stop_timeout: upon stream stop, the capture waits 1 second for the isr to stop 466 * the stream. This param is incremented in case of timeout. 467 * @frame_drop: a frame was ready but the buffer queue was empty so the frame 468 * was not sent to userspace 469 */ 470 struct rkisp1_debug { 471 struct dentry *debugfs_dir; 472 unsigned long data_loss; 473 unsigned long outform_size_error; 474 unsigned long img_stabilization_size_error; 475 unsigned long inform_size_error; 476 unsigned long irq_delay; 477 unsigned long mipi_error; 478 unsigned long stats_error; 479 unsigned long stop_timeout[2]; 480 unsigned long frame_drop[2]; 481 unsigned long complete_frames; 482 }; 483 484 /* 485 * struct rkisp1_device - ISP platform device 486 * 487 * @base_addr: base register address 488 * @dev: a pointer to the struct device 489 * @clk_size: number of clocks 490 * @clks: array of clocks 491 * @pm_domains: power domains 492 * @gasket: the gasket - i.MX8MP only 493 * @gasket_id: the gasket ID (0 or 1) - i.MX8MP only 494 * @v4l2_dev: v4l2_device variable 495 * @media_dev: media_device variable 496 * @notifier: a notifier to register on the v4l2-async API to be notified on the sensor 497 * @source: source subdev in-use, set when starting streaming 498 * @csi: internal CSI-2 receiver 499 * @isp: ISP sub-device 500 * @resizer_devs: resizer sub-devices 501 * @capture_devs: capture devices 502 * @stats: ISP statistics metadata capture device 503 * @params: ISP parameters metadata output device 504 * @pipe: media pipeline 505 * @stream_lock: serializes {start/stop}_streaming callbacks between the capture devices. 506 * @debug: debug params to be exposed on debugfs 507 * @info: version-specific ISP information 508 * @irqs: IRQ line numbers 509 * @irqs_enabled: the hardware is enabled and can cause interrupts 510 */ 511 struct rkisp1_device { 512 void __iomem *base_addr; 513 struct device *dev; 514 unsigned int clk_size; 515 struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK]; 516 struct dev_pm_domain_list *pm_domains; 517 struct regmap *gasket; 518 unsigned int gasket_id; 519 struct v4l2_device v4l2_dev; 520 struct media_device media_dev; 521 struct v4l2_async_notifier notifier; 522 struct v4l2_subdev *source; 523 struct rkisp1_csi csi; 524 struct rkisp1_isp isp; 525 struct rkisp1_resizer resizer_devs[2]; 526 struct rkisp1_capture capture_devs[2]; 527 struct rkisp1_stats stats; 528 struct rkisp1_params params; 529 struct media_pipeline pipe; 530 struct mutex stream_lock; /* serialize {start/stop}_streaming cb between capture devices */ 531 struct rkisp1_debug debug; 532 const struct rkisp1_info *info; 533 int irqs[RKISP1_NUM_IRQS]; 534 bool irqs_enabled; 535 }; 536 537 /* 538 * struct rkisp1_mbus_info - ISP media bus info, Translates media bus code to hardware 539 * format values 540 * 541 * @mbus_code: media bus code 542 * @pixel_enc: pixel encoding 543 * @mipi_dt: mipi data type 544 * @yuv_seq: the order of the Y, Cb, Cr values 545 * @bus_width: bus width 546 * @bayer_pat: bayer pattern 547 * @direction: a bitmask of the flags indicating on which pad the format is supported on 548 */ 549 struct rkisp1_mbus_info { 550 u32 mbus_code; 551 enum v4l2_pixel_encoding pixel_enc; 552 u32 mipi_dt; 553 u32 yuv_seq; 554 u8 bus_width; 555 enum rkisp1_fmt_raw_pat_type bayer_pat; 556 unsigned int direction; 557 }; 558 559 static inline void 560 rkisp1_write(struct rkisp1_device *rkisp1, unsigned int addr, u32 val) 561 { 562 writel(val, rkisp1->base_addr + addr); 563 } 564 565 static inline u32 rkisp1_read(struct rkisp1_device *rkisp1, unsigned int addr) 566 { 567 return readl(rkisp1->base_addr + addr); 568 } 569 570 /* 571 * rkisp1_cap_enum_mbus_codes - A helper function that return the i'th supported mbus code 572 * of the capture entity. This is used to enumerate the supported 573 * mbus codes on the source pad of the resizer. 574 * 575 * @cap: the capture entity 576 * @code: the mbus code, the function reads the code->index and fills the code->code 577 */ 578 int rkisp1_cap_enum_mbus_codes(struct rkisp1_capture *cap, 579 struct v4l2_subdev_mbus_code_enum *code); 580 581 /* 582 * rkisp1_mbus_info_get_by_index - Retrieve the ith supported mbus info 583 * 584 * @index: index of the mbus info to fetch 585 */ 586 const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_index(unsigned int index); 587 588 /* 589 * rkisp1_path_count - Return the number of paths supported by the device 590 * 591 * Some devices only have a main path, while other device have both a main path 592 * and a self path. This function returns the number of paths that this device 593 * has, based on the feature flags. It should be used insted of checking 594 * ARRAY_SIZE of capture_devs/resizer_devs. 595 */ 596 static inline unsigned int rkisp1_path_count(struct rkisp1_device *rkisp1) 597 { 598 return rkisp1_has_feature(rkisp1, SELF_PATH) ? 2 : 1; 599 } 600 601 /* 602 * rkisp1_sd_adjust_crop_rect - adjust a rectangle to fit into another rectangle. 603 * 604 * @crop: rectangle to adjust. 605 * @bounds: rectangle used as bounds. 606 */ 607 void rkisp1_sd_adjust_crop_rect(struct v4l2_rect *crop, 608 const struct v4l2_rect *bounds); 609 610 /* 611 * rkisp1_sd_adjust_crop - adjust a rectangle to fit into media bus format 612 * 613 * @crop: rectangle to adjust. 614 * @bounds: media bus format used as bounds. 615 */ 616 void rkisp1_sd_adjust_crop(struct v4l2_rect *crop, 617 const struct v4l2_mbus_framefmt *bounds); 618 619 void rkisp1_bls_swap_regs(enum rkisp1_fmt_raw_pat_type pattern, 620 const u32 input[4], u32 output[4]); 621 622 /* 623 * rkisp1_mbus_info_get_by_code - get the isp info of the media bus code 624 * 625 * @mbus_code: the media bus code 626 */ 627 const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_code(u32 mbus_code); 628 629 /* 630 * rkisp1_params_pre_configure - Configure the params before stream start 631 * 632 * @params: pointer to rkisp1_params 633 * @bayer_pat: the bayer pattern on the isp video sink pad 634 * @quantization: the quantization configured on the isp's src pad 635 * @ycbcr_encoding: the ycbcr_encoding configured on the isp's src pad 636 * 637 * This function is called by the ISP entity just before the ISP gets started. 638 * It applies the initial ISP parameters from the first params buffer, but 639 * skips LSC as it needs to be configured after the ISP is started. 640 */ 641 void rkisp1_params_pre_configure(struct rkisp1_params *params, 642 enum rkisp1_fmt_raw_pat_type bayer_pat, 643 enum v4l2_quantization quantization, 644 enum v4l2_ycbcr_encoding ycbcr_encoding); 645 646 /* 647 * rkisp1_params_post_configure - Configure the params after stream start 648 * 649 * @params: pointer to rkisp1_params 650 * 651 * This function is called by the ISP entity just after the ISP gets started. 652 * It applies the initial ISP LSC parameters from the first params buffer. 653 */ 654 void rkisp1_params_post_configure(struct rkisp1_params *params); 655 656 /* rkisp1_params_disable - disable all parameters. 657 * This function is called by the isp entity upon stream start 658 * when capturing bayer format. 659 * 660 * @params: pointer to rkisp1_params. 661 */ 662 void rkisp1_params_disable(struct rkisp1_params *params); 663 664 /* irq handlers */ 665 irqreturn_t rkisp1_isp_isr(int irq, void *ctx); 666 irqreturn_t rkisp1_csi_isr(int irq, void *ctx); 667 irqreturn_t rkisp1_capture_isr(int irq, void *ctx); 668 void rkisp1_stats_isr(struct rkisp1_stats *stats, u32 isp_ris); 669 void rkisp1_params_isr(struct rkisp1_device *rkisp1); 670 671 /* register/unregisters functions of the entities */ 672 int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1); 673 void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1); 674 675 int rkisp1_isp_register(struct rkisp1_device *rkisp1); 676 void rkisp1_isp_unregister(struct rkisp1_device *rkisp1); 677 678 int rkisp1_resizer_devs_register(struct rkisp1_device *rkisp1); 679 void rkisp1_resizer_devs_unregister(struct rkisp1_device *rkisp1); 680 681 int rkisp1_stats_register(struct rkisp1_device *rkisp1); 682 void rkisp1_stats_unregister(struct rkisp1_device *rkisp1); 683 684 int rkisp1_params_register(struct rkisp1_device *rkisp1); 685 void rkisp1_params_unregister(struct rkisp1_device *rkisp1); 686 687 #if IS_ENABLED(CONFIG_DEBUG_FS) 688 void rkisp1_debug_init(struct rkisp1_device *rkisp1); 689 void rkisp1_debug_cleanup(struct rkisp1_device *rkisp1); 690 #else 691 static inline void rkisp1_debug_init(struct rkisp1_device *rkisp1) 692 { 693 } 694 static inline void rkisp1_debug_cleanup(struct rkisp1_device *rkisp1) 695 { 696 } 697 #endif 698 699 #endif /* _RKISP1_COMMON_H */ 700