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:19eilnget my avd branch at https://github.com/eiln/m1n1.git and edit the sys.insert path at the top
09:21eilnfeel free to report j293ap bugs though. 4:2:2 chroma should work but the m1n1 code doesn't display nv16
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: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:11PaulFertser has quit [Quit: see you on the other side]
11:09ydalton has joined #asahi-dev
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: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: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:24leioto me that just screams for a csc_videoconvertscale gstreamer element to speed up transcodes and such
11:32leiowhat I wonder is how exposing this via v4l2 will then work with all the userspace out there
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: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: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:52chadmedwe'd probably be the first (and likely only) hardware prores codec supported upstream though
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: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: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:58ydalton has left #asahi-dev [ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.0.92)]
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
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?
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:36eilnthere's viola, cactus, ixora, daisy, salvia, lilyd, radish, clover, lotus, tansy, clary, catnip, dahlia. not all are supported
15:37kidplayer666 has joined #asahi-dev
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:13ArcaneNibbleinherently
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: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:09___nick___ has joined #asahi-dev
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: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:30jannegnicolas17: VP9? they supposedly added that for Google/Youtube on A* chips but didn't want to support it / let the world know
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: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:39eilncan you get this? https://www.dropbox.com/scl/fi/255zktwxy4z98bd31vlx9/avd-sample.tar.gz?rlkey=qj8mw6h1fqlbsa1lvwvknndd6&dl=0
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: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:53ArcaneNibbleno idea
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: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:15ArcaneNibblenot sure
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:28ArcaneNibbleenjoy
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: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:11RoguePlanet has quit []
20:11ydalton has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.0.92)]
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: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:27ChaosPrincesshttps://github.com/WhatAmISupposedToPutHere/asahi-nvram/blob/master/asahi-bless/src/lib.rs#L198 - this one for om_tree_oid
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:45crabbedhaloablut has quit []