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