最近在调TFT分辨率,当使用1024x768 16bpp时正常,而当调整为1024x768 24bpp时报"Failed to allocate video memory"的错误.
出错的地方是在分配显示缓冲区.代码如下:
static __inline int allocate_video_memory_map(struct fb_info *fbinfo)
{
...
fbinfo->screen_base = dma_alloc_writecombine(fbi->dev, map_size, (dma_addr_t *)&fbinfo->fix.smem_start, GFP_KERNEL);
if (!fbinfo->screen_base) {
return -ENOMEM;
}
return 0;
}
...
{
ret = allocate_video_memory_map(fbinfo);
if (ret) {
dev_err(fbi->dev, "Failed to allocate video memory ma (%d)\n", ret);
return -ENOMEM;
}
}
dma_alloc_writecombine函数
/*
* Allocate DMA-coherent memory space and return both the kernel remapped
* virtual and bus address for that space.
*/
void *
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
{
void *memory;
if (dma_alloc_from_coherent(dev, size, handle, &memory))
return memory;
if (arch_is_coherent()) {
void *virt;
virt = kmalloc(size, gfp);
if (!virt)
return NULL;
*handle = virt_to_dma(dev, virt);
return virt;
}
return __dma_alloc(dev, size,