diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-09-05 23:14:07 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-09-05 23:16:27 +0200 |
commit | f40b15d0cbe726e72652fcd8ff775d08b19affda (patch) | |
tree | c1ba87d1be4dedea86825e45c30e4ee19a9b21e3 /utils/hwstub/tools/lua/sonynwze370.lua | |
parent | f13cad4c8ef0dae4393682d7da294ce63f0eb7f7 (diff) | |
download | rockbox-f40b15d0cbe726e72652fcd8ff775d08b19affda.tar.gz rockbox-f40b15d0cbe726e72652fcd8ff775d08b19affda.zip |
hwstub: improve lcdif, digtctl, add sony nwz-e370
Change-Id: I5316cc9fd9addfca8a674628695fed1c1bf9269f
Diffstat (limited to 'utils/hwstub/tools/lua/sonynwze370.lua')
-rw-r--r-- | utils/hwstub/tools/lua/sonynwze370.lua | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/utils/hwstub/tools/lua/sonynwze370.lua b/utils/hwstub/tools/lua/sonynwze370.lua new file mode 100644 index 0000000000..969a440a08 --- /dev/null +++ b/utils/hwstub/tools/lua/sonynwze370.lua | |||
@@ -0,0 +1,98 @@ | |||
1 | -- | ||
2 | -- Sony NWZ-E370 | ||
3 | -- | ||
4 | NWZE370 = {} | ||
5 | |||
6 | function NWZE370.lcd_send(cmd, data) | ||
7 | STMP.lcdif.set_data_swizzle(0) | ||
8 | STMP.lcdif.set_byte_packing_format(0xf) | ||
9 | STMP.lcdif.send_pio(false, {cmd}) | ||
10 | if #data ~= 0 then | ||
11 | STMP.lcdif.send_pio(true, data) | ||
12 | end | ||
13 | end | ||
14 | |||
15 | function NWZE370.lcd_set_update_rect(x, y, w, h) | ||
16 | NWZE370.lcd_send(0x2a, {0, x, 0, x + w - 1}) | ||
17 | NWZE370.lcd_send(0x2b, {0, y, 0, y + h - 1}) | ||
18 | NWZE370.lcd_send(0x2c, {}) | ||
19 | end | ||
20 | |||
21 | function NWZE370.lcd_init() | ||
22 | STMP.pinctrl.lcdif.setup_system(8, false) | ||
23 | STMP.lcdif.init() | ||
24 | STMP.lcdif.set_databus_width(8) | ||
25 | STMP.lcdif.set_word_length(8) | ||
26 | STMP.lcdif.set_system_timing(2, 2, 2, 2) | ||
27 | STMP.lcdif.set_byte_packing_format(0xf) | ||
28 | STMP.lcdif.set_reset(1) | ||
29 | STMP.lcdif.set_reset(0) | ||
30 | STMP.lcdif.set_reset(1) | ||
31 | |||
32 | STMP.digctl.mdelay(150) | ||
33 | NWZE370.lcd_send(1, {}) -- software reset | ||
34 | NWZE370.lcd_send(0x11, {}) -- slee out | ||
35 | STMP.digctl.mdelay(150) | ||
36 | NWZE370.lcd_send(0x26, {4}) -- gamma set (curve 3) | ||
37 | NWZE370.lcd_send(0xb1, {9, 0xd}) -- frame rate (DIVA=9, VPA=13) => 88.9 Hz ? | ||
38 | NWZE370.lcd_send(0xc0, {8, 0}) -- power control 1 (GVDD=4.4 V, VCI1=2.75 V) | ||
39 | NWZE370.lcd_send(0xc1, {5}) -- power control 2 (setting 5) | ||
40 | NWZE370.lcd_send(0xc5, {0x31, 0x40}) -- VCOM control 1 (0x31, 0x40) | ||
41 | NWZE370.lcd_send(0xc7, {0xc8}) -- VCOM offset control (0xc8) | ||
42 | NWZE370.lcd_send(0xec, {0xc}) -- | ||
43 | NWZE370.lcd_send(0x3a, {5}) -- interface pixel format (16 bit/pixel) | ||
44 | NWZE370.lcd_send(0x2a, {0, 0, 0, 0x7f}) -- column address (0, 127) | ||
45 | NWZE370.lcd_send(0x2b, {0, 0, 0, 0x9f}) -- page address set (0, 159) | ||
46 | NWZE370.lcd_send(0x35, {0}) -- tear effect line on (M=0) | ||
47 | NWZE370.lcd_send(0x36, {0xc8}) -- memory access control (MH=0, BGR, ML=MV=0, MX=MY=1) | ||
48 | NWZE370.lcd_send(0xb4, {0}) -- display inversion (NLA=NLB=NLC=0) | ||
49 | NWZE370.lcd_send(0xb7, {0}) -- source driver direction control (CRL=0) | ||
50 | NWZE370.lcd_send(0xb8, {0}) -- gate driver direction control (CTB=0) | ||
51 | NWZE370.lcd_send(0xf2, {1}) -- gamma adjustment (enable) | ||
52 | NWZE370.lcd_send(0xe0, {0x3f, 0x20, 0x1d, 0x2d, 0x26, 0xc, 0x4b, 0xb7, | ||
53 | 0x39, 0x17, 0x1d, 0x16, 0x16, 0x10, 0}) -- positive gamma | ||
54 | NWZE370.lcd_send(0xe1, {0, 0x1f, 0x21, 0x12, 0x18, 0x13, 0x34, 0x48, | ||
55 | 0x46, 8, 0x21, 0x29, 0x28, 0x2f, 0x3f}) --negative gamma | ||
56 | NWZE370.lcd_send(0x29, {}) -- display on | ||
57 | |||
58 | NWZE370.lcd_set_update_rect(10, 10, 20, 20) | ||
59 | for i = 0, 19 do | ||
60 | for j = 0, 19 do | ||
61 | pix = 0xf800 | ||
62 | STMP.lcdif.send_pio(true, {bit32.band(pix, 0xff), bit32.rshift(pix, 8)}) | ||
63 | end | ||
64 | end | ||
65 | end | ||
66 | |||
67 | function NWZE370.set_backlight(val) | ||
68 | |||
69 | end | ||
70 | |||
71 | function NWZE370.init() | ||
72 | NWZE370.lcd_init() | ||
73 | --[[ | ||
74 | HW.LRADC.CTRL0.SFTRST.clr() | ||
75 | HW.LRADC.CTRL0.CLKGATE.clr() | ||
76 | HW.LRADC.CHn[0].ACCUMULATE.clr() | ||
77 | HW.LRADC.CHn[0].NUM_SAMPLES.write(0) | ||
78 | HW.LRADC.CHn[0].VALUE.write(0) | ||
79 | local t = {} | ||
80 | for i = 1,1000,1 do | ||
81 | HW.LRADC.CTRL0.SCHEDULE.write(1) | ||
82 | --local time = HW.DIGCTL.MICROSECONDS.read() | ||
83 | local time = i * 1000 | ||
84 | local val = HW.LRADC.CHn[0].VALUE.read() | ||
85 | t[#t + 1] = {time, val} | ||
86 | end | ||
87 | local file = io.open("data.txt", "w") | ||
88 | for i,v in ipairs(t) do | ||
89 | file:write(string.format("%d %d\n", v[1] / 1000, v[2])) | ||
90 | end | ||
91 | file:close() | ||
92 | print("Display curve using:") | ||
93 | print("gnuplot -persist"); | ||
94 | print("> plot \"data.txt\" using 1:2") | ||
95 | ]]-- | ||
96 | end | ||
97 | |||
98 | |||