summaryrefstree
path: root/kernel/drivers/media/platform/exynos/camera/is-groupmgr.h
blob: 332096be855fdd6d66a53f590ad0da72cae64f24 (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*
 * 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 IS_GROUP_MGR_H
#define IS_GROUP_MGR_H

#include "is-config.h"
#include "is-time.h"
#include "is-subdev-ctrl.h"
#include "is-video.h"
#include "is-cmd.h"
#include "is_groupmgr_config.h"

enum is_group_state {
	IS_GROUP_OPEN,
	IS_GROUP_INIT,
	IS_GROUP_START,
	IS_GROUP_SHOT,
	IS_GROUP_REQUEST_FSTOP,
	IS_GROUP_FORCE_STOP,
	IS_GROUP_OTF_INPUT,
	IS_GROUP_OTF_OUTPUT,
	IS_GROUP_PIPE_INPUT,
	IS_GROUP_PIPE_OUTPUT,
	IS_GROUP_SEMI_PIPE_INPUT,
	IS_GROUP_SEMI_PIPE_OUTPUT,
	IS_GROUP_VOTF_INPUT,
	IS_GROUP_VOTF_OUTPUT,
	IS_GROUP_STANDBY,
};

enum is_group_input_type {
	GROUP_INPUT_MEMORY,
	GROUP_INPUT_OTF,
	GROUP_INPUT_PIPE,
	GROUP_INPUT_SEMI_PIPE,
	GROUP_INPUT_VOTF
};

struct is_frame;
struct is_device_ischain;
typedef int (*is_shot_callback)(struct is_device_ischain *device,
	struct is_frame *frame);
typedef int (*is_pipe_shot_callback)(struct is_device_ischain *device,
	struct is_group *group,
	struct is_frame *frame);

struct is_group_frame {
	struct list_head		list;
	u32				fcount;
	struct is_crop		canv;
	struct camera2_node_group	group_cfg[GROUP_SLOT_MAX];
};

struct is_group_framemgr {
	struct is_group_frame	*gframes;
	spinlock_t			gframe_slock;
	struct list_head		gframe_head;
	u32				gframe_cnt;
};

struct is_group {
	u32				instance;	/* logical stream id */
	u32				logical_id;	/* logical group id */
	u32				id;		/* physical group id */
	u32				sensor_id;	/* physical module enum */
	u32				slot;		/* physical group slot */

	struct is_hw_ip			*hw_ip;
	struct is_group			*next;
	struct is_group			*prev;
	struct is_group			*gnext;
	struct is_group			*gprev;
	struct is_group			*parent;
	struct is_group			*child;
	struct is_group			*head;
	struct is_group			*tail;

	struct is_subdev		leader;
	struct is_subdev		*junction;
	struct is_subdev		*subdev[ENTRY_END];
	struct is_framemgr		*locked_sub_framemgr[ENTRY_END];

	struct list_head		subdev_list;

	/* for otf interface */
	atomic_t			sensor_fcount;
	atomic_t			backup_fcount;
	struct semaphore		smp_trigger;
	atomic_t			smp_shot_count;
	u32				init_shots;
	u32				asyn_shots;
	u32				sync_shots;
	u32				skip_shots;

	struct camera2_aa_ctl		intent_ctl;
	struct camera2_lens_ctl		lens_ctl;

	u32				source_vid; /* source video id */
	u32				pcount; /* program count */
	u32				fcount; /* frame count */
	atomic_t			scount; /* shot count */
	atomic_t			rcount; /* request count */
	unsigned long			state;

	struct list_head		gframe_head;
	u32				gframe_cnt;

	is_shot_callback		shot_callback;
	is_pipe_shot_callback		pipe_shot_callback;
	struct is_device_ischain	*device;
	struct is_device_sensor		*sensor;
	enum is_device_type		device_type;

#ifdef DEBUG_AA
#ifdef DEBUG_FLASH
	enum aa_ae_flashmode		flashmode;
	struct camera2_flash_dm		flash;
#endif
#endif

#ifdef MEASURE_TIME
#ifdef MONITOR_TIME
	struct is_time		time;
#endif
#endif
	u32				aeflashMode; /* Flash Mode Control */
	u32				remainIntentCount;
};

enum is_group_task_state {
	IS_GTASK_START,
	IS_GTASK_REQUEST_STOP
};

struct is_group_task {
	u32				id;
	struct task_struct		*task;
	struct kthread_worker		worker;
	struct semaphore		smp_resource;
	unsigned long			state;
	atomic_t			refcount;

#ifdef ENABLE_SYNC_REPROCESSING
	atomic_t			rep_tick; /* Sync reprocessing tick */
	struct list_head		sync_list;
	atomic_t			preview_cnt[IS_STREAM_COUNT];
	struct list_head		preview_list[IS_STREAM_COUNT];
#endif
};

struct is_groupmgr {
	struct is_group_framemgr	gframemgr[IS_STREAM_COUNT];
	struct is_group		*leader[IS_STREAM_COUNT];
	struct is_group		*group[IS_STREAM_COUNT][GROUP_SLOT_MAX];
	struct is_group_task	gtask[GROUP_ID_MAX];
};

int is_groupmgr_probe(struct platform_device *pdev,
	struct is_groupmgr *groupmgr);
int is_groupmgr_init(struct is_groupmgr *groupmgr,
	struct is_device_ischain *device);
int is_groupmgr_start(struct is_groupmgr *groupmgr,
	struct is_device_ischain *device);
int is_groupmgr_stop(struct is_groupmgr *groupmgr,
	struct is_device_ischain *device);
int is_group_probe(struct is_groupmgr *groupmgr,
	struct is_group *group,
	struct is_device_sensor *sensor,
	struct is_device_ischain *device,
	is_shot_callback shot_callback,
	u32 slot,
	u32 id,
	char *name,
	const struct is_subdev_ops *sops);
int is_group_open(struct is_groupmgr *groupmgr,
	struct is_group *group, u32 id,
	struct is_video_ctx *vctx);
int is_group_close(struct is_groupmgr *groupmgr,
	struct is_group *group);
int is_group_init(struct is_groupmgr *groupmgr,
	struct is_group *group,
	u32 input_type,
	u32 video_id,
	u32 stream_leader);
int is_group_start(struct is_groupmgr *groupmgr,
	struct is_group *group);
int is_group_stop(struct is_groupmgr *groupmgr,
	struct is_group *group);
int is_group_buffer_queue(struct is_groupmgr *groupmgr,
	struct is_group *group,
	struct is_queue *queue,
	u32 index);
int is_group_buffer_finish(struct is_groupmgr *groupmgr,
	struct is_group *group, u32 index);
int is_group_shot(struct is_groupmgr *groupmgr,
	struct is_group *group,
	struct is_frame *frame);
int is_group_done(struct is_groupmgr *groupmgr,
	struct is_group *group,
	struct is_frame *frame,
	u32 done_state);

unsigned long is_group_lock(struct is_group *group,
		enum is_device_type device_type,
		bool leader_lock);
void is_group_unlock(struct is_group *group, unsigned long flags,
		enum is_device_type device_type,
		bool leader_lock);
void is_group_subdev_cancel(struct is_group *group,
		struct is_frame *ldr_frame,
		enum is_device_type device_type,
		enum is_frame_state frame_state,
		bool flush);

int is_group_change_chain(struct is_groupmgr *groupmgr, struct is_group *group, u32 next_id);

/* get head group's framemgr */
#define GET_HEAD_GROUP_FRAMEMGR(group) \
	(((group) && ((group)->head) && ((group)->head->leader.vctx)) ? (&((group)->head->leader).vctx->queue.framemgr) : NULL)
#endif