PageRenderTime 16ms CodeModel.GetById 2ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/src/backend/rt-thread/ftk_display_rtthread.c

http://ftk.googlecode.com/
C | 48 lines | 38 code | 8 blank | 2 comment | 12 complexity | 7ffad468858f9a90899f6a0d89ae9c90 MD5 | raw file
 1
 2#include <stdlib.h>
 3#include "ftk_log.h"
 4#include "ftk_display_mem.h"
 5#include "ftk_display_rtthread.h"
 6
 7FtkDisplay* ftk_display_lcd_create(const char* filename)
 8{
 9	rt_device_t device;
10	rt_err_t result;
11	struct rt_device_graphic_info info;
12    FtkDisplay* thiz = NULL;
13	FtkPixelFormat format = 0;
14	
15	device = rt_device_find(filename);
16	if(device == RT_NULL) return NULL;
17
18	/* get framebuffer address */
19	result = rt_device_control(device, RTGRAPHIC_CTRL_GET_INFO, &info);
20	if(result != RT_EOK)
21	{
22		/* get device information failed */
23		return NULL;
24	}
25
26    if(info.bits_per_pixel == 16)
27    {
28        format = FTK_PIXEL_RGB565;
29    }
30    else if(info.bits_per_pixel == 24)
31    {
32        format = FTK_PIXEL_BGR24;
33    }
34    else if(info.bits_per_pixel == 32)
35    {
36        format = FTK_PIXEL_BGRA32;
37    }
38    else
39    {
40        assert(!"not supported framebuffer format.");
41    }
42
43    thiz = ftk_display_mem_create(format, info.width, info.height,
44            info.framebuffer, NULL, NULL);
45
46    return thiz;
47}
48