Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
include
drm
drm_buffer.h
Go to the documentation of this file.
1
/**************************************************************************
2
*
3
* Copyright 2010 Pauli Nieminen.
4
* All Rights Reserved.
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a
7
* copy of this software and associated documentation files (the
8
* "Software"), to deal in the Software without restriction, including
9
* without limitation the rights to use, copy, modify, merge, publish,
10
* distribute, sub license, and/or sell copies of the Software, and to
11
* permit persons to whom the Software is furnished to do so, subject to
12
* the following conditions:
13
*
14
* The above copyright notice and this permission notice (including the
15
* next paragraph) shall be included in all copies or substantial portions
16
* of the Software.
17
*
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
22
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24
* USE OR OTHER DEALINGS IN THE SOFTWARE.
25
*
26
*
27
**************************************************************************/
28
/*
29
* Multipart buffer for coping data which is larger than the page size.
30
*
31
* Authors:
32
* Pauli Nieminen <suokkos-at-gmail-dot-com>
33
*/
34
35
#ifndef _DRM_BUFFER_H_
36
#define _DRM_BUFFER_H_
37
38
#include <
drm/drmP.h
>
39
40
struct
drm_buffer
{
41
int
iterator
;
42
int
size
;
43
char
*
data
[];
44
};
45
46
50
static
inline
int
drm_buffer_page(
struct
drm_buffer
*
buf
)
51
{
52
return
buf->
iterator
/
PAGE_SIZE
;
53
}
57
static
inline
int
drm_buffer_index(
struct
drm_buffer
*
buf
)
58
{
59
return
buf->
iterator
& (
PAGE_SIZE
- 1);
60
}
64
static
inline
int
drm_buffer_unprocessed(
struct
drm_buffer
*
buf
)
65
{
66
return
buf->
size
- buf->
iterator
;
67
}
68
72
static
inline
void
drm_buffer_advance(
struct
drm_buffer
*
buf
,
int
bytes
)
73
{
74
buf->
iterator
+=
bytes
;
75
}
76
83
extern
int
drm_buffer_alloc
(
struct
drm_buffer
**
buf
,
int
size
);
84
92
extern
int
drm_buffer_copy_from_user
(
struct
drm_buffer
*
buf
,
93
void
__user *
user_data
,
int
size
);
94
98
extern
void
drm_buffer_free
(
struct
drm_buffer
*
buf
);
99
112
extern
void
*
drm_buffer_read_object
(
struct
drm_buffer
*
buf
,
113
int
objsize,
void
*stack_obj);
114
127
static
inline
void
*drm_buffer_pointer_to_dword(
struct
drm_buffer
*
buffer
,
128
int
offset
)
129
{
130
int
iter = buffer->
iterator
+ offset * 4;
131
return
&buffer->
data
[iter /
PAGE_SIZE
][iter & (
PAGE_SIZE
- 1)];
132
}
141
static
inline
void
*drm_buffer_pointer_to_byte(
struct
drm_buffer
*
buffer
,
142
int
offset
)
143
{
144
int
iter = buffer->
iterator
+
offset
;
145
return
&buffer->
data
[iter /
PAGE_SIZE
][iter & (
PAGE_SIZE
- 1)];
146
}
147
148
#endif
Generated on Thu Jan 10 2013 14:50:54 for Linux Kernel by
1.8.2