Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / include / media / davinci / dm644x_ccdc.h
1 /*
2  * Copyright (C) 2006-2009 Texas Instruments Inc
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18 #ifndef _DM644X_CCDC_H
19 #define _DM644X_CCDC_H
20 #include <media/davinci/ccdc_types.h>
21 #include <media/davinci/vpfe_types.h>
22
23 /* enum for No of pixel per line to be avg. in Black Clamping*/
24 enum ccdc_sample_length {
25         CCDC_SAMPLE_1PIXELS,
26         CCDC_SAMPLE_2PIXELS,
27         CCDC_SAMPLE_4PIXELS,
28         CCDC_SAMPLE_8PIXELS,
29         CCDC_SAMPLE_16PIXELS
30 };
31
32 /* enum for No of lines in Black Clamping */
33 enum ccdc_sample_line {
34         CCDC_SAMPLE_1LINES,
35         CCDC_SAMPLE_2LINES,
36         CCDC_SAMPLE_4LINES,
37         CCDC_SAMPLE_8LINES,
38         CCDC_SAMPLE_16LINES
39 };
40
41 /* enum for Alaw gamma width */
42 enum ccdc_gamma_width {
43         CCDC_GAMMA_BITS_15_6,   /* use bits 15-6 for gamma */
44         CCDC_GAMMA_BITS_14_5,
45         CCDC_GAMMA_BITS_13_4,
46         CCDC_GAMMA_BITS_12_3,
47         CCDC_GAMMA_BITS_11_2,
48         CCDC_GAMMA_BITS_10_1,
49         CCDC_GAMMA_BITS_09_0    /* use bits 9-0 for gamma */
50 };
51
52 /* returns the highest bit used for the gamma */
53 static inline u8 ccdc_gamma_width_max_bit(enum ccdc_gamma_width width)
54 {
55         return 15 - width;
56 }
57
58 enum ccdc_data_size {
59         CCDC_DATA_16BITS,
60         CCDC_DATA_15BITS,
61         CCDC_DATA_14BITS,
62         CCDC_DATA_13BITS,
63         CCDC_DATA_12BITS,
64         CCDC_DATA_11BITS,
65         CCDC_DATA_10BITS,
66         CCDC_DATA_8BITS
67 };
68
69 /* returns the highest bit used for this data size */
70 static inline u8 ccdc_data_size_max_bit(enum ccdc_data_size sz)
71 {
72         return sz == CCDC_DATA_8BITS ? 7 : 15 - sz;
73 }
74
75 /* structure for ALaw */
76 struct ccdc_a_law {
77         /* Enable/disable A-Law */
78         unsigned char enable;
79         /* Gamma Width Input */
80         enum ccdc_gamma_width gamma_wd;
81 };
82
83 /* structure for Black Clamping */
84 struct ccdc_black_clamp {
85         unsigned char enable;
86         /* only if bClampEnable is TRUE */
87         enum ccdc_sample_length sample_pixel;
88         /* only if bClampEnable is TRUE */
89         enum ccdc_sample_line sample_ln;
90         /* only if bClampEnable is TRUE */
91         unsigned short start_pixel;
92         /* only if bClampEnable is TRUE */
93         unsigned short sgain;
94         /* only if bClampEnable is FALSE */
95         unsigned short dc_sub;
96 };
97
98 /* structure for Black Level Compensation */
99 struct ccdc_black_compensation {
100         /* Constant value to subtract from Red component */
101         char r;
102         /* Constant value to subtract from Gr component */
103         char gr;
104         /* Constant value to subtract from Blue component */
105         char b;
106         /* Constant value to subtract from Gb component */
107         char gb;
108 };
109
110 /* structure for fault pixel correction */
111 struct ccdc_fault_pixel {
112         /* Enable or Disable fault pixel correction */
113         unsigned char enable;
114         /* Number of fault pixel */
115         unsigned short fp_num;
116         /* Address of fault pixel table */
117         unsigned long fpc_table_addr;
118 };
119
120 /* Structure for CCDC configuration parameters for raw capture mode passed
121  * by application
122  */
123 struct ccdc_config_params_raw {
124         /* data size value from 8 to 16 bits */
125         enum ccdc_data_size data_sz;
126         /* Structure for Optional A-Law */
127         struct ccdc_a_law alaw;
128         /* Structure for Optical Black Clamp */
129         struct ccdc_black_clamp blk_clamp;
130         /* Structure for Black Compensation */
131         struct ccdc_black_compensation blk_comp;
132         /* Structure for Fault Pixel Module Configuration */
133         struct ccdc_fault_pixel fault_pxl;
134 };
135
136
137 #ifdef __KERNEL__
138 #include <linux/io.h>
139 /* Define to enable/disable video port */
140 #define FP_NUM_BYTES            4
141 /* Define for extra pixel/line and extra lines/frame */
142 #define NUM_EXTRAPIXELS         8
143 #define NUM_EXTRALINES          8
144
145 /* settings for commonly used video formats */
146 #define CCDC_WIN_PAL     {0, 0, 720, 576}
147 /* ntsc square pixel */
148 #define CCDC_WIN_VGA    {0, 0, (640 + NUM_EXTRAPIXELS), (480 + NUM_EXTRALINES)}
149
150 /* Structure for CCDC configuration parameters for raw capture mode */
151 struct ccdc_params_raw {
152         /* pixel format */
153         enum ccdc_pixfmt pix_fmt;
154         /* progressive or interlaced frame */
155         enum ccdc_frmfmt frm_fmt;
156         /* video window */
157         struct v4l2_rect win;
158         /* field id polarity */
159         enum vpfe_pin_pol fid_pol;
160         /* vertical sync polarity */
161         enum vpfe_pin_pol vd_pol;
162         /* horizontal sync polarity */
163         enum vpfe_pin_pol hd_pol;
164         /* interleaved or separated fields */
165         enum ccdc_buftype buf_type;
166         /*
167          * enable to store the image in inverse
168          * order in memory(bottom to top)
169          */
170         unsigned char image_invert_enable;
171         /* configurable paramaters */
172         struct ccdc_config_params_raw config_params;
173 };
174
175 struct ccdc_params_ycbcr {
176         /* pixel format */
177         enum ccdc_pixfmt pix_fmt;
178         /* progressive or interlaced frame */
179         enum ccdc_frmfmt frm_fmt;
180         /* video window */
181         struct v4l2_rect win;
182         /* field id polarity */
183         enum vpfe_pin_pol fid_pol;
184         /* vertical sync polarity */
185         enum vpfe_pin_pol vd_pol;
186         /* horizontal sync polarity */
187         enum vpfe_pin_pol hd_pol;
188         /* enable BT.656 embedded sync mode */
189         int bt656_enable;
190         /* cb:y:cr:y or y:cb:y:cr in memory */
191         enum ccdc_pixorder pix_order;
192         /* interleaved or separated fields  */
193         enum ccdc_buftype buf_type;
194 };
195 #endif
196 #endif                          /* _DM644X_CCDC_H */