aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/samsung/mfc5x/mfc_inst.h
blob: e297c55ce8eaacd3122adc35e0e101213422aac9 (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
/*
 * linux/drivers/media/video/samsung/mfc5x/mfc_inst.h
 *
 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com/
 *
 * Instance manager file for Samsung MFC (Multi Function Codec - FIMV) driver
 *
 * 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 __MFC_INST_H
#define __MFC_INST_H __FILE__

#include <linux/list.h>

#include "mfc.h"
#include "mfc_interface.h"


/* FIXME: instance state should be more specific */
enum instance_state {
	INST_STATE_NULL		= 0,

	/* open */
	INST_STATE_CREATE	= 0x0001,

	/* ioctl - *_INIT */
	INST_STATE_SETUP	= 0x0004,

	/* ioctl - *_INIT */
	INST_STATE_OPEN		= 0x0010,
	INST_STATE_INIT,

	/* ioctl - *_EXE */
	INST_STATE_EXE		= 0x0020,
	INST_STATE_EXE_DONE,
};

struct mfc_inst_ctx;

struct codec_operations {
	/* initialization routines */
	int (*alloc_ctx_buf) (struct mfc_inst_ctx *ctx);
	int (*alloc_desc_buf) (struct mfc_inst_ctx *ctx);
	int (*get_init_arg) (struct mfc_inst_ctx *ctx, void *arg);
	int (*pre_seq_start) (struct mfc_inst_ctx *ctx);
	int (*post_seq_start) (struct mfc_inst_ctx *ctx);
	int (*set_init_arg) (struct mfc_inst_ctx *ctx, void *arg);
	int (*set_codec_bufs) (struct mfc_inst_ctx *ctx);
	int (*set_dpbs) (struct mfc_inst_ctx *ctx);		/* decoder */
	/* execution routines */
	int (*get_exe_arg) (struct mfc_inst_ctx *ctx, void *arg);
	int (*pre_frame_start) (struct mfc_inst_ctx *ctx);
	int (*post_frame_start) (struct mfc_inst_ctx *ctx);
	int (*multi_data_frame) (struct mfc_inst_ctx *ctx);
	int (*set_exe_arg) (struct mfc_inst_ctx *ctx, void *arg);
	/* configuration routines */
	int (*get_codec_cfg) (struct mfc_inst_ctx *ctx, int type, void *arg);
	int (*set_codec_cfg) (struct mfc_inst_ctx *ctx, int type, void *arg);
};

struct mfc_pre_cfg {
	struct list_head list;
	unsigned int type;
	unsigned int values[4];
};

struct mfc_dec_cfg {
	unsigned int crc;
	unsigned int pixelcache;
	unsigned int slice;
	unsigned int numextradpb;

	unsigned int postfilter;	/* MPEG4 */
	unsigned int dispdelay_en;	/* H.264 */
	unsigned int dispdelay_val;	/* H.264 */
	unsigned int width;		/* FIMV1 */
	unsigned int height;		/* FIMV1 */
};

struct mfc_enc_cfg {
	/*
	type:
	  init
	  runtime
	  init + runtime
	*/

	/* init */
	unsigned int pixelcache;

	unsigned int frameskip;
	unsigned int frammode;
	unsigned int hier_p;

	/* runtime ? */
	#if 0
	unsigned int frametype;
	unsigned int framerate;
	unsigned int bitrate;
	unsigned int vui;		/* H.264 */
	unsigned int hec;		/* MPEG4 */
	unsigned int seqhdrctrl;

	unsigned int i_period;
	#endif
};

enum mfc_resolution_status {
	RES_INCREASED = 1,
	RES_DECERASED = 2,
};

enum mfc_resolution_change_status {
	RES_NO_CHANGE = 0,
	RES_SET_CHANGE = 1,
	RES_SET_REALLOC = 2,
	RES_WAIT_FRAME_DONE = 3,
};

struct mfc_inst_ctx {
	int id;				/* assigned by driver */
	int cmd_id;			/* assigned by F/W */
	int codecid;
	unsigned int type;
	enum instance_state state;
	unsigned int width;
	unsigned int height;
	volatile unsigned char *shm;
	unsigned int shmofs;
	unsigned int ctxbufofs;
	unsigned int ctxbufsize;
	unsigned int descbufofs;	/* FIXME: move to decoder context */
	unsigned int descbufsize;	/* FIXME: move to decoder context */
	unsigned long userbase;
	SSBIP_MFC_BUFFER_TYPE buf_cache_type;

	int resolution_status;
	/*
	struct mfc_dec_cfg deccfg;
	struct mfc_enc_cfg enccfg;
	*/
	struct list_head presetcfgs;

	void *c_priv;
	struct codec_operations *c_ops;
	struct mfc_dev *dev;
#ifdef SYSMMU_MFC_ON
	unsigned long pgd;
#endif
#if defined(CONFIG_BUSFREQ)
	int busfreq_flag;		/* context bus frequency flag */
#endif

#if defined(CONFIG_CPU_EXYNOS4210) && defined(CONFIG_EXYNOS4_CPUFREQ)
	int cpufreq_flag; /* context CPU frequency flag*/
#endif

#ifdef CONFIG_EXYNOS_CONTENT_PATH_PROTECTION
	int drm_flag;
#endif

#ifdef CONFIG_BUSFREQ_OPP
	int dmcthreshold_flag;  /* context dmc max threshold flag */
#endif

#if SUPPORT_SLICE_ENCODING
	int slice_flag;
#endif
};

struct mfc_inst_ctx *mfc_create_inst(void);
void mfc_destroy_inst(struct mfc_inst_ctx *ctx);
int mfc_set_inst_state(struct mfc_inst_ctx *ctx, enum instance_state state);
int mfc_chk_inst_state(struct mfc_inst_ctx *ctx, enum instance_state state);
int mfc_set_inst_cfg(struct mfc_inst_ctx *ctx, int type, void *arg);
int mfc_get_inst_cfg(struct mfc_inst_ctx *ctx, int type, void *arg);

#endif /* __MFC_INST_H */