Commit 5fc27c61 authored by steven.zhang's avatar steven.zhang Committed by Terry.Qiu

ARM: Davinci: video previewer driver supported by Ti

Signed-off-by: default avatarTerry.Qiu <tqiu@neuros.com.cn>
parent b35e1e4c
......@@ -1076,5 +1076,11 @@ config DEVPORT
source "drivers/s390/char/Kconfig"
config PREVIEWER
tristate "DaVinci Previewer Driver Support"
default n
help
DaVinci Previewer Driver
endmenu
......@@ -115,6 +115,9 @@ obj-$(CONFIG_PS3_FLASH) += ps3flash.o
obj-$(CONFIG_JS_RTC) += js-rtc.o
js-rtc-y = rtc.o
davinci_previewer_driver-objs := davinci_previewer_hw.o davinci_previewer.o
obj-$(CONFIG_PREVIEWER) += davinci_previewer_driver.o
# Files generated that shall be removed upon make clean
clean-files := consolemap_deftbl.c defkeymap.c
......
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2006 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; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*/
/* davinci_previewer.h file */
#ifndef DAVINCI_PREVIEWER_H
#define DAVINCI_PREVIEWER_H
#ifdef DEBUG
#undef DEBUG
#endif
/*#define DEBUG*/
#include <linux/ioctl.h>
#ifdef __KERNEL__
/* include linux specific header files */
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <asm/semaphore.h>
#endif /* End of #ifdef __KERNEL__ */
/* Feature lists */
#define PREV_INPUT_FORMATTER 0x1
#define PREV_INVERSE_ALAW 0x2
#define PREV_HORZ_MEDIAN_FILTER 0x4
#define PREV_NOISE_FILTER 0x8
#define PREV_CFA 0x10
#define PREV_GAMMA 0x20
#define PREV_LUMA_ENHANCE 0x40
#define PREV_CHROMA_SUPPRESS 0x80
#define PREV_DARK_FRAME_SUBTRACT 0x100
#define PREV_LENS_SHADING 0x200
#define PREV_DARK_FRAME_CAPTURE 0x400
/* -- */
#define DOWN_SAMPLE_RATE1 1 /* Down sampling rate 1 */
#define DOWN_SAMPLE_RATE2 2 /* Down sampling rate 2 */
#define DOWN_SAMPLE_RATE3 4 /* Down sampling rate 4 */
#define DOWN_SAMPLE_RATE4 8 /* Down sampling rate 8 */
#define LUMA_TABLE_SIZE 128
#define GAMMA_TABLE_SIZE 1024
#define CFA_COEFF_TABLE_SIZE 576
#define NOISE_FILTER_TABLE_SIZE 256
#define WB_GAIN_MAX 4
#define RGB_MAX 3
#define MAX_BUFFER 8
#define MAX_IMAGE_WIDTH 1280
#define MAX_IMAGE_HEIGHT 1920
#define PREV_BUF_IN 0 /* input buffer */
#define PREV_BUF_OUT 1 /* output buffer */
#define PREV_INWIDTH_8BIT 0 /* pixel width of 8 bitS */
#define PREV_INWIDTH_10BIT 1 /* pixel width of 10 bits */
/* list of structures */
/* structure for request buffer */
struct prev_reqbufs {
int buf_type; /* type of frame buffer */
int size; /* size of the frame buffer to be allocated */
int count; /* number of frame buffer to be allocated */
};
/* structure buffer */
struct prev_buffer {
int index; /* index number, 0 -> N-1 */
int buf_type; /* buffer type, input or output */
int offset; /* address of the buffer used in the mmap()
system call */
int size; /* size of the buffer */
};
/* structure for size parameters */
struct prev_size_params {
unsigned int hstart; /* Starting pixel */
unsigned int vstart; /* Starting line */
unsigned int hsize; /* width of input image */
unsigned int vsize; /* height of input image */
unsigned char pixsize; /* pixel size of the image in
terms of bits */
unsigned short in_pitch; /* line offset of input image */
unsigned short out_pitch; /* line offset of output image */
};
/* structure for white balancing parameters */
struct prev_white_balance {
unsigned short wb_dgain; /* white
balance common
gain */
unsigned char wb_gain[WB_GAIN_MAX]; /* individual
color gains */
unsigned char wb_coefmatrix[WB_GAIN_MAX][WB_GAIN_MAX]; /* 16 position
out of 4
values */
};
/*structure for black adjustment for parameters */
struct prev_black_adjst { /* black adjustments for three colors */
char redblkadj; /* black adjustment offset for red color */
char greenblkadj; /* black adjustment offset for green color */
char blueblkadj; /* black adjustment offset for blue color */
};
/*structure for RGB2RGB blending parameters */
struct prev_rgbblending {
short blending[RGB_MAX][RGB_MAX]; /* color correlation 3x3 matrix */
short offset[RGB_MAX]; /* color correlation offsets */
};
/* structure RGB2YCbCr parameters */
struct prev_rgb2ycbcr_coeffs {
short coeff[RGB_MAX][RGB_MAX]; /* color conversion gains in
3x3 matrix */
short offset[RGB_MAX]; /* color conversion offsets */
};
/*structure for CFA coefficients */
struct prev_cfa_coeffs {
char hthreshold, vthreshold; /* horizontal an vertical
threshold */
int coeffs[CFA_COEFF_TABLE_SIZE]; /* cfa coefficients */
};
/* structure for Gamma Coefficients */
struct prev_gamma_coeffs {
unsigned char red[GAMMA_TABLE_SIZE]; /* table of gamma correction
values for red color */
unsigned char green[GAMMA_TABLE_SIZE]; /* table of gamma correction
values for green color */
unsigned char blue[GAMMA_TABLE_SIZE]; /* table of gamma correction
values for blue color */
};
/* structure for Nois Filter Coefficients */
struct prev_noiseflt_coeffs {
unsigned char noise[NOISE_FILTER_TABLE_SIZE]; /* noise filter
table */
unsigned char strength; /* to find out
weighted average */
};
/*structure for Chroma Suppression */
struct prev_chroma_spr {
unsigned char hpfy; /* whether to use high passed
version of Y or normal Y */
char threshold; /* threshold for chroma suppress */
unsigned char gain; /* chroma suppression gain */
};
/* enum data type for output pixel order */
enum prev_pixorder {
PREV_PIXORDER_CBYCRY = 0, /* LSB Cb0 Y0 Cr0 Y1 MSB */
PREV_PIXORDER_CRYCBY, /* LSB Cr0 Y0 Cb0 Y1 MSB */
PREV_PIXORDER_YCRYCB, /* LSB Y0 Cb0 Y1 Cr0 MSB */
PREV_PIXORDER_YCBYCR, /* LSB Y0 Cr0 Y1 Cb0 MSB */
};
/* -- */
/* structure for all configuration */
struct prev_params {
unsigned short features; /* Set of features
enabled */
struct prev_size_params size_params; /* size parameters */
struct prev_white_balance white_balance_params; /* white balancing
parameters */
struct prev_black_adjst black_adjst_params; /* black adjustment
parameters */
struct prev_rgbblending rgbblending_params; /* rgb blending
parameters */
struct prev_rgb2ycbcr_coeffs rgb2ycbcr_params; /* rgb to ycbcr
parameters */
unsigned char sample_rate; /* down sampling
rate for averager */
short hmf_threshold; /* horizontal median
filter threshold */
struct prev_cfa_coeffs cfa_coeffs; /* CFA coefficients */
struct prev_gamma_coeffs gamma_coeffs; /* gamma
coefficients */
struct prev_noiseflt_coeffs nf_coeffs; /* noise filter
coefficients */
unsigned int luma_enhance[LUMA_TABLE_SIZE]; /* luma enhancement
coeffs */
struct prev_chroma_spr chroma_suppress_params; /* chroma suppression
coefficients */
void *dark_frame_addr; /* dark frame
address */
unsigned short dark_frame_pitch; /* dark frame
lineoffset */
unsigned char lens_shading_sift; /* number of bits
to be shifted
for lens shading */
enum prev_pixorder pix_fmt; /* output pixel
format */
int contrast; /* contrast */
int brightness; /* brightness */
};
/* structure for input/output buffer, used while previewing */
struct prev_convert {
struct prev_buffer in_buff;
struct prev_buffer out_buff;
};
/* structure to know status of the hardware */
struct prev_status {
char hw_busy;
};
/* structure to knwo crop size */
struct prev_cropsize {
int hcrop;
int vcrop;
};
#ifdef __KERNEL__
/* device structure keeps track of global information */
struct prev_device {
struct prev_params *params;
unsigned char opened; /* state of the device */
unsigned char in_numbuffers; /* number of input
buffers */
unsigned char out_numbuffers; /* number of output
buffers */
struct prev_buffer *in_buff[MAX_BUFFER]; /* pointer to input
buffers */
struct prev_buffer *out_buff[MAX_BUFFER]; /*pointer to output
buffers */
struct completion wfc; /* used to wait for frame
precessing to be
completed */
struct semaphore sem;
};
void calculate_slices(struct prev_params *, int *hslice, int *vslice);
void prev_calculate_crop(struct prev_params *, struct prev_cropsize *crop);
int preview(struct prev_device *, struct prev_convert *arg);
int get_status(struct prev_status *);
int request_buffer(struct prev_device *, struct prev_reqbufs *);
int query_buffer(struct prev_device *, struct prev_buffer *);
irqreturn_t previewer_isr(int, void *, struct pt_regs *);
int free_buffers(struct prev_device *);
int validate_params(struct prev_params *);
#endif /* End of #ifdef __KERNEL__ */
/* ioctls definition */
#define PREV_IOC_BASE 'P'
#define PREV_REQBUF _IOW(PREV_IOC_BASE, 1, struct prev_reqbufs)
#define PREV_QUERYBUF _IOR(PREV_IOC_BASE, 2, struct prev_buffer)
#define PREV_SET_PARAM _IOW(PREV_IOC_BASE, 3, struct prev_params)
#define PREV_GET_PARAM _IOR(PREV_IOC_BASE, 4, struct prev_params)
#define PREV_PREVIEW _IOWR(PREV_IOC_BASE,5, struct prev_convert)
#define PREV_GET_STATUS _IOR(PREV_IOC_BASE, 6, char)
#define PREV_GET_CROPSIZE _IOR(PREV_IOC_BASE, 7, struct prev_cropsize)
#define PREV_SET_EXP _IOWR(PREV_IOC_BASE,8,int*)
#define PREV_IOC_MAXNR 8
/* End of ioctls */
#ifdef __KERNEL__
struct vm_struct_area;
struct inode;
struct file;
/* function definition for character driver interface functions */
int previewer_init(void);
void previewer_cleanup(void);
int previewer_open(struct inode *inode, struct file *);
int previewer_release(struct inode *inode, struct file *);
int previewer_ioctl(struct inode *inode, struct file *, unsigned int,
unsigned long);
int previewer_mmap(struct file *, struct vm_area_struct *);
#endif /* End of #ifdef __KERNEL__ */
#endif /* End of DAVINCI_PREVIEWER_H */
/*
* Copyright (C) 2006 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; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*/
/* davinci_previewer_hw.h file */
#ifndef DAVINCI_PREVIEWER_HW_H
#define DAVINCI_PREVIEWER_HW_H
#ifdef __KERNEL__
#include <linux/kernel.h> /* printk() */
#include <asm/io.h> /* For IO_ADDRESS */
#define PREVIEWER_IOBASE_VADDR IO_ADDRESS(0x01C70800)
/* Register Offsets from the base address */
#define PID 0x0000
#define PCR 0x0004
#define HORZ_INFO 0x0008
#define VERT_INFO 0x000C
#define RSDR_ADDR 0x0010
#define RADR_OFFSET 0x0014
#define DSDR_ADDR 0x0018
#define DRKF_OFFSET 0x001C
#define WSDR_ADDR 0x0020
#define WADD_OFFSET 0x0024
#define AVE 0x0028
#define HMED 0x002C
#define NF 0x0030
#define WB_DGAIN 0x0034
#define WBGAIN 0x0038
#define WBSEL 0x003C
#define CFA 0x0040
#define BLKADJOFF 0x0044
#define RGB_MAT1 0x0048
#define RGB_MAT2 0x004C
#define RGB_MAT3 0x0050
#define RGB_MAT4 0x0054
#define RGB_MAT5 0x0058
#define RGB_OFF1 0x005C
#define RGB_OFF2 0x0060
#define CSC0 0x0064
#define CSC1 0x0068
#define CSC2 0x006C
#define CSC_OFFSET 0x0070
#define CNT_BRT 0x0074
#define CSUP 0x0078
#define SETUP_YC 0x007C
#define SET_TBL_ADDR 0x0080
#define SET_TBL_DATA 0x0084
/* End of register offsets */
#define VPSS_PCR (0x3404-0x0800)
#define SDR_REQ_EXP (0x3508-0x0800)
/* Register read/write */
#define regw(val, reg) outl(val, (reg)+PREVIEWER_IOBASE_VADDR)
#define regr(reg) inl((reg)+PREVIEWER_IOBASE_VADDR)
/* -- */
/* macro for bit set and clear */
#define SETBIT(reg, bit) (reg = ((reg) | ((0x00000001)<<(bit))))
#define RESETBIT(reg, bit) (reg = ((reg) & (~(0x00000001<<(bit)))))
/* -- */
/* bit positions of the configurations in PCR register */
#define PREV_ENABLE_BIT 0
#define PREV_SOURCE_BIT 2
#define PREV_ONESHOT_BIT 3
#define PREV_WIDTH_BIT 4
#define INVALAW_BIT 5
#define DARK_FRAME_WRITE_BIT 6
#define DARK_FRAME_CAPTURE_BIT 7
#define HMF_BIT 8
#define NOISE_FILTER_BIT 9
#define CFA_BIT 10
#define LUMA_ENHANCE_BIT 15
#define CHROMA_SUPPRESS_BIT 16
#define RSZPORT_BIT 19
#define DDRAMPORT_BIT 20
#define SHADECOMP_BIT 21
#define GAMMA_BYPASS_BIT 26
#define PIXEL_ORDER_BIT 17
/* -- */
/* Internal RAM table addresses for NF */
#define NOISE_FILTER_START_ADDR 0x0C00
#define NOISE_FILTER_END_ADDR 0x0CFF
/* Internal RAM table addresses for gamma correction */
#define RED_GAMMA_START_ADDR 0x0000
#define RED_GAMMA_END_ADDR 0x03FF
#define GREEN_GAMMA_START_ADDR 0x0400
#define GREEN_GAMMA_END_ADDR 0x07FF
#define BLUE_GAMMA_START_ADDR 0x0800
#define BLUE_GAMMA_END_ADDR 0x0BFF
/* -- */
/* Internal RAM table addresses for Luma enhancement */
#define LUMA_ENHANCE_START_ADDR 0x1000
#define LUMA_ENHANCE_END_ADDR 0x107F
/* -- */
/* Internal RAM table addresses for CFA Coefficients */
#define CFA_COEFF_START_ADDR 0x1400
#define CFA_COEFF_END_ADDR 0x163F
/* -- */
/* bit position of whether to use high passed version of Y or not */
#define CHROMA_HPFY 16
#define AVE_ODD_PIXEL_DIST 16 /* (1 << 4)distance between two consecutive
pixels of same color is 2 in bayer pattern
in odd lines. to be set in 2 and 3 bits
of AVE */
#define AVE_EVEN_PIXEL_DIST 4 /*(1 << 2)distance between two consecutive
pixels of same color is 2 in bayer pattern
in even lines to be set in 4 and 5
bits of AVE */
/* inline function to enable previewer */
static inline void previewer_enable(void)
{
int pcr = regr(PCR);
regw((pcr | 0x01), PCR);
}
/* inline function to set previewer in one shot mode */
static inline void set_oneshot_mode(void)
{
int pcr = regr(PCR);
regw((pcr | (0x01 << 3)), PCR);
}
/* inline function to set previewer input source to DDRAM */
static inline void set_input_source(int i)
{
int pcr = regr(PCR);
regw((pcr | (i << 2)), PCR);
}
/* inline function to set read line offset */
static inline void set_rsdr_offset(int offset)
{
regw(offset, RADR_OFFSET);
}
/* inline function to set write line offset */
static inline void set_wsdr_offset(int offset)
{
regw(offset, WADD_OFFSET);
}
/* inline function to set the size of the input image in register */
static inline void set_size(int hstart, int vstart, int width, int height)
{
int horz_info = (width - 1 + hstart) & 0x3fff;
int vert_info = (height - 1 + vstart) & 0x3fff;
horz_info |= ((hstart & 0x3fff) << 16);
vert_info |= ((vstart & 0x3fff) << 16);
regw(horz_info, HORZ_INFO);
regw(vert_info, VERT_INFO);
}
/* inline function to set input/output addresses in registers */
static inline void set_address(unsigned long input, unsigned long output)
{
regw(input, RSDR_ADDR);
regw(output, WSDR_ADDR);
}
#define isbusy() ((regr(PCR) & 0x02)>>1)
static inline void prev_set_exp(int exp)
{
regw(((exp & 0x3ff) << 20), SDR_REQ_EXP);
}
static inline int prev_writebuffer_status(void)
{
return regr(VPSS_PCR);
}
/* Forward declaration */
struct prev_params;
extern int previewer_hw_setup(struct prev_params *);
#endif /* End of #ifdef __KERNEL__ */
#endif /* End of #ifdef DAVINCI_PREVIEWER_HW_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment