Skip to content

Commit 5681036

Browse files
WhatAmISupposedToPutHeremarcan
authored andcommitted
Add touchbar screen experiments
Signed-off-by: Sasha Finkelstein <[email protected]>
1 parent 91ff36b commit 5681036

3 files changed

Lines changed: 175 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
yt-dlp 'https://www.youtube.com/watch?v=UkgK8eUdpAo'
4+
ffmpeg -i *.webm -vf scale=80:60 crushed.mkv
5+
ffmpeg -i crushed.mkv -f rawvideo -pix_fmt rgb24 out.bin
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
from m1n1.hw.dart import DART
2+
from m1n1.utils import *
3+
4+
dart = DART.from_adt(u, "arm-io/dart-dispdfr")
5+
6+
width = 2040
7+
height = 60
8+
stride = 64
9+
10+
def make_fb():
11+
width = 80
12+
fb_size = align_up(width * stride * 4, 8 * 0x4000)
13+
buf = u.memalign(0x4000, fb_size)
14+
return (dart.iomap(0, buf, fb_size), buf)
15+
16+
17+
width = 2040
18+
fb_size = align_up(width * stride * 4, 8 * 0x4000)
19+
buf_mask = u.memalign(0x4000, fb_size)
20+
p.memset32(buf_mask, 0, fb_size)
21+
p.memset32(buf_mask, 0xFFFFFFFF, 10*stride)
22+
iova_mask = dart.iomap(0, buf_mask, fb_size)
23+
p.write32(0x228202200, iova_mask)
24+
25+
dart.dump_device(0)
26+
27+
#enable backlight
28+
p.write32(0x228600070,0x8051)
29+
p.write32(0x22860006c,0x229)
30+
31+
#enable fifo and vblank
32+
p.write32(0x228400100, 0x613)
33+
34+
# Color correction magic (idk why but it makes colors actually work)
35+
p.write32(0x228202074, 0x1)
36+
p.write32(0x228202028, 0x10)
37+
p.write32(0x22820202c, 0x1)
38+
p.write32(0x228202020, 0x1)
39+
p.write32(0x228202034, 0x1)
40+
41+
42+
#layer enable
43+
p.write32(0x228204020, 0x1)
44+
p.write32(0x228204068, 0x1)
45+
p.write32(0x2282040b4, 0x1)
46+
p.write32(0x2282040f4, 0x1)
47+
p.write32(0x2282040ac, 0x100000)
48+
p.write32(0x228201038, 0x10001)
49+
50+
#layer size
51+
p.write32(0x228204048, height << 16 | width)
52+
p.write32(0x22820404c, height << 16 | width)
53+
p.write32(0x22820407c, height << 16 | width)
54+
p.write32(0x228204054, height << 16 | width)
55+
56+
#global size
57+
p.write32(0x228201030, height << 16 | width)
58+
59+
#some more color correction
60+
p.write32(0x22820402c, 0x53e4001)
61+
62+
def make_pipe(iova):
63+
pipe = [
64+
0x20014038,
65+
0x2a | (stride * 4),
66+
0x20014030,
67+
0x2a | iova,
68+
]
69+
pipe = [0xc0000001 | (len(pipe) << 16)] + pipe
70+
return pipe
71+
72+
def flush(pipe):
73+
for i in pipe:
74+
p.write32(0x2282010c0, i)
75+
76+
data = open('out.bin', 'rb').read()
77+
def play():
78+
frame = 0
79+
while 1:
80+
iova, base = make_fb()
81+
for y in range(60):
82+
for x in range(80):
83+
pix = data[(x + y * 80 + frame * 80 * 60) * 3]
84+
pos = base + ((60 - y) + x * 64) * 4
85+
if pix < 128:
86+
p.write32(pos, 0)
87+
else:
88+
p.write32(pos, 0x00FFFFFF)
89+
flush(make_pipe(iova))
90+
frame += 1
91+
92+
play()
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
from m1n1.hw.dart import DART
2+
from m1n1.utils import *
3+
4+
dart = DART.from_adt(u, "arm-io/dart-dispdfr")
5+
6+
width = 2040
7+
height = 60
8+
stride = 64
9+
10+
fb_size = align_up(width * stride * 4, 8 * 0x4000)
11+
buf = u.memalign(0x4000, fb_size)
12+
13+
colors = [0xDD0000, 0xFE6230, 0xFEF600, 0x00BB00, 0x009BFE, 0x000083, 0x30009B]
14+
for i, color in enumerate(colors):
15+
lines = stride // len(colors)
16+
offset = i * lines * width * 4
17+
p.memset32(buf + offset, color, lines * width * 4)
18+
19+
20+
21+
iova = dart.iomap(0, buf, fb_size)
22+
buf_mask = u.memalign(0x4000, fb_size)
23+
p.memset32(buf_mask, 0xFFFFFFFF, fb_size)
24+
iova_mask = dart.iomap(0, buf_mask, fb_size)
25+
p.write32(0x228202200, iova_mask)
26+
27+
dart.dump_device(0)
28+
29+
#enable backlight
30+
p.write32(0x228600070,0x8051)
31+
p.write32(0x22860006c,0x229)
32+
33+
#enable fifo and vblank
34+
p.write32(0x228400100, 0x613)
35+
36+
# Color correction magic (idk why but it makes colors actually work)
37+
p.write32(0x228202074, 0x1)
38+
p.write32(0x228202028, 0x10)
39+
p.write32(0x22820202c, 0x1)
40+
p.write32(0x228202020, 0x1)
41+
p.write32(0x228202034, 0x1)
42+
43+
44+
#layer enable
45+
p.write32(0x228204020, 0x1)
46+
p.write32(0x228204068, 0x1)
47+
p.write32(0x2282040b4, 0x1)
48+
p.write32(0x2282040f4, 0x1)
49+
p.write32(0x2282040ac, 0x100000)
50+
p.write32(0x228201038, 0x10001)
51+
52+
#layer size
53+
p.write32(0x228204048, height << 16 | width)
54+
p.write32(0x22820404c, height << 16 | width)
55+
p.write32(0x22820407c, height << 16 | width)
56+
p.write32(0x228204054, height << 16 | width)
57+
58+
#global size
59+
p.write32(0x228201030, height << 16 | width)
60+
61+
#some more color correction
62+
p.write32(0x22820402c, 0x53e4001)
63+
64+
65+
pipe = [
66+
0x20014038,
67+
0x2a | (stride * 4),
68+
0x20014030,
69+
0x2a | iova,
70+
]
71+
72+
pipe = [0xc0000001 | (len(pipe) << 16)] + pipe
73+
74+
def flush(pipe):
75+
for i in pipe:
76+
p.write32(0x2282010c0, i)
77+
78+
flush(pipe)

0 commit comments

Comments
 (0)