Linux Can 4K @ 60 Haz

I tried getting 4K @ 60Hz using Intel built-in graphics, and I failed miserably.

Rather than spend more days on that project (yes, this is the year of Linux on the TV, I Mean Desktop), I bought a low-profile Nvidia card, since there are several people on the interwebs that claim to have gotten that to work.

It’s brand new, cheap and fanless, too: A Geforce GT 1030, which is Nvidia’s new budget card, launched last month, I think.

It’s finnier than Albert and takes up several PCI Express slots.

However, that’s not really a problem in this media computer: Lots and lots of space for it to spread itself out over. Just one PCI Express slot, though.

But it’s on the long side: If I had any hard disks installed in this machine, I would have had to get creative. Instead I just removed that HD tray thing.

But! There’s two … capacitors down there where the PCI Express “key” thing. Like just quarter millimetre too much to the right…

I bent them ever so gently over and I managed to get the card in. How utterly weird.


Anyway: Mission complete. This card has a DVI plug in addition to the HDMI, but I’m not going to use that, so I just left it with the protective rubber.

See? Lots of space. Of course, it would have been better to remove the cooler completely and hook it up via heat pipes to the chassis, but… that’s like work.

But did this solve my problems? After installing Nvidia’s proprietary drivers (apparently Nouveau doesn’t support the GT 1030 yet, since it’s a Kepler card)…

Yes! 3840×2160 @ 59.95 Hz, which is pretty close to 60Hz. Yay!

Of course, I have no 4K material on my computer, so the only thing that’s actually in 4K now is my Emacs-based movie interface. Here’s whatsername from Bewitched in 2K:

Eww! How awful! Horrible!

See! 4K! How beautiful!

(Let’s pretend that the entire difference isn’t in the different moire patterns!)


And the Futura looks much better in 4K too, right?


This was all worth it.

Isn’t 4K@60Hz HDMI possible in Linux?

I bought a spiffy new 4K TV the other week, and I wanted to set up a complete 4K pipeline. Not that there’s that much 4K stuff available: For instance, Netflix has a pitiful 101 list of shows, most of them made by Netflix themselves.

Anyhoo! I was thinking a bit about how to set this all up so that I’d have a 4K pipeline from my computer, while there’s a 2K pipeline from the Ipod (which I use to watch Amazon stuff) and a 4K pipeline from the Chomecast (which I planned on using to watch Netflix stuff). All the while being able to record shows so that I can screenshot them for the “The World” blog series. It’ll be simpler if I just draw a diagram:

See? Easy peasy. I have to insert an “HDMI splitter” (which is a euphemism for “HDCP stripper”) in between the Ipod and the HDMI recorder because DRM. But! Then I realised that I could just watch non-4K Netflix on the Ipod, so that simplified things hugely:

So simple! So I have the Ipod as a DRM device, and then all the rest is FREEDOM!

This is what it looks like in reality:

So neat and orderly.

So everything is A-OK, then? No. The thing is that I’m not able to get my PC to do 4K at 60Hz. This is what xrandr says:

See the 3840×2160 entry? That’s the one I want, and it has a max refresh rate of 30Hz. TV is 50Hz or 60Hz, so having only 30Hz sucks.

As you’ve probably also noticed, xrandr says that DP1 is connected, not HDMI. That’s because I plugged in an external DisplayPort to HDMI adapter, which is supposed to support 4K @ 60Hz. But that apparently doesn’t work.

I also tried the native “HDMI” plug on this motherboard (which is an ASRock Fatal1ty Z270 Gaming-ITX/ac LGA1151 HDMI 2.0 ITX motherboard *phew*), but that turns out to also be DisplayPort, really, but with a built-in DP->HDMI adapter (to allow 4K@60Hz).

This stuff is apparently called LSPCON, and support for it landed in Linux somewhat recently.

I’ve tried very up-to-date kernels (I’m now running on 4.12.0-994-generic), and my Debian is stretch, so it’s also quite recent. I’ve tried plugging the computer directly into the TV via an HDMI 2.0 cable, bypassing all switches and everything, and the result is the same.

My TV is a Sony A1E, which claims to support 4K@60Hz, but I’m unable to make either the Chromecast or the TV say what frame rate it has when it’s doing 4K.

So… is this supposed to work or not? Has anybody gotten 4K @ 60Hz HDMI to work in Linux?

[Edit a day later]:

Googling around shows a lot of people with similar problems that they apparently are able to resolve by adding the proper ModeLines.  In 2017.

So I tried this:

xrandr --newmode "3840x2160_60.00" 712.34 3840 4152 4576 5312 2160 2161 2164 2235 -HSync +Vsync
xrandr --addmode DP1 "3840x2160_60.00"
sleep 15
xrandr --verbose --output DP1 --mode "3840x2160_60.00"

But the Xorg log says:

[  2222.946] (II) intel(0): switch to mode 3840x2160@60.0 on DP1 using pipe 0, position (0, 0), rotation normal, reflection none
[  2222.967] (EE) intel(0): failed to set mode: Invalid argument [22]
[  2223.014] (--) intel(0): HDMI max TMDS frequency 300000KHz
[  2223.031] (II) intel(0): resizing framebuffer to 1920x1080
[  2223.031] (II) intel(0): switch to mode 1920x1080@60.0 on DP1 using pipe 0, position (0, 0), rotation normal, reflection none
[  2223.084] (--) intel(0): HDMI max TMDS frequency 300000KHz

So that’s a no go..

My New Fashion Designer Blog x Useful Consumer Review

I’ve been trying to use an Android device as my “lug around the apt. while doing stuff” device, but it’s just not good enough. None of the apps for sshfs file browsing or video watching are beyond the “well, it kinda works” level. The ssh times out and doesn’t come back again until you do *stuff* and all the video apps have audio/video sync issues.

(Don’t all Android users play TV via sshfs?)

So! Back to Linux!

I got this laptop which has a “tent” configuration where the keyboard is in the back. Since it’s Linux, sshfs and mplayer work perfectly. The only issue is just the portability.  Physically. See, it’s all tent-ey and stuff, but when it’s in that configuration, picking it up is very awkward. There’s nothing to grab hold on.

So! I got my sewing kit out (a gift from my mother like ten years ago and seldom used since) and bought a ribbon thingie.

Oh, yeah, the computer is a… is that a d and a q? So it’s a … Dairy Queen laptop?

Let’s go with that.

I had planned on wrapping the ribbon around a wine cork, but the wine tonight turned out to be from New Zealand and had a screw cap. So instead I just rolled the ribbon up…

… and then expertly stitched it up. (Don’t show that seam to anybody with sewing skills unless you want them to have a heart attack.)

I did one at either end and now I have a handle!

See! It works!!! (He says while gingerly walking around with it.)

(Oh, the thing being shown is an episode of … Killjoys. Yeah, that’s what it’s called. It’s about people pointing guns at each other… IN SPACE!)

This is what the Dairy Queen looks like from the other angle. Not quite as … TV-ey. That’s a word. (The keyboard is switched off when it’s in this position.)

I had to adapt my Emacs video viewer for touch action, and I used Touchéegg along the lines for the music player. Seems to work OK. I added touch actions for mplayer, too, so that I can pause and skip and stuff.


Ipad, Screenshots and Linux

It’s become increasingly clear over the past few months that many recent, fun-sounding films from countries with smaller film industries will never get a physical DVD release. The only way to see these films is via Amazon Prime, and since Amazon Prime isn’t conveniently available on Linux machines, I’m having to use an Ipad to watch these films.

Which is fine.

But I have to take screenshots. (I mean. I have to!) That leaves a lot of images on the Ipad, and I need a convenient way to get those from the Ipad to my Linux laptop.

Now, there’s Dropbox, and… stuff, but all those things require some manual work at the Ipad end or the Linux end. I hate manual work.

So wouldn’t it be nice if there was some way to just “do something” and then all the screenshots from the Ipad would magically appear in my Emacs on the Linux laptop?

There is!

It’s a bit fiddly, though, so let’s just get started.  (“A bit fiddly” is code for “seven pages of text is to follow”.  This is the year of Linux on the Desktop.)

My Laptop runs Ubuntu Linux, and it comes with an ifuse distribution that’s built with GnuTLS and not OpenSSL. This doesn’t work with IOS 10, so you need to build it yourself.

I’ve streamlined the build instructions a bit. The utilities and libraries needed to talk to Idevices is spread over four repositories, but the following should pull them all down, build them, and install them under /usr/local.

sudo apt-get build-dep ifuse 
for elem in libusbmuxd libimobiledevice usbmuxd ifuse; do 
  git clone${elem}.git 
  (cd $elem; sh ./; make; sudo make install) 

Check that your path is picking up the correct version by saying

$ type ifuse 
ifuse is /usr/local/bin/ifuse

Then plug in the Ipad via USB, and test that you can talk to the device. You may have to press “Trust this device” on the Ipad while connecting.

$ sudo mkdir /media/ipad 
$ sudo chown larsi.users /media/ipad 
$ idevicepair pair SUCCESS: Paired with device 37b633350ab83dc815a6a97dcd6d327b12c41968 
$ ifuse /media/ipad

You should now have the Ipad mounted, and the screenshots are under /media/ipad/DCIM.

Now for the fun part: Make the laptop copy over the files automatically whenever you plug in the Ipad.  I’m using the general setup from the usb-automount setup I did a few months ago.

The main difference is this udev.rules file:

ATTR{idVendor}="05ac", ATTR{idProduct}="12ab", PROGRAM="/bin/systemd-escape -p --template=usb-automount@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"

And then I use the following script to actually copy over the contents to the current “viewing directory”.



if [ "$command" = "remove" ]; then
    umount /media/ipad

# Mount the Ipad.
ifuse /media/ipad

if [ -d "/media/ipad/DCIM/100APPLE" ]; then
    cd /media/ipad/DCIM/100APPLE
    for pic in IMG*; do
        if [ ! -f "$to/$pic" ]; then
            cp -av "$pic" "$to/$pic"
            chown larsi.users "$to/$pic"
            if echo "$pic" | grep PNG > /dev/null; then
                shot=`echo "$pic" | sed 's/IMG_/shot/' | sed 's/PNG/png/'`
                if [ ! -f "/home/larsi/.movie-current/$shot" ]; then
                    ln "$to/$pic" "/home/larsi/.movie-current/$shot"

cd /
umount /media/ipad

Or something like that.  You obviously have to adjust the script to your needs if you want to do something like this, but the general idea should be sound, I think…

Look!  The images appeared in Emacs!  As if by magic!

It seems to work reliably, also after rebooting the laptop.  Apparently the “idevicepair pair” think only has to be done once?  Or something?

The only minor annoyance is that Ubuntu pops up an icon in the right-hand menu every time I plug in the Ipad.  Is there any way to say to Ubuntu “ignore this device in the UI”?  There is a way to make Ubuntu ignore all auto-mounted devices, but that’s not what I want, and there is a way to make Linux ignore a specific USB device completely (echo 0 > /sys/bus/usb/devices/2-1/authorized), but that’s not what I want, either.  I just want the UI to ignore this specific device…

Oh, never mind.

[Edit: I’ve now put the scripts on github.  That should make it easier to customize if anybody wants to use this setup…]

One Thing Leads To Another

In the previous installment, I got a new monitor for my stereo computer.

I thought everything was fine, but then I started noticing stuttering on flac playback. After some investigation, it seems as if X is on (and displaying stuff on this new, bigger monitor), and there’s network traffic, then the flac123 process is starved for time slices, even if the flac123 process is running with realtime priority.


Now, my stereo machine is very, very old. As far as I can tell, it’s from 2005, and is basically a laptop mainboard strapped into a nice case:

(It’s the black thing in the middle.) But even if it’s old, its requirements hadn’t really changed since I got it: It plays music and samples music and routes music to various rooms via an RME Multiface box. So I was going to use it until it stopped working, but I obviously can’t live with stuttering music and I didn’t want to spend more time on this, so I bought a new machine from QuietPC.

There’s not a lot inside, so I put the external 12V pad into the case. Tee hee. Well, thermally that’s probably not recommended, but it doesn’t seem to be a problem.

Nice heat pipes!

Look how different the new machine is! Instead of the round, blue LED power lamp, it’s now a… while LED power lamp. And it’s about 2mm wider than the old machine, but you can’t tell unless you know and then it annoys the fuck out of you.


Anyway, installation notes: Things basically work, but Debian still haven’t fixed their installation CDs to work on machines with NVMe disks. When it fails to install grub, you have to say:

mount --bind /dev /target/dev 
mount --bind /dev/pts /target/dev/pts 
mount --bind /proc /target/proc 
mount --bind /sys /target/sys 
cp /etc/resolv.conf /target/etc 
chroot /target /bin/bash 
aptitude update a
ptitude install grub-efi-amd64 
grub-install --target=x86_64-efi /dev/nvme0n1

Fixing this should have been kinda trivial and warranted fixing, wouldn’t you think? But they haven’t, and it’s been that way for a year…

Let’s see… anything else? Oh, yeah, I had to install a kernel and X from jessie backports, because the built-in Intel graphics are too new for Debian Stale. I mean Stable. Put

deb jessie-backports main contrib

into /etc/apt/sources.list and say

apt -t jessie-backports install linux-image-amd64 xserver-xorg-video-intel

although that may fail according to the phase of the moon, and I had to install linux-image-4.9.0-0.bpo.2-amd64 instead…

And the RME Multiface PCIe card said:

snd_hdsp 0000:03:00.0: Direct firmware load for multiface_firmware_rev11.bin failed with error -2

I got that to work by downloading the ALSA firmware package, compiling and installing the result as /lib/firmware/multiface_firmware_rev11.bin.

Oh, and the old machine was a 32 bit machine, so my C programs written in the late 90s had hilarious code like

(char*)((unsigned int)buf + max (write_start - block_start, 0)

that no longer happened to work (by accident) on a 64 bit machine. And these programs (used for splitting vinyl albums into individual songs and the like) are ridiculously fast now. The first time I ran it I thought there must have been a mistake, because it had split the album by the time I had released the key ordering the album to be split.

That’s the difference between a brand new NVMe disk and a first generation SSD. Man, those things were slow…

And the 3.5GHz Kaby Lake CPU probably doesn’t make things worse, either.

Vroom vroom. Now I can listen to music 10x faster than before. With the new machine, the flac files play with a more agile bassline and well-proportioned vocals, with plenty of details in a surefooted rhythmic structure: Nicely layered and fairly large in scale, but not too much authority or fascism.

Also: Gold interconnects.


I’m extremely lazy, so using a remote control to switch the TV on or off is just out of the question. The remote is just languishing in a cupboard somewhere, and the TV is always on. Which seems like a waste, since I only use it (like) a couple of days a week or something.

Most of the time it just functions as an xscreensaver-enabled display to show the sleeve of whatever album’s playing on the stereo.

But then! The other week a friend told me about something magical called “CEC”, which is apparently short for Consumer Electronics Control. It allows sending commands via HDMI (High-Definition Multimedia Interface) from your VIDEO (Visual Ideas Directed Except Oldskool) card to the TV (Television).

However, virtually no video cards support this natively. The notable exception is the graphics card in the Raspberry Pi (RPI).

Fortunately, Pulse-Eight sells CEC injectors. It a tiny thing you put in between your computer and your TV. And today it arrived:

Very small and cute.

It’s a bit more extensive with the wiring. The product page said that you can’t use it reliably if you have a very long HDMI cable to your TV, but mine is seven meters, and it seems to work fine…  Oh, perhaps I should try playing something that takes a lot of bandwidth…  Let’s see…  Captain America: Civil War Bluray…  Yup, there’s the captain.  No extra latency or anything that as far as I can tell.

There’s a USB port that you communicate over. The device shows up as a serial device in Linux, and you talk to it via a program called cec-client.

This excellent blog posts details how you use cec-client from Linux, but basically you just say

$ echo 'standby 0' | cec-client -s /dev/ttyACM0

and the TV goes to standby mode.


Mine didn’t, and it’s a five year old Samsung TV. After googling a bit more, it turns out that you have to enable this stuff under the “Anynet+” setting in the menus. Let’s just walk through this quickly, if anybody has problems finding the menu (which is something I had):

It’s way down in the main menu. Enter the “Content View” thing…

… and then choose “Anynet+”…

… and setup..

… and the thing you’re looking for is “Auto Turn Off”. If that’s on, then you can put the TV into standby mode via CEC. Makes sense, huh? HUH?!

So now all the bits are in place, and I can use this stuff. I chose to have xscreensaver wake the screen up with a -watch script modeled after this one.

So when I hit something on the TV machine keyboard, it unblanks xscreensaver and turns the TV on. (This takes an annoyingly long time, though… like 10 seconds? What’s up with TV makers and the incredible slowness involved with anything?)

To switch the TV off, I just hooked it up into my general go out/switch off everything before going to sleep actions.

Emacs is for automation.

There you go.

Obelisk: A Monitor Review

I’ve had the same monitor in my stereo control system for many years. It’s a 20″ Dell that’s OK.

It’s got an appropriate size for the living room. But lately it’s started having a high-pitched whine. If I play only punk music I can’t hear it at all, but otherwise it’s slightly annoying.

So I went looking for a new monitor. I thought it might be nice to have a rotated monitor this time: Higher than wide so that I can display the name of the currently playing artist un-sideways.

Practical as always.

So my specs here were: No logos, and no bezels wider on any sides, and as small as possible. The logo/bezel thing because inevitably that looks weird when rotated, and this is in the living room. Looking pretty is nice.

Behold! After searching for hours, there was one (1) monitor that fit the specs, and it’s this 24″ NEC EX241UN. It’s got very narrow bezels and no logos and nothing ugly. So it’s just like a matte obelisk.

But my stereo computer machine is oooold. It’s based on a 2GHz Pentium M 32-bit CPU. I think I bought it in 2005, possibly? You can see it underneath the cassette player up there… It’s in a Hush enclosure.

And it managed to connect to the screen! I wasn’t quite sure whether it was going to be able to do that, because it’s also a Pentium M motherboard and the video routing is not very well supported by Linux by default. But I managed to route the DVI signal out instead of the LVDS and VGA, and there’s … the Matrix?

Er. X isn’t quite sure….

OK, “Option rotate left” in xorg.conf instead.

Now I have to rearrange all the display data… Hm… Does that look nice?

The monitor itself is pretty nice.  Quite wide viewing angle, but when I standing there at the screen looking for something to play, I do get a slight sheen at the bottom of the screen, so it’s not perfect.  But it’s completely silent, as far as I can tell over my tinnitus.

Perhaps I should have a clock and a load monitor there. Just so that not 100% of the screen is Emacs. I don’t want to appear fanatical or anything.

Or perhaps the sleeve on top?

Hm… Perhaps I should make that font smaller. I’m nearsighted, but not actually blind.

The un-nerdiness of this setup cannot be misunderstimated.

Of course not.  Not.