1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #ifndef OMAP3_ISP_STAT_H
16 #define OMAP3_ISP_STAT_H
17
18 #include <linux/types.h>
19 #include <linux/omap3isp.h>
20 #include <media/v4l2-event.h>
21
22 #include "isp.h"
23 #include "ispvideo.h"
24
25 #define STAT_MAX_BUFS 5
26 #define STAT_NEVENTS 8
27
28 #define STAT_BUF_DONE 0
29 #define STAT_NO_BUF 1
30 #define STAT_BUF_WAITING_DMA 2
31
32 struct dma_chan;
33 struct ispstat;
34
35 struct ispstat_buffer {
36 struct sg_table sgt;
37 void *virt_addr;
38 dma_addr_t dma_addr;
39 struct timespec64 ts;
40 u32 buf_size;
41 u32 frame_number;
42 u16 config_counter;
43 u8 empty;
44 };
45
46 struct ispstat_ops {
47
48
49
50
51
52 int (*validate_params)(struct ispstat *stat, void *new_conf);
53
54
55
56
57
58
59
60
61 void (*set_params)(struct ispstat *stat, void *new_conf);
62
63
64 void (*setup_regs)(struct ispstat *stat, void *priv);
65
66
67 void (*enable)(struct ispstat *stat, int enable);
68
69
70 int (*busy)(struct ispstat *stat);
71
72
73 int (*buf_process)(struct ispstat *stat);
74 };
75
76 enum ispstat_state_t {
77 ISPSTAT_DISABLED = 0,
78 ISPSTAT_DISABLING,
79 ISPSTAT_ENABLED,
80 ISPSTAT_ENABLING,
81 ISPSTAT_SUSPENDED,
82 };
83
84 struct ispstat {
85 struct v4l2_subdev subdev;
86 struct media_pad pad;
87
88
89 unsigned configured:1;
90 unsigned update:1;
91 unsigned buf_processing:1;
92 unsigned sbl_ovl_recover:1;
93 u8 inc_config;
94 atomic_t buf_err;
95 enum ispstat_state_t state;
96 struct isp_device *isp;
97 void *priv;
98 void *recover_priv;
99 struct mutex ioctl_lock;
100
101 const struct ispstat_ops *ops;
102
103
104 u8 wait_acc_frames;
105 u16 config_counter;
106 u32 frame_number;
107 u32 buf_size;
108 u32 buf_alloc_size;
109 struct dma_chan *dma_ch;
110 unsigned long event_type;
111 struct ispstat_buffer *buf;
112 struct ispstat_buffer *active_buf;
113 struct ispstat_buffer *locked_buf;
114 };
115
116 struct ispstat_generic_config {
117
118
119
120
121
122
123 u32 buf_size;
124 u16 config_counter;
125 };
126
127 int omap3isp_stat_config(struct ispstat *stat, void *new_conf);
128 int omap3isp_stat_request_statistics(struct ispstat *stat,
129 struct omap3isp_stat_data *data);
130 int omap3isp_stat_request_statistics_time32(struct ispstat *stat,
131 struct omap3isp_stat_data_time32 *data);
132 int omap3isp_stat_init(struct ispstat *stat, const char *name,
133 const struct v4l2_subdev_ops *sd_ops);
134 void omap3isp_stat_cleanup(struct ispstat *stat);
135 int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
136 struct v4l2_fh *fh,
137 struct v4l2_event_subscription *sub);
138 int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
139 struct v4l2_fh *fh,
140 struct v4l2_event_subscription *sub);
141 int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable);
142
143 int omap3isp_stat_busy(struct ispstat *stat);
144 int omap3isp_stat_pcr_busy(struct ispstat *stat);
145 void omap3isp_stat_suspend(struct ispstat *stat);
146 void omap3isp_stat_resume(struct ispstat *stat);
147 int omap3isp_stat_enable(struct ispstat *stat, u8 enable);
148 void omap3isp_stat_sbl_overflow(struct ispstat *stat);
149 void omap3isp_stat_isr(struct ispstat *stat);
150 void omap3isp_stat_isr_frame_sync(struct ispstat *stat);
151 void omap3isp_stat_dma_isr(struct ispstat *stat);
152 int omap3isp_stat_register_entities(struct ispstat *stat,
153 struct v4l2_device *vdev);
154 void omap3isp_stat_unregister_entities(struct ispstat *stat);
155
156 #endif