upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / media / video / samsung / ump / common / ump_uk_types.h
1 /*
2  * Copyright (C) 2010 ARM Limited. All rights reserved.
3  * 
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  * 
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10
11 /**
12  * @file ump_uk_types.h
13  * Defines the types and constants used in the user-kernel interface
14  */
15
16 #ifndef __UMP_UK_TYPES_H__
17 #define __UMP_UK_TYPES_H__
18
19 #ifdef __cplusplus
20 extern "C"
21 {
22 #endif
23
24 /* Helpers for API version handling */
25 #define MAKE_VERSION_ID(x) (((x) << 16UL) | (x))
26 #define IS_VERSION_ID(x) (((x) & 0xFFFF) == (((x) >> 16UL) & 0xFFFF))
27 #define GET_VERSION(x) (((x) >> 16UL) & 0xFFFF)
28 #define IS_API_MATCH(x, y) (IS_VERSION_ID((x)) && IS_VERSION_ID((y)) && (GET_VERSION((x)) == GET_VERSION((y))))
29
30 /**
31  * API version define.
32  * Indicates the version of the kernel API
33  * The version is a 16bit integer incremented on each API change.
34  * The 16bit integer is stored twice in a 32bit integer
35  * So for version 1 the value would be 0x00010001
36  */
37 #define UMP_IOCTL_API_VERSION MAKE_VERSION_ID(2)
38
39 typedef enum
40 {
41         _UMP_IOC_QUERY_API_VERSION = 1,
42         _UMP_IOC_ALLOCATE,
43         _UMP_IOC_RELEASE,
44         _UMP_IOC_SIZE_GET,
45         _UMP_IOC_MAP_MEM,    /* not used in Linux */
46         _UMP_IOC_UNMAP_MEM,  /* not used in Linux */
47         _UMP_IOC_MSYNC,
48 }_ump_uk_functions;
49
50 typedef enum
51 {
52         UMP_REF_DRV_UK_CONSTRAINT_NONE = 0,
53         UMP_REF_DRV_UK_CONSTRAINT_PHYSICALLY_LINEAR = 1,
54         UMP_REF_DRV_UK_CONSTRAINT_USE_CACHE = 128,
55 } ump_uk_alloc_constraints;
56
57 typedef enum
58 {
59         _UMP_UK_MSYNC_CLEAN = 0,
60         _UMP_UK_MSYNC_CLEAN_AND_INVALIDATE = 1,
61         _UMP_UK_MSYNC_CLEAN_ALL_AND_INVALIDATE_ALL = 2,
62         _UMP_UK_MSYNC_READOUT_CACHE_ENABLED = 128,
63 } ump_uk_msync_op;
64
65 /**
66  * Get API version ([in,out] u32 api_version, [out] u32 compatible)
67  */
68 typedef struct _ump_uk_api_version_s
69 {
70         void *ctx;      /**< [in,out] user-kernel context (trashed on output) */
71         u32 version;    /**< Set to the user space version on entry, stores the device driver version on exit */
72         u32 compatible; /**< Non-null if the device is compatible with the client */
73 } _ump_uk_api_version_s;
74
75 /**
76  * ALLOCATE ([out] u32 secure_id, [in,out] u32 size,  [in] contraints)
77  */
78 typedef struct _ump_uk_allocate_s
79 {
80         void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
81         u32 secure_id;                          /**< Return value from DD to Userdriver */
82         u32 size;                               /**< Input and output. Requested size; input. Returned size; output */
83         ump_uk_alloc_constraints constraints;   /**< Only input to Devicedriver */
84 } _ump_uk_allocate_s;
85
86 /**
87  * SIZE_GET ([in] u32 secure_id, [out]size )
88  */
89 typedef struct _ump_uk_size_get_s
90 {
91         void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
92         u32 secure_id;                          /**< Input to DD */
93         u32 size;                               /**< Returned size; output */
94 } _ump_uk_size_get_s;
95
96 /**
97  * Release ([in] u32 secure_id)
98  */
99 typedef struct _ump_uk_release_s
100 {
101         void *ctx;                              /**< [in,out] user-kernel context (trashed on output) */
102         u32 secure_id;                          /**< Input to DD */
103 } _ump_uk_release_s;
104
105 typedef struct _ump_uk_map_mem_s
106 {
107         void *ctx;                      /**< [in,out] user-kernel context (trashed on output) */
108         void *mapping;                  /**< [out] Returns user-space virtual address for the mapping */
109         void *phys_addr;                /**< [in] physical address */
110         unsigned long size;             /**< [in] size */
111         u32 secure_id;                  /**< [in] secure_id to assign to mapping */
112         void * _ukk_private;            /**< Only used inside linux port between kernel frontend and common part to store vma */
113         u32 cookie;
114         u32 is_cached;            /**< [in,out] caching of CPU mappings */
115 } _ump_uk_map_mem_s;
116
117 typedef struct _ump_uk_unmap_mem_s
118 {
119         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
120         void *mapping;
121         u32 size;
122         void * _ukk_private;
123         u32 cookie;
124 } _ump_uk_unmap_mem_s;
125
126 typedef struct _ump_uk_msync_s
127 {
128         void *ctx;            /**< [in,out] user-kernel context (trashed on output) */
129         void *mapping;        /**< [in] mapping addr */
130         void *address;        /**< [in] flush start addr */
131         u32 size;             /**< [in] size to flush */
132         ump_uk_msync_op op;   /**< [in] flush operation */
133         u32 cookie;           /**< [in] cookie stored with reference to the kernel mapping internals */
134         u32 secure_id;        /**< [in] cookie stored with reference to the kernel mapping internals */
135         u32 is_cached;        /**< [out] caching of CPU mappings */
136 } _ump_uk_msync_s;
137
138 #ifdef __cplusplus
139 }
140 #endif
141
142 #endif /* __UMP_UK_TYPES_H__ */