SH7760/SH7763 集成 LCDC 帧缓冲驱动程序¶
0. 概述¶
SH7760/SH7763 集成了 LCD 显示控制器 (LCDC),理论上支持 1x1 到 1024x1024 的分辨率,颜色深度范围从 1 到 16 位,支持 STN、DSTN 和 TFT 面板。
注意事项
帧缓冲内存必须是在 Area3 顶部分配的大块内存(硬件要求)。由于此要求,您不应该将驱动程序做成模块,因为在运行时可能无法获得足够大的连续内存块。
驱动程序不支持在加载后更改分辨率(显示器无论如何都不支持热插拔)
在以下情况下可能会观察到严重闪烁:a) 如果您使用 15/16 位色彩模式且分辨率 >= 640x480 像素,b) 在 PCMCIA(或任何其他慢速总线)活动期间。
旋转仅支持顺时针 90 度,并且仅当水平分辨率 <= 320 像素时。
- 文件
drivers/video/sh7760fb.c
include/asm-sh/sh7760fb.h
1. 平台设置¶
- SH7760
视频数据通过 DMABRG DMA 引擎获取,因此您必须将 SH DMAC 配置为 DMABRG 模式(在启动时某处将 0x94808080 写入 DMARSRA 寄存器)。
PFC 寄存器 PCCR 和 PCDR 必须设置为外设模式。(将两者都写入零)。
驱动程序不会为您执行上述操作,因为板级设置是板级设置代码的工作。
2. 面板定义¶
LCDC 必须明确告知所连接 LCD 面板的类型。数据必须封装在“struct sh7760fb_platdata”中,并作为 platform_data 传递给驱动程序。
建议您仔细查阅 SH7760 手册,第 30 节。(http://documentation.renesas.com/eng/products/mpumcu/e602291_sh7760.pdf)
以下代码说明了在 640x480 TFT 上使帧缓冲工作所需的操作
#include <linux/fb.h>
#include <asm/sh7760fb.h>
/*
* NEC NL6440bc26-01 640x480 TFT
* dotclock 25175 kHz
* Xres 640 Yres 480
* Htotal 800 Vtotal 525
* HsynStart 656 VsynStart 490
* HsynLenn 30 VsynLenn 2
*
* The linux framebuffer layer does not use the syncstart/synclen
* values but right/left/upper/lower margin values. The comments
* for the x_margin explain how to calculate those from given
* panel sync timings.
*/
static struct fb_videomode nl6448bc26 = {
.name = "NL6448BC26",
.refresh = 60,
.xres = 640,
.yres = 480,
.pixclock = 39683, /* in picoseconds! */
.hsync_len = 30,
.vsync_len = 2,
.left_margin = 114, /* HTOT - (HSYNSLEN + HSYNSTART) */
.right_margin = 16, /* HSYNSTART - XRES */
.upper_margin = 33, /* VTOT - (VSYNLEN + VSYNSTART) */
.lower_margin = 10, /* VSYNSTART - YRES */
.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
.vmode = FB_VMODE_NONINTERLACED,
.flag = 0,
};
static struct sh7760fb_platdata sh7760fb_nl6448 = {
.def_mode = &nl6448bc26,
.ldmtr = LDMTR_TFT_COLOR_16, /* 16bit TFT panel */
.lddfr = LDDFR_8BPP, /* we want 8bit output */
.ldpmmr = 0x0070,
.ldpspr = 0x0500,
.ldaclnr = 0,
.ldickr = LDICKR_CLKSRC(LCDC_CLKSRC_EXTERNAL) |
LDICKR_CLKDIV(1),
.rotate = 0,
.novsync = 1,
.blank = NULL,
};
/* SH7760:
* 0xFE300800: 256 * 4byte xRGB palette ram
* 0xFE300C00: 42 bytes ctrl registers
*/
static struct resource sh7760_lcdc_res[] = {
[0] = {
.start = 0xFE300800,
.end = 0xFE300CFF,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = 65,
.end = 65,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device sh7760_lcdc_dev = {
.dev = {
.platform_data = &sh7760fb_nl6448,
},
.name = "sh7760-lcdc",
.id = -1,
.resource = sh7760_lcdc_res,
.num_resources = ARRAY_SIZE(sh7760_lcdc_res),
};