diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/media/video/zr36120_mem.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/media/video/zr36120_mem.c')
-rw-r--r-- | drivers/media/video/zr36120_mem.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/drivers/media/video/zr36120_mem.c b/drivers/media/video/zr36120_mem.c new file mode 100644 index 000000000000..c87113d6cc60 --- /dev/null +++ b/drivers/media/video/zr36120_mem.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /* | ||
2 | zr36120_mem.c - Zoran 36120/36125 based framegrabbers | ||
3 | |||
4 | Copyright (C) 1998-1999 Pauline Middelink <middelin@polyware.nl> | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 2 of the License, or | ||
9 | (at your option) any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software | ||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/config.h> | ||
22 | #include <linux/mm.h> | ||
23 | #include <linux/pci.h> | ||
24 | #include <linux/slab.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <asm/io.h> | ||
27 | #ifdef CONFIG_BIGPHYS_AREA | ||
28 | #include <linux/bigphysarea.h> | ||
29 | #endif | ||
30 | |||
31 | #include "zr36120.h" | ||
32 | #include "zr36120_mem.h" | ||
33 | |||
34 | /*******************************/ | ||
35 | /* Memory management functions */ | ||
36 | /*******************************/ | ||
37 | |||
38 | void* bmalloc(unsigned long size) | ||
39 | { | ||
40 | void* mem; | ||
41 | #ifdef CONFIG_BIGPHYS_AREA | ||
42 | mem = bigphysarea_alloc_pages(size/PAGE_SIZE, 1, GFP_KERNEL); | ||
43 | #else | ||
44 | /* | ||
45 | * The following function got a lot of memory at boottime, | ||
46 | * so we know its always there... | ||
47 | */ | ||
48 | mem = (void*)__get_free_pages(GFP_USER|GFP_DMA,get_order(size)); | ||
49 | #endif | ||
50 | if (mem) { | ||
51 | unsigned long adr = (unsigned long)mem; | ||
52 | while (size > 0) { | ||
53 | SetPageReserved(virt_to_page(phys_to_virt(adr))); | ||
54 | adr += PAGE_SIZE; | ||
55 | size -= PAGE_SIZE; | ||
56 | } | ||
57 | } | ||
58 | return mem; | ||
59 | } | ||
60 | |||
61 | void bfree(void* mem, unsigned long size) | ||
62 | { | ||
63 | if (mem) { | ||
64 | unsigned long adr = (unsigned long)mem; | ||
65 | unsigned long siz = size; | ||
66 | while (siz > 0) { | ||
67 | ClearPageReserved(virt_to_page(phys_to_virt(adr))); | ||
68 | adr += PAGE_SIZE; | ||
69 | siz -= PAGE_SIZE; | ||
70 | } | ||
71 | #ifdef CONFIG_BIGPHYS_AREA | ||
72 | bigphysarea_free_pages(mem); | ||
73 | #else | ||
74 | free_pages((unsigned long)mem,get_order(size)); | ||
75 | #endif | ||
76 | } | ||
77 | } | ||
78 | |||
79 | MODULE_LICENSE("GPL"); | ||