Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * ispstat.h
3 *
4 * TI OMAP3 ISP - Statistics core
5 *
6 * Copyright (C) 2010 Nokia Corporation
7 * Copyright (C) 2009 Texas Instruments, Inc
8 *
9 * Contacts: David Cohen <dacohen@gmail.com>
10 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
11 * Sakari Ailus <sakari.ailus@iki.fi>
12 *
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.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 * 02110-1301 USA
26 */
27
28#ifndef OMAP3_ISP_STAT_H
29#define OMAP3_ISP_STAT_H
30
31#include <linux/types.h>
32#include <linux/omap3isp.h>
33#include <linux/omap-dma.h>
34#include <media/v4l2-event.h>
35
36#include "isp.h"
37#include "ispvideo.h"
38
39#define STAT_MAX_BUFS 5
40#define STAT_NEVENTS 8
41
42#define STAT_BUF_DONE 0 /* Buffer is ready */
43#define STAT_NO_BUF 1 /* An error has occurred */
44#define STAT_BUF_WAITING_DMA 2 /* Histogram only: DMA is running */
45
46struct ispstat;
47
48struct ispstat_buffer {
49 struct sg_table sgt;
50 void *virt_addr;
51 dma_addr_t dma_addr;
52 struct timespec ts;
53 u32 buf_size;
54 u32 frame_number;
55 u16 config_counter;
56 u8 empty;
57};
58
59struct ispstat_ops {
60 /*
61 * Validate new params configuration.
62 * new_conf->buf_size value must be changed to the exact buffer size
63 * necessary for the new configuration if it's smaller.
64 */
65 int (*validate_params)(struct ispstat *stat, void *new_conf);
66
67 /*
68 * Save new params configuration.
69 * stat->priv->buf_size value must be set to the exact buffer size for
70 * the new configuration.
71 * stat->update is set to 1 if new configuration is different than
72 * current one.
73 */
74 void (*set_params)(struct ispstat *stat, void *new_conf);
75
76 /* Apply stored configuration. */
77 void (*setup_regs)(struct ispstat *stat, void *priv);
78
79 /* Enable/Disable module. */
80 void (*enable)(struct ispstat *stat, int enable);
81
82 /* Verify is module is busy. */
83 int (*busy)(struct ispstat *stat);
84
85 /* Used for specific operations during generic buf process task. */
86 int (*buf_process)(struct ispstat *stat);
87};
88
89enum ispstat_state_t {
90 ISPSTAT_DISABLED = 0,
91 ISPSTAT_DISABLING,
92 ISPSTAT_ENABLED,
93 ISPSTAT_ENABLING,
94 ISPSTAT_SUSPENDED,
95};
96
97struct ispstat {
98 struct v4l2_subdev subdev;
99 struct media_pad pad; /* sink pad */
100
101 /* Control */
102 unsigned configured:1;
103 unsigned update:1;
104 unsigned buf_processing:1;
105 unsigned sbl_ovl_recover:1;
106 u8 inc_config;
107 atomic_t buf_err;
108 enum ispstat_state_t state; /* enabling/disabling state */
109 struct omap_dma_channel_params dma_config;
110 struct isp_device *isp;
111 void *priv; /* pointer to priv config struct */
112 void *recover_priv; /* pointer to recover priv configuration */
113 struct mutex ioctl_lock; /* serialize private ioctl */
114
115 const struct ispstat_ops *ops;
116
117 /* Buffer */
118 u8 wait_acc_frames;
119 u16 config_counter;
120 u32 frame_number;
121 u32 buf_size;
122 u32 buf_alloc_size;
123 int dma_ch;
124 unsigned long event_type;
125 struct ispstat_buffer *buf;
126 struct ispstat_buffer *active_buf;
127 struct ispstat_buffer *locked_buf;
128};
129
130struct ispstat_generic_config {
131 /*
132 * Fields must be in the same order as in:
133 * - omap3isp_h3a_aewb_config
134 * - omap3isp_h3a_af_config
135 * - omap3isp_hist_config
136 */
137 u32 buf_size;
138 u16 config_counter;
139};
140
141int omap3isp_stat_config(struct ispstat *stat, void *new_conf);
142int omap3isp_stat_request_statistics(struct ispstat *stat,
143 struct omap3isp_stat_data *data);
144int omap3isp_stat_init(struct ispstat *stat, const char *name,
145 const struct v4l2_subdev_ops *sd_ops);
146void omap3isp_stat_cleanup(struct ispstat *stat);
147int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
148 struct v4l2_fh *fh,
149 struct v4l2_event_subscription *sub);
150int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
151 struct v4l2_fh *fh,
152 struct v4l2_event_subscription *sub);
153int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable);
154
155int omap3isp_stat_busy(struct ispstat *stat);
156int omap3isp_stat_pcr_busy(struct ispstat *stat);
157void omap3isp_stat_suspend(struct ispstat *stat);
158void omap3isp_stat_resume(struct ispstat *stat);
159int omap3isp_stat_enable(struct ispstat *stat, u8 enable);
160void omap3isp_stat_sbl_overflow(struct ispstat *stat);
161void omap3isp_stat_isr(struct ispstat *stat);
162void omap3isp_stat_isr_frame_sync(struct ispstat *stat);
163void omap3isp_stat_dma_isr(struct ispstat *stat);
164int omap3isp_stat_register_entities(struct ispstat *stat,
165 struct v4l2_device *vdev);
166void omap3isp_stat_unregister_entities(struct ispstat *stat);
167
168#endif /* OMAP3_ISP_STAT_H */