import from http://hacks.esar.org.uk/hg/hdmilight/file/tip/