MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_dc_init

Function rt_dc_init

bsp/loongson/ls1cdev/drivers/display_controller.c:114–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114static rt_err_t rt_dc_init(rt_device_t dev)
115{
116 int i, out, mode=-1;
117 int val;
118
119 rt_kprintf("PWM initied\n");
120 /* Set the back light PWM. */
121 pwminit();
122
123 for (i=0; i<sizeof(vga_mode)/sizeof(struct vga_struct); i++)
124 {
125 if (vga_mode[i].hr == FB_XSIZE && vga_mode[i].vr == FB_YSIZE)
126 {
127 mode=i;
128 /* 计算时钟 配置频率*/
129 caclulate_freq(OSC, vga_mode[i].pclk);
130 break;
131 }
132 }
133
134 if (mode<0)
135 {
136 rt_kprintf("\n\n\nunsupported framebuffer resolution\n\n\n");
137 return -RT_ERROR;
138 }
139
140 DC_FB_CONFIG = 0x0;
141 DC_FB_CONFIG = 0x3; // // framebuffer configuration RGB565
142 DC_DITHER_CONFIG = 0x0; //颜色抖动配置寄存器
143 DC_DITHER_TABLE_LOW = 0x0; //颜色抖动查找表低位寄存器
144 DC_DITHER_TABLE_HIGH = 0x0; //颜色抖动查找表高位寄存器
145 DC_PANEL_CONFIG = 0x80001311; //液晶面板配置寄存器
146 DC_PANEL_TIMING = 0x0;
147
148 DC_HDISPLAY = (vga_mode[mode].hfl<<16) | vga_mode[mode].hr;
149 DC_HSYNC = 0x40000000 | (vga_mode[mode].hse<<16) | vga_mode[mode].hss;
150 DC_VDISPLAY = (vga_mode[mode].vfl<<16) | vga_mode[mode].vr;
151 DC_VSYNC = 0x40000000 | (vga_mode[mode].vse<<16) | vga_mode[mode].vss;
152
153#if defined(CONFIG_VIDEO_32BPP)
154 DC_FB_CONFIG = 0x00100105;
155 DC_FB_BUFFER_STRIDE = FB_XSIZE*4;
156#elif defined(CONFIG_VIDEO_24BPP)
157 DC_FB_CONFIG = 0x00100104;
158 DC_FB_BUFFER_STRIDE = (FB_XSIZE*4+255)&(~255);
159#elif defined(CONFIG_VIDEO_16BPP)// 使用这个选项
160 DC_FB_CONFIG = 0x00100103;
161 DC_FB_BUFFER_STRIDE = (FB_XSIZE*2+0x7f)&(~0x7f);
162#elif defined(CONFIG_VIDEO_15BPP)
163 DC_FB_CONFIG = 0x00100102;
164 DC_FB_BUFFER_STRIDE = (FB_XSIZE*2+255)&(~255);
165#elif defined(CONFIG_VIDEO_12BPP)
166 DC_FB_CONFIG = 0x00100101;
167 DC_FB_BUFFER_STRIDE = (FB_XSIZE*2+255)&(~255);
168#else
169 DC_FB_CONFIG = 0x00100104;
170 DC_FB_BUFFER_STRIDE = (FB_XSIZE*4+255)&(~255);
171#endif

Callers

nothing calls this directly

Calls 3

rt_kprintfFunction · 0.85
pwminitFunction · 0.85
caclulate_freqFunction · 0.70

Tested by

no test coverage detected