summaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h
blob: 7cc115c9ebe6689a1c32151aaea7a9bec6401d7e (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
/*
 * Copyright (C) 2012 Texas Instruments Inc
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation version 2.
 *
 * This program 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 General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 * Contributors:
 *      Manjunath Hadli <manjunath.hadli@ti.com>
 *      Prabhakar Lad <prabhakar.lad@ti.com>
 */

#ifndef _DAVINCI_VPFE_USER_H
#define _DAVINCI_VPFE_USER_H

#include <linux/types.h>
#include <linux/videodev2.h>

/*
 * Private IOCTL
 *
 * VIDIOC_VPFE_ISIF_S_RAW_PARAMS: Set raw params in isif
 * VIDIOC_VPFE_ISIF_G_RAW_PARAMS: Get raw params from isif
 * VIDIOC_VPFE_PRV_S_CONFIG: Set ipipe engine configuration
 * VIDIOC_VPFE_PRV_G_CONFIG: Get ipipe engine configuration
 * VIDIOC_VPFE_RSZ_S_CONFIG: Set resizer engine configuration
 * VIDIOC_VPFE_RSZ_G_CONFIG: Get resizer engine configuration
 */

#define VIDIOC_VPFE_ISIF_S_RAW_PARAMS \
	_IOW('V', BASE_VIDIOC_PRIVATE + 1,  struct vpfe_isif_raw_config)
#define VIDIOC_VPFE_ISIF_G_RAW_PARAMS \
	_IOR('V', BASE_VIDIOC_PRIVATE + 2, struct vpfe_isif_raw_config)
#define VIDIOC_VPFE_IPIPE_S_CONFIG \
	_IOWR('P', BASE_VIDIOC_PRIVATE + 3, struct vpfe_ipipe_config)
#define VIDIOC_VPFE_IPIPE_G_CONFIG \
	_IOWR('P', BASE_VIDIOC_PRIVATE + 4, struct vpfe_ipipe_config)
#define VIDIOC_VPFE_RSZ_S_CONFIG \
	_IOWR('R', BASE_VIDIOC_PRIVATE + 5, struct vpfe_rsz_config)
#define VIDIOC_VPFE_RSZ_G_CONFIG \
	_IOWR('R', BASE_VIDIOC_PRIVATE + 6, struct vpfe_rsz_config)

/*
 * Private Control's for ISIF
 */
#define VPFE_ISIF_CID_CRGAIN		(V4L2_CID_USER_BASE | 0xa001)
#define VPFE_ISIF_CID_CGRGAIN		(V4L2_CID_USER_BASE | 0xa002)
#define VPFE_ISIF_CID_CGBGAIN		(V4L2_CID_USER_BASE | 0xa003)
#define VPFE_ISIF_CID_CBGAIN		(V4L2_CID_USER_BASE | 0xa004)
#define VPFE_ISIF_CID_GAIN_OFFSET	(V4L2_CID_USER_BASE | 0xa005)

/*
 * Private Control's for ISIF and IPIPEIF
 */
#define VPFE_CID_DPCM_PREDICTOR		(V4L2_CID_USER_BASE | 0xa006)

/************************************************************************
 *   Vertical Defect Correction parameters
 ***********************************************************************/

/**
 * vertical defect correction methods
 */
enum vpfe_isif_vdfc_corr_mode {
	/* Defect level subtraction. Just fed through if saturating */
	VPFE_ISIF_VDFC_NORMAL,
	/**
	 * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2
	 * if data saturating
	 */
	VPFE_ISIF_VDFC_HORZ_INTERPOL_IF_SAT,
	/* Horizontal interpolation (((i-2)+(i+2))/2) */
	VPFE_ISIF_VDFC_HORZ_INTERPOL
};

/**
 * Max Size of the Vertical Defect Correction table
 */
#define VPFE_ISIF_VDFC_TABLE_SIZE	8

/**
 * Values used for shifting up the vdfc defect level
 */
enum vpfe_isif_vdfc_shift {
	/* No Shift */
	VPFE_ISIF_VDFC_NO_SHIFT,
	/* Shift by 1 bit */
	VPFE_ISIF_VDFC_SHIFT_1,
	/* Shift by 2 bit */
	VPFE_ISIF_VDFC_SHIFT_2,
	/* Shift by 3 bit */
	VPFE_ISIF_VDFC_SHIFT_3,
	/* Shift by 4 bit */
	VPFE_ISIF_VDFC_SHIFT_4
};

/**
 * Defect Correction (DFC) table entry
 */
struct vpfe_isif_vdfc_entry {
	/* vertical position of defect */
	unsigned short pos_vert;
	/* horizontal position of defect */
	unsigned short pos_horz;
	/**
	 * Defect level of Vertical line defect position. This is subtracted
	 * from the data at the defect position
	 */
	unsigned char level_at_pos;
	/**
	 * Defect level of the pixels upper than the vertical line defect.
	 * This is subtracted from the data
	 */
	unsigned char level_up_pixels;
	/**
	 * Defect level of the pixels lower than the vertical line defect.
	 * This is subtracted from the data
	 */
	unsigned char level_low_pixels;
};

/**
 * Structure for Defect Correction (DFC) parameter
 */
struct vpfe_isif_dfc {
	/* enable vertical defect correction */
	unsigned char en;
	/* Correction methods */
	enum vpfe_isif_vdfc_corr_mode corr_mode;
	/**
	 * 0 - whole line corrected, 1 - not
	 * pixels upper than the defect
	 */
	unsigned char corr_whole_line;
	/**
	 * defect level shift value. level_at_pos, level_upper_pos,
	 * and level_lower_pos can be shifted up by this value
	 */
	enum vpfe_isif_vdfc_shift def_level_shift;
	/* defect saturation level */
	unsigned short def_sat_level;
	/* number of vertical defects. Max is VPFE_ISIF_VDFC_TABLE_SIZE */
	short num_vdefects;
	/* VDFC table ptr */
	struct vpfe_isif_vdfc_entry table[VPFE_ISIF_VDFC_TABLE_SIZE];
};

/************************************************************************
 *   Digital/Black clamp or DC Subtract parameters
 ************************************************************************/
/**
 * Horizontal Black Clamp modes
 */
enum vpfe_isif_horz_bc_mode {
	/**
	 * Horizontal clamp disabled. Only vertical clamp
	 * value is subtracted
	 */
	VPFE_ISIF_HORZ_BC_DISABLE,
	/**
	 * Horizontal clamp value is calculated and subtracted
	 * from image data along with vertical clamp value
	 */
	VPFE_ISIF_HORZ_BC_CLAMP_CALC_ENABLED,
	/**
	 * Horizontal clamp value calculated from previous image
	 * is subtracted from image data along with vertical clamp
	 * value. How the horizontal clamp value for the first image
	 * is calculated in this case ???
	 */
	VPFE_ISIF_HORZ_BC_CLAMP_NOT_UPDATED
};

/**
 * Base window selection for Horizontal Black Clamp calculations
 */
enum vpfe_isif_horz_bc_base_win_sel {
	/* Select Most left window for bc calculation */
	VPFE_ISIF_SEL_MOST_LEFT_WIN,

	/* Select Most right window for bc calculation */
	VPFE_ISIF_SEL_MOST_RIGHT_WIN,
};

/* Size of window in horizontal direction for horizontal bc */
enum vpfe_isif_horz_bc_sz_h {
	VPFE_ISIF_HORZ_BC_SZ_H_2PIXELS,
	VPFE_ISIF_HORZ_BC_SZ_H_4PIXELS,
	VPFE_ISIF_HORZ_BC_SZ_H_8PIXELS,
	VPFE_ISIF_HORZ_BC_SZ_H_16PIXELS
};

/* Size of window in vertcal direction for vertical bc */
enum vpfe_isif_horz_bc_sz_v {
	VPFE_ISIF_HORZ_BC_SZ_H_32PIXELS,
	VPFE_ISIF_HORZ_BC_SZ_H_64PIXELS,
	VPFE_ISIF_HORZ_BC_SZ_H_128PIXELS,
	VPFE_ISIF_HORZ_BC_SZ_H_256PIXELS
};

/**
 * Structure for Horizontal Black Clamp config params
 */
struct vpfe_isif_horz_bclamp {
	/* horizontal clamp mode */
	enum vpfe_isif_horz_bc_mode mode;
	/**
	 * pixel value limit enable.
	 *  0 - limit disabled
	 *  1 - pixel value limited to 1023
	 */
	unsigned char clamp_pix_limit;
	/**
	 * Select most left or right window for clamp val
	 * calculation
	 */
	enum vpfe_isif_horz_bc_base_win_sel base_win_sel_calc;
	/* Window count per color for calculation. range 1-32 */
	unsigned char win_count_calc;
	/* Window start position - horizontal for calculation. 0 - 8191 */
	unsigned short win_start_h_calc;
	/* Window start position - vertical for calculation 0 - 8191 */
	unsigned short win_start_v_calc;
	/* Width of the sample window in pixels for calculation */
	enum vpfe_isif_horz_bc_sz_h win_h_sz_calc;
	/* Height of the sample window in pixels for calculation */
	enum vpfe_isif_horz_bc_sz_v win_v_sz_calc;
};

/**
 * Black Clamp vertical reset values
 */
enum vpfe_isif_vert_bc_reset_val_sel {
	/* Reset value used is the clamp value calculated */
	VPFE_ISIF_VERT_BC_USE_HORZ_CLAMP_VAL,
	/* Reset value used is reset_clamp_val configured */
	VPFE_ISIF_VERT_BC_USE_CONFIG_CLAMP_VAL,
	/* No update, previous image value is used */
	VPFE_ISIF_VERT_BC_NO_UPDATE
};

enum vpfe_isif_vert_bc_sz_h {
	VPFE_ISIF_VERT_BC_SZ_H_2PIXELS,
	VPFE_ISIF_VERT_BC_SZ_H_4PIXELS,
	VPFE_ISIF_VERT_BC_SZ_H_8PIXELS,
	VPFE_ISIF_VERT_BC_SZ_H_16PIXELS,
	VPFE_ISIF_VERT_BC_SZ_H_32PIXELS,
	VPFE_ISIF_VERT_BC_SZ_H_64PIXELS
};

/**
 * Structure for Vertical Black Clamp configuration params
 */
struct vpfe_isif_vert_bclamp {
	/* Reset value selection for vertical clamp calculation */
	enum vpfe_isif_vert_bc_reset_val_sel reset_val_sel;
	/* U12 value if reset_sel = ISIF_BC_VERT_USE_CONFIG_CLAMP_VAL */
	unsigned short reset_clamp_val;
	/**
	 * U8Q8. Line average coefficient used in vertical clamp
	 * calculation
	 */
	unsigned char line_ave_coef;
	/* Width in pixels of the optical black region used for calculation. */
	enum vpfe_isif_vert_bc_sz_h ob_h_sz_calc;
	/* Height of the optical black region for calculation */
	unsigned short ob_v_sz_calc;
	/* Optical black region start position - horizontal. 0 - 8191 */
	unsigned short ob_start_h;
	/* Optical black region start position - vertical 0 - 8191 */
	unsigned short ob_start_v;
};

/**
 * Structure for Black Clamp configuration params
 */
struct vpfe_isif_black_clamp {
	/**
	 * this offset value is added irrespective of the clamp
	 * enable status. S13
	 */
	unsigned short dc_offset;
	/**
	 * Enable black/digital clamp value to be subtracted
	 * from the image data
	 */
	unsigned char en;
	/**
	 * black clamp mode. same/separate clamp for 4 colors
	 * 0 - disable - same clamp value for all colors
	 * 1 - clamp value calculated separately for all colors
	 */
	unsigned char bc_mode_color;
	/* Vertical start position for bc subtraction */
	unsigned short vert_start_sub;
	/* Black clamp for horizontal direction */
	struct vpfe_isif_horz_bclamp horz;
	/* Black clamp for vertical direction */
	struct vpfe_isif_vert_bclamp vert;
};

/*************************************************************************
 ** Color Space Conversion (CSC)
 *************************************************************************/
/**
 * Number of Coefficient values used for CSC
 */
#define VPFE_ISIF_CSC_NUM_COEFF 16

struct float_8_bit {
	/* 8 bit integer part */
	__u8 integer;
	/* 8 bit decimal part */
	__u8 decimal;
};

struct float_16_bit {
	/* 16 bit integer part */
	__u16 integer;
	/* 16 bit decimal part */
	__u16 decimal;
};

/*************************************************************************
 **  Color Space Conversion parameters
 *************************************************************************/
/**
 * Structure used for CSC config params
 */
struct vpfe_isif_color_space_conv {
	/* Enable color space conversion */
	unsigned char en;
	/**
	 * csc coefficient table. S8Q5, M00 at index 0, M01 at index 1, and
	 * so forth
	 */
	struct float_8_bit coeff[VPFE_ISIF_CSC_NUM_COEFF];
};

enum vpfe_isif_datasft {
	/* No Shift */
	VPFE_ISIF_NO_SHIFT,
	/* 1 bit Shift */
	VPFE_ISIF_1BIT_SHIFT,
	/* 2 bit Shift */
	VPFE_ISIF_2BIT_SHIFT,
	/* 3 bit Shift */
	VPFE_ISIF_3BIT_SHIFT,
	/* 4 bit Shift */
	VPFE_ISIF_4BIT_SHIFT,
	/* 5 bit Shift */
	VPFE_ISIF_5BIT_SHIFT,
	/* 6 bit Shift */
	VPFE_ISIF_6BIT_SHIFT
};

#define VPFE_ISIF_LINEAR_TAB_SIZE		192
/*************************************************************************
 **  Linearization parameters
 *************************************************************************/
/**
 * Structure for Sensor data linearization
 */
struct vpfe_isif_linearize {
	/* Enable or Disable linearization of data */
	unsigned char en;
	/* Shift value applied */
	enum vpfe_isif_datasft corr_shft;
	/* scale factor applied U11Q10 */
	struct float_16_bit scale_fact;
	/* Size of the linear table */
	unsigned short table[VPFE_ISIF_LINEAR_TAB_SIZE];
};

/*************************************************************************
 **  ISIF Raw configuration parameters
 *************************************************************************/
enum vpfe_isif_fmt_mode {
	VPFE_ISIF_SPLIT,
	VPFE_ISIF_COMBINE
};

enum vpfe_isif_lnum {
	VPFE_ISIF_1LINE,
	VPFE_ISIF_2LINES,
	VPFE_ISIF_3LINES,
	VPFE_ISIF_4LINES
};

enum vpfe_isif_line {
	VPFE_ISIF_1STLINE,
	VPFE_ISIF_2NDLINE,
	VPFE_ISIF_3RDLINE,
	VPFE_ISIF_4THLINE
};

struct vpfe_isif_fmtplen {
	/**
	 * number of program entries for SET0, range 1 - 16
	 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
	 * ISIF_COMBINE
	 */
	unsigned short plen0;
	/**
	 * number of program entries for SET1, range 1 - 16
	 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
	 * ISIF_COMBINE
	 */
	unsigned short plen1;
	/**
	 * number of program entries for SET2, range 1 - 16
	 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
	 * ISIF_COMBINE
	 */
	unsigned short plen2;
	/**
	 * number of program entries for SET3, range 1 - 16
	 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
	 * ISIF_COMBINE
	 */
	unsigned short plen3;
};

struct vpfe_isif_fmt_cfg {
	/* Split or combine or line alternate */
	enum vpfe_isif_fmt_mode fmtmode;
	/* enable or disable line alternating mode */
	unsigned char ln_alter_en;
	/* Split/combine line number */
	enum vpfe_isif_lnum lnum;
	/* Address increment Range 1 - 16 */
	unsigned int addrinc;
};

struct vpfe_isif_fmt_addr_ptr {
	/* Initial address */
	unsigned int init_addr;
	/* output line number */
	enum vpfe_isif_line out_line;
};

struct vpfe_isif_fmtpgm_ap {
	/* program address pointer */
	unsigned char pgm_aptr;
	/* program address increment or decrement */
	unsigned char pgmupdt;
};

struct vpfe_isif_data_formatter {
	/* Enable/Disable data formatter */
	unsigned char en;
	/* data formatter configuration */
	struct vpfe_isif_fmt_cfg cfg;
	/* Formatter program entries length */
	struct vpfe_isif_fmtplen plen;
	/* first pixel in a line fed to formatter */
	unsigned short fmtrlen;
	/* HD interval for output line. Only valid when split line */
	unsigned short fmthcnt;
	/* formatter address pointers */
	struct vpfe_isif_fmt_addr_ptr fmtaddr_ptr[16];
	/* program enable/disable */
	unsigned char pgm_en[32];
	/* program address pointers */
	struct vpfe_isif_fmtpgm_ap fmtpgm_ap[32];
};

struct vpfe_isif_df_csc {
	/* Color Space Conversion configuration, 0 - csc, 1 - df */
	unsigned int df_or_csc;
	/* csc configuration valid if df_or_csc is 0 */
	struct vpfe_isif_color_space_conv csc;
	/* data formatter configuration valid if df_or_csc is 1 */
	struct vpfe_isif_data_formatter df;
	/* start pixel in a line at the input */
	unsigned int start_pix;
	/* number of pixels in input line */
	unsigned int num_pixels;
	/* start line at the input */
	unsigned int start_line;
	/* number of lines at the input */
	unsigned int num_lines;
};

struct vpfe_isif_gain_offsets_adj {
	/* Enable or Disable Gain adjustment for SDRAM data */
	unsigned char gain_sdram_en;
	/* Enable or Disable Gain adjustment for IPIPE data */
	unsigned char gain_ipipe_en;
	/* Enable or Disable Gain adjustment for H3A data */
	unsigned char gain_h3a_en;
	/* Enable or Disable Gain adjustment for SDRAM data */
	unsigned char offset_sdram_en;
	/* Enable or Disable Gain adjustment for IPIPE data */
	unsigned char offset_ipipe_en;
	/* Enable or Disable Gain adjustment for H3A data */
	unsigned char offset_h3a_en;
};

struct vpfe_isif_cul {
	/* Horizontal Cull pattern for odd lines */
	unsigned char hcpat_odd;
	/* Horizontal Cull pattern for even lines */
	unsigned char hcpat_even;
	/* Vertical Cull pattern */
	unsigned char vcpat;
	/* Enable or disable lpf. Apply when cull is enabled */
	unsigned char en_lpf;
};

/* all the stuff in this struct will be provided by userland */
struct vpfe_isif_raw_config {
	/* Linearization parameters for image sensor data input */
	struct vpfe_isif_linearize linearize;
	/* Data formatter or CSC */
	struct vpfe_isif_df_csc df_csc;
	/* Defect Pixel Correction (DFC) confguration */
	struct vpfe_isif_dfc dfc;
	/* Black/Digital Clamp configuration */
	struct vpfe_isif_black_clamp bclamp;
	/* Gain, offset adjustments */
	struct vpfe_isif_gain_offsets_adj gain_offset;
	/* Culling */
	struct vpfe_isif_cul culling;
	/* horizontal offset for Gain/LSC/DFC */
	unsigned short horz_offset;
	/* vertical offset for Gain/LSC/DFC */
	unsigned short vert_offset;
};

/**********************************************************************
 *	IPIPE API Structures
 **********************************************************************/

/* IPIPE module configurations */

/* IPIPE input configuration */
#define VPFE_IPIPE_INPUT_CONFIG		BIT(0)
/* LUT based Defect Pixel Correction */
#define VPFE_IPIPE_LUTDPC		BIT(1)
/* On the fly (OTF) Defect Pixel Correction */
#define VPFE_IPIPE_OTFDPC		BIT(2)
/* Noise Filter - 1 */
#define VPFE_IPIPE_NF1			BIT(3)
/* Noise Filter - 2 */
#define VPFE_IPIPE_NF2			BIT(4)
/* White Balance.  Also a control ID */
#define VPFE_IPIPE_WB			BIT(5)
/* 1st RGB to RBG Blend module */
#define VPFE_IPIPE_RGB2RGB_1		BIT(6)
/* 2nd RGB to RBG Blend module */
#define VPFE_IPIPE_RGB2RGB_2		BIT(7)
/* Gamma Correction */
#define VPFE_IPIPE_GAMMA		BIT(8)
/* 3D LUT color conversion */
#define VPFE_IPIPE_3D_LUT		BIT(9)
/* RGB to YCbCr module */
#define VPFE_IPIPE_RGB2YUV		BIT(10)
/* YUV 422 conversion module */
#define VPFE_IPIPE_YUV422_CONV		BIT(11)
/* Edge Enhancement */
#define VPFE_IPIPE_YEE			BIT(12)
/* Green Imbalance Correction */
#define VPFE_IPIPE_GIC			BIT(13)
/* CFA Interpolation */
#define VPFE_IPIPE_CFA			BIT(14)
/* Chroma Artifact Reduction */
#define VPFE_IPIPE_CAR			BIT(15)
/* Chroma Gain Suppression */
#define VPFE_IPIPE_CGS			BIT(16)
/* Global brightness and contrast control */
#define VPFE_IPIPE_GBCE			BIT(17)

#define VPFE_IPIPE_MAX_MODULES		18

struct ipipe_float_u16 {
	unsigned short integer;
	unsigned short decimal;
};

struct ipipe_float_s16 {
	short integer;
	unsigned short decimal;
};

struct ipipe_float_u8 {
	unsigned char integer;
	unsigned char decimal;
};

/* Copy method selection for vertical correction
 *  Used when ipipe_dfc_corr_meth is IPIPE_DPC_CTORB_AFTER_HINT
 */
enum vpfe_ipipe_dpc_corr_meth {
	/* replace by black or white dot specified by repl_white */
	VPFE_IPIPE_DPC_REPL_BY_DOT = 0,
	/* Copy from left */
	VPFE_IPIPE_DPC_CL = 1,
	/* Copy from right */
	VPFE_IPIPE_DPC_CR = 2,
	/* Horizontal interpolation */
	VPFE_IPIPE_DPC_H_INTP = 3,
	/* Vertical interpolation */
	VPFE_IPIPE_DPC_V_INTP = 4,
	/* Copy from top  */
	VPFE_IPIPE_DPC_CT = 5,
	/* Copy from bottom */
	VPFE_IPIPE_DPC_CB = 6,
	/* 2D interpolation */
	VPFE_IPIPE_DPC_2D_INTP = 7,
};

struct vpfe_ipipe_lutdpc_entry {
	/* Horizontal position */
	unsigned short horz_pos;
	/* vertical position */
	unsigned short vert_pos;
	enum vpfe_ipipe_dpc_corr_meth method;
};

#define VPFE_IPIPE_MAX_SIZE_DPC 256

/* Structure for configuring DPC module */
struct vpfe_ipipe_lutdpc {
	/* 0 - disable, 1 - enable */
	unsigned char en;
	/* 0 - replace with black dot, 1 - white dot when correction
	 * method is  IPIPE_DFC_REPL_BY_DOT=0,
	 */
	unsigned char repl_white;
	/* number of entries in the correction table. Currently only
	 * support up-to 256 entries. infinite mode is not supported
	 */
	unsigned short dpc_size;
	struct vpfe_ipipe_lutdpc_entry table[VPFE_IPIPE_MAX_SIZE_DPC];
};

enum vpfe_ipipe_otfdpc_det_meth {
	VPFE_IPIPE_DPC_OTF_MIN_MAX,
	VPFE_IPIPE_DPC_OTF_MIN_MAX2
};

struct vpfe_ipipe_otfdpc_thr {
	unsigned short r;
	unsigned short gr;
	unsigned short gb;
	unsigned short b;
};

enum vpfe_ipipe_otfdpc_alg {
	VPFE_IPIPE_OTFDPC_2_0,
	VPFE_IPIPE_OTFDPC_3_0
};

struct vpfe_ipipe_otfdpc_2_0_cfg {
	/* defect detection threshold for MIN_MAX2 method  (DPC 2.0 alg) */
	struct vpfe_ipipe_otfdpc_thr det_thr;
	/* defect correction threshold for MIN_MAX2 method (DPC 2.0 alg) or
	 * maximum value for MIN_MAX method
	 */
	struct vpfe_ipipe_otfdpc_thr corr_thr;
};

struct vpfe_ipipe_otfdpc_3_0_cfg {
	/* DPC3.0 activity adj shf. activity = (max2-min2) >> (6 -shf)
	 */
	unsigned char act_adj_shf;
	/* DPC3.0 detection threshold, THR */
	unsigned short det_thr;
	/* DPC3.0 detection threshold slope, SLP */
	unsigned short det_slp;
	/* DPC3.0 detection threshold min, MIN */
	unsigned short det_thr_min;
	/* DPC3.0 detection threshold max, MAX */
	unsigned short det_thr_max;
	/* DPC3.0 correction threshold, THR */
	unsigned short corr_thr;
	/* DPC3.0 correction threshold slope, SLP */
	unsigned short corr_slp;
	/* DPC3.0 correction threshold min, MIN */
	unsigned short corr_thr_min;
	/* DPC3.0 correction threshold max, MAX */
	unsigned short corr_thr_max;
};

struct vpfe_ipipe_otfdpc {
	/* 0 - disable, 1 - enable */
	unsigned char en;
	/* defect detection method */
	enum vpfe_ipipe_otfdpc_det_meth det_method;
	/* Algorithm used. Applicable only when IPIPE_DPC_OTF_MIN_MAX2 is
	 * used
	 */
	enum vpfe_ipipe_otfdpc_alg alg;
	union {
		/* if alg is IPIPE_OTFDPC_2_0 */
		struct vpfe_ipipe_otfdpc_2_0_cfg dpc_2_0;
		/* if alg is IPIPE_OTFDPC_3_0 */
		struct vpfe_ipipe_otfdpc_3_0_cfg dpc_3_0;
	} alg_cfg;
};

/* Threshold values table size */
#define VPFE_IPIPE_NF_THR_TABLE_SIZE		8
/* Intensity values table size */
#define VPFE_IPIPE_NF_STR_TABLE_SIZE		8

/* NF, sampling method for green pixels */
enum vpfe_ipipe_nf_sampl_meth {
	/* Same as R or B */
	VPFE_IPIPE_NF_BOX,
	/* Diamond mode */
	VPFE_IPIPE_NF_DIAMOND
};

/* Structure for configuring NF module */
struct vpfe_ipipe_nf {
	/* 0 - disable, 1 - enable */
	unsigned char en;
	/* Sampling method for green pixels */
	enum vpfe_ipipe_nf_sampl_meth gr_sample_meth;
	/* Down shift value in LUT reference address
	 */
	unsigned char shft_val;
	/* Spread value in NF algorithm
	 */
	unsigned char spread_val;
	/* Apply LSC gain to threshold. Enable this only if
	 * LSC is enabled in ISIF
	 */
	unsigned char apply_lsc_gain;
	/* Threshold values table */
	unsigned short thr[VPFE_IPIPE_NF_THR_TABLE_SIZE];
	/* intensity values table */
	unsigned char str[VPFE_IPIPE_NF_STR_TABLE_SIZE];
	/* Edge detection minimum threshold */
	unsigned short edge_det_min_thr;
	/* Edge detection maximum threshold */
	unsigned short edge_det_max_thr;
};

enum vpfe_ipipe_gic_alg {
	VPFE_IPIPE_GIC_ALG_CONST_GAIN,
	VPFE_IPIPE_GIC_ALG_ADAPT_GAIN
};

enum vpfe_ipipe_gic_thr_sel {
	VPFE_IPIPE_GIC_THR_REG,
	VPFE_IPIPE_GIC_THR_NF
};

enum vpfe_ipipe_gic_wt_fn_type {
	/* Use difference as index */
	VPFE_IPIPE_GIC_WT_FN_TYP_DIF,
	/* Use weight function as index */
	VPFE_IPIPE_GIC_WT_FN_TYP_HP_VAL
};

/* structure for Green Imbalance Correction */
struct vpfe_ipipe_gic {
	/* 0 - disable, 1 - enable */
	unsigned char en;
	/* 0 - Constant gain , 1 - Adaptive gain algorithm */
	enum vpfe_ipipe_gic_alg gic_alg;
	/* GIC gain or weight. Used for Constant gain and Adaptive algorithms
	 */
	unsigned short gain;
	/* Threshold selection. GIC register values or NF2 thr table */
	enum vpfe_ipipe_gic_thr_sel thr_sel;
	/* thr1. Used when thr_sel is  IPIPE_GIC_THR_REG */
	unsigned short thr;
	/* this value is used for thr2-thr1, thr3-thr2 or
	 * thr4-thr3 when wt_fn_type is index. Otherwise it
	 * is the
	 */
	unsigned short slope;
	/* Apply LSC gain to threshold. Enable this only if
	 * LSC is enabled in ISIF & thr_sel is IPIPE_GIC_THR_REG
	 */
	unsigned char apply_lsc_gain;
	/* Multiply Nf2 threshold by this gain. Use this when thr_sel
	 * is IPIPE_GIC_THR_NF
	 */
	struct ipipe_float_u8 nf2_thr_gain;
	/* Weight function uses difference as index or high pass value.
	 * Used for adaptive gain algorithm
	 */
	enum vpfe_ipipe_gic_wt_fn_type wt_fn_type;
};

/* Structure for configuring WB module */
struct vpfe_ipipe_wb {
	/* Offset (S12) for R */
	short ofst_r;
	/* Offset (S12) for Gr */
	short ofst_gr;
	/* Offset (S12) for Gb */
	short ofst_gb;
	/* Offset (S12) for B */
	short ofst_b;
	/* Gain (U13Q9) for Red */
	struct ipipe_float_u16 gain_r;
	/* Gain (U13Q9) for Gr */
	struct ipipe_float_u16 gain_gr;
	/* Gain (U13Q9) for Gb */
	struct ipipe_float_u16 gain_gb;
	/* Gain (U13Q9) for Blue */
	struct ipipe_float_u16 gain_b;
};

enum vpfe_ipipe_cfa_alg {
	/* Algorithm is 2DirAC */
	VPFE_IPIPE_CFA_ALG_2DIRAC,
	/* Algorithm is 2DirAC + Digital Antialiasing (DAA) */
	VPFE_IPIPE_CFA_ALG_2DIRAC_DAA,
	/* Algorithm is DAA */
	VPFE_IPIPE_CFA_ALG_DAA
};

/* Structure for CFA Interpolation */
struct vpfe_ipipe_cfa {
	/* 2DirAC or 2DirAC + DAA */
	enum vpfe_ipipe_cfa_alg alg;
	/* 2Dir CFA HP value Low Threshold */
	unsigned short hpf_thr_2dir;
	/* 2Dir CFA HP value slope */
	unsigned short hpf_slp_2dir;
	/* 2Dir CFA HP mix threshold */
	unsigned short hp_mix_thr_2dir;
	/* 2Dir CFA HP mix slope */
	unsigned short hp_mix_slope_2dir;
	/* 2Dir Direction threshold */
	unsigned short dir_thr_2dir;
	/* 2Dir Direction slope */
	unsigned short dir_slope_2dir;
	/* 2Dir Non Directional Weight */
	unsigned short nd_wt_2dir;
	/* DAA Mono Hue Fraction */
	unsigned short hue_fract_daa;
	/* DAA Mono Edge threshold */
	unsigned short edge_thr_daa;
	/* DAA Mono threshold minimum */
	unsigned short thr_min_daa;
	/* DAA Mono threshold slope */
	unsigned short thr_slope_daa;
	/* DAA Mono slope minimum */
	unsigned short slope_min_daa;
	/* DAA Mono slope slope */
	unsigned short slope_slope_daa;
	/* DAA Mono LP wight */
	unsigned short lp_wt_daa;
};

/* Struct for configuring RGB2RGB blending module */
struct vpfe_ipipe_rgb2rgb {
	/* Matrix coefficient for RR S12Q8 for ID = 1 and S11Q8 for ID = 2 */
	struct ipipe_float_s16 coef_rr;
	/* Matrix coefficient for GR S12Q8/S11Q8 */
	struct ipipe_float_s16 coef_gr;
	/* Matrix coefficient for BR S12Q8/S11Q8 */
	struct ipipe_float_s16 coef_br;
	/* Matrix coefficient for RG S12Q8/S11Q8 */
	struct ipipe_float_s16 coef_rg;
	/* Matrix coefficient for GG S12Q8/S11Q8 */
	struct ipipe_float_s16 coef_gg;
	/* Matrix coefficient for BG S12Q8/S11Q8 */
	struct ipipe_float_s16 coef_bg;
	/* Matrix coefficient for RB S12Q8/S11Q8 */
	struct ipipe_float_s16 coef_rb;
	/* Matrix coefficient for GB S12Q8/S11Q8 */
	struct ipipe_float_s16 coef_gb;
	/* Matrix coefficient for BB S12Q8/S11Q8 */
	struct ipipe_float_s16 coef_bb;
	/* Output offset for R S13/S11 */
	int out_ofst_r;
	/* Output offset for G S13/S11 */
	int out_ofst_g;
	/* Output offset for B S13/S11 */
	int out_ofst_b;
};

#define VPFE_IPIPE_MAX_SIZE_GAMMA		512

enum vpfe_ipipe_gamma_tbl_size {
	VPFE_IPIPE_GAMMA_TBL_SZ_64 = 64,
	VPFE_IPIPE_GAMMA_TBL_SZ_128 = 128,
	VPFE_IPIPE_GAMMA_TBL_SZ_256 = 256,
	VPFE_IPIPE_GAMMA_TBL_SZ_512 = 512,
};

enum vpfe_ipipe_gamma_tbl_sel {
	VPFE_IPIPE_GAMMA_TBL_RAM = 0,
	VPFE_IPIPE_GAMMA_TBL_ROM = 1,
};

struct vpfe_ipipe_gamma_entry {
	/* 10 bit slope */
	short slope;
	/* 10 bit offset */
	unsigned short offset;
};

/* Structure for configuring Gamma correction module */
struct vpfe_ipipe_gamma {
	/* 0 - Enable Gamma correction for Red
	 * 1 - bypass Gamma correction. Data is divided by 16
	 */
	unsigned char bypass_r;
	/* 0 - Enable Gamma correction for Blue
	 * 1 - bypass Gamma correction. Data is divided by 16
	 */
	unsigned char bypass_b;
	/* 0 - Enable Gamma correction for Green
	 * 1 - bypass Gamma correction. Data is divided by 16
	 */
	unsigned char bypass_g;
	/* IPIPE_GAMMA_TBL_RAM or IPIPE_GAMMA_TBL_ROM */
	enum vpfe_ipipe_gamma_tbl_sel tbl_sel;
	/* Table size for RAM gamma table.
	 */
	enum vpfe_ipipe_gamma_tbl_size tbl_size;
	/* R table */
	struct vpfe_ipipe_gamma_entry table_r[VPFE_IPIPE_MAX_SIZE_GAMMA];
	/* Blue table */
	struct vpfe_ipipe_gamma_entry table_b[VPFE_IPIPE_MAX_SIZE_GAMMA];
	/* Green table */
	struct vpfe_ipipe_gamma_entry table_g[VPFE_IPIPE_MAX_SIZE_GAMMA];
};

#define VPFE_IPIPE_MAX_SIZE_3D_LUT		729

struct vpfe_ipipe_3d_lut_entry {
	/* 10 bit entry for red */
	unsigned short r;
	/* 10 bit entry for green */
	unsigned short g;
	/* 10 bit entry for blue */
	unsigned short b;
};

/* structure for 3D-LUT */
struct vpfe_ipipe_3d_lut {
	/* enable/disable 3D lut */
	unsigned char en;
	/* 3D - LUT table entry */
	struct vpfe_ipipe_3d_lut_entry table[VPFE_IPIPE_MAX_SIZE_3D_LUT];
};

/* Struct for configuring rgb2ycbcr module */
struct vpfe_ipipe_rgb2yuv {
	/* Matrix coefficient for RY S12Q8 */
	struct ipipe_float_s16 coef_ry;
	/* Matrix coefficient for GY S12Q8 */
	struct ipipe_float_s16 coef_gy;
	/* Matrix coefficient for BY S12Q8 */
	struct ipipe_float_s16 coef_by;
	/* Matrix coefficient for RCb S12Q8 */
	struct ipipe_float_s16 coef_rcb;
	/* Matrix coefficient for GCb S12Q8 */
	struct ipipe_float_s16 coef_gcb;
	/* Matrix coefficient for BCb S12Q8 */
	struct ipipe_float_s16 coef_bcb;
	/* Matrix coefficient for RCr S12Q8 */
	struct ipipe_float_s16 coef_rcr;
	/* Matrix coefficient for GCr S12Q8 */
	struct ipipe_float_s16 coef_gcr;
	/* Matrix coefficient for BCr S12Q8 */
	struct ipipe_float_s16 coef_bcr;
	/* Output offset for R S11 */
	int out_ofst_y;
	/* Output offset for Cb S11 */
	int out_ofst_cb;
	/* Output offset for Cr S11 */
	int out_ofst_cr;
};

enum vpfe_ipipe_gbce_type {
	VPFE_IPIPE_GBCE_Y_VAL_TBL = 0,
	VPFE_IPIPE_GBCE_GAIN_TBL = 1,
};

#define VPFE_IPIPE_MAX_SIZE_GBCE_LUT		1024

/* structure for Global brightness and Contrast */
struct vpfe_ipipe_gbce {
	/* enable/disable GBCE */
	unsigned char en;
	/* Y - value table or Gain table */
	enum vpfe_ipipe_gbce_type type;
	/* ptr to LUT for GBCE with 1024 entries */
	unsigned short table[VPFE_IPIPE_MAX_SIZE_GBCE_LUT];
};

/* Chrominance position. Applicable only for YCbCr input
 * Applied after edge enhancement
 */
enum vpfe_chr_pos {
	/* Co-siting, same position with luminance */
	VPFE_IPIPE_YUV422_CHR_POS_COSITE = 0,
	/* Centering, In the middle of luminance */
	VPFE_IPIPE_YUV422_CHR_POS_CENTRE = 1,
};

/* Structure for configuring yuv422 conversion module */
struct vpfe_ipipe_yuv422_conv {
	/* Max Chrominance value */
	unsigned char en_chrom_lpf;
	/* 1 - enable LPF for chrminance, 0 - disable */
	enum vpfe_chr_pos chrom_pos;
};

#define VPFE_IPIPE_MAX_SIZE_YEE_LUT		1024

enum vpfe_ipipe_yee_merge_meth {
	VPFE_IPIPE_YEE_ABS_MAX = 0,
	VPFE_IPIPE_YEE_EE_ES = 1,
};

/* Structure for configuring YUV Edge Enhancement module */
struct vpfe_ipipe_yee {
	/* 1 - enable enhancement, 0 - disable */
	unsigned char en;
	/* enable/disable halo reduction in edge sharpner */
	unsigned char en_halo_red;
	/* Merge method between Edge Enhancer and Edge sharpner */
	enum vpfe_ipipe_yee_merge_meth merge_meth;
	/* HPF Shift length */
	unsigned char hpf_shft;
	/* HPF Coefficient 00, S10 */
	short hpf_coef_00;
	/* HPF Coefficient 01, S10 */
	short hpf_coef_01;
	/* HPF Coefficient 02, S10 */
	short hpf_coef_02;
	/* HPF Coefficient 10, S10 */
	short hpf_coef_10;
	/* HPF Coefficient 11, S10 */
	short hpf_coef_11;
	/* HPF Coefficient 12, S10 */
	short hpf_coef_12;
	/* HPF Coefficient 20, S10 */
	short hpf_coef_20;
	/* HPF Coefficient 21, S10 */
	short hpf_coef_21;
	/* HPF Coefficient 22, S10 */
	short hpf_coef_22;
	/* Lower threshold before referring to LUT */
	unsigned short yee_thr;
	/* Edge sharpener Gain */
	unsigned short es_gain;
	/* Edge sharpener lower threshold */
	unsigned short es_thr1;
	/* Edge sharpener upper threshold */
	unsigned short es_thr2;
	/* Edge sharpener gain on gradient */
	unsigned short es_gain_grad;
	/* Edge sharpener offset on gradient */
	unsigned short es_ofst_grad;
	/* Ptr to EE table. Must have 1024 entries */
	short table[VPFE_IPIPE_MAX_SIZE_YEE_LUT];
};

enum vpfe_ipipe_car_meth {
	/* Chromatic Gain Control */
	VPFE_IPIPE_CAR_CHR_GAIN_CTRL = 0,
	/* Dynamic switching between CHR_GAIN_CTRL
	 * and MED_FLTR
	 */
	VPFE_IPIPE_CAR_DYN_SWITCH = 1,
	/* Median Filter */
	VPFE_IPIPE_CAR_MED_FLTR = 2,
};

enum vpfe_ipipe_car_hpf_type {
	VPFE_IPIPE_CAR_HPF_Y = 0,
	VPFE_IPIPE_CAR_HPF_H = 1,
	VPFE_IPIPE_CAR_HPF_V = 2,
	VPFE_IPIPE_CAR_HPF_2D = 3,
	/* 2D HPF from YUV Edge Enhancement */
	VPFE_IPIPE_CAR_HPF_2D_YEE = 4,
};

struct vpfe_ipipe_car_gain {
	/* csup_gain */
	unsigned char gain;
	/* csup_shf. */
	unsigned char shft;
	/* gain minimum */
	unsigned short gain_min;
};

/* Structure for Chromatic Artifact Reduction */
struct vpfe_ipipe_car {
	/* enable/disable */
	unsigned char en;
	/* Gain control or Dynamic switching */
	enum vpfe_ipipe_car_meth meth;
	/* Gain1 function configuration for Gain control */
	struct vpfe_ipipe_car_gain gain1;
	/* Gain2 function configuration for Gain control */
	struct vpfe_ipipe_car_gain gain2;
	/* HPF type used for CAR */
	enum vpfe_ipipe_car_hpf_type hpf;
	/* csup_thr: HPF threshold for Gain control */
	unsigned char hpf_thr;
	/* Down shift value for hpf. 2 bits */
	unsigned char hpf_shft;
	/* switch limit for median filter */
	unsigned char sw0;
	/* switch coefficient for Gain control */
	unsigned char sw1;
};

/* structure for Chromatic Gain Suppression */
struct vpfe_ipipe_cgs {
	/* enable/disable */
	unsigned char en;
	/* gain1 bright side threshold */
	unsigned char h_thr;
	/* gain1 bright side slope */
	unsigned char h_slope;
	/* gain1 down shift value for bright side */
	unsigned char h_shft;
	/* gain1 bright side minimum gain */
	unsigned char h_min;
};

/* Max pixels allowed in the input. If above this either decimation
 * or frame division mode to be enabled
 */
#define VPFE_IPIPE_MAX_INPUT_WIDTH	2600

struct vpfe_ipipe_input_config {
	unsigned int vst;
	unsigned int hst;
};

/**
 * struct vpfe_ipipe_config - IPIPE engine configuration (user)
 * @input_config: Pointer to structure for ipipe configuration.
 * @flag: Specifies which ISP IPIPE functions should be enabled.
 * @lutdpc: Pointer to luma enhancement structure.
 * @otfdpc: Pointer to structure for defect correction.
 * @nf1: Pointer to structure for Noise Filter.
 * @nf2: Pointer to structure for Noise Filter.
 * @gic: Pointer to structure for Green Imbalance.
 * @wbal: Pointer to structure for White Balance.
 * @cfa: Pointer to structure containing the CFA interpolation.
 * @rgb2rgb1: Pointer to structure for RGB to RGB Blending.
 * @rgb2rgb2: Pointer to structure for RGB to RGB Blending.
 * @gamma: Pointer to gamma structure.
 * @lut: Pointer to structure for 3D LUT.
 * @rgb2yuv: Pointer to structure for RGB-YCbCr conversion.
 * @gbce: Pointer to structure for Global Brightness,Contrast Control.
 * @yuv422_conv: Pointer to structure for YUV 422 conversion.
 * @yee: Pointer to structure for Edge Enhancer.
 * @car: Pointer to structure for Chromatic Artifact Reduction.
 * @cgs: Pointer to structure for Chromatic Gain Suppression.
 */
struct vpfe_ipipe_config {
	__u32 flag;
	struct vpfe_ipipe_input_config __user *input_config;
	struct vpfe_ipipe_lutdpc __user *lutdpc;
	struct vpfe_ipipe_otfdpc __user *otfdpc;
	struct vpfe_ipipe_nf __user *nf1;
	struct vpfe_ipipe_nf __user *nf2;
	struct vpfe_ipipe_gic __user *gic;
	struct vpfe_ipipe_wb __user *wbal;
	struct vpfe_ipipe_cfa __user *cfa;
	struct vpfe_ipipe_rgb2rgb __user *rgb2rgb1;
	struct vpfe_ipipe_rgb2rgb __user *rgb2rgb2;
	struct vpfe_ipipe_gamma __user *gamma;
	struct vpfe_ipipe_3d_lut __user *lut;
	struct vpfe_ipipe_rgb2yuv __user *rgb2yuv;
	struct vpfe_ipipe_gbce __user *gbce;
	struct vpfe_ipipe_yuv422_conv __user *yuv422_conv;
	struct vpfe_ipipe_yee __user *yee;
	struct vpfe_ipipe_car __user *car;
	struct vpfe_ipipe_cgs __user *cgs;
};

/*******************************************************************
 **  Resizer API structures
 *******************************************************************/
/* Interpolation types used for horizontal rescale */
enum vpfe_rsz_intp_t {
	VPFE_RSZ_INTP_CUBIC,
	VPFE_RSZ_INTP_LINEAR
};

/* Horizontal LPF intensity selection */
enum vpfe_rsz_h_lpf_lse_t {
	VPFE_RSZ_H_LPF_LSE_INTERN,
	VPFE_RSZ_H_LPF_LSE_USER_VAL
};

enum vpfe_rsz_down_scale_ave_sz {
	VPFE_IPIPE_DWN_SCALE_1_OVER_2,
	VPFE_IPIPE_DWN_SCALE_1_OVER_4,
	VPFE_IPIPE_DWN_SCALE_1_OVER_8,
	VPFE_IPIPE_DWN_SCALE_1_OVER_16,
	VPFE_IPIPE_DWN_SCALE_1_OVER_32,
	VPFE_IPIPE_DWN_SCALE_1_OVER_64,
	VPFE_IPIPE_DWN_SCALE_1_OVER_128,
	VPFE_IPIPE_DWN_SCALE_1_OVER_256
};

struct vpfe_rsz_output_spec {
	/* enable horizontal flip */
	unsigned char h_flip;
	/* enable vertical flip */
	unsigned char v_flip;
	/* line start offset for y. */
	unsigned int vst_y;
	/* line start offset for c. Only for 420 */
	unsigned int vst_c;
	/* vertical rescale interpolation type, YCbCr or Luminance */
	enum vpfe_rsz_intp_t v_typ_y;
	/* vertical rescale interpolation type for Chrominance */
	enum vpfe_rsz_intp_t v_typ_c;
	/* vertical lpf intensity - Luminance */
	unsigned char v_lpf_int_y;
	/* vertical lpf intensity - Chrominance */
	unsigned char v_lpf_int_c;
	/* horizontal rescale interpolation types, YCbCr or Luminance  */
	enum vpfe_rsz_intp_t h_typ_y;
	/* horizontal rescale interpolation types, Chrominance */
	enum vpfe_rsz_intp_t h_typ_c;
	/* horizontal lpf intensity - Luminance */
	unsigned char h_lpf_int_y;
	/* horizontal lpf intensity - Chrominance */
	unsigned char h_lpf_int_c;
	/* Use down scale mode for scale down */
	unsigned char en_down_scale;
	/* if downscale, set the downscale more average size for horizontal
	 * direction. Used only if output width and height is less than
	 * input sizes
	 */
	enum vpfe_rsz_down_scale_ave_sz h_dscale_ave_sz;
	/* if downscale, set the downscale more average size for vertical
	 * direction. Used only if output width and height is less than
	 * input sizes
	 */
	enum vpfe_rsz_down_scale_ave_sz v_dscale_ave_sz;
	/* Y offset. If set, the offset would be added to the base address
	 */
	unsigned int user_y_ofst;
	/* C offset. If set, the offset would be added to the base address
	 */
	unsigned int user_c_ofst;
};

struct vpfe_rsz_config_params {
	unsigned int vst;
	/* horizontal start position of the image
	 * data to IPIPE
	 */
	unsigned int hst;
	/* output spec of the image data coming out of resizer - 0(UYVY).
	 */
	struct vpfe_rsz_output_spec output1;
	/* output spec of the image data coming out of resizer - 1(UYVY).
	 */
	struct vpfe_rsz_output_spec output2;
	/* 0 , chroma sample at odd pixel, 1 - even pixel */
	unsigned char chroma_sample_even;
	unsigned char frame_div_mode_en;
	unsigned char yuv_y_min;
	unsigned char yuv_y_max;
	unsigned char yuv_c_min;
	unsigned char yuv_c_max;
	enum vpfe_chr_pos out_chr_pos;
	unsigned char bypass;
};

/* Structure for VIDIOC_VPFE_RSZ_[S/G]_CONFIG IOCTLs */
struct vpfe_rsz_config {
	struct vpfe_rsz_config_params *config;
};

#endif		/* _DAVINCI_VPFE_USER_H */
OpenPOWER on IntegriCloud