Skip to content

Commit c6169c1

Browse files
ArcaneNibblemarcan
authored andcommitted
jpeg: Import register definitions
This comes from experiments that were performed out-of-tree Signed-off-by: R <[email protected]>
1 parent 0f6991c commit c6169c1

1 file changed

Lines changed: 299 additions & 0 deletions

File tree

proxyclient/m1n1/hw/jpeg.py

Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
# SPDX-License-Identifier: MIT
2+
from ..utils import *
3+
from enum import IntEnum
4+
5+
6+
class R_STATUS(Register32):
7+
DONE = 0
8+
TIMEOUT = 1
9+
RD_BUF_OVERFLOW = 2
10+
WR_BUF_OVERFLOW = 3
11+
CODEC_BUF_OVERFLOW = 4
12+
SOME_KIND_OF_MACROBLOCK_SIZE_ERROR = 5
13+
AXI_ERROR = 6
14+
15+
16+
class E_CODEC(IntEnum):
17+
_444 = 0
18+
_422 = 1
19+
_411 = 2
20+
_420 = 3
21+
_400 = 4
22+
23+
24+
class R_CODEC(Register32):
25+
CODEC = 31, 0, E_CODEC # FIXME actual width
26+
27+
28+
class E_ENCODE_PIXEL_FORMAT(IntEnum):
29+
RGB101010 = 0
30+
YUV10_linear = 1 # partially tested, details not understood
31+
RGB888 = 2
32+
RGB565 = 3
33+
YUV_planar = 4 # partially tested, details not understood
34+
YUV_linear = 5 # partially tested, details not understood
35+
36+
37+
class R_ENCODE_PIXEL_FORMAT(Register32):
38+
FORMAT = 31, 0, E_ENCODE_PIXEL_FORMAT # FIXME actual width
39+
40+
41+
class E_SCALE(IntEnum):
42+
DIV1 = 0
43+
DIV2 = 1
44+
DIV4 = 2
45+
DIV8 = 3
46+
47+
48+
class R_SCALE_FACTOR(Register32):
49+
SCALE = 31, 0, E_SCALE # FIXME actual width
50+
51+
52+
class E_DECODE_PIXEL_FORMAT(IntEnum):
53+
YUV444_planar = 0
54+
YUV422_planar = 1
55+
YUV420_planar = 2
56+
YUV422_linear = 3
57+
_YUV10_broken_doesnt_work = 4
58+
RGBA888 = 5
59+
RGB565 = 6
60+
_RGB101010_broken_doesnt_work = 7
61+
62+
63+
class R_DECODE_PIXEL_FORMAT(Register32):
64+
FORMAT = 31, 0, E_DECODE_PIXEL_FORMAT # FIXME actual width
65+
66+
67+
class E_JPEG_IO_FLAGS_SUBSAMPLING(IntEnum):
68+
_444 = 0
69+
_422 = 1
70+
_420 = 2
71+
_400 = 3
72+
FOUR_COMPONENTS_MODE = 4
73+
_411_BROKEN = 6
74+
75+
76+
class R_JPEG_IO_FLAGS(Register32):
77+
SUBSAMPLING_MODE = 2, 0, E_JPEG_IO_FLAGS_SUBSAMPLING
78+
# not sure what this is supposed to do
79+
MAKE_DECODE_WORK_BREAK_ENCODE = 3
80+
OUTPUT_MACROBLOCKS_UNFLIPPED_H = 4
81+
OUTPUT_8BYTE_CHUNKS_CORRECTLY = 5
82+
83+
84+
class R_JPEG_OUTPUT_FLAGS(Register32):
85+
# bit0 doesn't seem to do anything
86+
SKIP_HEADERS = 1 # output only SOS/EOI, no SOI/DQT/SOF0/DHT
87+
OUTPUT_SOF0_AFTER_DHT = 2 # output SOF0 after DHT instead of before it
88+
# bit3 doesn't seem to do anything
89+
COMPRESS_WORSE = 4 # not sure exactly what this does
90+
91+
92+
class R_QTBL_SEL(Register32):
93+
COMPONENT0 = 1, 0
94+
COMPONENT1 = 3, 2
95+
COMPONENT2 = 5, 4
96+
COMPONENT3 = 7, 6 # guessed
97+
98+
99+
class JPEGRegs(RegMap):
100+
REG_0x0 = 0x0, Register32
101+
REG_0x4 = 0x4, Register32
102+
MODE = 0x8, Register32
103+
REG_0xc = 0xc, Register32
104+
105+
REG_0x20 = 0x20, Register32
106+
STATUS = 0x24, R_STATUS
107+
108+
CODEC = 0x28, R_CODEC
109+
110+
REG_0x2c = 0x2c, Register32
111+
REG_0x30 = 0x30, Register32
112+
REG_0x34 = 0x34, Register32
113+
# this changes the output drastically if set to 1 for decode
114+
# breaks encode if not set to 1
115+
REG_0x38 = 0x38, Register32
116+
117+
# not sure what the difference is. siting? type2 seems to win over type1
118+
CHROMA_HALVE_H_TYPE1 = 0x3c, Register32
119+
CHROMA_HALVE_H_TYPE2 = 0x40, Register32
120+
CHROMA_HALVE_V_TYPE1 = 0x44, Register32
121+
CHROMA_HALVE_V_TYPE2 = 0x48, Register32
122+
123+
# if double and quadruple both set --> double
124+
CHROMA_DOUBLE_H = 0x4c, Register32
125+
CHROMA_QUADRUPLE_H = 0x50, Register32
126+
CHROMA_DOUBLE_V = 0x54, Register32
127+
128+
# details not fully understood yet
129+
PX_USE_PLANE1 = 0x58, Register32
130+
PX_TILES_W = 0x5c, Register32
131+
PX_TILES_H = 0x60, Register32
132+
PX_PLANE0_WIDTH = 0x64, Register32
133+
PX_PLANE0_HEIGHT = 0x68, Register32
134+
PX_PLANE0_TILING_H = 0x6c, Register32
135+
PX_PLANE0_TILING_V = 0x70, Register32
136+
PX_PLANE0_STRIDE = 0x74, Register32
137+
PX_PLANE1_WIDTH = 0x78, Register32
138+
PX_PLANE1_HEIGHT = 0x7c, Register32
139+
PX_PLANE1_TILING_H = 0x80, Register32
140+
PX_PLANE1_TILING_V = 0x84, Register32
141+
PX_PLANE1_STRIDE = 0x88, Register32
142+
143+
INPUT_START1 = 0x8c, Register32
144+
INPUT_START2 = 0x90, Register32
145+
REG_0x94 = 0x94, Register32
146+
REG_0x98 = 0x98, Register32
147+
INPUT_END = 0x9c, Register32
148+
149+
OUTPUT_START1 = 0xa0, Register32
150+
OUTPUT_START2 = 0xa4, Register32
151+
OUTPUT_END = 0xa8, Register32
152+
153+
MATRIX_MULT = irange(0xAC, 11, 4), Register32
154+
DITHER = irange(0xD8, 10, 4), Register32
155+
156+
ENCODE_PIXEL_FORMAT = 0x100, R_ENCODE_PIXEL_FORMAT
157+
# RGB888: R, G, B = byte pos
158+
# RGB101010: R, G, B = 0/1/2 = low/mid/high bits
159+
# RGB565: R, G, B = 0/1/2 = low/mid/high bits
160+
ENCODE_COMPONENT0_POS = 0x104, Register32
161+
ENCODE_COMPONENT1_POS = 0x108, Register32
162+
ENCODE_COMPONENT2_POS = 0x10c, Register32
163+
ENCODE_COMPONENT3_POS = 0x110, Register32
164+
165+
CONVERT_COLOR_SPACE = 0x114, Register32
166+
167+
REG_0x118 = 0x118, Register32
168+
REG_0x11c = 0x11c, Register32
169+
170+
REG_0x120 = 0x120, Register32
171+
# driver mentions surface tiling, but this doesn't seem to work???
172+
REG_0x124 = 0x124, Register32
173+
REG_0x128 = 0x128, Register32
174+
REG_0x12c = 0x12c, Register32
175+
176+
DECODE_MACROBLOCKS_W = 0x130, Register32
177+
DECODE_MACROBLOCKS_H = 0x134, Register32
178+
RIGHT_EDGE_PIXELS = 0x138, Register32
179+
BOTTOM_EDGE_PIXELS = 0x13c, Register32
180+
RIGHT_EDGE_SAMPLES = 0x140, Register32
181+
BOTTOM_EDGE_SAMPLES = 0x144, Register32
182+
183+
SCALE_FACTOR = 0x148, R_SCALE_FACTOR
184+
185+
DECODE_PIXEL_FORMAT = 0x14c, R_DECODE_PIXEL_FORMAT
186+
# 0 = Cb Y'0 Cr Y'1 1 = Y'0 Cb Y'1 Cr
187+
YUV422_ORDER = 0x150, Register32
188+
# 0 = BGRA 1 = RGBA
189+
RGBA_ORDER = 0x154, Register32
190+
RGBA_ALPHA = 0x158, Register32
191+
192+
REG_0x15c = 0x15c, Register32
193+
194+
REG_0x160 = 0x160, Register32
195+
REG_0x164 = 0x164, Register32
196+
# REG_0x168 = 0x168, Register32
197+
REG_0x16c = 0x16c, Register32
198+
199+
REG_0x170 = 0x170, Register32
200+
# REG_0x174 = 0x174, Register32
201+
PERFCOUNTER = 0x178, Register32
202+
# REG_0x17c = 0x17c, Register32
203+
204+
# REG_0x180 = 0x180, Register32
205+
TIMEOUT = 0x184, Register32
206+
HWREV = 0x188, Register32
207+
# REG_0x18c = 0x18c, Register32
208+
209+
# REG_0x190 = 0x190, Register32
210+
# REG_0x194 = 0x194, Register32
211+
# REG_0x198 = 0x198, Register32
212+
REG_0x19c = 0x19c, Register32
213+
214+
ENABLE_RST_LOGGING = 0x1a0, Register32
215+
RST_LOG_ENTRIES = 0x1a4, Register32
216+
217+
REG_0x1a8 = 0x1a8, Register32
218+
REG_0x1ac = 0x1ac, Register32
219+
220+
REG_0x1b0 = 0x1b0, Register32
221+
REG_0x1b4 = 0x1b4, Register32
222+
# REG_0x1b8 = 0x1b8, Register32
223+
REG_0x1bc = 0x1bc, Register32
224+
225+
REG_0x1c0 = 0x1c0, Register32
226+
REG_0x1c4 = 0x1c4, Register32
227+
REG_0x1c8 = 0x1c8, Register32
228+
REG_0x1cc = 0x1cc, Register32
229+
230+
REG_0x1d0 = 0x1d0, Register32
231+
REG_0x1d4 = 0x1d4, Register32
232+
# REG_0x1d8 = 0x1d8, Register32
233+
# REG_0x1dc = 0x1dc, Register32
234+
235+
# REG_0x1e0 = 0x1e0, Register32
236+
# REG_0x1e4 = 0x1e4, Register32
237+
# REG_0x1e8 = 0x1e8, Register32
238+
# REG_0x1ec = 0x1ec, Register32
239+
240+
# REG_0x1f0 = 0x1f0, Register32
241+
# REG_0x1f4 = 0x1f4, Register32
242+
# REG_0x1f8 = 0x1f8, Register32
243+
REG_0x1fc = 0x1fc, Register32
244+
245+
REG_0x200 = 0x200, Register32
246+
REG_0x204 = 0x204, Register32
247+
REG_0x208 = 0x208, Register32
248+
REG_0x20c = 0x20c, Register32
249+
250+
REG_0x210 = 0x210, Register32
251+
REG_0x214 = 0x214, Register32
252+
REG_0x218 = 0x218, Register32
253+
REG_0x21c = 0x21c, Register32
254+
255+
REG_0x220 = 0x220, Register32
256+
REG_0x224 = 0x224, Register32
257+
REG_0x228 = 0x228, Register32
258+
REG_0x22c = 0x22c, Register32
259+
260+
REG_0x230 = 0x230, Register32
261+
REG_0x234 = 0x234, Register32
262+
# REG_0x238 = 0x238, Register32
263+
REG_0x23c = 0x23c, Register32
264+
265+
REG_0x240 = 0x240, Register32
266+
REG_0x244 = 0x244, Register32
267+
REG_0x248 = 0x248, Register32
268+
REG_0x24c = 0x24c, Register32
269+
270+
REG_0x250 = 0x250, Register32
271+
REG_0x254 = 0x254, Register32
272+
REG_0x258 = 0x258, Register32
273+
REG_0x25c = 0x25c, Register32
274+
275+
JPEG_IO_FLAGS = 0x1000, R_JPEG_IO_FLAGS
276+
REG_0x1004 = 0x1004, Register32
277+
# REG_0x1008 = 0x1008, Register32
278+
QTBL_SEL = 0x100c, R_QTBL_SEL
279+
280+
# fixme what _exactly_ does this control
281+
HUFFMAN_TABLE = 0x1010, Register32
282+
RST_INTERVAL = 0x1014, Register32 # 16 bits effective
283+
JPEG_HEIGHT = 0x1018, Register32
284+
JPEG_WIDTH = 0x101c, Register32
285+
286+
COMPRESSED_BYTES = 0x1020, Register32
287+
JPEG_OUTPUT_FLAGS = 0x1024, R_JPEG_OUTPUT_FLAGS
288+
REG_0x1028 = 0x1028, Register32
289+
REG_0x102c = 0x102c, Register32
290+
291+
BITSTREAM_CORRUPTION = 0x1030, Register32
292+
# REG_0x1034 = 0x1034, Register32
293+
# REG_0x1038 = 0x1038, Register32
294+
# REG_0x103c = 0x103c, Register32
295+
296+
QTBL = irange(0x1100, 64, 4), Register32
297+
298+
# todo what's the format?
299+
RSTLOG = irange(0x2000, 1024, 4), Register32

0 commit comments

Comments
 (0)