1/*
2 * Copyright (C) 2013 - 2014 Texas Instruments, Inc.
3 *
4 * Benoit Parrot <bparrot@ti.com>
5 * Lad, Prabhakar <prabhakar.csengg@gmail.com>
6 *
7 * This program is free software; you may redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
12 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
15 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
16 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 * SOFTWARE.
19 */
20
21#ifndef AM437X_VPFE_USER_H
22#define AM437X_VPFE_USER_H
23
24#include <linux/videodev2.h>
25
26enum vpfe_ccdc_data_size {
27	VPFE_CCDC_DATA_16BITS = 0,
28	VPFE_CCDC_DATA_15BITS,
29	VPFE_CCDC_DATA_14BITS,
30	VPFE_CCDC_DATA_13BITS,
31	VPFE_CCDC_DATA_12BITS,
32	VPFE_CCDC_DATA_11BITS,
33	VPFE_CCDC_DATA_10BITS,
34	VPFE_CCDC_DATA_8BITS,
35};
36
37/* enum for No of pixel per line to be avg. in Black Clamping*/
38enum vpfe_ccdc_sample_length {
39	VPFE_CCDC_SAMPLE_1PIXELS = 0,
40	VPFE_CCDC_SAMPLE_2PIXELS,
41	VPFE_CCDC_SAMPLE_4PIXELS,
42	VPFE_CCDC_SAMPLE_8PIXELS,
43	VPFE_CCDC_SAMPLE_16PIXELS,
44};
45
46/* enum for No of lines in Black Clamping */
47enum vpfe_ccdc_sample_line {
48	VPFE_CCDC_SAMPLE_1LINES = 0,
49	VPFE_CCDC_SAMPLE_2LINES,
50	VPFE_CCDC_SAMPLE_4LINES,
51	VPFE_CCDC_SAMPLE_8LINES,
52	VPFE_CCDC_SAMPLE_16LINES,
53};
54
55/* enum for Alaw gamma width */
56enum vpfe_ccdc_gamma_width {
57	VPFE_CCDC_GAMMA_BITS_15_6 = 0,	/* use bits 15-6 for gamma */
58	VPFE_CCDC_GAMMA_BITS_14_5,
59	VPFE_CCDC_GAMMA_BITS_13_4,
60	VPFE_CCDC_GAMMA_BITS_12_3,
61	VPFE_CCDC_GAMMA_BITS_11_2,
62	VPFE_CCDC_GAMMA_BITS_10_1,
63	VPFE_CCDC_GAMMA_BITS_09_0,	/* use bits 9-0 for gamma */
64};
65
66/* structure for ALaw */
67struct vpfe_ccdc_a_law {
68	/* Enable/disable A-Law */
69	unsigned char enable;
70	/* Gamma Width Input */
71	enum vpfe_ccdc_gamma_width gamma_wd;
72};
73
74/* structure for Black Clamping */
75struct vpfe_ccdc_black_clamp {
76	unsigned char enable;
77	/* only if bClampEnable is TRUE */
78	enum vpfe_ccdc_sample_length sample_pixel;
79	/* only if bClampEnable is TRUE */
80	enum vpfe_ccdc_sample_line sample_ln;
81	/* only if bClampEnable is TRUE */
82	unsigned short start_pixel;
83	/* only if bClampEnable is TRUE */
84	unsigned short sgain;
85	/* only if bClampEnable is FALSE */
86	unsigned short dc_sub;
87};
88
89/* structure for Black Level Compensation */
90struct vpfe_ccdc_black_compensation {
91	/* Constant value to subtract from Red component */
92	char r;
93	/* Constant value to subtract from Gr component */
94	char gr;
95	/* Constant value to subtract from Blue component */
96	char b;
97	/* Constant value to subtract from Gb component */
98	char gb;
99};
100
101/* Structure for CCDC configuration parameters for raw capture mode passed
102 * by application
103 */
104struct vpfe_ccdc_config_params_raw {
105	/* data size value from 8 to 16 bits */
106	enum vpfe_ccdc_data_size data_sz;
107	/* Structure for Optional A-Law */
108	struct vpfe_ccdc_a_law alaw;
109	/* Structure for Optical Black Clamp */
110	struct vpfe_ccdc_black_clamp blk_clamp;
111	/* Structure for Black Compensation */
112	struct vpfe_ccdc_black_compensation blk_comp;
113};
114
115/*
116 *  Private IOCTL
117 * VIDIOC_AM437X_CCDC_CFG - Set CCDC configuration for raw capture
118 * This is an experimental ioctl that will change in future kernels. So use
119 * this ioctl with care !
120 **/
121#define VIDIOC_AM437X_CCDC_CFG \
122	_IOW('V', BASE_VIDIOC_PRIVATE + 1, void *)
123
124#endif		/* AM437X_VPFE_USER_H */
125