From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7399C433DB for ; Wed, 24 Mar 2021 03:02:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79DD8619DC for ; Wed, 24 Mar 2021 03:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234989AbhCXDBi (ORCPT ); Tue, 23 Mar 2021 23:01:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234961AbhCXDBD (ORCPT ); Tue, 23 Mar 2021 23:01:03 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 623C6C061763 for ; Tue, 23 Mar 2021 20:01:02 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id l18so17714110edc.9 for ; Tue, 23 Mar 2021 20:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PBjcpQgIglZYIQCLYI/ABjzh4xZMbSaRaKT1WiivV+Y=; b=P+Cj5trNRI+g0OmQ7t84I96iN9b9Xc6vphPi42LmTQYbZXpFuxaYlAE/p34MW97Ker GY+7qxE6jvn0R8H5lpa3DkiNdekJkuMU7n4hJ+Run6n8/EWdh1PxJVdfHdU0UNFWvlnf BvEUsJQ+8eDyNI+EEsY/6bDwocR274HobSDGU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PBjcpQgIglZYIQCLYI/ABjzh4xZMbSaRaKT1WiivV+Y=; b=t+yOGS0peA8rz07lnnMQxgI3+z7YOVJsIkA1Xxyn6gXm+BvN0aPJlQjlMpqE11qg9i EHAMeer0iieQ/taluC/qHMUsxq+e4oXi1beBvDj2KPmtlr7UjepMryAbkNA8491DHepx 5BsY/1c4qW1U/npFdVtsbF+ThDkkbnxmi2cefvJn+kiU/hRhAI58WAqnRIq0PB5mt3aK OyWQC+uR0NEEHEunfzxXAU22O/1KftAPZbDtTa4hDzDOq9QobnPaAvzBOSeZoajgVHY9 yxssX8OdOkYqu1R7H1/9utm+urCtNvnP7phGPHLnRK/J+Htj1kHoKJHfML5J5jxkwG8m n+8Q== X-Gm-Message-State: AOAM532aE8b1JQS1d5zn3t+mMvWGMGAwaABPo7myO+GqBCjmj7aYU8Wk qkM9F5LErIrXR24k59vp0wy+kO7nc1vW6A== X-Google-Smtp-Source: ABdhPJz9fQd+SDPMAovAtgVVBmwpwOhKzmCRnOMZEuzCSbax2MnI87mM+eIFAf577WxknXrx1w45qg== X-Received: by 2002:aa7:cf95:: with SMTP id z21mr1027457edx.76.1616554860697; Tue, 23 Mar 2021 20:01:00 -0700 (PDT) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com. [209.85.128.43]) by smtp.gmail.com with ESMTPSA id ld19sm260132ejb.102.2021.03.23.20.00.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Mar 2021 20:01:00 -0700 (PDT) Received: by mail-wm1-f43.google.com with SMTP id g20so12097003wmk.3 for ; Tue, 23 Mar 2021 20:00:59 -0700 (PDT) X-Received: by 2002:a1c:c282:: with SMTP id s124mr710113wmf.99.1616554859441; Tue, 23 Mar 2021 20:00:59 -0700 (PDT) MIME-Version: 1.0 References: <20210319055342.127308-1-senozhatsky@chromium.org> <20210319055342.127308-6-senozhatsky@chromium.org> In-Reply-To: From: Tomasz Figa Date: Wed, 24 Mar 2021 12:00:48 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv3 5/6] media: uvcvideo: add UVC 1.5 ROI control To: Sergey Senozhatsky Cc: Ricardo Ribalda , Laurent Pinchart , Mauro Carvalho Chehab , Hans Verkuil , Linux Media Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 24, 2021 at 11:52 AM Sergey Senozhatsky wrote: > > On (21/03/24 11:34), Tomasz Figa wrote: > > On Wed, Mar 24, 2021 at 11:31 AM Sergey Senozhatsky > > wrote: > [..] > > > > Adjusting the rectangle to something supported by the hardware is > > > > mentioned explicitly in the V4L2 API documentation and is what drivers > > > > have to implement. Returning an error on invalid value is not a > > > > correct behavior here (and similarly for many other operations, e.g. > > > > S_FMT). > > > > > > Well, in this particular case we are talking about user-space that wants > > > to set ROI rectangle that is knowingly violates device's GET_MAX and > > > overflows UVC ROI rectangle u16 value range. That's a clear bug in user-space. > > > Do we want to pretend that user-space does the correct thing and fixup > > > stuff behind the scenes? > > > > > > > That's how the API is defined. There is a valid use case for this - > > you don't need to run QUERY_CTRL if all you need is setting the > > biggest possible rectangle, just set it to (0, 0), (INT_MAX, INT_MAX). > > I guess in our case we need to talk about rectangle,auto-controls tuple > that we send to firmware > > rect { > (0, 0), (INT_MAX, INT_MAX) > } > auto-controls { > INT_MAX > } > > For ROI user-space also must provide valid auto-controls value, which > normally requires GET_MIN/GET_MAX discovery. > > v4l2 selection API mentions only rectangle adjustments and errnos like > -ERANGE also mention "It is not possible to adjust struct v4l2_rect r > rectangle to satisfy all constraints given in the flags argument". > > So in case when auto-controls is out of supported range (out of > GET_MIN, GET_MAX range) there is no way for us to tell user-space that > auto-controls is wrong. We probably need silently pick up the first > supported value, but not sure how well this will work out in the end. Shouldn't the autocontrol selection be done via a separate bitmask control rather than some custom flags in the selection API? Best regards, Tomasz