fb_mem

info->fix.smem_start
    ---- 如果是从kmalloc或者get_free_pages()分配的,这样的内存是不能用remap_pfn_range()映射出去的,要对每个页面调用SetPageReserved()标记为“保留”才可以,virt_to_phys()函数只能得到其物理地址,remap_pfn_range()中的第三个参数是要求是物理页面的帧号,即pfn,所以phys还要>>page_shift。
    ---- 如果是通过vmalloc分配得到的,也和上面一样,但是需要用vmalloc_to_pfn。
通过kmalloc, get_free_pages,vmalloc分配的物理内存页面,最好不要用remap_pfn_page方法,最后使用VMA的nopage方法。

对于设备内存,最好调用pgprot_nocached(vma->vm_page_prot)后传给remap_pfn_range,防止处理器缓存。

最好是使用fb_mmap()。

static   int   xxx_mmap(struct   file   *file,   struct   vm_area_struct   *vma)
{
//   TODO:   allocate   the   raw   frame   buffer   if   necessary
unsigned   long   page,   pos;
unsigned   long   start   =   vma-> vm_start;
unsigned   long   size     =   vma-> vm_end-vma-> vm_start;
struct   private   *cam   =   file-> private_data;

DBG( "enter   zoran_mmap/n ");
if   (!cam)
return   -ENODEV;


/*   We   let   mmap   allocate   as   much   as   it   wants   because   Linux   was   adding   2048   bytes
  *   to   the   size   the   application   requested   for   mmap   and   it   was   screwing   apps   up.
  */
//memcpy(cam-> framebuf, "this   is   a   test ",14);
pos   =   (unsigned   long)cam-> framebuf;
while   (size   >   0)   {
page   =   vmalloc_to_pfn((void   *)pos);
if   (remap_pfn_range(vma,   start,   page,   PAGE_SIZE,   PAGE_SHARED))
return   -EAGAIN;

start   +=   PAGE_SIZE;
pos   +=   PAGE_SIZE;
if   (size   >   PAGE_SIZE)
size   -=   PAGE_SIZE;
else
size   =   0;
}
                DBG( "mmap   success ");
cam-> mmapped   =   1;
return   0;
}


简单点,性能监视器什么的统统扔掉,你这个lv_mem_get_used_size()在lvgl v9.3根本没有。 你赶紧把人家https://docs.lvgl.io/9.3好好收入知识库里面学习吧。报错: cat@lubancat:~/work/lvgl/demo$ make gcc -Wall -Wextra -O2 -g -DLV_COLOR_DEPTH=32 -I/home/cat/software/install_dir/lvgl/include -I/home/cat/software/install_dir/lvgl/include/lvgl -c main.c -o main.o main.c: In function ‘main’: main.c:171:30: warning: implicit declaration of function ‘lv_mem_get_used_size’; did you mean ‘lv_event_get_old_size’? [-Wimplicit-function-declaration] 171 | size_t used_kb = lv_mem_get_used_size() / 1024; | ^~~~~~~~~~~~~~~~~~~~ | lv_event_get_old_size main.c:172:31: warning: implicit declaration of function ‘lv_mem_get_total_size’ [-Wimplicit-function-declaration] 172 | size_t total_kb = lv_mem_get_total_size() / 1024; | ^~~~~~~~~~~~~~~~~~~~~ main.c:173:35: warning: implicit declaration of function ‘lv_mem_get_fragmentation’; did you mean ‘lv_bar_get_orientation’? [-Wimplicit-function-declaration] 173 | size_t frag_percent = lv_mem_get_fragmentation(); | ^~~~~~~~~~~~~~~~~~~~~~~~ | lv_bar_get_orientation main.c:90:14: warning: unused parameter ‘argc’ [-Wunused-parameter] 90 | int main(int argc, char **argv) { | ~~~~^~~~ main.c:90:27: warning: unused parameter ‘argv’ [-Wunused-parameter] 90 | int main(int argc, char **argv) { | ~~~~~~~^~~~ gcc -Wall -Wextra -O2 -g -DLV_COLOR_DEPTH=32 -o lvgl_demo main.o -L/home/cat/software/install_dir/lvgl/lib -llvgl -linput -ludev -ldrm -lxkbcommon -lm -lpthread -linput -ludev -ldrm /usr/bin/ld: main.o: in function `main': /home/cat/work/lvgl/demo/main.c:171: undefined reference to `lv_mem_get_used_size' /usr/bin/ld: /home/cat/work/lvgl/demo/main.c:172: undefined reference to `lv_mem_get_total_size' /usr/bin/ld: /home/cat/work/lvgl/demo/main.c:173: undefined reference to `lv_mem_get_fragmentation' collect2: error: ld returned 1 exit status
06-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值