Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1131349rwb; Tue, 4 Oct 2022 16:09:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MwuMBTQmggat4SIPJdTVrk74Pwm95fApAW5R2LMcEGl4KhTz8fPtsJTdLkz24XFGnigCq X-Received: by 2002:a62:8787:0:b0:561:2b15:a91b with SMTP id i129-20020a628787000000b005612b15a91bmr14306484pfe.63.1664924971246; Tue, 04 Oct 2022 16:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664924971; cv=none; d=google.com; s=arc-20160816; b=YQ9iLXueVLn03DNaESh9kTm1nbbxsCz5Klcx50ZHpn6DE9Jy/WUrdtOuc2A8Ba7W2c v4q4WHFWhcZVM7WXivO+PZIAqklBSJ3mfytAx//1ceVaT44ZGYB5o9TQ1u7GBN1d5IuU Z7rWRkVILzOO+wKiYCn2yIH8V0X7WkWgg+VnwgXhIHHU8zU/uQSO9B1LWMutIqjnuQM2 MzNxjTRW4N3rv4aJzY79zrwh5LQ56PNiMpix61pC1feV/XNoc+A8EIeWuvmNTKNFi8BJ 8uf7cpTzR86hLgHAJmKJlED1s+Y8wtTka79hHHqQ+Pq71pqRTlUVU5VZY4QtsC3ZGDjf zbnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date; bh=/vkBlmaYeIkL2M2icAPM7poNZ2CkdodQ/ODXXzWrb30=; b=AQEw5lU1dEylnmYM5lniVLkDNZPhnzC68396cLlSCYuJKmgt7VOWMY1u+sbDDXSIh6 rLMrLBaYvDCjsJKURMJPLQ9LtPkPsXOLPdDoA8m3LdEuxeqhPZAx20JYfUV7LzMq+6O0 l3hWZm4UfW+Nt5gDY4jeetWYfkXty1qgX1VuXruQa3ObqPNoGFlDSZygeRc069HTjIrO s4UcSb1Gg0jmzTETQHoVl3LkyVkDErJL0mUVv9bVBqUDaTI8D3I93Jq3jR+WXb7tr2Vy Dc4Fw06fA3zhAvtN8F2yqDOeZeUFQ4XP+2WBwFnsReu6DIg6LdYcdZLMCkUFSEDy/Ak9 PCcQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rj2-20020a17090b3e8200b00200287ed212si282878pjb.120.2022.10.04.16.09.19; Tue, 04 Oct 2022 16:09: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229462AbiJDW4P (ORCPT + 99 others); Tue, 4 Oct 2022 18:56:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiJDW4M (ORCPT ); Tue, 4 Oct 2022 18:56:12 -0400 Received: from relay03.th.seeweb.it (relay03.th.seeweb.it [5.144.164.164]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 740AA237EB; Tue, 4 Oct 2022 15:56:08 -0700 (PDT) Received: from SoMainline.org (94-209-172-39.cable.dynamic.v4.ziggo.nl [94.209.172.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r1.th.seeweb.it (Postfix) with ESMTPSA id 132B4200D2; Wed, 5 Oct 2022 00:56:06 +0200 (CEST) Date: Wed, 5 Oct 2022 00:56:04 +0200 From: Marijn Suijten To: Dmitry Baryshkov Cc: phone-devel@vger.kernel.org, Rob Clark , Vinod Koul , ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , David Airlie , Daniel Vetter , Abhinav Kumar , Sean Paul , Thomas Zimmermann , Javier Martinez Canillas , Alex Deucher , Douglas Anderson , Vladimir Lypak , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Marek Vasut Subject: Re: [PATCH 3/5] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits Message-ID: <20221004225604.4ysjrc2zmnbqordk@SoMainline.org> Mail-Followup-To: Marijn Suijten , Dmitry Baryshkov , phone-devel@vger.kernel.org, Rob Clark , Vinod Koul , ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , David Airlie , Daniel Vetter , Abhinav Kumar , Sean Paul , Thomas Zimmermann , Javier Martinez Canillas , Alex Deucher , Douglas Anderson , Vladimir Lypak , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Marek Vasut References: <20221001190807.358691-1-marijn.suijten@somainline.org> <20221001190807.358691-4-marijn.suijten@somainline.org> <20221004223504.vlfmxerdv47tlkdu@SoMainline.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 2022-10-05 01:40:12, Dmitry Baryshkov wrote: > On 05/10/2022 01:35, Marijn Suijten wrote: > > On 2022-10-04 17:45:50, Dmitry Baryshkov wrote: > >> On Sat, 1 Oct 2022 at 22:08, Marijn Suijten > >> wrote: > >> [..] > >>> - bytes_in_slice = DIV_ROUND_UP(dsc->slice_width * dsc->bits_per_pixel, 8); > >>> + bytes_in_slice = DIV_ROUND_UP(dsc->slice_width * bpp, 8); > >> > >> > >> bytes_in_slice = DIV_ROUND_UP(dsc->slice_width * dsc->bits_per_pixel, 8 * 16); ? > > > > Not necessarily a fan of this, it "hides" the fact that we are dealing > > with 4 fractional bits (1/16th precision, it is correct though); but > > since this is the only use of `bpp` I can change it and document this > > fact wiht a comment on top (including referencing the validation pointed > > out in dsi_populate_dsc_params()). > > > > Alternatively we can inline the `>> 4` here? > > No, I don't think so. If we shift by 4 bits, we'd loose the fractional > part. DIV_ROUND_UP( .... , 8 * 16) ensures that we round it up rather > than just dropping it. I'd still keep the `-EINVAL` on `if (dsc->bits_per_pixel & 0xf)` to guarantee that there is no fractional part. After all, as explained in the patch description, none of this code / the DSI driver in general seems to be able to handle fractional bits per pixel. > >>> [..] > >>> - dsc->slice_chunk_size = dsc->slice_width * dsc->bits_per_pixel / 8; > >>> - if ((dsc->slice_width * dsc->bits_per_pixel) % 8) > >>> + dsc->slice_chunk_size = dsc->slice_width * bpp / 8; > >>> + if ((dsc->slice_width * bpp) % 8) > >> > >> One can use fixed point math here too: > >> > >> dsc->slice_chunk_size = (dsc->slice_width * dsc->bits_per_pixel + 8 * > >> 16 - 1)/ (8 * 16); > > > > Good catch, this is effectively a DIV_ROUND_UP() that we happened to > > call bytes_in_slice above... > > > > Shall I tackle this in the same patch, or insert another cleanup patch? > > It's up to you. I usually prefer separate patches, even if just to ease > bisecting between unrelated changes. Same feeling here, and have already set it up that way; added two extra patches to 1. replace this with DIV_ROUND_UP() and 2. remove the recalculation of slice_chunk_size (disguised as bytes_in_slice) above. - Marijn