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