From: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
To: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>,
<intel-gfx@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH 2/3] drm/i915/display/: Add Read/Write support for Adaptive Sync SDP
Date: Mon, 27 Nov 2023 16:34:15 +0530 [thread overview]
Message-ID: <8f5a608a-21ac-4648-abea-eca29a4ca8da@intel.com> (raw)
In-Reply-To: <20231123140244.4183869-3-mitulkumar.ajitkumar.golani@intel.com>
On 11/23/2023 7:32 PM, Mitul Golani wrote:
> Add the necessary structures and functions to handle reading and
> unpacking Adaptive Sync Secondary Data Packets. Also add support
> to write and pack AS SDP.
>
> Signed-off-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
> ---
> .../drm/i915/display/intel_display_types.h | 1 +
> drivers/gpu/drm/i915/display/intel_dp.c | 118 +++++++++++++++++-
> 2 files changed, 114 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> index 9a44350ba05d..7d87923f63af 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -1325,6 +1325,7 @@ struct intel_crtc_state {
> union hdmi_infoframe hdmi;
> union hdmi_infoframe drm;
> struct drm_dp_vsc_sdp vsc;
> + struct drm_dp_as_sdp async;
> } infoframes;
>
> u8 eld[MAX_ELD_BYTES];
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 1422c2370269..39624746d612 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -94,6 +94,8 @@
> #define INTEL_DP_RESOLUTION_STANDARD (2 << INTEL_DP_RESOLUTION_SHIFT_MASK)
> #define INTEL_DP_RESOLUTION_FAILSAFE (3 << INTEL_DP_RESOLUTION_SHIFT_MASK)
>
> +#define AS_SDP_ENABLE REG_BIT(2)
> +#define AS_SDP_OP_MODE REG_GENMASK(1, 0)
>
> /* Constants for DP DSC configurations */
> static const u8 valid_dsc_bpp[] = {6, 8, 10, 12, 15};
> @@ -4113,6 +4115,42 @@ intel_dp_needs_vsc_sdp(const struct intel_crtc_state *crtc_state,
> return false;
> }
>
> +static ssize_t intel_dp_as_sdp_pack(const struct drm_dp_as_sdp *async,
> + struct dp_sdp *sdp, size_t size)
> +{
> + size_t length = sizeof(struct dp_sdp);
> +
> + if (size < length)
> + return -ENOSPC;
> +
> + memset(sdp, 0, size);
> +
> + /* Prepare AS (Adaptive Sync) VSC Header */
> + sdp->sdp_header.HB0 = 0;
> + sdp->sdp_header.HB1 = async->sdp_type;
> + sdp->sdp_header.HB2 = 0x02;
> + sdp->sdp_header.HB3 = async->length;
> +
> + /* Fill AS (Adaptive Sync) SDP Payload */
> + if ((sdp->db[0] & 0x03) == 0) {
> + sdp->db[3] = 0;
> + sdp->db[4] &= 0xFC;
> + }
> +
> + sdp->db[1] = async->vmin & 0xFF;
> + sdp->db[2] = (async->vmin >> 8) & 0xF;
> + sdp->db[17] = (async->vmin >> 8) & 0xFF;
> + sdp->db[18] = async->vmax & 0xFF;
> + sdp->db[19] = (async->vmax >> 8) & 0xFF;
> + sdp->db[20] = async->target_rr & 0xFF;
> + sdp->db[21] = (async->target_rr >> 8) & 0xFF;
> + sdp->db[22] = async->duration_incr_ms;
> + sdp->db[23] = async->duration_decr_ms;
> + sdp->db[24] = async->operation_mode;
This doesnt look correct, DB9-31 are supposed to be 0, am I missing
something? Can you re-check this?
> +
> + return length;
> +}
> +
> static ssize_t intel_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc,
> struct dp_sdp *sdp, size_t size)
> {
> @@ -4280,6 +4318,10 @@ static void intel_write_dp_sdp(struct intel_encoder *encoder,
> &crtc_state->infoframes.drm.drm,
> &sdp, sizeof(sdp));
> break;
> + case DP_SDP_ADAPTIVE_SYNC:
> + len = intel_dp_as_sdp_pack(&crtc_state->infoframes.async, &sdp,
> + sizeof(sdp));
> + break;
The function intel_write_dp_sdp with type DP_SDP_ADAPTIVE_SYNC needs to
be called from intel_dp_set_infoframes.
I see this is missing, perhaps to be added as last patch.
> default:
> MISSING_CASE(type);
> return;
> @@ -4342,6 +4384,44 @@ void intel_dp_set_infoframes(struct intel_encoder *encoder,
> intel_write_dp_sdp(encoder, crtc_state, HDMI_PACKET_TYPE_GAMUT_METADATA);
> }
>
> +/*
> + * This function is to unpack AS SDP Packet
> + */
> +static
> +int intel_dp_as_sdp_unpack(struct drm_dp_as_sdp *async,
> + const void *buffer, size_t size)
> +{
> + const struct dp_sdp *sdp = buffer;
> +
> + if (size < sizeof(struct dp_sdp))
> + return -EINVAL;
> +
> + memset(async, 0, sizeof(*async));
> +
> + if (sdp->sdp_header.HB0 != 0)
> + return -EINVAL;
> +
> + if (sdp->sdp_header.HB1 != DP_SDP_ADAPTIVE_SYNC)
> + return -EINVAL;
> +
> + if (sdp->sdp_header.HB2 != 0x02)
> + return -EINVAL;
> +
> + if ((sdp->sdp_header.HB3 & 0x3F) != 9)
> + return -EINVAL;
> +
> + if (sdp->db[0] != (AS_SDP_ENABLE | AS_SDP_OP_MODE))
> + return -EINVAL;
> +
> + async->vmin = ((u64)sdp->db[2] << 32) | (u64)sdp->db[1];
> + async->vmax = 0;
> + async->target_rr = 0;
> + async->duration_incr_ms = 0;
> + async->duration_decr_ms = 0;
> +
> + return 0;
> +}
> +
> static int intel_dp_vsc_sdp_unpack(struct drm_dp_vsc_sdp *vsc,
> const void *buffer, size_t size)
> {
> @@ -4412,12 +4492,35 @@ static int intel_dp_vsc_sdp_unpack(struct drm_dp_vsc_sdp *vsc,
> return 0;
> }
>
> +/*
> + * This function to read registers to fetch packets
> + */
> +static int
> +intel_read_dp_as_metadata_infoframe_sdp(struct intel_encoder *encoder,
> + struct intel_crtc_state *crtc_state,
> + struct drm_dp_as_sdp *async)
> +{
> + struct intel_digital_port *dig_port = enc_to_dig_port(encoder);
> + struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> + unsigned int type = DP_SDP_ADAPTIVE_SYNC;
> + struct dp_sdp sdp = {};
> + int ret;
> +
> + dig_port->read_infoframe(encoder, crtc_state, type, &sdp,
> + sizeof(sdp));
> +
> + ret = intel_dp_as_sdp_unpack(async, &sdp, sizeof(sdp));
> + if (ret)
> + drm_dbg_kms(&dev_priv->drm, "Failed to unpack DP AS SDP\n");
> +
> + return ret;
> +}
> +
> static int
> intel_dp_hdr_metadata_infoframe_sdp_unpack(struct hdmi_drm_infoframe *drm_infoframe,
> const void *buffer, size_t size)
> {
> int ret;
> -
> const struct dp_sdp *sdp = buffer;
>
> if (size < sizeof(struct dp_sdp))
> @@ -4484,9 +4587,10 @@ static void intel_read_dp_vsc_sdp(struct intel_encoder *encoder,
> drm_dbg_kms(&dev_priv->drm, "Failed to unpack DP VSC SDP\n");
> }
>
> -static void intel_read_dp_hdr_metadata_infoframe_sdp(struct intel_encoder *encoder,
> - struct intel_crtc_state *crtc_state,
> - struct hdmi_drm_infoframe *drm_infoframe)
> +static void
> +intel_read_dp_hdr_metadata_infoframe_sdp(struct intel_encoder *encoder,
> + struct intel_crtc_state *crtc_state,
> + struct hdmi_drm_infoframe *drm_infoframe)
> {
> struct intel_digital_port *dig_port = enc_to_dig_port(encoder);
> struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> @@ -4495,7 +4599,7 @@ static void intel_read_dp_hdr_metadata_infoframe_sdp(struct intel_encoder *encod
> int ret;
>
> if ((crtc_state->infoframes.enable &
> - intel_hdmi_infoframe_enable(type)) == 0)
> + intel_hdmi_infoframe_enable(type)) == 0)
> return;
>
> dig_port->read_infoframe(encoder, crtc_state, type, &sdp,
> @@ -4522,6 +4626,10 @@ void intel_read_dp_sdp(struct intel_encoder *encoder,
> intel_read_dp_hdr_metadata_infoframe_sdp(encoder, crtc_state,
> &crtc_state->infoframes.drm.drm);
> break;
> + case DP_SDP_ADAPTIVE_SYNC:
> + intel_read_dp_as_metadata_infoframe_sdp(encoder, crtc_state,
> + &crtc_state->infoframes.async);
> + break;
Similar to the write case, call to intel_read_dp_sdp with
DP_SDP_ADAPTIVE_SYNC is missing from intel_ddi_get_config.
So need a patch to actually call read and writes.
Regards,
Ankit
> default:
> MISSING_CASE(type);
> break;
next prev parent reply other threads:[~2023-11-27 11:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 14:02 [Intel-gfx] [PATCH 0/3] Enable Adaptive Sync SDP Support for DP Mitul Golani
2023-11-23 14:02 ` [Intel-gfx] [PATCH 1/3] drm: Add Adaptive Sync SDP logging Mitul Golani
2023-11-23 15:22 ` Nautiyal, Ankit K
2023-11-24 5:58 ` kernel test robot
2023-11-24 7:56 ` kernel test robot
2023-11-24 12:53 ` Jani Nikula
2023-11-23 14:02 ` [Intel-gfx] [PATCH 2/3] drm/i915/display/: Add Read/Write support for Adaptive Sync SDP Mitul Golani
2023-11-24 13:01 ` Jani Nikula
2023-11-24 13:01 ` Jani Nikula
2023-11-27 11:04 ` Nautiyal, Ankit K [this message]
2023-11-23 14:02 ` [Intel-gfx] [PATCH 3/3] drm/i915/display/:Compute and enable daptive " Mitul Golani
2023-11-27 11:04 ` Nautiyal, Ankit K
2023-11-23 19:48 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for Enable Adaptive Sync SDP Support for DP Patchwork
2023-11-23 20:06 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8f5a608a-21ac-4648-abea-eca29a4ca8da@intel.com \
--to=ankit.k.nautiyal@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mitulkumar.ajitkumar.golani@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox