playing a video on the macpro M1 touchbar

playing a video on the macpro M1 touchbar

okay so yesterday i installed the great asahi linux project on my m1 macbook pro. it works great! im not so used to fedora, but it's working out.

my macbook pro (m1 2020) has a touch bar. much to my surprise, it worked right out the box. the people over at asahi linux have been doing a wonderful job sifting through all of apple's bullshit, and this was not something i was expecting to work.

it was even more surprising when i realised that they had written the kernel module so that is was a drm device. for those unaware, a drm device, in the context of the linux kernel, is a display of some sort that uses the direct rendering manager. it's kind of linux's way of unifying all the different kinds of displays. asahi linux uses it's own tiny dfr to show the default touchbar function, but that's a bit boring.

so, if it's a display... what else can we do with it? i poked through the source code (yay for open source), and had the idea of playing an episode of house md. it seemed doable, because a few of the options for the touchbar used effectively a blit function to copy images to the display. just a bit of copy pasting and whatnot, and we should be golden, right?

wrong. first off, the size that the drm driver reports doesn't seem quite accurate, or at least it has some overdraw. it reports as a 2008x60 display, and i ended up using 2008x64. not sure where the four pixels came from, but it was a pain to figure out.

another issue is that the colour layout is fucked up. the tiny dfr source code uses argb32. argb32 defines four bytes per pixel, where the first three are red, green and blue respectively, and the last is the alpha channel. do you wanna know what the touchbar uses...? no? too bad. it's BLUE, GREEN, RED, then alpha. and afaik the alpha doesn't fucking do anything, because it's premixed or whatever (i don't fully understand it).

needless to say, i eventually got it working. the rest of the project was basically finding an up-to-date rust library to pull raw frames from videos with ffmpeg, but after that, we get a fun little house md episode playing on the left hand side of the touchbar. yay!

there's a bunch more you could do with the touchbar, it's really just a screen that you can put anything on. i'm excited to mess around with it more, but this was really just a silly little project.

you can check out the source code (and maybe run it for yourself) here: tiny-vlc