gpu: pvr: pdumpfs: add pdumpfs_mutex
[sgx.git] / pvr / pvr_pdumpfs.c
1 /*
2  * Copyright (c) 2010-2011 by Luc Verhaegen <libv@codethink.co.uk>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18
19 #include <linux/mutex.h>
20
21 #include "img_defs.h"
22 #include "services_headers.h"
23 #include "pvr_pdump.h"
24 #include "pvr_pdumpfs.h"
25
26 static struct mutex pdumpfs_mutex[1];
27
28 enum pdumpfs_mode {
29         PDUMPFS_MODE_DISABLED,
30         PDUMPFS_MODE_STANDARD,
31         PDUMPFS_MODE_FULL,
32 };
33
34 static enum pdumpfs_mode pdumpfs_mode = PDUMPFS_MODE_DISABLED;
35 static u32 pdumpfs_frame_number;
36
37 void
38 pdumpfs_frame_set(u32 frame)
39 {
40         mutex_lock(pdumpfs_mutex);
41
42         pdumpfs_frame_number = frame;
43
44         mutex_unlock(pdumpfs_mutex);
45 }
46
47 bool
48 pdumpfs_capture_enabled(void)
49 {
50         bool ret;
51
52         mutex_lock(pdumpfs_mutex);
53
54         if (pdumpfs_mode == PDUMPFS_MODE_FULL)
55                 ret = true;
56         else
57                 ret = false;
58
59         mutex_unlock(pdumpfs_mutex);
60
61         return ret;
62 }
63
64 bool
65 pdumpfs_flags_check(u32 flags)
66 {
67         bool ret;
68
69         if (flags & PDUMP_FLAGS_NEVER)
70                 return false;
71
72         mutex_lock(pdumpfs_mutex);
73
74         if (pdumpfs_mode == PDUMPFS_MODE_FULL)
75                 ret = true;
76         else if ((pdumpfs_mode == PDUMPFS_MODE_STANDARD) &&
77                  (flags & PDUMP_FLAGS_CONTINUOUS))
78                 ret = true;
79         else
80                 ret = false;
81
82         mutex_unlock(pdumpfs_mutex);
83
84         return ret;
85 }
86
87 enum PVRSRV_ERROR
88 pdumpfs_write_data(void *buffer, size_t size, bool from_user)
89 {
90         mutex_lock(pdumpfs_mutex);
91
92         mutex_unlock(pdumpfs_mutex);
93
94         return PVRSRV_OK;
95 }
96
97 void
98 pdumpfs_write_string(char *string)
99 {
100         mutex_lock(pdumpfs_mutex);
101
102         mutex_unlock(pdumpfs_mutex);
103 }
104
105 int
106 pdumpfs_init(void)
107 {
108         mutex_init(pdumpfs_mutex);
109
110         return 0;
111 }
112
113 void
114 pdumpfs_cleanup(void)
115 {
116
117 }