drm/dsc: add helper for calculating rc buffer size from DPCD
authorJani Nikula <jani.nikula@intel.com>
Tue, 8 Dec 2020 12:33:53 +0000 (14:33 +0200)
committerJani Nikula <jani.nikula@intel.com>
Thu, 10 Dec 2020 08:49:47 +0000 (10:49 +0200)
Add a helper for calculating the rc buffer size from the DCPD offsets
DP_DSC_RC_BUF_BLK_SIZE and DP_DSC_RC_BUF_SIZE.

Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Harry Wentland <hwentlan@amd.com>
Cc: Manasi Navare <manasi.d.navare@intel.com>
Cc: Vandita Kulkarni <vandita.kulkarni@intel.com>
Reviewed-by: Vandita Kulkarni <vandita.kulkarni@intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/6c6aee22740fe7a8cf2b8e768bfda378850cf59a.1607429866.git.jani.nikula@intel.com
drivers/gpu/drm/drm_dsc.c
include/drm/drm_dsc.h

index 09afbc01ea94348d78081000571c0ba38c7a1dfa..ff602f7ec65b1e722458a562abf99a138b59b755 100644 (file)
@@ -49,6 +49,33 @@ void drm_dsc_dp_pps_header_init(struct dp_sdp_header *pps_header)
 }
 EXPORT_SYMBOL(drm_dsc_dp_pps_header_init);
 
+/**
+ * drm_dsc_dp_rc_buffer_size - get rc buffer size in bytes
+ * @rc_buffer_block_size: block size code, according to DPCD offset 62h
+ * @rc_buffer_size: number of blocks - 1, according to DPCD offset 63h
+ *
+ * return:
+ * buffer size in bytes, or 0 on invalid input
+ */
+int drm_dsc_dp_rc_buffer_size(u8 rc_buffer_block_size, u8 rc_buffer_size)
+{
+       int size = 1024 * (rc_buffer_size + 1);
+
+       switch (rc_buffer_block_size) {
+       case DP_DSC_RC_BUF_BLK_SIZE_1:
+               return 1 * size;
+       case DP_DSC_RC_BUF_BLK_SIZE_4:
+               return 4 * size;
+       case DP_DSC_RC_BUF_BLK_SIZE_16:
+               return 16 * size;
+       case DP_DSC_RC_BUF_BLK_SIZE_64:
+               return 64 * size;
+       default:
+               return 0;
+       }
+}
+EXPORT_SYMBOL(drm_dsc_dp_rc_buffer_size);
+
 /**
  * drm_dsc_pps_payload_pack() - Populates the DSC PPS
  *
index 732f32740c86416bc56bf88352d48b5fd7acd5c7..e66560174ff16a5fb6a589e4d7eeed0a11aae392 100644 (file)
@@ -602,6 +602,7 @@ struct drm_dsc_pps_infoframe {
 } __packed;
 
 void drm_dsc_dp_pps_header_init(struct dp_sdp_header *pps_header);
+int drm_dsc_dp_rc_buffer_size(u8 rc_buffer_block_size, u8 rc_buffer_size);
 void drm_dsc_pps_payload_pack(struct drm_dsc_picture_parameter_set *pps_sdp,
                                const struct drm_dsc_config *dsc_cfg);
 int drm_dsc_compute_rc_parameters(struct drm_dsc_config *vdsc_cfg);