Path: blob/master/include/media/davinci/dm355_ccdc.h
10818 views
/*1* Copyright (C) 2005-2009 Texas Instruments Inc2*3* This program is free software; you can redistribute it and/or modify4* it under the terms of the GNU General Public License as published by5* the Free Software Foundation; either version 2 of the License, or6* (at your option) any later version.7*8* This program is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License14* along with this program; if not, write to the Free Software15* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA16*/17#ifndef _DM355_CCDC_H18#define _DM355_CCDC_H19#include <media/davinci/ccdc_types.h>20#include <media/davinci/vpfe_types.h>2122/* enum for No of pixel per line to be avg. in Black Clamping */23enum ccdc_sample_length {24CCDC_SAMPLE_1PIXELS,25CCDC_SAMPLE_2PIXELS,26CCDC_SAMPLE_4PIXELS,27CCDC_SAMPLE_8PIXELS,28CCDC_SAMPLE_16PIXELS29};3031/* enum for No of lines in Black Clamping */32enum ccdc_sample_line {33CCDC_SAMPLE_1LINES,34CCDC_SAMPLE_2LINES,35CCDC_SAMPLE_4LINES,36CCDC_SAMPLE_8LINES,37CCDC_SAMPLE_16LINES38};3940/* enum for Alaw gama width */41enum ccdc_gamma_width {42CCDC_GAMMA_BITS_13_4,43CCDC_GAMMA_BITS_12_3,44CCDC_GAMMA_BITS_11_2,45CCDC_GAMMA_BITS_10_1,46CCDC_GAMMA_BITS_09_047};4849enum ccdc_colpats {50CCDC_RED,51CCDC_GREEN_RED,52CCDC_GREEN_BLUE,53CCDC_BLUE54};5556struct ccdc_col_pat {57enum ccdc_colpats olop;58enum ccdc_colpats olep;59enum ccdc_colpats elop;60enum ccdc_colpats elep;61};6263enum ccdc_datasft {64CCDC_DATA_NO_SHIFT,65CCDC_DATA_SHIFT_1BIT,66CCDC_DATA_SHIFT_2BIT,67CCDC_DATA_SHIFT_3BIT,68CCDC_DATA_SHIFT_4BIT,69CCDC_DATA_SHIFT_5BIT,70CCDC_DATA_SHIFT_6BIT71};7273enum ccdc_data_size {74CCDC_DATA_16BITS,75CCDC_DATA_15BITS,76CCDC_DATA_14BITS,77CCDC_DATA_13BITS,78CCDC_DATA_12BITS,79CCDC_DATA_11BITS,80CCDC_DATA_10BITS,81CCDC_DATA_8BITS82};83enum ccdc_mfilt1 {84CCDC_NO_MEDIAN_FILTER1,85CCDC_AVERAGE_FILTER1,86CCDC_MEDIAN_FILTER187};8889enum ccdc_mfilt2 {90CCDC_NO_MEDIAN_FILTER2,91CCDC_AVERAGE_FILTER2,92CCDC_MEDIAN_FILTER293};9495/* structure for ALaw */96struct ccdc_a_law {97/* Enable/disable A-Law */98unsigned char enable;99/* Gama Width Input */100enum ccdc_gamma_width gama_wd;101};102103/* structure for Black Clamping */104struct ccdc_black_clamp {105/* only if bClampEnable is TRUE */106unsigned char b_clamp_enable;107/* only if bClampEnable is TRUE */108enum ccdc_sample_length sample_pixel;109/* only if bClampEnable is TRUE */110enum ccdc_sample_line sample_ln;111/* only if bClampEnable is TRUE */112unsigned short start_pixel;113/* only if bClampEnable is FALSE */114unsigned short sgain;115unsigned short dc_sub;116};117118/* structure for Black Level Compensation */119struct ccdc_black_compensation {120/* Constant value to subtract from Red component */121unsigned char r;122/* Constant value to subtract from Gr component */123unsigned char gr;124/* Constant value to subtract from Blue component */125unsigned char b;126/* Constant value to subtract from Gb component */127unsigned char gb;128};129130struct ccdc_float {131int integer;132unsigned int decimal;133};134135#define CCDC_CSC_COEFF_TABLE_SIZE 16136/* structure for color space converter */137struct ccdc_csc {138unsigned char enable;139/*140* S8Q5. Use 2 decimal precision, user values range from -3.00 to 3.99.141* example - to use 1.03, set integer part as 1, and decimal part as 3142* to use -1.03, set integer part as -1 and decimal part as 3143*/144struct ccdc_float coeff[CCDC_CSC_COEFF_TABLE_SIZE];145};146147/* Structures for Vertical Defect Correction*/148enum ccdc_vdf_csl {149CCDC_VDF_NORMAL,150CCDC_VDF_HORZ_INTERPOL_SAT,151CCDC_VDF_HORZ_INTERPOL152};153154enum ccdc_vdf_cuda {155CCDC_VDF_WHOLE_LINE_CORRECT,156CCDC_VDF_UPPER_DISABLE157};158159enum ccdc_dfc_mwr {160CCDC_DFC_MWR_WRITE_COMPLETE,161CCDC_DFC_WRITE_REG162};163164enum ccdc_dfc_mrd {165CCDC_DFC_READ_COMPLETE,166CCDC_DFC_READ_REG167};168169enum ccdc_dfc_ma_rst {170CCDC_DFC_INCR_ADDR,171CCDC_DFC_CLR_ADDR172};173174enum ccdc_dfc_mclr {175CCDC_DFC_CLEAR_COMPLETE,176CCDC_DFC_CLEAR177};178179struct ccdc_dft_corr_ctl {180enum ccdc_vdf_csl vdfcsl;181enum ccdc_vdf_cuda vdfcuda;182unsigned int vdflsft;183};184185struct ccdc_dft_corr_mem_ctl {186enum ccdc_dfc_mwr dfcmwr;187enum ccdc_dfc_mrd dfcmrd;188enum ccdc_dfc_ma_rst dfcmarst;189enum ccdc_dfc_mclr dfcmclr;190};191192#define CCDC_DFT_TABLE_SIZE 16193/*194* Main Structure for vertical defect correction. Vertical defect195* correction can correct up to 16 defects if defects less than 16196* then pad the rest with 0197*/198struct ccdc_vertical_dft {199unsigned char ver_dft_en;200unsigned char gen_dft_en;201unsigned int saturation_ctl;202struct ccdc_dft_corr_ctl dft_corr_ctl;203struct ccdc_dft_corr_mem_ctl dft_corr_mem_ctl;204int table_size;205unsigned int dft_corr_horz[CCDC_DFT_TABLE_SIZE];206unsigned int dft_corr_vert[CCDC_DFT_TABLE_SIZE];207unsigned int dft_corr_sub1[CCDC_DFT_TABLE_SIZE];208unsigned int dft_corr_sub2[CCDC_DFT_TABLE_SIZE];209unsigned int dft_corr_sub3[CCDC_DFT_TABLE_SIZE];210};211212struct ccdc_data_offset {213unsigned char horz_offset;214unsigned char vert_offset;215};216217/*218* Structure for CCDC configuration parameters for raw capture mode passed219* by application220*/221struct ccdc_config_params_raw {222/* data shift to be applied before storing */223enum ccdc_datasft datasft;224/* data size value from 8 to 16 bits */225enum ccdc_data_size data_sz;226/* median filter for sdram */227enum ccdc_mfilt1 mfilt1;228enum ccdc_mfilt2 mfilt2;229/* low pass filter enable/disable */230unsigned char lpf_enable;231/* Threshold of median filter */232int med_filt_thres;233/*234* horz and vertical data offset. Appliable for defect correction235* and lsc236*/237struct ccdc_data_offset data_offset;238/* Structure for Optional A-Law */239struct ccdc_a_law alaw;240/* Structure for Optical Black Clamp */241struct ccdc_black_clamp blk_clamp;242/* Structure for Black Compensation */243struct ccdc_black_compensation blk_comp;244/* struture for vertical Defect Correction Module Configuration */245struct ccdc_vertical_dft vertical_dft;246/* structure for color space converter Module Configuration */247struct ccdc_csc csc;248/* color patters for bayer capture */249struct ccdc_col_pat col_pat_field0;250struct ccdc_col_pat col_pat_field1;251};252253#ifdef __KERNEL__254#include <linux/io.h>255256#define CCDC_WIN_PAL {0, 0, 720, 576}257#define CCDC_WIN_VGA {0, 0, 640, 480}258259struct ccdc_params_ycbcr {260/* pixel format */261enum ccdc_pixfmt pix_fmt;262/* progressive or interlaced frame */263enum ccdc_frmfmt frm_fmt;264/* video window */265struct v4l2_rect win;266/* field id polarity */267enum vpfe_pin_pol fid_pol;268/* vertical sync polarity */269enum vpfe_pin_pol vd_pol;270/* horizontal sync polarity */271enum vpfe_pin_pol hd_pol;272/* enable BT.656 embedded sync mode */273int bt656_enable;274/* cb:y:cr:y or y:cb:y:cr in memory */275enum ccdc_pixorder pix_order;276/* interleaved or separated fields */277enum ccdc_buftype buf_type;278};279280/* Gain applied to Raw Bayer data */281struct ccdc_gain {282unsigned short r_ye;283unsigned short gr_cy;284unsigned short gb_g;285unsigned short b_mg;286};287288/* Structure for CCDC configuration parameters for raw capture mode */289struct ccdc_params_raw {290/* pixel format */291enum ccdc_pixfmt pix_fmt;292/* progressive or interlaced frame */293enum ccdc_frmfmt frm_fmt;294/* video window */295struct v4l2_rect win;296/* field id polarity */297enum vpfe_pin_pol fid_pol;298/* vertical sync polarity */299enum vpfe_pin_pol vd_pol;300/* horizontal sync polarity */301enum vpfe_pin_pol hd_pol;302/* interleaved or separated fields */303enum ccdc_buftype buf_type;304/* Gain values */305struct ccdc_gain gain;306/* offset */307unsigned int ccdc_offset;308/* horizontal flip enable */309unsigned char horz_flip_enable;310/*311* enable to store the image in inverse order in memory312* (bottom to top)313*/314unsigned char image_invert_enable;315/* Configurable part of raw data */316struct ccdc_config_params_raw config_params;317};318319#endif320#endif /* DM355_CCDC_H */321322323