summaryrefstree
path: root/kernel/drivers/media/platform/exynos/fimc-is2/fimc-is-device-flite.h
blob: 98bfc59d77a5c2afc92e0194dda5d1f2c4b1b210 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * Samsung Exynos5 SoC series FIMC-IS driver
 *
 *
 * Copyright (c) 2011 Samsung Electronics Co., Ltd
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef FIMC_IS_DEVICE_FLITE_H
#define FIMC_IS_DEVICE_FLITE_H

#include <linux/interrupt.h>
#include "fimc-is-type.h"

#define EXPECT_FRAME_START	0
#define EXPECT_FRAME_END	1

#define FLITE_NOTIFY_FSTART	0
#define FLITE_NOTIFY_FEND	1

#define FLITE_ENABLE_FLAG	1
#define FLITE_ENABLE_MASK	0xFFFF
#define FLITE_ENABLE_SHIFT	0

#define FLITE_NOWAIT_FLAG	1
#define FLITE_NOWAIT_MASK	0xFFFF0000
#define FLITE_NOWAIT_SHIFT	16

#define FLITE_OVERFLOW_COUNT	10

#define FLITE_VVALID_TIME_BASE 32 /* ms */


struct fimc_is_device_sensor;

enum fimc_is_flite_state {
	/* finish state */
	FLITE_LAST_CAPTURE = 0,
	/* flite join ischain */
	FLITE_JOIN_ISCHAIN,
	/* one the fly output */
	FLITE_OTF_WITH_3AA,
	/* If it's dummy, H/W setting can't be applied */
	FLITE_DUMMY,
	/* WDMA flag */
	FLITE_DMA_ENABLE,
	FLITE_START_STREAM
};

enum fimc_is_flite_buf_done_mode {
	FLITE_BUF_DONE_NORMAL	= 0, /* when end-irq */
	FLITE_BUF_DONE_EARLY	= 1, /* when delayed work queue since start-irq */
};

/*
 * 10p means 10% early than end irq. We supposed that VVALID time is variable
 * ex. 32 * 0.1 = 3ms, early interval is (33 - 3) = 29ms
 *     32 * 0.2 = 6ms,                   (33 - 6) = 26ms
 *     32 * 0.3 = 9ms,                   (33 - 9) = 23ms
 *     32 * 0.4 = 12ms,                  (33 - 12) = 20ms
 */
enum fimc_is_flite_early_buf_done_mode {
	FLITE_BUF_EARLY_NOTHING	= 0,
	FLITE_BUF_EARLY_10P	= 1, /* 10%(29ms) 3ms */
	FLITE_BUF_EARLY_20P	= 2, /* 20%(26ms) 6ms */
	FLITE_BUF_EARLY_30P	= 3, /* 30%(23ms) 9ms */
	FLITE_BUF_EARLY_40P	= 4, /* 40%(20ms) 12ms */
};

struct fimc_is_device_flite {
	u32				instance;
	u32 __iomem			*base_reg;
	resource_size_t			regs_start;
	resource_size_t			regs_end;
	int				irq;
	unsigned long			state;
	wait_queue_head_t		wait_queue;

	struct fimc_is_image		image;
	struct fimc_is_framemgr		*framemgr;

	u32				overflow_cnt;

	u32				csi; /* which csi channel is connceted */
	u32				group; /* which 3aa gorup is connected when otf is enable */

	u32				sw_checker;
	atomic_t			fcount;
	u32				tasklet_param_str;
	struct tasklet_struct		tasklet_flite_str;
	u32				tasklet_param_end;
	struct tasklet_struct		tasklet_flite_end;

	/* for early buffer done */
	u32				buf_done_mode;
	u32				early_buf_done_mode;
	u32				buf_done_wait_time;
	bool				early_work_skip;
	bool				early_work_called;
	struct tasklet_struct		tasklet_flite_early_end;
	struct workqueue_struct		*early_workqueue;
	struct delayed_work		early_work_wq;
	void				(*chk_early_buf_done)(struct fimc_is_device_flite *flite, u32 framerate, u32 position);

	/* pointer address from device sensor */
	struct v4l2_subdev		**subdev;
};

int fimc_is_flite_probe(struct fimc_is_device_sensor *device,
	u32 instance);
int fimc_is_flite_open(struct v4l2_subdev *subdev,
	struct fimc_is_framemgr *framemgr);
int fimc_is_flite_close(struct v4l2_subdev *subdev);

extern u32 __iomem *notify_fcount_sen0;
extern u32 __iomem *notify_fcount_sen1;
extern u32 __iomem *notify_fcount_sen2;
extern u32 __iomem *notify_fcount_sen3;

#endif