Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3615118iog; Tue, 21 Jun 2022 02:22:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uS4SDlG0MGNA68NPqFE2UDAaagfhTeKIIc0dw8pk/17LNiZmMRNL69o35OKLcbqhQC3HwW X-Received: by 2002:a17:90b:4a0a:b0:1ec:bd8d:a128 with SMTP id kk10-20020a17090b4a0a00b001ecbd8da128mr5715955pjb.67.1655803351438; Tue, 21 Jun 2022 02:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655803351; cv=none; d=google.com; s=arc-20160816; b=du1I2JaBokGxIpnzy7NwtwZRWs3ZkRI7Yg50X9ij//MsOWb9KtvoO84OxvDNBCBU8q caEQbKFHZoTz5DelXqKfKpHGafyGGt9wUi4PBbPBjb8Wa+j2C53HUjqOEbdf+wpDVomw PFRfdjvwR6rEkeLIFKy+7NxKLV2/EpLfnqW7TOW5RGI4G2z+fU1oJN7iP4sOGVEzCnzD Z0xSingW9Oe46oTA7U744liqTcRLWkO/kT2cmHCaLgPVc5I2aDjrjvCc3kLoS0LhRJzl zHZwVyl1NIoyZIMrL3BNNIFrqbSf4FYqhRZJULVktNvjQI7OCum6hkndhONckJRt/JRE +WXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=vJPkzk6EQlamjTWr4zwrEkoumU44Ke4DpZgp6nabWaI=; b=ixpTlHer2bS+BrgXuZS6jrm+u2UM2D3U2xL474IjvhAZVntBLHHMUDSupMxTuV40mj hZ74369/LXoEXY0F9y+R80dyQp0EmsCUL4dKYW3u5+/pjAxVOLKCaDxEhWS5QQE+S49a u6ISF64qPQ9HRGP7cEtEUmntQkvQU0EvShc+eB0u+fvtT7oRZGgaWENOyjY43Y6HO8Gh zCpRKXDMka1+0kADdLFUBV1m4QWPFBCsBNzDpMeMAeAFTB+9HAgffz1tKE4wTPhZwV4U k/BTBc/EpcWA+dKPo+Sv3pspkt9I4LjIrxPJ+S2rJwNMEkg6QlV9zoQvgHSssvACqX0p 0abw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=u06d4Rhv; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn18-20020a17090b38d200b001e67f6b069csi16563256pjb.131.2022.06.21.02.22.16; Tue, 21 Jun 2022 02:22:31 -0700 (PDT) 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=@quicinc.com header.s=qcdkim header.b=u06d4Rhv; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348535AbiFUJGv (ORCPT + 99 others); Tue, 21 Jun 2022 05:06:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348440AbiFUJGu (ORCPT ); Tue, 21 Jun 2022 05:06:50 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2327F15A34; Tue, 21 Jun 2022 02:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1655802409; x=1687338409; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=vJPkzk6EQlamjTWr4zwrEkoumU44Ke4DpZgp6nabWaI=; b=u06d4Rhv+TX8JC7JKs0hFJSWG/w6ke83gTamWqodev/Sqc3vWNyYH+mS GIlshTp+Q4zUodNTY4jDzaN8fj4cilRJdZbbtyeaOVmqDTK3+AbXSSINe iYoZAydvi0giZXtwRdqMPXlvOmDoGpBt+5tj6IzSbXqE84+kYY5cGACWF E=; Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 21 Jun 2022 02:06:49 -0700 X-QCInternal: smtphost Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/AES256-SHA; 21 Jun 2022 02:06:47 -0700 X-QCInternal: smtphost Received: from kalyant-linux.qualcomm.com ([10.204.66.210]) by ironmsg02-blr.qualcomm.com with ESMTP; 21 Jun 2022 14:36:31 +0530 Received: by kalyant-linux.qualcomm.com (Postfix, from userid 94428) id 25A1241C5; Tue, 21 Jun 2022 02:06:31 -0700 (PDT) From: Kalyan Thota To: y@qualcomm.com, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org Cc: Kalyan Thota , linux-kernel@vger.kernel.org, robdclark@gmail.com, dianders@chromium.org, swboyd@chromium.org, quic_vpolimer@quicinc.com, dmitry.baryshkov@linaro.org, quic_abhinavk@quicinc.com Subject: [v1 2/2] drm/msm/disp/dpu1: enable crtc color management based on encoder topology Date: Tue, 21 Jun 2022 02:06:27 -0700 Message-Id: <1655802387-15275-2-git-send-email-quic_kalyant@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1655802387-15275-1-git-send-email-quic_kalyant@quicinc.com> References: <1655802387-15275-1-git-send-email-quic_kalyant@quicinc.com> X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Crtc color management needs to be registered only for the crtc which has the capability to handle it. Since topology decides which encoder will get the dspp hw block, tie up the crtc and the encoder together (encoder->possible_crtcs) Change-Id: If5a0f33547b6f527ca4b8fbb78424b141dbbd711 Signed-off-by: Kalyan Thota --- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 8 ++++++-- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 2 +- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 20 ++++++++++++++++---- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 5 +++++ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 22 ++++++++++++++++++---- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c index 7763558..2913acb 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c @@ -1511,7 +1511,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 int enc_mask) { struct drm_crtc *crtc = NULL; struct dpu_crtc *dpu_crtc = NULL; @@ -1544,7 +1544,11 @@ 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); + /* Register crtc color management if the encoder has dspp, use the + * crtc to mark it as possible_crtcs for that encoder. + */ + if(BIT(crtc->index) & enc_mask) + drm_crtc_enable_color_mgmt(crtc, 0, true, 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 b8785c3..0a6458e 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h @@ -269,7 +269,7 @@ void dpu_crtc_complete_commit(struct drm_crtc *crtc); * @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 int enc_mask); /** * 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 f2cb497..893ce68 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include "msm_drv.h" #include "dpu_kms.h" @@ -511,13 +513,18 @@ void dpu_encoder_helper_split_config( } } -static struct msm_display_topology dpu_encoder_get_topology( - struct dpu_encoder_virt *dpu_enc, +struct msm_display_topology dpu_encoder_get_topology( + struct drm_encoder *drm_enc, struct dpu_kms *dpu_kms, struct drm_display_mode *mode) { struct msm_display_topology topology = {0}; + struct dpu_encoder_virt *dpu_enc; + struct drm_bridge *bridge; int i, intf_count = 0; + bool primary_display = false; + + dpu_enc = to_dpu_encoder_virt(drm_enc); for (i = 0; i < MAX_PHYS_ENCODERS_PER_VIRTUAL; i++) if (dpu_enc->phys_encs[i]) @@ -542,7 +549,12 @@ 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) { + drm_for_each_bridge_in_chain(drm_enc, bridge) { + if (bridge->type != DRM_MODE_CONNECTOR_DisplayPort) + primary_display = true; + } + + if (primary_display) { if (dpu_kms->catalog->dspp && (dpu_kms->catalog->dspp_count >= topology.num_lm)) topology.num_dspp = topology.num_lm; @@ -601,7 +613,7 @@ static int dpu_encoder_virt_atomic_check( } } - topology = dpu_encoder_get_topology(dpu_enc, dpu_kms, adj_mode); + topology = dpu_encoder_get_topology(drm_enc, dpu_kms, adj_mode); /* Reserve dynamic resources now. */ if (!ret) { diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h index 1f39327..c4daf7c 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h @@ -172,4 +172,9 @@ int dpu_encoder_get_vsync_count(struct drm_encoder *drm_enc); bool dpu_encoder_is_widebus_enabled(const struct drm_encoder *drm_enc); +struct msm_display_topology dpu_encoder_get_topology( + struct drm_encoder *drm_enc, + struct dpu_kms *dpu_kms, + struct drm_display_mode *mode); + #endif /* __DPU_ENCODER_H__ */ diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c index 3a4da0d..486ff9d 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c @@ -687,9 +687,12 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) unsigned cursor_idx = 0; unsigned primary_idx = 0; bool pin_overlays; + unsigned int max_dspp_count = 0; + unsigned int enc_mask = 0; struct msm_drm_private *priv; struct dpu_mdss_cfg *catalog; + struct msm_display_topology topology = {0}; int primary_planes_idx = 0, cursor_planes_idx = 0, i, ret; int max_crtc_count; @@ -754,10 +757,19 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) } max_crtc_count = min(max_crtc_count, primary_planes_idx); + max_dspp_count = catalog->dspp_count; + + drm_for_each_encoder(encoder, dev) { + topology = dpu_encoder_get_topology(encoder, dpu_kms, NULL); + if (topology.num_dspp > 0 && (topology.num_dspp <= max_dspp_count)) { + enc_mask |= BIT(encoder->index); + max_dspp_count -= topology.num_dspp; + } + } /* Create one CRTC per encoder */ for (i = 0; i < max_crtc_count; i++) { - crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i]); + crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i], enc_mask); if (IS_ERR(crtc)) { ret = PTR_ERR(crtc); return ret; @@ -765,9 +777,11 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms) priv->crtcs[priv->num_crtcs++] = crtc; } - /* All CRTCs are compatible with all encoders */ - drm_for_each_encoder(encoder, dev) - encoder->possible_crtcs = (1 << priv->num_crtcs) - 1; + /* Attach CRTC's to compatiable encoders */ + drm_for_each_encoder(encoder, dev) { + encoder->possible_crtcs = (enc_mask & BIT(encoder->index)) ? + BIT(encoder->index) : (((1 << priv->num_crtcs) - 1) & ~enc_mask); + } return 0; } -- 2.7.4