We'll want basically the same thing for mdp5, so refactor it out so it can be shared. Signed-off-by: NRob Clark <robdclark@gmail.com>