tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / mali / common / mali_gp_job.h
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
11 #ifndef __MALI_GP_JOB_H__
12 #define __MALI_GP_JOB_H__
13
14 #include "mali_osk.h"
15 #include "mali_osk_list.h"
16 #include "mali_uk_types.h"
17 #include "mali_session.h"
18
19 /**
20  * The structure represents a GP job, including all sub-jobs
21  * (This struct unfortunately needs to be public because of how the _mali_osk_list_*
22  * mechanism works)
23  */
24 struct mali_gp_job
25 {
26         _mali_osk_list_t list;                             /**< Used to link jobs together in the scheduler queue */
27         struct mali_session_data *session;                 /**< Session which submitted this job */
28         _mali_uk_gp_start_job_s uargs;                     /**< Arguments from user space */
29         u32 id;                                            /**< identifier for this job in kernel space (sequential numbering) */
30         u32 heap_current_addr;                             /**< Holds the current HEAP address when the job has completed */
31         u32 perf_counter_value0;                           /**< Value of performance counter 0 (to be returned to user space) */
32         u32 perf_counter_value1;                           /**< Value of performance counter 1 (to be returned to user space) */
33         u32 pid;                                           /**< Process ID of submitting process */
34         u32 tid;                                           /**< Thread ID of submitting thread */
35         _mali_osk_notification_t *finished_notification;   /**< Notification sent back to userspace on job complete */
36         _mali_osk_notification_t *oom_notification;        /**< Notification sent back to userspace on OOM */
37 };
38
39 struct mali_gp_job *mali_gp_job_create(struct mali_session_data *session, _mali_uk_gp_start_job_s *uargs, u32 id);
40 void mali_gp_job_delete(struct mali_gp_job *job);
41
42 u32 mali_gp_job_get_gp_counter_src0(void);
43 mali_bool mali_gp_job_set_gp_counter_src0(u32 counter);
44 u32 mali_gp_job_get_gp_counter_src1(void);
45 mali_bool mali_gp_job_set_gp_counter_src1(u32 counter);
46
47 MALI_STATIC_INLINE u32 mali_gp_job_get_id(struct mali_gp_job *job)
48 {
49         return (NULL == job) ? 0 : job->id;
50 }
51
52 MALI_STATIC_INLINE u32 mali_gp_job_get_user_id(struct mali_gp_job *job)
53 {
54         return job->uargs.user_job_ptr;
55 }
56
57 MALI_STATIC_INLINE u32 mali_gp_job_get_frame_builder_id(struct mali_gp_job *job)
58 {
59         return job->uargs.frame_builder_id;
60 }
61
62 MALI_STATIC_INLINE u32 mali_gp_job_get_flush_id(struct mali_gp_job *job)
63 {
64         return job->uargs.flush_id;
65 }
66
67 MALI_STATIC_INLINE u32 mali_gp_job_get_pid(struct mali_gp_job *job)
68 {
69         return job->pid;
70 }
71
72 MALI_STATIC_INLINE u32 mali_gp_job_get_tid(struct mali_gp_job *job)
73 {
74         return job->tid;
75 }
76
77 MALI_STATIC_INLINE u32* mali_gp_job_get_frame_registers(struct mali_gp_job *job)
78 {
79         return job->uargs.frame_registers;
80 }
81
82 MALI_STATIC_INLINE struct mali_session_data *mali_gp_job_get_session(struct mali_gp_job *job)
83 {
84         return job->session;
85 }
86
87 MALI_STATIC_INLINE mali_bool mali_gp_job_has_vs_job(struct mali_gp_job *job)
88 {
89         return (job->uargs.frame_registers[0] != job->uargs.frame_registers[1]) ? MALI_TRUE : MALI_FALSE;
90 }
91
92 MALI_STATIC_INLINE mali_bool mali_gp_job_has_plbu_job(struct mali_gp_job *job)
93 {
94         return (job->uargs.frame_registers[2] != job->uargs.frame_registers[3]) ? MALI_TRUE : MALI_FALSE;
95 }
96
97 MALI_STATIC_INLINE u32 mali_gp_job_get_current_heap_addr(struct mali_gp_job *job)
98 {
99         return job->heap_current_addr;
100 }
101
102 MALI_STATIC_INLINE void mali_gp_job_set_current_heap_addr(struct mali_gp_job *job, u32 heap_addr)
103 {
104         job->heap_current_addr = heap_addr;
105 }
106
107 MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_flag(struct mali_gp_job *job)
108 {
109         return job->uargs.perf_counter_flag;
110 }
111
112 MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_src0(struct mali_gp_job *job)
113 {
114         return job->uargs.perf_counter_src0;
115 }
116
117 MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_src1(struct mali_gp_job *job)
118 {
119         return job->uargs.perf_counter_src1;
120 }
121
122 MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_value0(struct mali_gp_job *job)
123 {
124         return job->perf_counter_value0;
125 }
126
127 MALI_STATIC_INLINE u32 mali_gp_job_get_perf_counter_value1(struct mali_gp_job *job)
128 {
129         return job->perf_counter_value1;
130 }
131
132 MALI_STATIC_INLINE void mali_gp_job_set_perf_counter_src0(struct mali_gp_job *job, u32 src)
133 {
134         job->uargs.perf_counter_src0 = src;
135 }
136
137 MALI_STATIC_INLINE void mali_gp_job_set_perf_counter_src1(struct mali_gp_job *job, u32 src)
138 {
139         job->uargs.perf_counter_src1 = src;
140 }
141
142 MALI_STATIC_INLINE void mali_gp_job_set_perf_counter_value0(struct mali_gp_job *job, u32 value)
143 {
144         job->perf_counter_value0 = value;
145 }
146
147 MALI_STATIC_INLINE void mali_gp_job_set_perf_counter_value1(struct mali_gp_job *job, u32 value)
148 {
149         job->perf_counter_value1 = value;
150 }
151
152 #endif /* __MALI_GP_JOB_H__ */