[media] exynos4-is: Correct input DMA YUV order configuration
[deliverable/linux.git] / drivers / media / platform / exynos4-is / fimc-lite.h
CommitLineData
2b511edb
SN
1/*
2 * Copyright (C) 2012 Samsung Electronics Co., Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef FIMC_LITE_H_
10#define FIMC_LITE_H_
11
25422781 12#include <linux/sizes.h>
2b511edb
SN
13#include <linux/io.h>
14#include <linux/irqreturn.h>
15#include <linux/platform_device.h>
16#include <linux/sched.h>
17#include <linux/spinlock.h>
18#include <linux/types.h>
19#include <linux/videodev2.h>
20
21#include <media/media-entity.h>
22#include <media/videobuf2-core.h>
80f958f4 23#include <media/v4l2-ctrls.h>
2b511edb
SN
24#include <media/v4l2-device.h>
25#include <media/v4l2-mediabus.h>
26#include <media/s5p_fimc.h>
27
2b511edb
SN
28#define FIMC_LITE_DRV_NAME "exynos-fimc-lite"
29#define FLITE_CLK_NAME "flite"
30#define FIMC_LITE_MAX_DEVS 2
31#define FLITE_REQ_BUFS_MIN 2
32
33/* Bit index definitions for struct fimc_lite::state */
34enum {
35 ST_FLITE_LPM,
36 ST_FLITE_PENDING,
37 ST_FLITE_RUN,
38 ST_FLITE_STREAM,
39 ST_FLITE_SUSPENDED,
40 ST_FLITE_OFF,
41 ST_FLITE_IN_USE,
42 ST_FLITE_CONFIG,
43 ST_SENSOR_STREAM,
44};
45
46#define FLITE_SD_PAD_SINK 0
6319d6a0
SN
47#define FLITE_SD_PAD_SOURCE_DMA 1
48#define FLITE_SD_PAD_SOURCE_ISP 2
49#define FLITE_SD_PADS_NUM 3
2b511edb 50
9c8399c8 51struct flite_drvdata {
2b511edb
SN
52 unsigned short max_width;
53 unsigned short max_height;
54 unsigned short out_width_align;
55 unsigned short win_hor_offs_align;
56 unsigned short out_hor_offs_align;
57};
58
2b511edb
SN
59#define fimc_lite_get_drvdata(_pdev) \
60 ((struct flite_drvdata *) platform_get_device_id(_pdev)->driver_data)
61
62struct fimc_lite_events {
63 unsigned int data_overflow;
64};
65
66#define FLITE_MAX_PLANES 1
67
68/**
69 * struct flite_frame - source/target frame properties
70 * @f_width: full pixel width
71 * @f_height: full pixel height
72 * @rect: crop/composition rectangle
e90ad659 73 * @fmt: pointer to pixel format description data structure
2b511edb
SN
74 */
75struct flite_frame {
76 u16 f_width;
77 u16 f_height;
78 struct v4l2_rect rect;
e90ad659 79 const struct fimc_fmt *fmt;
2b511edb
SN
80};
81
82/**
83 * struct flite_buffer - video buffer structure
84 * @vb: vb2 buffer
85 * @list: list head for the buffers queue
86 * @paddr: precalculated physical address
87 */
88struct flite_buffer {
89 struct vb2_buffer vb;
90 struct list_head list;
91 dma_addr_t paddr;
92};
93
94/**
95 * struct fimc_lite - fimc lite structure
96 * @pdev: pointer to FIMC-LITE platform device
9c8399c8 97 * @dd: SoC specific driver data structure
2b511edb
SN
98 * @v4l2_dev: pointer to top the level v4l2_device
99 * @vfd: video device node
100 * @fh: v4l2 file handle
101 * @alloc_ctx: videobuf2 memory allocator context
102 * @subdev: FIMC-LITE subdev
103 * @vd_pad: media (sink) pad for the capture video node
104 * @subdev_pads: the subdev media pads
6319d6a0 105 * @sensor: sensor subdev attached to FIMC-LITE directly or through MIPI-CSIS
2b511edb
SN
106 * @ctrl_handler: v4l2 control handler
107 * @test_pattern: test pattern controls
108 * @index: FIMC-LITE platform device index
109 * @pipeline: video capture pipeline data structure
b9ee31e6 110 * @pipeline_ops: media pipeline ops for the video node driver
2b511edb
SN
111 * @slock: spinlock protecting this data structure and the hw registers
112 * @lock: mutex serializing video device and the subdev operations
113 * @clock: FIMC-LITE gate clock
114 * @regs: memory mapped io registers
115 * @irq_queue: interrupt handler waitqueue
2b511edb
SN
116 * @payload: image size in bytes (w x h x bpp)
117 * @inp_frame: camera input frame structure
118 * @out_frame: DMA output frame structure
119 * @out_path: output data path (DMA or FIFO)
120 * @source_subdev_grp_id: source subdev group id
121 * @state: driver state flags
122 * @pending_buf_q: pending buffers queue head
123 * @active_buf_q: the queue head of buffers scheduled in hardware
124 * @vb_queue: vb2 buffers queue
125 * @active_buf_count: number of video buffers scheduled in hardware
126 * @frame_count: the captured frames counter
127 * @reqbufs_count: the number of buffers requested with REQBUFS ioctl
128 * @ref_count: driver's private reference counter
129 */
130struct fimc_lite {
131 struct platform_device *pdev;
9c8399c8 132 struct flite_drvdata *dd;
2b511edb 133 struct v4l2_device *v4l2_dev;
1bcd7041 134 struct video_device vfd;
2b511edb
SN
135 struct v4l2_fh fh;
136 struct vb2_alloc_ctx *alloc_ctx;
137 struct v4l2_subdev subdev;
138 struct media_pad vd_pad;
139 struct media_pad subdev_pads[FLITE_SD_PADS_NUM];
6319d6a0 140 struct v4l2_subdev *sensor;
2b511edb
SN
141 struct v4l2_ctrl_handler ctrl_handler;
142 struct v4l2_ctrl *test_pattern;
143 u32 index;
144 struct fimc_pipeline pipeline;
b9ee31e6 145 const struct fimc_pipeline_ops *pipeline_ops;
2b511edb
SN
146
147 struct mutex lock;
148 spinlock_t slock;
149
150 struct clk *clock;
151 void __iomem *regs;
152 wait_queue_head_t irq_queue;
153
2b511edb
SN
154 unsigned long payload[FLITE_MAX_PLANES];
155 struct flite_frame inp_frame;
156 struct flite_frame out_frame;
03878bb4 157 atomic_t out_path;
2b511edb
SN
158 unsigned int source_subdev_grp_id;
159
160 unsigned long state;
161 struct list_head pending_buf_q;
162 struct list_head active_buf_q;
163 struct vb2_queue vb_queue;
164 unsigned int frame_count;
165 unsigned int reqbufs_count;
166 int ref_count;
167
168 struct fimc_lite_events events;
169};
170
171static inline bool fimc_lite_active(struct fimc_lite *fimc)
172{
173 unsigned long flags;
174 bool ret;
175
176 spin_lock_irqsave(&fimc->slock, flags);
177 ret = fimc->state & (1 << ST_FLITE_RUN) ||
178 fimc->state & (1 << ST_FLITE_PENDING);
179 spin_unlock_irqrestore(&fimc->slock, flags);
180 return ret;
181}
182
183static inline void fimc_lite_active_queue_add(struct fimc_lite *dev,
184 struct flite_buffer *buf)
185{
186 list_add_tail(&buf->list, &dev->active_buf_q);
187}
188
189static inline struct flite_buffer *fimc_lite_active_queue_pop(
190 struct fimc_lite *dev)
191{
192 struct flite_buffer *buf = list_entry(dev->active_buf_q.next,
193 struct flite_buffer, list);
194 list_del(&buf->list);
195 return buf;
196}
197
198static inline void fimc_lite_pending_queue_add(struct fimc_lite *dev,
199 struct flite_buffer *buf)
200{
201 list_add_tail(&buf->list, &dev->pending_buf_q);
202}
203
204static inline struct flite_buffer *fimc_lite_pending_queue_pop(
205 struct fimc_lite *dev)
206{
207 struct flite_buffer *buf = list_entry(dev->pending_buf_q.next,
208 struct flite_buffer, list);
209 list_del(&buf->list);
210 return buf;
211}
212
213#endif /* FIMC_LITE_H_ */
This page took 0.089993 seconds and 5 git commands to generate.