|
|
@@ -24,8 +24,8 @@
|
|
|
#include <lwp_user_mm.h>
|
|
|
#include "rt_lcd.h"
|
|
|
|
|
|
-struct imx6ull_lcd_config lcd_config = LCD_BUS_CONFIG;
|
|
|
-struct imx6ull_lcd_bus lcd_obj;
|
|
|
+static struct imx6ull_lcd_config g_lcd_config = LCD_BUS_CONFIG;
|
|
|
+static struct imx6ull_lcd_bus g_lcd_obj;
|
|
|
|
|
|
static rt_err_t imx6ull_elcd_init(rt_device_t device)
|
|
|
{
|
|
|
@@ -80,7 +80,7 @@ static rt_err_t imx6ull_elcd_control(rt_device_t device, int cmd, void *args)
|
|
|
{
|
|
|
case RTGRAPHIC_CTRL_RECT_UPDATE:
|
|
|
{
|
|
|
- rt_hw_cpu_dcache_clean((void *)(lcd_obj.info.framebuffer),
|
|
|
+ rt_hw_cpu_dcache_clean((void *)(g_lcd_obj.info.framebuffer),
|
|
|
elcd_dev->info.width * elcd_dev->info.height * elcd_dev->info.bits_per_pixel/8);
|
|
|
break;
|
|
|
}
|
|
|
@@ -115,7 +115,7 @@ static rt_err_t imx6ull_elcd_control(rt_device_t device, int cmd, void *args)
|
|
|
{
|
|
|
struct fb_fix_screeninfo *info = (struct fb_fix_screeninfo *)args;
|
|
|
strncpy(info->id, elcd_dev->config->name, (strlen(elcd_dev->config->name)+1));
|
|
|
- info->smem_len = elcd_dev->info.width * elcd_dev->info.height * 2;;
|
|
|
+ info->smem_len = elcd_dev->info.width * elcd_dev->info.height * 2;
|
|
|
info->smem_start = (rt_uint32_t)lwp_map_user_phy(lwp_self(), RT_NULL,
|
|
|
elcd_dev->fb_phy,
|
|
|
info->smem_len, 1);
|
|
|
@@ -151,59 +151,61 @@ int rt_hw_elcd_init(void)
|
|
|
{
|
|
|
rt_err_t ret = 0;
|
|
|
|
|
|
- lcd_config.ELCDIF = (LCDIF_Type *)imx6ull_get_periph_vaddr((rt_uint32_t)(lcd_config.ELCDIF));
|
|
|
- lcd_config.lcd_mux_base = (rt_uint32_t)imx6ull_get_periph_vaddr((rt_uint32_t)(lcd_config.lcd_mux_base));
|
|
|
- lcd_config.lcd_cfg_base = (rt_uint32_t)imx6ull_get_periph_vaddr((rt_uint32_t)(lcd_config.lcd_cfg_base));
|
|
|
+ g_lcd_config.ELCDIF = (LCDIF_Type *)imx6ull_get_periph_vaddr((rt_uint32_t)(g_lcd_config.ELCDIF));
|
|
|
+ g_lcd_config.lcd_mux_base = (rt_uint32_t)imx6ull_get_periph_vaddr((rt_uint32_t)(g_lcd_config.lcd_mux_base));
|
|
|
+ g_lcd_config.lcd_cfg_base = (rt_uint32_t)imx6ull_get_periph_vaddr((rt_uint32_t)(g_lcd_config.lcd_cfg_base));
|
|
|
|
|
|
for(int i = 0; i < LCD_GPIO_MAX; i++)
|
|
|
{
|
|
|
- IOMUXC_SetPinMux((lcd_config.lcd_mux_base + i * 4), 0x0U, 0x00000000U, 0x0U, (lcd_config.lcd_cfg_base + i * 4), 0);
|
|
|
- IOMUXC_SetPinConfig((lcd_config.lcd_mux_base + i * 4), 0x0U, 0x00000000U, 0x0U, (lcd_config.lcd_cfg_base + i * 4), 0xB9);
|
|
|
+ IOMUXC_SetPinMux((g_lcd_config.lcd_mux_base + i * 4),
|
|
|
+ 0x0U, 0x0U, 0x0U, (g_lcd_config.lcd_cfg_base + i * 4), 0);
|
|
|
+ IOMUXC_SetPinConfig((g_lcd_config.lcd_mux_base + i * 4),
|
|
|
+ 0x0U, 0x0U, 0x0U, (g_lcd_config.lcd_cfg_base + i * 4), 0xB9);
|
|
|
}
|
|
|
|
|
|
- CLOCK_EnableClock(lcd_config.apd_clk_name);
|
|
|
- CLOCK_EnableClock(lcd_config.pix_clk_name);
|
|
|
+ CLOCK_EnableClock(g_lcd_config.apd_clk_name);
|
|
|
+ CLOCK_EnableClock(g_lcd_config.pix_clk_name);
|
|
|
|
|
|
- lcd_obj.config = &lcd_config;
|
|
|
+ g_lcd_obj.config = &g_lcd_config;
|
|
|
|
|
|
- lcd_obj.fb_virt = rt_pages_alloc(rt_page_bits(LCD_BUF_SIZE));
|
|
|
- lcd_obj.fb_phy = lcd_obj.fb_virt + PV_OFFSET;
|
|
|
+ g_lcd_obj.fb_virt = rt_pages_alloc(rt_page_bits(LCD_BUF_SIZE));
|
|
|
+ g_lcd_obj.fb_phy = g_lcd_obj.fb_virt + PV_OFFSET;
|
|
|
|
|
|
- LOG_D("fb address => 0x%08x\n", lcd_obj.fb_phy);
|
|
|
- if(lcd_obj.fb_phy == RT_NULL)
|
|
|
+ LOG_D("fb address => 0x%08x\n", g_lcd_obj.fb_phy);
|
|
|
+ if(g_lcd_obj.fb_phy == RT_NULL)
|
|
|
{
|
|
|
LOG_E("initialize frame buffer failed!\n");
|
|
|
return -RT_ERROR;
|
|
|
}
|
|
|
|
|
|
- lcd_obj.info.width = LCD_WIDTH;
|
|
|
- lcd_obj.info.height = LCD_HEIGHT;
|
|
|
- lcd_obj.info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
|
|
|
- lcd_obj.info.bits_per_pixel = LCD_BITS_PER_PIXEL;
|
|
|
- lcd_obj.info.framebuffer = (void *)lcd_obj.fb_virt;
|
|
|
+ g_lcd_obj.info.width = LCD_WIDTH;
|
|
|
+ g_lcd_obj.info.height = LCD_HEIGHT;
|
|
|
+ g_lcd_obj.info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
|
|
|
+ g_lcd_obj.info.bits_per_pixel = LCD_BITS_PER_PIXEL;
|
|
|
+ g_lcd_obj.info.framebuffer = (void *)g_lcd_obj.fb_virt;
|
|
|
|
|
|
- lcd_obj.parent.type = RT_Device_Class_Graphic;
|
|
|
+ g_lcd_obj.parent.type = RT_Device_Class_Graphic;
|
|
|
|
|
|
#ifdef RT_USING_DEVICE_OPS
|
|
|
- lcd_obj.parent.ops = &elcd_ops;
|
|
|
+ g_lcd_obj.parent.ops = &elcd_ops;
|
|
|
#else
|
|
|
- lcd_obj.parent.init = imx6ull_elcd_init;
|
|
|
- lcd_obj.parent.open = RT_NULL;
|
|
|
- lcd_obj.parent.close = RT_NULL;
|
|
|
- lcd_obj.parent.read = RT_NULL;
|
|
|
- lcd_obj.parent.write = RT_NULL;
|
|
|
- lcd_obj.parent.control = imx6ull_elcd_control;
|
|
|
+ g_lcd_obj.parent.init = imx6ull_elcd_init;
|
|
|
+ g_lcd_obj.parent.open = RT_NULL;
|
|
|
+ g_lcd_obj.parent.close = RT_NULL;
|
|
|
+ g_lcd_obj.parent.read = RT_NULL;
|
|
|
+ g_lcd_obj.parent.write = RT_NULL;
|
|
|
+ g_lcd_obj.parent.control = imx6ull_elcd_control;
|
|
|
#endif
|
|
|
|
|
|
- lcd_obj.parent.user_data = (void *)&lcd_obj.info;
|
|
|
+ g_lcd_obj.parent.user_data = (void *)&g_lcd_obj.info;
|
|
|
|
|
|
- ret = rt_device_register(&lcd_obj.parent, lcd_obj.config->name, RT_DEVICE_FLAG_RDWR);
|
|
|
+ ret = rt_device_register(&g_lcd_obj.parent, g_lcd_obj.config->name, RT_DEVICE_FLAG_RDWR);
|
|
|
|
|
|
/* LCD_BL */
|
|
|
- rt_pin_mode (IMX6ULL_LCD_BL_PIN, PIN_MODE_OUTPUT);
|
|
|
+ rt_pin_mode(IMX6ULL_LCD_BL_PIN, PIN_MODE_OUTPUT);
|
|
|
rt_pin_write(IMX6ULL_LCD_BL_PIN, PIN_HIGH);
|
|
|
|
|
|
- rt_memset((rt_uint8_t *)lcd_obj.fb_virt, 0xff, LCD_BUF_SIZE);
|
|
|
+ rt_memset((rt_uint8_t *)g_lcd_obj.fb_virt, 0xff, LCD_BUF_SIZE);
|
|
|
|
|
|
return ret;
|
|
|
}
|