1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright 2021-2022 Bootlin 4 * Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com> 5 */ 6 7 #ifndef _SUN6I_ISP_H_ 8 #define _SUN6I_ISP_H_ 9 10 #include <media/v4l2-device.h> 11 #include <media/videobuf2-v4l2.h> 12 13 #include "sun6i_isp_capture.h" 14 #include "sun6i_isp_params.h" 15 #include "sun6i_isp_proc.h" 16 17 #define SUN6I_ISP_NAME "sun6i-isp" 18 #define SUN6I_ISP_DESCRIPTION "Allwinner A31 ISP Device" 19 20 enum sun6i_isp_port { 21 SUN6I_ISP_PORT_CSI0 = 0, 22 SUN6I_ISP_PORT_CSI1 = 1, 23 }; 24 25 struct sun6i_isp_buffer { 26 struct vb2_v4l2_buffer v4l2_buffer; 27 struct list_head list; 28 }; 29 30 struct sun6i_isp_v4l2 { 31 struct v4l2_device v4l2_dev; 32 struct media_device media_dev; 33 }; 34 35 struct sun6i_isp_table { 36 void *data; 37 dma_addr_t address; 38 unsigned int size; 39 }; 40 41 struct sun6i_isp_tables { 42 struct sun6i_isp_table load; 43 struct sun6i_isp_table save; 44 45 struct sun6i_isp_table lut; 46 struct sun6i_isp_table drc; 47 struct sun6i_isp_table stats; 48 }; 49 50 struct sun6i_isp_device { 51 struct device *dev; 52 53 struct sun6i_isp_tables tables; 54 55 struct sun6i_isp_v4l2 v4l2; 56 struct sun6i_isp_proc proc; 57 struct sun6i_isp_capture capture; 58 struct sun6i_isp_params params; 59 60 struct regmap *regmap; 61 struct clk *clock_mod; 62 struct clk *clock_ram; 63 struct reset_control *reset; 64 65 spinlock_t state_lock; /* State helpers lock. */ 66 }; 67 68 struct sun6i_isp_variant { 69 unsigned int table_load_save_size; 70 unsigned int table_lut_size; 71 unsigned int table_drc_size; 72 unsigned int table_stats_size; 73 }; 74 75 /* Helpers */ 76 77 u32 sun6i_isp_load_read(struct sun6i_isp_device *isp_dev, u32 offset); 78 void sun6i_isp_load_write(struct sun6i_isp_device *isp_dev, u32 offset, 79 u32 value); 80 u32 sun6i_isp_address_value(dma_addr_t address); 81 82 /* State */ 83 84 void sun6i_isp_state_update(struct sun6i_isp_device *isp_dev, bool ready_hold); 85 86 /* Tables */ 87 88 void sun6i_isp_tables_configure(struct sun6i_isp_device *isp_dev); 89 90 #endif 91