tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / mali / linux / mali_ukk_pp.c
1 /*
2  * Copyright (C) 2011-2012 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 #include <linux/fs.h>       /* file system operations */
11 #include <asm/uaccess.h>    /* user space access */
12
13 #include "mali_ukk.h"
14 #include "mali_osk.h"
15 #include "mali_kernel_common.h"
16 #include "mali_session.h"
17 #include "mali_ukk_wrappers.h"
18
19 int pp_start_job_wrapper(struct mali_session_data *session_data, _mali_uk_pp_start_job_s __user *uargs)
20 {
21         _mali_osk_errcode_t err;
22         int fence = -1;
23
24         MALI_CHECK_NON_NULL(uargs, -EINVAL);
25         MALI_CHECK_NON_NULL(session_data, -EINVAL);
26
27         err = _mali_ukk_pp_start_job(session_data, uargs, &fence);
28         if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
29
30         if (-1 != fence)
31         {
32                 if (0 != put_user(fence, &uargs->fence)) return -EFAULT;
33         }
34
35         return 0;
36 }
37
38 int pp_get_number_of_cores_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_number_of_cores_s __user *uargs)
39 {
40     _mali_uk_get_pp_number_of_cores_s kargs;
41     _mali_osk_errcode_t err;
42
43     MALI_CHECK_NON_NULL(uargs, -EINVAL);
44     MALI_CHECK_NON_NULL(session_data, -EINVAL);
45
46     kargs.ctx = session_data;
47     err = _mali_ukk_get_pp_number_of_cores(&kargs);
48     if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
49
50     if (0 != put_user(kargs.number_of_cores, &uargs->number_of_cores)) return -EFAULT;
51
52     return 0;
53 }
54
55 int pp_get_core_version_wrapper(struct mali_session_data *session_data, _mali_uk_get_pp_core_version_s __user *uargs)
56 {
57     _mali_uk_get_pp_core_version_s kargs;
58     _mali_osk_errcode_t err;
59
60     MALI_CHECK_NON_NULL(uargs, -EINVAL);
61     MALI_CHECK_NON_NULL(session_data, -EINVAL);
62
63     kargs.ctx = session_data;
64     err = _mali_ukk_get_pp_core_version(&kargs);
65     if (_MALI_OSK_ERR_OK != err) return map_errcode(err);
66
67     if (0 != put_user(kargs.version, &uargs->version)) return -EFAULT;
68
69     return 0;
70 }
71
72 int pp_disable_wb_wrapper(struct mali_session_data *session_data, _mali_uk_pp_disable_wb_s __user *uargs)
73 {
74         _mali_uk_pp_disable_wb_s kargs;
75
76     MALI_CHECK_NON_NULL(uargs, -EINVAL);
77     MALI_CHECK_NON_NULL(session_data, -EINVAL);
78
79     if (0 != copy_from_user(&kargs, uargs, sizeof(_mali_uk_pp_disable_wb_s))) return -EFAULT;
80
81     kargs.ctx = session_data;
82     _mali_ukk_pp_job_disable_wb(&kargs);
83
84     return 0;
85 }