upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / media / video / samsung / mfc5x / mfc_inst.h
1 /*
2  * linux/drivers/media/video/samsung/mfc5x/mfc_inst.h
3  *
4  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5  *              http://www.samsung.com/
6  *
7  * Instance manager file for Samsung MFC (Multi Function Codec - FIMV) driver
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #ifndef __MFC_INST_H
15 #define __MFC_INST_H __FILE__
16
17 #include <linux/list.h>
18
19 #include "mfc.h"
20 #include "mfc_interface.h"
21
22
23 /* FIXME: instance state should be more specific */
24 enum instance_state {
25         INST_STATE_NULL         = 0,
26
27         /* open */
28         INST_STATE_CREATE       = 0x0001,
29
30         /* ioctl - *_INIT */
31         INST_STATE_SETUP        = 0x0004,
32
33         /* ioctl - *_INIT */
34         INST_STATE_OPEN         = 0x0010,
35         INST_STATE_INIT,
36
37         /* ioctl - *_EXE */
38         INST_STATE_EXE          = 0x0020,
39         INST_STATE_EXE_DONE,
40 };
41
42 struct mfc_inst_ctx;
43
44 struct codec_operations {
45         /* initialization routines */
46         int (*alloc_ctx_buf) (struct mfc_inst_ctx *ctx);
47         int (*alloc_desc_buf) (struct mfc_inst_ctx *ctx);
48         int (*get_init_arg) (struct mfc_inst_ctx *ctx, void *arg);
49         int (*pre_seq_start) (struct mfc_inst_ctx *ctx);
50         int (*post_seq_start) (struct mfc_inst_ctx *ctx);
51         int (*set_init_arg) (struct mfc_inst_ctx *ctx, void *arg);
52         int (*set_codec_bufs) (struct mfc_inst_ctx *ctx);
53         int (*set_dpbs) (struct mfc_inst_ctx *ctx);             /* decoder */
54         /* execution routines */
55         int (*get_exe_arg) (struct mfc_inst_ctx *ctx, void *arg);
56         int (*pre_frame_start) (struct mfc_inst_ctx *ctx);
57         int (*post_frame_start) (struct mfc_inst_ctx *ctx);
58         int (*multi_data_frame) (struct mfc_inst_ctx *ctx);
59         int (*set_exe_arg) (struct mfc_inst_ctx *ctx, void *arg);
60         /* configuration routines */
61         int (*get_codec_cfg) (struct mfc_inst_ctx *ctx, unsigned int type, int *value);
62         int (*set_codec_cfg) (struct mfc_inst_ctx *ctx, unsigned int type, int *value);
63 };
64
65 struct mfc_pre_cfg {
66         struct list_head list;
67         unsigned int type;
68         unsigned int value[4];
69 };
70
71 struct mfc_dec_cfg {
72         unsigned int crc;
73         unsigned int pixelcache;
74         unsigned int slice;
75         unsigned int numextradpb;
76
77         unsigned int postfilter;        /* MPEG4 */
78         unsigned int dispdelay_en;      /* H.264 */
79         unsigned int dispdelay_val;     /* H.264 */
80         unsigned int width;             /* FIMV1 */
81         unsigned int height;            /* FIMV1 */
82 };
83
84 struct mfc_enc_cfg {
85         /*
86         type:
87           init
88           runtime
89           init + runtime
90         */
91
92         /* init */
93         unsigned int pixelcache;
94
95         unsigned int frameskip;
96         unsigned int frammode;
97         unsigned int hier_p;
98
99         /* runtime ? */
100         #if 0
101         unsigned int frametype;
102         unsigned int framerate;
103         unsigned int bitrate;
104         unsigned int vui;               /* H.264 */
105         unsigned int hec;               /* MPEG4 */
106         unsigned int seqhdrctrl;
107
108         unsigned int i_period;
109         #endif
110 };
111
112 enum mfc_resolution_status {
113         RES_INCREASED = 1,
114         RES_DECERASED = 2,
115 };
116
117 enum mfc_resolution_change_status {
118         RES_NO_CHANGE = 0,
119         RES_SET_CHANGE = 1,
120         RES_SET_REALLOC = 2,
121         RES_WAIT_FRAME_DONE = 3,
122 };
123
124 struct mfc_inst_ctx {
125         int id;                         /* assigned by driver */
126         int cmd_id;                     /* assigned by F/W */
127         int codecid;
128         unsigned int type;
129         enum instance_state state;
130         unsigned int width;
131         unsigned int height;
132         volatile unsigned char *shm;
133         unsigned int shmofs;
134         unsigned int ctxbufofs;
135         unsigned int ctxbufsize;
136         unsigned int descbufofs;        /* FIXME: move to decoder context */
137         unsigned int descbufsize;       /* FIXME: move to decoder context */
138         unsigned long userbase;
139         SSBIP_MFC_BUFFER_TYPE buf_cache_type;
140
141         int resolution_status;
142         /*
143         struct mfc_dec_cfg deccfg;
144         struct mfc_enc_cfg enccfg;
145         */
146         struct list_head presetcfgs;
147
148         void *c_priv;
149         struct codec_operations *c_ops;
150         struct mfc_dev *dev;
151 #ifdef SYSMMU_MFC_ON
152         unsigned long pgd;
153 #endif
154 #ifdef CONFIG_CPU_FREQ
155         int busfreq_flag; /* context bus frequency flag*/
156 #endif
157 };
158
159 struct mfc_inst_ctx *mfc_create_inst(void);
160 void mfc_destroy_inst(struct mfc_inst_ctx* ctx);
161 int mfc_set_inst_state(struct mfc_inst_ctx *ctx, enum instance_state state);
162 int mfc_chk_inst_state(struct mfc_inst_ctx *ctx, enum instance_state state);
163 int mfc_set_inst_cfg(struct mfc_inst_ctx *ctx, unsigned int type, int *value);
164
165 #endif /* __MFC_INST_H */