Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3463364rwi; Sun, 16 Oct 2022 11:20:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GdtdkhXSTFg1gZTlQzOKGK4X7iPnuIeecy23uzJJSbs6DXAw93WLMsfsFDgdpmjIzBbnU X-Received: by 2002:a17:907:728a:b0:78d:2b4b:e7f7 with SMTP id dt10-20020a170907728a00b0078d2b4be7f7mr5920005ejc.269.1665944413896; Sun, 16 Oct 2022 11:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665944413; cv=none; d=google.com; s=arc-20160816; b=DXy+uzeDUgUAIsVuFjXUBWYWFnPLIvTbnkE+0VX9YEqXEBQN5ugBsSyZCAmOh25yl2 GTuo5V9IqCz4c7MzNJHmozzeoOTGB1geRjMBGF4pZbf1/UV3VnxCeEVI4jYXQLS0Bnx8 ovYaDu8+XxkH+3F8Y2hekG8h15rZC8r0r36oOu9950/UFlJuUHZHrIYAjajvXUhxEOtX vsJHYvrdasjl/CF/424rPDTKj5QczQ5aT6Lw0GB5v9cRfpBRosW60z67gEhJnY4b9jvq WhBt2yOqxmTxUWDTNhTnwTvRj0YP0c89nghYDpHHAx30Q8E1ti5fs7t5PzC2oRuuUuqv gaqQ== 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 :cc:to:content-language:subject:reply-to:user-agent:mime-version :date:message-id:from:dkim-signature; bh=vSRr/j+Evb9BMA2XLUvE7/B7qNHF/qpJdEql+dXYhK8=; b=inMnSx59jKHEvdlGY37yUjTHnRLu29tJAqdq4EcKaE710fahFKntboAzDlnq/m8/ck JyiUy19rmxSI/tKjmO3YUyWCzCI2PNS/QdL6TmBcw+JGRqPC9wkyXZuYbKGJZKpBHK0n QEWrYqOCB3zwo0TE4WyKYIdHnbxp/jDxzS0x+bFQ9+blkEGAH8byc61bw+uy2Y18d2gZ ZOlWbQvX69V0oM1NAJ6CUauDhbm/aSTF/ElHsUGqRH95WOKmB6oh6jM0xL3+DLAqiNU7 vkJ5Imq1l2P6NgNbbh1zHygqM8fSlWtA3nip90xTE09kUdMbgpg2IXHUONricjm687Pc pqkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=O1fhxdAF; 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 u21-20020aa7d895000000b004569899e0bcsi6457573edq.138.2022.10.16.11.19.48; Sun, 16 Oct 2022 11:20:13 -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=O1fhxdAF; 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 S229818AbiJPSM4 (ORCPT + 99 others); Sun, 16 Oct 2022 14:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbiJPSMy (ORCPT ); Sun, 16 Oct 2022 14:12:54 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA37B482 for ; Sun, 16 Oct 2022 11:12:53 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id r22so11547647ljn.10 for ; Sun, 16 Oct 2022 11:12:53 -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:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:from:to:cc:subject:date:message-id:reply-to; bh=vSRr/j+Evb9BMA2XLUvE7/B7qNHF/qpJdEql+dXYhK8=; b=O1fhxdAF8qvfIwtjK6Ez9gV/11wN0p8lVgVvIuYj5OBpkQsM8+0lXbCMJ7ZJgOpumi MDo0Ubxh4pse9UXyLDEhsl2RoO9/isoYMONvYusDoJRRBa99G77p/UNnKpHETdvqVGrE efOT0lVGsrY8bHvbZ6QzyZ1EEpFJRJrDgSO5R7fsSgYJxbdBtPa7HkWmqJ/zhluEoYmC R3NfKAEfIAphn8jXiTl0bHVS+bAqm/Lrab/+AaBV5mokSC9WSfepT0V8+Ae1dFUNwWcI tUCVNq9MNJqRGP9fcjj4Ebk7j6QSDbfmLbg7TejANpbnQ3V10kWjLfk/LjfrkRtD2a+i iM4g== 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:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vSRr/j+Evb9BMA2XLUvE7/B7qNHF/qpJdEql+dXYhK8=; b=ygj/B8LGYkWMUatTQ4+bCbPoIBktECm0E/EaKBoFIdRb2UOgY8sL87cIjrL4xz+yKx sv+Mz6CaJEJGzoXLK4sq6O81rZBvgPXgjquRtSsnnDmC7bN4SU7gVWDjrRI2burpMG1K KWmf7+Vxnh8dypvexiBVCjQGe6GORhzgZbiCt3Dag2liIZotoSWl0CrlSU82uTJf8cGl 0z3xK+m68f8Wd0gYbKG89xvM2J/XiLqAsEUZ/CXcOyT6bdc1WRz1tr6INNJCuUchsLH/ slnI1G7aNcwqmNJtaDkWAJmgHeNbpuFhbNxI9M4aWHA67ecglJMUTUPzQtdTjvDoyf2N bGIQ== X-Gm-Message-State: ACrzQf1IuA0WAzMZfjeyjnlkO9Cy9dO+u6oUbf7IZoDYw4DUYOjJOEti /VxuEEOKF35MA+8LhWiDaKk= X-Received: by 2002:a2e:54a:0:b0:26e:1ab:c507 with SMTP id 71-20020a2e054a000000b0026e01abc507mr2807766ljf.215.1665943971567; Sun, 16 Oct 2022 11:12:51 -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 5-20020ac25f05000000b00492e3a8366esm1144735lfq.9.2022.10.16.11.12.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Oct 2022 11:12:50 -0700 (PDT) From: Mateusz Kwiatkowski X-Google-Original-From: Mateusz Kwiatkowski Message-ID: <270c4a51-0a03-f048-46da-ab37900f8b91@gmail.com> Date: Sun, 16 Oct 2022 20:12:48 +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 Reply-To: kfyatek+publicgit@gmail.com 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 References: <20220728-rpi-analog-tv-properties-v5-0-d841cc64fe4b@cerno.tech> <20220728-rpi-analog-tv-properties-v5-19-d841cc64fe4b@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v5-19-d841cc64fe4b@cerno.tech> 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, 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