aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/omap/omap_voutlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/omap/omap_voutlib.c')
-rw-r--r--drivers/media/video/omap/omap_voutlib.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/media/video/omap/omap_voutlib.c b/drivers/media/video/omap/omap_voutlib.c
index 8ae74817a11..115408b9274 100644
--- a/drivers/media/video/omap/omap_voutlib.c
+++ b/drivers/media/video/omap/omap_voutlib.c
@@ -24,8 +24,12 @@
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/videodev2.h> 25#include <linux/videodev2.h>
26 26
27#include <linux/dma-mapping.h>
28
27#include <plat/cpu.h> 29#include <plat/cpu.h>
28 30
31#include "omap_voutlib.h"
32
29MODULE_AUTHOR("Texas Instruments"); 33MODULE_AUTHOR("Texas Instruments");
30MODULE_DESCRIPTION("OMAP Video library"); 34MODULE_DESCRIPTION("OMAP Video library");
31MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
@@ -291,3 +295,45 @@ void omap_vout_new_format(struct v4l2_pix_format *pix,
291} 295}
292EXPORT_SYMBOL_GPL(omap_vout_new_format); 296EXPORT_SYMBOL_GPL(omap_vout_new_format);
293 297
298/*
299 * Allocate buffers
300 */
301unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr)
302{
303 u32 order, size;
304 unsigned long virt_addr, addr;
305
306 size = PAGE_ALIGN(buf_size);
307 order = get_order(size);
308 virt_addr = __get_free_pages(GFP_KERNEL, order);
309 addr = virt_addr;
310
311 if (virt_addr) {
312 while (size > 0) {
313 SetPageReserved(virt_to_page(addr));
314 addr += PAGE_SIZE;
315 size -= PAGE_SIZE;
316 }
317 }
318 *phys_addr = (u32) virt_to_phys((void *) virt_addr);
319 return virt_addr;
320}
321
322/*
323 * Free buffers
324 */
325void omap_vout_free_buffer(unsigned long virtaddr, u32 buf_size)
326{
327 u32 order, size;
328 unsigned long addr = virtaddr;
329
330 size = PAGE_ALIGN(buf_size);
331 order = get_order(size);
332
333 while (size > 0) {
334 ClearPageReserved(virt_to_page(addr));
335 addr += PAGE_SIZE;
336 size -= PAGE_SIZE;
337 }
338 free_pages((unsigned long) virtaddr, order);
339}