Currently LocalDisplayAdapter in AOSP filters out similar modes based on their currently limited supported attributes: width/height/refresh.
This leads to a situation where important modes are discarded, like the preferred mode and/or the active mode, leading SurfaceFlinger to select an unwanted and potentially invalid mode in the list provided by drm-hwcomposer to HWC2.
Let's pre-filter the modes provided to HWC2 by :
- systematically adding the preferred mode
- systematically adding the current active mode, if different from preferred mode
- keeping the interlaced modes filtering-out if no other non-interlace modes with same widthXheight exists (for HD-Ready 1080i TVs or CVBS)
- discarding modes if a similar mode with same widthXheight@refresh was already selected for HWC2
This mimics the behavior of LocalDisplayAdapter filtering algorithm, but keeps the important modes from the DRM Point Of View and drops the duplicate modes while keeping the mode ordering from DRM in account.
This local filtering should ultimately go out when HWC2 can actually handle mode Attributes to describe Preferred mode, Interlaced, 3D... and LocalDisplayAdapter uses these Attributes for filtering duplicate modes.
Signed-off-by: Neil Armstrong email@example.com