| 881 |
theseven |
1 |
#include "global.h"
|
|
|
2 |
#include "board/ipodclassic/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 ipcl_lcd_send_cmd(const struct lcdif_instance* interface, int cmd)
|
|
|
10 |
{
|
|
|
11 |
interface->driver->send_cmd(interface, cmd);
|
|
|
12 |
}
|
|
|
13 |
|
|
|
14 |
static void ipcl_lcd_send_data(const struct lcdif_instance* interface, int data)
|
|
|
15 |
{
|
|
|
16 |
interface->driver->send_data(interface, data);
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
static void ipcl_lcd_init(const struct lcd_instance* instance)
|
|
|
20 |
{
|
|
|
21 |
const struct ipodclassic_lcd_config* data = (const struct ipodclassic_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 ipcl_lcd_get_native_format(const struct lcd_instance* instance)
|
|
|
27 |
{
|
|
|
28 |
return FRAMEBUFFER_FORMAT_R5G6B5_LE;
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
static void ipcl_lcd_power(const struct lcd_instance* instance, bool on)
|
|
|
32 |
{
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
static void ipcl_lcd_backlight(const struct lcd_instance* instance, int brightness)
|
|
|
36 |
{
|
|
|
37 |
const struct ipodclassic_lcd_config* data = (const struct ipodclassic_lcd_config*)instance->driver_config;
|
|
|
38 |
if (!data->backlight) return;
|
|
|
39 |
data->backlight->driver->set_brightness(data->backlight, brightness);
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
static void ipcl_lcd_setup_range(const struct lcd_instance* instance, int x, int y, int w, int h)
|
|
|
43 |
{
|
|
|
44 |
const struct ipodclassic_lcd_config* data = (const struct ipodclassic_lcd_config*)instance->driver_config;
|
|
|
45 |
const struct lcdif_instance* interface = data->interface;
|
|
|
46 |
int type = (PDAT6 & 0x30) >> 4;
|
|
|
47 |
if (type & 2)
|
|
|
48 |
{
|
|
|
49 |
ipcl_lcd_send_cmd(interface, 0x210);
|
|
|
50 |
ipcl_lcd_send_data(interface, x);
|
|
|
51 |
ipcl_lcd_send_cmd(interface, 0x211);
|
|
|
52 |
ipcl_lcd_send_data(interface, x + w - 1);
|
|
|
53 |
ipcl_lcd_send_cmd(interface, 0x212);
|
|
|
54 |
ipcl_lcd_send_data(interface, y);
|
|
|
55 |
ipcl_lcd_send_cmd(interface, 0x213);
|
|
|
56 |
ipcl_lcd_send_data(interface, y + h - 1);
|
|
|
57 |
ipcl_lcd_send_cmd(interface, 0x200);
|
|
|
58 |
ipcl_lcd_send_data(interface, x);
|
|
|
59 |
ipcl_lcd_send_cmd(interface, 0x201);
|
|
|
60 |
ipcl_lcd_send_data(interface, y);
|
|
|
61 |
ipcl_lcd_send_cmd(interface, 0x202);
|
|
|
62 |
}
|
|
|
63 |
else
|
|
|
64 |
{
|
|
|
65 |
ipcl_lcd_send_cmd(interface, 0x2a);
|
|
|
66 |
ipcl_lcd_send_data(interface, x >> 8);
|
|
|
67 |
ipcl_lcd_send_data(interface, x & 0xff);
|
|
|
68 |
ipcl_lcd_send_data(interface, (x + w - 1) >> 8);
|
|
|
69 |
ipcl_lcd_send_data(interface, (x + w - 1) & 0xff);
|
|
|
70 |
ipcl_lcd_send_cmd(interface, 0x2b);
|
|
|
71 |
ipcl_lcd_send_data(interface, y >> 8);
|
|
|
72 |
ipcl_lcd_send_data(interface, y & 0xff);
|
|
|
73 |
ipcl_lcd_send_data(interface, (y + h - 1) >> 8);
|
|
|
74 |
ipcl_lcd_send_data(interface, (y + h - 1) & 0xff);
|
|
|
75 |
ipcl_lcd_send_cmd(interface, 0x2c);
|
|
|
76 |
}
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
static void ipcl_lcd_fill_pixels(const struct lcd_instance* instance, uint32_t color, int count)
|
|
|
80 |
{
|
|
|
81 |
const struct ipodclassic_lcd_config* data = (const struct ipodclassic_lcd_config*)instance->driver_config;
|
|
|
82 |
const struct lcdif_instance* interface = data->interface;
|
|
|
83 |
interface->driver->send_repeat(interface, color, count);
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
static void ipcl_lcd_blit_pixels(const struct lcd_instance* instance, void* buffer, int count)
|
|
|
87 |
{
|
|
|
88 |
const struct ipodclassic_lcd_config* data = (const struct ipodclassic_lcd_config*)instance->driver_config;
|
|
|
89 |
const struct lcdif_instance* interface = data->interface;
|
|
|
90 |
interface->driver->send_bulk(interface, buffer, count);
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
const struct lcd_driver ipodclassic_lcd_driver =
|
|
|
95 |
{
|
|
|
96 |
.init = ipcl_lcd_init,
|
|
|
97 |
.get_native_format = ipcl_lcd_get_native_format,
|
|
|
98 |
.power = ipcl_lcd_power,
|
|
|
99 |
.backlight = ipcl_lcd_backlight,
|
|
|
100 |
.setup_range = ipcl_lcd_setup_range,
|
|
|
101 |
.fill_pixels = ipcl_lcd_fill_pixels,
|
|
|
102 |
.blit_pixels = ipcl_lcd_blit_pixels,
|
|
|
103 |
};
|