Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/dsc: fix drm_edp_dsc_sink_output_bpp() DPCD high byte usage

The operator precedence between << and & is wrong, leading to the high
byte being completely ignored. For example, with the 6.4 format, 32
becomes 0 and 24 becomes 8. Fix it, and remove the slightly confusing
and unnecessary DP_DSC_MAX_BITS_PER_PIXEL_HI_SHIFT macro while at it.

Fixes: 0575650077ea ("drm/dp: DRM DP helper/macros to get DP sink DSC parameters")
Cc: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Cc: Manasi Navare <navaremanasi@google.com>
Cc: Anusha Srivatsa <anusha.srivatsa@intel.com>
Cc: <stable@vger.kernel.org> # v5.0+
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230406134615.1422509-1-jani.nikula@intel.com

+2 -4
-1
include/drm/display/drm_dp.h
··· 286 286 287 287 #define DP_DSC_MAX_BITS_PER_PIXEL_HI 0x068 /* eDP 1.4 */ 288 288 # define DP_DSC_MAX_BITS_PER_PIXEL_HI_MASK (0x3 << 0) 289 - # define DP_DSC_MAX_BITS_PER_PIXEL_HI_SHIFT 8 290 289 # define DP_DSC_MAX_BPP_DELTA_VERSION_MASK 0x06 291 290 # define DP_DSC_MAX_BPP_DELTA_AVAILABILITY 0x08 292 291
+2 -3
include/drm/display/drm_dp_helper.h
··· 181 181 drm_edp_dsc_sink_output_bpp(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE]) 182 182 { 183 183 return dsc_dpcd[DP_DSC_MAX_BITS_PER_PIXEL_LOW - DP_DSC_SUPPORT] | 184 - (dsc_dpcd[DP_DSC_MAX_BITS_PER_PIXEL_HI - DP_DSC_SUPPORT] & 185 - DP_DSC_MAX_BITS_PER_PIXEL_HI_MASK << 186 - DP_DSC_MAX_BITS_PER_PIXEL_HI_SHIFT); 184 + ((dsc_dpcd[DP_DSC_MAX_BITS_PER_PIXEL_HI - DP_DSC_SUPPORT] & 185 + DP_DSC_MAX_BITS_PER_PIXEL_HI_MASK) << 8); 187 186 } 188 187 189 188 static inline u32