hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/media/platform/rockchip/cif/dev.h
....@@ -94,6 +94,13 @@
9494 #define CROP_SRC_SENSOR_MASK (0x1 << 0)
9595 #define CROP_SRC_USR_MASK (0x1 << 1)
9696
97
+/*
98
+ * max wait time for stream stop
99
+ */
100
+#define RKCIF_STOP_MAX_WAIT_TIME_MS (500)
101
+
102
+#define RKCIF_SKIP_FRAME_MAX (16)
103
+
97104 enum rkcif_workmode {
98105 RKCIF_WORKMODE_ONEFRAME = 0x00,
99106 RKCIF_WORKMODE_PINGPONG = 0x01,
....@@ -193,6 +200,7 @@
193200
194201 struct rkcif_tools_buffer {
195202 struct vb2_v4l2_buffer *vb;
203
+ struct rkisp_rx_buf *dbufs;
196204 struct list_head list;
197205 u32 frame_idx;
198206 u64 timestamp;
....@@ -279,10 +287,12 @@
279287 unsigned int width;
280288 unsigned int height;
281289 unsigned int virtual_width;
290
+ unsigned int left_virtual_width;
282291 unsigned int crop_st_x;
283292 unsigned int crop_st_y;
284293 unsigned int dsi_input;
285294 struct rkmodule_lvds_cfg lvds_cfg;
295
+ struct rkmodule_capture_info capture_info;
286296 };
287297
288298 struct rkcif_vdev_node {
....@@ -468,6 +478,18 @@
468478 u32 group;
469479 };
470480
481
+enum rkcif_toisp_buf_update_state {
482
+ RKCIF_TOISP_BUF_ROTATE,
483
+ RKCIF_TOISP_BUF_THESAME,
484
+ RKCIF_TOISP_BUF_LOSS,
485
+};
486
+
487
+struct rkcif_toisp_buf_state {
488
+ enum rkcif_toisp_buf_update_state state;
489
+ int check_cnt;
490
+ bool is_early_update;
491
+};
492
+
471493 /*
472494 * struct rkcif_stream - Stream states TODO
473495 *
....@@ -526,7 +548,8 @@
526548 unsigned int cur_stream_mode;
527549 struct rkcif_rx_buffer rx_buf[RKISP_VICAP_BUF_CNT_MAX];
528550 struct list_head rx_buf_head;
529
- int buf_num_toisp;
551
+ int total_buf_num;
552
+ int rx_buf_num;
530553 u64 line_int_cnt;
531554 int lack_buf_cnt;
532555 unsigned int buf_wake_up_cnt;
....@@ -536,6 +559,11 @@
536559 int last_rx_buf_idx;
537560 int last_frame_idx;
538561 int new_fource_idx;
562
+ atomic_t buf_cnt;
563
+ struct completion stop_complete;
564
+ struct rkcif_toisp_buf_state toisp_buf_state;
565
+ u32 skip_frame;
566
+ u32 cur_skip_frame;
539567 bool stopping;
540568 bool crop_enable;
541569 bool crop_dyn_en;
....@@ -552,6 +580,9 @@
552580 bool is_in_vblank;
553581 bool is_change_toisp;
554582 bool is_stop_capture;
583
+ bool is_wait_dma_stop;
584
+ bool is_single_cap;
585
+ bool is_wait_stop_complete;
555586 };
556587
557588 struct rkcif_lvds_subdev {
....@@ -787,6 +818,20 @@
787818 u32 intstat;
788819 u32 lastline;
789820 u32 lastpixel;
821
+ u32 size_id0;
822
+ u32 size_id1;
823
+ u32 size_id2;
824
+ u32 size_id3;
825
+};
826
+
827
+enum rkcif_resume_user {
828
+ RKCIF_RESUME_CIF,
829
+ RKCIF_RESUME_ISP,
830
+};
831
+
832
+struct rkcif_sensor_work {
833
+ struct work_struct work;
834
+ int on;
790835 };
791836
792837 /*
....@@ -817,6 +862,7 @@
817862 int chip_id;
818863 atomic_t stream_cnt;
819864 atomic_t power_cnt;
865
+ atomic_t streamoff_cnt;
820866 struct mutex stream_lock; /* lock between streams */
821867 struct mutex scale_lock; /* lock between scale dev */
822868 struct mutex tools_lock; /* lock between tools dev */
....@@ -841,6 +887,7 @@
841887 struct rkcif_work_struct reset_work;
842888 int id_use_cnt;
843889 unsigned int csi_host_idx;
890
+ unsigned int csi_host_idx_def;
844891 unsigned int dvp_sof_in_oneframe;
845892 unsigned int wait_line;
846893 unsigned int wait_line_bak;
....@@ -848,6 +895,7 @@
848895 struct completion cmpl_ntf;
849896 struct csi2_dphy_hw *dphy_hw;
850897 phys_addr_t resmem_pa;
898
+ dma_addr_t resmem_addr;
851899 size_t resmem_size;
852900 struct rk_tb_client tb_client;
853901 bool is_start_hdr;
....@@ -858,6 +906,9 @@
858906 bool is_thunderboot;
859907 bool is_rdbk_to_online;
860908 bool is_support_tools;
909
+ bool is_rtt_suspend;
910
+ bool sensor_state_change;
911
+ bool is_toisp_reset;
861912 int rdbk_debug;
862913 struct rkcif_sync_cfg sync_cfg;
863914 int sditf_cnt;
....@@ -866,6 +917,14 @@
866917 int sensor_linetime;
867918 u32 err_state;
868919 struct rkcif_err_state_work err_state_work;
920
+ struct rkcif_sensor_work sensor_work;
921
+ int resume_mode;
922
+ u32 nr_buf_size;
923
+ u32 share_mem_size;
924
+ u32 thunderboot_sensor_num;
925
+ int sensor_state;
926
+ u32 intr_mask;
927
+ struct delayed_work work_deal_err;
869928 };
870929
871930 extern struct platform_driver rkcif_plat_drv;
....@@ -883,7 +942,7 @@
883942 int rkcif_scale_start(struct rkcif_scale_vdev *scale_vdev);
884943
885944 const struct
886
-cif_input_fmt *get_input_fmt(struct v4l2_subdev *sd,
945
+cif_input_fmt *rkcif_get_input_fmt(struct rkcif_device *dev,
887946 struct v4l2_rect *rect,
888947 u32 pad_id, struct csi_channel_info *csi_info);
889948
....@@ -962,5 +1021,15 @@
9621021 void rkcif_rockit_dev_deinit(void);
9631022
9641023 void rkcif_err_print_work(struct work_struct *work);
1024
+int rkcif_stream_suspend(struct rkcif_device *cif_dev, int mode);
1025
+int rkcif_stream_resume(struct rkcif_device *cif_dev, int mode);
1026
+
1027
+static inline u64 rkcif_time_get_ns(struct rkcif_device *dev)
1028
+{
1029
+ if (dev->chip_id == CHIP_RV1106_CIF)
1030
+ return ktime_get_boottime_ns();
1031
+ else
1032
+ return ktime_get_ns();
1033
+}
9651034
9661035 #endif