[media] exynos4-is: Drop drvdata handling in fimc-lite for non-dt platforms
[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
59struct fimc_lite_events {
60 unsigned int data_overflow;
61};
62
63#define FLITE_MAX_PLANES 1
64
65/**
66 * struct flite_frame - source/target frame properties
67 * @f_width: full pixel width
68 * @f_height: full pixel height
69 * @rect: crop/composition rectangle
e90ad659 70 * @fmt: pointer to pixel format description data structure
2b511edb
SN
71 */
72struct flite_frame {
73 u16 f_width;
74 u16 f_height;
75 struct v4l2_rect rect;
e90ad659 76 const struct fimc_fmt *fmt;
2b511edb
SN
77};
78
79/**
80 * struct flite_buffer - video buffer structure
81 * @vb: vb2 buffer
82 * @list: list head for the buffers queue
83 * @paddr: precalculated physical address
84 */
85struct flite_buffer {
86 struct vb2_buffer vb;
87 struct list_head list;
88 dma_addr_t paddr;
89};
90
91/**
92 * struct fimc_lite - fimc lite structure
93 * @pdev: pointer to FIMC-LITE platform device
9c8399c8 94 * @dd: SoC specific driver data structure
bc7584b0 95 * @ve: exynos video device entity structure
2b511edb 96 * @v4l2_dev: pointer to top the level v4l2_device
2b511edb
SN
97 * @fh: v4l2 file handle
98 * @alloc_ctx: videobuf2 memory allocator context
99 * @subdev: FIMC-LITE subdev
100 * @vd_pad: media (sink) pad for the capture video node
101 * @subdev_pads: the subdev media pads
6319d6a0 102 * @sensor: sensor subdev attached to FIMC-LITE directly or through MIPI-CSIS
2b511edb
SN
103 * @ctrl_handler: v4l2 control handler
104 * @test_pattern: test pattern controls
105 * @index: FIMC-LITE platform device index
106 * @pipeline: video capture pipeline data structure
b9ee31e6 107 * @pipeline_ops: media pipeline ops for the video node driver
2b511edb
SN
108 * @slock: spinlock protecting this data structure and the hw registers
109 * @lock: mutex serializing video device and the subdev operations
110 * @clock: FIMC-LITE gate clock
111 * @regs: memory mapped io registers
112 * @irq_queue: interrupt handler waitqueue
2b511edb
SN
113 * @payload: image size in bytes (w x h x bpp)
114 * @inp_frame: camera input frame structure
115 * @out_frame: DMA output frame structure
116 * @out_path: output data path (DMA or FIFO)
117 * @source_subdev_grp_id: source subdev group id
118 * @state: driver state flags
119 * @pending_buf_q: pending buffers queue head
120 * @active_buf_q: the queue head of buffers scheduled in hardware
121 * @vb_queue: vb2 buffers queue
122 * @active_buf_count: number of video buffers scheduled in hardware
123 * @frame_count: the captured frames counter
124 * @reqbufs_count: the number of buffers requested with REQBUFS ioctl
2b511edb
SN
125 */
126struct fimc_lite {
127 struct platform_device *pdev;
9c8399c8 128 struct flite_drvdata *dd;
bc7584b0 129 struct exynos_video_entity ve;
2b511edb 130 struct v4l2_device *v4l2_dev;
2b511edb
SN
131 struct v4l2_fh fh;
132 struct vb2_alloc_ctx *alloc_ctx;
133 struct v4l2_subdev subdev;
134 struct media_pad vd_pad;
135 struct media_pad subdev_pads[FLITE_SD_PADS_NUM];
6319d6a0 136 struct v4l2_subdev *sensor;
2b511edb
SN
137 struct v4l2_ctrl_handler ctrl_handler;
138 struct v4l2_ctrl *test_pattern;
068b16b6 139 int index;
2b511edb
SN
140
141 struct mutex lock;
142 spinlock_t slock;
143
144 struct clk *clock;
145 void __iomem *regs;
146 wait_queue_head_t irq_queue;
147
2b511edb
SN
148 unsigned long payload[FLITE_MAX_PLANES];
149 struct flite_frame inp_frame;
150 struct flite_frame out_frame;
03878bb4 151 atomic_t out_path;
2b511edb
SN
152 unsigned int source_subdev_grp_id;
153
154 unsigned long state;
155 struct list_head pending_buf_q;
156 struct list_head active_buf_q;
157 struct vb2_queue vb_queue;
158 unsigned int frame_count;
159 unsigned int reqbufs_count;
2b511edb
SN
160
161 struct fimc_lite_events events;
9ea89e2b 162 bool streaming;
2b511edb
SN
163};
164
165static inline bool fimc_lite_active(struct fimc_lite *fimc)
166{
167 unsigned long flags;
168 bool ret;
169
170 spin_lock_irqsave(&fimc->slock, flags);
171 ret = fimc->state & (1 << ST_FLITE_RUN) ||
172 fimc->state & (1 << ST_FLITE_PENDING);
173 spin_unlock_irqrestore(&fimc->slock, flags);
174 return ret;
175}
176
177static inline void fimc_lite_active_queue_add(struct fimc_lite *dev,
178 struct flite_buffer *buf)
179{
180 list_add_tail(&buf->list, &dev->active_buf_q);
181}
182
183static inline struct flite_buffer *fimc_lite_active_queue_pop(
184 struct fimc_lite *dev)
185{
186 struct flite_buffer *buf = list_entry(dev->active_buf_q.next,
187 struct flite_buffer, list);
188 list_del(&buf->list);
189 return buf;
190}
191
192static inline void fimc_lite_pending_queue_add(struct fimc_lite *dev,
193 struct flite_buffer *buf)
194{
195 list_add_tail(&buf->list, &dev->pending_buf_q);
196}
197
198static inline struct flite_buffer *fimc_lite_pending_queue_pop(
199 struct fimc_lite *dev)
200{
201 struct flite_buffer *buf = list_entry(dev->pending_buf_q.next,
202 struct flite_buffer, list);
203 list_del(&buf->list);
204 return buf;
205}
206
207#endif /* FIMC_LITE_H_ */
This page took 0.098223 seconds and 5 git commands to generate.