Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2261659rdb; Fri, 8 Dec 2023 03:13:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGOyP4r2ZPO0PS9+lpj7eXNjA0S3/+Mkbv4GnN0nUAC36DL4MXNktEPtaQSub0s6fEL2rB X-Received: by 2002:a17:90b:4003:b0:286:cac7:3b45 with SMTP id ie3-20020a17090b400300b00286cac73b45mr3498093pjb.60.1702033982232; Fri, 08 Dec 2023 03:13:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702033982; cv=none; d=google.com; s=arc-20160816; b=So+yNPJv/gjiCVxTn0bJT2lslOftVzqvnGM3+AAaYaCf2XwJZuFS/Hq8gBG4CrlGwW iSaGCKGSyabwJ7XNqEEVWYrLx8Dr3DE8hDXvoDCOpCoOWsu2yRLcziATP1XwCrhbtd/h 4Sm9yo4LMgEKqxaLORxr6WT4MEujUc3mx7opvOXD7xSO8RO8sp3dtBrQTyRRPt6pjfyL ehPJfv7P3ltkv5LrQ8p3AJNO/kn/rjm9bjYETLvbn/gMI42+gssz41TPcKrm1Jy7vX3x XZaShnAKLNSmfC5QcldjTz1L4ewRfsR4IpZNZEahVOrT/uv4F2A+c0uGWNBYhwDTJLRy cb9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=i+qYeo0Zg18ZkL8tHwRVHyVmW1yjuK0YJmkuP1+ez/c=; fh=u+8seKyB07yIfN5FApT/HxHz0QUzYKPNWnQOq0f6iUM=; b=YMcvW82CJdie8AJjFiPY8hoXog+hQJcDhUhSel2i7e1t2pMJwCNV6KQWfwCsl2sjp6 WcfU4Ou0olImMogzcmm0ELV5WYnLjiAzS8VZX3Igx3l8s5r3TShyBOjKsjN8hDVS7hlu 8Tiq5E5iXHsvxZ9JPYDWkp0jfJT3OeWAIzer0AjgnPxgChv5yk+OURLZuZ9QgfYP9R8y y3P0yLaMnrs3thmgUd9x2jrcfJ2dQlxt5KfHahZ41a/FhnWnr9cokQWBG1CTVqxPSCak O81hBc/tt+u1upmJfT+1Zv1zh0gRTODSsTxdkBX/2rG5EiR8BFeusZIE/NHqVMz+pOOf DEiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C5rvc4BH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id c23-20020a17090abf1700b00286b5ae24e3si2768045pjs.114.2023.12.08.03.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 03:13:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C5rvc4BH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 100E78280802; Fri, 8 Dec 2023 03:12:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232736AbjLHLMn (ORCPT + 99 others); Fri, 8 Dec 2023 06:12:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231656AbjLHLMk (ORCPT ); Fri, 8 Dec 2023 06:12:40 -0500 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8B08122 for ; Fri, 8 Dec 2023 03:12:46 -0800 (PST) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5d3758fdd2eso19083177b3.0 for ; Fri, 08 Dec 2023 03:12:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702033966; x=1702638766; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=i+qYeo0Zg18ZkL8tHwRVHyVmW1yjuK0YJmkuP1+ez/c=; b=C5rvc4BHWJSL3SGT5MyCEG2o4bJBjR2+WtmB8juRIbjiUjeqGYmPZ9+o69F8PMdhTh HSjxrVNxmsQChxkm4by//VFotLsiZWKdK/FuRTH/55NiBQnWBnyBo1KYufaIYgmmzdkI qbAzI3PBZTdiJXTxO3G8fNjpaNfQCP0PECx2lDLHJj7s+CIxSpRcv+GM/SGRjXpe0hc1 ZPfcDL99uVl2EwMn8+IL0YiiHdYakbqEWHRgRbb0cYv4elDB4K9VChPf3Yld2RZRMR0F ahKPC/CJFRDOWdFeK2GlLaRHGKb0t5yf5EqkGxPFwQBeqoxcO9stwFWkGQmIQ5EAgrwD QsgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702033966; x=1702638766; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=i+qYeo0Zg18ZkL8tHwRVHyVmW1yjuK0YJmkuP1+ez/c=; b=lZYVPsXyq3ujUFl5b68DnQX+ydEGM8IHiQ2U7DoGBhFJxCdCZ45YRbn1OIXM5Ufxh8 +Eixw4eAlPs5GvMczdH0RGaH6eqANRFOWv5RjECwjHw6lCIoBQsuPizFEC/icaHtqS4e 2I0Av89fE1kZtMkXgEyLqiSl1LEHTOgMfdm1hcS8pTAU84TfW2ZhiKzBzAaqiSSfoliC eNheNVHojfZs8CbItnO05pfep8Z3YiYqdB98GwtrlNaU0ko8xCH7AVBh8ZzJbdXblxcc Xml6PeeZFnR0jDX0fChZs1UQCB8Jw7bjhNfh5/xQMHduixUTyhmLD2s1r63YRRT5xyn0 gZFA== X-Gm-Message-State: AOJu0YyFEgxhnu1TVcBqWWk3TT3wZrVyQdZjy5wzPj+Y2ghdNFalYapl FJO7NJOEvp++8hXJt9ZBQO1S46wE+BPbvNJ9pJX2tQ== X-Received: by 2002:a81:ad57:0:b0:5d7:1941:3558 with SMTP id l23-20020a81ad57000000b005d719413558mr3882129ywk.63.1702033966103; Fri, 08 Dec 2023 03:12:46 -0800 (PST) MIME-Version: 1.0 References: <20231208050641.32582-1-quic_abhinavk@quicinc.com> <20231208050641.32582-5-quic_abhinavk@quicinc.com> In-Reply-To: <20231208050641.32582-5-quic_abhinavk@quicinc.com> From: Dmitry Baryshkov Date: Fri, 8 Dec 2023 13:12:35 +0200 Message-ID: Subject: Re: [PATCH v2 04/16] drm/msm/dpu: move csc matrices to dpu_hw_util To: Abhinav Kumar Cc: freedreno@lists.freedesktop.org, Rob Clark , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, quic_jesszhan@quicinc.com, quic_parellan@quicinc.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 howler.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 (howler.vger.email [0.0.0.0]); Fri, 08 Dec 2023 03:12:59 -0800 (PST) On Fri, 8 Dec 2023 at 07:07, Abhinav Kumar wrote: > > Since the type and usage of CSC matrices is spanning across DPU > lets introduce a helper to the dpu_hw_util to return the CSC > corresponding to the request type. This will help to add more > supported CSC types such as the RGB to YUV one which is used in > the case of CDM. > > Signed-off-by: Abhinav Kumar > --- > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.c | 54 +++++++++++++++++++++ > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.h | 7 +++ > drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 39 ++------------- > 3 files changed, 64 insertions(+), 36 deletions(-) > > 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 0b05061e3e62..59a153331194 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,60 @@ 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) > > +static const struct dpu_csc_cfg dpu_csc_YUV2RGB_601L = { > + { > + /* S15.16 format */ > + 0x00012A00, 0x00000000, 0x00019880, > + 0x00012A00, 0xFFFF9B80, 0xFFFF3000, > + 0x00012A00, 0x00020480, 0x00000000, > + }, > + /* signed bias */ > + { 0xfff0, 0xff80, 0xff80,}, > + { 0x0, 0x0, 0x0,}, > + /* unsigned clamp */ > + { 0x10, 0xeb, 0x10, 0xf0, 0x10, 0xf0,}, > + { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,}, > +}; > + > +static const struct dpu_csc_cfg dpu_csc10_YUV2RGB_601L = { > + { > + /* S15.16 format */ > + 0x00012A00, 0x00000000, 0x00019880, > + 0x00012A00, 0xFFFF9B80, 0xFFFF3000, > + 0x00012A00, 0x00020480, 0x00000000, > + }, > + /* signed bias */ > + { 0xffc0, 0xfe00, 0xfe00,}, > + { 0x0, 0x0, 0x0,}, > + /* unsigned clamp */ > + { 0x40, 0x3ac, 0x40, 0x3c0, 0x40, 0x3c0,}, > + { 0x00, 0x3ff, 0x00, 0x3ff, 0x00, 0x3ff,}, > +}; > + > +/** > + * dpu_hw_get_csc_cfg - get the CSC matrix based on the request type > + * @type: type of the requested CSC matrix from caller > + * Return: CSC matrix corresponding to the request type in DPU format > + */ > +const struct dpu_csc_cfg *dpu_hw_get_csc_cfg(enum dpu_hw_csc_cfg_type type) > +{ > + const struct dpu_csc_cfg *csc_cfg = NULL; > + > + switch (type) { > + case DPU_HW_YUV2RGB_601L: > + csc_cfg = &dpu_csc_YUV2RGB_601L; > + break; > + case DPU_HW_YUV2RGB_601L_10BIT: > + csc_cfg = &dpu_csc10_YUV2RGB_601L; > + break; > + default: > + DPU_ERROR("unknown csc_cfg type\n"); > + break; > + } > + > + return csc_cfg; > +} > + > void dpu_reg_write(struct dpu_hw_blk_reg_map *c, > u32 reg_off, > u32 val, > 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 fe083b2e5696..49f2bcf6de15 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.h > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_util.h > @@ -19,6 +19,11 @@ > #define MISR_CTRL_STATUS_CLEAR BIT(10) > #define MISR_CTRL_FREE_RUN_MASK BIT(31) > > +enum dpu_hw_csc_cfg_type { > + DPU_HW_YUV2RGB_601L, > + DPU_HW_YUV2RGB_601L_10BIT, > +}; > + > /* > * This is the common struct maintained by each sub block > * for mapping the register offsets in this block to the > @@ -368,4 +373,6 @@ bool dpu_hw_clk_force_ctrl(struct dpu_hw_blk_reg_map *c, > const struct dpu_clk_ctrl_reg *clk_ctrl_reg, > bool enable); > > +const struct dpu_csc_cfg *dpu_hw_get_csc_cfg(enum dpu_hw_csc_cfg_type type); I don't think we need extra enum and wrapper. Just export const data structures directly. > + > #endif /* _DPU_HW_UTIL_H */ > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c > index 3235ab132540..31641889b9f0 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c > @@ -21,6 +21,7 @@ > #include "dpu_kms.h" > #include "dpu_formats.h" > #include "dpu_hw_sspp.h" > +#include "dpu_hw_util.h" > #include "dpu_trace.h" > #include "dpu_crtc.h" > #include "dpu_vbif.h" > @@ -508,50 +509,16 @@ static void _dpu_plane_setup_pixel_ext(struct dpu_hw_scaler3_cfg *scale_cfg, > } > } > > -static const struct dpu_csc_cfg dpu_csc_YUV2RGB_601L = { > - { > - /* S15.16 format */ > - 0x00012A00, 0x00000000, 0x00019880, > - 0x00012A00, 0xFFFF9B80, 0xFFFF3000, > - 0x00012A00, 0x00020480, 0x00000000, > - }, > - /* signed bias */ > - { 0xfff0, 0xff80, 0xff80,}, > - { 0x0, 0x0, 0x0,}, > - /* unsigned clamp */ > - { 0x10, 0xeb, 0x10, 0xf0, 0x10, 0xf0,}, > - { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,}, > -}; > - > -static const struct dpu_csc_cfg dpu_csc10_YUV2RGB_601L = { > - { > - /* S15.16 format */ > - 0x00012A00, 0x00000000, 0x00019880, > - 0x00012A00, 0xFFFF9B80, 0xFFFF3000, > - 0x00012A00, 0x00020480, 0x00000000, > - }, > - /* signed bias */ > - { 0xffc0, 0xfe00, 0xfe00,}, > - { 0x0, 0x0, 0x0,}, > - /* unsigned clamp */ > - { 0x40, 0x3ac, 0x40, 0x3c0, 0x40, 0x3c0,}, > - { 0x00, 0x3ff, 0x00, 0x3ff, 0x00, 0x3ff,}, > -}; > - > static const struct dpu_csc_cfg *_dpu_plane_get_csc(struct dpu_sw_pipe *pipe, > const struct dpu_format *fmt) > { > - const struct dpu_csc_cfg *csc_ptr; > - > if (!DPU_FORMAT_IS_YUV(fmt)) > return NULL; > > if (BIT(DPU_SSPP_CSC_10BIT) & pipe->sspp->cap->features) > - csc_ptr = &dpu_csc10_YUV2RGB_601L; > + return dpu_hw_get_csc_cfg(DPU_HW_YUV2RGB_601L_10BIT); > else > - csc_ptr = &dpu_csc_YUV2RGB_601L; > - > - return csc_ptr; > + return dpu_hw_get_csc_cfg(DPU_HW_YUV2RGB_601L); > } > > static void _dpu_plane_setup_scaler(struct dpu_sw_pipe *pipe, > -- > 2.40.1 > -- With best wishes Dmitry