#
…

2023-11-24

00:12johey has quit [Ping timeout: 480 seconds]
00:13johey has joined #asahi-dev
03:32jeisom has quit [Ping timeout: 480 seconds]
04:47tristan2 has joined #asahi-dev
04:49tristan2_ has quit [Ping timeout: 480 seconds]
05:29crabbedhaloablut has joined #asahi-dev
06:25dylanchapell has quit [Read error: Connection reset by peer]
06:50dylanchapell has joined #asahi-dev
07:23kidplayer666 has joined #asahi-dev
09:18eiln has joined #asahi-dev
09:19eilnreading logs from eons ago
09:19eilnnicolas17: re: bad apple
09:19eilnget my avd branch at https://github.com/eiln/m1n1.git and edit the sys.insert path at the top
09:20eilnffmpeg -i bad-apple.mp4 -c:v copy (or reencode libx264) bad-apple.h264
09:20eilnpython3 experiments/avd.py -i bad-apple.h264
09:20eilnonly tested j293ap
09:21eilnfeel free to report j293ap bugs though. 4:2:2 chroma should work but the m1n1 code doesn't display nv16
09:22eiln*can't
09:22eilnydalton: cm3 firmware I wrote about here https://eiln.net/avd-notes.html posted another one last night too
09:39linuxgemini has quit [Quit: Ping timeout (120 seconds)]
09:39j`eyeiln: this is a fun read even though I understand 0% :-)
09:41linuxgemini has joined #asahi-dev
09:46eilnedit: if macOS says "AVD version Viola" at boot it should work. but m1n1-side register offsets might differ per soc
09:52pjakobsson has quit [Ping timeout: 480 seconds]
09:55chadmed has joined #asahi-dev
10:00mazextremely impressive indeed. though I'm in the same situation as j`ey on this front!
10:11PaulFertser has quit [Quit: see you on the other side]
11:09ydalton has joined #asahi-dev
11:09ydaltonomg bad apple decoded by avd :3
11:13ydaltoneiln: also, i tried your cm3 emulator script and it crashed complaining about unmapped reads/writes. would the emulator script have to be rewritten to suit the m2? that's where i got my firmware from
11:13ydalton has left #asahi-dev [ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.0.92)]
11:15eilnyes, the memory layout is different. not rewritten but it needs to be adjusted. soc and avd codename (from macos)?
11:16ydalton has joined #asahi-dev
11:16ydaltont8112 but i don't know the codename of avd
11:17eilnlog show --last 5m --info --debug
11:17eilnalso emu is useless without the trace dumps
11:17ydaltoni had frame params and the commands from a while ago
11:18ydaltonmaybe i will use your tracer script from your avd branch of m1n1
11:19ydaltonomg, your tracer script has a function save_firmware, i was doing it manually with the mmio dump 💀
11:21leiowhat's CSC about? Is it something we could use e.g. for a gstreamer element that would replace videoconvertscale?
11:21eilnagain you need to adjust the offsets
11:22ydaltonlooks like it, the regs look different than what i had on my m2
11:23eilnleio: colorspace converter and scaler. does a lot of stuff ranging from colorspace conversion, scaling (I'm not being sarcastic), pixel fills, tiling, up to AV1 film grain generation. up next on my list :D we'd need to completely rework V4L2 though
11:23leiousable standalone in userspace somehow too?
11:23leio(well, if the support for such is written)
11:24eilnwe'll need to make an api for it, yes.
11:24leioto me that just screams for a csc_videoconvertscale gstreamer element to speed up transcodes and such
11:24ydaltoneiln: what's with AVD_BASE being used? can't you get that from adt?
11:24leiobut maybe in practice just letting GPU do it is good enough or better
11:31ydaltonah man, i remember the opcodes thing, memories
11:32leiowhat I wonder is how exposing this via v4l2 will then work with all the userspace out there
11:32eilnthat's what I meant by "reworking v4l2"
11:32eilnI sent marcan an email about it
11:33leio(I jumped to decoding now, not csc)
11:33leioI could poke at anything needed from gstreamer, in theory
11:33leiobut there's more to that world than gstreamer, unfortunately :D
11:36eilnI'd like to get ffmpeg hwaccel for scaling too (if that ever comes). meaning v4l2 should obviously have a generic api for it, one gst can make use of too.
11:36ydaltonisn't there vaapi? i don't know enough about that though
11:41chadmedthere was talk a while ago of writing a backend for vaapi but i cant remember where that ended up
11:43ydaltonwell, wouldn't that give hardware accelerated video for free? once a kernel driver is written
11:43ydaltonsince gstreamer, chromium, firefox are using
11:44chadmedwell yeah thats the idea
11:45chadmedbootlin did some work on a v4l2 backend for libva but idk if it will suit our needs specifically
11:45eilnnone of them are sufficient. prores is/was on my list too but they don't even list all the exotic pixel formats prores uses, let alone an api. but I found out not long ago that I don't have prores, wtf
11:46eilnactually none of them are even good enough for avd
11:50ydaltoni didn't know linux had any prores support
11:50chadmedprores is a very popular intermediate format in digital video pipelines
11:51chadmedand davinci resolve has a (mostly) well maintained linux version
11:52chadmedwe'd probably be the first (and likely only) hardware prores codec supported upstream though
11:53ydaltonare there any hardware prores codecs outside of apple silicon?
11:54chadmedyeah but usually on board ISPs for digital video cameras
11:54chadmedarri and blackmagic being well known vendors of such cameras
11:54ydaltoni mean on graphics cards for example
11:54leioisn't vaapi so that there's a hardware-specific kernel side and then a vaapi driver that makes it usable through a common API for userspace apps, while you could also use the specific stuff exposed by the kernel driver for other things?
11:54leiovaapi driver being userspace
11:54chadmedleio: yes and bootlin have a basic v4l2 backend for vaapi but if eilin says its not good enough for avd or apr then i trust her
11:55chadmedand no i dont think anyones done a prores hw block on a commodity gpu
11:56eilnit's not really a parallelizable task
11:56chadmedpeople working in prores probably just bought mac pros with the afterburner card which aiui is just avd, ave and apr on a pcie card
11:57ydaltonwonder if there was any linux support for those, probably not
11:58ydalton has left #asahi-dev [ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.0.92)]
11:58chadmedand they didnt have avd or ave, only an older version of apr
11:59eilnis that the same avd/ave/apr? intel macs shipped with imagination's decode IP, ave sucks enough that I trust it's the same one, but apr wasn't released until m1+s
11:59chadmedits a decode only version and doesnt do demosaicing so it might be something different
12:00chadmedprob that imagination chip on a card then
12:06chadmedwait no it cant be i dont think they ever did a prores codec
12:10eilnawh they couldn't have outsourced their own codec
12:11leiowhere do the decoded frames end up in terms of memory location, in the context of achieving zero-copy to display?
12:13eilnleio: all dma-capable peripherals operate in iommu/dart space (all except gpu). we could double iommu-map the underlying page to do m2m or zero copy
12:14leioall except gpu, meaning we can't "zero-copy" it for stuff like video/x-raw(memory:GLMemory) or vulkan video?
12:16leiofor linux direct scanout, having it in DMABuf would be most interesting, I believe
13:48pjakobsson has joined #asahi-dev
14:13kidplayer666 has quit [Quit: Connection closed for inactivity]
14:15eiln has quit [Quit: WeeChat 4.1.1]
14:37nicolas17eiln: is "Viola" the codename for AVD or for this particular revision? do you know of other names?
15:10jeisom has joined #asahi-dev
15:19eiln has joined #asahi-dev
15:28PaulFertser has joined #asahi-dev
15:36eilnnicolas17: viola is j293 AVD (V3 in device tree). the revision codenames are all some weird plantae
15:36eiln*strings*
15:36eilnthere's viola, cactus, ixora, daisy, salvia, lilyd, radish, clover, lotus, tansy, clary, catnip, dahlia. not all are supported
15:37eilnwho does that?
15:37kidplayer666 has joined #asahi-dev
15:37nicolas17wow, that's a lot
15:38nicolas17I just went "ooh codenames I love codenames"
15:39nicolas17but it's gonna be Work to figure out which is which :D
15:39nicolas17I assume it's Viola on every M1 SoC?
15:40eilnno. m1+s were "V4" in device tree
15:41nicolas17sorry I mean on every device with M1, not Pro/Max
15:41nicolas17it would be weird if it was j293-specific
15:44eilnyeah I'd guess so. you can run 'log show' grep AppleAVD
16:08ArcaneNibbleM1 Max is LilyD
16:08ArcaneNibble(sorry, I *am* kinda alive despite having been too burned out to do any work on this)
16:09ArcaneNibbleprores on M1 Max is RE-ed enough that someone could theoretically write a driver
16:09ArcaneNibblei haven't tried, since i know the vast majority of the complexity is integrating into the linux frameworks (v4l2?) that i know absolutely nothing about
16:10ArcaneNibbleunless someone wants to do a char/misc proof-of-concept
16:10ArcaneNibblei have basic work on scaler/csc
16:10ArcaneNibblebut it's *so* complicated and i don't really know how to trigger most operations from userspace
16:11ArcaneNibbleif someone wants to tackle prores on the linux side, feel free to message me (and/or publicly here)
16:12ArcaneNibblehardware is conceptually very simple: you just give it a frame (by putting a descriptor in a ring buffer) and it encodes/decodes it and tells you when it's done
16:13nicolas17prores is entirely intra-only?
16:13nicolas17so you don't even have to worry about order of frames, you just throw a pile of images there and they come back out decoded
16:14ArcaneNibbleoh right, prores is also missing somebody to RE the bitstream for "prores raw"
16:14ArcaneNibble(but it's certainly possible to treat that as a black box)
16:16ArcaneNibbleoh yeah, i also still have the hardware JPEG block RE'd without a linux driver, but that's of questionable utility (mjpeg accelerator?)
16:18nicolas17ArcaneNibble: I tried to reverse engineer the weird proprietary PNG extensions Apple has and I found even Apple's own code doesn't decode it consistently
16:23ArcaneNibblethe biggest blocker for AVD on my part (other than burnout) is not knowing all that much about video codecs
16:24ArcaneNibblei think we'd want to completely rip out apple's M3 firmware for it though, it is terrible
16:47ArcaneNibbleexcellent work!
17:02eilnnicolas17: prores is an intra-only codec so people editing video can seek fast
17:02eilnArcaneNibble: good to hear from you :) I don't even plan on using the coprocessor, let alone firmware
17:03ArcaneNibblehm, pretty sure the VP/PP interrupts aren't routed to the main CPU?
17:03ArcaneNibblewhich is one thing that the M3 notably does
17:05eilnI'm not a video codec expert (jannau is) but I haven't ran into much math stuff. it's mostly RTFM and figuring out bitfields
17:08eilnI don't think VP/PP interrupts at all considering CM3 polls a status register
17:09___nick___ has joined #asahi-dev
17:09nicolas17I'm not a video codec expert, but I understand like, MPEG2 at a conceptual level
17:10ArcaneNibblethe firmware definitely has IRQ handlers in the vector table
17:10ArcaneNibbleit *also* polls status registers, yes
17:18eilnexecuting code in a power-gated range is such a nightmare that I'd like to avoid that if we can
17:19ArcaneNibbleis the M3's memory lost on power gate?
17:19eilnline 607 in avd_emu.py (heh) is the non-aic (PP) interrupt I believe. it does two writes at the polled status register which, if it doesn't, PP fails after the fifth-ish run
17:21eilnavd has another power domain which is not in the device tree and not PMGR, lovely. it's enabled by write 0xfff I believe. it's gated on that. and I believe there is no "off" write
17:24ArcaneNibbledon't quite follow which bits of code you're looking at
17:25ArcaneNibblebut i was thinking that for an RE'd implementation we'd either want "m3 does almost nothing, just proxies interrupts" or "m3 does a lot of offloading in a more competent way than apple"
17:26eilnbut I can't imagine a cortex-m3 is any faster, and I don't think that's worth the IPC
17:28nicolas17eiln: I just read your blog post... I wonder if there's some version of macOS where they did leave behind code for the mystery codec :o
17:30nicolas17time to shine for the data hoarders
17:30jannegnicolas17: VP9? they supposedly added that for Google/Youtube on A* chips but didn't want to support it / let the world know
17:31nicolas17janneg: there's registers for (in order): H265, ???, H264, VP9
17:32ArcaneNibbleeiln: oh, you mean writes to registers at 40100124 and after?
17:33ArcaneNibble(we're looking at a very different version of the firmware so the addresses won't match up)
17:35eilnlet me upload a tarball of j293 trace samples
17:36ArcaneNibblein lilyD, there's handlers in the cm3 firmware for IRQ78 and up
17:36ArcaneNibblein groups of 5
17:38ArcaneNibblewhich we had been guessing was interrupts for each VP being done or having an error
17:39eilnif you unpack that into data/* you should be able to run my forked avd_emu.py
17:40eiln5, interesting.
17:41ArcaneNibbleoh sorry, the 5th one is always an infinite loop
17:41ArcaneNibbleso groups of 4, stride of 5
17:42ArcaneNibblefirst one pokes a status register then calls a shared handler that logs 'CtxD', second one logs 'H?Er' (error?), and the other two do more complicated things
17:43eilnwe might be talking about different things, but it's not an infinite loop, it's polling the status register to change. it's why I added the w_40104060 hook
17:44ArcaneNibblehmm, maybe lilyD is totally different
17:44ArcaneNibblewhich version are you looking at?
17:44eilnj293ap 13.5 viola, it's in the tarball
17:45ArcaneNibbleoh! viola firmware IRQs are totally different!
17:50ArcaneNibblefrom a quick eyeball of the firmwares we have on hand here, clover/viola are different from dahlia/radish/lilyC/lilyD
17:52eilnpost executing PP, it's supposed to poll and do two magic writes into the status register. that value slightly differs per codec. https://github.com/eiln/m1n1/blob/avd/proxyclient/m1n1/fw/avd/decoder.py#L92C9-L92C23. these are after PP is completely done so it doesn't affect the output but it "resets" PP for the following runs.
17:53eilnwhat soc was clover?
17:59ArcaneNibbleclover might be older than viola? it uses smaller numbers in the unreadably messy start() function
18:00ArcaneNibbleso it might be A14?
18:00ArcaneNibblethe others use a revision number in a completely different range
18:01ArcaneNibbleso... apple split out some cm3 IRQs?
18:04eilnwe could crowdsource 'log show'
18:06ArcaneNibblebut yeah, we can see the status register polling you mentioned
18:06ArcaneNibblethe lilyD firmware doesn't look like that
18:11russelltg has joined #asahi-dev
18:11ArcaneNibblebtw, there's no gap between 265/264 on lilyD
18:11ArcaneNibblethere's instead a mysterious thing *after* it
18:12ArcaneNibblelike, after VP9
18:12ArcaneNibbleat least, from static analysis
18:13ArcaneNibbleoh wait, does viola only have three VP fifos?
18:13ArcaneNibblelilyD has multiple
18:13ArcaneNibbleit has 4 h.265, 4 h.264, and 1 vp9
18:14nicolas17from eiln's blog:
18:14nicolas17AVD_VP_INSN_FIFO_265 0x1104004
18:14nicolas17AVD_VP_INSN_FIFO_??? 0x1104008 /* mystery codec */
18:14nicolas17AVD_VP_INSN_FIFO_264 0x110400c
18:14nicolas17AVD_VP_INSN_FIFO_VP9 0x1104010
18:15eilnit has four FIFOs? how are they scheduled?
18:16ArcaneNibbledidn't manage to poke hard enough to figure that out
18:16ArcaneNibble(also, didn't care much and figured "we can do it our own way anyways, doesn't matter what apple's firmware actually does")
18:17ArcaneNibblethe opcodes that go into the fifos look the same / very similar between lilyD and viola
18:18eilnis it 264/5 for sure? I can't imagine parsing macroblocks is a threaded task. maybe vp9 for threadframes but that's the only non-one
18:20ArcaneNibblefunctions that poke it log HvpD/AvpD/LvpD so pretty sure
18:26eilnaah I'm gonna snooze off, we'll definitely investigate this ;)
18:30krbtgtwrt the Mystery Codec, i wonder of it's VC1
18:31krbtgtit is used on blu-ray, it's from around the late 2000s
18:31krbtgtor one of the other VC "family" codecs
18:33krbtgtit's possible it was also removed a long time ago and you're just seeing the holes where it used to be too
18:36ellyqI wonder if it might be AV1?
18:36eilnyeah it's probably just some prototype design
18:36ellyq(sorry for butting in, just curious)
18:36eilnit's not
18:38eilnif the other ones have multiple fifos (why?) it's possible it's hevc fifo#2 but I recall I couldn't get it to work with hevc. also the version number jump was suspicious
18:41ArcaneNibbleV?Dn isn't a version number
18:41ArcaneNibblelilyD fills in [0-8] depending on which fifo is used
18:47eilnmy understanding is that each fifo is the entrypoint to a separate processor. actually I don't think there's any other way because you can see it processing each step with each word written
18:49eilnat least on mine it's not schedulable i.e. vp9 instruction stream has to go into the vp9 fifo, etc
18:58eilnoh wait no if there are multiple processors we can definitely make use of them as long as their output doesn't get overwritten. but I haven't seen any evidence of macOS threading these. their firmware IPCs are interrupts and the command for executing VP vs. PP (which there's only one of) is handled inside a single IPC decode command. ig that's one thing we can do better
19:00eiln has quit [Quit: WeeChat 4.1.1]
19:09aradhya7 has joined #asahi-dev
19:59RoguePlanet has joined #asahi-dev
20:00ydalton has joined #asahi-dev
20:01ydaltoneiln: t8112's avd seems to be codenamed dahlia
20:11RoguePlanet has quit []
20:11ydalton has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.0.92)]
20:17nicolas17AAAAAAAAAA I found a mistake in Apple's APFS documentation >_<
20:20ChaosPrincesswhich one? :P
20:22nicolas17"Virtual objects are stored on disk at a block address that you look up using an object map"
20:22nicolas17"To access a virtual object using the object map, perform the following operations: [...] Locate the B-tree for the object map by reading the om_tree_oid field of omap_phys_t"
20:22nicolas17"om_tree_oid: The virtual object identifier of the tree being used for object mappings."
20:23nicolas17if om_tree_oid is a virtual OID then I need to look it up in the object map, but to look something up in the object map I need to get the btree that om_tree_oid points at, how can that possibly work?
20:23nicolas17it seems om_tree_oid is a *physical* object ID
20:25ChaosPrincessthere is also another one in omap description where they give two contradicting sentences about about what exact data is stored in it
20:26nicolas17om_snapshot_tree_oid is also documented as being a virtual OID, I haven't checked but that smells also wrong
20:27nicolas17ChaosPrincess: oh, paddr_t vs omap_val_t?
20:30nicolas17ok so I'm trying to figure out something
20:31nicolas17is everything in a data volume encrypted, including the trees that say *where* the data is? I guess yes because otherwise you could know the directory structure and file size, even if not the file names or content?
20:32ChaosPrincessthose are encrypted
20:33nicolas17if I delete an encrypted data volume without knowing the encryption key, how does APFS know which blocks became free?
20:33ChaosPrincessthere are two kinds of encryption - full volume and per-file
20:34nicolas17yes, and docs say per-file is only used on iOS, but maybe that's wrong and it's also used on ARM macOS too
20:40ChaosPrincessSo, if i understand it correctly, there is an object map tree and a filesystem tree.
20:40ChaosPrincessfilesystem tree is encrypted, but i guess object map isnt?
20:49kidplayer666 has quit [Quit: Connection closed for inactivity]
21:05SalimTer- has joined #asahi-dev
21:07___nick___ has quit [Ping timeout: 480 seconds]
21:09SalimTerryLi has quit [Ping timeout: 480 seconds]
22:24RoguePlanet has joined #asahi-dev
22:25RoguePlanet has quit []
22:41kettenis has joined #asahi-dev
22:42kettenisrtkit_handle_oslog: unhandled oslog event 0x0300006e62370420
22:42kettenisrtkit_handle_oslog: unhandled oslog event 0x0400002000000105
22:42kettenisrtkit_handle_oslog: unhandled oslog event 0x0400004001050000
22:42kettenisrtkit_handle_oslog: unhandled oslog event 0x0400006000000000
22:42kettenisrtkit_handle_oslog: unhandled oslog event 0x050672694670744d
22:42kettenisrtkit_handle_oslog: unhandled oslog event 0x056500657261776d
22:42kettenisdo folks see those events on Linux as well?
22:45crabbedhaloablut has quit []
22:51jannegkettenis: which coproc and which device? I don't see anything on j314c or j375d. should be logged as warning
22:53kettenisthis is mtp on j413
22:54jannegyes, I see the same oslog messages from mtp on j493
…