mirror of
git://projects.qi-hardware.com/iris.git
synced 2025-04-21 12:27:27 +03:00
working lcd driver
This commit is contained in:
@@ -28,8 +28,7 @@ class DevBuzzer:
|
||||
DevBuzzer ():
|
||||
is_beeping = false
|
||||
tcu_stop_counter (pwm)
|
||||
//tcu_select_extalclk (pwm)
|
||||
tcu_select_pclk (pwm)
|
||||
tcu_select_extalclk (pwm)
|
||||
tcu_select_clk_div64 (pwm)
|
||||
tcu_enable_pwm_output (pwm)
|
||||
void stop ():
|
||||
|
||||
@@ -121,7 +121,7 @@ static void reset ():
|
||||
#elif defined (NANONOTE)
|
||||
// Note that the sync pulse is part of the pre-display region.
|
||||
// Horizontal timings.
|
||||
unsigned hsync = 1, hpre = 141, hpost = 273
|
||||
unsigned hsync = 1, hpre = 70, hpost = 273
|
||||
// Vertical timings.
|
||||
unsigned vsync = 1, vpre = 21, vpost = 2
|
||||
// 3 clocks per pixel.
|
||||
@@ -129,7 +129,7 @@ static void reset ():
|
||||
// Bits per pixel.
|
||||
unsigned bpp = LCD_CTRL_BPP_18_24
|
||||
// Configuration.
|
||||
unsigned cfg = LCD_CFG_MODE_SERIAL_TFT | LCD_CFG_HSP | LCD_CFG_VSP
|
||||
unsigned cfg = LCD_CFG_MODE_SERIAL_TFT | LCD_CFG_HSP | LCD_CFG_VSP | LCD_CFG_PCP
|
||||
// Set up SPI pins.
|
||||
gpio_as_output (SP_PORT, (1 << SPEN) | (1 << SPCK) | (1 << SPDA))
|
||||
gpio_set (SP_PORT, (1 << SPEN) | (1 << SPCK))
|
||||
@@ -139,7 +139,7 @@ static void reset ():
|
||||
|
||||
// Note that the sync pulse is part of the pre-display region.
|
||||
unsigned vpe = vsync, vds = vpre, vde = vds + v, vt = vde + vpost
|
||||
unsigned hpe = hsync, hds = hpre, hde = hds + cpp * h, ht = hde + hpost
|
||||
unsigned hpe = hsync, hds = hpre, hde = hds + h, ht = hde + hpost
|
||||
|
||||
cpm_stop_lcd ()
|
||||
|
||||
@@ -156,17 +156,11 @@ static void reset ():
|
||||
CPM_CFCR |= CPM_CFCR_UPE
|
||||
#elif defined (NANONOTE)
|
||||
unsigned val = cpm_get_pllout2 () / pixclock - 1
|
||||
kdebug ("clock: ")
|
||||
kdebug_num (val)
|
||||
kdebug ("\n")
|
||||
//assert (val < 0x400)
|
||||
//cpm_set_pixdiv (val)
|
||||
//cpm_set_pixdiv (12)
|
||||
|
||||
val = cpm_get_pllout2 () / (pixclock * 3) - 1
|
||||
kdebug ("clock: ")
|
||||
kdebug_num (val)
|
||||
kdebug ("\n")
|
||||
assert (val < 0x20)
|
||||
//cpm_set_ldiv (val)
|
||||
// Update dividers.
|
||||
@@ -179,7 +173,7 @@ static void reset ():
|
||||
|
||||
#ifdef NANONOTE
|
||||
// Reset the controller.
|
||||
//write_reg (BACKLIGHT1, 0x1e)
|
||||
write_reg (BACKLIGHT1, 0x1e)
|
||||
// Enable display.
|
||||
write_reg (BACKLIGHT1, 0x5f)
|
||||
// Set data to rgbrgbrgb input, with a delta color filter.
|
||||
@@ -252,6 +246,15 @@ enum captype:
|
||||
#endif
|
||||
SET_EOF_CB
|
||||
|
||||
static unsigned spot (unsigned x, unsigned y, unsigned cx, unsigned cy):
|
||||
unsigned dx2 = (x - cx) * (x - cx)
|
||||
unsigned dy2 = (y - cy) * (y - cy)
|
||||
unsigned d2 = dx2 + dy2
|
||||
unsigned l = 120
|
||||
if d2 >= l * l:
|
||||
return 0
|
||||
return ((l * l - d2 - 1) << 8) / (l * l)
|
||||
|
||||
Kernel::Num start ():
|
||||
map_lcd ()
|
||||
map_cpm ()
|
||||
@@ -265,21 +268,18 @@ Kernel::Num start ():
|
||||
assert (physical & PAGE_MASK && ~physical)
|
||||
for unsigned i = 0; i < pages; ++i:
|
||||
Kernel::Page p = Kernel::my_memory.create_page ()
|
||||
p.alloc_physical (physical + i * PAGE_SIZE, false, true)
|
||||
Kernel::my_memory.map (p, (unsigned)LCD_FRAMEBUFFER_BASE + i * PAGE_SIZE)
|
||||
p.alloc_physical (physical + (i << PAGE_BITS), false, true)
|
||||
Kernel::my_memory.map (p, (unsigned)LCD_FRAMEBUFFER_BASE + (i << PAGE_BITS))
|
||||
Kernel::free_cap (p)
|
||||
for unsigned y = 0; y < v; ++y:
|
||||
unsigned g = (y << 8) / v
|
||||
for unsigned x = 0; x < h; ++x:
|
||||
unsigned r = (x << 8) / h
|
||||
unsigned b = ((x + y) << 8) / (h + v)
|
||||
unsigned r = spot (x, y, 100, 160)
|
||||
unsigned g = spot (x, y, 160, 60)
|
||||
unsigned b = spot (x, y, 220, 160)
|
||||
#if defined (TRENDTAC)
|
||||
LCD_FRAMEBUFFER_BASE[y * h + x] = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)
|
||||
#elif defined (NANONOTE)
|
||||
LCD_FRAMEBUFFER_BASE[(y * h + x) * Bpp + 3] = 0
|
||||
LCD_FRAMEBUFFER_BASE[(y * h + x) * Bpp + 2] = r
|
||||
LCD_FRAMEBUFFER_BASE[(y * h + x) * Bpp + 1] = g
|
||||
LCD_FRAMEBUFFER_BASE[(y * h + x) * Bpp + 0] = b
|
||||
LCD_FRAMEBUFFER_BASE[y * h + x] = (r << 16) | (g << 8) | b
|
||||
#else
|
||||
#error "Define your framebuffer format."
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user