Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3463486rwi; Sun, 16 Oct 2022 11:20:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM511PXpR+jFIBqYct8y+CBbnFpWhTKIAoE4fIe0hvCYshd4o/Fm05so1E/PBBCOd9BFKOA9 X-Received: by 2002:a17:907:74a:b0:77e:9455:b4e3 with SMTP id xc10-20020a170907074a00b0077e9455b4e3mr6073490ejb.471.1665944422017; Sun, 16 Oct 2022 11:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665944422; cv=none; d=google.com; s=arc-20160816; b=YmIlAuEcvQFfvaRzEXi4PGDN2kx6PHuq7l6lQqYy22d4lOkYq2wHi1K2OF5hJEBNB8 PQYK2GhITHEU4FVVJlFc1KScHKjK7p5bkSSCNPSz+BVPmVHIO4MOptXlQtEjfu/BBC7y UH8mvW2YZ9R/q9Ck3hQsKgfQ8EE21++DZmY2jfCoSiAyTckF/jsC0wytSatfb7t+Lk1H TJ7EO0RpKON85AL9uslOsRdTFdPopx9FQsyGNp7eZqiqVsZxAKjzd2xJlRNJFoj0ku2t ubASTvjp7kAVYqgfZw2UkudDfayNBG/2gdL3fkPdYmmPe28ZRfIfXcebPGvKXGkILNo5 ycZQ== 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:references :reply-to:cc:to:content-language:subject:user-agent:mime-version :date:message-id:from:dkim-signature; bh=viplUm+By6s8XGYflV1jaRl8q/qb4f9y9KZgb4QOLdc=; b=TjDUwlQK+z+v0I/vUge9jRUNqREsdPTM0uk+SPj6cEMcdzUN3x+mPyHaSSBKRDoNeJ AYSz5SgOsGoIf2Ha9xlhx5O6fojylsQIScxJaso+95zevAbkfTlHGO2tdt3WRe+MZC4R /pNbYOcQa58/8F1JlpXdX95uLOe86hpvAumSf9ejPNruGC3xAHzqIUx9G6ZNh6rC5aqs Vzq5D+fflW+JO2JZok74iezSt7J8isVdSjuHeJhbMV+H+lHlzHUYSuzuXxLtFPSbMC95 wQZaCA9erqal8XuMBT9g4tF7kFOezSOk21J1ZQ7GEG+k0BlGCrvvUwWl7KkbqrTMy8PW aOzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mmnJBH4q; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a05640250c600b0045d47f522f5si5134720edb.367.2022.10.16.11.19.56; Sun, 16 Oct 2022 11:20:22 -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=@gmail.com header.s=20210112 header.b=mmnJBH4q; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbiJPSQl (ORCPT + 99 others); Sun, 16 Oct 2022 14:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229770AbiJPSQi (ORCPT ); Sun, 16 Oct 2022 14:16:38 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E867E4456F for ; Sun, 16 Oct 2022 11:16:36 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id j23so11556205lji.8 for ; Sun, 16 Oct 2022 11:16:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:reply-to:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=viplUm+By6s8XGYflV1jaRl8q/qb4f9y9KZgb4QOLdc=; b=mmnJBH4qc8H6AxaIiyfc2vzVCocrgGCP4ib4yJyyUtnrahrAqqBoHWVhpiMA2Z0OW5 clJw0eZ5ImFHiphKJGDLJTJwrl5F5EZAB8AQSIvGjbloClAAQeXnYoMdHg/NyMaVmrrx 45BTHjzh4BuqwfEA8zksbvlOlz7BSnrV4ReNMW3BvXD5/BdkOdy0eitwWx2u8k03lLKz u4xD5+hFv5grqx6LtotWs14ANU9Ev5Gf0+ICFYsqAftfjkrns9cCaltmHO+gJOc3vzza mTmL+c/PPP4rkIb4BK/mG7N8kfZwWPjUvRAs2jmM/ra5H3udWtZwmKbAMNIDsTFpsFp0 IGyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:reply-to:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=viplUm+By6s8XGYflV1jaRl8q/qb4f9y9KZgb4QOLdc=; b=55Mrgv4m80DCo90tvQzfiMByST43Zsy2CLdB6yPAqIa+kuEs4f/iT0I9PuA+0A3U8H sO806whakZ/t1u13tiXkgdYLhY+4KoiY/+hvd4zl3iFtcdfzyMb+MOqgMjP/0ZECWa54 BfTkOUNVBJA0vsMVwB3iNmCjq3fRjlAKPtvXUAQAHthrEUnHGZAGdOcAqz0hPclesQEx BH4Oav5dxL9b54x6XH6/Ezu/eYe9l05l0D2S5PRBRK9SvsZiKgxrGikZRa7SCs7yrlPT lBRLEe+3RRDnkOyveQqefbalRNng0CryqBQLLP1PQeFLeFB3G87cWIYr5uuVMSOWAr8M 1e0w== X-Gm-Message-State: ACrzQf0SFZzetmTaWdOH0PWYBUh5PeNuuQgwoufAaDJSnIJWk/zJg9HT nH2cg8r/t/2LtsK6NnWzXnE= X-Received: by 2002:a2e:91c8:0:b0:26e:977a:14b1 with SMTP id u8-20020a2e91c8000000b0026e977a14b1mr2876789ljg.379.1665944195109; Sun, 16 Oct 2022 11:16:35 -0700 (PDT) Received: from ?IPV6:2a02:a31a:a240:1700:64bb:87df:aad7:a9f0? ([2a02:a31a:a240:1700:64bb:87df:aad7:a9f0]) by smtp.googlemail.com with ESMTPSA id p22-20020a2eba16000000b0026dffa29989sm1221591lja.23.2022.10.16.11.16.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Oct 2022 11:16:34 -0700 (PDT) From: Mateusz Kwiatkowski X-Google-Original-From: Mateusz Kwiatkowski Message-ID: <31759a06-ddd0-6b78-0e10-8e8754f394f9@gmail.com> Date: Sun, 16 Oct 2022 20:16:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [PATCH v5 19/22] drm/vc4: vec: Check for VEC output constraints Content-Language: pl To: Maxime Ripard , Karol Herbst , Jani Nikula , Tvrtko Ursulin , Daniel Vetter , Maarten Lankhorst , David Airlie , Joonas Lahtinen , Lyude Paul , Maxime Ripard , Emma Anholt , Chen-Yu Tsai , Samuel Holland , Ben Skeggs , Thomas Zimmermann , Rodrigo Vivi , Jernej Skrabec Cc: Dom Cobley , linux-sunxi@lists.linux.dev, Dave Stevenson , =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Hans de Goede , Phil Elwell Reply-To: kfyatek+publicgit@gmail.com References: <20220728-rpi-analog-tv-properties-v5-0-d841cc64fe4b@cerno.tech> <20220728-rpi-analog-tv-properties-v5-19-d841cc64fe4b@cerno.tech> <270c4a51-0a03-f048-46da-ab37900f8b91@gmail.com> In-Reply-To: <270c4a51-0a03-f048-46da-ab37900f8b91@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLYTO, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 Hi Maxime, Sorry about the mess that happened to the previous message. I hope this one will be delivered more cleanly. W dniu 13.10.2022 o 15:19, Maxime Ripard pisze: > From: Mateusz Kwiatkowski > > The VEC can accept pretty much any relatively reasonable mode, but still > has a bunch of constraints to meet. > > Let's create an atomic_check() implementation that will make sure we > don't end up accepting a non-functional mode. > > Acked-by: Noralf Trønnes > Signed-off-by: Mateusz Kwiatkowski > Signed-off-by: Maxime Ripard > --- >  drivers/gpu/drm/vc4/vc4_vec.c | 48 +++++++++++++++++++++++++++++++++++++++++++ >  1 file changed, 48 insertions(+) > > diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c > index 90e375a8a8f9..1fcb7baf874e 100644 > --- a/drivers/gpu/drm/vc4/vc4_vec.c > +++ b/drivers/gpu/drm/vc4/vc4_vec.c > @@ -453,6 +453,7 @@ static int vc4_vec_encoder_atomic_check(struct drm_encoder *encoder, >                      struct drm_crtc_state *crtc_state, >                      struct drm_connector_state *conn_state) >  { > +    const struct drm_display_mode *mode = &crtc_state->adjusted_mode; >      const struct vc4_vec_tv_mode *vec_mode; >   >      vec_mode = &vc4_vec_tv_modes[conn_state->tv.legacy_mode]; > @@ -461,6 +462,53 @@ static int vc4_vec_encoder_atomic_check(struct drm_encoder *encoder, >          !drm_mode_equal(vec_mode->mode, &crtc_state->adjusted_mode)) >          return -EINVAL; >   > +    if (mode->crtc_hdisplay % 4) > +        return -EINVAL; > + > +    if (!(mode->crtc_hsync_end - mode->crtc_hsync_start)) > +        return -EINVAL; > + > +    switch (mode->vtotal) { > +    case 525: > +        if (mode->crtc_vtotal > 262) > +            return -EINVAL; > + > +        if (mode->crtc_vdisplay < 1 || mode->crtc_vdisplay > 253) > +            return -EINVAL; > + > +        if (!(mode->crtc_vsync_start - mode->crtc_vdisplay)) > +            return -EINVAL; > + > +        if ((mode->crtc_vsync_end - mode->crtc_vsync_start) != 3) > +            return -EINVAL; > + > +        if ((mode->crtc_vtotal - mode->crtc_vsync_end) < 4) > +            return -EINVAL; > + > +        break; > + > +    case 625: > +        if (mode->crtc_vtotal > 312) > +            return -EINVAL; > + > +        if (mode->crtc_vdisplay < 1 || mode->crtc_vdisplay > 305) > +            return -EINVAL; > + > +        if (!(mode->crtc_vsync_start - mode->crtc_vdisplay)) > +            return -EINVAL; > + > +        if ((mode->crtc_vsync_end - mode->crtc_vsync_start) != 3) > +            return -EINVAL; > + > +        if ((mode->crtc_vtotal - mode->crtc_vsync_end) < 2) > +            return -EINVAL; > + > +        break; > + > +    default: > +        return -EINVAL; > +    } > + >      return 0; >  } >   > In my original version of this function (https://github.com/raspberrypi/linux/pull/4406/files) the switch is over reference_mode->vtotal, not mode->vtotal. This was intended to explicitly allow a different value of mode->vtotal, to support non-standard modes, such as "fake" 525 lines with SECAM encoding, or the progressive modes. You're switching over mode->vtotal, which makes specifying those impossible. I don't think we should limit the users like that. We're removing reference_mode in patch 20/22, so adding a switch over reference_mode->vtotal is probably not a good idea -- in that case I'd switch over mode->htotal instead: 858 for "NTSC" and 864 for "PAL". This may seem a bit weird, but any other value of htotal causes the VEC to output garbage anyway. Best regards, Mateusz Kwiatkowski