diff options
author | Robby Cai <R63905@freescale.com> | 2013-08-07 13:59:14 +0800 |
---|---|---|
committer | guoyin.chen <guoyin.chen@freescale.com> | 2013-08-13 19:10:48 +0800 |
commit | e4acceb9671d90e973de29ea4d6e330bc97c76ec (patch) | |
tree | db231ccf10852c6ac203100e918ea53f0da5e740 /drivers/media/video | |
parent | 8db7aa887c632e151eba5ef8a22a7d7e266f8388 (diff) |
ENGR00275011 Make V4L2_PIX_FMT_YUYV visiable as CSI output format
V4L2_PIX_FMT_YUYV is the original format from camera and the source format
for CSI. This format may be needed on Android to do CSC before encoding.
We can now choose V4L2_PIX_FMT_YUYV or V4L2_PIX_FMT_UYVY for the CSI
output format.
Signed-off-by: Robby Cai <R63905@freescale.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/mxc/capture/csi_v4l2_capture.c | 10 | ||||
-rw-r--r-- | drivers/media/video/mxc/capture/fsl_csi.c | 18 | ||||
-rw-r--r-- | drivers/media/video/mxc/capture/fsl_csi.h | 3 |
3 files changed, 30 insertions, 1 deletions
diff --git a/drivers/media/video/mxc/capture/csi_v4l2_capture.c b/drivers/media/video/mxc/capture/csi_v4l2_capture.c index f2620d85bcc3..d1273f1e63f5 100644 --- a/drivers/media/video/mxc/capture/csi_v4l2_capture.c +++ b/drivers/media/video/mxc/capture/csi_v4l2_capture.c @@ -554,6 +554,7 @@ static int csi_v4l2_prepare_bufs(cam_data *cam, struct v4l2_buffer *buf) static inline int valid_mode(u32 palette) { return (palette == V4L2_PIX_FMT_RGB565) || + (palette == V4L2_PIX_FMT_YUYV) || (palette == V4L2_PIX_FMT_UYVY) || (palette == V4L2_PIX_FMT_YUV420); } @@ -825,12 +826,21 @@ static int csi_v4l2_s_fmt(cam_data *cam, struct v4l2_format *f) switch (f->fmt.pix.pixelformat) { case V4L2_PIX_FMT_RGB565: size = f->fmt.pix.width * f->fmt.pix.height * 2; + csi_init_format(V4L2_PIX_FMT_UYVY); csi_set_16bit_imagpara(f->fmt.pix.width, f->fmt.pix.height); bytesperline = f->fmt.pix.width * 2; break; case V4L2_PIX_FMT_UYVY: size = f->fmt.pix.width * f->fmt.pix.height * 2; + csi_init_format(f->fmt.pix.pixelformat); + csi_set_16bit_imagpara(f->fmt.pix.width, + f->fmt.pix.height); + bytesperline = f->fmt.pix.width * 2; + break; + case V4L2_PIX_FMT_YUYV: + size = f->fmt.pix.width * f->fmt.pix.height * 2; + csi_init_format(f->fmt.pix.pixelformat); csi_set_16bit_imagpara(f->fmt.pix.width, f->fmt.pix.height); bytesperline = f->fmt.pix.width * 2; diff --git a/drivers/media/video/mxc/capture/fsl_csi.c b/drivers/media/video/mxc/capture/fsl_csi.c index 5368b57c7a61..b3badfa4215b 100644 --- a/drivers/media/video/mxc/capture/fsl_csi.c +++ b/drivers/media/video/mxc/capture/fsl_csi.c @@ -124,6 +124,24 @@ void csi_init_interface(void) } EXPORT_SYMBOL(csi_init_interface); +void csi_init_format(int fmt) +{ + unsigned int val; + + val = __raw_readl(CSI_CSICR1); + if (fmt == V4L2_PIX_FMT_YUYV) { + val &= ~BIT_PACK_DIR; + val &= ~BIT_SWAP16_EN; + } else if (fmt == V4L2_PIX_FMT_UYVY) { + val |= BIT_PACK_DIR; + val |= BIT_SWAP16_EN; + } else + pr_warning("unsupported format, old format remains.\n"); + + __raw_writel(val, CSI_CSICR1); +} +EXPORT_SYMBOL(csi_init_format); + /*! * csi_enable_mclk * diff --git a/drivers/media/video/mxc/capture/fsl_csi.h b/drivers/media/video/mxc/capture/fsl_csi.h index d8096cc3b16d..aff74b96aaa6 100644 --- a/drivers/media/video/mxc/capture/fsl_csi.h +++ b/drivers/media/video/mxc/capture/fsl_csi.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2012 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2009-2013 Freescale Semiconductor, Inc. All Rights Reserved. */ /* @@ -186,6 +186,7 @@ typedef void (*csi_irq_callback_t) (void *data, unsigned long status); int32_t csi_enable_mclk(int src, bool flag, bool wait); void csi_init_interface(void); +void csi_init_format(int fmt); void csi_set_16bit_imagpara(int width, int height); void csi_set_12bit_imagpara(int width, int height); int csi_read_mclk_flag(void); |