1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * stf_capture.h 4 * 5 * Starfive Camera Subsystem driver 6 * 7 * Copyright (C) 2021-2023 StarFive Technology Co., Ltd. 8 */ 9 10 #ifndef STF_CAPTURE_H 11 #define STF_CAPTURE_H 12 13 #include "stf-video.h" 14 15 #define VIN_CHANNEL_SEL_EN 0x14 16 #define VIN_START_ADDR_N 0x18 17 #define VIN_INRT_PIX_CFG 0x1c 18 #define VIN_START_ADDR_O 0x20 19 #define VIN_CFG_REG 0x24 20 21 #define U0_VIN_CNFG_AXI_DVP_EN BIT(2) 22 23 #define U0_VIN_CHANNEL_SEL_MASK GENMASK(3, 0) 24 #define U0_VIN_AXIWR0_EN BIT(4) 25 #define CHANNEL(x) ((x) << 0) 26 27 #define U0_VIN_INTR_CLEAN BIT(0) 28 #define U0_VIN_INTR_M BIT(1) 29 #define U0_VIN_PIX_CNT_END_MASK GENMASK(12, 2) 30 #define U0_VIN_PIX_CT_MASK GENMASK(14, 13) 31 #define U0_VIN_PIXEL_HEIGH_BIT_SEL_MAKS GENMASK(16, 15) 32 33 #define PIX_CNT_END(x) ((x) << 2) 34 #define PIX_CT(x) ((x) << 13) 35 #define PIXEL_HEIGH_BIT_SEL(x) ((x) << 15) 36 37 #define U0_VIN_CNFG_DVP_HS_POS BIT(1) 38 #define U0_VIN_CNFG_DVP_SWAP_EN BIT(2) 39 #define U0_VIN_CNFG_DVP_VS_POS BIT(3) 40 #define U0_VIN_CNFG_GEN_EN_AXIRD BIT(4) 41 #define U0_VIN_CNFG_ISP_DVP_EN0 BIT(5) 42 #define U0_VIN_MIPI_BYTE_EN_ISP0(n) ((n) << 6) 43 #define U0_VIN_MIPI_CHANNEL_SEL0(n) ((n) << 8) 44 #define U0_VIN_P_I_MIPI_HAEDER_EN0(n) ((n) << 12) 45 #define U0_VIN_PIX_NUM(n) ((n) << 13) 46 #define U0_VIN_MIPI_BYTE_EN_ISP0_MASK GENMASK(7, 6) 47 #define U0_VIN_MIPI_CHANNEL_SEL0_MASK GENMASK(11, 8) 48 #define U0_VIN_P_I_MIPI_HAEDER_EN0_MASK BIT(12) 49 #define U0_VIN_PIX_NUM_MASK GENMASK(16, 13) 50 51 enum stf_v_state { 52 STF_OUTPUT_OFF, 53 STF_OUTPUT_RESERVED, 54 STF_OUTPUT_SINGLE, 55 STF_OUTPUT_CONTINUOUS, 56 STF_OUTPUT_IDLE, 57 STF_OUTPUT_STOPPING 58 }; 59 60 struct stf_v_buf { 61 int active_buf; 62 struct stfcamss_buffer *buf[2]; 63 struct stfcamss_buffer *last_buffer; 64 struct list_head pending_bufs; 65 struct list_head ready_bufs; 66 enum stf_v_state state; 67 unsigned int sequence; 68 /* protects the above member variables */ 69 spinlock_t lock; 70 atomic_t frame_skip; 71 }; 72 73 struct stf_capture { 74 struct stfcamss_video video; 75 struct stf_v_buf buffers; 76 enum stf_capture_type type; 77 }; 78 79 irqreturn_t stf_wr_irq_handler(int irq, void *priv); 80 irqreturn_t stf_isp_irq_handler(int irq, void *priv); 81 irqreturn_t stf_line_irq_handler(int irq, void *priv); 82 int stf_capture_register(struct stfcamss *stfcamss, 83 struct v4l2_device *v4l2_dev); 84 void stf_capture_unregister(struct stfcamss *stfcamss); 85 86 #endif 87