1 /* SPDX-License-Identifier: GPL-2.0-only */
5 * TI OMAP3 ISP - Statistics core
7 * Copyright (C) 2010 Nokia Corporation
8 * Copyright (C) 2009 Texas Instruments, Inc
10 * Contacts: David Cohen <dacohen@gmail.com>
11 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
12 * Sakari Ailus <sakari.ailus@iki.fi>
15 #ifndef OMAP3_ISP_STAT_H
16 #define OMAP3_ISP_STAT_H
18 #include <linux/types.h>
19 #include <linux/omap3isp.h>
20 #include <media/v4l2-event.h>
25 #define STAT_MAX_BUFS 5
26 #define STAT_NEVENTS 8
28 #define STAT_BUF_DONE 0 /* Buffer is ready */
29 #define STAT_NO_BUF 1 /* An error has occurred */
30 #define STAT_BUF_WAITING_DMA 2 /* Histogram only: DMA is running */
35 struct ispstat_buffer
{
48 * Validate new params configuration.
49 * new_conf->buf_size value must be changed to the exact buffer size
50 * necessary for the new configuration if it's smaller.
52 int (*validate_params
)(struct ispstat
*stat
, void *new_conf
);
55 * Save new params configuration.
56 * stat->priv->buf_size value must be set to the exact buffer size for
57 * the new configuration.
58 * stat->update is set to 1 if new configuration is different than
61 void (*set_params
)(struct ispstat
*stat
, void *new_conf
);
63 /* Apply stored configuration. */
64 void (*setup_regs
)(struct ispstat
*stat
, void *priv
);
66 /* Enable/Disable module. */
67 void (*enable
)(struct ispstat
*stat
, int enable
);
69 /* Verify is module is busy. */
70 int (*busy
)(struct ispstat
*stat
);
72 /* Used for specific operations during generic buf process task. */
73 int (*buf_process
)(struct ispstat
*stat
);
76 enum ispstat_state_t
{
85 struct v4l2_subdev subdev
;
86 struct media_pad pad
; /* sink pad */
89 unsigned configured
:1;
91 unsigned buf_processing
:1;
92 unsigned sbl_ovl_recover
:1;
95 enum ispstat_state_t state
; /* enabling/disabling state */
96 struct isp_device
*isp
;
97 void *priv
; /* pointer to priv config struct */
98 void *recover_priv
; /* pointer to recover priv configuration */
99 struct mutex ioctl_lock
; /* serialize private ioctl */
101 const struct ispstat_ops
*ops
;
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
;
116 struct ispstat_generic_config
{
118 * Fields must be in the same order as in:
119 * - omap3isp_h3a_aewb_config
120 * - omap3isp_h3a_af_config
121 * - omap3isp_hist_config
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
,
137 struct v4l2_event_subscription
*sub
);
138 int omap3isp_stat_unsubscribe_event(struct v4l2_subdev
*subdev
,
140 struct v4l2_event_subscription
*sub
);
141 int omap3isp_stat_s_stream(struct v4l2_subdev
*subdev
, int enable
);
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
);
156 #endif /* OMAP3_ISP_STAT_H */