/* arch/arm/mach-rk29/vpu_mem.c\r
*\r
* Copyright (C) 2010 ROCKCHIP, Inc.\r
+ * author: chenhengming chm@rock-chips.com\r
*\r
* This software is licensed under the terms of the GNU General Public\r
* License version 2, as published by the Free Software Foundation, and\r
\r
/**\r
* struct for process session which connect to vpu_mem\r
- * \r
+ *\r
* @author ChenHengming (2011-4-11)\r
*/\r
typedef struct vpu_mem_session {\r
} vdm_region;\r
\r
/**\r
- * struct for region information \r
- * this struct should be modified with bitmap lock \r
+ * struct for region information\r
+ * this struct should be modified with bitmap lock\r
*/\r
typedef struct vpu_mem_link_info {\r
struct list_head session_link; /* link to vpu_mem_session list */\r
* O_SYNC to get an uncached region */\r
unsigned cached;\r
unsigned buffered;\r
- /* \r
+ /*\r
* vdm_session init only store the free region but use a vdm_session for convenience\r
*/\r
vdm_session status;\r
#define is_free_region(x) ((0 == (x)->used) && (0 == (x)->post))\r
\r
/**\r
- * vpu memory info dump: \r
- * first dump global info, then dump each session info \r
- * \r
+ * vpu memory info dump:\r
+ * first dump global info, then dump each session info\r
+ *\r
* @author ChenHengming (2011-4-20)\r
*/\r
static void dump_status(void)\r
\r
/**\r
* find used link in a session\r
- * \r
+ *\r
* @author ChenHengming (2011-4-18)\r
- * \r
- * @param session \r
- * @param index \r
- * \r
- * @return vdm_link* \r
+ *\r
+ * @param session\r
+ * @param index\r
+ *\r
+ * @return vdm_link*\r
*/\r
static vdm_link *find_used_link(vdm_session *session, int index)\r
{\r
\r
/**\r
* find post link from vpu_mem's vdm_post list\r
- * \r
+ *\r
* @author ChenHengming (2011-4-18)\r
- * \r
- * @param index \r
- * \r
- * @return vdm_link* \r
+ *\r
+ * @param index\r
+ *\r
+ * @return vdm_link*\r
*/\r
static vdm_link *find_post_link(int index)\r
{\r
\r
/**\r
* find free link from vpu_mem's vdm_free list\r
- * \r
+ *\r
* @author Administrator (2011-4-19)\r
- * \r
- * @param index \r
- * \r
- * @return vdm_link* \r
+ *\r
+ * @param index\r
+ *\r
+ * @return vdm_link*\r
*/\r
static vdm_link *find_free_link(int index)\r
{\r
}\r
/**\r
* insert a region into the index list for search\r
- * \r
+ *\r
* @author ChenHengming (2011-4-18)\r
- * \r
- * @param region \r
- * \r
- * @return int \r
+ *\r
+ * @param region\r
+ *\r
+ * @return int\r
*/\r
static int _insert_region_index(vdm_region *region)\r
{\r
\r
/**\r
* insert a link into vdm_free list, indexed by vdm_link->index\r
- * \r
+ *\r
* @author ChenHengming (2011-4-20)\r
- * \r
- * @param link \r
+ *\r
+ * @param link\r
*/\r
static void _insert_link_status_free(vdm_link *link)\r
{\r
}\r
\r
/**\r
- * Create a link and a region by index and pfn at a same time, \r
- * and connect the link with the region \r
- * \r
+ * Create a link and a region by index and pfn at a same time,\r
+ * and connect the link with the region\r
+ *\r
* @author ChenHengming (2011-4-20)\r
- * \r
- * @param index \r
- * @param pfn \r
- * \r
- * @return vdm_link* \r
+ *\r
+ * @param index\r
+ * @param pfn\r
+ *\r
+ * @return vdm_link*\r
*/\r
static vdm_link *new_link_by_index(int index, int pfn)\r
{\r
}\r
\r
/**\r
- * Create a link from a already exist region and connect to the \r
- * region \r
- * \r
+ * Create a link from a already exist region and connect to the\r
+ * region\r
+ *\r
* @author ChenHengming (2011-4-20)\r
- * \r
- * @param region \r
- * \r
- * @return vdm_link* \r
+ *\r
+ * @param region\r
+ *\r
+ * @return vdm_link*\r
*/\r
static vdm_link *new_link_by_region(vdm_region *region)\r
{\r
\r
/**\r
* Delete a link completely\r
- * \r
+ *\r
* @author ChenHengming (2011-4-20)\r
- * \r
- * @param link \r
+ *\r
+ * @param link\r
*/\r
static void link_del(vdm_link *link)\r
{\r
}\r
\r
/**\r
- * Called by malloc, check whether a free link can by used for a \r
- * len of pfn, if can then put a used link to status link \r
- * \r
+ * Called by malloc, check whether a free link can by used for a\r
+ * len of pfn, if can then put a used link to status link\r
+ *\r
* @author ChenHengming (2011-4-20)\r
- * \r
- * @param link \r
- * @param session \r
- * @param pfn \r
- * \r
- * @return vdm_link* \r
+ *\r
+ * @param link\r
+ * @param session\r
+ * @param pfn\r
+ *\r
+ * @return vdm_link*\r
*/\r
static vdm_link *get_used_link_from_free_link(vdm_link *link, vdm_session *session, int pfn)\r
{\r
{\r
vdm_session *session;\r
int ret = 0;\r
- \r
+\r
DLOG("current %u file %p(%d)\n", current->pid, file, (int)file_count(file));\r
/* setup file->private_data to indicate its unmapped */\r
/* you can only open a vpu_mem device one time */\r
session->pid = current->pid;\r
INIT_LIST_HEAD(&session->list_post);\r
INIT_LIST_HEAD(&session->list_used);\r
- \r
+\r
file->private_data = session;\r
- \r
+\r
down_write(&vdm_rwsem);\r
list_add_tail(&session->list_session, &vdm_proc);\r
up_write(&vdm_rwsem);\r
static long vpu_mem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)\r
{\r
long index, ret = 0;\r
- \r
+\r
switch (cmd) {\r
case VPU_MEM_GET_PHYS:\r
DLOG("get_phys\n");\r
vpu_mem.dev.name = pdata->name;\r
vpu_mem.dev.minor = MISC_DYNAMIC_MINOR;\r
vpu_mem.dev.fops = &vpu_mem_fops;\r
- \r
+\r
err = misc_register(&vpu_mem.dev);\r
if (err) {\r
printk(KERN_ALERT "Unable to register vpu_mem driver!\n");\r
goto err_cant_register_device;\r
}\r
- \r
+\r
vpu_mem.num_entries = vpu_mem.size / VPU_MEM_MIN_ALLOC;\r
\r
tmp = new_link_by_index(0, vpu_mem.num_entries);\r
#endif\r
else\r
vpu_mem.vbase = ioremap(vpu_mem.base, vpu_mem.size);\r
- \r
+\r
if (vpu_mem.vbase == 0)\r
goto error_cant_remap;\r
- \r
+\r
#if VPU_MEM_DEBUG\r
debugfs_create_file(pdata->name, S_IFREG | S_IRUGO, NULL, (void *)vpu_mem.dev.minor,\r
&debug_fops);\r
link->index, link->pfn, link->link_used, link->link_post);\r
}\r
}\r
- \r
+\r
// ´òÓ¡ vpu_mem_info ÖеÄÈ«²¿ session µÄ region Õ¼ÓÃÇé¿ö\r
list_for_each_entry_safe(session, tmp_session, &vdm_proc, list_session) {\r
seq_printf(s, "\npid: %d\n", session->pid);\r