Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3625126pxb; Mon, 21 Feb 2022 02:08:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxo5gg6xlfJXhS27voJc9Jh/uP4sSnIKujL3TfFjS9kBZpHe6sxT99SsLu53VGG9J3hNRww X-Received: by 2002:aa7:c612:0:b0:40f:2a41:bddb with SMTP id h18-20020aa7c612000000b0040f2a41bddbmr20342417edq.291.1645438128265; Mon, 21 Feb 2022 02:08:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645438128; cv=none; d=google.com; s=arc-20160816; b=cWZ8y/XO1oQVQJQMnUpAdTblwrswxt3+y2Q86f7NZE3SQLYcHucE2BnTGpyFKuIm4T wISIgoUF19d0KfwJZhtiBEgwvmzqH5MVnKSGLyN1Oe4nYV916rB47vfAZSxOM4xZ6Ovp Q+AE54xnBL5JumZ5ValIMad1gqvHr/qLmbZnG1C2T/1hZj8H8Elkblx/8onaigsZS65E 53laQHTO9av7ImJO56TOMVQXPhOoAGD69B6nMXb321BsvfeWc+aYK2WQQfxRm9a0gXhA PZiuR4hljppFhKb1WojphX8YCRaTQay7exQtrGc7o7KqMCjv49+3BNUE8wlLb+hS+zi6 Piqw== 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=eb896sueNM4NHpigYPMkh5NK55eQiNdPOGg2uyxmUwE=; b=RfVkrEmPAPOQGbcxef4JDyP/DUL4hzHaFvJPU7AtnB96Wwgn1i+Ufj9JLYV0/M0Tw6 GhgkEp0iCBBU9O0fV2JrY2ahfe28dx/Emo/zqKEn0p0b56y5GeHLtfv7H67+fQKFz37f 56a0x7jq7rVhBYjeD3qtYdr4gZh0HJIJh2pb/ioMkhVZYvwh7bMquU7bHbzTHM7xjAXd pl2u0Ix35Ttm7PJHVx1pAsYc9MMivn3ooz2DNRyCCLo8SDNhaqhuXZq8zCnEhEv+nJxG NYbwKJ2WOVqFDwMG/2qghD9RCcW6Z4e3ZkoOyDtz60x9sEa8ajXMKbr2JLG9x3jobZLG ip8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FU4dSv1Z; 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 fl21si7632484ejc.583.2022.02.21.02.08.25; Mon, 21 Feb 2022 02:08:48 -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=FU4dSv1Z; 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 S1343503AbiBUCRx (ORCPT + 99 others); Sun, 20 Feb 2022 21:17:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240542AbiBUCRw (ORCPT ); Sun, 20 Feb 2022 21:17:52 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E0F04CD6A for ; Sun, 20 Feb 2022 18:17:29 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id j15so15863737lfe.11 for ; Sun, 20 Feb 2022 18:17:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=eb896sueNM4NHpigYPMkh5NK55eQiNdPOGg2uyxmUwE=; b=FU4dSv1ZSLXJ2sgUfR7Y2KHFmTT4TqLKUqNnrjcCeboM4ZE0FkQ2lRUZ97k5t+lNrI u4VNugYm+ggJk3+UNK2J4/O8xpFiH1ZUAGXUR77OHNd8WkDsKGjNE3Nys/MAr4eyLEUX VRBvTuc/iMALphJberS1xU6csyYguaKJJEoymBXa9roTEAhMuT9GMge2FRoGitNdBsae wGCy3HC+ODsdJ98fmtjmbOQAVg5zwnWprZoojBI+bJjIW1w9HnEavBWXWb/9Bc74aU7S au4TN6VV5v0uM127oSckWfnOvSNw7vH2lW2Ml0z7auHuTr/errwS1BvaqYQtffkVtXMT FqgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=eb896sueNM4NHpigYPMkh5NK55eQiNdPOGg2uyxmUwE=; b=S+8dbJdp6irRxKDtRWLcgkt+nwqtZGKP7N+pSy+EuGJA44lY5TdWTQ8Mi8ouEDUon+ 621bSZ/VbzmKwkurUcyQgxGlOYVFLAV4zg20iz849kBUo7R2LaVLyGfKHR7ER++JeqHi i89PvQ0Nu+uH+1x8fp0l7Fcj/sqptU32FvzCukp1O2mgPuartbCCH70LBC/HpePQjGRB pnAs5MidPR7CbbBRur74I/1BTXnXrZTJoMgOlqJA0z0GEyzlwkFToF/MkEnzatMtMJkR CdFtUq+UfNU/tPwmCmMJME1nWK3piWSJf5z2y1BH4EO4MHZtd333b1z1OkanE1rC7kH4 x4cg== X-Gm-Message-State: AOAM531gUJpwwLwnUCCLvGMug6kUHY6OkRY70iVecdsk5CkPTdzD9FFU +1+sfRoeR9som6+S7gnCVjNymA== X-Received: by 2002:a05:6512:3b88:b0:443:7b08:2fcb with SMTP id g8-20020a0565123b8800b004437b082fcbmr12370342lfv.621.1645409847655; Sun, 20 Feb 2022 18:17:27 -0800 (PST) Received: from [192.168.1.211] ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id 6sm969170lfq.241.2022.02.20.18.17.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 20 Feb 2022 18:17:26 -0800 (PST) Message-ID: Date: Mon, 21 Feb 2022 05:17:26 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [REPOST PATCH v4 01/13] drm/msm/dsi: add support for dsc data Content-Language: en-GB To: Vinod Koul , Rob Clark Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , David Airlie , Daniel Vetter , Jonathan Marek , Abhinav Kumar , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org References: <20220210103423.271016-1-vkoul@kernel.org> <20220210103423.271016-2-vkoul@kernel.org> From: Dmitry Baryshkov In-Reply-To: <20220210103423.271016-2-vkoul@kernel.org> 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,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/02/2022 13:34, Vinod Koul wrote: > Display Stream Compression (DSC) parameters need to be calculated. Add > helpers and struct msm_display_dsc_config in msm_drv for this > msm_display_dsc_config uses drm_dsc_config for DSC parameters. > > Signed-off-by: Vinod Koul > --- > drivers/gpu/drm/msm/dsi/dsi_host.c | 132 +++++++++++++++++++++++++++++ > drivers/gpu/drm/msm/msm_drv.h | 15 ++++ > 2 files changed, 147 insertions(+) > > diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c > index 6b3ced4aaaf5..27553194f9fa 100644 > --- a/drivers/gpu/drm/msm/dsi/dsi_host.c > +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c > @@ -31,6 +31,8 @@ > > #define DSI_RESET_TOGGLE_DELAY_MS 20 > > +static int dsi_populate_dsc_params(struct msm_display_dsc_config *dsc); > + > static int dsi_get_version(const void __iomem *base, u32 *major, u32 *minor) > { > u32 ver; > @@ -157,6 +159,7 @@ struct msm_dsi_host { > struct regmap *sfpb; > > struct drm_display_mode *mode; > + struct msm_display_dsc_config *dsc; > > /* connected device info */ > struct device_node *device_node; > @@ -1718,6 +1721,135 @@ static int dsi_host_parse_lane_data(struct msm_dsi_host *msm_host, > return -EINVAL; > } > > +static u32 dsi_dsc_rc_buf_thresh[DSC_NUM_BUF_RANGES - 1] = { > + 0x0e, 0x1c, 0x2a, 0x38, 0x46, 0x54, 0x62, > + 0x69, 0x70, 0x77, 0x79, 0x7b, 0x7d, 0x7e > +}; > + > +/* only 8bpc, 8bpp added */ > +static char min_qp[DSC_NUM_BUF_RANGES] = { > + 0, 0, 1, 1, 3, 3, 3, 3, 3, 3, 5, 5, 5, 7, 13 > +}; > + > +static char max_qp[DSC_NUM_BUF_RANGES] = { > + 4, 4, 5, 6, 7, 7, 7, 8, 9, 10, 11, 12, 13, 13, 15 > +}; > + > +static char bpg_offset[DSC_NUM_BUF_RANGES] = { > + 2, 0, 0, -2, -4, -6, -8, -8, -8, -10, -10, -12, -12, -12, -12 > +}; > + > +static int dsi_populate_dsc_params(struct msm_display_dsc_config *dsc) > +{ > + int mux_words_size; > + int groups_per_line, groups_total; > + int min_rate_buffer_size; > + int hrd_delay; > + int pre_num_extra_mux_bits, num_extra_mux_bits; > + int slice_bits; > + int target_bpp_x16; > + int data; > + int final_value, final_scale; > + int i; > + > + dsc->drm->rc_model_size = 8192; > + dsc->drm->first_line_bpg_offset = 12; > + dsc->drm->rc_edge_factor = 6; > + dsc->drm->rc_tgt_offset_high = 3; > + dsc->drm->rc_tgt_offset_low = 3; > + dsc->drm->simple_422 = 0; > + dsc->drm->convert_rgb = 1; > + dsc->drm->vbr_enable = 0; > + > + /* handle only bpp = bpc = 8 */ > + for (i = 0; i < DSC_NUM_BUF_RANGES - 1 ; i++) > + dsc->drm->rc_buf_thresh[i] = dsi_dsc_rc_buf_thresh[i]; > + > + for (i = 0; i < DSC_NUM_BUF_RANGES; i++) { > + dsc->drm->rc_range_params[i].range_min_qp = min_qp[i]; > + dsc->drm->rc_range_params[i].range_max_qp = max_qp[i]; > + dsc->drm->rc_range_params[i].range_bpg_offset = bpg_offset[i]; > + } > + > + dsc->drm->initial_offset = 6144; /* Not bpp 12 */ > + if (dsc->drm->bits_per_pixel != 8) > + dsc->drm->initial_offset = 2048; /* bpp = 12 */ > + > + mux_words_size = 48; /* bpc == 8/10 */ > + if (dsc->drm->bits_per_component == 12) > + mux_words_size = 64; > + > + dsc->drm->initial_xmit_delay = 512; > + dsc->drm->initial_scale_value = 32; > + dsc->drm->first_line_bpg_offset = 12; > + dsc->drm->line_buf_depth = dsc->drm->bits_per_component + 1; > + > + /* bpc 8 */ > + dsc->drm->flatness_min_qp = 3; > + dsc->drm->flatness_max_qp = 12; > + dsc->det_thresh_flatness = 7 + 2 * (dsc->drm->bits_per_component - 8); > + dsc->drm->rc_quant_incr_limit0 = 11; > + dsc->drm->rc_quant_incr_limit1 = 11; > + dsc->drm->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC; > + > + /* FIXME: need to call drm_dsc_compute_rc_parameters() so that rest of > + * params are calculated > + */ > + dsc->slice_last_group_size = 3 - (dsc->drm->slice_width % 3); > + groups_per_line = DIV_ROUND_UP(dsc->drm->slice_width, 3); > + dsc->drm->slice_chunk_size = dsc->drm->slice_width * dsc->drm->bits_per_pixel / 8; > + if ((dsc->drm->slice_width * dsc->drm->bits_per_pixel) % 8) > + dsc->drm->slice_chunk_size++; > + > + /* rbs-min */ > + min_rate_buffer_size = dsc->drm->rc_model_size - dsc->drm->initial_offset + > + dsc->drm->initial_xmit_delay * dsc->drm->bits_per_pixel + > + groups_per_line * dsc->drm->first_line_bpg_offset; > + > + hrd_delay = DIV_ROUND_UP(min_rate_buffer_size, dsc->drm->bits_per_pixel); > + > + dsc->drm->initial_dec_delay = hrd_delay - dsc->drm->initial_xmit_delay; > + > + dsc->drm->initial_scale_value = 8 * dsc->drm->rc_model_size / > + (dsc->drm->rc_model_size - dsc->drm->initial_offset); > + > + slice_bits = 8 * dsc->drm->slice_chunk_size * dsc->drm->slice_height; > + > + groups_total = groups_per_line * dsc->drm->slice_height; > + > + data = dsc->drm->first_line_bpg_offset * 2048; > + > + dsc->drm->nfl_bpg_offset = DIV_ROUND_UP(data, (dsc->drm->slice_height - 1)); > + > + pre_num_extra_mux_bits = 3 * (mux_words_size + (4 * dsc->drm->bits_per_component + 4) - 2); > + > + num_extra_mux_bits = pre_num_extra_mux_bits - (mux_words_size - > + ((slice_bits - pre_num_extra_mux_bits) % mux_words_size)); > + > + data = 2048 * (dsc->drm->rc_model_size - dsc->drm->initial_offset + num_extra_mux_bits); > + dsc->drm->slice_bpg_offset = DIV_ROUND_UP(data, groups_total); > + > + /* bpp * 16 + 0.5 */ > + data = dsc->drm->bits_per_pixel * 16; > + data *= 2; > + data++; > + data /= 2; > + target_bpp_x16 = data; > + > + data = (dsc->drm->initial_xmit_delay * target_bpp_x16) / 16; > + final_value = dsc->drm->rc_model_size - data + num_extra_mux_bits; > + dsc->drm->final_offset = final_value; > + > + final_scale = 8 * dsc->drm->rc_model_size / (dsc->drm->rc_model_size - final_value); > + > + data = (final_scale - 9) * (dsc->drm->nfl_bpg_offset + dsc->drm->slice_bpg_offset); > + dsc->drm->scale_increment_interval = (2048 * dsc->drm->final_offset) / data; > + > + dsc->drm->scale_decrement_interval = groups_per_line / (dsc->drm->initial_scale_value - 8); > + > + return 0; > +} > + > static int dsi_host_parse_dt(struct msm_dsi_host *msm_host) > { > struct device *dev = &msm_host->pdev->dev; > diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h > index d7574e6bd4e4..384f9bad4760 100644 > --- a/drivers/gpu/drm/msm/msm_drv.h > +++ b/drivers/gpu/drm/msm/msm_drv.h > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -134,6 +135,20 @@ struct msm_drm_thread { > struct kthread_worker *worker; > }; > > +/* DSC config */ > +struct msm_display_dsc_config { > + struct drm_dsc_config *drm; > + > + u32 initial_lines; > + u32 pkt_per_line; > + u32 bytes_in_slice; > + u32 bytes_per_pkt; > + u32 eol_byte_num; > + u32 pclk_per_line; > + u32 slice_last_group_size; > + u32 det_thresh_flatness; I have been looking throught the dsc params calculation. And it looks like this struct is not necessary at all. inital_lines can be passed to dpu_encoder_dsc_pipe_cfg() / hw_dsc->ops.dsc_config() directly. slice_last_group_size and det_thresh_flatness can be calculated in dpu_hw_dsc_config() directly. And the rest is only used in dsi_timing_setup(), where they are calculated an immediately used to set the hardware. Let's probably drop it, unless there is a good reason to have it? > +}; > + > struct msm_drm_private { > > struct drm_device *dev; -- With best wishes Dmitry