summaryrefslogtreecommitdiff
path: root/isp/stats.h
blob: f68d4faf50c6e8ac019ed05de49bdbdc4ffb82c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * OMAP3 ISP library - OMAP3 ISP statistics
 *
 * Copyright (C) 2010-2012 Ideas on board SPRL
 *
 * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef __OMAP3ISP_STATS_H
#define __OMAP3ISP_STATS_H

#include <stdint.h>

struct omap3_isp_device;

enum omap3_isp_stat_engine {
	OMAP3_ISP_STAT_AEWB = 1 << 0,
	OMAP3_ISP_STAT_HIST = 1 << 1,
};

/*
 * struct omap3_isp_aewb_stats - OMAP3 ISP AEWB statistics
 * @npix: Total number of accumulated pixels
 * @unsat: Number of accumulated unsaturated pixels
 * @accum: Accumulators
 *
 * The first 4 accumulators store the accumulated pixel values for the 4 color
 * components, organized as follows.
 *
 * +---+---+
 * | 0 | 1 |
 * +---+---+
 * | 2 | 3 |
 * +---+---+
 *
 * The next 4 accumulators are similar, but store the accumulated saturated
 * (clipped) pixel values.
 */
struct omap3_isp_aewb_stats {
	uint32_t npix;
	uint32_t unsat;
	uint32_t accum[8];
};

/*
 * struct omap3_isp_histogram_stats - OMAP3 ISP histogram statistics
 * @nbins: Number of bins in the histogram
 * @bins: Array of histogram frequency data
 *
 * Each bin entry is stored on 32 bits but limited to 20 bits.
 */
struct omap3_isp_histogram_stats {
	unsigned int nbins;
	uint32_t *bins;
};

/*
 * omap3_isp_stats_enable - Enable or disable the statistics engine
 * @isp: The ISP device
 * @which: The statistics engine(s) to enable
 *
 * The statistics engines must be enabled prior to starting the video stream.
 * When enabled, statistics will be computed for every frame and delivered
 * through the ISP aewb_ready() and histogram_ready() callbacks.
 */
void omap3_isp_stats_enable(struct omap3_isp_device *isp,
			    enum omap3_isp_stat_engine which);

/*
 * omap3_isp_stats_get_format - Get frame format at the statistics engine input
 * @isp: The ISP device
 * @format: Frame format
 *
 * Fill the format argument with the frame format at the statistics engine
 * input.
 */
int omap3_isp_stats_get_format(struct omap3_isp_device *isp,
			       struct v4l2_mbus_framefmt *format);

/*
 * omap3_isp_aewb_configure - Configure the AEWB statistics engine
 * @isp: The ISP device
 * @rect: The region of interest, relative to the sensor output frame size
 * @saturation: Pixel saturation threshold value
 */
int omap3_isp_aewb_configure(struct omap3_isp_device *isp, struct v4l2_rect *rect,
			     unsigned int saturation);

/*
 * omap3_isp_histogram_configure - Configure the histogram statistics engine
 * @isp: The ISP device
 * @rect: The region of interest, relative to the sensor output frame size
 */
int omap3_isp_histogram_configure(struct omap3_isp_device *isp,
				  struct v4l2_rect *rect);

#endif