Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1136963pxf; Thu, 18 Mar 2021 22:55:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyK/J70PtuT2AxBu7nHwYYZt4ZtLc+9CYsreCgjgVKDdERpAeukby4wSWUdgKPMqTvZ7Gz X-Received: by 2002:a17:906:f8d5:: with SMTP id lh21mr2461267ejb.64.1616133332640; Thu, 18 Mar 2021 22:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616133332; cv=none; d=google.com; s=arc-20160816; b=QwOYbIOaEXaPqW/TwxRgvv18+miATO0Hq9Euf160kOY8MuTjDSncUu2JIizqvLAHWx Nli073JQ+6K/fRrRbb+mzu5hDoGuY5+s3iacZCS2tCbbo05u4kY3AX5eYONbZnyw8t6R I4/m/OGvIQWqkdtMiXBx0dCIkYZfZfZeMGzEMfQNOsKO7IMueLV19YgUlK5vCVLuxxjA fmdFKbzgCkwdvJHMbMSWZhAtoXQVeb4Xe8K4yaTg1QV0L/VFgBpWLfkxzQdeyAx4X43q +qCyLwniVQ4UnZTUgJXjb5xeih20DF/0Vwr1I9V65IHEG/AQDEAwnTw9IUR2yc/JDeWx na5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hUuLvnE4iNx9waeqgL5Xgn7vAWrbF4/6uYgvJNfJksg=; b=NS2OW7M7NUgvD7l1U1zlOSCOBfV9ZdDynkc4z1N/n/isewu84ojW7Up+URH88V0wRH tt+ONFoAdCn2Js4kMDyabdDi1i2yCkfhw/eTmjqUWyvecGEZQVO6CAiZK3K94HNfMLor 8i+D1BUOeYFEDR7qd512qUdYUxg8kiIX9PATlSHezFVjZkhIsypcuhNgUG4+nas7Z4VK XXztblQ1a1KUwPkVwV8ZIQ+nekmGpZU9viDqtYC6f5EmTlnOJT6eFXnQLii6TKEaL+Ps lNj3taxD4FReOOeq+SXjlin7QHtWQYRFVPbY1JU4MBFzRWyCBUu9BUG4kqjoPztw5r99 vdMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UVOTQqJH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si3245797edn.333.2021.03.18.22.55.10; Thu, 18 Mar 2021 22:55:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UVOTQqJH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233941AbhCSFyR (ORCPT + 99 others); Fri, 19 Mar 2021 01:54:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233916AbhCSFxz (ORCPT ); Fri, 19 Mar 2021 01:53:55 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0456EC06174A for ; Thu, 18 Mar 2021 22:53:55 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id b184so5122769pfa.11 for ; Thu, 18 Mar 2021 22:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hUuLvnE4iNx9waeqgL5Xgn7vAWrbF4/6uYgvJNfJksg=; b=UVOTQqJHmqbSvw07EbUCTFAVj5IMI31Xz8uAB6N6OxqUi9fvgpOSEhhVcnnyVWpW+s 5bo73igaDKOwnax+Vqrf1uP/AUeY23eXLoiJrxepJwIofAghqVltSB383yzb5807HEYF yZh/wHRNZ4KzOdfB5knPeXK6yV93hxkQ9rxTw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hUuLvnE4iNx9waeqgL5Xgn7vAWrbF4/6uYgvJNfJksg=; b=q77shpqNWPorHSevG0cNgKSvvOa+shSvLPe5hF8ICvwdVLsHpOZnT3ZhqnLhh5/+lT Rrkgn5zKckOYGeqj/2L2G7zm/k21RXSqDlQPEIbaTt9eoZcKYA9abByuNDIUtv2+HK8B LUHuB+jbhTmnXsAJqOC7ViJH64cwpDuEpxN/wHS8ZxuCiNhkbDB8JtZWkEoocN/382gy 9J3O8AHINi6fDcYdQ9o4zPXLZb/CyPdjvxvSbmOjllSFmAmqg11vVAIqEwKZqrXOrvlw 2HKF4zUiyYnuveo6TOrxBvuTPgfovMqO6PtwURJ6c2SvG5I682PdiydvwAQEbdmEKETa L2AQ== X-Gm-Message-State: AOAM53158aOpZ7UGIwaioNsYayLQ5qOtcqjz1sf9AS6BV7E9XmaBTZ5E HpQ1I89i9g9iG8ajXOKds9+cuQ== X-Received: by 2002:aa7:8dda:0:b029:1fa:19b3:7ed9 with SMTP id j26-20020aa78dda0000b02901fa19b37ed9mr7681554pfr.32.1616133234579; Thu, 18 Mar 2021 22:53:54 -0700 (PDT) Received: from senozhatsky.flets-east.jp ([2409:10:2e40:5100:6577:f83d:5865:dfac]) by smtp.gmail.com with ESMTPSA id o13sm4043704pgv.40.2021.03.18.22.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:53:54 -0700 (PDT) From: Sergey Senozhatsky To: Laurent Pinchart , Ricardo Ribalda Cc: Tomasz Figa , Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv3 2/6] media: v4l UAPI: document ROI selection targets Date: Fri, 19 Mar 2021 14:53:38 +0900 Message-Id: <20210319055342.127308-3-senozhatsky@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210319055342.127308-1-senozhatsky@chromium.org> References: <20210319055342.127308-1-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Document V4L2 selection targets that will be used to ROI implementation. Signed-off-by: Sergey Senozhatsky --- .../media/v4l/selection-api-configuration.rst | 22 +++++++++++++++ .../media/v4l/selection-api-examples.rst | 28 +++++++++++++++++++ .../media/v4l/v4l2-selection-targets.rst | 24 ++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/selection-api-configuration.rst b/Documentation/userspace-api/media/v4l/selection-api-configuration.rst index fee49bf1a1c0..b5fdd765e2db 100644 --- a/Documentation/userspace-api/media/v4l/selection-api-configuration.rst +++ b/Documentation/userspace-api/media/v4l/selection-api-configuration.rst @@ -135,3 +135,25 @@ and the height of rectangles obtained using ``V4L2_SEL_TGT_CROP`` and ``V4L2_SEL_TGT_COMPOSE`` targets. If these are not equal then the scaling is applied. The application can compute the scaling ratios using these values. + +Configuration of Region of Interest (ROI) +========================================= + +The range of auto-controls values and of coordinates of the top left +corner, width and height of areas that can be ROI is given by the +``V4L2_SEL_TGT_ROI_BOUNDS_MIN`` and ``V4L2_SEL_TGT_ROI_BOUNDS_MAX`` +targets. It is recommended for the driver developers to put the top/left +corner at position ``(0,0)``. + +The top left corner, width and height of the Region of Interest area +and auto-controls currently being employed by the device are given by +the ``V4L2_SEL_TGT_ROI`` target. It uses the same coordinate system +as ``V4L2_SEL_TGT_ROI_BOUNDS_MIN`` and ``V4L2_SEL_TGT_ROI_BOUNDS_MAX``. + +In order to change active ROI top left, width and height coordinates +and ROI auto-controls use ``V4L2_SEL_TGT_ROI`` target. + +Each capture device has a default ROI rectangle and auto-controls +value given by the ``V4L2_SEL_TGT_ROI_DEFAULT`` target. Drivers shall +set the ROI rectangle to the default when the driver is first loaded, +but not later. diff --git a/Documentation/userspace-api/media/v4l/selection-api-examples.rst b/Documentation/userspace-api/media/v4l/selection-api-examples.rst index 5f8e8a1f59d7..ad2664888700 100644 --- a/Documentation/userspace-api/media/v4l/selection-api-examples.rst +++ b/Documentation/userspace-api/media/v4l/selection-api-examples.rst @@ -82,3 +82,31 @@ Example: Querying for scaling factors /* computing scaling factors */ hscale = (double)compose.r.width / crop.r.width; vscale = (double)compose.r.height / crop.r.height; + +Setting Region Of Interest area to half of the default value + +Example: Simple ROI +=========================== + +.. code-block:: c + + struct v4l2_selection roi = { + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, + .target = V4L2_SEL_TGT_ROI_DEFAULT, + }; + struct v4l2_rect r; + + ret = ioctl(fd, VIDIOC_G_SELECTION, &roi); + if (ret) + exit(-1); + /* setting smaller ROI rectangle */ + r.width = roi.r.width / 2; + r.height = roi.r.height / 2; + r.left = roi.r.width / 4; + r.top = roi.r.height / 4; + roi.r = r; + roi.target = V4L2_SEL_TGT_ROI; + roi.flags = V4L2_SEL_FLAG_ROI_AUTO_EXPOSURE; + ret = ioctl(fd, VIDIOC_S_SELECTION, &roi); + if (ret) + exit(-1); diff --git a/Documentation/userspace-api/media/v4l/v4l2-selection-targets.rst b/Documentation/userspace-api/media/v4l/v4l2-selection-targets.rst index b46bae984f35..d1dc9c50eb05 100644 --- a/Documentation/userspace-api/media/v4l/v4l2-selection-targets.rst +++ b/Documentation/userspace-api/media/v4l/v4l2-selection-targets.rst @@ -75,6 +75,30 @@ of the two interfaces they are used. modified by hardware. - Yes - No + * - ``V4L2_SEL_TGT_ROI`` + - 0x0200 + - Current Region of Interest rectangle and auto-controls value. + - Yes + - No + * - ``V4L2_SEL_TGT_ROI_DEFAULT`` + - 0x0201 + - Suggested Region of Interest rectangle and auto-controls value. + - Yes + - No + * - ``V4L2_SEL_TGT_ROI_BOUNDS_MIN`` + - 0x0202 + - Minimum bounds of the Region of Interest rectangle and minimum + auto-controls value. All valid ROI rectangles and auto-controls + should be within minimum-maximum range. + - Yes + - No + * - ``V4L2_SEL_TGT_ROI_BOUNDS_MAX`` + - 0x0203 + - Maximum bounds of the Region of Interest rectangle and maximum + auto-controls value. All valid ROI rectangles and auto-controls + should be within minimum-maximum range. + - Yes + - No .. raw:: latex -- 2.31.0.rc2.261.g7f71774620-goog