Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp719942rdh; Wed, 14 Feb 2024 09:18:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX/BWLNqgyKVKcNCizYSSCJTLeqOfVZvXAF2KTnEBDoOcdMZiZ8lTgONqcRtjcFQwS42gXV0/5zbg6Xe5vMgxA1G88kKx/yeG3h1DNmzQ== X-Google-Smtp-Source: AGHT+IEwLY64A1sciKIw1jPulI0iBmuCuJEX6wIk0QILM3Z0w2U7uALYrkaRQt4jpGkL/RoUWAK2 X-Received: by 2002:ac8:5a55:0:b0:42d:b1ba:fef4 with SMTP id o21-20020ac85a55000000b0042db1bafef4mr3268011qta.68.1707931082332; Wed, 14 Feb 2024 09:18:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707931082; cv=pass; d=google.com; s=arc-20160816; b=hfnAiOau5+PDvqOWN8gXB4lTt3l5gUAWLDcvIgW4cn4eBOateMI41mb8dcFTkP0dni /N5mUWnEm/JevULGhdbPIB2wy0Gsn0WdQqrAdWVj2kECRHGbgbbbM6h3xZqsL8w4WtCN Kg9ERpfF8egNqbGRBFqj4FbReKCJA9JEpro/H2imKw0u12oqCSsNDjSJdOiWapc4xzTG M7d4g01Z792ld8h1+LfQGX4RYJsYzgoYpICqcsHJzDOCsOSBSgAwmHrS/5mn12kn9SN+ FQKxT/diH2Tcy5auSV/zVhPCa0FC01xccbr+f+iKhko3HHXd/CwNLRyvy4eIRDU28bxL 5tUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=cpgWYEWq6DP+jNNJl+5t63QHfxeoJvHVCyCtujNb1Sw=; fh=VO7BjQcKIT9HhPMOnc36J9zVK0B+Rb84rXNjGZlD0CU=; b=EmJLwEY3vnTSdoTLBbUkmM5d5iE/XHh/pVcBKdWs+nhYwi4gTzrLepxtZVJkcp1Cli DTIZG9Vq89WDsB0pFgT73N5DWm6l/+fbGkaF0zbchFkHpTfWk5OM1Bt84H/TlwvZTbrc WyPYxSRS/NEfAPUIFoY4Z8VOIXPRkI2Ig4FXQFdtdXnOrZoFlssy/P1XCr0Vm3XXRkXa YhB7pyyf8kBYxHnBCFhVRN2tLE8C17/o77BprBsPRi5ReU7cKOmKP84IYUSoQAqhiT3Y OJOjCjDc5FP06UMXYBtxpRrsGbhAI/8/0xZxu+QWkaURJp7jqYckouqsEPzvAC9Ggr3H clPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IHSRuXpl; 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-65635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCWFmud7TGAAe9ZKgp24xaPF9f2G3WCexT1GxUVMAtjhltd7E9oVUSy9GbHZU8KlmSKmvSXnhSLjnQr9rLjGlLnEMtjfrcA1ZZGbcQX0Jw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q16-20020ac84510000000b0042c49437b5csi5350017qtn.39.2024.02.14.09.18.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 09:18:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IHSRuXpl; 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-65635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65635-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B24881C21198 for ; Wed, 14 Feb 2024 17:18:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66B0D7C6E3; Wed, 14 Feb 2024 17:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="IHSRuXpl" 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 84C7B6087F for ; Wed, 14 Feb 2024 17:17:53 +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=1707931075; cv=none; b=lRooA37WeDBK8VwALFAyiG+zt+sOV4QO6JByDU8BakmVymxO+BxMmOP1iK1JsvIpj6aWAl8XvHB+SZS5ZlDcaEwUjnwKrYM6NMWnsVicY38FkWsaVzs8uDLHKcFDrSh6w5tOPL3yoGE7/zkWcxek5wWb8ns+dn4pYjC0xqBafXs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707931075; c=relaxed/simple; bh=9Kt1tPZvc2PJE7DS8h6uq3G+B3Bo+jjJh3zwI+puTls=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=MlSYB3rhJVhOSDFWQeVrSnfEC6j1hCo4tT3uGapW7K3R5d75ebKewwD3Ppx7bia1PxMOF26LfWMFnS0pA/p/zk9T6xv0Q8oOmdFKQHx19NLQZysFpYc9oUtI/3G4cre+/ZJM02aY4TLItY+w5bToCdc6XF4ue06CJPyt8siunOQ= 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=IHSRuXpl; 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 (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41E90aaG004320; Wed, 14 Feb 2024 17:17:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=cpgWYEWq6DP+jNNJl+5t63QHfxeoJvHVCyCtujNb1Sw=; b=IH SRuXplkPZZ/86a1haB8VQIlP619AFNbdBNEKGQIyUB2F7OgKeM7g/gVePl/3liqM 3QtHlBFLSpK0t//gka85eU+T5ecJwCwAh01Hlh1uqDc4VhOk8zC50Vuphka12t90 wrMq9d0dksrqJtAAM53Y+tPGXqASEf9rmx8cPGm1ggfpIw7ngVja+RVnbFst/ShO YFqS5sszrrgx/JGnsfapc1RM+JIqZJUosVD5xC422qjXh5Q0mngi/H9iKEg+FeDd D58t3gg1bPdD3kk4MTDrOhD3GK2d9yXoI0qENggNlxxCD6ZscUdBuIVsAX6mstRi p0XWu6jVLOiI0meSbdFg== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w8enna89h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Feb 2024 17:17:37 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41EHHafN003490 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Feb 2024 17:17:36 GMT Received: from [10.71.109.81] (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; Wed, 14 Feb 2024 09:17:35 -0800 Message-ID: Date: Wed, 14 Feb 2024 09:17:34 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] drm/dp: move intel_dp_vsc_sdp_pack() to generic helper Content-Language: en-US To: Dmitry Baryshkov CC: , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , , , , , , , References: <20240213234513.2411604-1-quic_abhinavk@quicinc.com> From: Abhinav Kumar In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) 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: _-kD4V7i3gEHIiLo4KbsIDDpjrMh6YEY X-Proofpoint-ORIG-GUID: _-kD4V7i3gEHIiLo4KbsIDDpjrMh6YEY 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-14_10,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 phishscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402140135 On 2/14/2024 12:15 AM, Dmitry Baryshkov wrote: > On Wed, 14 Feb 2024 at 01:45, Abhinav Kumar 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. >> >> Signed-off-by: Abhinav Kumar > > My preference would be to have packing functions in > drivers/video/hdmi.c, as we already have > hdmi_audio_infoframe_pack_for_dp() there. > My preference is drm_dp_helper because it already has some VSC SDP stuff and after discussion with Ville on IRC, I decided to post it this way. hdmi_audio_infoframe_pack_for_dp() is an exception from my PoV as the hdmi audio infoframe fields were re-used and packed into a DP SDP thereby re-using the existing struct hdmi_audio_infoframe . This is not like that. Here we pack from struct drm_dp_vsc_sdp to struct dp_sdp both of which had prior usages already in this file. So it all adds up and makes sense to me to be in this file. I will let the other DRM core maintainers comment on this. Ville, Jani? >> --- >> drivers/gpu/drm/display/drm_dp_helper.c | 78 +++++++++++++++++++++++++ >> drivers/gpu/drm/i915/display/intel_dp.c | 73 +---------------------- >> include/drm/display/drm_dp_helper.h | 3 + >> 3 files changed, 84 insertions(+), 70 deletions(-) >> >> diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c >> index b1ca3a1100da..066cfbbf7a91 100644 >> --- a/drivers/gpu/drm/display/drm_dp_helper.c >> +++ b/drivers/gpu/drm/display/drm_dp_helper.c >> @@ -2916,6 +2916,84 @@ void drm_dp_vsc_sdp_log(const char *level, struct device *dev, >> } >> 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) > > I know that you are just moving the function. Maybe there can be > patch#2, which drops the size argument? The struct dp_sdp already has > a defined size. The i915 driver just passes sizeof(sdp), which is more > or less useless. > Yes this is a valid point, I also noticed this. I can post it on top of this once we get an agreement and ack on this patch first. >> +{ >> + 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 f5ef95da5534..e94db51aeeb7 100644 >> --- a/drivers/gpu/drm/i915/display/intel_dp.c >> +++ b/drivers/gpu/drm/i915/display/intel_dp.c >> @@ -4110,73 +4110,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, >> @@ -4269,8 +4202,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, >> @@ -4297,7 +4230,7 @@ void intel_write_dp_vsc_sdp(struct intel_encoder *encoder, >> struct dp_sdp sdp = {}; >> ssize_t len; >> >> - len = intel_dp_vsc_sdp_pack(vsc, &sdp, sizeof(sdp)); >> + len = drm_dp_vsc_sdp_pack(vsc, &sdp, sizeof(sdp)); >> >> if (drm_WARN_ON(&dev_priv->drm, len < 0)) >> return; >> diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h >> index 863b2e7add29..f8db34a2f7a5 100644 >> --- a/include/drm/display/drm_dp_helper.h >> +++ b/include/drm/display/drm_dp_helper.h >> @@ -813,4 +813,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 >> > >