| 881 |
theseven |
1 |
#include "global.h"
|
|
|
2 |
#include "board/ipodnano2g/lcd.h"
|
|
|
3 |
#include "interface/lcd/lcd.h"
|
|
|
4 |
#include "interface/lcdif/lcdif.h"
|
|
|
5 |
#include "interface/backlight_manager/backlight_manager.h"
|
|
|
6 |
#include "soc/s5l87xx/regs.h"
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
static void n2g_lcd_send_cmd(const struct lcdif_instance* interface, int cmd)
|
|
|
10 |
{
|
|
|
11 |
interface->driver->send_cmd(interface, cmd);
|
|
|
12 |
}
|
|
|
13 |
|
|
|
14 |
static void n2g_lcd_send_data(const struct lcdif_instance* interface, int data)
|
|
|
15 |
{
|
|
|
16 |
interface->driver->send_data(interface, data);
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
static void n2g_lcd_init(const struct lcd_instance* instance)
|
|
|
20 |
{
|
|
|
21 |
const struct ipodnano2g_lcd_config* data = (const struct ipodnano2g_lcd_config*)instance->driver_config;
|
|
|
22 |
data->interface->driver->init(data->interface);
|
|
|
23 |
if (data->backlight) data->backlight->driver->init(data->backlight);
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
enum framebuffer_format n2g_lcd_get_native_format(const struct lcd_instance* instance)
|
|
|
27 |
{
|
|
|
28 |
return FRAMEBUFFER_FORMAT_R5G6B5_LE;
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
static void n2g_lcd_power(const struct lcd_instance* instance, bool on)
|
|
|
32 |
{
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
static void n2g_lcd_backlight(const struct lcd_instance* instance, int brightness)
|
|
|
36 |
{
|
|
|
37 |
const struct ipodnano2g_lcd_config* data = (const struct ipodnano2g_lcd_config*)instance->driver_config;
|
|
|
38 |
if (!data->backlight) return;
|
|
|
39 |
data->backlight->driver->set_brightness(data->backlight, brightness);
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
static void n2g_lcd_setup_range(const struct lcd_instance* instance, int x, int y, int w, int h)
|
|
|
43 |
{
|
|
|
44 |
const struct ipodnano2g_lcd_config* data = (const struct ipodnano2g_lcd_config*)instance->driver_config;
|
|
|
45 |
const struct lcdif_instance* interface = data->interface;
|
|
|
46 |
int type = (PDAT13 & 1) | (PDAT14 & 2);
|
|
|
47 |
if (type == 2)
|
|
|
48 |
{
|
|
|
49 |
n2g_lcd_send_cmd(interface, 0x50);
|
|
|
50 |
n2g_lcd_send_data(interface, x);
|
|
|
51 |
n2g_lcd_send_cmd(interface, 0x51);
|
|
|
52 |
n2g_lcd_send_data(interface, x + w - 1);
|
|
|
53 |
n2g_lcd_send_cmd(interface, 0x52);
|
|
|
54 |
n2g_lcd_send_data(interface, y);
|
|
|
55 |
n2g_lcd_send_cmd(interface, 0x53);
|
|
|
56 |
n2g_lcd_send_data(interface, y + h - 1);
|
|
|
57 |
n2g_lcd_send_cmd(interface, 0x20);
|
|
|
58 |
n2g_lcd_send_data(interface, x);
|
|
|
59 |
n2g_lcd_send_cmd(interface, 0x21);
|
|
|
60 |
n2g_lcd_send_data(interface, y);
|
|
|
61 |
n2g_lcd_send_cmd(interface, 0x22);
|
|
|
62 |
}
|
|
|
63 |
else
|
|
|
64 |
{
|
|
|
65 |
n2g_lcd_send_cmd(interface, 0x2a);
|
|
|
66 |
n2g_lcd_send_data(interface, x);
|
|
|
67 |
n2g_lcd_send_data(interface, x + w - 1);
|
|
|
68 |
n2g_lcd_send_cmd(interface, 0x2b);
|
|
|
69 |
n2g_lcd_send_data(interface, y);
|
|
|
70 |
n2g_lcd_send_data(interface, y + h - 1);
|
|
|
71 |
n2g_lcd_send_cmd(interface, 0x2c);
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
static void n2g_lcd_fill_pixels(const struct lcd_instance* instance, uint32_t color, int count)
|
|
|
76 |
{
|
|
|
77 |
const struct ipodnano2g_lcd_config* data = (const struct ipodnano2g_lcd_config*)instance->driver_config;
|
|
|
78 |
const struct lcdif_instance* interface = data->interface;
|
|
|
79 |
interface->driver->send_repeat(interface, color, count);
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
static void n2g_lcd_blit_pixels(const struct lcd_instance* instance, void* buffer, int count)
|
|
|
83 |
{
|
|
|
84 |
const struct ipodnano2g_lcd_config* data = (const struct ipodnano2g_lcd_config*)instance->driver_config;
|
|
|
85 |
const struct lcdif_instance* interface = data->interface;
|
|
|
86 |
interface->driver->send_bulk(interface, buffer, count);
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
const struct lcd_driver ipodnano2g_lcd_driver =
|
|
|
91 |
{
|
|
|
92 |
.init = n2g_lcd_init,
|
|
|
93 |
.get_native_format = n2g_lcd_get_native_format,
|
|
|
94 |
.power = n2g_lcd_power,
|
|
|
95 |
.backlight = n2g_lcd_backlight,
|
|
|
96 |
.setup_range = n2g_lcd_setup_range,
|
|
|
97 |
.fill_pixels = n2g_lcd_fill_pixels,
|
|
|
98 |
.blit_pixels = n2g_lcd_blit_pixels,
|
|
|
99 |
};
|