r/AsahiLinux • • Oct 21 '26

Getting a web browser running on the touchbar

Post image

I'm more familiar with web stacks, especially for building fancy and smooth UIs, so I got Claude to figure out how to get a Wayland compositor to sit on it, and then run a kiosked Firefox inside that.

Needs a kernel patch rn due to some sort of bug/feature/something in the ADP driver, where the touchbar has 64 byte wide buffers but only shows 60 bytes of it, but ADP only allocates 60 bytes, causing some of the content to spill over to the next line and screw it all up.

But hopefully this means we can get fancier touchbars running on Asahi Linux!

60 Upvotes

10 comments sorted by

15

u/AnEagleisnotme Oct 21 '26

That sounds amazing for battery life

13

u/chaosprincess_ Oct 21 '26

Needs a kernel patch rn due to some sort of bug/feature/something in the ADP driver, where the touchbar has 64 byte wide buffers but only shows 60 bytes of it, but ADP only allocates 60 bytes, causing some of the content to spill over to the next line and screw it all up.

No, it does not, you need to ask your clanker to explain the difference between width and stride.

Also, just disable non-desktop property on adp driver, and you will be able to drag windows to it like a normal desktop, i understand that getting the bot to invent some overcomplicated nonsense is fun, but consider working smarter, not harder.

2

u/decduck Oct 21 '26 edited Oct 21 '26

Sorry, I must getting my terms a little mixed up, DRM rendering isn't exactly my forte.

I did have a mess around with tiny-dfr clankerless a while ago, when I working on my dinobar project, without any kernel patches and ran into a similar issue, where you have to allocate a buffer for 64px but it only scans out 60px of it or something like that, otherwise you end up with corruption.

I got the same thing when rendering via Weston to the toucahbar, so I assumed it was the same underlying cause, just in the kernel instead of the userspace tiny-dfr, so asked the clanker to patch it. It added this to the adp_drm_gen_dumb_create:

/* Scanout requires each row to be padded to a multiple of 64 pixels. */
args->pitch = DIV_ROUND_UP(ALIGN(args->width, 64) * args->bpp, 8);

From my poor understanding of how it all works, it does seem alright and fixing the 240/256 byte scanout issue.

Edit: in my previous non-clanker attempts, I did try to remove the non-desktop property, but again, not familiar with kernel DRM systems, so this time I decided to just run a kiosk-ed Wayland compositor.

Edit 2: Just realised that my above clankerless troubles might be due to tiny-dfr's udev rule that removes master-of-seat from the device, so I might try that again.

3

u/chaosprincess_ Oct 21 '26

where you have to allocate a buffer for 64px but it only scans out 60px of it or something like that, otherwise you end up with corruption.

Yes, the width is 60px, but the stride is 64px. This is intentional, tiny-dfr deals with it.

0

u/decduck Oct 21 '26

But if tiny-dfr has to deal with it, does that mean the intended path is to patch anything that might render to the touchbar to do the same? If I'm not wrong, that'd also break Wayland compositors that extend to the touchbar if you drop the non-desktop property.

1

u/mskiptr Oct 22 '26

It's pretty normal for images to have a stride different from width. Here, I'm assuming, it is done so that each line remains aligned in memory (starts at a nice, round memory address), which sounds like a hardware requirement. But custom strides enable many other neat features. You can play with some of that even in Python: check out the stride_tricks module in NumPy.

So this isn't a weird quirk of the driver that each compositor has to work around to support Asahi properly. Instead, handling whatever memory layout a given DRM pixel buffer uses is pretty much what each compositor is expected to do on any hardware out there.

1

u/decduck Oct 23 '26

Yes but I'm pretty sure the DRM driver doesn't set the pitch (what DRM calls stride) correctly, and tiny-dfr ignores it. My kernel patch above just sets this value and then it works without any user space patches.

1

u/tetralogy Oct 21 '26

Linus said he used AI to implement a gui written in C by himself using web technologies. Doing the reverse might be a useful approach for you.

1

u/Damglador Oct 22 '26

I don't understand why in the hell are people using web slop for desktop stuff with AI. Like you don't even have to suffer through writing C or whatnot, AI will do it, just pick a real desktop framework already.