Message ID | 20240215190834.3222812-1-quic_abhinavk@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-67553-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp60759dyb; Thu, 15 Feb 2024 11:09:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW7riNMqvvycVg6pST7MXYdy+idhpczlX6B0Wjl9rHmkAQJMwUtiiaKgqYXMNWvlNBZXVj7Dx25dRj9hnlDghC8LDqnQQ== X-Google-Smtp-Source: AGHT+IEj7aaROBU++/kn2BzjoZGjKwwuUOZ/yyVXqMolIoK4ptbg7Nc9iAW1c/sy87AFUoQNWpWw X-Received: by 2002:ac2:58ca:0:b0:512:8881:b0b0 with SMTP id u10-20020ac258ca000000b005128881b0b0mr1564168lfo.38.1708024158944; Thu, 15 Feb 2024 11:09:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708024158; cv=pass; d=google.com; s=arc-20160816; b=S9SIdXqislNg8mX5faKjUrgCrR7CNnOsuw10So6VUzMIfRS9Hc5qgK1JOURdZe1vpp 3Tjyyb9U3fLxGeaQVbo4xlC7w9DAxBbSE77tbsrb+++RmaWanMWvAjy9wBUF31mgSQJd 4eyPxVSLtZi8N2QMDQoSQzH3IX3xr0P5XcLCU5hvPv1vvBvUoR1ChT1z++i0zmEVvz5F Qcjtn/hJxbPbzUJQUXEznItqJySGf6+hMyULhxB1n3T847Mcfu5paxTvZ5NG9Em4MkSM 9hDi0couaERPKK0CdWBTpXCEX6jLlxV0JMLpvjQ3inEfxUL1XPrrJZ/c/8bny3LLdDNK Gehw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=8WHqq+JPABcr9TUapr2Y2fy9p+O1+fPjCNfuvXj4B+g=; fh=jkkot3vQwRdh7ZCFqr69BTjy6RVP37XrlzFJqwqUX3Q=; b=Rgxv9/8Cblbvq9eRWzqFN+pe9ZnbnjylLmkG6QAK3YvgTxTPHsqLczDL2PTa/VBT1R igZKBkAUnrGxYzj/2cw5s2LcYNAoK0CDIpSQELMZupjdCFlQ2aa6ywPOdDXb/hKODN1H 4nQH9Knt08OJ/2DoeDMvLAMdcRMDECizbuJU02cf3CRJ0FdFt5hRknxJv5XuU256ylrS A7OhYPVquf7TzFWAQZToCrR3388rZzuxT/3vdt1k8N2IdP5Sopu1cR0WgH5IsyquKM37 jfy4mNetzn+18gsztG9LORwtU2E8V7CDJgZdGgNGAF9P0C2oO4yWKp2mQI6eu7HAXAm9 h61g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=U3nj8npf; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-67553-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67553-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id mb8-20020a170906eb0800b00a3db0577915si404098ejb.872.2024.02.15.11.09.18 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 11:09:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67553-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=U3nj8npf; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-67553-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67553-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5F9D31F2151C for <ouuuleilei@gmail.com>; Thu, 15 Feb 2024 19:09:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACCDF13958A; Thu, 15 Feb 2024 19:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="U3nj8npf" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A7123D6D for <linux-kernel@vger.kernel.org>; Thu, 15 Feb 2024 19:09:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708024143; cv=none; b=DXbBTxO6aBlPbJhz977gqa09gyu5XVyf7Rw+JRrk74rAHrDQjrxClnpdCzGb52GMbzI78KVyLsAhuXQ1Ylsn0w5Jg4d6P+SLvAw2dST1Gr9Pk2c1xGHrzIutd8Hh9s2PEvxHR0Yn+8rmggwSTwa9mKEVRTmNNS4mX0zKajZHcRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708024143; c=relaxed/simple; bh=Vrycz9zR0jiW5CW4N8cLC6KiY0T/p5ojmCrCUnGWMaw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=VEuDo19bmVuvUk7HxgMQ3M//OaWftf9tCllS1IeXxkA+lHHfPbngg7WBSEBPto4ANu3kJj3qU4d5I6adnsH7ML1R5X1YCVifHVp4TgxhVFd9qEVVkXMkJzxG+8ZSZqmVPsHSN+GKgU9ENeMKYaGNOzM8PBOefO/cgaknzjaib4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=U3nj8npf; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41FG4MuE031791; Thu, 15 Feb 2024 19:08:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=8WHqq+J PABcr9TUapr2Y2fy9p+O1+fPjCNfuvXj4B+g=; b=U3nj8npfAnNfCxDhFSwx0ox Pv5duhUZK4vETAWTCoAe5j/MKCEyv9imxXl83Dnm4hGEVtz7yShqyAbkzmRvx8ll 9wZEcN6dCvSa4aBx/ksxJtHxuxKkbZ/3LexeCGtczny+7lpj1yMUy/ndPT2f/V/L 8sztCAhB46O7ndnULj00uGZECcanbYyzD8tyq8SAoI1SfmXXqAXL3r7kjnplWmKM YujT5exyEojDuRGVxak0TMCh1rP1oB1EIOJtMD4IZE4UGJqbnG42++npNg2q1SPO VDMO+aUbmxxxSxSG+3deHhLlOI9g54+iuuZBTs5nw2Rnq95Tz51++WZF2z4UHmQ= = Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w9e4h1t72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Feb 2024 19:08:45 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41FJ8ido010080 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Feb 2024 19:08:44 GMT Received: from abhinavk-linux1.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 15 Feb 2024 11:08:43 -0800 From: Abhinav Kumar <quic_abhinavk@quicinc.com> To: <dri-devel@lists.freedesktop.org>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Jani Nikula <jani.nikula@linux.intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> CC: Abhinav Kumar <quic_abhinavk@quicinc.com>, <robdclark@gmail.com>, <freedreno@lists.freedesktop.org>, <dmitry.baryshkov@linaro.org>, <intel-gfx@lists.freedesktop.org>, <ville.syrjala@linux.intel.com>, <quic_jesszhan@quicinc.com>, <linux-kernel@vger.kernel.org>, <intel-xe@lists.freedesktop.org> Subject: [PATCH v2] drm/dp: move intel_dp_vsc_sdp_pack() to generic helper Date: Thu, 15 Feb 2024 11:08:34 -0800 Message-ID: <20240215190834.3222812-1-quic_abhinavk@quicinc.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: T7dngG2H_HaB3-eFianvs3eRmlcF3_dr X-Proofpoint-ORIG-GUID: T7dngG2H_HaB3-eFianvs3eRmlcF3_dr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-15_18,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 impostorscore=0 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402150154 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790993140397242507 X-GMAIL-MSGID: 1790993140397242507 |
Series |
[v2] drm/dp: move intel_dp_vsc_sdp_pack() to generic helper
|
|
Commit Message
Abhinav Kumar
Feb. 15, 2024, 7:08 p.m. UTC
intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. Lets move this to drm_dp_helper to achieve this. changes in v2: - rebased on top of drm-tip Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com> --- drivers/gpu/drm/display/drm_dp_helper.c | 78 +++++++++++++++++++++++++ drivers/gpu/drm/i915/display/intel_dp.c | 71 +--------------------- include/drm/display/drm_dp_helper.h | 3 + 3 files changed, 83 insertions(+), 69 deletions(-)
Comments
On Thu, 15 Feb 2024, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. > Lets move this to drm_dp_helper to achieve this. > > changes in v2: > - rebased on top of drm-tip > > Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Acked-by: Jani Nikula <jani.nikula@intel.com> > --- > drivers/gpu/drm/display/drm_dp_helper.c | 78 +++++++++++++++++++++++++ > drivers/gpu/drm/i915/display/intel_dp.c | 71 +--------------------- > include/drm/display/drm_dp_helper.h | 3 + > 3 files changed, 83 insertions(+), 69 deletions(-) > > diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c > index 8d6ce46471ae..6c91f400ecb1 100644 > --- a/drivers/gpu/drm/display/drm_dp_helper.c > +++ b/drivers/gpu/drm/display/drm_dp_helper.c > @@ -2913,6 +2913,84 @@ void drm_dp_vsc_sdp_log(struct drm_printer *p, const struct drm_dp_vsc_sdp *vsc) > } > EXPORT_SYMBOL(drm_dp_vsc_sdp_log); > > +/** > + * drm_dp_vsc_sdp_pack() - pack a given vsc sdp into generic dp_sdp > + * @vsc: vsc sdp initialized according to its purpose as defined in > + * table 2-118 - table 2-120 in DP 1.4a specification > + * @sdp: valid handle to the generic dp_sdp which will be packed > + * @size: valid size of the passed sdp handle > + * > + * Returns length of sdp on success and error code on failure > + */ > +ssize_t drm_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, > + struct dp_sdp *sdp, size_t size) > +{ > + size_t length = sizeof(struct dp_sdp); > + > + if (size < length) > + return -ENOSPC; > + > + memset(sdp, 0, size); > + > + /* > + * Prepare VSC Header for SU as per DP 1.4a spec, Table 2-119 > + * VSC SDP Header Bytes > + */ > + sdp->sdp_header.HB0 = 0; /* Secondary-Data Packet ID = 0 */ > + sdp->sdp_header.HB1 = vsc->sdp_type; /* Secondary-data Packet Type */ > + sdp->sdp_header.HB2 = vsc->revision; /* Revision Number */ > + sdp->sdp_header.HB3 = vsc->length; /* Number of Valid Data Bytes */ > + > + if (vsc->revision == 0x6) { > + sdp->db[0] = 1; > + sdp->db[3] = 1; > + } > + > + /* > + * Revision 0x5 and revision 0x7 supports Pixel Encoding/Colorimetry > + * Format as per DP 1.4a spec and DP 2.0 respectively. > + */ > + if (!(vsc->revision == 0x5 || vsc->revision == 0x7)) > + goto out; > + > + /* VSC SDP Payload for DB16 through DB18 */ > + /* Pixel Encoding and Colorimetry Formats */ > + sdp->db[16] = (vsc->pixelformat & 0xf) << 4; /* DB16[7:4] */ > + sdp->db[16] |= vsc->colorimetry & 0xf; /* DB16[3:0] */ > + > + switch (vsc->bpc) { > + case 6: > + /* 6bpc: 0x0 */ > + break; > + case 8: > + sdp->db[17] = 0x1; /* DB17[3:0] */ > + break; > + case 10: > + sdp->db[17] = 0x2; > + break; > + case 12: > + sdp->db[17] = 0x3; > + break; > + case 16: > + sdp->db[17] = 0x4; > + break; > + default: > + WARN(1, "Missing case %d\n", vsc->bpc); > + return -EINVAL; > + } > + > + /* Dynamic Range and Component Bit Depth */ > + if (vsc->dynamic_range == DP_DYNAMIC_RANGE_CTA) > + sdp->db[17] |= 0x80; /* DB17[7] */ > + > + /* Content Type */ > + sdp->db[18] = vsc->content_type & 0x7; > + > +out: > + return length; > +} > +EXPORT_SYMBOL(drm_dp_vsc_sdp_pack); > + > /** > * drm_dp_get_pcon_max_frl_bw() - maximum frl supported by PCON > * @dpcd: DisplayPort configuration data > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c > index 217196196e50..a9458df475e2 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp.c > +++ b/drivers/gpu/drm/i915/display/intel_dp.c > @@ -4089,73 +4089,6 @@ intel_dp_needs_vsc_sdp(const struct intel_crtc_state *crtc_state, > return false; > } > > -static ssize_t intel_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, > - struct dp_sdp *sdp, size_t size) > -{ > - size_t length = sizeof(struct dp_sdp); > - > - if (size < length) > - return -ENOSPC; > - > - memset(sdp, 0, size); > - > - /* > - * Prepare VSC Header for SU as per DP 1.4a spec, Table 2-119 > - * VSC SDP Header Bytes > - */ > - sdp->sdp_header.HB0 = 0; /* Secondary-Data Packet ID = 0 */ > - sdp->sdp_header.HB1 = vsc->sdp_type; /* Secondary-data Packet Type */ > - sdp->sdp_header.HB2 = vsc->revision; /* Revision Number */ > - sdp->sdp_header.HB3 = vsc->length; /* Number of Valid Data Bytes */ > - > - if (vsc->revision == 0x6) { > - sdp->db[0] = 1; > - sdp->db[3] = 1; > - } > - > - /* > - * Revision 0x5 and revision 0x7 supports Pixel Encoding/Colorimetry > - * Format as per DP 1.4a spec and DP 2.0 respectively. > - */ > - if (!(vsc->revision == 0x5 || vsc->revision == 0x7)) > - goto out; > - > - /* VSC SDP Payload for DB16 through DB18 */ > - /* Pixel Encoding and Colorimetry Formats */ > - sdp->db[16] = (vsc->pixelformat & 0xf) << 4; /* DB16[7:4] */ > - sdp->db[16] |= vsc->colorimetry & 0xf; /* DB16[3:0] */ > - > - switch (vsc->bpc) { > - case 6: > - /* 6bpc: 0x0 */ > - break; > - case 8: > - sdp->db[17] = 0x1; /* DB17[3:0] */ > - break; > - case 10: > - sdp->db[17] = 0x2; > - break; > - case 12: > - sdp->db[17] = 0x3; > - break; > - case 16: > - sdp->db[17] = 0x4; > - break; > - default: > - MISSING_CASE(vsc->bpc); > - break; > - } > - /* Dynamic Range and Component Bit Depth */ > - if (vsc->dynamic_range == DP_DYNAMIC_RANGE_CTA) > - sdp->db[17] |= 0x80; /* DB17[7] */ > - > - /* Content Type */ > - sdp->db[18] = vsc->content_type & 0x7; > - > -out: > - return length; > -} > - > static ssize_t > intel_dp_hdr_metadata_infoframe_sdp_pack(struct drm_i915_private *i915, > const struct hdmi_drm_infoframe *drm_infoframe, > @@ -4248,8 +4181,8 @@ static void intel_write_dp_sdp(struct intel_encoder *encoder, > > switch (type) { > case DP_SDP_VSC: > - len = intel_dp_vsc_sdp_pack(&crtc_state->infoframes.vsc, &sdp, > - sizeof(sdp)); > + len = drm_dp_vsc_sdp_pack(&crtc_state->infoframes.vsc, &sdp, > + sizeof(sdp)); > break; > case HDMI_PACKET_TYPE_GAMUT_METADATA: > len = intel_dp_hdr_metadata_infoframe_sdp_pack(dev_priv, > diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h > index d02014a87f12..8474504d4c88 100644 > --- a/include/drm/display/drm_dp_helper.h > +++ b/include/drm/display/drm_dp_helper.h > @@ -812,4 +812,7 @@ int drm_dp_bw_overhead(int lane_count, int hactive, > int bpp_x16, unsigned long flags); > int drm_dp_bw_channel_coding_efficiency(bool is_uhbr); > > +ssize_t drm_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, > + struct dp_sdp *sdp, size_t size); > + > #endif /* _DRM_DP_HELPER_H_ */
On Thu, 15 Feb 2024 at 21:08, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > > intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. > Lets move this to drm_dp_helper to achieve this. > > changes in v2: > - rebased on top of drm-tip > > Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> v1 had an explicit comment before the ack: > From my side, with the promise of the size fixup. However I observe neither a second patch removing the size argument nor it being dropped as a part of this patch. > Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com> > --- > drivers/gpu/drm/display/drm_dp_helper.c | 78 +++++++++++++++++++++++++ > drivers/gpu/drm/i915/display/intel_dp.c | 71 +--------------------- > include/drm/display/drm_dp_helper.h | 3 + > 3 files changed, 83 insertions(+), 69 deletions(-) > > diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c > index 8d6ce46471ae..6c91f400ecb1 100644 > --- a/drivers/gpu/drm/display/drm_dp_helper.c > +++ b/drivers/gpu/drm/display/drm_dp_helper.c > @@ -2913,6 +2913,84 @@ void drm_dp_vsc_sdp_log(struct drm_printer *p, const struct drm_dp_vsc_sdp *vsc) > } > EXPORT_SYMBOL(drm_dp_vsc_sdp_log); > > +/** > + * drm_dp_vsc_sdp_pack() - pack a given vsc sdp into generic dp_sdp > + * @vsc: vsc sdp initialized according to its purpose as defined in > + * table 2-118 - table 2-120 in DP 1.4a specification > + * @sdp: valid handle to the generic dp_sdp which will be packed > + * @size: valid size of the passed sdp handle > + * > + * Returns length of sdp on success and error code on failure > + */ > +ssize_t drm_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, > + struct dp_sdp *sdp, size_t size) > +{ > + size_t length = sizeof(struct dp_sdp); > + > + if (size < length) > + return -ENOSPC; > + > + memset(sdp, 0, size); > + > + /* > + * Prepare VSC Header for SU as per DP 1.4a spec, Table 2-119 > + * VSC SDP Header Bytes > + */ > + sdp->sdp_header.HB0 = 0; /* Secondary-Data Packet ID = 0 */ > + sdp->sdp_header.HB1 = vsc->sdp_type; /* Secondary-data Packet Type */ > + sdp->sdp_header.HB2 = vsc->revision; /* Revision Number */ > + sdp->sdp_header.HB3 = vsc->length; /* Number of Valid Data Bytes */ > + > + if (vsc->revision == 0x6) { > + sdp->db[0] = 1; > + sdp->db[3] = 1; > + } > + > + /* > + * Revision 0x5 and revision 0x7 supports Pixel Encoding/Colorimetry > + * Format as per DP 1.4a spec and DP 2.0 respectively. > + */ > + if (!(vsc->revision == 0x5 || vsc->revision == 0x7)) > + goto out; > + > + /* VSC SDP Payload for DB16 through DB18 */ > + /* Pixel Encoding and Colorimetry Formats */ > + sdp->db[16] = (vsc->pixelformat & 0xf) << 4; /* DB16[7:4] */ > + sdp->db[16] |= vsc->colorimetry & 0xf; /* DB16[3:0] */ > + > + switch (vsc->bpc) { > + case 6: > + /* 6bpc: 0x0 */ > + break; > + case 8: > + sdp->db[17] = 0x1; /* DB17[3:0] */ > + break; > + case 10: > + sdp->db[17] = 0x2; > + break; > + case 12: > + sdp->db[17] = 0x3; > + break; > + case 16: > + sdp->db[17] = 0x4; > + break; > + default: > + WARN(1, "Missing case %d\n", vsc->bpc); > + return -EINVAL; > + } > + > + /* Dynamic Range and Component Bit Depth */ > + if (vsc->dynamic_range == DP_DYNAMIC_RANGE_CTA) > + sdp->db[17] |= 0x80; /* DB17[7] */ > + > + /* Content Type */ > + sdp->db[18] = vsc->content_type & 0x7; > + > +out: > + return length; > +} > +EXPORT_SYMBOL(drm_dp_vsc_sdp_pack); > + > /** > * drm_dp_get_pcon_max_frl_bw() - maximum frl supported by PCON > * @dpcd: DisplayPort configuration data > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c > index 217196196e50..a9458df475e2 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp.c > +++ b/drivers/gpu/drm/i915/display/intel_dp.c > @@ -4089,73 +4089,6 @@ intel_dp_needs_vsc_sdp(const struct intel_crtc_state *crtc_state, > return false; > } > > -static ssize_t intel_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, > - struct dp_sdp *sdp, size_t size) > -{ > - size_t length = sizeof(struct dp_sdp); > - > - if (size < length) > - return -ENOSPC; > - > - memset(sdp, 0, size); > - > - /* > - * Prepare VSC Header for SU as per DP 1.4a spec, Table 2-119 > - * VSC SDP Header Bytes > - */ > - sdp->sdp_header.HB0 = 0; /* Secondary-Data Packet ID = 0 */ > - sdp->sdp_header.HB1 = vsc->sdp_type; /* Secondary-data Packet Type */ > - sdp->sdp_header.HB2 = vsc->revision; /* Revision Number */ > - sdp->sdp_header.HB3 = vsc->length; /* Number of Valid Data Bytes */ > - > - if (vsc->revision == 0x6) { > - sdp->db[0] = 1; > - sdp->db[3] = 1; > - } > - > - /* > - * Revision 0x5 and revision 0x7 supports Pixel Encoding/Colorimetry > - * Format as per DP 1.4a spec and DP 2.0 respectively. > - */ > - if (!(vsc->revision == 0x5 || vsc->revision == 0x7)) > - goto out; > - > - /* VSC SDP Payload for DB16 through DB18 */ > - /* Pixel Encoding and Colorimetry Formats */ > - sdp->db[16] = (vsc->pixelformat & 0xf) << 4; /* DB16[7:4] */ > - sdp->db[16] |= vsc->colorimetry & 0xf; /* DB16[3:0] */ > - > - switch (vsc->bpc) { > - case 6: > - /* 6bpc: 0x0 */ > - break; > - case 8: > - sdp->db[17] = 0x1; /* DB17[3:0] */ > - break; > - case 10: > - sdp->db[17] = 0x2; > - break; > - case 12: > - sdp->db[17] = 0x3; > - break; > - case 16: > - sdp->db[17] = 0x4; > - break; > - default: > - MISSING_CASE(vsc->bpc); > - break; > - } > - /* Dynamic Range and Component Bit Depth */ > - if (vsc->dynamic_range == DP_DYNAMIC_RANGE_CTA) > - sdp->db[17] |= 0x80; /* DB17[7] */ > - > - /* Content Type */ > - sdp->db[18] = vsc->content_type & 0x7; > - > -out: > - return length; > -} > - > static ssize_t > intel_dp_hdr_metadata_infoframe_sdp_pack(struct drm_i915_private *i915, > const struct hdmi_drm_infoframe *drm_infoframe, > @@ -4248,8 +4181,8 @@ static void intel_write_dp_sdp(struct intel_encoder *encoder, > > switch (type) { > case DP_SDP_VSC: > - len = intel_dp_vsc_sdp_pack(&crtc_state->infoframes.vsc, &sdp, > - sizeof(sdp)); > + len = drm_dp_vsc_sdp_pack(&crtc_state->infoframes.vsc, &sdp, > + sizeof(sdp)); > break; > case HDMI_PACKET_TYPE_GAMUT_METADATA: > len = intel_dp_hdr_metadata_infoframe_sdp_pack(dev_priv, > diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h > index d02014a87f12..8474504d4c88 100644 > --- a/include/drm/display/drm_dp_helper.h > +++ b/include/drm/display/drm_dp_helper.h > @@ -812,4 +812,7 @@ int drm_dp_bw_overhead(int lane_count, int hactive, > int bpp_x16, unsigned long flags); > int drm_dp_bw_channel_coding_efficiency(bool is_uhbr); > > +ssize_t drm_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, > + struct dp_sdp *sdp, size_t size); > + > #endif /* _DRM_DP_HELPER_H_ */ > -- > 2.34.1 >
On 2/20/2024 10:49 AM, Dmitry Baryshkov wrote: > On Thu, 15 Feb 2024 at 21:08, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: >> >> intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. >> Lets move this to drm_dp_helper to achieve this. >> >> changes in v2: >> - rebased on top of drm-tip >> >> Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > > v1 had an explicit comment before the ack: > Yes, I remember the comment. I did not make any changes to v2 other than just rebasing it on drm-tip to get the ack from i915 folks. >> From my side, with the promise of the size fixup. > > However I observe neither a second patch removing the size argument > nor it being dropped as a part of this patch. > Yes, now that in v2 we got the ack for this patch, I can spin a v3 with the addition of the next patch to remove the size OR as another series so as to not block the main series which needs this patch. I would prefer the latter. >> Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com> >> --- >> drivers/gpu/drm/display/drm_dp_helper.c | 78 +++++++++++++++++++++++++ >> drivers/gpu/drm/i915/display/intel_dp.c | 71 +--------------------- >> include/drm/display/drm_dp_helper.h | 3 + >> 3 files changed, 83 insertions(+), 69 deletions(-) >> >> diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c >> index 8d6ce46471ae..6c91f400ecb1 100644 >> --- a/drivers/gpu/drm/display/drm_dp_helper.c >> +++ b/drivers/gpu/drm/display/drm_dp_helper.c >> @@ -2913,6 +2913,84 @@ void drm_dp_vsc_sdp_log(struct drm_printer *p, const struct drm_dp_vsc_sdp *vsc) >> } >> EXPORT_SYMBOL(drm_dp_vsc_sdp_log); >> >> +/** >> + * drm_dp_vsc_sdp_pack() - pack a given vsc sdp into generic dp_sdp >> + * @vsc: vsc sdp initialized according to its purpose as defined in >> + * table 2-118 - table 2-120 in DP 1.4a specification >> + * @sdp: valid handle to the generic dp_sdp which will be packed >> + * @size: valid size of the passed sdp handle >> + * >> + * Returns length of sdp on success and error code on failure >> + */ >> +ssize_t drm_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, >> + struct dp_sdp *sdp, size_t size) >> +{ >> + size_t length = sizeof(struct dp_sdp); >> + >> + if (size < length) >> + return -ENOSPC; >> + >> + memset(sdp, 0, size); >> + >> + /* >> + * Prepare VSC Header for SU as per DP 1.4a spec, Table 2-119 >> + * VSC SDP Header Bytes >> + */ >> + sdp->sdp_header.HB0 = 0; /* Secondary-Data Packet ID = 0 */ >> + sdp->sdp_header.HB1 = vsc->sdp_type; /* Secondary-data Packet Type */ >> + sdp->sdp_header.HB2 = vsc->revision; /* Revision Number */ >> + sdp->sdp_header.HB3 = vsc->length; /* Number of Valid Data Bytes */ >> + >> + if (vsc->revision == 0x6) { >> + sdp->db[0] = 1; >> + sdp->db[3] = 1; >> + } >> + >> + /* >> + * Revision 0x5 and revision 0x7 supports Pixel Encoding/Colorimetry >> + * Format as per DP 1.4a spec and DP 2.0 respectively. >> + */ >> + if (!(vsc->revision == 0x5 || vsc->revision == 0x7)) >> + goto out; >> + >> + /* VSC SDP Payload for DB16 through DB18 */ >> + /* Pixel Encoding and Colorimetry Formats */ >> + sdp->db[16] = (vsc->pixelformat & 0xf) << 4; /* DB16[7:4] */ >> + sdp->db[16] |= vsc->colorimetry & 0xf; /* DB16[3:0] */ >> + >> + switch (vsc->bpc) { >> + case 6: >> + /* 6bpc: 0x0 */ >> + break; >> + case 8: >> + sdp->db[17] = 0x1; /* DB17[3:0] */ >> + break; >> + case 10: >> + sdp->db[17] = 0x2; >> + break; >> + case 12: >> + sdp->db[17] = 0x3; >> + break; >> + case 16: >> + sdp->db[17] = 0x4; >> + break; >> + default: >> + WARN(1, "Missing case %d\n", vsc->bpc); >> + return -EINVAL; >> + } >> + >> + /* Dynamic Range and Component Bit Depth */ >> + if (vsc->dynamic_range == DP_DYNAMIC_RANGE_CTA) >> + sdp->db[17] |= 0x80; /* DB17[7] */ >> + >> + /* Content Type */ >> + sdp->db[18] = vsc->content_type & 0x7; >> + >> +out: >> + return length; >> +} >> +EXPORT_SYMBOL(drm_dp_vsc_sdp_pack); >> + >> /** >> * drm_dp_get_pcon_max_frl_bw() - maximum frl supported by PCON >> * @dpcd: DisplayPort configuration data >> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c >> index 217196196e50..a9458df475e2 100644 >> --- a/drivers/gpu/drm/i915/display/intel_dp.c >> +++ b/drivers/gpu/drm/i915/display/intel_dp.c >> @@ -4089,73 +4089,6 @@ intel_dp_needs_vsc_sdp(const struct intel_crtc_state *crtc_state, >> return false; >> } >> >> -static ssize_t intel_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, >> - struct dp_sdp *sdp, size_t size) >> -{ >> - size_t length = sizeof(struct dp_sdp); >> - >> - if (size < length) >> - return -ENOSPC; >> - >> - memset(sdp, 0, size); >> - >> - /* >> - * Prepare VSC Header for SU as per DP 1.4a spec, Table 2-119 >> - * VSC SDP Header Bytes >> - */ >> - sdp->sdp_header.HB0 = 0; /* Secondary-Data Packet ID = 0 */ >> - sdp->sdp_header.HB1 = vsc->sdp_type; /* Secondary-data Packet Type */ >> - sdp->sdp_header.HB2 = vsc->revision; /* Revision Number */ >> - sdp->sdp_header.HB3 = vsc->length; /* Number of Valid Data Bytes */ >> - >> - if (vsc->revision == 0x6) { >> - sdp->db[0] = 1; >> - sdp->db[3] = 1; >> - } >> - >> - /* >> - * Revision 0x5 and revision 0x7 supports Pixel Encoding/Colorimetry >> - * Format as per DP 1.4a spec and DP 2.0 respectively. >> - */ >> - if (!(vsc->revision == 0x5 || vsc->revision == 0x7)) >> - goto out; >> - >> - /* VSC SDP Payload for DB16 through DB18 */ >> - /* Pixel Encoding and Colorimetry Formats */ >> - sdp->db[16] = (vsc->pixelformat & 0xf) << 4; /* DB16[7:4] */ >> - sdp->db[16] |= vsc->colorimetry & 0xf; /* DB16[3:0] */ >> - >> - switch (vsc->bpc) { >> - case 6: >> - /* 6bpc: 0x0 */ >> - break; >> - case 8: >> - sdp->db[17] = 0x1; /* DB17[3:0] */ >> - break; >> - case 10: >> - sdp->db[17] = 0x2; >> - break; >> - case 12: >> - sdp->db[17] = 0x3; >> - break; >> - case 16: >> - sdp->db[17] = 0x4; >> - break; >> - default: >> - MISSING_CASE(vsc->bpc); >> - break; >> - } >> - /* Dynamic Range and Component Bit Depth */ >> - if (vsc->dynamic_range == DP_DYNAMIC_RANGE_CTA) >> - sdp->db[17] |= 0x80; /* DB17[7] */ >> - >> - /* Content Type */ >> - sdp->db[18] = vsc->content_type & 0x7; >> - >> -out: >> - return length; >> -} >> - >> static ssize_t >> intel_dp_hdr_metadata_infoframe_sdp_pack(struct drm_i915_private *i915, >> const struct hdmi_drm_infoframe *drm_infoframe, >> @@ -4248,8 +4181,8 @@ static void intel_write_dp_sdp(struct intel_encoder *encoder, >> >> switch (type) { >> case DP_SDP_VSC: >> - len = intel_dp_vsc_sdp_pack(&crtc_state->infoframes.vsc, &sdp, >> - sizeof(sdp)); >> + len = drm_dp_vsc_sdp_pack(&crtc_state->infoframes.vsc, &sdp, >> + sizeof(sdp)); >> break; >> case HDMI_PACKET_TYPE_GAMUT_METADATA: >> len = intel_dp_hdr_metadata_infoframe_sdp_pack(dev_priv, >> diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h >> index d02014a87f12..8474504d4c88 100644 >> --- a/include/drm/display/drm_dp_helper.h >> +++ b/include/drm/display/drm_dp_helper.h >> @@ -812,4 +812,7 @@ int drm_dp_bw_overhead(int lane_count, int hactive, >> int bpp_x16, unsigned long flags); >> int drm_dp_bw_channel_coding_efficiency(bool is_uhbr); >> >> +ssize_t drm_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, >> + struct dp_sdp *sdp, size_t size); >> + >> #endif /* _DRM_DP_HELPER_H_ */ >> -- >> 2.34.1 >> > >
On Tue, 20 Feb 2024 at 20:53, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > > > > On 2/20/2024 10:49 AM, Dmitry Baryshkov wrote: > > On Thu, 15 Feb 2024 at 21:08, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > >> > >> intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. > >> Lets move this to drm_dp_helper to achieve this. > >> > >> changes in v2: > >> - rebased on top of drm-tip > >> > >> Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > > > > v1 had an explicit comment before the ack: > > > > Yes, I remember the comment. I did not make any changes to v2 other than > just rebasing it on drm-tip to get the ack from i915 folks. > > >> From my side, with the promise of the size fixup. > > > > However I observe neither a second patch removing the size argument > > nor it being dropped as a part of this patch. > > > > Yes, now that in v2 we got the ack for this patch, I can spin a v3 with > the addition of the next patch to remove the size OR as another series > so as to not block the main series which needs this patch. > > I would prefer the latter. It doesn't work this way. The comment should have been fixed for v2.
On 2/20/2024 11:05 AM, Dmitry Baryshkov wrote: > On Tue, 20 Feb 2024 at 20:53, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: >> >> >> >> On 2/20/2024 10:49 AM, Dmitry Baryshkov wrote: >>> On Thu, 15 Feb 2024 at 21:08, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: >>>> >>>> intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. >>>> Lets move this to drm_dp_helper to achieve this. >>>> >>>> changes in v2: >>>> - rebased on top of drm-tip >>>> >>>> Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> >>> >>> v1 had an explicit comment before the ack: >>> >> >> Yes, I remember the comment. I did not make any changes to v2 other than >> just rebasing it on drm-tip to get the ack from i915 folks. >> >>>> From my side, with the promise of the size fixup. >>> >>> However I observe neither a second patch removing the size argument >>> nor it being dropped as a part of this patch. >>> >> >> Yes, now that in v2 we got the ack for this patch, I can spin a v3 with >> the addition of the next patch to remove the size OR as another series >> so as to not block the main series which needs this patch. >> >> I would prefer the latter. > > It doesn't work this way. The comment should have been fixed for v2. > Ack, I can post a v3 now by adding the removal in patch 2 of this series. > >
On Tue, 20 Feb 2024 at 21:09, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > > > > On 2/20/2024 11:05 AM, Dmitry Baryshkov wrote: > > On Tue, 20 Feb 2024 at 20:53, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > >> > >> > >> > >> On 2/20/2024 10:49 AM, Dmitry Baryshkov wrote: > >>> On Thu, 15 Feb 2024 at 21:08, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > >>>> > >>>> intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. > >>>> Lets move this to drm_dp_helper to achieve this. > >>>> > >>>> changes in v2: > >>>> - rebased on top of drm-tip > >>>> > >>>> Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > >>> > >>> v1 had an explicit comment before the ack: > >>> > >> > >> Yes, I remember the comment. I did not make any changes to v2 other than > >> just rebasing it on drm-tip to get the ack from i915 folks. > >> > >>>> From my side, with the promise of the size fixup. > >>> > >>> However I observe neither a second patch removing the size argument > >>> nor it being dropped as a part of this patch. > >>> > >> > >> Yes, now that in v2 we got the ack for this patch, I can spin a v3 with > >> the addition of the next patch to remove the size OR as another series > >> so as to not block the main series which needs this patch. > >> > >> I would prefer the latter. > > > > It doesn't work this way. The comment should have been fixed for v2. > > > > Ack, I can post a v3 now by adding the removal in patch 2 of this series. Yes, please.
On Tue, 20 Feb 2024 at 21:05, Dmitry Baryshkov <dmitry.baryshkov@linaro.org> wrote: > > On Tue, 20 Feb 2024 at 20:53, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > > > > > > > > On 2/20/2024 10:49 AM, Dmitry Baryshkov wrote: > > > On Thu, 15 Feb 2024 at 21:08, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > > >> > > >> intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. > > >> Lets move this to drm_dp_helper to achieve this. > > >> > > >> changes in v2: > > >> - rebased on top of drm-tip > > >> > > >> Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > > > > > > v1 had an explicit comment before the ack: > > > > > > > Yes, I remember the comment. I did not make any changes to v2 other than > > just rebasing it on drm-tip to get the ack from i915 folks. > > > > >> From my side, with the promise of the size fixup. > > > > > > However I observe neither a second patch removing the size argument > > > nor it being dropped as a part of this patch. > > > > > > > Yes, now that in v2 we got the ack for this patch, I can spin a v3 with > > the addition of the next patch to remove the size OR as another series > > so as to not block the main series which needs this patch. > > > > I would prefer the latter. > > It doesn't work this way. The comment should have been fixed for v2. This probably deserves some explanation. Currently there is only one user of this function. So it is easy to fix it. Once there are several users, you have to fix all of them at the same time, patching different drm subtrees. That complicates the life of maintainers.
On 2/20/2024 11:20 AM, Dmitry Baryshkov wrote: > On Tue, 20 Feb 2024 at 21:05, Dmitry Baryshkov > <dmitry.baryshkov@linaro.org> wrote: >> >> On Tue, 20 Feb 2024 at 20:53, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: >>> >>> >>> >>> On 2/20/2024 10:49 AM, Dmitry Baryshkov wrote: >>>> On Thu, 15 Feb 2024 at 21:08, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: >>>>> >>>>> intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. >>>>> Lets move this to drm_dp_helper to achieve this. >>>>> >>>>> changes in v2: >>>>> - rebased on top of drm-tip >>>>> >>>>> Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> >>>> >>>> v1 had an explicit comment before the ack: >>>> >>> >>> Yes, I remember the comment. I did not make any changes to v2 other than >>> just rebasing it on drm-tip to get the ack from i915 folks. >>> >>>>> From my side, with the promise of the size fixup. >>>> >>>> However I observe neither a second patch removing the size argument >>>> nor it being dropped as a part of this patch. >>>> >>> >>> Yes, now that in v2 we got the ack for this patch, I can spin a v3 with >>> the addition of the next patch to remove the size OR as another series >>> so as to not block the main series which needs this patch. >>> >>> I would prefer the latter. >> >> It doesn't work this way. The comment should have been fixed for v2. > > This probably deserves some explanation. Currently there is only one > user of this function. So it is easy to fix it. Once there are several > users, you have to fix all of them at the same time, patching > different drm subtrees. That complicates the life of maintainers. > Yes, understood. Its easier to fix it now if its really needed. Actually, I think the reason the size was passed was to make sure a valid struct dp_sdp *sdp was being passed. If we drop the size, we need to have a if (!sdp) check as there is a memset followed by dereference. So maybe, if we want to keep this API protected, its not too bad to have?
On Tue, Feb 20, 2024 at 11:27:18AM -0800, Abhinav Kumar wrote: > > > On 2/20/2024 11:20 AM, Dmitry Baryshkov wrote: > > On Tue, 20 Feb 2024 at 21:05, Dmitry Baryshkov > > <dmitry.baryshkov@linaro.org> wrote: > >> > >> On Tue, 20 Feb 2024 at 20:53, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > >>> > >>> > >>> > >>> On 2/20/2024 10:49 AM, Dmitry Baryshkov wrote: > >>>> On Thu, 15 Feb 2024 at 21:08, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: > >>>>> > >>>>> intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. > >>>>> Lets move this to drm_dp_helper to achieve this. > >>>>> > >>>>> changes in v2: > >>>>> - rebased on top of drm-tip > >>>>> > >>>>> Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > >>>> > >>>> v1 had an explicit comment before the ack: > >>>> > >>> > >>> Yes, I remember the comment. I did not make any changes to v2 other than > >>> just rebasing it on drm-tip to get the ack from i915 folks. > >>> > >>>>> From my side, with the promise of the size fixup. > >>>> > >>>> However I observe neither a second patch removing the size argument > >>>> nor it being dropped as a part of this patch. > >>>> > >>> > >>> Yes, now that in v2 we got the ack for this patch, I can spin a v3 with > >>> the addition of the next patch to remove the size OR as another series > >>> so as to not block the main series which needs this patch. > >>> > >>> I would prefer the latter. > >> > >> It doesn't work this way. The comment should have been fixed for v2. > > > > This probably deserves some explanation. Currently there is only one > > user of this function. So it is easy to fix it. Once there are several > > users, you have to fix all of them at the same time, patching > > different drm subtrees. That complicates the life of maintainers. > > > > Yes, understood. Its easier to fix it now if its really needed. > > Actually, I think the reason the size was passed was to make sure > a valid struct dp_sdp *sdp was being passed. The size is supposed to be the size of *hardware* buffer where this gets written into. But looks like this wasn't done correctly when the code was copy-pasted from the HDMI inforframe code.
On 2/20/2024 11:41 AM, Ville Syrjälä wrote: > On Tue, Feb 20, 2024 at 11:27:18AM -0800, Abhinav Kumar wrote: >> >> >> On 2/20/2024 11:20 AM, Dmitry Baryshkov wrote: >>> On Tue, 20 Feb 2024 at 21:05, Dmitry Baryshkov >>> <dmitry.baryshkov@linaro.org> wrote: >>>> >>>> On Tue, 20 Feb 2024 at 20:53, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: >>>>> >>>>> >>>>> >>>>> On 2/20/2024 10:49 AM, Dmitry Baryshkov wrote: >>>>>> On Thu, 15 Feb 2024 at 21:08, Abhinav Kumar <quic_abhinavk@quicinc.com> wrote: >>>>>>> >>>>>>> intel_dp_vsc_sdp_pack() can be re-used by other DRM drivers as well. >>>>>>> Lets move this to drm_dp_helper to achieve this. >>>>>>> >>>>>>> changes in v2: >>>>>>> - rebased on top of drm-tip >>>>>>> >>>>>>> Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> >>>>>> >>>>>> v1 had an explicit comment before the ack: >>>>>> >>>>> >>>>> Yes, I remember the comment. I did not make any changes to v2 other than >>>>> just rebasing it on drm-tip to get the ack from i915 folks. >>>>> >>>>>>> From my side, with the promise of the size fixup. >>>>>> >>>>>> However I observe neither a second patch removing the size argument >>>>>> nor it being dropped as a part of this patch. >>>>>> >>>>> >>>>> Yes, now that in v2 we got the ack for this patch, I can spin a v3 with >>>>> the addition of the next patch to remove the size OR as another series >>>>> so as to not block the main series which needs this patch. >>>>> >>>>> I would prefer the latter. >>>> >>>> It doesn't work this way. The comment should have been fixed for v2. >>> >>> This probably deserves some explanation. Currently there is only one >>> user of this function. So it is easy to fix it. Once there are several >>> users, you have to fix all of them at the same time, patching >>> different drm subtrees. That complicates the life of maintainers. >>> >> >> Yes, understood. Its easier to fix it now if its really needed. >> >> Actually, I think the reason the size was passed was to make sure >> a valid struct dp_sdp *sdp was being passed. > > The size is supposed to be the size of *hardware* buffer where this > gets written into. But looks like this wasn't done correctly when > the code was copy-pasted from the HDMI inforframe code. > Alright, in that case, let me post a patch to drop this and let me know if that works for you.
diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c index 8d6ce46471ae..6c91f400ecb1 100644 --- a/drivers/gpu/drm/display/drm_dp_helper.c +++ b/drivers/gpu/drm/display/drm_dp_helper.c @@ -2913,6 +2913,84 @@ void drm_dp_vsc_sdp_log(struct drm_printer *p, const struct drm_dp_vsc_sdp *vsc) } EXPORT_SYMBOL(drm_dp_vsc_sdp_log); +/** + * drm_dp_vsc_sdp_pack() - pack a given vsc sdp into generic dp_sdp + * @vsc: vsc sdp initialized according to its purpose as defined in + * table 2-118 - table 2-120 in DP 1.4a specification + * @sdp: valid handle to the generic dp_sdp which will be packed + * @size: valid size of the passed sdp handle + * + * Returns length of sdp on success and error code on failure + */ +ssize_t drm_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, + struct dp_sdp *sdp, size_t size) +{ + size_t length = sizeof(struct dp_sdp); + + if (size < length) + return -ENOSPC; + + memset(sdp, 0, size); + + /* + * Prepare VSC Header for SU as per DP 1.4a spec, Table 2-119 + * VSC SDP Header Bytes + */ + sdp->sdp_header.HB0 = 0; /* Secondary-Data Packet ID = 0 */ + sdp->sdp_header.HB1 = vsc->sdp_type; /* Secondary-data Packet Type */ + sdp->sdp_header.HB2 = vsc->revision; /* Revision Number */ + sdp->sdp_header.HB3 = vsc->length; /* Number of Valid Data Bytes */ + + if (vsc->revision == 0x6) { + sdp->db[0] = 1; + sdp->db[3] = 1; + } + + /* + * Revision 0x5 and revision 0x7 supports Pixel Encoding/Colorimetry + * Format as per DP 1.4a spec and DP 2.0 respectively. + */ + if (!(vsc->revision == 0x5 || vsc->revision == 0x7)) + goto out; + + /* VSC SDP Payload for DB16 through DB18 */ + /* Pixel Encoding and Colorimetry Formats */ + sdp->db[16] = (vsc->pixelformat & 0xf) << 4; /* DB16[7:4] */ + sdp->db[16] |= vsc->colorimetry & 0xf; /* DB16[3:0] */ + + switch (vsc->bpc) { + case 6: + /* 6bpc: 0x0 */ + break; + case 8: + sdp->db[17] = 0x1; /* DB17[3:0] */ + break; + case 10: + sdp->db[17] = 0x2; + break; + case 12: + sdp->db[17] = 0x3; + break; + case 16: + sdp->db[17] = 0x4; + break; + default: + WARN(1, "Missing case %d\n", vsc->bpc); + return -EINVAL; + } + + /* Dynamic Range and Component Bit Depth */ + if (vsc->dynamic_range == DP_DYNAMIC_RANGE_CTA) + sdp->db[17] |= 0x80; /* DB17[7] */ + + /* Content Type */ + sdp->db[18] = vsc->content_type & 0x7; + +out: + return length; +} +EXPORT_SYMBOL(drm_dp_vsc_sdp_pack); + /** * drm_dp_get_pcon_max_frl_bw() - maximum frl supported by PCON * @dpcd: DisplayPort configuration data diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 217196196e50..a9458df475e2 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -4089,73 +4089,6 @@ intel_dp_needs_vsc_sdp(const struct intel_crtc_state *crtc_state, return false; } -static ssize_t intel_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, - struct dp_sdp *sdp, size_t size) -{ - size_t length = sizeof(struct dp_sdp); - - if (size < length) - return -ENOSPC; - - memset(sdp, 0, size); - - /* - * Prepare VSC Header for SU as per DP 1.4a spec, Table 2-119 - * VSC SDP Header Bytes - */ - sdp->sdp_header.HB0 = 0; /* Secondary-Data Packet ID = 0 */ - sdp->sdp_header.HB1 = vsc->sdp_type; /* Secondary-data Packet Type */ - sdp->sdp_header.HB2 = vsc->revision; /* Revision Number */ - sdp->sdp_header.HB3 = vsc->length; /* Number of Valid Data Bytes */ - - if (vsc->revision == 0x6) { - sdp->db[0] = 1; - sdp->db[3] = 1; - } - - /* - * Revision 0x5 and revision 0x7 supports Pixel Encoding/Colorimetry - * Format as per DP 1.4a spec and DP 2.0 respectively. - */ - if (!(vsc->revision == 0x5 || vsc->revision == 0x7)) - goto out; - - /* VSC SDP Payload for DB16 through DB18 */ - /* Pixel Encoding and Colorimetry Formats */ - sdp->db[16] = (vsc->pixelformat & 0xf) << 4; /* DB16[7:4] */ - sdp->db[16] |= vsc->colorimetry & 0xf; /* DB16[3:0] */ - - switch (vsc->bpc) { - case 6: - /* 6bpc: 0x0 */ - break; - case 8: - sdp->db[17] = 0x1; /* DB17[3:0] */ - break; - case 10: - sdp->db[17] = 0x2; - break; - case 12: - sdp->db[17] = 0x3; - break; - case 16: - sdp->db[17] = 0x4; - break; - default: - MISSING_CASE(vsc->bpc); - break; - } - /* Dynamic Range and Component Bit Depth */ - if (vsc->dynamic_range == DP_DYNAMIC_RANGE_CTA) - sdp->db[17] |= 0x80; /* DB17[7] */ - - /* Content Type */ - sdp->db[18] = vsc->content_type & 0x7; - -out: - return length; -} - static ssize_t intel_dp_hdr_metadata_infoframe_sdp_pack(struct drm_i915_private *i915, const struct hdmi_drm_infoframe *drm_infoframe, @@ -4248,8 +4181,8 @@ static void intel_write_dp_sdp(struct intel_encoder *encoder, switch (type) { case DP_SDP_VSC: - len = intel_dp_vsc_sdp_pack(&crtc_state->infoframes.vsc, &sdp, - sizeof(sdp)); + len = drm_dp_vsc_sdp_pack(&crtc_state->infoframes.vsc, &sdp, + sizeof(sdp)); break; case HDMI_PACKET_TYPE_GAMUT_METADATA: len = intel_dp_hdr_metadata_infoframe_sdp_pack(dev_priv, diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h index d02014a87f12..8474504d4c88 100644 --- a/include/drm/display/drm_dp_helper.h +++ b/include/drm/display/drm_dp_helper.h @@ -812,4 +812,7 @@ int drm_dp_bw_overhead(int lane_count, int hactive, int bpp_x16, unsigned long flags); int drm_dp_bw_channel_coding_efficiency(bool is_uhbr); +ssize_t drm_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, + struct dp_sdp *sdp, size_t size); + #endif /* _DRM_DP_HELPER_H_ */