Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2488000rdb; Fri, 8 Dec 2023 09:28:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPeG7HDQjf22E3fMUwpzHaDqeV/2Y9OwVHVPWQFQbNL+dl40maY6GKx3+vyi3JPU61t5iQ X-Received: by 2002:a05:6359:7285:b0:170:5d43:3889 with SMTP id uw5-20020a056359728500b001705d433889mr183012rwb.43.1702056516740; Fri, 08 Dec 2023 09:28:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702056516; cv=none; d=google.com; s=arc-20160816; b=ntp8yi2osYnqSb0ys35T4V/abX+/G7tfuww6CMfAFyq9Tb5X/viU+gYrogKUXUvrhj UCKtq5id/TUv4Pr7ZlpRWA7M0EQL3umMsCuhhsMjSiNb4XZ3h+vS70ICCu0whxqY+id9 8Fw2L1EKSEgO7Okbtwn4mfRqZhXCJpy+5ICXkjDMQl2LnxcwBjCJCzXBcQ6ceWZjc9y6 8qCAnyedwOCqVDzcCQVcDU+yhAqVLD8f8LCih6lxjpLPn/i8HN2+CP8FFyacVKVUxXFI 09issxqwbLWsSg8BWLWu0ex+78aYzM1gXbgSGs1Wh1LWXJ9zrovN1tP30C7AyU4qqlLN JmuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=CKCRmnaIpTnBPjwf8fSJ3R7eZ64nbAD4RxhqReCI9Lo=; fh=1F4O3yHu21T8QLdQ5GUr4CAXJeBqSHcVm6pPyoYFBOY=; b=nvUY5e74OA8jM9az9KrkMadstItOIdLMRISPj7yXPZsbSWafONwg4wev4BGDiZzEjX ZDUNZU8vb43mK/n+zcZBo0kvg+9bntraCWUoI72u5tAGdDxUg6eg/OtilAdGPG3+euVg APRJnzqL0yxeuQfSBG3N44Y+PSqyJRl4esaNHneo6gupbWjfSDk24qhACKatLz4+1gBD vbJ9FUvtvuRBpnB65lQ7rlLdtnYpdDw7nZJTti3p1Cdurs83cBvt/Z/ZiTTvaEv3xaFz MRPuo3pu+w3ULfwUIieArIr3VHRReLsD3l3SE2SUNeok/ZAB8MQhhKMor5yLBSuuShp1 7STA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=iFHL5jQ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id z4-20020a656644000000b005c67e10f238si1866317pgv.492.2023.12.08.09.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 09:28:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=iFHL5jQ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0592882DDF9D; Fri, 8 Dec 2023 09:28:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233481AbjLHR2K (ORCPT + 99 others); Fri, 8 Dec 2023 12:28:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233790AbjLHR2G (ORCPT ); Fri, 8 Dec 2023 12:28:06 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7637CE0; Fri, 8 Dec 2023 09:28:12 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B8FGnSQ021111; Fri, 8 Dec 2023 17:28:04 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=CKCRmnaIpTnBPjwf8fSJ3R7eZ64nbAD4RxhqReCI9Lo=; b=iFHL5jQ03uqASHmnodGL3UndQnSuOMMANy8O/R9JKQxGC7cR8jV0fuvhOgYngNc1J4zR c0Rj8wVMVyzJ5BHfr//rz6V7B+X1AS+10wpo0VoKmC4TLmiqPr3PzuwdSN1TqSvMAlx/ HTQ4VW/vcyssZ61hAW5qG/xipr8viUB6BF6o2AvtVWr3MVYOr7Dqxj5oU6xZAuDt5Xy7 IT5Q3jh+coiyvdIdDHBUoEt1+s7Vd7fvu3c1mlnwbALy7kQ/ZjkQxuUaZxC77tVgsHF2 QdoUupsfwjY/UPGyROyByo5VzvFgBg04wksE5dZMAx8cEncvPEwY4rMgNmaIJNkp5RFg lQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uuuu4shqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Dec 2023 17:28:04 +0000 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 3B8HS3R2007825 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 8 Dec 2023 17:28:03 GMT Received: from [10.110.30.94] (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; Fri, 8 Dec 2023 09:28:01 -0800 Message-ID: <55564921-5e52-d254-1909-d2ebdc6cea1b@quicinc.com> Date: Fri, 8 Dec 2023 09:27:59 -0800 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 v2 12/16] drm/msm/dpu: add an API to setup the CDM block for writeback Content-Language: en-US To: Dmitry Baryshkov CC: , Rob Clark , "Sean Paul" , Marijn Suijten , "David Airlie" , Daniel Vetter , , , , , References: <20231208050641.32582-1-quic_abhinavk@quicinc.com> <20231208050641.32582-13-quic_abhinavk@quicinc.com> From: Abhinav Kumar In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] 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: 97gP-Z4WbbxpdNBcEsdqSpwCUNj4056u X-Proofpoint-ORIG-GUID: 97gP-Z4WbbxpdNBcEsdqSpwCUNj4056u X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-08_11,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 bulkscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312080144 X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 08 Dec 2023 09:28:33 -0800 (PST) On 12/8/2023 3:52 AM, Dmitry Baryshkov wrote: > On Fri, 8 Dec 2023 at 07:07, Abhinav Kumar wrote: >> >> Add an API dpu_encoder_helper_phys_setup_cdm() which can be used by >> the writeback encoder to setup the CDM block. >> >> Currently, this is defined and used within the writeback's physical >> encoder layer however, the function can be modified to be used to setup >> the CDM block even for non-writeback interfaces. >> >> Until those modifications are planned and made, keep it local to >> writeback. >> >> changes in v2: >> - add the RGB2YUV CSC matrix to dpu util as needed by CDM >> - use dpu_hw_get_csc_cfg() to get and program CSC >> - drop usage of setup_csc_data() and setup_cdwn() cdm ops >> as they both have been merged into enable() >> - drop reduntant hw_cdm and hw_pp checks >> >> Signed-off-by: Abhinav Kumar >> --- >> .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 3 + >> .../drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 96 ++++++++++++++++++- >> drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.c | 17 ++++ >> drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.h | 1 + >> 4 files changed, 116 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h >> index 410f6225789c..1d6d1eb642b9 100644 >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h >> @@ -16,6 +16,7 @@ >> #include "dpu_hw_pingpong.h" >> #include "dpu_hw_ctl.h" >> #include "dpu_hw_top.h" >> +#include "dpu_hw_cdm.h" >> #include "dpu_encoder.h" >> #include "dpu_crtc.h" >> >> @@ -210,6 +211,7 @@ static inline int dpu_encoder_phys_inc_pending(struct dpu_encoder_phys *phys) >> * @wbirq_refcount: Reference count of writeback interrupt >> * @wb_done_timeout_cnt: number of wb done irq timeout errors >> * @wb_cfg: writeback block config to store fb related details >> + * @cdm_cfg: cdm block config needed to store writeback block's CDM configuration >> * @wb_conn: backpointer to writeback connector >> * @wb_job: backpointer to current writeback job >> * @dest: dpu buffer layout for current writeback output buffer >> @@ -219,6 +221,7 @@ struct dpu_encoder_phys_wb { >> atomic_t wbirq_refcount; >> int wb_done_timeout_cnt; >> struct dpu_hw_wb_cfg wb_cfg; >> + struct dpu_hw_cdm_cfg cdm_cfg; >> struct drm_writeback_connector *wb_conn; >> struct drm_writeback_job *wb_job; >> struct dpu_hw_fmt_layout dest; >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c >> index 4665367cf14f..85429c62d727 100644 >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c >> @@ -259,6 +259,99 @@ static void dpu_encoder_phys_wb_setup_ctl(struct dpu_encoder_phys *phys_enc) >> } >> } >> >> +/** >> + * dpu_encoder_phys_wb_setup_cdp - setup chroma down sampling block >> + * @phys_enc:Pointer to physical encoder >> + */ >> +static void dpu_encoder_helper_phys_setup_cdm(struct dpu_encoder_phys *phys_enc) >> +{ >> + struct dpu_hw_cdm *hw_cdm; >> + struct dpu_hw_cdm_cfg *cdm_cfg; >> + struct dpu_hw_pingpong *hw_pp; >> + struct dpu_encoder_phys_wb *wb_enc; >> + const struct msm_format *format; >> + const struct dpu_format *dpu_fmt; >> + struct drm_writeback_job *wb_job; >> + int ret; >> + >> + if (!phys_enc) >> + return; >> + >> + wb_enc = to_dpu_encoder_phys_wb(phys_enc); >> + cdm_cfg = &wb_enc->cdm_cfg; >> + hw_pp = phys_enc->hw_pp; >> + hw_cdm = phys_enc->hw_cdm; >> + wb_job = wb_enc->wb_job; >> + >> + format = msm_framebuffer_format(wb_enc->wb_job->fb); >> + dpu_fmt = dpu_get_dpu_format_ext(format->pixel_format, wb_job->fb->modifier); >> + >> + if (!hw_cdm) >> + return; >> + >> + if (!DPU_FORMAT_IS_YUV(dpu_fmt)) { >> + DPU_DEBUG("[enc:%d] cdm_disable fmt:%x\n", DRMID(phys_enc->parent), >> + dpu_fmt->base.pixel_format); >> + if (hw_cdm->ops.disable) >> + hw_cdm->ops.disable(hw_cdm); >> + >> + return; >> + } >> + >> + memset(cdm_cfg, 0, sizeof(struct dpu_hw_cdm_cfg)); >> + >> + cdm_cfg->output_width = wb_job->fb->width; >> + cdm_cfg->output_height = wb_job->fb->height; >> + cdm_cfg->output_fmt = dpu_fmt; >> + cdm_cfg->output_type = CDM_CDWN_OUTPUT_WB; >> + cdm_cfg->output_bit_depth = DPU_FORMAT_IS_DX(dpu_fmt) ? >> + CDM_CDWN_OUTPUT_10BIT : CDM_CDWN_OUTPUT_8BIT; >> + cdm_cfg->csc_cfg = dpu_hw_get_csc_cfg(DPU_HW_RGB2YUV_601L_10BIT); >> + if (!cdm_cfg->csc_cfg) { >> + DPU_ERROR("valid csc not found\n"); >> + return; >> + } >> + >> + /* enable 10 bit logic */ >> + switch (cdm_cfg->output_fmt->chroma_sample) { >> + case DPU_CHROMA_RGB: >> + cdm_cfg->h_cdwn_type = CDM_CDWN_DISABLE; >> + cdm_cfg->v_cdwn_type = CDM_CDWN_DISABLE; >> + break; >> + case DPU_CHROMA_H2V1: >> + cdm_cfg->h_cdwn_type = CDM_CDWN_COSITE; >> + cdm_cfg->v_cdwn_type = CDM_CDWN_DISABLE; >> + break; >> + case DPU_CHROMA_420: >> + cdm_cfg->h_cdwn_type = CDM_CDWN_COSITE; >> + cdm_cfg->v_cdwn_type = CDM_CDWN_OFFSITE; >> + break; >> + case DPU_CHROMA_H1V2: >> + default: >> + DPU_ERROR("[enc:%d] unsupported chroma sampling type\n", >> + DRMID(phys_enc->parent)); >> + cdm_cfg->h_cdwn_type = CDM_CDWN_DISABLE; >> + cdm_cfg->v_cdwn_type = CDM_CDWN_DISABLE; > > If it is unsupported, we should return an error here. > The caller of this API and the caller of the API even before that do not have error checking as they are all void. Disabling CDWN is the appropriate corrective action for this case and should be sufficient. >> + break; >> + } >> + >> + DPU_DEBUG("[enc:%d] cdm_enable:%d,%d,%X,%d,%d,%d,%d]\n", >> + DRMID(phys_enc->parent), cdm_cfg->output_width, >> + cdm_cfg->output_height, cdm_cfg->output_fmt->base.pixel_format, >> + cdm_cfg->output_type, cdm_cfg->output_bit_depth, >> + cdm_cfg->h_cdwn_type, cdm_cfg->v_cdwn_type); >> + >> + if (hw_cdm->ops.enable) { >> + cdm_cfg->pp_id = hw_pp->idx; >> + ret = hw_cdm->ops.enable(hw_cdm, cdm_cfg); >> + if (ret < 0) { >> + DPU_ERROR("[enc:%d] failed to enable CDM; ret:%d\n", >> + DRMID(phys_enc->parent), ret); >> + return; >> + } >> + } >> +} >> + >> /** >> * dpu_encoder_phys_wb_atomic_check - verify and fixup given atomic states >> * @phys_enc: Pointer to physical encoder >> @@ -382,8 +475,9 @@ static void dpu_encoder_phys_wb_setup( >> >> dpu_encoder_phys_wb_setup_fb(phys_enc, fb); >> >> - dpu_encoder_phys_wb_setup_ctl(phys_enc); >> + dpu_encoder_helper_phys_setup_cdm(phys_enc); >> >> + dpu_encoder_phys_wb_setup_ctl(phys_enc); >> } >> >> /** >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.c >> index 59a153331194..34143491aba2 100644 >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.c >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.c >> @@ -87,6 +87,8 @@ static u32 dpu_hw_util_log_mask = DPU_DBG_MASK_NONE; >> #define QOS_QOS_CTRL_VBLANK_EN BIT(16) >> #define QOS_QOS_CTRL_CREQ_VBLANK_MASK GENMASK(21, 20) >> >> +#define TO_S15D16(_x_)((_x_) << 7) > > Huh? I don't understand why it is shifted by 7. If you have data in > S8.9 format, I'd say that it makes things less obvious compared to > S15.16 (where you can perform division on the fly). > I was referring to below comment and also because the values are in S15.16 in https://git.codelinaro.org/clo/la/platform/vendor/opensource/display-drivers/-/blob/clo/main/msm/sde/sde_encoder_phys_wb.c?ref_type=heads#L35 428 struct dpu_csc_cfg { 429 /* matrix coefficients in S15.16 format */ 430 uint32_t csc_mv[DPU_CSC_MATRIX_COEFF_SIZE]; 431 uint32_t csc_pre_bv[DPU_CSC_BIAS_SIZE]; 432 uint32_t csc_post_bv[DPU_CSC_BIAS_SIZE]; 433 uint32_t csc_pre_lv[DPU_CSC_CLAMP_SIZE]; 434 uint32_t csc_post_lv[DPU_CSC_CLAMP_SIZE]; 435 }; 436 >> + >> static const struct dpu_csc_cfg dpu_csc_YUV2RGB_601L = { >> { >> /* S15.16 format */ >> @@ -117,6 +119,18 @@ static const struct dpu_csc_cfg dpu_csc10_YUV2RGB_601L = { >> { 0x00, 0x3ff, 0x00, 0x3ff, 0x00, 0x3ff,}, >> }; >> >> +static const struct dpu_csc_cfg dpu_csc10_rgb2yuv_601l = { >> + { >> + TO_S15D16(0x0083), TO_S15D16(0x0102), TO_S15D16(0x0032), >> + TO_S15D16(0x1fb5), TO_S15D16(0x1f6c), TO_S15D16(0x00e1), >> + TO_S15D16(0x00e1), TO_S15D16(0x1f45), TO_S15D16(0x1fdc) >> + }, >> + { 0x00, 0x00, 0x00 }, >> + { 0x0040, 0x0200, 0x0200 }, >> + { 0x000, 0x3ff, 0x000, 0x3ff, 0x000, 0x3ff }, >> + { 0x040, 0x3ac, 0x040, 0x3c0, 0x040, 0x3c0 }, >> +}; >> + >> /** >> * dpu_hw_get_csc_cfg - get the CSC matrix based on the request type >> * @type: type of the requested CSC matrix from caller >> @@ -133,6 +147,9 @@ const struct dpu_csc_cfg *dpu_hw_get_csc_cfg(enum dpu_hw_csc_cfg_type type) >> case DPU_HW_YUV2RGB_601L_10BIT: >> csc_cfg = &dpu_csc10_YUV2RGB_601L; >> break; >> + case DPU_HW_RGB2YUV_601L_10BIT: >> + csc_cfg = &dpu_csc10_rgb2yuv_601l; >> + break; >> default: >> DPU_ERROR("unknown csc_cfg type\n"); >> break; >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.h >> index 49f2bcf6de15..ed153d66f660 100644 >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.h >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.h >> @@ -22,6 +22,7 @@ >> enum dpu_hw_csc_cfg_type { >> DPU_HW_YUV2RGB_601L, >> DPU_HW_YUV2RGB_601L_10BIT, >> + DPU_HW_RGB2YUV_601L_10BIT, >> }; >> >> /* >> -- >> 2.40.1 >> > >