Merge remote-tracking branch 'sound-asoc/for-next'
[deliverable/linux.git] / drivers / media / platform / exynos4-is / fimc-isp.h
CommitLineData
9a761e43
SN
1/*
2 * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
3 *
4 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
5 *
6 * Authors: Sylwester Nawrocki <s.nawrocki@samsung.com>
7 * Younghwan Joo <yhwan.joo@samsung.com>
8 *
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.
12 */
13#ifndef FIMC_ISP_H_
14#define FIMC_ISP_H_
15
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>
22
23#include <media/media-entity.h>
c139990e 24#include <media/videobuf2-v4l2.h>
9a761e43
SN
25#include <media/v4l2-device.h>
26#include <media/v4l2-mediabus.h>
d647f0b7 27#include <media/drv-intf/exynos-fimc.h>
9a761e43 28
4434adff
SN
29extern int fimc_isp_debug;
30
31#define isp_dbg(level, dev, fmt, arg...) \
32 v4l2_dbg(level, fimc_isp_debug, dev, fmt, ## arg)
33
9a761e43
SN
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
34947b8a 38#define FIMC_ISP_SOURCE_HEIGHT_MIN 8
9a761e43
SN
39#define FIMC_ISP_CAC_MARGIN_WIDTH 16
40#define FIMC_ISP_CAC_MARGIN_HEIGHT 12
41
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
34947b8a 45#define FIMC_ISP_SOURCE_HEIGHT_MAX 4000
9a761e43
SN
46
47#define FIMC_ISP_NUM_FORMATS 3
48#define FIMC_ISP_REQ_BUFS_MIN 2
34947b8a 49#define FIMC_ISP_REQ_BUFS_MAX 32
9a761e43
SN
50
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
56
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
62 */
63struct fimc_isp_frame {
64 u16 width;
65 u16 height;
66 struct v4l2_rect rect;
67};
68
69struct fimc_isp_ctrls {
70 struct v4l2_ctrl_handler handler;
71
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;
78 };
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;
89
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;
102};
103
34947b8a 104struct isp_video_buf {
2d700715 105 struct vb2_v4l2_buffer vb;
34947b8a
SN
106 dma_addr_t dma_addr[FIMC_ISP_MAX_PLANES];
107 unsigned int index;
108};
109
110#define to_isp_video_buf(_b) container_of(_b, struct isp_video_buf, vb)
111
112#define FIMC_ISP_MAX_BUFS 4
113
9a761e43
SN
114/**
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
126 */
127struct fimc_is_video {
34947b8a 128 struct exynos_video_entity ve;
9a761e43
SN
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;
9a761e43 134 unsigned int reqbufs_count;
34947b8a
SN
135 unsigned int buf_count;
136 unsigned int buf_mask;
137 unsigned int frame_count;
9a761e43 138 int streaming;
34947b8a 139 struct isp_video_buf *buffers[FIMC_ISP_MAX_BUFS];
9a761e43 140 const struct fimc_fmt *format;
34947b8a 141 struct v4l2_pix_format_mplane pixfmt;
9a761e43
SN
142};
143
34947b8a
SN
144/* struct fimc_isp:state bit definitions */
145#define ST_ISP_VID_CAP_BUF_PREP 0
146#define ST_ISP_VID_CAP_STREAMING 1
147
9a761e43
SN
148/**
149 * struct fimc_isp - FIMC-IS ISP data structure
150 * @pdev: pointer to FIMC-IS platform device
9a761e43
SN
151 * @subdev: ISP v4l2_subdev
152 * @subdev_pads: the ISP subdev media pads
9a761e43 153 * @test_pattern: test pattern controls
f525e176 154 * @ctrls: v4l2 controls structure
9a761e43 155 * @video_lock: mutex serializing video device and the subdev operations
9a761e43
SN
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
160 */
161struct fimc_isp {
162 struct platform_device *pdev;
9a761e43
SN
163 struct v4l2_subdev subdev;
164 struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM];
5cfaad64
SN
165 struct v4l2_mbus_framefmt src_fmt;
166 struct v4l2_mbus_framefmt sink_fmt;
9a761e43
SN
167 struct v4l2_ctrl *test_pattern;
168 struct fimc_isp_ctrls ctrls;
169
170 struct mutex video_lock;
171 struct mutex subdev_lock;
172
9a761e43
SN
173 unsigned int cac_margin_x;
174 unsigned int cac_margin_y;
175
176 unsigned long state;
177
178 struct fimc_is_video video_capture;
179};
180
181#define ctrl_to_fimc_isp(_ctrl) \
182 container_of(ctrl->handler, struct fimc_isp, ctrls.handler)
183
184struct fimc_is;
185
186int fimc_isp_subdev_create(struct fimc_isp *isp);
187void fimc_isp_subdev_destroy(struct fimc_isp *isp);
188void fimc_isp_irq_handler(struct fimc_is *is);
189int fimc_is_create_controls(struct fimc_isp *isp);
190int fimc_is_delete_controls(struct fimc_isp *isp);
191const struct fimc_fmt *fimc_isp_find_format(const u32 *pixelformat,
192 const u32 *mbus_code, int index);
193#endif /* FIMC_ISP_H_ */
This page took 0.276571 seconds and 5 git commands to generate.