You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
[media] V4L: Add driver for S3C24XX/S3C64XX SoC series camera interface
This patch adds V4L2 driver for Samsung S3C24XX/S3C64XX SoC series camera interface. The driver exposes a subdev device node for CAMIF pixel resolution and crop control and two video capture nodes - for the "codec" and "preview" data paths. It has been tested on Mini2440 (s3c2440) and Mini6410 (s3c6410) board with gstreamer and mplayer. Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com> Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com> Signed-off-by: Andrey Gusakov <dron0gus@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
d033a308d8
commit
babde1c243
@@ -109,6 +109,18 @@ config VIDEO_OMAP3_DEBUG
|
||||
---help---
|
||||
Enable debug messages on OMAP 3 camera controller driver.
|
||||
|
||||
config VIDEO_S3C_CAMIF
|
||||
tristate "Samsung S3C24XX/S3C64XX SoC Camera Interface driver"
|
||||
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
|
||||
depends on (PLAT_S3C64XX || PLAT_S3C24XX) && PM_RUNTIME
|
||||
select VIDEOBUF2_DMA_CONTIG
|
||||
---help---
|
||||
This is a v4l2 driver for s3c24xx and s3c64xx SoC series camera
|
||||
host interface (CAMIF).
|
||||
|
||||
To compile this driver as a module, choose M here: the module
|
||||
will be called s3c-camif.
|
||||
|
||||
source "drivers/media/platform/soc_camera/Kconfig"
|
||||
source "drivers/media/platform/s5p-fimc/Kconfig"
|
||||
source "drivers/media/platform/s5p-tv/Kconfig"
|
||||
|
||||
@@ -27,6 +27,7 @@ obj-$(CONFIG_VIDEO_CODA) += coda.o
|
||||
|
||||
obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE) += m2m-deinterlace.o
|
||||
|
||||
obj-$(CONFIG_VIDEO_S3C_CAMIF) += s3c-camif/
|
||||
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/
|
||||
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg/
|
||||
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc/
|
||||
|
||||
5
drivers/media/platform/s3c-camif/Makefile
Normal file
5
drivers/media/platform/s3c-camif/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
# Makefile for s3c244x/s3c64xx CAMIF driver
|
||||
|
||||
s3c-camif-objs := camif-core.o camif-capture.o camif-regs.o
|
||||
|
||||
obj-$(CONFIG_VIDEO_S3C_CAMIF) += s3c-camif.o
|
||||
1672
drivers/media/platform/s3c-camif/camif-capture.c
Normal file
1672
drivers/media/platform/s3c-camif/camif-capture.c
Normal file
File diff suppressed because it is too large
Load Diff
662
drivers/media/platform/s3c-camif/camif-core.c
Normal file
662
drivers/media/platform/s3c-camif/camif-core.c
Normal file
File diff suppressed because it is too large
Load Diff
393
drivers/media/platform/s3c-camif/camif-core.h
Normal file
393
drivers/media/platform/s3c-camif/camif-core.h
Normal file
@@ -0,0 +1,393 @@
|
||||
/*
|
||||
* s3c24xx/s3c64xx SoC series Camera Interface (CAMIF) driver
|
||||
*
|
||||
* Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
|
||||
* Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef CAMIF_CORE_H_
|
||||
#define CAMIF_CORE_H_
|
||||
|
||||
#include <linux/io.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include <media/media-entity.h>
|
||||
#include <media/v4l2-ctrls.h>
|
||||
#include <media/v4l2-dev.h>
|
||||
#include <media/v4l2-device.h>
|
||||
#include <media/v4l2-mediabus.h>
|
||||
#include <media/videobuf2-core.h>
|
||||
#include <media/s3c_camif.h>
|
||||
|
||||
#define S3C_CAMIF_DRIVER_NAME "s3c-camif"
|
||||
#define CAMIF_REQ_BUFS_MIN 3
|
||||
#define CAMIF_MAX_OUT_BUFS 4
|
||||
#define CAMIF_MAX_PIX_WIDTH 4096
|
||||
#define CAMIF_MAX_PIX_HEIGHT 4096
|
||||
#define SCALER_MAX_RATIO 64
|
||||
#define CAMIF_DEF_WIDTH 640
|
||||
#define CAMIF_DEF_HEIGHT 480
|
||||
#define CAMIF_STOP_TIMEOUT 1500 /* ms */
|
||||
|
||||
#define S3C244X_CAMIF_IP_REV 0x20 /* 2.0 */
|
||||
#define S3C2450_CAMIF_IP_REV 0x30 /* 3.0 - not implemented, not tested */
|
||||
#define S3C6400_CAMIF_IP_REV 0x31 /* 3.1 - not implemented, not tested */
|
||||
#define S3C6410_CAMIF_IP_REV 0x32 /* 3.2 */
|
||||
|
||||
/* struct camif_vp::state */
|
||||
|
||||
#define ST_VP_PENDING (1 << 0)
|
||||
#define ST_VP_RUNNING (1 << 1)
|
||||
#define ST_VP_STREAMING (1 << 2)
|
||||
#define ST_VP_SENSOR_STREAMING (1 << 3)
|
||||
|
||||
#define ST_VP_ABORTING (1 << 4)
|
||||
#define ST_VP_OFF (1 << 5)
|
||||
#define ST_VP_LASTIRQ (1 << 6)
|
||||
|
||||
#define ST_VP_CONFIG (1 << 8)
|
||||
|
||||
#define CAMIF_SD_PAD_SINK 0
|
||||
#define CAMIF_SD_PAD_SOURCE_C 1
|
||||
#define CAMIF_SD_PAD_SOURCE_P 2
|
||||
#define CAMIF_SD_PADS_NUM 3
|
||||
|
||||
enum img_fmt {
|
||||
IMG_FMT_RGB565 = 0x0010,
|
||||
IMG_FMT_RGB666,
|
||||
IMG_FMT_XRGB8888,
|
||||
IMG_FMT_YCBCR420 = 0x0020,
|
||||
IMG_FMT_YCRCB420,
|
||||
IMG_FMT_YCBCR422P,
|
||||
IMG_FMT_YCBYCR422 = 0x0040,
|
||||
IMG_FMT_YCRYCB422,
|
||||
IMG_FMT_CBYCRY422,
|
||||
IMG_FMT_CRYCBY422,
|
||||
};
|
||||
|
||||
#define img_fmt_is_rgb(x) ((x) & 0x10)
|
||||
#define img_fmt_is_ycbcr(x) ((x) & 0x60)
|
||||
|
||||
/* Possible values for struct camif_fmt::flags */
|
||||
#define FMT_FL_S3C24XX_CODEC (1 << 0)
|
||||
#define FMT_FL_S3C24XX_PREVIEW (1 << 1)
|
||||
#define FMT_FL_S3C64XX (1 << 2)
|
||||
|
||||
/**
|
||||
* struct camif_fmt - pixel format description
|
||||
* @fourcc: fourcc code for this format, 0 if not applicable
|
||||
* @color: a corresponding enum img_fmt
|
||||
* @colplanes: number of physically contiguous data planes
|
||||
* @flags: indicate for which SoCs revisions this format is valid
|
||||
* @depth: bits per pixel (total)
|
||||
* @ybpp: number of luminance bytes per pixel
|
||||
*/
|
||||
struct camif_fmt {
|
||||
char *name;
|
||||
u32 fourcc;
|
||||
u32 color;
|
||||
u16 colplanes;
|
||||
u16 flags;
|
||||
u8 depth;
|
||||
u8 ybpp;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct camif_dma_offset - pixel offset information for DMA
|
||||
* @initial: offset (in pixels) to first pixel
|
||||
* @line: offset (in pixels) from end of line to start of next line
|
||||
*/
|
||||
struct camif_dma_offset {
|
||||
int initial;
|
||||
int line;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct camif_frame - source/target frame properties
|
||||
* @f_width: full pixel width
|
||||
* @f_height: full pixel height
|
||||
* @rect: crop/composition rectangle
|
||||
* @dma_offset: DMA offset configuration
|
||||
*/
|
||||
struct camif_frame {
|
||||
u16 f_width;
|
||||
u16 f_height;
|
||||
struct v4l2_rect rect;
|
||||
struct camif_dma_offset dma_offset;
|
||||
};
|
||||
|
||||
/* CAMIF clocks enumeration */
|
||||
enum {
|
||||
CLK_GATE,
|
||||
CLK_CAM,
|
||||
CLK_MAX_NUM,
|
||||
};
|
||||
|
||||
struct vp_pix_limits {
|
||||
u16 max_out_width;
|
||||
u16 max_sc_out_width;
|
||||
u16 out_width_align;
|
||||
u16 max_height;
|
||||
u8 min_out_width;
|
||||
u16 out_hor_offset_align;
|
||||
};
|
||||
|
||||
struct camif_pix_limits {
|
||||
u16 win_hor_offset_align;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct s3c_camif_variant - CAMIF variant structure
|
||||
* @vp_pix_limits: pixel limits for the codec and preview paths
|
||||
* @camif_pix_limits: pixel limits for the camera input interface
|
||||
* @ip_revision: the CAMIF IP revision: 0x20 for s3c244x, 0x32 for s3c6410
|
||||
*/
|
||||
struct s3c_camif_variant {
|
||||
struct vp_pix_limits vp_pix_limits[2];
|
||||
struct camif_pix_limits pix_limits;
|
||||
u8 ip_revision;
|
||||
u8 has_img_effect;
|
||||
unsigned int vp_offset;
|
||||
};
|
||||
|
||||
struct s3c_camif_drvdata {
|
||||
const struct s3c_camif_variant *variant;
|
||||
unsigned long bus_clk_freq;
|
||||
};
|
||||
|
||||
struct camif_scaler {
|
||||
u8 scaleup_h;
|
||||
u8 scaleup_v;
|
||||
u8 copy;
|
||||
u8 enable;
|
||||
u32 h_shift;
|
||||
u32 v_shift;
|
||||
u32 pre_h_ratio;
|
||||
u32 pre_v_ratio;
|
||||
u32 pre_dst_width;
|
||||
u32 pre_dst_height;
|
||||
u32 main_h_ratio;
|
||||
u32 main_v_ratio;
|
||||
};
|
||||
|
||||
struct camif_dev;
|
||||
|
||||
/**
|
||||
* struct camif_vp - CAMIF data processing path structure (codec/preview)
|
||||
* @irq_queue: interrupt handling waitqueue
|
||||
* @irq: interrupt number for this data path
|
||||
* @camif: pointer to the camif structure
|
||||
* @pad: media pad for the video node
|
||||
* @vdev video device
|
||||
* @ctrl_handler: video node controls handler
|
||||
* @owner: file handle that own the streaming
|
||||
* @pending_buf_q: pending (empty) buffers queue head
|
||||
* @active_buf_q: active (being written) buffers queue head
|
||||
* @active_buffers: counter of buffer set up at the DMA engine
|
||||
* @buf_index: identifier of a last empty buffer set up in H/W
|
||||
* @frame_sequence: image frame sequence counter
|
||||
* @reqbufs_count: the number of buffers requested
|
||||
* @scaler: the scaler structure
|
||||
* @out_fmt: pixel format at this video path output
|
||||
* @payload: the output data frame payload size
|
||||
* @out_frame: the output pixel resolution
|
||||
* @state: the video path's state
|
||||
* @fmt_flags: flags determining supported pixel formats
|
||||
* @id: CAMIF id, 0 - codec, 1 - preview
|
||||
* @rotation: current image rotation value
|
||||
* @hflip: apply horizontal flip if set
|
||||
* @vflip: apply vertical flip if set
|
||||
*/
|
||||
struct camif_vp {
|
||||
wait_queue_head_t irq_queue;
|
||||
int irq;
|
||||
struct camif_dev *camif;
|
||||
struct media_pad pad;
|
||||
struct video_device vdev;
|
||||
struct v4l2_ctrl_handler ctrl_handler;
|
||||
struct v4l2_fh *owner;
|
||||
struct vb2_queue vb_queue;
|
||||
struct list_head pending_buf_q;
|
||||
struct list_head active_buf_q;
|
||||
unsigned int active_buffers;
|
||||
unsigned int buf_index;
|
||||
unsigned int frame_sequence;
|
||||
unsigned int reqbufs_count;
|
||||
struct camif_scaler scaler;
|
||||
const struct camif_fmt *out_fmt;
|
||||
unsigned int payload;
|
||||
struct camif_frame out_frame;
|
||||
unsigned int state;
|
||||
u16 fmt_flags;
|
||||
u8 id;
|
||||
u8 rotation;
|
||||
u8 hflip;
|
||||
u8 vflip;
|
||||
unsigned int offset;
|
||||
};
|
||||
|
||||
/* Video processing path enumeration */
|
||||
#define VP_CODEC 0
|
||||
#define VP_PREVIEW 1
|
||||
#define CAMIF_VP_NUM 2
|
||||
|
||||
/**
|
||||
* struct camif_dev - the CAMIF driver private data structure
|
||||
* @media_dev: top-level media device structure
|
||||
* @v4l2_dev: root v4l2_device
|
||||
* @subdev: camera interface ("catchcam") subdev
|
||||
* @mbus_fmt: camera input media bus format
|
||||
* @camif_crop: camera input interface crop rectangle
|
||||
* @pads: the camif subdev's media pads
|
||||
* @stream_count: the camera interface streaming reference counter
|
||||
* @sensor: image sensor data structure
|
||||
* @m_pipeline: video entity pipeline description
|
||||
* @ctrl_handler: v4l2 control handler (owned by @subdev)
|
||||
* @test_pattern: test pattern controls
|
||||
* @vp: video path (DMA) description (codec/preview)
|
||||
* @alloc_ctx: memory buffer allocator context
|
||||
* @variant: variant information for this device
|
||||
* @dev: pointer to the CAMIF device struct
|
||||
* @pdata: a copy of the driver's platform data
|
||||
* @clock: clocks required for the CAMIF operation
|
||||
* @lock: mutex protecting this data structure
|
||||
* @slock: spinlock protecting CAMIF registers
|
||||
* @io_base: start address of the mmaped CAMIF registers
|
||||
*/
|
||||
struct camif_dev {
|
||||
struct media_device media_dev;
|
||||
struct v4l2_device v4l2_dev;
|
||||
struct v4l2_subdev subdev;
|
||||
struct v4l2_mbus_framefmt mbus_fmt;
|
||||
struct v4l2_rect camif_crop;
|
||||
struct media_pad pads[CAMIF_SD_PADS_NUM];
|
||||
int stream_count;
|
||||
|
||||
struct cam_sensor {
|
||||
struct v4l2_subdev *sd;
|
||||
short power_count;
|
||||
short stream_count;
|
||||
} sensor;
|
||||
struct media_pipeline *m_pipeline;
|
||||
|
||||
struct v4l2_ctrl_handler ctrl_handler;
|
||||
struct v4l2_ctrl *ctrl_test_pattern;
|
||||
struct {
|
||||
struct v4l2_ctrl *ctrl_colorfx;
|
||||
struct v4l2_ctrl *ctrl_colorfx_cbcr;
|
||||
};
|
||||
u8 test_pattern;
|
||||
u8 colorfx;
|
||||
u8 colorfx_cb;
|
||||
u8 colorfx_cr;
|
||||
|
||||
struct camif_vp vp[CAMIF_VP_NUM];
|
||||
struct vb2_alloc_ctx *alloc_ctx;
|
||||
|
||||
const struct s3c_camif_variant *variant;
|
||||
struct device *dev;
|
||||
struct s3c_camif_plat_data pdata;
|
||||
struct clk *clock[CLK_MAX_NUM];
|
||||
struct mutex lock;
|
||||
spinlock_t slock;
|
||||
void __iomem *io_base;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct camif_addr - Y/Cb/Cr DMA start address structure
|
||||
* @y: luminance plane dma address
|
||||
* @cb: Cb plane dma address
|
||||
* @cr: Cr plane dma address
|
||||
*/
|
||||
struct camif_addr {
|
||||
dma_addr_t y;
|
||||
dma_addr_t cb;
|
||||
dma_addr_t cr;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct camif_buffer - the camif video buffer structure
|
||||
* @vb: vb2 buffer
|
||||
* @list: list head for the buffers queue
|
||||
* @paddr: DMA start addresses
|
||||
* @index: an identifier of this buffer at the DMA engine
|
||||
*/
|
||||
struct camif_buffer {
|
||||
struct vb2_buffer vb;
|
||||
struct list_head list;
|
||||
struct camif_addr paddr;
|
||||
unsigned int index;
|
||||
};
|
||||
|
||||
const struct camif_fmt *s3c_camif_find_format(struct camif_vp *vp,
|
||||
const u32 *pixelformat, int index);
|
||||
int s3c_camif_register_video_node(struct camif_dev *camif, int idx);
|
||||
void s3c_camif_unregister_video_node(struct camif_dev *camif, int idx);
|
||||
irqreturn_t s3c_camif_irq_handler(int irq, void *priv);
|
||||
int s3c_camif_create_subdev(struct camif_dev *camif);
|
||||
void s3c_camif_unregister_subdev(struct camif_dev *camif);
|
||||
int s3c_camif_set_defaults(struct camif_dev *camif);
|
||||
int s3c_camif_get_scaler_config(struct camif_vp *vp,
|
||||
struct camif_scaler *scaler);
|
||||
|
||||
static inline void camif_active_queue_add(struct camif_vp *vp,
|
||||
struct camif_buffer *buf)
|
||||
{
|
||||
list_add_tail(&buf->list, &vp->active_buf_q);
|
||||
vp->active_buffers++;
|
||||
}
|
||||
|
||||
static inline struct camif_buffer *camif_active_queue_pop(
|
||||
struct camif_vp *vp)
|
||||
{
|
||||
struct camif_buffer *buf = list_first_entry(&vp->active_buf_q,
|
||||
struct camif_buffer, list);
|
||||
list_del(&buf->list);
|
||||
vp->active_buffers--;
|
||||
return buf;
|
||||
}
|
||||
|
||||
static inline struct camif_buffer *camif_active_queue_peek(
|
||||
struct camif_vp *vp, int index)
|
||||
{
|
||||
struct camif_buffer *tmp, *buf;
|
||||
|
||||
if (WARN_ON(list_empty(&vp->active_buf_q)))
|
||||
return NULL;
|
||||
|
||||
list_for_each_entry_safe(buf, tmp, &vp->active_buf_q, list) {
|
||||
if (buf->index == index) {
|
||||
list_del(&buf->list);
|
||||
vp->active_buffers--;
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void camif_pending_queue_add(struct camif_vp *vp,
|
||||
struct camif_buffer *buf)
|
||||
{
|
||||
list_add_tail(&buf->list, &vp->pending_buf_q);
|
||||
}
|
||||
|
||||
static inline struct camif_buffer *camif_pending_queue_pop(
|
||||
struct camif_vp *vp)
|
||||
{
|
||||
struct camif_buffer *buf = list_first_entry(&vp->pending_buf_q,
|
||||
struct camif_buffer, list);
|
||||
list_del(&buf->list);
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif /* CAMIF_CORE_H_ */
|
||||
606
drivers/media/platform/s3c-camif/camif-regs.c
Normal file
606
drivers/media/platform/s3c-camif/camif-regs.c
Normal file
File diff suppressed because it is too large
Load Diff
269
drivers/media/platform/s3c-camif/camif-regs.h
Normal file
269
drivers/media/platform/s3c-camif/camif-regs.h
Normal file
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* Register definition file for s3c24xx/s3c64xx SoC CAMIF driver
|
||||
*
|
||||
* Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
|
||||
* Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef CAMIF_REGS_H_
|
||||
#define CAMIF_REGS_H_
|
||||
|
||||
#include "camif-core.h"
|
||||
#include <media/s3c_camif.h>
|
||||
|
||||
/*
|
||||
* The id argument indicates the processing path:
|
||||
* id = 0 - codec (FIMC C), 1 - preview (FIMC P).
|
||||
*/
|
||||
|
||||
/* Camera input format */
|
||||
#define S3C_CAMIF_REG_CISRCFMT 0x00
|
||||
#define CISRCFMT_ITU601_8BIT (1 << 31)
|
||||
#define CISRCFMT_ITU656_8BIT (0 << 31)
|
||||
#define CISRCFMT_ORDER422_YCBYCR (0 << 14)
|
||||
#define CISRCFMT_ORDER422_YCRYCB (1 << 14)
|
||||
#define CISRCFMT_ORDER422_CBYCRY (2 << 14)
|
||||
#define CISRCFMT_ORDER422_CRYCBY (3 << 14)
|
||||
#define CISRCFMT_ORDER422_MASK (3 << 14)
|
||||
#define CISRCFMT_SIZE_CAM_MASK (0x1fff << 16 | 0x1fff)
|
||||
|
||||
/* Window offset */
|
||||
#define S3C_CAMIF_REG_CIWDOFST 0x04
|
||||
#define CIWDOFST_WINOFSEN (1 << 31)
|
||||
#define CIWDOFST_CLROVCOFIY (1 << 30)
|
||||
#define CIWDOFST_CLROVRLB_PR (1 << 28)
|
||||
/* #define CIWDOFST_CLROVPRFIY (1 << 27) */
|
||||
#define CIWDOFST_CLROVCOFICB (1 << 15)
|
||||
#define CIWDOFST_CLROVCOFICR (1 << 14)
|
||||
#define CIWDOFST_CLROVPRFICB (1 << 13)
|
||||
#define CIWDOFST_CLROVPRFICR (1 << 12)
|
||||
#define CIWDOFST_OFST_MASK (0x7ff << 16 | 0x7ff)
|
||||
|
||||
/* Window offset 2 */
|
||||
#define S3C_CAMIF_REG_CIWDOFST2 0x14
|
||||
#define CIWDOFST2_OFST2_MASK (0xfff << 16 | 0xfff)
|
||||
|
||||
/* Global control */
|
||||
#define S3C_CAMIF_REG_CIGCTRL 0x08
|
||||
#define CIGCTRL_SWRST (1 << 31)
|
||||
#define CIGCTRL_CAMRST (1 << 30)
|
||||
#define CIGCTRL_TESTPATTERN_NORMAL (0 << 27)
|
||||
#define CIGCTRL_TESTPATTERN_COLOR_BAR (1 << 27)
|
||||
#define CIGCTRL_TESTPATTERN_HOR_INC (2 << 27)
|
||||
#define CIGCTRL_TESTPATTERN_VER_INC (3 << 27)
|
||||
#define CIGCTRL_TESTPATTERN_MASK (3 << 27)
|
||||
#define CIGCTRL_INVPOLPCLK (1 << 26)
|
||||
#define CIGCTRL_INVPOLVSYNC (1 << 25)
|
||||
#define CIGCTRL_INVPOLHREF (1 << 24)
|
||||
#define CIGCTRL_IRQ_OVFEN (1 << 22)
|
||||
#define CIGCTRL_HREF_MASK (1 << 21)
|
||||
#define CIGCTRL_IRQ_LEVEL (1 << 20)
|
||||
/* IRQ_CLR_C, IRQ_CLR_P */
|
||||
#define CIGCTRL_IRQ_CLR(id) (1 << (19 - (id)))
|
||||
#define CIGCTRL_FIELDMODE (1 << 2)
|
||||
#define CIGCTRL_INVPOLFIELD (1 << 1)
|
||||
#define CIGCTRL_CAM_INTERLACE (1 << 0)
|
||||
|
||||
/* Y DMA output frame start address. n = 0..3. */
|
||||
#define S3C_CAMIF_REG_CIYSA(id, n) (0x18 + (id) * 0x54 + (n) * 4)
|
||||
/* Cb plane output DMA start address. n = 0..3. Only codec path. */
|
||||
#define S3C_CAMIF_REG_CICBSA(id, n) (0x28 + (id) * 0x54 + (n) * 4)
|
||||
/* Cr plane output DMA start address. n = 0..3. Only codec path. */
|
||||
#define S3C_CAMIF_REG_CICRSA(id, n) (0x38 + (id) * 0x54 + (n) * 4)
|
||||
|
||||
/* CICOTRGFMT, CIPRTRGFMT - Target format */
|
||||
#define S3C_CAMIF_REG_CITRGFMT(id, _offs) (0x48 + (id) * (0x34 + (_offs)))
|
||||
#define CITRGFMT_IN422 (1 << 31) /* only for s3c24xx */
|
||||
#define CITRGFMT_OUT422 (1 << 30) /* only for s3c24xx */
|
||||
#define CITRGFMT_OUTFORMAT_YCBCR420 (0 << 29) /* only for s3c6410 */
|
||||
#define CITRGFMT_OUTFORMAT_YCBCR422 (1 << 29) /* only for s3c6410 */
|
||||
#define CITRGFMT_OUTFORMAT_YCBCR422I (2 << 29) /* only for s3c6410 */
|
||||
#define CITRGFMT_OUTFORMAT_RGB (3 << 29) /* only for s3c6410 */
|
||||
#define CITRGFMT_OUTFORMAT_MASK (3 << 29) /* only for s3c6410 */
|
||||
#define CITRGFMT_TARGETHSIZE(x) ((x) << 16)
|
||||
#define CITRGFMT_FLIP_NORMAL (0 << 14)
|
||||
#define CITRGFMT_FLIP_X_MIRROR (1 << 14)
|
||||
#define CITRGFMT_FLIP_Y_MIRROR (2 << 14)
|
||||
#define CITRGFMT_FLIP_180 (3 << 14)
|
||||
#define CITRGFMT_FLIP_MASK (3 << 14)
|
||||
/* Preview path only */
|
||||
#define CITRGFMT_ROT90_PR (1 << 13)
|
||||
#define CITRGFMT_TARGETVSIZE(x) ((x) << 0)
|
||||
#define CITRGFMT_TARGETSIZE_MASK ((0x1fff << 16) | 0x1fff)
|
||||
|
||||
/* CICOCTRL, CIPRCTRL. Output DMA control. */
|
||||
#define S3C_CAMIF_REG_CICTRL(id, _offs) (0x4c + (id) * (0x34 + (_offs)))
|
||||
#define CICTRL_BURST_MASK (0xfffff << 4)
|
||||
/* xBURSTn - 5-bits width */
|
||||
#define CICTRL_YBURST1(x) ((x) << 19)
|
||||
#define CICTRL_YBURST2(x) ((x) << 14)
|
||||
#define CICTRL_RGBBURST1(x) ((x) << 19)
|
||||
#define CICTRL_RGBBURST2(x) ((x) << 14)
|
||||
#define CICTRL_CBURST1(x) ((x) << 9)
|
||||
#define CICTRL_CBURST2(x) ((x) << 4)
|
||||
#define CICTRL_LASTIRQ_ENABLE (1 << 2)
|
||||
#define CICTRL_ORDER422_MASK (3 << 0)
|
||||
|
||||
/* CICOSCPRERATIO, CIPRSCPRERATIO. Pre-scaler control 1. */
|
||||
#define S3C_CAMIF_REG_CISCPRERATIO(id, _offs) (0x50 + (id) * (0x34 + (_offs)))
|
||||
|
||||
/* CICOSCPREDST, CIPRSCPREDST. Pre-scaler control 2. */
|
||||
#define S3C_CAMIF_REG_CISCPREDST(id, _offs) (0x54 + (id) * (0x34 + (_offs)))
|
||||
|
||||
/* CICOSCCTRL, CIPRSCCTRL. Main scaler control. */
|
||||
#define S3C_CAMIF_REG_CISCCTRL(id, _offs) (0x58 + (id) * (0x34 + (_offs)))
|
||||
#define CISCCTRL_SCALERBYPASS (1 << 31)
|
||||
/* s3c244x preview path only, s3c64xx both */
|
||||
#define CIPRSCCTRL_SAMPLE (1 << 31)
|
||||
/* 0 - 16-bit RGB, 1 - 24-bit RGB */
|
||||
#define CIPRSCCTRL_RGB_FORMAT_24BIT (1 << 30) /* only for s3c244x */
|
||||
#define CIPRSCCTRL_SCALEUP_H (1 << 29) /* only for s3c244x */
|
||||
#define CIPRSCCTRL_SCALEUP_V (1 << 28) /* only for s3c244x */
|
||||
/* s3c64xx */
|
||||
#define CISCCTRL_SCALEUP_H (1 << 30)
|
||||
#define CISCCTRL_SCALEUP_V (1 << 29)
|
||||
#define CISCCTRL_SCALEUP_MASK (0x3 << 29)
|
||||
#define CISCCTRL_CSCR2Y_WIDE (1 << 28)
|
||||
#define CISCCTRL_CSCY2R_WIDE (1 << 27)
|
||||
#define CISCCTRL_LCDPATHEN_FIFO (1 << 26)
|
||||
#define CISCCTRL_INTERLACE (1 << 25)
|
||||
#define CISCCTRL_SCALERSTART (1 << 15)
|
||||
#define CISCCTRL_INRGB_FMT_RGB565 (0 << 13)
|
||||
#define CISCCTRL_INRGB_FMT_RGB666 (1 << 13)
|
||||
#define CISCCTRL_INRGB_FMT_RGB888 (2 << 13)
|
||||
#define CISCCTRL_INRGB_FMT_MASK (3 << 13)
|
||||
#define CISCCTRL_OUTRGB_FMT_RGB565 (0 << 11)
|
||||
#define CISCCTRL_OUTRGB_FMT_RGB666 (1 << 11)
|
||||
#define CISCCTRL_OUTRGB_FMT_RGB888 (2 << 11)
|
||||
#define CISCCTRL_OUTRGB_FMT_MASK (3 << 11)
|
||||
#define CISCCTRL_EXTRGB_EXTENSION (1 << 10)
|
||||
#define CISCCTRL_ONE2ONE (1 << 9)
|
||||
#define CISCCTRL_MAIN_RATIO_MASK (0x1ff << 16 | 0x1ff)
|
||||
|
||||
/* CICOTAREA, CIPRTAREA. Target area for DMA (Hsize x Vsize). */
|
||||
#define S3C_CAMIF_REG_CITAREA(id, _offs) (0x5c + (id) * (0x34 + (_offs)))
|
||||
#define CITAREA_MASK 0xfffffff
|
||||
|
||||
/* Codec (id = 0) or preview (id = 1) path status. */
|
||||
#define S3C_CAMIF_REG_CISTATUS(id, _offs) (0x64 + (id) * (0x34 + (_offs)))
|
||||
#define CISTATUS_OVFIY_STATUS (1 << 31)
|
||||
#define CISTATUS_OVFICB_STATUS (1 << 30)
|
||||
#define CISTATUS_OVFICR_STATUS (1 << 29)
|
||||
#define CISTATUS_OVF_MASK (0x7 << 29)
|
||||
#define CIPRSTATUS_OVF_MASK (0x3 << 30)
|
||||
#define CISTATUS_VSYNC_STATUS (1 << 28)
|
||||
#define CISTATUS_FRAMECNT_MASK (3 << 26)
|
||||
#define CISTATUS_FRAMECNT(__reg) (((__reg) >> 26) & 0x3)
|
||||
#define CISTATUS_WINOFSTEN_STATUS (1 << 25)
|
||||
#define CISTATUS_IMGCPTEN_STATUS (1 << 22)
|
||||
#define CISTATUS_IMGCPTENSC_STATUS (1 << 21)
|
||||
#define CISTATUS_VSYNC_A_STATUS (1 << 20)
|
||||
#define CISTATUS_FRAMEEND_STATUS (1 << 19) /* 17 on s3c64xx */
|
||||
|
||||
/* Image capture enable */
|
||||
#define S3C_CAMIF_REG_CIIMGCPT(_offs) (0xa0 + (_offs))
|
||||
#define CIIMGCPT_IMGCPTEN (1 << 31)
|
||||
#define CIIMGCPT_IMGCPTEN_SC(id) (1 << (30 - (id)))
|
||||
/* Frame control: 1 - one-shot, 0 - free run */
|
||||
#define CIIMGCPT_CPT_FREN_ENABLE(id) (1 << (25 - (id)))
|
||||
#define CIIMGCPT_CPT_FRMOD_ENABLE (0 << 18)
|
||||
#define CIIMGCPT_CPT_FRMOD_CNT (1 << 18)
|
||||
|
||||
/* Capture sequence */
|
||||
#define S3C_CAMIF_REG_CICPTSEQ 0xc4
|
||||
|
||||
/* Image effects */
|
||||
#define S3C_CAMIF_REG_CIIMGEFF(_offs) (0xb0 + (_offs))
|
||||
#define CIIMGEFF_IE_ENABLE(id) (1 << (30 + (id)))
|
||||
#define CIIMGEFF_IE_ENABLE_MASK (3 << 30)
|
||||
/* Image effect: 1 - after scaler, 0 - before scaler */
|
||||
#define CIIMGEFF_IE_AFTER_SC (1 << 29)
|
||||
#define CIIMGEFF_FIN_MASK (7 << 26)
|
||||
#define CIIMGEFF_FIN_BYPASS (0 << 26)
|
||||
#define CIIMGEFF_FIN_ARBITRARY (1 << 26)
|
||||
#define CIIMGEFF_FIN_NEGATIVE (2 << 26)
|
||||
#define CIIMGEFF_FIN_ARTFREEZE (3 << 26)
|
||||
#define CIIMGEFF_FIN_EMBOSSING (4 << 26)
|
||||
#define CIIMGEFF_FIN_SILHOUETTE (5 << 26)
|
||||
#define CIIMGEFF_PAT_CBCR_MASK ((0xff << 13) | 0xff)
|
||||
#define CIIMGEFF_PAT_CB(x) ((x) << 13)
|
||||
#define CIIMGEFF_PAT_CR(x) (x)
|
||||
|
||||
/* MSCOY0SA, MSPRY0SA. Y/Cb/Cr frame start address for input DMA. */
|
||||
#define S3C_CAMIF_REG_MSY0SA(id) (0xd4 + ((id) * 0x2c))
|
||||
#define S3C_CAMIF_REG_MSCB0SA(id) (0xd8 + ((id) * 0x2c))
|
||||
#define S3C_CAMIF_REG_MSCR0SA(id) (0xdc + ((id) * 0x2c))
|
||||
|
||||
/* MSCOY0END, MSCOY0END. Y/Cb/Cr frame end address for input DMA. */
|
||||
#define S3C_CAMIF_REG_MSY0END(id) (0xe0 + ((id) * 0x2c))
|
||||
#define S3C_CAMIF_REG_MSCB0END(id) (0xe4 + ((id) * 0x2c))
|
||||
#define S3C_CAMIF_REG_MSCR0END(id) (0xe8 + ((id) * 0x2c))
|
||||
|
||||
/* MSPRYOFF, MSPRYOFF. Y/Cb/Cr offset. n: 0 - codec, 1 - preview. */
|
||||
#define S3C_CAMIF_REG_MSYOFF(id) (0x118 + ((id) * 0x2c))
|
||||
#define S3C_CAMIF_REG_MSCBOFF(id) (0x11c + ((id) * 0x2c))
|
||||
#define S3C_CAMIF_REG_MSCROFF(id) (0x120 + ((id) * 0x2c))
|
||||
|
||||
/* Real input DMA data size. n = 0 - codec, 1 - preview. */
|
||||
#define S3C_CAMIF_REG_MSWIDTH(id) (0xf8 + (id) * 0x2c)
|
||||
#define AUTOLOAD_ENABLE (1 << 31)
|
||||
#define ADDR_CH_DIS (1 << 30)
|
||||
#define MSHEIGHT(x) (((x) & 0x3ff) << 16)
|
||||
#define MSWIDTH(x) ((x) & 0x3ff)
|
||||
|
||||
/* Input DMA control. n = 0 - codec, 1 - preview */
|
||||
#define S3C_CAMIF_REG_MSCTRL(id) (0xfc + (id) * 0x2c)
|
||||
#define MSCTRL_ORDER422_M_YCBYCR (0 << 4)
|
||||
#define MSCTRL_ORDER422_M_YCRYCB (1 << 4)
|
||||
#define MSCTRL_ORDER422_M_CBYCRY (2 << 4)
|
||||
#define MSCTRL_ORDER422_M_CRYCBY (3 << 4)
|
||||
/* 0 - camera, 1 - DMA */
|
||||
#define MSCTRL_SEL_DMA_CAM (1 << 3)
|
||||
#define MSCTRL_INFORMAT_M_YCBCR420 (0 << 1)
|
||||
#define MSCTRL_INFORMAT_M_YCBCR422 (1 << 1)
|
||||
#define MSCTRL_INFORMAT_M_YCBCR422I (2 << 1)
|
||||
#define MSCTRL_INFORMAT_M_RGB (3 << 1)
|
||||
#define MSCTRL_ENVID_M (1 << 0)
|
||||
|
||||
/* CICOSCOSY, CIPRSCOSY. Scan line Y/Cb/Cr offset. */
|
||||
#define S3C_CAMIF_REG_CISSY(id) (0x12c + (id) * 0x0c)
|
||||
#define S3C_CAMIF_REG_CISSCB(id) (0x130 + (id) * 0x0c)
|
||||
#define S3C_CAMIF_REG_CISSCR(id) (0x134 + (id) * 0x0c)
|
||||
#define S3C_CISS_OFFS_INITIAL(x) ((x) << 16)
|
||||
#define S3C_CISS_OFFS_LINE(x) ((x) << 0)
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
void camif_hw_reset(struct camif_dev *camif);
|
||||
void camif_hw_clear_pending_irq(struct camif_vp *vp);
|
||||
void camif_hw_clear_fifo_overflow(struct camif_vp *vp);
|
||||
void camif_hw_set_lastirq(struct camif_vp *vp, int enable);
|
||||
void camif_hw_set_input_path(struct camif_vp *vp);
|
||||
void camif_hw_enable_scaler(struct camif_vp *vp, bool on);
|
||||
void camif_hw_enable_capture(struct camif_vp *vp);
|
||||
void camif_hw_disable_capture(struct camif_vp *vp);
|
||||
void camif_hw_set_camera_bus(struct camif_dev *camif);
|
||||
void camif_hw_set_source_format(struct camif_dev *camif);
|
||||
void camif_hw_set_camera_crop(struct camif_dev *camif);
|
||||
void camif_hw_set_scaler(struct camif_vp *vp);
|
||||
void camif_hw_set_flip(struct camif_vp *vp);
|
||||
void camif_hw_set_output_dma(struct camif_vp *vp);
|
||||
void camif_hw_set_target_format(struct camif_vp *vp);
|
||||
void camif_hw_set_test_pattern(struct camif_dev *camif, unsigned int pattern);
|
||||
void camif_hw_set_effect(struct camif_dev *camif, unsigned int effect,
|
||||
unsigned int cr, unsigned int cb);
|
||||
void camif_hw_set_output_addr(struct camif_vp *vp, struct camif_addr *paddr,
|
||||
int index);
|
||||
void camif_hw_dump_regs(struct camif_dev *camif, const char *label);
|
||||
|
||||
static inline u32 camif_hw_get_status(struct camif_vp *vp)
|
||||
{
|
||||
return readl(vp->camif->io_base + S3C_CAMIF_REG_CISTATUS(vp->id,
|
||||
vp->offset));
|
||||
}
|
||||
|
||||
#endif /* CAMIF_REGS_H_ */
|
||||
45
include/media/s3c_camif.h
Normal file
45
include/media/s3c_camif.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* s3c24xx/s3c64xx SoC series Camera Interface (CAMIF) driver
|
||||
*
|
||||
* Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef MEDIA_S3C_CAMIF_
|
||||
#define MEDIA_S3C_CAMIF_
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#include <media/v4l2-mediabus.h>
|
||||
|
||||
/**
|
||||
* struct s3c_camif_sensor_info - an image sensor description
|
||||
* @i2c_board_info: pointer to an I2C sensor subdevice board info
|
||||
* @clock_frequency: frequency of the clock the host provides to a sensor
|
||||
* @mbus_type: media bus type
|
||||
* @i2c_bus_num: i2c control bus id the sensor is attached to
|
||||
* @flags: the parallel bus flags defining signals polarity (V4L2_MBUS_*)
|
||||
* @use_field: 1 if parallel bus FIELD signal is used (only s3c64xx)
|
||||
*/
|
||||
struct s3c_camif_sensor_info {
|
||||
struct i2c_board_info i2c_board_info;
|
||||
unsigned long clock_frequency;
|
||||
enum v4l2_mbus_type mbus_type;
|
||||
u16 i2c_bus_num;
|
||||
u16 flags;
|
||||
u8 use_field;
|
||||
};
|
||||
|
||||
struct s3c_camif_plat_data {
|
||||
struct s3c_camif_sensor_info sensor;
|
||||
int (*gpio_get)(void);
|
||||
int (*gpio_put)(void);
|
||||
};
|
||||
|
||||
/* Platform default helper functions */
|
||||
int s3c_camif_gpio_get(void);
|
||||
int s3c_camif_gpio_put(void);
|
||||
|
||||
#endif /* MEDIA_S3C_CAMIF_ */
|
||||
Reference in New Issue
Block a user