From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id D1FC410E325 for ; Tue, 9 May 2023 05:43:06 +0000 (UTC) From: Swati Sharma To: igt-dev@lists.freedesktop.org Date: Tue, 9 May 2023 11:12:19 +0530 Message-Id: <20230509054221.162805-2-swati2.sharma@intel.com> In-Reply-To: <20230509054221.162805-1-swati2.sharma@intel.com> References: <20230509054221.162805-1-swati2.sharma@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t 1/3] lib/dsc: Add helpers for VDSC Fractional BPP debugfs entry List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: Helper functions are added for getting/setting VDSC Fractional BPP debugfs entry. v2: -improved func description (Ankit) -increased buff size (Ankit) -asserted bpp_prec (Ankit) v3: -return 0 on success instead of 1 (Jouni) -rebase Signed-off-by: Swati Sharma --- lib/igt_dsc.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_dsc.h | 5 +++ 2 files changed, 89 insertions(+) diff --git a/lib/igt_dsc.c b/lib/igt_dsc.c index 9e1ab9b1..04ec3d98 100644 --- a/lib/igt_dsc.c +++ b/lib/igt_dsc.c @@ -183,3 +183,87 @@ int igt_force_dsc_output_format(int drmfd, char *connector_name, return write_dsc_debugfs(drmfd, connector_name, "i915_dsc_output_format", buf); } + +static +bool check_dsc_fractional_bpp_debugfs(int drmfd, char *connector_name, + const char *check_str) +{ + char file_name[128] = {0}; + char buf[512]; + + sprintf(file_name, "%s/i915_dsc_fractional_bpp", connector_name); + + igt_debugfs_read(drmfd, file_name, buf); + + return strstr(buf, check_str); +} + +/* + * igt_get_dsc_fractional_bpp_supported: + * @drmfd: A drm file descriptor + * @connector_name: Name of the libdrm connector we're going to use + * + * Returns: The dsc sink bpp precision. + * Precision value of + * 16 => 1/16 + * 8 => 1/8 + * 1 => fractional bpp not supported + */ +int igt_get_dsc_fractional_bpp_supported(int drmfd, char *connector_name) +{ + char file_name[128] = {0}; + char buf[512]; + char *start_loc; + int bpp_prec; + + sprintf(file_name, "%s/i915_dsc_fec_support", connector_name); + igt_debugfs_read(drmfd, file_name, buf); + + igt_assert(start_loc = strstr(buf, "DSC_Sink_BPP_Precision: ")); + igt_assert_eq(sscanf(start_loc, "DSC_Sink_BPP_Precision: %d", &bpp_prec), 1); + igt_assert(bpp_prec > 0); + + return bpp_prec; +} + +/* + * igt_is_force_dsc_fractional_bpp_enabled: + * @drmfd: A drm file descriptor + * @connector_name: Name of the libdrm connector we're going to use + * + * Returns: True if DSC Fractional BPP is force enabled (via debugfs) for the given connector, + * false otherwise. + */ +bool igt_is_force_dsc_fractional_bpp_enabled(int drmfd, char *connector_name) +{ + return check_dsc_fractional_bpp_debugfs(drmfd, connector_name, "Force_DSC_Fractional_BPP_Enable: yes"); +} + +/* + * igt_force_dsc_fractional_bpp_enable: + * @drmfd: A drm file descriptor + * @connector_name: Name of the libdrm connector we're going to use + * + * Returns: 0 on success or negative error code, in case of failure. + */ +int igt_force_dsc_fractional_bpp_enable(int drmfd, char *connector_name) +{ + return write_dsc_debugfs(drmfd, connector_name, "i915_dsc_fractional_bpp", "1"); +} + +/* + * igt_get_dsc_fractional_bpp_debugfs_fd: + * @drmfd: A drm file descriptor + * @connector_name: Name of the libdrm connector we're going to use + * + * Returns: fd of the DSC Fractional BPP debugfs for the given connector, + * else returns -1. + */ +int igt_get_dsc_fractional_bpp_debugfs_fd(int drmfd, char *connector_name) +{ + char file_name[128] = {0}; + + sprintf(file_name, "%s/i915_dsc_fractional_bpp", connector_name); + + return openat(igt_debugfs_dir(drmfd), file_name, O_WRONLY); +} diff --git a/lib/igt_dsc.h b/lib/igt_dsc.h index 9608aad4..e4d86696 100644 --- a/lib/igt_dsc.h +++ b/lib/igt_dsc.h @@ -8,6 +8,7 @@ #include "igt_fb.h" #include "igt_kms.h" +#include "igt_core.h" bool igt_is_dsc_supported(int drmfd, char *connector_name); bool igt_is_fec_supported(int drmfd, char *connector_name); @@ -20,5 +21,9 @@ bool igt_is_dsc_output_format_supported_by_sink(int drmfd, char *connector_name, enum dsc_output_format output_format); int igt_force_dsc_output_format(int drmfd, char *connector_name, enum dsc_output_format output_format); +int igt_get_dsc_fractional_bpp_supported(int drmfd, char *connector_name); +bool igt_is_force_dsc_fractional_bpp_enabled(int drmfd, char *connector_name); +int igt_force_dsc_fractional_bpp_enable(int drmfd, char *connector_name); +int igt_get_dsc_fractional_bpp_debugfs_fd(int drmfd, char *connector_name); #endif -- 2.25.1