sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / media / platform / exynos4-is / fimc-isp.h
blob3cdd52491294321d30b9e73b19da1ec32e8c579c
1 /*
2 * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
4 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
6 * Authors: Sylwester Nawrocki <s.nawrocki@samsung.com>
7 * Younghwan Joo <yhwan.joo@samsung.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 #ifndef FIMC_ISP_H_
14 #define FIMC_ISP_H_
16 #include <linux/io.h>
17 #include <linux/platform_device.h>
18 #include <linux/sched.h>
19 #include <linux/spinlock.h>
20 #include <linux/types.h>
21 #include <linux/videodev2.h>
23 #include <media/media-entity.h>
24 #include <media/videobuf2-v4l2.h>
25 #include <media/v4l2-device.h>
26 #include <media/v4l2-mediabus.h>
27 #include <media/drv-intf/exynos-fimc.h>
29 extern int fimc_isp_debug;
31 #define isp_dbg(level, dev, fmt, arg...) \
32 v4l2_dbg(level, fimc_isp_debug, dev, fmt, ## arg)
34 /* FIXME: revisit these constraints */
35 #define FIMC_ISP_SINK_WIDTH_MIN (16 + 8)
36 #define FIMC_ISP_SINK_HEIGHT_MIN (12 + 8)
37 #define FIMC_ISP_SOURCE_WIDTH_MIN 8
38 #define FIMC_ISP_SOURCE_HEIGHT_MIN 8
39 #define FIMC_ISP_CAC_MARGIN_WIDTH 16
40 #define FIMC_ISP_CAC_MARGIN_HEIGHT 12
42 #define FIMC_ISP_SINK_WIDTH_MAX (4000 - 16)
43 #define FIMC_ISP_SINK_HEIGHT_MAX (4000 + 12)
44 #define FIMC_ISP_SOURCE_WIDTH_MAX 4000
45 #define FIMC_ISP_SOURCE_HEIGHT_MAX 4000
47 #define FIMC_ISP_NUM_FORMATS 3
48 #define FIMC_ISP_REQ_BUFS_MIN 2
49 #define FIMC_ISP_REQ_BUFS_MAX 32
51 #define FIMC_ISP_SD_PAD_SINK 0
52 #define FIMC_ISP_SD_PAD_SRC_FIFO 1
53 #define FIMC_ISP_SD_PAD_SRC_DMA 2
54 #define FIMC_ISP_SD_PADS_NUM 3
55 #define FIMC_ISP_MAX_PLANES 1
57 /**
58 * struct fimc_isp_frame - source/target frame properties
59 * @width: full image width
60 * @height: full image height
61 * @rect: crop/composition rectangle
63 struct fimc_isp_frame {
64 u16 width;
65 u16 height;
66 struct v4l2_rect rect;
69 struct fimc_isp_ctrls {
70 struct v4l2_ctrl_handler handler;
72 /* Auto white balance */
73 struct v4l2_ctrl *auto_wb;
74 /* Auto ISO control cluster */
75 struct {
76 struct v4l2_ctrl *auto_iso;
77 struct v4l2_ctrl *iso;
79 /* Adjust - contrast */
80 struct v4l2_ctrl *contrast;
81 /* Adjust - saturation */
82 struct v4l2_ctrl *saturation;
83 /* Adjust - sharpness */
84 struct v4l2_ctrl *sharpness;
85 /* Adjust - brightness */
86 struct v4l2_ctrl *brightness;
87 /* Adjust - hue */
88 struct v4l2_ctrl *hue;
90 /* Auto/manual exposure */
91 struct v4l2_ctrl *auto_exp;
92 /* Manual exposure value */
93 struct v4l2_ctrl *exposure;
94 /* AE/AWB lock/unlock */
95 struct v4l2_ctrl *aewb_lock;
96 /* Exposure metering mode */
97 struct v4l2_ctrl *exp_metering;
98 /* AFC */
99 struct v4l2_ctrl *afc;
100 /* ISP image effect */
101 struct v4l2_ctrl *colorfx;
104 struct isp_video_buf {
105 struct vb2_v4l2_buffer vb;
106 dma_addr_t dma_addr[FIMC_ISP_MAX_PLANES];
107 unsigned int index;
110 #define to_isp_video_buf(_b) container_of(_b, struct isp_video_buf, vb)
112 #define FIMC_ISP_MAX_BUFS 4
115 * struct fimc_is_video - fimc-is video device structure
116 * @vdev: video_device structure
117 * @type: video device type (CAPTURE/OUTPUT)
118 * @pad: video device media (sink) pad
119 * @pending_buf_q: pending buffers queue head
120 * @active_buf_q: a queue head of buffers scheduled in hardware
121 * @vb_queue: vb2 buffer queue
122 * @active_buf_count: number of video buffers scheduled in hardware
123 * @frame_count: counter of frames dequeued to user space
124 * @reqbufs_count: number of buffers requested with REQBUFS ioctl
125 * @format: current pixel format
127 struct fimc_is_video {
128 struct exynos_video_entity ve;
129 enum v4l2_buf_type type;
130 struct media_pad pad;
131 struct list_head pending_buf_q;
132 struct list_head active_buf_q;
133 struct vb2_queue vb_queue;
134 unsigned int reqbufs_count;
135 unsigned int buf_count;
136 unsigned int buf_mask;
137 unsigned int frame_count;
138 int streaming;
139 struct isp_video_buf *buffers[FIMC_ISP_MAX_BUFS];
140 const struct fimc_fmt *format;
141 struct v4l2_pix_format_mplane pixfmt;
144 /* struct fimc_isp:state bit definitions */
145 #define ST_ISP_VID_CAP_BUF_PREP 0
146 #define ST_ISP_VID_CAP_STREAMING 1
149 * struct fimc_isp - FIMC-IS ISP data structure
150 * @pdev: pointer to FIMC-IS platform device
151 * @subdev: ISP v4l2_subdev
152 * @subdev_pads: the ISP subdev media pads
153 * @test_pattern: test pattern controls
154 * @ctrls: v4l2 controls structure
155 * @video_lock: mutex serializing video device and the subdev operations
156 * @cac_margin_x: horizontal CAC margin in pixels
157 * @cac_margin_y: vertical CAC margin in pixels
158 * @state: driver state flags
159 * @video_capture: the ISP block video capture device
161 struct fimc_isp {
162 struct platform_device *pdev;
163 struct v4l2_subdev subdev;
164 struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM];
165 struct v4l2_mbus_framefmt src_fmt;
166 struct v4l2_mbus_framefmt sink_fmt;
167 struct v4l2_ctrl *test_pattern;
168 struct fimc_isp_ctrls ctrls;
170 struct mutex video_lock;
171 struct mutex subdev_lock;
173 unsigned int cac_margin_x;
174 unsigned int cac_margin_y;
176 unsigned long state;
178 struct fimc_is_video video_capture;
181 #define ctrl_to_fimc_isp(_ctrl) \
182 container_of(ctrl->handler, struct fimc_isp, ctrls.handler)
184 struct fimc_is;
186 int fimc_isp_subdev_create(struct fimc_isp *isp);
187 void fimc_isp_subdev_destroy(struct fimc_isp *isp);
188 void fimc_isp_irq_handler(struct fimc_is *is);
189 int fimc_is_create_controls(struct fimc_isp *isp);
190 int fimc_is_delete_controls(struct fimc_isp *isp);
191 const struct fimc_fmt *fimc_isp_find_format(const u32 *pixelformat,
192 const u32 *mbus_code, int index);
193 #endif /* FIMC_ISP_H_ */