先是获得DMA的内存映射(一致性DMA映射)
/* allocate the framebuffer */
info->screen_base =
dma_alloc_coherent(dev, info->fix.smem_len,
(dma_addr_t *) & info->fix.smem_start,
GFP_KERNEL | GFP_DMA);
然后去设置寄存器,以让硬件去搬运从 info->fix.smem_start 的物理地址开始 缓存
从代码上分析,这里的fb_offset_32就是info->fix.smem_start 物理地址
fb_offset_32 = fb_offset_32 >> 5;
case WIN_OSD0:
osd_merge(OSD_OSDWIN0OFST_O0AH,
((fb_offset_32 & 0x7800000) >>
(23 - OSD_WINOFST_AH_SHIFT)) | 0x1000,
OSD_OSDWIN0OFST);
osd_merge(OSD_OSDWINADH_O0AH,
(fb_offset_32 & 0x7F0000) >>
(16 - OSD_OSDWINADH_O0AH_SHIFT),
OSD_OSDWINADH);
osd_write(fb_offset_32 & 0xFFFF, OSD_OSDWIN0ADL);
break;
下面的表格给出了 应写入 frame buffer address 到OSD 寄存器的 关系
Frame buffer address | OSD registers base address = 0x1c71c00 | |||
bit | bit | offset | Register name | description |
[31-28] | bit[12-9] | 20h | OSDWIN0OFST | Bitmap Window 0 Offset |
[27-21] | bit[6-0] | 34h | OSDWINADH | BMP Window 0/1 Address - High |
[20-5] | bit[12-0] | 38h | OSDWIN0ADL | BMP Window 0 Address - Low |
[5-0] 丢弃 |
|
|
|
|
也就是
DM365: start address is 27-bit long address b26 - b23 are in offset register b12 - b9, and * bit 26 has to be '1'
* bit 26 has to be '1' 是因为物理地址起始是0x8000 0000