diff options
Diffstat (limited to 'utils/hwstub/tools')
-rw-r--r-- | utils/hwstub/tools/lua/sonynwze360.lua | 182 | ||||
-rw-r--r-- | utils/hwstub/tools/lua/sonynwze370.lua | 10 |
2 files changed, 189 insertions, 3 deletions
diff --git a/utils/hwstub/tools/lua/sonynwze360.lua b/utils/hwstub/tools/lua/sonynwze360.lua new file mode 100644 index 0000000000..368cfb498a --- /dev/null +++ b/utils/hwstub/tools/lua/sonynwze360.lua | |||
@@ -0,0 +1,182 @@ | |||
1 | -- | ||
2 | -- Sony NWZ-E370 | ||
3 | -- | ||
4 | NWZE360 = {} | ||
5 | |||
6 | function NWZE360.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 cmd ~= 0x22 then | ||
11 | STMP.lcdif.send_pio(true, {data}) | ||
12 | end | ||
13 | end | ||
14 | |||
15 | function NWZE360.lcd_set_update_rect(x, y, w, h) | ||
16 | NWZE360.lcd_send(2, bit32.rshift(x, 8)) | ||
17 | NWZE360.lcd_send(3, bit32.band(x, 0xff)) | ||
18 | NWZE360.lcd_send(4, bit32.rshift(x + w - 1, 8)) | ||
19 | NWZE360.lcd_send(5, bit32.band(x + w - 1, 0xff)) | ||
20 | NWZE360.lcd_send(6, bit32.rshift(y, 8)) | ||
21 | NWZE360.lcd_send(7, bit32.band(y, 0xff)) | ||
22 | NWZE360.lcd_send(8, bit32.rshift(y + h - 1, 8)) | ||
23 | NWZE360.lcd_send(9, bit32.band(y + h - 1, 0xff)) | ||
24 | NWZE360.lcd_send(0x22, 0) | ||
25 | end | ||
26 | |||
27 | function NWZE360.lcd_enable(en) | ||
28 | if not en then | ||
29 | NWZE360.lcd_send(0x1f, 0xd1) | ||
30 | NWZE360.lcd_send(1, 0x40) | ||
31 | NWZE360.lcd_send(1, 0xc0) | ||
32 | NWZE360.lcd_send(0x19, 1) | ||
33 | else | ||
34 | NWZE360.lcd_send(0x19, 0x81) | ||
35 | STMP.digctl.udelay(5000) | ||
36 | NWZE360.lcd_send(1, 0x40) | ||
37 | STMP.digctl.udelay(20000) | ||
38 | NWZE360.lcd_send(1, 0) | ||
39 | NWZE360.lcd_send(0x1f, 0xd0) | ||
40 | end | ||
41 | end | ||
42 | |||
43 | function NWZE360.lcd_init() | ||
44 | STMP.lcdif.setup_clock() | ||
45 | STMP.pinctrl.lcdif.setup_system(8, false) | ||
46 | STMP.lcdif.init() | ||
47 | STMP.lcdif.set_databus_width(8) | ||
48 | STMP.lcdif.set_word_length(8) | ||
49 | STMP.lcdif.set_system_timing(1, 1, 1, 1) | ||
50 | STMP.lcdif.set_byte_packing_format(0xf) | ||
51 | STMP.lcdif.set_reset(1) | ||
52 | STMP.lcdif.set_reset(0) | ||
53 | STMP.lcdif.set_reset(1) | ||
54 | |||
55 | NWZE360.lcd_send(0xEA, 0) | ||
56 | NWZE360.lcd_send(0xEB, 0x20) | ||
57 | NWZE360.lcd_send(0xEC, 0xC) | ||
58 | NWZE360.lcd_send(0xED, 0xC4) | ||
59 | NWZE360.lcd_send(0xE8, 0x38) | ||
60 | NWZE360.lcd_send(0xE9, 0xE) | ||
61 | NWZE360.lcd_send(0xF1, 1) | ||
62 | NWZE360.lcd_send(0xF2, 8) | ||
63 | NWZE360.lcd_send(0x2E, 0x86) | ||
64 | NWZE360.lcd_send(0x29, 0xFF) | ||
65 | NWZE360.lcd_send(0xE4, 1) | ||
66 | NWZE360.lcd_send(0xE5, 0x20) | ||
67 | NWZE360.lcd_send(0xE7, 1) | ||
68 | NWZE360.lcd_send(0x40, 0) | ||
69 | NWZE360.lcd_send(0x41, 0) | ||
70 | NWZE360.lcd_send(0x42, 0) | ||
71 | NWZE360.lcd_send(0x43, 0x14) | ||
72 | NWZE360.lcd_send(0x44, 0x14) | ||
73 | NWZE360.lcd_send(0x45, 0x28) | ||
74 | NWZE360.lcd_send(0x46, 0x11) | ||
75 | NWZE360.lcd_send(0x47, 0x57) | ||
76 | NWZE360.lcd_send(0x48, 5) | ||
77 | NWZE360.lcd_send(0x49, 0x16) | ||
78 | NWZE360.lcd_send(0x4A, 0x19) | ||
79 | NWZE360.lcd_send(0x4B, 0x1A) | ||
80 | NWZE360.lcd_send(0x4C, 0x1A) | ||
81 | NWZE360.lcd_send(0x50, 0x17) | ||
82 | NWZE360.lcd_send(0x51, 0x2B) | ||
83 | NWZE360.lcd_send(0x52, 0x2B) | ||
84 | NWZE360.lcd_send(0x53, 0x3F) | ||
85 | NWZE360.lcd_send(0x54, 0x3F) | ||
86 | NWZE360.lcd_send(0x55, 0x3F) | ||
87 | NWZE360.lcd_send(0x56, 0x28) | ||
88 | NWZE360.lcd_send(0x57, 0x6E) | ||
89 | NWZE360.lcd_send(0x58, 5) | ||
90 | NWZE360.lcd_send(0x59, 5) | ||
91 | NWZE360.lcd_send(0x5A, 6) | ||
92 | NWZE360.lcd_send(0x5B, 9) | ||
93 | NWZE360.lcd_send(0x5C, 0x1A) | ||
94 | NWZE360.lcd_send(0x5D, 0xCC) | ||
95 | NWZE360.lcd_send(0x1B, 0x1B) | ||
96 | NWZE360.lcd_send(0x1A, 1) | ||
97 | NWZE360.lcd_send(0x24, 0x2F) -- something special here | ||
98 | NWZE360.lcd_send(0x25, 0x57) -- something special here | ||
99 | NWZE360.lcd_send(0x23, 0x8A) | ||
100 | NWZE360.lcd_send(0x2F, 1) | ||
101 | NWZE360.lcd_send(0x60, 0) | ||
102 | NWZE360.lcd_send(0x16, 8) | ||
103 | NWZE360.lcd_send(0x18, 0x36) -- something special here | ||
104 | NWZE360.lcd_send(0x19, 1) | ||
105 | STMP.digctl.udelay(5000) | ||
106 | NWZE360.lcd_send(1, 0) | ||
107 | NWZE360.lcd_send(0x1F, 0x88) | ||
108 | STMP.digctl.udelay(5000) | ||
109 | NWZE360.lcd_send(0x1F, 0x80) | ||
110 | STMP.digctl.udelay(5000) | ||
111 | NWZE360.lcd_send(0x1F, 0x90) | ||
112 | STMP.digctl.udelay(5000) | ||
113 | NWZE360.lcd_send(0x1F, 0xD0) | ||
114 | STMP.digctl.udelay(5000) | ||
115 | NWZE360.lcd_send(0x17, 6) | ||
116 | NWZE360.lcd_send(0x37, 0) | ||
117 | NWZE360.lcd_send(0x28, 0x38) | ||
118 | STMP.digctl.udelay(40000) | ||
119 | NWZE360.lcd_send(0x28, 0x3C) | ||
120 | |||
121 | --NWZE360.lcd_send(0x36, 0x0) -- experimental | ||
122 | --NWZE360.lcd_send(0x16, 8 + 0x60) -- redraw with landscape orientation | ||
123 | |||
124 | NWZE360.set_backlight(100) | ||
125 | |||
126 | NWZE360.lcd_set_update_rect(0, 0, 240, 320) | ||
127 | STMP.lcdif.set_word_length(8) | ||
128 | for i = 0, 240 do | ||
129 | for j = 0, 320 do | ||
130 | r = 0x1f | ||
131 | g = 0x3f | ||
132 | b = 0x1f | ||
133 | pix = bit32.bor(r, bit32.bor(bit32.lshift(g, 6), bit32.lshift(b, 11))) | ||
134 | STMP.lcdif.send_pio(true, {bit32.band(pix, 0xff), bit32.rshift(pix, 8)}) | ||
135 | --STMP.lcdif.send_pio(true, {pix}) | ||
136 | end | ||
137 | end | ||
138 | end | ||
139 | |||
140 | function NWZE360.set_backlight(val) | ||
141 | STMP.pinctrl.pin(0, 10).muxsel('GPIO') | ||
142 | STMP.pinctrl.pin(0, 10).enable() | ||
143 | STMP.pinctrl.pin(0, 10).set() | ||
144 | end | ||
145 | |||
146 | function NWZE360.init() | ||
147 | NWZE360.lcd_init() | ||
148 | NWZE360.set_backlight(100) | ||
149 | STMP.i2c.init() | ||
150 | STMP.i2c.set_speed(true) | ||
151 | for i = 2, 254, 2 do | ||
152 | if STMP.i2c.transmit(i, {}, true) then | ||
153 | print(string.format("%#x OK", i)) | ||
154 | end | ||
155 | end | ||
156 | --[[ | ||
157 | HW.LRADC.CTRL0.SFTRST.clr() | ||
158 | HW.LRADC.CTRL0.CLKGATE.clr() | ||
159 | HW.LRADC.CHn[0].ACCUMULATE.clr() | ||
160 | HW.LRADC.CHn[0].NUM_SAMPLES.write(0) | ||
161 | HW.LRADC.CHn[0].VALUE.write(0) | ||
162 | local t = {} | ||
163 | for i = 1,1000,1 do | ||
164 | HW.LRADC.CTRL0.SCHEDULE.write(1) | ||
165 | --local time = HW.DIGCTL.MICROSECONDS.read() | ||
166 | local time = i * 1000 | ||
167 | local val = HW.LRADC.CHn[0].VALUE.read() | ||
168 | t[#t + 1] = {time, val} | ||
169 | end | ||
170 | local file = io.open("data.txt", "w") | ||
171 | for i,v in ipairs(t) do | ||
172 | file:write(string.format("%d %d\n", v[1] / 1000, v[2])) | ||
173 | end | ||
174 | file:close() | ||
175 | print("Display curve using:") | ||
176 | print("gnuplot -persist") | ||
177 | print("> plot \"data.txt\" using 1:2") | ||
178 | ]]-- | ||
179 | end | ||
180 | |||
181 | |||
182 | |||
diff --git a/utils/hwstub/tools/lua/sonynwze370.lua b/utils/hwstub/tools/lua/sonynwze370.lua index 969a440a08..ef9e8cb4e7 100644 --- a/utils/hwstub/tools/lua/sonynwze370.lua +++ b/utils/hwstub/tools/lua/sonynwze370.lua | |||
@@ -19,6 +19,7 @@ function NWZE370.lcd_set_update_rect(x, y, w, h) | |||
19 | end | 19 | end |
20 | 20 | ||
21 | function NWZE370.lcd_init() | 21 | function NWZE370.lcd_init() |
22 | STMP.lcdif.setup_clock() | ||
22 | STMP.pinctrl.lcdif.setup_system(8, false) | 23 | STMP.pinctrl.lcdif.setup_system(8, false) |
23 | STMP.lcdif.init() | 24 | STMP.lcdif.init() |
24 | STMP.lcdif.set_databus_width(8) | 25 | STMP.lcdif.set_databus_width(8) |
@@ -55,9 +56,9 @@ function NWZE370.lcd_init() | |||
55 | 0x46, 8, 0x21, 0x29, 0x28, 0x2f, 0x3f}) --negative gamma | 56 | 0x46, 8, 0x21, 0x29, 0x28, 0x2f, 0x3f}) --negative gamma |
56 | NWZE370.lcd_send(0x29, {}) -- display on | 57 | NWZE370.lcd_send(0x29, {}) -- display on |
57 | 58 | ||
58 | NWZE370.lcd_set_update_rect(10, 10, 20, 20) | 59 | NWZE370.lcd_set_update_rect(10, 10, 20, 10) |
59 | for i = 0, 19 do | 60 | for i = 0, 19 do |
60 | for j = 0, 19 do | 61 | for j = 0, 9 do |
61 | pix = 0xf800 | 62 | pix = 0xf800 |
62 | STMP.lcdif.send_pio(true, {bit32.band(pix, 0xff), bit32.rshift(pix, 8)}) | 63 | STMP.lcdif.send_pio(true, {bit32.band(pix, 0xff), bit32.rshift(pix, 8)}) |
63 | end | 64 | end |
@@ -65,11 +66,14 @@ function NWZE370.lcd_init() | |||
65 | end | 66 | end |
66 | 67 | ||
67 | function NWZE370.set_backlight(val) | 68 | function NWZE370.set_backlight(val) |
68 | 69 | STMP.pinctrl.pin(0, 10).muxsel('GPIO') | |
70 | STMP.pinctrl.pin(0, 10).enable() | ||
71 | STMP.pinctrl.pin(0, 10).set() | ||
69 | end | 72 | end |
70 | 73 | ||
71 | function NWZE370.init() | 74 | function NWZE370.init() |
72 | NWZE370.lcd_init() | 75 | NWZE370.lcd_init() |
76 | NWZE370.set_backlight(100) | ||
73 | --[[ | 77 | --[[ |
74 | HW.LRADC.CTRL0.SFTRST.clr() | 78 | HW.LRADC.CTRL0.SFTRST.clr() |
75 | HW.LRADC.CTRL0.CLKGATE.clr() | 79 | HW.LRADC.CTRL0.CLKGATE.clr() |