4 * TI OMAP3 ISP - Statistics core
6 * Copyright (C) 2010 Nokia Corporation
7 * Copyright (C) 2009 Texas Instruments, Inc
9 * Contacts: David Cohen <dacohen@gmail.com>
10 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
11 * Sakari Ailus <sakari.ailus@iki.fi>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
18 #ifndef OMAP3_ISP_STAT_H
19 #define OMAP3_ISP_STAT_H
21 #include <linux/types.h>
22 #include <linux/omap3isp.h>
23 #include <linux/omap-dma.h>
24 #include <media/v4l2-event.h>
29 #define STAT_MAX_BUFS 5
30 #define STAT_NEVENTS 8
32 #define STAT_BUF_DONE 0 /* Buffer is ready */
33 #define STAT_NO_BUF 1 /* An error has occurred */
34 #define STAT_BUF_WAITING_DMA 2 /* Histogram only: DMA is running */
38 struct ispstat_buffer {
51 * Validate new params configuration.
52 * new_conf->buf_size value must be changed to the exact buffer size
53 * necessary for the new configuration if it's smaller.
55 int (*validate_params)(struct ispstat *stat, void *new_conf);
58 * Save new params configuration.
59 * stat->priv->buf_size value must be set to the exact buffer size for
60 * the new configuration.
61 * stat->update is set to 1 if new configuration is different than
64 void (*set_params)(struct ispstat *stat, void *new_conf);
66 /* Apply stored configuration. */
67 void (*setup_regs)(struct ispstat *stat, void *priv);
69 /* Enable/Disable module. */
70 void (*enable)(struct ispstat *stat, int enable);
72 /* Verify is module is busy. */
73 int (*busy)(struct ispstat *stat);
75 /* Used for specific operations during generic buf process task. */
76 int (*buf_process)(struct ispstat *stat);
79 enum ispstat_state_t {
88 struct v4l2_subdev subdev;
89 struct media_pad pad; /* sink pad */
92 unsigned configured:1;
94 unsigned buf_processing:1;
95 unsigned sbl_ovl_recover:1;
98 enum ispstat_state_t state; /* enabling/disabling state */
99 struct omap_dma_channel_params dma_config;
100 struct isp_device *isp;
101 void *priv; /* pointer to priv config struct */
102 void *recover_priv; /* pointer to recover priv configuration */
103 struct mutex ioctl_lock; /* serialize private ioctl */
105 const struct ispstat_ops *ops;
114 unsigned long event_type;
115 struct ispstat_buffer *buf;
116 struct ispstat_buffer *active_buf;
117 struct ispstat_buffer *locked_buf;
120 struct ispstat_generic_config {
122 * Fields must be in the same order as in:
123 * - omap3isp_h3a_aewb_config
124 * - omap3isp_h3a_af_config
125 * - omap3isp_hist_config
131 int omap3isp_stat_config(struct ispstat *stat, void *new_conf);
132 int omap3isp_stat_request_statistics(struct ispstat *stat,
133 struct omap3isp_stat_data *data);
134 int omap3isp_stat_init(struct ispstat *stat, const char *name,
135 const struct v4l2_subdev_ops *sd_ops);
136 void omap3isp_stat_cleanup(struct ispstat *stat);
137 int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
139 struct v4l2_event_subscription *sub);
140 int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
142 struct v4l2_event_subscription *sub);
143 int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable);
145 int omap3isp_stat_busy(struct ispstat *stat);
146 int omap3isp_stat_pcr_busy(struct ispstat *stat);
147 void omap3isp_stat_suspend(struct ispstat *stat);
148 void omap3isp_stat_resume(struct ispstat *stat);
149 int omap3isp_stat_enable(struct ispstat *stat, u8 enable);
150 void omap3isp_stat_sbl_overflow(struct ispstat *stat);
151 void omap3isp_stat_isr(struct ispstat *stat);
152 void omap3isp_stat_isr_frame_sync(struct ispstat *stat);
153 void omap3isp_stat_dma_isr(struct ispstat *stat);
154 int omap3isp_stat_register_entities(struct ispstat *stat,
155 struct v4l2_device *vdev);
156 void omap3isp_stat_unregister_entities(struct ispstat *stat);
158 #endif /* OMAP3_ISP_STAT_H */