lavd/fbdev: move common code to separate file