Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp789883rwb; Wed, 16 Nov 2022 07:42:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ta7fjAlHO/dxCDxD4VvEoKvlSlHhfzOWi3XVLjl7KtcyuCzuk858rkMGg6ZvQ66Tro2kR X-Received: by 2002:a17:903:2614:b0:174:7d26:812f with SMTP id jd20-20020a170903261400b001747d26812fmr9627254plb.63.1668613342501; Wed, 16 Nov 2022 07:42:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668613342; cv=none; d=google.com; s=arc-20160816; b=a3ckA8asaDNPOVjuwdhMfEDaRTqZQiuc9L6iDbiItd+zoEgh5sn4SIZbXNqlpgaCVd vju1CxTM0UPiWlA4/YyK5D2PVZmTLTJ3WlPPD/ppRF88gve6tSfXu2VK10211SHeFn9k 1pgG91xysFhgsXmld4PX5LmCEQfhzTOgItpJQjTw11bTc+V7MUQIUy3ZnilJVDbcwnBg ozcF4YfP/HgDy/SSA1W1PkVg8B3ct1jHj9THfPPNeUPvGAK11QJfDzAEWem6TsQtcebs bR3iK9E4g21eO9kgiQJBKD+4TYzhe4yNPuGTc2UXGwkJWa/oy9lWCsJlu3UwjxHAgg8q zvwg== 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=2goIufjGjVQGV/zZ8VbRSUhaqmRAY4KQcN6kgtfw8sc=; b=VfZiDs0YfQYXFZz2Gc5MfmnXOBK6d+yUT2Bpc+YzeZc/T+LmLGOGwJKv/aqWPCKJon JnKtgNHHp9t62bJLkSHA76E+YA0Z0JmVp0VaRCtoji270wTbjxhhLshpzWe0DbUDxyYp HdyvpsGwnMuZVmOVezxzrX3SdZkzOjGnC/xxK7C/KMTya7qZQYvWYljoKZ4tP333Y0L1 q998ZsDhGMYi0BQ45OlNark5EOWMnV9WfxrYNrauurGGztZwgkd4S+1bC5Rp2ds2Jk5z k6be84N/RTkprLHVKZar/VLVHSiETBFzWLEDC/Z9IZsCg7oXvseYMxNXMDt6PqvJqAxc fenA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VYiMG+8i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n16-20020aa78a50000000b005676e2c36b4si12800342pfa.47.2022.11.16.07.42.11; Wed, 16 Nov 2022 07:42:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VYiMG+8i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232760AbiKPPHJ (ORCPT + 91 others); Wed, 16 Nov 2022 10:07:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232590AbiKPPG4 (ORCPT ); Wed, 16 Nov 2022 10:06:56 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F7D2CC80 for ; Wed, 16 Nov 2022 07:06:54 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id be13so29995885lfb.4 for ; Wed, 16 Nov 2022 07:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=2goIufjGjVQGV/zZ8VbRSUhaqmRAY4KQcN6kgtfw8sc=; b=VYiMG+8i+a7fdcSjRZPBbNKOYSlXS0vixWdNV6+kXcx76lkfIBS9sVMmQu54SwyM6Y xgnbwKRsjixQyKVPQkm88j1lLVie15ZFP28YI/PtDJ5HSu5rCkY24+QpPppw2xOgpEva 5fjmn60euI0fFVzh2Cs6NlfZjVxn6tfjIr42gFGs1W1FtDX5z8krjAs/q70zM0YG3PlP YdThoM1TFGVGCcbf0kBs+TKZUj8xprGN4CvymrZwumccDeKFKkjKm/2SUAo8M7QcnkT9 N4eu8YR8UGXRGWPhE2O3qchLnxg0qB5Ou3fcP/ZiizVMitC3PvBUDrX/6J24LBGHkhjh bmGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2goIufjGjVQGV/zZ8VbRSUhaqmRAY4KQcN6kgtfw8sc=; b=pIeEfyo6B095q1+Ookq06ue3wK79LwILz/KdN2Et8bi751iMZvPMCSJ1l4ZrioATqD 7JYuZpsD7EqPBXrF5d/uynajt7V06V/jTGC60B+No3LfkpzE7fklfyHATHblvekadicQ tSWRgxD5OY478ieM9/C1LYxBqOmmLrsLLkARl6BbXYgYb+FQbY+BTpJH6gwWayrkAv0R 9SpVjkpQnJsLRKVtuwvNeZTulxVPF6ip00ffvaCW2F7nqw9L2axU9NyzF0eohrCxBC/R p4Z+FgJJBRh/UwfIpiRjHINcDkW6lmH89/sjXZWxEUt3yF1IzSranGzZiQ2RCoWRnB5R MwxQ== X-Gm-Message-State: ANoB5pmhCrFvM9KBATWAUXwcL50F5pxb8YCl18Z9/143NWle5wC64o+b xqHZ13tQlaMnoHm/UlVnEDKQ0g== X-Received: by 2002:a05:6512:33c3:b0:4a2:23f5:c1f6 with SMTP id d3-20020a05651233c300b004a223f5c1f6mr7809082lfg.472.1668611212391; Wed, 16 Nov 2022 07:06:52 -0800 (PST) Received: from [10.10.15.130] ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id w26-20020ac2443a000000b004acbfa4a18bsm2644453lfl.173.2022.11.16.07.06.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Nov 2022 07:06:52 -0800 (PST) Message-ID: Date: Wed, 16 Nov 2022 18:06:51 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [v1] drm/msm/disp/dpu1: add color management support for the crtc Content-Language: en-GB To: Kalyan Thota , "Kalyan Thota (QUIC)" , "dri-devel@lists.freedesktop.org" , "linux-arm-msm@vger.kernel.org" , "freedreno@lists.freedesktop.org" , "devicetree@vger.kernel.org" Cc: "linux-kernel@vger.kernel.org" , "robdclark@chromium.org" , "dianders@chromium.org" , "swboyd@chromium.org" , "Vinod Polimera (QUIC)" , "Abhinav Kumar (QUIC)" References: <1668175043-11028-1-git-send-email-quic_kalyant@quicinc.com> <8480ff54-0c5b-d6d1-eb48-8571257e69e5@linaro.org> From: Dmitry Baryshkov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/11/2022 17:29, Kalyan Thota wrote: > > >> -----Original Message----- >> From: Dmitry Baryshkov >> Sent: Saturday, November 12, 2022 4:13 AM >> To: Kalyan Thota (QUIC) ; dri- >> devel@lists.freedesktop.org; linux-arm-msm@vger.kernel.org; >> freedreno@lists.freedesktop.org; devicetree@vger.kernel.org >> Cc: linux-kernel@vger.kernel.org; robdclark@chromium.org; >> dianders@chromium.org; swboyd@chromium.org; Vinod Polimera (QUIC) >> ; Abhinav Kumar (QUIC) >> >> Subject: Re: [v1] drm/msm/disp/dpu1: add color management support for the >> crtc >> >> WARNING: This email originated from outside of Qualcomm. Please be wary of >> any links or attachments, and do not enable macros. >> >> On 11/11/2022 16:57, Kalyan Thota wrote: >>> Add color management support for the crtc provided there are enough >>> dspps that can be allocated from the catalogue. >>> >>> Changes in v1: >>> - cache color enabled state in the dpu crtc obj (Dmitry) >>> - simplify dspp allocation while creating crtc (Dmitry) >>> - register for color when crtc is created (Dmitry) >>> >>> Signed-off-by: Kalyan Thota >>> --- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 5 +-- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 6 ++-- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 7 ++-- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 53 >> ++++++++++++++++++++++++++++- >>> 4 files changed, 64 insertions(+), 7 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c >>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c >>> index 4170fbe..ca4c3b3 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c >>> @@ -1571,7 +1571,7 @@ static const struct drm_crtc_helper_funcs >>> dpu_crtc_helper_funcs = { >>> >>> /* initialize crtc */ >>> struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane >> *plane, >>> - struct drm_plane *cursor) >>> + struct drm_plane *cursor, unsigned long >>> + features) >>> { >>> struct drm_crtc *crtc = NULL; >>> struct dpu_crtc *dpu_crtc = NULL; @@ -1583,6 +1583,7 @@ struct >>> drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane >>> *plane, >>> >>> crtc = &dpu_crtc->base; >>> crtc->dev = dev; >>> + dpu_crtc->color_enabled = features & BIT(DPU_DSPP_PCC); >>> >>> spin_lock_init(&dpu_crtc->spin_lock); >>> atomic_set(&dpu_crtc->frame_pending, 0); @@ -1604,7 +1605,7 @@ >>> struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct >>> drm_plane *plane, >>> >>> drm_crtc_helper_add(crtc, &dpu_crtc_helper_funcs); >>> >>> - drm_crtc_enable_color_mgmt(crtc, 0, true, 0); >>> + drm_crtc_enable_color_mgmt(crtc, 0, dpu_crtc->color_enabled, 0); >>> >>> /* save user friendly CRTC name for later */ >>> snprintf(dpu_crtc->name, DPU_CRTC_NAME_SIZE, "crtc%u", >>> crtc->base.id); diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h >>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h >>> index 539b68b..342f9ae 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h >>> @@ -136,6 +136,7 @@ struct dpu_crtc_frame_event { >>> * @enabled : whether the DPU CRTC is currently enabled. updated in the >>> * commit-thread, not state-swap time which is earlier, so >>> * safe to make decisions on during VBLANK on/off work >>> + * @color_enabled : whether crtc supports color management >>> * @feature_list : list of color processing features supported on a crtc >>> * @active_list : list of color processing features are active >>> * @dirty_list : list of color processing features are dirty >>> @@ -164,7 +165,7 @@ struct dpu_crtc { >>> u64 play_count; >>> ktime_t vblank_cb_time; >>> bool enabled; >>> - >>> + bool color_enabled; >>> struct list_head feature_list; >>> struct list_head active_list; >>> struct list_head dirty_list; >>> @@ -269,10 +270,11 @@ void dpu_crtc_complete_commit(struct drm_crtc >> *crtc); >>> * @dev: dpu device >>> * @plane: base plane >>> * @cursor: cursor plane >>> + * @features: color features >>> * @Return: new crtc object or error >>> */ >>> struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane >> *plane, >>> - struct drm_plane *cursor); >>> + struct drm_plane *cursor, unsigned long >>> + features); >>> >>> /** >>> * dpu_crtc_register_custom_event - api for enabling/disabling crtc >>> event diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> index c9058aa..d72edb8 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> @@ -579,6 +579,7 @@ bool dpu_encoder_use_dsc_merge(struct drm_encoder >> *drm_enc) >>> static struct msm_display_topology dpu_encoder_get_topology( >>> struct dpu_encoder_virt *dpu_enc, >>> struct dpu_kms *dpu_kms, >>> + struct dpu_crtc *dpu_crtc, >>> struct drm_display_mode *mode) >>> { >>> struct msm_display_topology topology = {0}; @@ -607,7 +608,7 @@ >>> static struct msm_display_topology dpu_encoder_get_topology( >>> else >>> topology.num_lm = (mode->hdisplay > MAX_HDISPLAY_SPLIT) >>> ? 2 : 1; >>> >>> - if (dpu_enc->disp_info.intf_type == DRM_MODE_ENCODER_DSI) { >>> + if (dpu_crtc->color_enabled) { >>> if (dpu_kms->catalog->dspp && >>> (dpu_kms->catalog->dspp_count >= topology.num_lm)) >>> topology.num_dspp = topology.num_lm; @@ -642,6 >>> +643,7 @@ static int dpu_encoder_virt_atomic_check( >>> struct drm_display_mode *adj_mode; >>> struct msm_display_topology topology; >>> struct dpu_global_state *global_state; >>> + struct dpu_crtc *dpu_crtc; >>> int i = 0; >>> int ret = 0; >>> >>> @@ -652,6 +654,7 @@ static int dpu_encoder_virt_atomic_check( >>> } >>> >>> dpu_enc = to_dpu_encoder_virt(drm_enc); >>> + dpu_crtc = to_dpu_crtc(crtc_state->crtc); >>> DPU_DEBUG_ENC(dpu_enc, "\n"); >>> >>> priv = drm_enc->dev->dev_private; @@ -677,7 +680,7 @@ static int >>> dpu_encoder_virt_atomic_check( >>> } >>> } >>> >>> - topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, adj_mode); >>> + topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, dpu_crtc, >>> + adj_mode); >>> >>> /* Reserve dynamic resources now. */ >>> if (!ret) { >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c >>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c >>> index 0709da2..ce6f5e6 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c >>> @@ -734,7 +734,54 @@ static int _dpu_kms_setup_displays(struct drm_device >> *dev, >>> return rc; >>> } >>> >>> +/** >>> + * _dpu_kms_populate_dspp_features - Evaluate how many dspps pairs can be >> facilitated >>> + to enable color features for encoder and assign >>> + color features prefering primary >> >> preferring >> >>> + * @dpu_kms: Pointer to dpu kms structure >>> + * @features: Pointer to feature array >>> + * >>> + * Baring single entry, if atleast 2 dspps are available in the >>> + catalogue, >> >> at least >> >>> + * then color can be enabled for that crtc */ static void >>> +_dpu_kms_populate_dspp_features(struct dpu_kms *dpu_kms, >>> + unsigned long *features) >>> +{ >>> + struct drm_encoder *encoder; >>> + u32 external_enc_mask = 0; >>> + u32 num_dspps = dpu_kms->catalog->dspp_count; >>> + >>> + if (!num_dspps) >>> + return; >>> + else if (num_dspps > 1) >>> + num_dspps /= 2; >>> + >>> + /* Ensure all primary encoders get first allocation of color */ >>> + drm_for_each_encoder(encoder, dpu_kms->dev) { >>> + if(dpu_encoder_is_primary(encoder)) { >>> + if (num_dspps) { >>> + features[encoder->index] = dpu_kms->catalog->dspp- >>> features; >>> + num_dspps--; >>> + } >>> + } else if(dpu_encoder_is_external(encoder)) { >>> + external_enc_mask |= drm_encoder_mask(encoder); >>> + } >>> + } >>> + >>> + if(!num_dspps) >>> + return; >>> + >>> + /* Allocate color for external encoders after primary */ >> >> Please. No "primary" encoders. You already have sense of internal vs external, >> plugable, or which ever way you would like to call them. You don't need to add >> another safety check, do you? >> >>> + drm_for_each_encoder_mask(encoder, dpu_kms->dev, >> external_enc_mask) { >>> + if (num_dspps) { >>> + features[encoder->index] = dpu_kms->catalog->dspp->features; >>> + num_dspps--; >>> + } >>> + } >>> +} >>> + >>> #define MAX_PLANES 20 >>> +#define MAX_ENCODERS 10 >>> static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) >>> { >>> struct drm_device *dev; >>> @@ -749,6 +796,8 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms >>> *dpu_kms) >>> >>> int primary_planes_idx = 0, cursor_planes_idx = 0, i, ret; >>> int max_crtc_count; >>> + unsigned long features[MAX_ENCODERS] = {0}; >>> + >>> dev = dpu_kms->dev; >>> priv = dev->dev_private; >>> catalog = dpu_kms->catalog; >>> @@ -798,12 +847,14 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms >> *dpu_kms) >>> } >>> >>> max_crtc_count = min(max_crtc_count, primary_planes_idx); >>> + _dpu_kms_populate_dspp_features(dpu_kms, features); >>> >>> /* Create one CRTC per encoder */ >>> i = 0; >>> drm_for_each_encoder(encoder, dev) { >>> if (i < max_crtc_count) { >>> - crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i]); >>> + crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i], >>> + features[encoder->index]); >> >> A simple counter should be enough. You know the number of 'rich' CRTCs, which >> can get DSPP (or a pair of DSPPs). Then you can create a feature-rich CRTC >> provided the current encoder should use one and if the number of created 'rich' >> CRTCs is not greater than the 'possibly rich' >> number. > Since encoder list is iterative, and pluggable/builtin encoders can be registered in any order. we need to traverse the list > to pick up preferred encoders so as to attach color features. I couldn't get a logic on how to accomplish that using a counter. can you explain a bit more on the idea that you have. drm_for_each_encoder(encoder, dev) { bool use_ctm = false; if (dpu_encoder_is_builtin(encoder, state)) use_ctm = true; crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i], use_ctm); } > >> >>> if (IS_ERR(crtc)) { >>> ret = PTR_ERR(crtc); >>> return ret; >> >> -- >> With best wishes >> Dmitry > -- With best wishes Dmitry