1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
2 /*
3  * RP1 PiSP Front End statistics definitions
4  *
5  * Copyright (C) 2021 - Raspberry Pi Ltd.
6  *
7  */
8 #ifndef _UAPI_PISP_FE_STATISTICS_H_
9 #define _UAPI_PISP_FE_STATISTICS_H_
10 
11 #include <linux/types.h>
12 
13 #define PISP_FLOATING_STATS_NUM_ZONES 4
14 #define PISP_AGC_STATS_NUM_BINS 1024
15 #define PISP_AGC_STATS_SIZE 16
16 #define PISP_AGC_STATS_NUM_ZONES (PISP_AGC_STATS_SIZE * PISP_AGC_STATS_SIZE)
17 #define PISP_AGC_STATS_NUM_ROW_SUMS 512
18 
19 struct pisp_agc_statistics_zone {
20 	__u64 Y_sum;
21 	__u32 counted;
22 	__u32 pad;
23 } __attribute__((packed));
24 
25 struct pisp_agc_statistics {
26 	__u32 row_sums[PISP_AGC_STATS_NUM_ROW_SUMS];
27 	/*
28 	 * 32-bits per bin means an image (just less than) 16384x16384 pixels
29 	 * in size can weight every pixel from 0 to 15.
30 	 */
31 	__u32 histogram[PISP_AGC_STATS_NUM_BINS];
32 	struct pisp_agc_statistics_zone floating[PISP_FLOATING_STATS_NUM_ZONES];
33 } __attribute__((packed));
34 
35 #define PISP_AWB_STATS_SIZE 32
36 #define PISP_AWB_STATS_NUM_ZONES (PISP_AWB_STATS_SIZE * PISP_AWB_STATS_SIZE)
37 
38 struct pisp_awb_statistics_zone {
39 	__u32 R_sum;
40 	__u32 G_sum;
41 	__u32 B_sum;
42 	__u32 counted;
43 } __attribute__((packed));
44 
45 struct pisp_awb_statistics {
46 	struct pisp_awb_statistics_zone zones[PISP_AWB_STATS_NUM_ZONES];
47 	struct pisp_awb_statistics_zone floating[PISP_FLOATING_STATS_NUM_ZONES];
48 } __attribute__((packed));
49 
50 #define PISP_CDAF_STATS_SIZE 8
51 #define PISP_CDAF_STATS_NUM_FOMS (PISP_CDAF_STATS_SIZE * PISP_CDAF_STATS_SIZE)
52 
53 struct pisp_cdaf_statistics {
54 	__u64 foms[PISP_CDAF_STATS_NUM_FOMS];
55 	__u64 floating[PISP_FLOATING_STATS_NUM_ZONES];
56 } __attribute__((packed));
57 
58 struct pisp_statistics {
59 	struct pisp_awb_statistics awb;
60 	struct pisp_agc_statistics agc;
61 	struct pisp_cdaf_statistics cdaf;
62 } __attribute__((packed));
63 
64 #endif /* _UAPI_PISP_FE_STATISTICS_H_ */
65