From patchwork Tue Apr 16 19:32:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789626 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C81D132801 for ; Tue, 16 Apr 2024 19:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296012; cv=none; b=U05trlPXIP06s9Q8V9km79X1RSyfLRsNw8xVoy5BdFb5+Mvsg5/b/pYzdWBohtjNqgoz55fqBXWZ9bNqohPJLZMkIN9L2aAGLMNZL6gI3onsaGPQDHL9ZWcupSR2VekLl9h18yAJ2eh5glUVozGDeS0/4a12amaa1aTRZzxJwF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296012; c=relaxed/simple; bh=r3x723Snzkjpcuach5hQ4+R9JXBfiUgeKKTHkL+GnYU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mrN6qtyfPrI0ZFTLzfbjhcJ8x1tk0QCRRVRjLbmVzZ4zZiVNq/CW1m+oOOZ+Sccs+hu6/DAk/fQV0JtG8qNkfyo773kptA3yMm3sK73yxurK+aAtWO6aC6D9Gy+pT3c81uSnLDBemPblyLMvhp1LhvgVFqMgycaAsuxncbwfNlU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GT4xbDpv; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GT4xbDpv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296011; x=1744832011; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r3x723Snzkjpcuach5hQ4+R9JXBfiUgeKKTHkL+GnYU=; b=GT4xbDpv/KB6uMswfmpqg5jqTpFVIYvr5FSTmRv28E3n78VRzE9WVjnl mvt0r6lfuYNy60hH22Axd7LTIuHgIztsJ24nO//ANK50Lymz9dzFBkkBM iEch8To0RXyOCgd+1zt/sA9K2DjK20Hh2rj0hqlbv33PJs2r9emYu6gDf CWNx6xTcyDJUAGSP5I1Ux1cJHASof7PBrv1MnXMpxUOLXhlmLHWQSuGkG p0qIR4Wgd0YhwhAVKxtu3amRS4F6Gry9djKXc240Su0IDgVQfaZbkfETE /fOiXJ8raK4UxACofSNYdvmt76q3560ECd7g7VPTNpZrkM1WTZcq7QszN A==; X-CSE-ConnectionGUID: jEGv5fETQD2rl/kIoT5xiw== X-CSE-MsgGUID: tVn4uukVSOOxvcy/d/xsSA== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8621183" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8621183" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:29 -0700 X-CSE-ConnectionGUID: GYdDlD/HToibATcMtmxeqw== X-CSE-MsgGUID: AItxn6U+SwSwZNggO74Ykg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22430681" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:27 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id DAEF41204F9; Tue, 16 Apr 2024 22:33:23 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 02/46] media: v4l2-subdev: Clearly document that the crop API won't be extended Date: Tue, 16 Apr 2024 22:32:35 +0300 Message-Id: <20240416193319.778192-3-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Laurent Pinchart The V4L2 subdev crop API has been marked as obsolete, deprecated by the selection API. Despite this, it has recently been extended with streams support. In hindsight this was a mistake. Make sure it doesn't happen again by clearly documenting that no new extensions will be accepted. Suggested-by: Hans Verkuil Signed-off-by: Laurent Pinchart Acked-by: Sakari Ailus Reviewed-by: Tomi Valkeinen Signed-off-by: Sakari Ailus --- .../userspace-api/media/v4l/vidioc-subdev-g-crop.rst | 6 +++--- include/uapi/linux/v4l2-subdev.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-crop.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-crop.rst index 92d933631fda..88a748103a71 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-crop.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-crop.rst @@ -37,9 +37,9 @@ Description .. note:: - This is an :ref:`obsolete` interface and may be removed - in the future. It is superseded by - :ref:`the selection API `. + This is an :ref:`obsolete` interface and may be removed in the future. It is + superseded by :ref:`the selection API `. No new + extensions to the :c:type:`v4l2_subdev_crop` structure will be accepted. To retrieve the current crop rectangle applications set the ``pad`` field of a struct :c:type:`v4l2_subdev_crop` to the diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h index 7048c51581c6..81a24bd38003 100644 --- a/include/uapi/linux/v4l2-subdev.h +++ b/include/uapi/linux/v4l2-subdev.h @@ -50,6 +50,10 @@ struct v4l2_subdev_format { * @rect: pad crop rectangle boundaries * @stream: stream number, defined in subdev routing * @reserved: drivers and applications must zero this array + * + * The subdev crop API is an obsolete interface and may be removed in the + * future. It is superseded by the selection API. No new extensions to this + * structure will be accepted. */ struct v4l2_subdev_crop { __u32 which; From patchwork Tue Apr 16 19:32:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789625 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 752231386C9 for ; Tue, 16 Apr 2024 19:33:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296014; cv=none; b=owWVlUpVjETNpfsuU0mqdsUoYrLd2RxdY9CKC9nt5/LaXjlkyMEhRCtzKp/D8HnzQFQu+5yrmUUi3RtSSOE+AH7g9U1dXQfrj4/8Xt/ThUPhOQKkQAbGveACUlU1GNtoCKufhHCP1RydtYHJM5Bv+pT+0sXC/gnBdF9g+zmkag0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296014; c=relaxed/simple; bh=Fv60f7XVEHDWWZHI4nzoa1A4KB0uiCOFaQyWbCrnlMI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K/RJNy+jokN6J4DKOp4nhAoezbAmi+hNsw/eLFrT+XNEGYmVUXLmk8KEc+pG2qZoAnFDI46FnGRIGgytVIvm9Lm38iYfkhcv2ife3k+rX1oYp7/hXlJec/L0nbS7F14XavtovYUdkzkV+9JF9bkQu/hJsh3PfeemETpgvpZO6b0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WBzEKEtL; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WBzEKEtL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296012; x=1744832012; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fv60f7XVEHDWWZHI4nzoa1A4KB0uiCOFaQyWbCrnlMI=; b=WBzEKEtLJRiCus/Wk1aS/FB+700UCvAMROLzS7gwSRxXPLrrekYe9wAE lqaDAVYF3OYnLMMOL0VJawLt7QX/lRWR2jMZ8DZn1cxPyiTwNYBKmAXP1 o1/UzWlnumsci+OnQV5qeTO7tTmRTJDm9lGqv5+s2WvOTV7KKsm6+Wyev zIAuWvAkoKd7XHT8nIfPdd73O4B9HpdIFtonvvIPBsC5pzQpYw48MPXfq AsY86WaVUn9c1wUpLWkOOWlLVI7xO4LalpECEiqpHE2oRGmbJe12KCV/i Siqs8Vb18hVeqf+xXhyfHDUBRek4qu2diw54W6eiCsgJV1R1T2TDZf0zO A==; X-CSE-ConnectionGUID: EU97snunSxSr78b4HafLlA== X-CSE-MsgGUID: /6tYzWHnSM6vj00rAlD1Bw== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8621201" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8621201" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:32 -0700 X-CSE-ConnectionGUID: jOwPwTq0T5ahpEhTPG2Ipw== X-CSE-MsgGUID: jAdJSXDVTGSCr3yd+xh+6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22430718" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:29 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 5CA7E12056F; Tue, 16 Apr 2024 22:33:26 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 04/46] media: uapi: Add generic serial metadata mbus formats Date: Tue, 16 Apr 2024 22:32:37 +0300 Message-Id: <20240416193319.778192-5-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add generic serial metadata mbus formats. These formats describe data width and packing but not the content itself. The reason for specifying such formats is that the formats as such are fairly device specific but they are still handled by CSI-2 receiver drivers that should not be aware of device specific formats. What makes generic metadata formats possible is that these formats are parsed by software only, after capturing the data to system memory. Also add a definition for "Data Unit" to cover what is essentially a pixel but is not image data. Signed-off-by: Sakari Ailus Reviewed-by: Laurent Pinchart --- .../userspace-api/media/glossary.rst | 9 + .../media/v4l/subdev-formats.rst | 255 ++++++++++++++++++ include/uapi/linux/media-bus-format.h | 9 + 3 files changed, 273 insertions(+) diff --git a/Documentation/userspace-api/media/glossary.rst b/Documentation/userspace-api/media/glossary.rst index ef0ab601b5bf..84dbded08b47 100644 --- a/Documentation/userspace-api/media/glossary.rst +++ b/Documentation/userspace-api/media/glossary.rst @@ -25,6 +25,15 @@ Glossary See :ref:`cec`. +.. _media-glossary-data-unit: + + Data Unit + + Unit of data transported by a bus. On parallel buses, the data unit + consists of one or more related samples while on serial buses the data + unit is logical. If the data unit is image data, it may also be called a + pixel. + Device Driver Part of the Linux Kernel that implements support for a hardware component. diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst index eb3cd20b0cf2..d9a5ee954cdd 100644 --- a/Documentation/userspace-api/media/v4l/subdev-formats.rst +++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst @@ -8306,3 +8306,258 @@ The following table lists the existing metadata formats. both sides of the link and the bus format is a fixed metadata format that is not configurable from userspace. Width and height will be set to 0 for this format. + +Generic Serial Metadata Formats +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Generic serial metadata formats are used on serial buses where the actual data +content is more or less device specific but the data is transmitted and received +by multiple devices that do not process the data in any way, simply writing +it to system memory for processing in software at the end of the pipeline. + +"b" in an array cell signifies a byte of data, followed by the number of the bit +and finally the bit number in subscript. "x" indicates a padding bit. + +.. _media-bus-format-generic-meta: + +.. cssclass: longtable + +.. flat-table:: Generic Serial Metadata Formats + :header-rows: 2 + :stub-columns: 0 + + * - Identifier + - Code + - + - :cspan:`23` Data organization within bus ``Data Unit + `` + * - + - + - Bit + - 23 + - 22 + - 21 + - 20 + - 19 + - 18 + - 17 + - 16 + - 15 + - 14 + - 13 + - 12 + - 11 + - 10 + - 9 + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + - 1 + - 0 + * .. _MEDIA-BUS-FMT-META-8: + + - MEDIA_BUS_FMT_META_8 + - 0x8001 + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - b0\ :sub:`7` + - b0\ :sub:`6` + - b0\ :sub:`5` + - b0\ :sub:`4` + - b0\ :sub:`3` + - b0\ :sub:`2` + - b0\ :sub:`1` + - b0\ :sub:`0` + * .. _MEDIA-BUS-FMT-META-10: + + - MEDIA_BUS_FMT_META_10 + - 0x8002 + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - b0\ :sub:`7` + - b0\ :sub:`6` + - b0\ :sub:`5` + - b0\ :sub:`4` + - b0\ :sub:`3` + - b0\ :sub:`2` + - b0\ :sub:`1` + - b0\ :sub:`0` + - x + - x + * .. _MEDIA-BUS-FMT-META-12: + + - MEDIA_BUS_FMT_META_12 + - 0x8003 + - + - + - + - + - + - + - + - + - + - + - + - + - + - b0\ :sub:`7` + - b0\ :sub:`6` + - b0\ :sub:`5` + - b0\ :sub:`4` + - b0\ :sub:`3` + - b0\ :sub:`2` + - b0\ :sub:`1` + - b0\ :sub:`0` + - x + - x + - x + - x + * .. _MEDIA-BUS-FMT-META-14: + + - MEDIA_BUS_FMT_META_14 + - 0x8004 + - + - + - + - + - + - + - + - + - + - + - + - b0\ :sub:`7` + - b0\ :sub:`6` + - b0\ :sub:`5` + - b0\ :sub:`4` + - b0\ :sub:`3` + - b0\ :sub:`2` + - b0\ :sub:`1` + - b0\ :sub:`0` + - x + - x + - x + - x + - x + - x + * .. _MEDIA-BUS-FMT-META-16: + + - MEDIA_BUS_FMT_META_16 + - 0x8005 + - + - + - + - + - + - + - + - + - + - b0\ :sub:`7` + - b0\ :sub:`6` + - b0\ :sub:`5` + - b0\ :sub:`4` + - b0\ :sub:`3` + - b0\ :sub:`2` + - b0\ :sub:`1` + - b0\ :sub:`0` + - x + - x + - x + - x + - x + - x + - x + - x + * .. _MEDIA-BUS-FMT-META-20: + + - MEDIA_BUS_FMT_META_20 + - 0x8006 + - + - + - + - + - + - b0\ :sub:`7` + - b0\ :sub:`6` + - b0\ :sub:`5` + - b0\ :sub:`4` + - b0\ :sub:`3` + - b0\ :sub:`2` + - b0\ :sub:`1` + - b0\ :sub:`0` + - x + - x + - x + - x + - x + - x + - x + - x + - x + - x + - x + - x + * .. _MEDIA-BUS-FMT-META-24: + + - MEDIA_BUS_FMT_META_24 + - 0x8007 + - + - b0\ :sub:`7` + - b0\ :sub:`6` + - b0\ :sub:`5` + - b0\ :sub:`4` + - b0\ :sub:`3` + - b0\ :sub:`2` + - b0\ :sub:`1` + - b0\ :sub:`0` + - x + - x + - x + - x + - x + - x + - x + - x + - x + - x + - x + - x + - x + - x + - x + - x diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h index f05f747e444d..d4c1d991014b 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -174,4 +174,13 @@ */ #define MEDIA_BUS_FMT_METADATA_FIXED 0x7001 +/* Generic line based metadata formats for serial buses. Next is 0x8008. */ +#define MEDIA_BUS_FMT_META_8 0x8001 +#define MEDIA_BUS_FMT_META_10 0x8002 +#define MEDIA_BUS_FMT_META_12 0x8003 +#define MEDIA_BUS_FMT_META_14 0x8004 +#define MEDIA_BUS_FMT_META_16 0x8005 +#define MEDIA_BUS_FMT_META_20 0x8006 +#define MEDIA_BUS_FMT_META_24 0x8007 + #endif /* __LINUX_MEDIA_BUS_FORMAT_H */ From patchwork Tue Apr 16 19:32:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789624 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 671F81386B3 for ; Tue, 16 Apr 2024 19:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296019; cv=none; b=biOt9xzk3cpj/IiL6dqvEqRTFIMiZjhdwvtzu3+bS+oF3s9Pj3kQ2ifpzXkueWHXQE5NsFsBfWnMD3Ap+ocxLfHovrJWb+Fn07pL6WZhRR76qnAHhAcAi7O2Ti10P4VEZsfRjhsSB8auOFADBJqSj34DiiwuMHaJWIzaRJfjU6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296019; c=relaxed/simple; bh=wMW5ETOxTOfoOuhHFlmuBiBeSQyGdiytdXmgxqpbNls=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bi/skfjDI1k4iY6IHX90CRaqhvFgVgIlu29HJ9wkzZWq2oHZv1QZgK/Vm9YbLI47KCv/hrQyu3El0lcA+04eAaB1UGzxXGJH+FM+jQ5r/TKkfRS+hTSNvGjSu+lKqhNXwNxKLxHQDRmI2GSAHkXPS9DY797my3WYa83mR7WT8CQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DTmoKoP1; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DTmoKoP1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296018; x=1744832018; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wMW5ETOxTOfoOuhHFlmuBiBeSQyGdiytdXmgxqpbNls=; b=DTmoKoP1vp6+GeGMPJ2ihxVgOFv+KD5fvFxixS86lR9cF/Irx66f1Hfr o2CO+PoghrV/ELjLnwmDR3JKMYDgcNeQEFoh2E8QNoK381BgHf6TBsZxX 6kc7vBLulSVl0uCx8DtP1fEb5h2yoxpQQzoDunfwK6DsGQrmgQnsHRoJs GZThi+W6/VV0RC4xhohLYDHC8gKvuwAlHA8l9mpPVKtzS1fpmZ9iEMnj5 sPTtr166WZ0xLkQfzFi4+uzoGL220/XzlzOIiLXY1Ywf6uJvDOhOKVIYi N5Iw/uk9S3aV2HqX4IE/fqBIlQft0l4YQJcNMJkpMtcBXyhIepbV0CEbg A==; X-CSE-ConnectionGUID: 5V7oxZicQL+Qi6uTWFYZ4g== X-CSE-MsgGUID: h4WtvfbGTTeW/UyPB5ixWg== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="19906034" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="19906034" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:37 -0700 X-CSE-ConnectionGUID: DEozAG8kQPKM7aeptKwdtA== X-CSE-MsgGUID: YokMLeh+RI6Ku+aE8c/XyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="27155265" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:34 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 858E91204F6; Tue, 16 Apr 2024 22:33:29 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 06/46] media: uapi: v4l: Add generic 8-bit metadata format definitions Date: Tue, 16 Apr 2024 22:32:39 +0300 Message-Id: <20240416193319.778192-7-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Generic 8-bit metadata formats define the in-memory data layout but not the format of the data itself. The reasoning for having such formats is to allow CSI-2 receiver drivers to receive and DMA drivers to write the data to memory without knowing a large number of device-specific formats. These formats may be used only in conjunction with a Media controller pipeline where the internal pad of the source sub-device defines the specific format of the data (using an mbus code). Signed-off-by: Sakari Ailus --- .../userspace-api/media/v4l/dev-subdev.rst | 2 + .../userspace-api/media/v4l/meta-formats.rst | 3 +- .../media/v4l/metafmt-generic.rst | 328 ++++++++++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 7 + include/uapi/linux/videodev2.h | 8 + 5 files changed, 347 insertions(+), 1 deletion(-) create mode 100644 Documentation/userspace-api/media/v4l/metafmt-generic.rst diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst index 43988516acdd..f375b820ab68 100644 --- a/Documentation/userspace-api/media/v4l/dev-subdev.rst +++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst @@ -506,6 +506,8 @@ source pads. subdev-formats +.. _subdev-routing: + Streams, multiplexed media pads and internal routing ---------------------------------------------------- diff --git a/Documentation/userspace-api/media/v4l/meta-formats.rst b/Documentation/userspace-api/media/v4l/meta-formats.rst index 0bb61fc5bc00..c23aac823d2c 100644 --- a/Documentation/userspace-api/media/v4l/meta-formats.rst +++ b/Documentation/userspace-api/media/v4l/meta-formats.rst @@ -13,9 +13,10 @@ These formats are used for the :ref:`metadata` interface only. :maxdepth: 1 metafmt-d4xx + metafmt-generic metafmt-intel-ipu3 metafmt-rkisp1 metafmt-uvc + metafmt-vivid metafmt-vsp1-hgo metafmt-vsp1-hgt - metafmt-vivid diff --git a/Documentation/userspace-api/media/v4l/metafmt-generic.rst b/Documentation/userspace-api/media/v4l/metafmt-generic.rst new file mode 100644 index 000000000000..cba34be64dfe --- /dev/null +++ b/Documentation/userspace-api/media/v4l/metafmt-generic.rst @@ -0,0 +1,328 @@ +.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later + +******************************************************************************************************************************************************************************************************************************************************************************** +V4L2_META_FMT_GENERIC_8 ('MET8'), V4L2_META_FMT_GENERIC_CSI2_10 ('MC1A'), V4L2_META_FMT_GENERIC_CSI2_12 ('MC1C'), V4L2_META_FMT_GENERIC_CSI2_14 ('MC1E'), V4L2_META_FMT_GENERIC_CSI2_16 ('MC1G'), V4L2_META_FMT_GENERIC_CSI2_20 ('MC1K'), V4L2_META_FMT_GENERIC_CSI2_24 ('MC1O') +******************************************************************************************************************************************************************************************************************************************************************************** + + +Generic line-based metadata formats + + +Description +=========== + +These generic line-based metadata formats define the memory layout of the data +without defining the format or meaning of the metadata itself. These formats may +only be used with a Media Controller pipeline where the more specific format is +reported by an :ref:`internal sink pad ` of the source +sub-device. See also :ref:`source routes `. + +.. _v4l2-meta-fmt-generic-8: + +V4L2_META_FMT_GENERIC_8 +----------------------- + +The V4L2_META_FMT_GENERIC_8 format is a plain 8-bit metadata format. + +This format is also used on CSI-2 for both 8 bits per ``Data Unit +`` as well as for 16 bits per Data Unit when two bytes +of metadata are packed into one 16-bit Data Unit. + +**Byte Order Of V4L2_META_FMT_GENERIC_8.** +Each cell is one byte. "M" denotes a byte of metadata. + +.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}| + +.. flat-table:: Sample 4x2 Metadata Frame + :header-rows: 0 + :stub-columns: 0 + :widths: 12 8 8 8 8 + + * - start + 0: + - M\ :sub:`00` + - M\ :sub:`10` + - M\ :sub:`20` + - M\ :sub:`30` + * - start + 4: + - M\ :sub:`01` + - M\ :sub:`11` + - M\ :sub:`21` + - M\ :sub:`31` + +.. _v4l2-meta-fmt-generic-csi2-10: + +V4L2_META_FMT_GENERIC_CSI2_10 +----------------------------- + +V4L2_META_FMT_GENERIC_CSI2_10 contains 8-bit generic metadata packed in 10-bit +Data Units, with one padding byte after every four bytes of metadata. This +format is typically used by CSI-2 receivers with a source that transmits +MEDIA_BUS_FMT_META_10 and the CSI-2 receiver writes the received data to memory +as-is. + +The packing of the data follows the MIPI CSI-2 specification and the padding of +the data is defined in the MIPI CCS specification. + +This format is also used in conjunction with 20 bits per ``Data Unit +`` formats that pack two bytes of metadata into one +Data Unit. + +This format is little endian. + +**Byte Order Of V4L2_META_FMT_GENERIC_CSI2_10.** +Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding. + +.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{.8cm}| + +.. flat-table:: Sample 4x2 Metadata Frame + :header-rows: 0 + :stub-columns: 0 + :widths: 12 8 8 8 8 8 + + * - start + 0: + - M\ :sub:`00` + - M\ :sub:`10` + - M\ :sub:`20` + - M\ :sub:`30` + - x + * - start + 5: + - M\ :sub:`01` + - M\ :sub:`11` + - M\ :sub:`21` + - M\ :sub:`31` + - x + +.. _v4l2-meta-fmt-generic-csi2-12: + +V4L2_META_FMT_GENERIC_CSI2_12 +----------------------------- + +V4L2_META_FMT_GENERIC_CSI2_12 contains 8-bit generic metadata packed in 12-bit +Data Units, with two padding bytes after every four bytes of metadata. This +format is typically used by CSI-2 receivers with a source that transmits +MEDIA_BUS_FMT_META_12 and the CSI-2 receiver writes the received data to memory +as-is. + +The packing of the data follows the MIPI CSI-2 specification and the padding of +the data is defined in the MIPI CCS specification. + +This format is also used in conjunction with 24 bits per ``Data Unit +`` formats that pack two bytes of metadata into one +Data Unit. + +This format is little endian. + +**Byte Order Of V4L2_META_FMT_GENERIC_CSI2_12.** +Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding. + +.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{.8cm}|p{.8cm}| + +.. flat-table:: Sample 4x2 Metadata Frame + :header-rows: 0 + :stub-columns: 0 + :widths: 12 8 8 8 8 8 8 + + * - start + 0: + - M\ :sub:`00` + - M\ :sub:`10` + - x + - M\ :sub:`20` + - M\ :sub:`30` + - x + * - start + 6: + - M\ :sub:`01` + - M\ :sub:`11` + - x + - M\ :sub:`21` + - M\ :sub:`31` + - x + +.. _v4l2-meta-fmt-generic-csi2-14: + +V4L2_META_FMT_GENERIC_CSI2_14 +----------------------------- + +V4L2_META_FMT_GENERIC_CSI2_14 contains 8-bit generic metadata packed in 14-bit +Data Units, with three padding bytes after every four bytes of metadata. This +format is typically used by CSI-2 receivers with a source that transmits +MEDIA_BUS_FMT_META_14 and the CSI-2 receiver writes the received data to memory +as-is. + +The packing of the data follows the MIPI CSI-2 specification and the padding of +the data is defined in the MIPI CCS specification. + +This format is little endian. + +**Byte Order Of V4L2_META_FMT_GENERIC_CSI2_14.** +Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding. + +.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{1.2cm}|p{.8cm}|p{.8cm}|p{.8cm}| + +.. flat-table:: Sample 4x2 Metadata Frame + :header-rows: 0 + :stub-columns: 0 + :widths: 12 8 8 8 8 8 8 8 + + * - start + 0: + - M\ :sub:`00` + - M\ :sub:`10` + - M\ :sub:`20` + - M\ :sub:`30` + - x + - x + - x + * - start + 7: + - M\ :sub:`01` + - M\ :sub:`11` + - M\ :sub:`21` + - M\ :sub:`31` + - x + - x + - x + +.. _v4l2-meta-fmt-generic-csi2-16: + +V4L2_META_FMT_GENERIC_CSI2_16 +----------------------------- + +V4L2_META_FMT_GENERIC_CSI2_16 contains 8-bit generic metadata packed in 16-bit +Data Units, with one padding byte after every byte of metadata. This format is +typically used by CSI-2 receivers with a source that transmits +MEDIA_BUS_FMT_META_16 and the CSI-2 receiver writes the received data to memory +as-is. + +The packing of the data follows the MIPI CSI-2 specification and the padding of +the data is defined in the MIPI CCS specification. + +This format is little endian. + +**Byte Order Of V4L2_META_FMT_GENERIC_CSI2_16.** +Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding. + +.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{1.2cm}|p{.8cm}| + +.. flat-table:: Sample 4x2 Metadata Frame + :header-rows: 0 + :stub-columns: 0 + :widths: 12 8 8 8 8 8 8 8 8 + + * - start + 0: + - M\ :sub:`00` + - x + - M\ :sub:`10` + - x + - M\ :sub:`20` + - x + - M\ :sub:`30` + - x + * - start + 8: + - M\ :sub:`01` + - x + - M\ :sub:`11` + - x + - M\ :sub:`21` + - x + - M\ :sub:`31` + - x + +.. _v4l2-meta-fmt-generic-csi2-20: + +V4L2_META_FMT_GENERIC_CSI2_20 +----------------------------- + +V4L2_META_FMT_GENERIC_CSI2_20 contains 8-bit generic metadata packed in 20-bit +Data Units, with alternating one or two padding bytes after every byte of +metadata. This format is typically used by CSI-2 receivers with a source that +transmits MEDIA_BUS_FMT_META_20 and the CSI-2 receiver writes the received data +to memory as-is. + +The packing of the data follows the MIPI CSI-2 specification and the padding of +the data is defined in the MIPI CCS specification. + +This format is little endian. + +**Byte Order Of V4L2_META_FMT_GENERIC_CSI2_20.** +Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding. + +.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{.8cm}| + +.. flat-table:: Sample 4x2 Metadata Frame + :header-rows: 0 + :stub-columns: 0 + :widths: 12 8 8 8 8 8 8 8 8 8 8 + + * - start + 0: + - M\ :sub:`00` + - x + - M\ :sub:`10` + - x + - x + - M\ :sub:`20` + - x + - M\ :sub:`30` + - x + - x + * - start + 10: + - M\ :sub:`01` + - x + - M\ :sub:`11` + - x + - x + - M\ :sub:`21` + - x + - M\ :sub:`31` + - x + - x + +.. _v4l2-meta-fmt-generic-csi2-24: + +V4L2_META_FMT_GENERIC_CSI2_24 +----------------------------- + +V4L2_META_FMT_GENERIC_CSI2_24 contains 8-bit generic metadata packed in 24-bit +Data Units, with two padding bytes after every byte of metadata. This format is +typically used by CSI-2 receivers with a source that transmits +MEDIA_BUS_FMT_META_24 and the CSI-2 receiver writes the received data to memory +as-is. + +The packing of the data follows the MIPI CSI-2 specification and the padding of +the data is defined in the MIPI CCS specification. + +This format is little endian. + +**Byte Order Of V4L2_META_FMT_GENERIC_CSI2_24.** +Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding. + +.. tabularcolumns:: |p{2.4cm}|p{1.2cm}|p{.8cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{.8cm}|p{1.2cm}|p{.8cm}|p{.8cm}| + +.. flat-table:: Sample 4x2 Metadata Frame + :header-rows: 0 + :stub-columns: 0 + :widths: 12 8 8 8 8 8 8 8 8 8 8 8 8 + + * - start + 0: + - M\ :sub:`00` + - x + - x + - M\ :sub:`10` + - x + - x + - M\ :sub:`20` + - x + - x + - M\ :sub:`30` + - x + - x + * - start + 12: + - M\ :sub:`01` + - x + - x + - M\ :sub:`11` + - x + - x + - M\ :sub:`21` + - x + - x + - M\ :sub:`31` + - x + - x diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 5aeff5519407..ae2dca7f2817 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1460,6 +1460,13 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_PIX_FMT_Y210: descr = "10-bit YUYV Packed"; break; case V4L2_PIX_FMT_Y212: descr = "12-bit YUYV Packed"; break; case V4L2_PIX_FMT_Y216: descr = "16-bit YUYV Packed"; break; + case V4L2_META_FMT_GENERIC_8: descr = "8-bit Generic Metadata"; break; + case V4L2_META_FMT_GENERIC_CSI2_10: descr = "8-bit Generic Meta, 10b CSI-2"; break; + case V4L2_META_FMT_GENERIC_CSI2_12: descr = "8-bit Generic Meta, 12b CSI-2"; break; + case V4L2_META_FMT_GENERIC_CSI2_14: descr = "8-bit Generic Meta, 14b CSI-2"; break; + case V4L2_META_FMT_GENERIC_CSI2_16: descr = "8-bit Generic Meta, 16b CSI-2"; break; + case V4L2_META_FMT_GENERIC_CSI2_20: descr = "8-bit Generic Meta, 20b CSI-2"; break; + case V4L2_META_FMT_GENERIC_CSI2_24: descr = "8-bit Generic Meta, 24b CSI-2"; break; default: /* Compressed formats */ diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 2663213b76a4..c7cf20b5da67 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -839,6 +839,14 @@ struct v4l2_pix_format { #define V4L2_META_FMT_RK_ISP1_PARAMS v4l2_fourcc('R', 'K', '1', 'P') /* Rockchip ISP1 3A Parameters */ #define V4L2_META_FMT_RK_ISP1_STAT_3A v4l2_fourcc('R', 'K', '1', 'S') /* Rockchip ISP1 3A Statistics */ +#define V4L2_META_FMT_GENERIC_8 v4l2_fourcc('M', 'E', 'T', '8') /* Generic 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_10 v4l2_fourcc('M', 'C', '1', 'A') /* 10-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_12 v4l2_fourcc('M', 'C', '1', 'C') /* 12-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_14 v4l2_fourcc('M', 'C', '1', 'E') /* 14-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_16 v4l2_fourcc('M', 'C', '1', 'G') /* 16-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_20 v4l2_fourcc('M', 'C', '1', 'K') /* 20-bit CSI-2 packed 8-bit metadata */ +#define V4L2_META_FMT_GENERIC_CSI2_24 v4l2_fourcc('M', 'C', '1', 'O') /* 24-bit CSI-2 packed 8-bit metadata */ + /* priv field value to indicates that subsequent fields are valid. */ #define V4L2_PIX_FMT_PRIV_MAGIC 0xfeedcafe From patchwork Tue Apr 16 19:32:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789623 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F703139D01 for ; Tue, 16 Apr 2024 19:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296020; cv=none; b=UNZeRlmTJPuXtj0YYyDay9xYPpZBtSR6TXnuJlYg78xTzFLKLN6XiE7KUqa1R1DjmxiZK0rUM08WvW7wJaCHaejz2DW7jKFCuCAibraT4FqtebJ8sljL0QncAfCPqMMVw5lB4mXw5mzmZ+KbmLngauUyg5fDPFJRc4WaXBZRTo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296020; c=relaxed/simple; bh=9NVcs+CPjK/NLXHVLxYJeBlkgHJ6cOnfdXWiFvZE//s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SIWmHIj4bKecOUxGpC4VRNBpilp3AbADnZVS0+1R6r/kaEs1//C1ze5ZVhP+suQB7JM/Tjv4Hv3hDt9UE9rHS7q8zr6tHMNFOVI64WoAtqBb7YdUEQIee8bsQaobyvjE1CpmrvocZP6HpjZf5Rh8087N9Uner0hIm0CNaY+P+jk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gLz/4cDx; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gLz/4cDx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296020; x=1744832020; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9NVcs+CPjK/NLXHVLxYJeBlkgHJ6cOnfdXWiFvZE//s=; b=gLz/4cDxFNxSbL2Q430wBJxouxoV3je8nOKeGfTqB5A44xX/TkGHEcNs bMcOdLhmoLJ4b+W6uqO7cXqeaDqtldbvxXKUPhNEkxLUwBaQSc4dSa69E JGFv5YSPU75yyn2P5+v0skVQ14HSlIpNg2aoPn/aDrJLKUHYyFeTTlNpv zXh8090xEG787YGS2+BHSto7nukKZ8orsv7cPCFM5YUPfdKhz+S213wXp mShPvDatKL6XYPPg0PZ8NL8eAFCDTYlpUdNCLrL5ZYv2iAykgICspxyrl Ki56WpRZjtB1EWGJDk3+DT0FvYryR361nQ2yoaWWSh6nbqLFVb9imtLCW g==; X-CSE-ConnectionGUID: VYeuttgxRLayofDQXiYN/Q== X-CSE-MsgGUID: RWkJ204yQFSQuajQZqjq/w== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="19906045" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="19906045" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:39 -0700 X-CSE-ConnectionGUID: DyG+bwgdR9Kn8oSiii7Mcg== X-CSE-MsgGUID: iwHIyuS9QRysHeVCTlMaMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="27155273" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:36 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 5C0A012053D; Tue, 16 Apr 2024 22:33:32 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 08/46] media: Documentation: Additional streams generally don't harm capture Date: Tue, 16 Apr 2024 22:32:41 +0300 Message-Id: <20240416193319.778192-9-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Having extra streams on the source end of the link that cannot be captured by the sink sub-device generally are not an issue, at least not on CSI-2 bus. Still document that there may be hardware-specific limitations. For example on parallel bus this might not work on all cases. Signed-off-by: Sakari Ailus Reviewed-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- Documentation/userspace-api/media/v4l/dev-subdev.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst index f375b820ab68..b76e02e54512 100644 --- a/Documentation/userspace-api/media/v4l/dev-subdev.rst +++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst @@ -529,9 +529,9 @@ the its sink pad and allows to route them individually to one of its source pads. Subdevice drivers that support multiplexed streams are compatible with -non-multiplexed subdev drivers, but, of course, require a routing configuration -where the link between those two types of drivers contains only a single -stream. +non-multiplexed subdev drivers. However, if the driver at the sink end of a link +does not support streams, then only stream 0 of source end may be captured. +There may be additional limitations specific to the sink device. Understanding streams ^^^^^^^^^^^^^^^^^^^^^ From patchwork Tue Apr 16 19:32:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789622 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C20BD139D01 for ; Tue, 16 Apr 2024 19:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296023; cv=none; b=lMyciVx1mQR5z3JztzA5PPFLG+W7wo16PldRKhkmx9jKnQvCRdkcINbr2CPduR/Ydua6gBDZspv+2Ym2iJ+/JYU7uBXVD/6mGSQJrUxcwkZ6doNCLiv2cX5jT12+DiDaJxeAjePNF9skD1Hguf6VZ2QLGNfGT2+bQ7voqu7AUis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296023; c=relaxed/simple; bh=2hHBHb9a2LHDXxsOGs2nNxxqI4BCTfEtOUY1FDAPwVc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Wv1LfS5bj3gcVA1RgoxaYL+teCvmbOzRvg3sYGVJMA8kMx7n6kAamGXx/NNpBcLJUvtE2fP2zSkEmdCQF19g24/y+cqzMcRxaNQeEphXmHGpVzEta3akHTo4zo46WA9qmIHrmgDsR8iethw9bIANXcjXTmMwxjyfo+3wFkYpgvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eqxy+QHR; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eqxy+QHR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296022; x=1744832022; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2hHBHb9a2LHDXxsOGs2nNxxqI4BCTfEtOUY1FDAPwVc=; b=eqxy+QHRNSi0NHUu4WhLcTYLMiOfC28/QkVl5LsK3G/TftVAI+5+dPzx Vkri41NhI3qs5Lb+2YilLTHVMhNJ6mBagoTlE5WVi/fgKFClu3A60lkVX HiSt9KodzIJKg1D5NNC5399cvOPo0Hs41K7o4hyc2gmjDYIwOES1rp46n s8sGWIeOMqn+oJJB58QlIm/ikm0OE6yVJ7vmhCO9rIx75obhVmZW3KQJV N0jb1TmkbzjZQSO1SAe23R/TVsil1DisoC0wGLvL/6aU93KQ0DyNlpoyn tCwoF2jryHGKbYbNgtZ8i6Z2OoFIpjzTmzI7Y8H1Jc4+TD00uC6HyXlcD Q==; X-CSE-ConnectionGUID: EEi7DHMYRciiZcVyjit/6w== X-CSE-MsgGUID: AKlfXrCMR3eUQidqfkYfQw== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="19906062" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="19906062" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:42 -0700 X-CSE-ConnectionGUID: XXibV3UET+yYjnzfCVe7bQ== X-CSE-MsgGUID: 9zIc7MUhQlanw9dSz85O6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="27155285" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:39 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 320E312056F; Tue, 16 Apr 2024 22:33:35 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 10/46] media: Documentation: v4l: Document internal sink pads Date: Tue, 16 Apr 2024 22:32:43 +0300 Message-Id: <20240416193319.778192-11-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Document internal sink pads, pads that have both SINK and INTERNAL flags set. Use the IMX219 camera sensor as an example. Signed-off-by: Sakari Ailus Reviewed-by Julien Massot --- .../userspace-api/media/v4l/dev-subdev.rst | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst index b76e02e54512..d30dcb9e2537 100644 --- a/Documentation/userspace-api/media/v4l/dev-subdev.rst +++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst @@ -553,6 +553,27 @@ A stream at a specific point in the media pipeline is identified by the sub-device and a (pad, stream) pair. For sub-devices that do not support multiplexed streams the 'stream' field is always 0. +.. _v4l2-subdev-internal-source-pads: + +Internal sink pads and routing +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Cases where a single sub-device source pad is traversed by multiple streams, one +or more of which originate from within the sub-device itself, are special as +there is no external sink pad for such routes. In those cases, the sources of +the internally generated streams are represented by internal sink pads, which +are sink pads that have the :ref:`MEDIA_PAD_FL_INTERNAL ` +pad flag set. + +Internal pads have all the properties of an external pad, including formats and +selections. The format in this case is the source format of the stream. An +internal pad always has a single stream only (0). + +Routes from an internal sink pad to an external source pad are typically not +modifiable but they can be activated and deactivated using the +:ref:`V4L2_SUBDEV_ROUTE_FL_ACTIVE ` flag, depending +on driver capabilities. + Interaction between routes, streams, formats and selections ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -668,3 +689,127 @@ To configure this pipeline, the userspace must take the following steps: the configurations along the stream towards the receiver, using :ref:`VIDIOC_SUBDEV_S_FMT ` ioctls to configure each stream endpoint in each sub-device. + +Internal pads setup example +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A simple example of a multiplexed stream setup might be as follows: + +- An IMX219 camera sensor source sub-device, with one source pad (0), one + internal sink pad (1) as the source of the image data and an internal sink + pad (2) as the source of the embedded data. There are two routes, one from the + internal sink pad 1 to the source 0 (image data) and another from the internal + sink pad 2 to the source pad 0 (embedded data). Both streams are always + active, i.e. there is no need to separately enable the embedded data + stream. The sensor uses the CSI-2 interface. + +- A CSI-2 receiver in the SoC. The receiver has a single sink pad (pad 0), + connected to the sensor, and two source pads (pads 1 and 2), to the DMA + engine. The receiver demultiplexes the incoming streams to the source pads. + +- DMA engines in the SoC, one for each stream. Each DMA engine is connected to a + single source pad of the receiver. + +The sensor and the receiver are modelled as V4L2 sub-devices, exposed to +userspace via /dev/v4l-subdevX device nodes. The DMA engines are modelled as +V4L2 devices, exposed to userspace via /dev/videoX nodes. + +To configure this pipeline, the userspace must take the following steps: + +1) Set up media links between entities: enable the links from the sensor to the + receiver and from the receiver to the DMA engines. This step does not differ + from normal non-multiplexed media controller setup. + +2) Configure routing + +.. flat-table:: Camera sensor. There are no configurable routes. + :header-rows: 1 + + * - Sink Pad/Stream + - Source Pad/Stream + - Routing Flags + - Comments + * - 1/0 + - 0/0 + - V4L2_SUBDEV_ROUTE_FL_ACTIVE + - Pixel data stream from the sink pad + * - 2/0 + - 0/1 + - V4L2_SUBDEV_ROUTE_FL_ACTIVE + - Metadata stream from the internal sink pad + +.. flat-table:: Receiver routing table. Typically both routes need to be + explicitly set. + :header-rows: 1 + + * - Sink Pad/Stream + - Source Pad/Stream + - Routing Flags + - Comments + * - 0/0 + - 1/0 + - V4L2_SUBDEV_ROUTE_FL_ACTIVE + - Pixel data stream from camera sensor + * - 0/1 + - 2/0 + - V4L2_SUBDEV_ROUTE_FL_ACTIVE + - Metadata stream from camera sensor + +The options available in sensor's routing configuration are dictated by hardware +capabilities: typically camera sensors always produce an image data stream while +it may be possible to enable and disable the embedded data stream. + +3) Configure formats and selections + + This example assumes that the formats are propagated from sink pad to the + source pad as-is. The tables contain fields of both struct v4l2_subdev_format + and struct v4l2_mbus_framefmt. + +.. flat-table:: Formats set on the sub-devices. Bold values are set, others are + static or propagated. The order is aligned with configured + routes. + :header-rows: 1 + :fill-cells: + + * - Sub-device + - Pad/Stream + - Width + - Height + - Code + * - :rspan:`3` IMX219 + - 1/0 + - 3296 + - 2480 + - MEDIA_BUS_FMT_SRGGB10 + * - 0/0 + - **3296** + - **2480** + - **MEDIA_BUS_FMT_SRGGB10** + * - 2/0 + - 3296 + - 2 + - MEDIA_BUS_FMT_IMX219_EMBEDDED + * - 1/1 + - 3296 + - 2 + - MEDIA_BUS_FMT_META_10 + * - :rspan:`3` CSI-2 receiver + - 0/0 + - **3296** + - **2480** + - **MEDIA_BUS_FMT_SRGGB10** + * - 1/0 + - 3296 + - 2480 + - MEDIA_BUS_FMT_SRGGB10 + * - 0/1 + - **3296** + - **2** + - **MEDIA_BUS_FMT_META_10** + * - 2/0 + - 3296 + - 2 + - MEDIA_BUS_FMT_META_10 + +The embedded data format does not need to be configured as the format is +dictated by the pixel data format in this case. From patchwork Tue Apr 16 19:32:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789621 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD3FC13A3ED for ; Tue, 16 Apr 2024 19:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296026; cv=none; b=lyDQmhUubVatVTnIVT0Bs62YCYmD33GrCV0rHOhYkbUORaC7PRAgg18o1wXF+/m2REk6X1vCF1cHmMPP5VkD4Y2TdS6MnFu/l0ynSAXm7wMV66x9yxHFPUgKmMv/jW4mET96I107Tf6Qeo8YogED/4iE/PKIG1pHOofTsc/cxGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296026; c=relaxed/simple; bh=x1q2jYT7l6M/yyygGuOEuPh9b460A8OkfyHWmdoji1o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pVHBJ+GmWAM6losg07UXfYLguQXOAt/RuFfaaf+s3472I/g+TUSUjI3M5ENFjnwFNe+WC3MhEMPesSO5UOoSo4Bbxlb4nUamLS6ycybn+IMATTi2bD3y8sMRCtIVwst6OuqRbhP9Kz1OBPAmhgHpXb19GNmjYlvLawgWdWtzhK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VHyBw438; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VHyBw438" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296024; x=1744832024; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x1q2jYT7l6M/yyygGuOEuPh9b460A8OkfyHWmdoji1o=; b=VHyBw438+V+2I1bsutdD8lo1utuESOaNTg/DaJIdezV6uwG7yU+jz5WM c8t9mkFeHxPrug2Fh9p3r5PpriQMoyrtsoa3bNEWu+KMp6x2vkfdqgEPs nfFB+UaViChzMWjTdGV9iHmxMEL4IP6vqN+dTQoJu5ymHd5AWLaD967X0 p3SrosSxrOxmRJR46ZDWxi+vhLghixdXeTRvzB5YgWnXl1s9/+P8wFAii TTBPNhIMiPI9rt9hh07HjKD2Lh13eOTvpMplXec2XwCo+oj4EuUKMKEhQ Y5CulnLQP79Z0ukMPZWGv9tfRAZpSFDuinb4ZQRV4tEKd8nvRZKVmdeyc w==; X-CSE-ConnectionGUID: uVHOcIAGRYCrCNM2hm/tPg== X-CSE-MsgGUID: lelZGV1oQ6aoxm3fO2elzw== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="19906075" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="19906075" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:44 -0700 X-CSE-ConnectionGUID: zxdqdfvES3yZVIXMUEtmEA== X-CSE-MsgGUID: ofbD8i5kQuyBnsNhUUUApw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="27155292" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:41 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id D3A871204F6; Tue, 16 Apr 2024 22:33:37 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 12/46] media: v4l: subdev: Add a function to lock two sub-device states, use it Date: Tue, 16 Apr 2024 22:32:45 +0300 Message-Id: <20240416193319.778192-13-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add two new functions, v4l2_subdev_lock_states() and v4l2_subdev_unclock_states(), to acquire and release the state of two sub-devices. They differ from calling v4l2_subdev_{un,}lock_state() so that if the two states share the same lock, the lock is acquired only once. Also use the new functions in v4l2_subdev_link_validate(). Signed-off-by: Sakari Ailus Reviewed-by: Julien Massot Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-subdev.c | 12 +++----- include/media/v4l2-subdev.h | 40 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 45836f0a2b0a..4b1b310b5d68 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1402,17 +1402,13 @@ int v4l2_subdev_link_validate(struct media_link *link) states_locked = sink_state && source_state; - if (states_locked) { - v4l2_subdev_lock_state(sink_state); - v4l2_subdev_lock_state(source_state); - } + if (states_locked) + v4l2_subdev_lock_states(sink_state, source_state); ret = v4l2_subdev_link_validate_locked(link, states_locked); - if (states_locked) { - v4l2_subdev_unlock_state(sink_state); - v4l2_subdev_unlock_state(source_state); - } + if (states_locked) + v4l2_subdev_unlock_states(sink_state, source_state); return ret; } diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index a9e6b8146279..9cce48365975 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1724,6 +1724,46 @@ static inline void v4l2_subdev_unlock_state(struct v4l2_subdev_state *state) mutex_unlock(state->lock); } +/** + * v4l2_subdev_lock_states - Lock two sub-device states + * @state1: One subdevice state + * @state2: The other subdevice state + * + * Locks the state of two sub-devices. + * + * The states must be unlocked with v4l2_subdev_unlock_states() after use. + * + * This differs from calling v4l2_subdev_lock_state() on both states so that if + * the states share the same lock, the lock is acquired only once (so no + * deadlock occurs). The caller is responsible for ensuring the locks will + * always be acquired in the same order. + */ +static inline void v4l2_subdev_lock_states(struct v4l2_subdev_state *state1, + struct v4l2_subdev_state *state2) +{ + mutex_lock(state1->lock); + if (state1->lock != state2->lock) + mutex_lock(state2->lock); +} + +/** + * v4l2_subdev_unlock_states() - Unlock two sub-device states + * @state1: One subdevice state + * @state2: The other subdevice state + * + * Unlocks the state of two sub-devices. + * + * This differs from calling v4l2_subdev_unlock_state() on both states so that + * if the states share the same lock, the lock is released only once. + */ +static inline void v4l2_subdev_unlock_states(struct v4l2_subdev_state *state1, + struct v4l2_subdev_state *state2) +{ + mutex_unlock(state1->lock); + if (state1->lock != state2->lock) + mutex_unlock(state2->lock); +} + /** * v4l2_subdev_get_unlocked_active_state() - Checks that the active subdev state * is unlocked and returns it From patchwork Tue Apr 16 19:32:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789620 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52FE013A265 for ; Tue, 16 Apr 2024 19:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296028; cv=none; b=sOC6Tekn8rT2MNFg5gNMeE8ufC1mf/h+oQErCZjBbBFZSHRldB3WtzPc/VquW7J9EHRUHuhvOJaIVC9VayWnf6XDUcO2vIY8aJhCr+Nhx/Nt8R56rvoc9IvipGEKeMZP+xFQm02yRLhmW/Uq1ejpbjhpoG+pg6ZuXW747OWVeNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296028; c=relaxed/simple; bh=pqfDcVE/YOyw+XiAges2rgmlpGwMI9/1uNUTAAQIWWQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mTXqZ42+8KgkccbLrOCZ9wSBPvEopdy3WGDsAUC1C1ngI1mVCX9H8lYBrwUWdXbQ1g/gYWyD9h88NXrKDLDD4LPT7nmnrbyPoUwEpjdk/3MU9bQO6mR1KfnPse3IefxKAhiSVMYnaOL7WC3EDcCPMSBThXWus6r8oRDDcyWF3M4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YkGPpK/9; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YkGPpK/9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296028; x=1744832028; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pqfDcVE/YOyw+XiAges2rgmlpGwMI9/1uNUTAAQIWWQ=; b=YkGPpK/9YFrhp6HI65OCDrFoK5eiWbNx8kjNnQVR1bh8lTA+fUlOlR0o DPYGVoLosfMMMsfoV6zOLkOEuyjd0RfuCibpzVqIqG9teEYQtlzcMKcav uDHBL/k50wppIW8jUOLscGIwXJELvfIKWwr95DwPZUxBAEf/VhKdwJMQ6 wAFhX9yPr7pPcfF86b6Y7V27wa4cEl3K7iUmvF0UdWH132shjlwa/NYns 5X2DPJslom0XBVt+p6jadX1sQzkMrhTNdWlXALth7IgUIsf4pYLlZ/1hy I8DIxwmiRW9ZvzrPukHphR/Pjf5arxBK3UvSSIqedhdY35XTU7s7MaGJH g==; X-CSE-ConnectionGUID: YEscxNkeTfax6HXafAIdaA== X-CSE-MsgGUID: Xojo4Bq3SOGkV9Mt/Wujig== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="19906086" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="19906086" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:46 -0700 X-CSE-ConnectionGUID: ZfTYuS/MR+uBJFXwNO325A== X-CSE-MsgGUID: E1oXCXqTTceVteD8GLHmDg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="27155313" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:44 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 6FFFD11F879; Tue, 16 Apr 2024 22:33:40 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 14/46] media: v4l: subdev: Copy argument back to user also for S_ROUTING Date: Tue, 16 Apr 2024 22:32:47 +0300 Message-Id: <20240416193319.778192-15-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As the user needs to know what went wrong for S_ROUTING, copy array arguments back to the user. Signed-off-by: Sakari Ailus Reviewed-by: Julien Massot Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 2cfc9106857a..1863ecae9ec9 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -3445,11 +3445,14 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg, * FIXME: subdev IOCTLS are partially handled here and partially in * v4l2-subdev.c and the 'always_copy' flag can only be set for IOCTLS * defined here as part of the 'v4l2_ioctls' array. As - * VIDIOC_SUBDEV_G_ROUTING needs to return results to applications even - * in case of failure, but it is not defined here as part of the + * VIDIOC_SUBDEV_[GS]_ROUTING needs to return results to applications + * even in case of failure, but it is not defined here as part of the * 'v4l2_ioctls' array, insert an ad-hoc check to address that. */ - if (err < 0 && !always_copy && cmd != VIDIOC_SUBDEV_G_ROUTING) + if (cmd == VIDIOC_SUBDEV_G_ROUTING || cmd == VIDIOC_SUBDEV_S_ROUTING) + always_copy = true; + + if (err < 0 && !always_copy) goto out; if (has_array_args) { From patchwork Tue Apr 16 19:32:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789619 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 322E513A412 for ; Tue, 16 Apr 2024 19:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296030; cv=none; b=q/SXAk7QhYYeh4UPEzU4A4roSbwJN2l4+bpF1cnxapStvcR1wWU/9DBu6Qk6rzgwSc5PTaQMQlP/qe/CgoU8+BVwzZ0PK3aVAS0m4pq0mO7xA0W7NdVk5Xkbn7bs99S5HDHUGF4VW6xR1emzfcRNYH9ZrC6k8Dxbc2Con8rS8TE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296030; c=relaxed/simple; bh=u+wdARH1bMm/ZrpemB1FGjHbI8DgJvIlS8L9ax43vq4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BwQcNJn0kT0qVvkMP3vc/tAnehhA2elh52NJKKIYhc8eokDcw+fdgXzvm3ILi7VLfULrRLcoYDe43rwX8RCE4iyzi3jw10TfChZciFVnppSIyaf4vtHnSscS4q0Yq6vDabxRPji95TjSjksPjwXFE5f8GejMuKmMXbLVn9ZdH44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hvDYAtuP; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hvDYAtuP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296029; x=1744832029; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u+wdARH1bMm/ZrpemB1FGjHbI8DgJvIlS8L9ax43vq4=; b=hvDYAtuPLtucVK7N7Aq34UiOx/XZcCh+KKxI5J8v+6aRc/JM34FpG67D ivya13RaRMt5h+4o1iqI2aQeGwX0Hb8342ujC2PuEgUkha1f7hm7BhXvs ygteNcew5R7sAG4EfTc1EPjz8mIMu8LQ61KplbaX2tqnPnE3wSGO3JeN9 ONBsgDzyuotW+kbOVJNR3AQIiVMDLH3EYTgn4lOo72Yi/U95Lb0lWeJ4Y 1Al+ELVUH5KT0m8nDdwD+PRXgRGsFwa1RYRzXMU+2nKGDt5rBepPyx79C mDmZQA6Ji8aGoSH1riAWVc77hrInUFob/jGDyee9UpkCKG0KZQTeXdzf4 g==; X-CSE-ConnectionGUID: FFJmS18FQrqY+7ddKjHuHQ== X-CSE-MsgGUID: aSJSfnslQX+G2EkFnD18/A== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="19906100" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="19906100" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:49 -0700 X-CSE-ConnectionGUID: 5OIZY8zmRlan1m49ufzWqQ== X-CSE-MsgGUID: 79c8sAtiTWqQ0y1yAzgwqw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="27155351" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:47 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 2414C12056F; Tue, 16 Apr 2024 22:33:43 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 16/46] media: v4l: subdev: Return routes set using S_ROUTING Date: Tue, 16 Apr 2024 22:32:49 +0300 Message-Id: <20240416193319.778192-17-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Return the routes set using S_ROUTING back to the user. Also reflect this in documentation. Signed-off-by: Sakari Ailus Reviewed-by: Laurent Pinchart --- .../media/v4l/vidioc-subdev-g-routing.rst | 7 ++----- drivers/media/v4l2-core/v4l2-subdev.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst index 27eb4c82a0e1..88df7bf80b00 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst @@ -44,7 +44,8 @@ Drivers report their current routing tables using the ``VIDIOC_SUBDEV_G_ROUTING`` ioctl and application may enable or disable routes with the ``VIDIOC_SUBDEV_S_ROUTING`` ioctl, by adding or removing routes and setting or clearing flags of the ``flags`` field of a struct -:c:type:`v4l2_subdev_route`. +:c:type:`v4l2_subdev_route`. Similarly to ``VIDIOC_SUBDEV_G_ROUTING``, also +``VIDIOC_SUBDEV_S_ROUTING`` returns the routes back to the user. All stream configurations are reset when ``VIDIOC_SUBDEV_S_ROUTING`` is called. This means that the userspace must reconfigure all stream formats and selections @@ -157,10 +158,6 @@ On success 0 is returned, on error -1 and the ``errno`` variable is set appropriately. The generic error codes are described at the :ref:`Generic Error Codes ` chapter. -ENOSPC - The application provided ``num_routes`` is not big enough to contain - all the available routes the subdevice exposes. - EINVAL The sink or source pad identifiers reference a non-existing pad or reference pads of different types (ie. the sink_pad identifiers refers to a source diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 904378007a79..36b2f78cd551 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -959,8 +959,18 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, krouting.len_routes = routing->len_routes; krouting.routes = routes; - return v4l2_subdev_call(sd, pad, set_routing, state, + rval = v4l2_subdev_call(sd, pad, set_routing, state, routing->which, &krouting); + if (rval < 0) + return rval; + + memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes, + state->routing.routes, + min(state->routing.num_routes, routing->len_routes) * + sizeof(*state->routing.routes)); + routing->num_routes = state->routing.num_routes; + + return 0; } case VIDIOC_SUBDEV_G_ROUTING: { From patchwork Tue Apr 16 19:32:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789618 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A31F113A265 for ; Tue, 16 Apr 2024 19:33:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296033; cv=none; b=bv9uZsgVTYajPkJ3oCLM8kHgEPBOvGoNcjuKkPPr4lPI9tcZvF4RWHXtO6FWmDpnsTXo2QaE2dmNgk7fAyHSh13UmftI19of1C51qqy4WsNI32MrJo7wWaKM2hwLXz7pYlXAtEoY5xrczZ+zFVNY8IjdHpSMNwveB4BxejGtqLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296033; c=relaxed/simple; bh=VbxA/CXN58rfKsEMDmPzTB3GKljE4dP/mAd+U7dAm+M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=avj9VlbSFxrwThQvLOs3X3xo6Wz7qnbNb4hNW4xRazMWhpOuuqU57upooScGZTsIrM3EfQQSxWtp9m2KbOlj7w+nv+AAB4hRfE+ZlQtLQrLTJv+5mNOfzOHJQxuQoeKHQ8nSvf4ba9fBVMk7VdGM0NbOMimiwqkFHcUfzNCd8Ak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=JkMiBmen; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JkMiBmen" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296033; x=1744832033; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VbxA/CXN58rfKsEMDmPzTB3GKljE4dP/mAd+U7dAm+M=; b=JkMiBmenZCSHJ6nkX2msX+dxCFFURBd+QExwIlZKui94dEGjvQuqI53/ 0hRu2ch3dYuuLOYmHi+nTqjR1e86SfSZnHtSrPxEdk0bCvxJWZVcGi5vA 9EaprGjEupATuV4xIyKr1Py1+nLvb7W10K/FwyudVIrqlJuYSbmtUxq9v ek7Xi5yS9W5AfiuYHBcI8mzzF1b3KLDJVB0WQP5uWtEc0ATkPETvZvpL0 0flddtmBun9EEfO7zKFm7iaUulSSxrFKAV1WSE53OfvvbzTo4rE7j/cQq /3Lc4fSItX+Nzkx5d2ZxCA7h3W76wcjLI7wVxOojRcVzCiOpUfz1pc5Hw A==; X-CSE-ConnectionGUID: lVPPT8IySICLeZ4bhB9juw== X-CSE-MsgGUID: AahfL9yIQnKUremd/YXhug== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="19906117" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="19906117" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:53 -0700 X-CSE-ConnectionGUID: mmX8Cp+dSQOIJMyXI4XoOQ== X-CSE-MsgGUID: ZLojFL42ScmYoyQ1gl95ww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="27155380" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:50 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id CA1D31204F9; Tue, 16 Apr 2024 22:33:45 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 18/46] media: ccs: No need to set streaming to false in power off Date: Tue, 16 Apr 2024 22:32:51 +0300 Message-Id: <20240416193319.778192-19-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Streaming will have been stopped before the sensor is powered off, and so sensor->streaming is also false already. Do not set it as part of the runtime suspend callback. Signed-off-by: Sakari Ailus Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ccs/ccs-core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index e1ae0f9fad43..7e5474e38732 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -1710,7 +1710,6 @@ static int ccs_power_off(struct device *dev) usleep_range(5000, 5000); regulator_bulk_disable(ARRAY_SIZE(ccs_regulators), sensor->regulators); - sensor->streaming = false; return 0; } From patchwork Tue Apr 16 19:32:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789617 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B90D81386C7 for ; Tue, 16 Apr 2024 19:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296039; cv=none; b=emP81vXHpKqVm26xipm/+y9yKgYooAcrxRzkpljO4eC5rPE5GVxPummyVDFGeoLBs6LfoAfDRwo18bCxNCSvO4fta2tZZRxCVKT+IDQGZUv7d4fGe96QjZj3MffxYXObDmQbiSJDFKv+Ndnq420DhwdlzqmCXzBvtKuuhvx1/A4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296039; c=relaxed/simple; bh=AQyxc2i6RGx3HmT+VL717qXd+tyFmMtovdcwFhMtTfo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c1lqkHGMYcSSp/jO5wUaFWbzPUWugSGuvs4fjfdMlk/w2C6KlqB3tUEFdrP9rzqkZBAcnBXEcmoa9r0yYELJTxFN+QOnXOeVP1UvcQ87pC7ud4EXzaLXOZK5qsCyv2SkudBAHru9Pl3c2ocs/P5cdL4amrcJ0HOBl5oM6ghvcvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QqYJK3+9; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QqYJK3+9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296038; x=1744832038; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AQyxc2i6RGx3HmT+VL717qXd+tyFmMtovdcwFhMtTfo=; b=QqYJK3+9v5f8rlLWsCH0HILBkX3AUsLsn/4p9FH1MRudcu61Qu4r4G95 QP1KS5z+6gmayYh2tQn5rnQj4wtKniBveTM3lFVGh7nHhOwfq5FIyeARq SClzPu9moAEuNlx/+U888/IDu6pUxN8KJlPht7IamOzTNH2kv0s0VpUod 4YLkx3LxR+LWkUjHvKpwti94W16WHR7GvpbjtYCzqskmkatbvwEip2UhF OXJ4+2Rw0DKqI7J4VszPYjlNFZkM5oLf9ifyP+s+ot7XlT3pMg3wn5lhE 8frVTiz5pE3Nkp/AiPRhezg4cTEkJUg7tD7QJ78EWHsTvYXgO2T0FsnSr g==; X-CSE-ConnectionGUID: a2/GL41hSECIVQqapUcmAw== X-CSE-MsgGUID: ylhAZo9jRrWfeQVgbhKbGw== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929798" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929798" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:57 -0700 X-CSE-ConnectionGUID: SWx9L4ZLROaQv5MU5KrQcg== X-CSE-MsgGUID: QB54Pbe6RnOjMQD21EmxTg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380172" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:54 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 5BEB91204F6; Tue, 16 Apr 2024 22:33:50 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 21/46] media: ccs: Use {enable,disable}_streams operations Date: Tue, 16 Apr 2024 22:32:54 +0300 Message-Id: <20240416193319.778192-22-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Switch from s_stream() video op to enable_streams() and disable_streams() pad operations. They are preferred and required for streams support. Signed-off-by: Sakari Ailus --- drivers/media/i2c/ccs/ccs-core.c | 83 ++++++++++++++------------------ 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index d14e90f8568a..aaa6bf8495e1 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -1715,7 +1715,7 @@ static int ccs_power_off(struct device *dev) } /* ----------------------------------------------------------------------------- - * Video stream management + * V4L2 subdev video operations */ static int ccs_pm_get_init(struct ccs_sensor *sensor) @@ -1739,11 +1739,11 @@ static int ccs_pm_get_init(struct ccs_sensor *sensor) sensor->handler_setup_needed = false; /* Restore V4L2 controls to the previously suspended device */ - rval = v4l2_ctrl_handler_setup(&sensor->pixel_array->ctrl_handler); + rval = __v4l2_ctrl_handler_setup(&sensor->pixel_array->ctrl_handler); if (rval) goto error; - rval = v4l2_ctrl_handler_setup(&sensor->src->ctrl_handler); + rval = __v4l2_ctrl_handler_setup(&sensor->src->ctrl_handler); if (rval) goto error; @@ -1755,13 +1755,21 @@ static int ccs_pm_get_init(struct ccs_sensor *sensor) return rval; } -static int ccs_start_streaming(struct ccs_sensor *sensor) +static int ccs_enable_streams(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, u32 pad, + u64 streams_mask) { + struct ccs_sensor *sensor = to_ccs_sensor(subdev); struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); unsigned int binning_mode; int rval; - mutex_lock(&sensor->mutex); + if (pad != CCS_PAD_SRC) + return -EINVAL; + + rval = ccs_pm_get_init(sensor); + if (rval) + return rval; rval = ccs_write(sensor, CSI_DATA_FORMAT, (sensor->csi_format->width << 8) | @@ -1880,64 +1888,41 @@ static int ccs_start_streaming(struct ccs_sensor *sensor) rval = ccs_write(sensor, MODE_SELECT, CCS_MODE_SELECT_STREAMING); -err_pm_put: - mutex_unlock(&sensor->mutex); - - return rval; -} - -static int ccs_stop_streaming(struct ccs_sensor *sensor) -{ - struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); - int rval; + sensor->streaming = true; - mutex_lock(&sensor->mutex); - rval = ccs_write(sensor, MODE_SELECT, CCS_MODE_SELECT_SOFTWARE_STANDBY); - if (rval) - goto out; + return 0; - rval = ccs_call_quirk(sensor, post_streamoff); - if (rval) - dev_err(&client->dev, "post_streamoff quirks failed\n"); +err_pm_put: + pm_runtime_mark_last_busy(&client->dev); + pm_runtime_put_autosuspend(&client->dev); -out: - mutex_unlock(&sensor->mutex); return rval; } -/* ----------------------------------------------------------------------------- - * V4L2 subdev video operations - */ - -static int ccs_set_stream(struct v4l2_subdev *subdev, int enable) +static int ccs_disable_streams(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, u32 pad, + u64 streams_mask) { struct ccs_sensor *sensor = to_ccs_sensor(subdev); struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); int rval; - if (!enable) { - ccs_stop_streaming(sensor); - sensor->streaming = false; - pm_runtime_mark_last_busy(&client->dev); - pm_runtime_put_autosuspend(&client->dev); - - return 0; - } + if (pad != CCS_PAD_SRC) + return -EINVAL; - rval = ccs_pm_get_init(sensor); + rval = ccs_write(sensor, MODE_SELECT, CCS_MODE_SELECT_SOFTWARE_STANDBY); if (rval) return rval; - sensor->streaming = true; + rval = ccs_call_quirk(sensor, post_streamoff); + if (rval) + dev_err(&client->dev, "post_streamoff quirks failed\n"); - rval = ccs_start_streaming(sensor); - if (rval < 0) { - sensor->streaming = false; - pm_runtime_mark_last_busy(&client->dev); - pm_runtime_put_autosuspend(&client->dev); - } + sensor->streaming = false; + pm_runtime_mark_last_busy(&client->dev); + pm_runtime_put_autosuspend(&client->dev); - return rval; + return 0; } static int ccs_pre_streamon(struct v4l2_subdev *subdev, u32 flags) @@ -1963,7 +1948,9 @@ static int ccs_pre_streamon(struct v4l2_subdev *subdev, u32 flags) } } + mutex_lock(&sensor->mutex); rval = ccs_pm_get_init(sensor); + mutex_unlock(&sensor->mutex); if (rval) return rval; @@ -3047,7 +3034,7 @@ static int ccs_init_state(struct v4l2_subdev *sd, } static const struct v4l2_subdev_video_ops ccs_video_ops = { - .s_stream = ccs_set_stream, + .s_stream = v4l2_subdev_s_stream_helper, .pre_streamon = ccs_pre_streamon, .post_streamoff = ccs_post_streamoff, }; @@ -3058,6 +3045,8 @@ static const struct v4l2_subdev_pad_ops ccs_pad_ops = { .set_fmt = ccs_set_format, .get_selection = ccs_get_selection, .set_selection = ccs_set_selection, + .enable_streams = ccs_enable_streams, + .disable_streams = ccs_disable_streams, }; static const struct v4l2_subdev_sensor_ops ccs_sensor_ops = { From patchwork Tue Apr 16 19:32:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789616 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7832B13AA2A for ; Tue, 16 Apr 2024 19:33:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296040; cv=none; b=EjmSuDUJ/4OYJL9FqlGcfW7J7Q0Mya+VMmW/OsCpQAPxxtnSUPoAW0b2IwjpV4dHyCV8W8c6LnPK+YOdAD6lEsY90f3NG5XqCg8+LS/WfJZaQLR54uc0+Mv9Mm5bc8ih0YZUvZARReVKUlNkBaH5sSDtd5yXmv5I3MDLBb3CtTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296040; c=relaxed/simple; bh=N2yHA+6k5HIx92G2Kw66zz4ryid9cXzLGZvOz6A9d5U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ltFsD8aoQ4WbS9e2rPh0LbZMMdw/hP2Om60xFBDMa8WxCHt4V5957uPG7AhRk1DZAQIiSwuAAMUcWU59UfmArigdzr91o5WfKhlXbwa0A5RH84Z/foUajmX+s4uyv/3c1DGlaQojrxXdFV8Sxhx8apknBST2sobGEj/y9rdmjZc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jbEEA2yq; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jbEEA2yq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296039; x=1744832039; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=N2yHA+6k5HIx92G2Kw66zz4ryid9cXzLGZvOz6A9d5U=; b=jbEEA2yqjisPuW7bwFufT1qZIh1dS6C2QkwAxHaQSj8khdj+sbEEFSSr ynfitjdRx1iB8xATAY1L3kiYlBDrzGlkGEFcDcWGmy3+YckUN+JjrdPVN O5UkBFkzRDHw5JBSFumPTkdDQ+RT/IwDstQI/5DEJTUyTtNgNfTjcfF6s SLYRxB7ukPYYVFGc3WebLmvz0IkS1tOxq9QOjYgeCsyFPftYK/5xPZntQ pZEmNWo4DC6EouFGI7I9CkwJBYtNFErgfAWz6OzdOhmKICPonUYQKTzAb 93jgqa/oJtLRqQ867RLuxYjs2AwmgE0lyue5Afza9D0lGjwBaWPRApYIb g==; X-CSE-ConnectionGUID: 49RQmtUDSzqKarUgJ5hbdw== X-CSE-MsgGUID: cyQvIUqNTvyxrh3DG4C/8w== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929809" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929809" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:59 -0700 X-CSE-ConnectionGUID: GLBo+bvoRTK+TKFOVbeZKw== X-CSE-MsgGUID: DLBojPgXTs2Q7uObDncVDQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380187" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:56 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 4E8A41204F9; Tue, 16 Apr 2024 22:33:53 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 23/46] media: ccs: Move ccs_validate_csi_data_format up Date: Tue, 16 Apr 2024 22:32:56 +0300 Message-Id: <20240416193319.778192-24-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 ccs_validate_csi_data_format() will soon be needed elsewhere, above its current location. Move it up. Signed-off-by: Sakari Ailus Reviewed-by: Julien Massot Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ccs/ccs-core.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index c39ee4394534..a711233f6fbf 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -1980,6 +1980,20 @@ static int ccs_post_streamoff(struct v4l2_subdev *subdev) return pm_runtime_put(&client->dev); } +static const struct ccs_csi_data_format +*ccs_validate_csi_data_format(struct ccs_sensor *sensor, u32 code) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(ccs_csi_data_formats); i++) { + if (sensor->mbus_frame_fmts & (1 << i) && + ccs_csi_data_formats[i].code == code) + return &ccs_csi_data_formats[i]; + } + + return sensor->csi_format; +} + static int ccs_enum_mbus_code(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) @@ -2115,20 +2129,6 @@ static void ccs_propagate(struct v4l2_subdev *subdev, } } -static const struct ccs_csi_data_format -*ccs_validate_csi_data_format(struct ccs_sensor *sensor, u32 code) -{ - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(ccs_csi_data_formats); i++) { - if (sensor->mbus_frame_fmts & (1 << i) && - ccs_csi_data_formats[i].code == code) - return &ccs_csi_data_formats[i]; - } - - return sensor->csi_format; -} - static int ccs_set_format_source(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_format *fmt) From patchwork Tue Apr 16 19:32:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789615 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D8451386CF for ; Tue, 16 Apr 2024 19:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296043; cv=none; b=q7f/zj4ZElCOUoQAeGQLRfmC+WZBVszwrnN5l2RdGcI/E5L1ZhH+Kf7esP+mmlS9q7xLVbD4J7ZL4H4aaBkD8T141dfybENf+mPLNPwaDTyyygOun8chJlyBv9T+AgTYaedS7URNdauqxyUr1KrCFCiI+6mVbqGdxEF84+Z7p5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296043; c=relaxed/simple; bh=vpcwE7cZ9s+ebaoL4zAMArumxOU1TlbuyHb8WvOI3Cg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q84Fn42S4zwRopQBEfMa3LP52ombv6dbOBEabmND+p9l/Ra1Spqj4AG5rHc81y7ScWNVogSKXTjWr8+vwU/7vIjjMfWVV6VJsvxeyTo/LgvTLFuxpl+A8Y+L9l0mtarC33qv4aoJQPryS3Aij93VipZQqYAeTpvLMGuPbZvZMok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hVO023Ig; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hVO023Ig" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296042; x=1744832042; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vpcwE7cZ9s+ebaoL4zAMArumxOU1TlbuyHb8WvOI3Cg=; b=hVO023IgNfqIlEJ/sevEm32uMXHp0PS/vKlXMay+QEW4Gs4qtPgXRTLW EN1WOYT8lZu2ltnTJjNF2FdoQ4jVOvkNoq1whtmOnUvELYT6MJMvtiwya CqSg2U2uKCVbqTFoiedrQkQW21lbjFd+Jihe1Dw97Hz2kIygG47t9bHEe 5ly6waMftc2iY4EPDcl5bijGiHBGLu4oec1Fc014P3ykGBEgKDINCl7AE 0rKWWHZof5nndBdputfa6bOzpEAG30rIBi1PDdKwMF7tltX9dSxD0qnV/ ZeVreaf35N4fW9swL5Gv37WmVncm73b/BMuC4LBR8Ia6p9zgs8bkeiVyb w==; X-CSE-ConnectionGUID: jGbDUDoqRdmVKIF1S6VR7A== X-CSE-MsgGUID: RwPp0z9vTziSHMbkEhVkyw== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929820" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929820" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:02 -0700 X-CSE-ConnectionGUID: dEsacepBTqKbiBKSTA8XIA== X-CSE-MsgGUID: qDGtbrl/RPqTNAGzYVWPNQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380201" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:33:59 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 132B41205CF; Tue, 16 Apr 2024 22:33:55 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 25/46] media: uapi: v4l: subdev: Enable streams API Date: Tue, 16 Apr 2024 22:32:58 +0300 Message-Id: <20240416193319.778192-26-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove v4l2_subdev_enable_streams_api variable that was used to easily enable streams API for development, and conditions that use the variable. This patch enables the streams API for V4L2 sub-device interface which allows transporting multiple streams on a single MC link. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-subdev.c | 30 --------------------------- 1 file changed, 30 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index e68f16a7c041..caf312e5e0d9 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -26,15 +26,6 @@ #include #include -#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) -/* - * The Streams API is an experimental feature. To use the Streams API, set - * 'v4l2_subdev_enable_streams_api' to 1 below. - */ - -static bool v4l2_subdev_enable_streams_api; -#endif - /* * Maximum stream ID is 63 for now, as we use u64 bitmask to represent a set * of streams. @@ -570,13 +561,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, V4L2_SUBDEV_CLIENT_CAP_STREAMS; int rval; - /* - * If the streams API is not enabled, remove V4L2_SUBDEV_CAP_STREAMS. - * Remove this when the API is no longer experimental. - */ - if (!v4l2_subdev_enable_streams_api) - streams_subdev = false; - switch (cmd) { case VIDIOC_SUBDEV_QUERYCAP: { struct v4l2_subdev_capability *cap = arg; @@ -918,9 +902,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, struct v4l2_subdev_krouting krouting = {}; unsigned int i; - if (!v4l2_subdev_enable_streams_api) - return -ENOIOCTLCMD; - if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS)) return -ENOIOCTLCMD; @@ -991,9 +972,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, struct v4l2_subdev_routing *routing = arg; struct v4l2_subdev_krouting *krouting; - if (!v4l2_subdev_enable_streams_api) - return -ENOIOCTLCMD; - if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS)) return -ENOIOCTLCMD; @@ -1021,14 +999,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, case VIDIOC_SUBDEV_S_CLIENT_CAP: { struct v4l2_subdev_client_capability *client_cap = arg; - /* - * Clear V4L2_SUBDEV_CLIENT_CAP_STREAMS if streams API is not - * enabled. Remove this when streams API is no longer - * experimental. - */ - if (!v4l2_subdev_enable_streams_api) - client_cap->capabilities &= ~V4L2_SUBDEV_CLIENT_CAP_STREAMS; - /* Filter out unsupported capabilities */ client_cap->capabilities &= (V4L2_SUBDEV_CLIENT_CAP_STREAMS | V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH); From patchwork Tue Apr 16 19:33:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789614 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D599139585 for ; Tue, 16 Apr 2024 19:34:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296047; cv=none; b=iGWpPeo3b9tShu0ht568LVO17S7sqQkR/wnOknLN3oK1ozy5VJVOmLjlRoXYsaR5X/yBStqSM4IZmj2KuPVrJfXtM2SkbI6lVV6DByL6rmCpoHKaTbscVcfQGiMtC7BRqnyAuED5M1/wPH9zTnzjdfrsAvDDHzPVQqXmDOVpfns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296047; c=relaxed/simple; bh=FKvST9MrhN8JK7mzfgslQ2FDmbGe/y31jpv961MggoQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rqn0bKGLVbu0crZpTu8pr+T8WfhBXVKlbGlr/JL0MueYexrbO3Y+g+p/5IIP1TOT1oVdpUQpwyvWeALvy4E+4R04TAmlW12RT+rS7OljN1PVEZ7N9SKupRYcYVRZ/ud2IVUllmiUQ+mN8DN/5X1SmRyQQQT/NK8OjuC+C+byY30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eZ5PkRUi; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eZ5PkRUi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296046; x=1744832046; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FKvST9MrhN8JK7mzfgslQ2FDmbGe/y31jpv961MggoQ=; b=eZ5PkRUibv1cc0eyKV4XFz6QWv522gGDKhbA2WFtvLZsK1cDxIpA0owj 6rMSH41pdisiWRCLuI+cIam/jDBjqe27KtGVMVedsnN8AUsp5x+EreG+I w2laaEN41ocOcpDzkobQkFazpzwMcKbIyrqKtlSPm5xoBIFdMoT4KTN/l rSD9w5cmxLFJM0x0KuXQm3P3EM9y7Oansawp79su9JxWKauIchQoPZQgf PwpdRwWJn5OsNjXSFgl6W8YGYCjqJrldqa9mp2QLdN01k7S4JB+6zNL/n sNEzW9J2+luXqSKa8tRIIz/KF3j3fCj3wz1byWX9gfiTMOgMPySN8XgfM w==; X-CSE-ConnectionGUID: oLW9M0DcQMGH0k3DXrsZAg== X-CSE-MsgGUID: K0+QN21VS6CWAHjh3VYTrA== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929830" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929830" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:04 -0700 X-CSE-ConnectionGUID: Wda0N1nWRK6yxov15FShig== X-CSE-MsgGUID: lcIaAWdZTVWahqm/ZRT/tw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380210" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:01 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 9B43712056F; Tue, 16 Apr 2024 22:33:58 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 27/46] media: uapi: ccs: Add media bus code for MIPI CCS embedded data Date: Tue, 16 Apr 2024 22:33:00 +0300 Message-Id: <20240416193319.778192-28-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add new MIPI CCS embedded data media bus code (MEDIA_BUS_FMT_CCS_EMBEDDED). Signed-off-by: Sakari Ailus Reviewed-by: Julien Massot --- .../media/v4l/subdev-formats.rst | 32 +++++++++++++++++++ include/uapi/linux/media-bus-format.h | 3 ++ 2 files changed, 35 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst index 0547f2733ee3..fa181ce8f48c 100644 --- a/Documentation/userspace-api/media/v4l/subdev-formats.rst +++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst @@ -8316,6 +8316,10 @@ content is more or less device specific but the data is transmitted and received by multiple devices that do not process the data in any way, simply writing it to system memory for processing in software at the end of the pipeline. +The exact format of the data generated by the device is reported on the internal +source pad of the originating sub-device, using one of the more specific +metadata formats such as MEDIA_BUS_FMT_CCS_EMBEDDED. + "b" in an array cell signifies a byte of data, followed by the number of the bit and finally the bit number in subscript. "x" indicates a padding bit. @@ -8562,3 +8566,31 @@ and finally the bit number in subscript. "x" indicates a padding bit. - x - x - x + +.. _MEDIA-BUS-FMT-CCS-EMBEDDED: + +MIPI CCS Embedded Data Formats +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +`MIPI CCS `_ defines a +metadata format for sensor embedded data, which is used to store the register +configuration used for capturing a given frame. The format is defined in the CCS +specification. The media bus code for this format is +``MEDIA_BUS_FMT_CCS_EMBEDDED``. + +The CCS embedded data format definition includes three levels: + +1. Padding within CSI-2 bus :ref:`Data Unit ` as + documented in the MIPI CCS specification. + +2. The tagged data format as documented in the MIPI CCS specification. + +3. Register addresses and register documentation as documented in the MIPI CCS + specification. + +The format definition shall be used only by devices that fulfill all three +levels above. + +This mbus code are only used for "2-byte simplified tagged data format" (code +0xa) but their use may be extended further in the future, to cover other CCS +embedded data format codes. diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h index d4c1d991014b..03f7e9ab517b 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -183,4 +183,7 @@ #define MEDIA_BUS_FMT_META_20 0x8006 #define MEDIA_BUS_FMT_META_24 0x8007 +/* Specific metadata formats. Next is 0x9002. */ +#define MEDIA_BUS_FMT_CCS_EMBEDDED 0x9001 + #endif /* __LINUX_MEDIA_BUS_FORMAT_H */ From patchwork Tue Apr 16 19:33:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789613 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 998B813AD04 for ; Tue, 16 Apr 2024 19:34:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296049; cv=none; b=WbKe1qeNagAFGTfWOUAC0w+OBIFsimQvNuHd/Ma5+xKf8GLUm1CDML7HAl3VNmjo9W/eO3sAPFFeR2ZacKxPMtA+prCvowvG4S0jWYdk0WtGEh3W1uGTwf0N3fLD+TdLgpiu46WyRzSOLc+uR55mPJTopOud12xHsbA+AMngvxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296049; c=relaxed/simple; bh=WmZ77LjwUfJAaGbhbawY2FKnE8T0KsAU3VEShN0/j9A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FdjqK6U3P5qPuIjJlMRoTo9jfSz5u6uqWITqA+S7qhyGxEjDmb1vThPV2E8MEkNaCB/dVJK/xfbN9mX2flkQ0ieD7t3Oc5jLjPg0eYpEFKbdeUU5VGPITywmkGlZb04nGHqfXgS9Y/zUJZlQlPJV1UqwLSBS19KfvGrch6Xn3lA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fzHy8x+y; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fzHy8x+y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296048; x=1744832048; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WmZ77LjwUfJAaGbhbawY2FKnE8T0KsAU3VEShN0/j9A=; b=fzHy8x+ySDsfoFBAmsIovek9W4j1rIo0lsYxOLNt1b5uxU0y1XO9yGWe B6Z6F5iJ7nUM6iqRjQoCNBWkpsjKA9QKKHt0Harz9nqR2mfkcGcmZPChw AkVyTMtOOdDRAWe+wudyJh/JlvRd8RpH+YYrhtCqfuFYMSdqPinDxClVA XI0h2PIovrdMltr8RRezc+Yz9dtwztz38Bi5Za1QrN3XfCciYQQQWTwJ8 4JWUhA4WQDz3gNVUPM/uTBUfiaZMD4JEnL1GJ+L/kGsgkpZnjUtSzBWxE gVPue1c5uxURHYAd9elZTQaVkd5J5RtNl4rA6+lmPgKyWJt+iaeEYr4Yr Q==; X-CSE-ConnectionGUID: QgLXV11sR9eRRb1Qqe21PQ== X-CSE-MsgGUID: QNjkLTSXR4+4DWG8Kew0MQ== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929842" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929842" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:07 -0700 X-CSE-ConnectionGUID: XgpaSmrqTr2DgpOUCJoapA== X-CSE-MsgGUID: S3F9+w4DQRqQsiqhh2Ow/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380226" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:04 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 27DA311F879; Tue, 16 Apr 2024 22:34:01 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 29/46] media: Documentation: ccs: Document routing Date: Tue, 16 Apr 2024 22:33:02 +0300 Message-Id: <20240416193319.778192-30-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Document which routes are available for the CCS driver (source) sub-device and what configuration are possible. Also update copyright. Signed-off-by: Sakari Ailus --- .../userspace-api/media/drivers/ccs.rst | 38 ++++++++++++++++++- .../media/v4l/subdev-formats.rst | 2 + 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Documentation/userspace-api/media/drivers/ccs.rst b/Documentation/userspace-api/media/drivers/ccs.rst index 03015b33d5ab..53890ac54dab 100644 --- a/Documentation/userspace-api/media/drivers/ccs.rst +++ b/Documentation/userspace-api/media/drivers/ccs.rst @@ -111,4 +111,40 @@ than in the centre. Shading correction needs to be enabled for luminance correction level to have an effect. -**Copyright** |copy| 2020 Intel Corporation +.. _media-ccs-routes: + +Routes +------ + +The CCS driver implements one or two :ref:`routes ` in +its source sub-device (scaler sub-device if exists for the device, otherwise +binner) depending on whether the sensor supports embedded data. (All CCS +compliant sensors do but the CCS driver supports preceding standards that did +not require embedded data support, too.) + +The first route of the CCS source sub-device is for pixel data (sink pad +0/stream 0 -> source pad 1/stream 0) and the second one is for embedded data +(internal sink pad 2/stream 0 -> source pad 1/stream 1). + +Embedded data +~~~~~~~~~~~~~ + +MIPI CCS supports generation of camera sensor embedded data. The media bus code +used for this format on the internal sink pad is +:ref:`MEDIA_BUS_FMT_CCS_EMBEDDDED `. + +The bit depth of the CCS pixel data affects how the sensor will output the +embedded data, adding padding to align with CSI-2 bus :ref:`Data Units +` for that particular bit depth. This is indicated by +the generic metadata format on the sensor's source sub-device's source pad. + +Devices supporting embedded data for bit depths greater than or equal to 16 may +support more dense packing or legacy single metadata byte per data unit, or both +of these. The supported embedded data formats can be enumerated and configured +on stream 1 of the source pad (1) of the CCS source sub-device. + +The use of the denser packing results in embedded data lines being longer than +the pixel data in data units since the data units are smaller. In bytes the +embedded data lines are still not longer than the image data lines. + +**Copyright** |copy| 2020, 2023 Intel Corporation diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst index fa181ce8f48c..a04756092238 100644 --- a/Documentation/userspace-api/media/v4l/subdev-formats.rst +++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst @@ -8594,3 +8594,5 @@ levels above. This mbus code are only used for "2-byte simplified tagged data format" (code 0xa) but their use may be extended further in the future, to cover other CCS embedded data format codes. + +Also see :ref:`CCS driver documentation `. From patchwork Tue Apr 16 19:33:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789612 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACAD213AD25 for ; Tue, 16 Apr 2024 19:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296051; cv=none; b=VAlap1r1sLrNAkhZ253xWVVxGT2QKYrf9TYoQ1Z9u1ZHoSl7Wh68Q5DPG8sHrxHngRCG62waKER74JYvSktSwqaUqjVaTAMpY16y/yTdPzHbJCBqjjb7TPSU2rzX3xqn93muUp6YuK/c735wKLDU7cRgmaukQF7UJegVVsTIZRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296051; c=relaxed/simple; bh=Q+8umYPut/xlSeGACqh0u1KtcMNhhNmYRyvfEI842yQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RRu/fRjYqP+uA0cRql/YLVz6oBz/xsPXWrA1wmThvY09uXtEbTX33dMFUnxldtfT4ZMG315tocikHDSunC/2k4PyaGCANQtzYFXAOl4QO6SSdLeb4oKi4MvmP2LA0X5qER1N06aYaN+B2l/1Kmc55ksDa1eerroHiRj0EW8qeLs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Z2lOuzj3; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Z2lOuzj3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296050; x=1744832050; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q+8umYPut/xlSeGACqh0u1KtcMNhhNmYRyvfEI842yQ=; b=Z2lOuzj3J3eRJSqFUcBNMYjgf4vLpHHMEysNgYm21CEHhgos7IFr5KCh m7V1RY/HrTnjPUlJ/Su6sfA2Q6R8kEyYH+gLg7KZXsBWVAaJ4RXPgNWAy NS3ebK/ok/AP9VqcjcyymMOGV8RP/JXZxQezahrrvM1Ah/TKCHKyNA0D8 QAJPDWTfXw+aWrCSjVSLX0klzKv+2WKsp1EM1DfufR7SaB8QykwYiBBic F4VWbS7O31EgsV9NQbQJsqpKXBdo+l9izQxAjxSJvNxg9/RzYR/F1ZRsc X0232AjcGUZAtCndKnQlfKCICSW5lwv9o6z3HhHhS+3K1w+tVCpeYvwQ7 A==; X-CSE-ConnectionGUID: 74ZOo1VpTq6NFuP7hP3N8A== X-CSE-MsgGUID: 0fUruiTURAGQxFVYesJLIw== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929852" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929852" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:09 -0700 X-CSE-ConnectionGUID: FSijGhGJQiKasMJl8hwTjw== X-CSE-MsgGUID: Ex/efmEUQmOQvmLGM4sZWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380231" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:06 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 62E011205CF; Tue, 16 Apr 2024 22:34:02 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 30/46] media: ccs: Add support for embedded data stream Date: Tue, 16 Apr 2024 22:33:03 +0300 Message-Id: <20240416193319.778192-31-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for embedded data stream, in UAPI and frame descriptor. This patch adds also a new embedded data pad (2) to the source sub-device. Signed-off-by: Sakari Ailus --- drivers/media/i2c/ccs/ccs-core.c | 372 +++++++++++++++++++++++++++++-- drivers/media/i2c/ccs/ccs.h | 18 +- 2 files changed, 362 insertions(+), 28 deletions(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index 3ca2415fca3b..ba629eafec43 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -1903,6 +1903,13 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, if (rval < 0) goto err_pm_put; + /* Configure embedded data */ + if (sensor->csi_format->compressed >= 16) { + rval = ccs_write(sensor, EMB_DATA_CTRL, sensor->emb_data_ctrl); + if (rval < 0) + goto err_pm_put; + } + if (CCS_LIM(sensor, FLASH_MODE_CAPABILITY) & (CCS_FLASH_MODE_CAPABILITY_SINGLE_STROBE | SMIAPP_FLASH_MODE_CAPABILITY_MULTIPLE_STROBE) && @@ -2022,6 +2029,57 @@ static const struct ccs_csi_data_format return sensor->csi_format; } +#define CCS_EMBEDDED_CODE_DEPTH(depth, half_depth) \ + depth, \ + CCS_EMB_DATA_CAPABILITY_TWO_BYTES_PER_RAW##depth, \ + CCS_EMB_DATA_CAPABILITY_NO_ONE_BYTE_PER_RAW##depth, \ + CCS_EMB_DATA_CTRL_RAW##half_depth##_PACKING_FOR_RAW##depth, \ + MEDIA_BUS_FMT_META_##half_depth, \ + MEDIA_BUS_FMT_META_##depth, \ + +static const struct ccs_embedded_code { + u8 depth; + u8 cap_two_bytes_per_sample; + u8 cap_no_legacy; + u8 ctrl; + u32 code_two_bytes; + u32 code_legacy; +} ccs_embedded_codes[] = { + { CCS_EMBEDDED_CODE_DEPTH(16, 8) }, + { CCS_EMBEDDED_CODE_DEPTH(20, 10) }, + { CCS_EMBEDDED_CODE_DEPTH(24, 12) }, +}; + +static const struct ccs_embedded_code *ccs_embedded_code(unsigned int bpp) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(ccs_embedded_codes); i++) + if (ccs_embedded_codes[i].depth == bpp) + return ccs_embedded_codes + i; + + WARN_ON(1); + + return ccs_embedded_codes; +} + +static u32 +ccs_default_embedded_code(struct ccs_sensor *sensor, + const struct ccs_embedded_code *embedded_code) +{ + if (CCS_LIM(sensor, EMB_DATA_CAPABILITY) & + BIT(embedded_code->cap_two_bytes_per_sample)) + return embedded_code->code_two_bytes; + + if (!(CCS_LIM(sensor, EMB_DATA_CAPABILITY) & + BIT(embedded_code->cap_no_legacy))) + return embedded_code->code_legacy; + + WARN_ON(1); + + return embedded_code->code_legacy; +} + static int ccs_enum_mbus_code(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) @@ -2037,6 +2095,69 @@ static int ccs_enum_mbus_code(struct v4l2_subdev *subdev, dev_err(&client->dev, "subdev %s, pad %u, index %u\n", subdev->name, code->pad, code->index); + if (subdev == &sensor->src->sd) { + if (code->pad == CCS_PAD_META) { + if (code->index) + goto out; + + code->code = MEDIA_BUS_FMT_CCS_EMBEDDED; + + rval = 0; + goto out; + } + if (code->stream == CCS_STREAM_META) { + struct v4l2_mbus_framefmt *pix_fmt = + v4l2_subdev_state_get_format(sd_state, + CCS_PAD_SRC, + CCS_STREAM_PIXEL); + const struct ccs_csi_data_format *csi_format = + ccs_validate_csi_data_format(sensor, + pix_fmt->code); + unsigned int i = 0; + u32 codes[2]; + + switch (csi_format->compressed) { + case 8: + codes[i++] = MEDIA_BUS_FMT_META_8; + break; + case 10: + codes[i++] = MEDIA_BUS_FMT_META_10; + break; + case 12: + codes[i++] = MEDIA_BUS_FMT_META_12; + break; + case 14: + codes[i++] = MEDIA_BUS_FMT_META_14; + break; + case 16: + case 20: + case 24: { + const struct ccs_embedded_code *embedded_code = + ccs_embedded_code(csi_format->compressed); + + if (CCS_LIM(sensor, EMB_DATA_CAPABILITY) & + BIT(embedded_code->cap_two_bytes_per_sample)) + codes[i++] = + embedded_code->code_two_bytes; + + if (!(CCS_LIM(sensor, EMB_DATA_CAPABILITY) & + BIT(embedded_code->cap_no_legacy))) + codes[i++] = embedded_code->code_legacy; + break; + } + default: + WARN_ON(1); + } + + if (WARN_ON(i > ARRAY_SIZE(codes)) || code->index >= i) + goto out; + + code->code = codes[code->index]; + rval = 0; + goto out; + } + } + if (subdev != &sensor->src->sd || code->pad != CCS_PAD_SRC) { if (code->index) goto out; @@ -2079,8 +2200,11 @@ static int __ccs_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_format *fmt) { - fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - fmt->format.code = __ccs_get_mbus_code(subdev, fmt->pad); + fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad, + fmt->stream); + + if (fmt->pad != CCS_PAD_META && fmt->stream != CCS_STREAM_META) + fmt->format.code = __ccs_get_mbus_code(subdev, fmt->pad); return 0; } @@ -2110,10 +2234,11 @@ static void ccs_get_crop_compose(struct v4l2_subdev *subdev, if (crops) for (i = 0; i < subdev->entity.num_pads; i++) crops[i] = - v4l2_subdev_state_get_crop(sd_state, i); + v4l2_subdev_state_get_crop(sd_state, i, + CCS_STREAM_PIXEL); if (comps) - *comps = v4l2_subdev_state_get_compose(sd_state, - ssd->sink_pad); + *comps = v4l2_subdev_state_get_compose(sd_state, ssd->sink_pad, + CCS_STREAM_PIXEL); } /* Changes require propagation only on sink pad. */ @@ -2146,7 +2271,8 @@ static void ccs_propagate(struct v4l2_subdev *subdev, fallthrough; case V4L2_SEL_TGT_COMPOSE: *crops[CCS_PAD_SRC] = *comp; - fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC); + fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC, + CCS_STREAM_PIXEL); fmt->width = comp->width; fmt->height = comp->height; if (which == V4L2_SUBDEV_FORMAT_ACTIVE && ssd == sensor->src) @@ -2210,6 +2336,83 @@ static int ccs_set_format_source(struct v4l2_subdev *subdev, return ccs_pll_update(sensor); } +static int ccs_set_format_meta(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *sd_state, + struct v4l2_mbus_framefmt *fmt) +{ + struct ccs_sensor *sensor = to_ccs_sensor(subdev); + const struct ccs_csi_data_format *csi_format; + struct v4l2_mbus_framefmt *pix_fmt; + struct v4l2_mbus_framefmt *meta_fmt; + struct v4l2_mbus_framefmt *meta_out_fmt; + u32 code; + + pix_fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC, + CCS_STREAM_PIXEL); + meta_fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_META, 0); + meta_out_fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC, + CCS_STREAM_META); + + code = fmt ? fmt->code : meta_out_fmt->code; + + meta_out_fmt->width = meta_fmt->width = pix_fmt->width; + meta_out_fmt->height = meta_fmt->height = + sensor->embedded_end - sensor->embedded_start; + meta_fmt->code = MEDIA_BUS_FMT_CCS_EMBEDDED; + + csi_format = ccs_validate_csi_data_format(sensor, pix_fmt->code); + + switch (csi_format->compressed) { + case 8: + meta_out_fmt->code = MEDIA_BUS_FMT_META_8; + break; + case 10: + meta_out_fmt->code = MEDIA_BUS_FMT_META_10; + break; + case 12: + meta_out_fmt->code = MEDIA_BUS_FMT_META_12; + break; + case 14: + meta_out_fmt->code = MEDIA_BUS_FMT_META_14; + break; + case 16: + case 20: + case 24: { + const struct ccs_embedded_code *embedded_code; + + embedded_code = ccs_embedded_code(csi_format->compressed); + meta_out_fmt->code = + ccs_default_embedded_code(sensor, embedded_code); + + if (!(CCS_LIM(sensor, EMB_DATA_CAPABILITY) & + BIT(embedded_code->cap_no_legacy)) && + code == embedded_code->code_legacy) { + meta_out_fmt->code = embedded_code->code_legacy; + sensor->emb_data_ctrl = 0; + } + + if (CCS_LIM(sensor, EMB_DATA_CAPABILITY) & + BIT(embedded_code->cap_two_bytes_per_sample) && + code == embedded_code->code_two_bytes) { + meta_out_fmt->code = embedded_code->code_two_bytes; + sensor->emb_data_ctrl = embedded_code->ctrl; + meta_fmt->width <<= 1; + meta_out_fmt->width <<= 1; + } + + break; + } + default: + WARN_ON(1); + return 0; + } + + if (fmt) + *fmt = *meta_out_fmt; + + return 0; +} + static int ccs_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_format *fmt) @@ -2218,12 +2421,25 @@ static int ccs_set_format(struct v4l2_subdev *subdev, struct ccs_subdev *ssd = to_ccs_subdev(subdev); struct v4l2_rect *crops[CCS_PADS]; + if (subdev == &sensor->src->sd && fmt->pad == CCS_PAD_META) + return ccs_get_format(subdev, sd_state, fmt); + mutex_lock(&sensor->mutex); + if (subdev == &sensor->src->sd && fmt->stream == CCS_STREAM_META) { + ccs_set_format_meta(subdev, sd_state, &fmt->format); + + mutex_unlock(&sensor->mutex); + + return 0; + } + if (fmt->pad == ssd->source_pad) { int rval; rval = ccs_set_format_source(subdev, sd_state, fmt); + if (sensor->embedded_start != sensor->embedded_end) + ccs_set_format_meta(subdev, sd_state, NULL); mutex_unlock(&sensor->mutex); @@ -2498,6 +2714,12 @@ static int ccs_sel_supported(struct v4l2_subdev *subdev, struct ccs_sensor *sensor = to_ccs_sensor(subdev); struct ccs_subdev *ssd = to_ccs_subdev(subdev); + if (sel->stream != CCS_STREAM_PIXEL) + return -EINVAL; + + if (sel->pad == CCS_PAD_META) + return -EINVAL; + /* We only implement crop in three places. */ switch (sel->target) { case V4L2_SEL_TGT_CROP: @@ -2542,7 +2764,8 @@ static int ccs_set_crop(struct v4l2_subdev *subdev, if (sel->pad == ssd->sink_pad) { struct v4l2_mbus_framefmt *mfmt = - v4l2_subdev_state_get_format(sd_state, sel->pad); + v4l2_subdev_state_get_format(sd_state, sel->pad, + CCS_STREAM_PIXEL); src_size.width = mfmt->width; src_size.height = mfmt->height; @@ -2603,7 +2826,9 @@ static int ccs_get_selection(struct v4l2_subdev *subdev, } else if (sel->pad == ssd->sink_pad) { struct v4l2_mbus_framefmt *sink_fmt = v4l2_subdev_state_get_format(sd_state, - ssd->sink_pad); + ssd->sink_pad, + CCS_STREAM_PIXEL); + sel->r.top = sel->r.left = 0; sel->r.width = sink_fmt->width; sel->r.height = sink_fmt->height; @@ -2686,6 +2911,14 @@ static int ccs_get_frame_desc(struct v4l2_subdev *subdev, unsigned int pad, entry++; desc->num_entries++; + if (sensor->embedded_start != sensor->embedded_end) { + entry->pixelcode = MEDIA_BUS_FMT_CCS_EMBEDDED; + entry->stream = CCS_STREAM_META; + entry->bus.csi2.dt = MIPI_CSI2_DT_EMBEDDED_8B; + entry++; + desc->num_entries++; + } + return 0; } @@ -3004,6 +3237,8 @@ static void ccs_cleanup(struct ccs_sensor *sensor) ccs_free_controls(sensor); } +static const struct v4l2_subdev_internal_ops ccs_internal_ops; + static int ccs_init_subdev(struct ccs_sensor *sensor, struct ccs_subdev *ssd, const char *name, unsigned short num_pads, u32 function, @@ -3016,15 +3251,18 @@ static int ccs_init_subdev(struct ccs_sensor *sensor, if (!ssd) return 0; - if (ssd != sensor->src) + if (ssd != sensor->src) { v4l2_subdev_init(&ssd->sd, &ccs_ops); + ssd->sd.internal_ops = &ccs_internal_ops; + } ssd->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; ssd->sd.entity.function = function; ssd->sensor = sensor; ssd->npads = num_pads; - ssd->source_pad = num_pads - 1; + ssd->source_pad = + ssd == sensor->pixel_array ? CCS_PA_PAD_SRC : CCS_PAD_SRC; v4l2_i2c_subdev_set_name(&ssd->sd, client, sensor->minfo.name, name); @@ -3038,6 +3276,10 @@ static int ccs_init_subdev(struct ccs_sensor *sensor, ssd->sd.owner = THIS_MODULE; ssd->sd.dev = &client->dev; v4l2_set_subdevdata(&ssd->sd, client); + } else { + ssd->sd.flags |= V4L2_SUBDEV_FL_STREAMS; + ssd->pads[CCS_PAD_META].flags = + MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_INTERNAL; } rval = media_entity_pads_init(&ssd->sd.entity, ssd->npads, ssd->pads); @@ -3055,21 +3297,19 @@ static int ccs_init_subdev(struct ccs_sensor *sensor, return 0; } -static int ccs_init_state(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state) +static int __ccs_init_state(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state) { struct ccs_subdev *ssd = to_ccs_subdev(sd); struct ccs_sensor *sensor = ssd->sensor; unsigned int pad = ssd == sensor->pixel_array ? CCS_PA_PAD_SRC : CCS_PAD_SINK; struct v4l2_mbus_framefmt *fmt = - v4l2_subdev_state_get_format(sd_state, pad); + v4l2_subdev_state_get_format(sd_state, pad, CCS_STREAM_PIXEL); struct v4l2_rect *crop = - v4l2_subdev_state_get_crop(sd_state, pad); + v4l2_subdev_state_get_crop(sd_state, pad, CCS_STREAM_PIXEL); bool is_active = !sd->active_state || sd->active_state == sd_state; - mutex_lock(&sensor->mutex); - ccs_get_native_size(ssd, crop); fmt->width = crop->width; @@ -3081,20 +3321,78 @@ static int ccs_init_state(struct v4l2_subdev *sd, if (is_active) sensor->pa_src = *crop; - mutex_unlock(&sensor->mutex); return 0; } - fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC); + fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC, + CCS_STREAM_PIXEL); fmt->code = ssd == sensor->src ? sensor->csi_format->code : sensor->internal_csi_format->code; fmt->field = V4L2_FIELD_NONE; ccs_propagate(sd, sd_state, is_active, V4L2_SEL_TGT_CROP); + return 0; +} + +static int ccs_init_state(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state) +{ + struct ccs_subdev *ssd = to_ccs_subdev(sd); + struct ccs_sensor *sensor = ssd->sensor; + int rval; + + mutex_lock(&sensor->mutex); + rval = __ccs_init_state(sd, sd_state); mutex_unlock(&sensor->mutex); - return 0; + return rval; +} + +static int ccs_src_init_state(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state) +{ + struct v4l2_subdev_route routes[] = { + { + .sink_pad = CCS_PAD_SINK, + .source_pad = CCS_PAD_SRC, + .source_stream = CCS_STREAM_PIXEL, + .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE, + }, { + .sink_pad = CCS_PAD_META, + .source_pad = CCS_PAD_SRC, + .source_stream = CCS_STREAM_META, + .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE, + } + }; + struct v4l2_subdev_krouting routing = { + .routes = routes, + .num_routes = 1, + }; + struct ccs_subdev *ssd = to_ccs_subdev(sd); + struct ccs_sensor *sensor = ssd->sensor; + int rval; + + mutex_lock(&sensor->mutex); + + if (sensor->embedded_start != sensor->embedded_end) + routing.num_routes++; + + rval = v4l2_subdev_set_routing(sd, sd_state, &routing); + if (rval) + goto out; + + rval = __ccs_init_state(sd, sd_state); + if (rval) + goto out; + + if (sensor->embedded_start != sensor->embedded_end) + ccs_set_format_meta(sd, sd_state, NULL); + +out: + mutex_unlock(&sensor->mutex); + + return rval; } static const struct v4l2_subdev_video_ops ccs_video_ops = { @@ -3109,6 +3407,14 @@ static const struct v4l2_subdev_pad_ops ccs_pad_ops = { .set_fmt = ccs_set_format, .get_selection = ccs_get_selection, .set_selection = ccs_set_selection, +}; + +static const struct v4l2_subdev_pad_ops ccs_src_pad_ops = { + .enum_mbus_code = ccs_enum_mbus_code, + .get_fmt = ccs_get_format, + .set_fmt = ccs_set_format, + .get_selection = ccs_get_selection, + .set_selection = ccs_set_selection, .enable_streams = ccs_enable_streams, .disable_streams = ccs_disable_streams, .get_frame_desc = ccs_get_frame_desc, @@ -3125,12 +3431,22 @@ static const struct v4l2_subdev_ops ccs_ops = { .sensor = &ccs_sensor_ops, }; +static const struct v4l2_subdev_ops ccs_src_ops = { + .video = &ccs_video_ops, + .pad = &ccs_src_pad_ops, + .sensor = &ccs_sensor_ops, +}; + static const struct media_entity_operations ccs_entity_ops = { .link_validate = v4l2_subdev_link_validate, }; -static const struct v4l2_subdev_internal_ops ccs_internal_src_ops = { +static const struct v4l2_subdev_internal_ops ccs_internal_ops = { .init_state = ccs_init_state, +}; + +static const struct v4l2_subdev_internal_ops ccs_src_internal_ops = { + .init_state = ccs_src_init_state, .registered = ccs_registered, .unregistered = ccs_unregistered, }; @@ -3281,8 +3597,8 @@ static int ccs_probe(struct i2c_client *client) sensor->src = &sensor->ssds[sensor->ssds_used]; - v4l2_i2c_subdev_init(&sensor->src->sd, client, &ccs_ops); - sensor->src->sd.internal_ops = &ccs_internal_src_ops; + v4l2_i2c_subdev_init(&sensor->src->sd, client, &ccs_src_ops); + sensor->src->sd.internal_ops = &ccs_src_internal_ops; sensor->regulators = devm_kcalloc(&client->dev, ARRAY_SIZE(ccs_regulators), @@ -3553,12 +3869,20 @@ static int ccs_probe(struct i2c_client *client) goto out_cleanup; } - rval = ccs_init_subdev(sensor, sensor->scaler, " scaler", 2, + rval = ccs_init_subdev(sensor, sensor->scaler, " scaler", + sensor->ssds_used != CCS_SUBDEVS ? + CCS_PADS_NOMETA : + sensor->embedded_start == sensor->embedded_end ? + CCS_PADS_NOMETA : CCS_PADS, MEDIA_ENT_F_PROC_VIDEO_SCALER, "ccs scaler mutex", &scaler_lock_key); if (rval) goto out_cleanup; - rval = ccs_init_subdev(sensor, sensor->binner, " binner", 2, + rval = ccs_init_subdev(sensor, sensor->binner, " binner", + sensor->ssds_used == CCS_SUBDEVS ? + CCS_PADS_NOMETA : + sensor->embedded_start == sensor->embedded_end ? + CCS_PADS_NOMETA : CCS_PADS, MEDIA_ENT_F_PROC_VIDEO_SCALER, "ccs binner mutex", &binner_lock_key); if (rval) diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h index 90b442a3d53e..477b2fb99aa0 100644 --- a/drivers/media/i2c/ccs/ccs.h +++ b/drivers/media/i2c/ccs/ccs.h @@ -173,11 +173,18 @@ struct ccs_csi_data_format { #define CCS_SUBDEVS 3 #define CCS_PA_PAD_SRC 0 -#define CCS_PAD_SINK 0 -#define CCS_PAD_SRC 1 -#define CCS_PADS 2 +enum { + CCS_PAD_SINK, + CCS_PAD_SRC, + CCS_PAD_META, + CCS_PADS_NOMETA = CCS_PAD_META, + CCS_PADS, +}; -#define CCS_STREAM_PIXEL 0 +enum { + CCS_STREAM_PIXEL, + CCS_STREAM_META, +}; struct ccs_binning_subtype { u8 horizontal:4; @@ -228,6 +235,9 @@ struct ccs_sensor { int default_pixel_order; struct ccs_data_container sdata, mdata; + u32 embedded_mbus_code; + u8 emb_data_ctrl; + u8 binning_horizontal; u8 binning_vertical; From patchwork Tue Apr 16 19:33:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789611 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 570AA13AD38 for ; Tue, 16 Apr 2024 19:34:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296055; cv=none; b=B4x/jwerfe1we61YX8MKGoZoY79LXpzb4004gtrxPc4hnOrY97VnZfXby2xOaoDCvqENPNQxlYGV4S3uNsJFLAdf9E7BJ4kA7Z8yujjAeYTnMGiQVpDiHEcIYw0IgnVxt7kSPCnE2mpYSggEy+ebU4iZbzVgjXD08kItD3n6L6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296055; c=relaxed/simple; bh=i6bfthToyGSHowMPrNeLJWut8tDpXcLMG17iMyMJPbQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aehmUMxnyNkmL9QTYK7lTksEuJ9gDpnDM3izPIZKpYs9L+Q5HFAzlTemS6EW/XkAzO8E7rhzWBkWyWK7Bdgc1hPYEx1gqrywnODzhEYVo8sx/gutbUiQID1IsW5aae1/rCLl/qlnuPTpjnPGTNRYUwyldBR4+mWOJLOOFHPBnp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RvvCF4GL; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RvvCF4GL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296053; x=1744832053; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i6bfthToyGSHowMPrNeLJWut8tDpXcLMG17iMyMJPbQ=; b=RvvCF4GLqnNuE60Bs/dIbT4Q59lq2ajP5cIYSXWRs+BP2A6AsBT0bO7t Bl0cJE9X1gORAcLzzNQpIevsCQo7hJxwm8Rh1dU3lBEW4KXf8XnBAoTD7 rMtsZc6e5B1BIHffI+BycMEaVfk47IruBd/VKdj8BrHy30sVekUCHJ2rW SwBi355Lo8Ro8hX+5s/IzJKidbMHvmz24jYnXaZTMaYe2+d9zZTieq4Oi 3eXwtUWkNHa5Yw4CX7/BQuKhqeTtSrLuUJOuZIMq8T9c7Za7K0HKn93NS kOdQvDPqdoLbCusadKmfvohM5lMvEryv6or/0vN9OkXNLGACRctXtFu9/ A==; X-CSE-ConnectionGUID: czA8fpmBTUiRadtUJKSzdA== X-CSE-MsgGUID: RnmU2HgxQiWzILFw2G/vUA== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929862" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929862" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:12 -0700 X-CSE-ConnectionGUID: 3x2+mAS6SQK2U8rrQZdPlA== X-CSE-MsgGUID: koBW8OWbSFGIbnLJIThtnQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380240" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:09 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 9A9DD12056F; Tue, 16 Apr 2024 22:34:05 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 32/46] media: ccs: Rely on sub-device state locking Date: Tue, 16 Apr 2024 22:33:05 +0300 Message-Id: <20240416193319.778192-33-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rely on sub-device state locking to serialise access to driver's data structures. The driver-provided mutex is used as the state lock for all driver sub-devices. Signed-off-by: Sakari Ailus --- drivers/media/i2c/ccs/ccs-core.c | 192 +++++++++++++------------------ drivers/media/i2c/ccs/ccs.h | 1 - 2 files changed, 81 insertions(+), 112 deletions(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index 299b5ac6538c..f82f3ec37c7c 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -541,12 +541,13 @@ static int ccs_pll_update(struct ccs_sensor *sensor) * */ -static void __ccs_update_exposure_limits(struct ccs_sensor *sensor) +static void __ccs_update_exposure_limits(struct ccs_sensor *sensor, + struct v4l2_rect *pa_src) { struct v4l2_ctrl *ctrl = sensor->exposure; int max; - max = sensor->pa_src.height + sensor->vblank->val - + max = pa_src->height + sensor->vblank->val - CCS_LIM(sensor, COARSE_INTEGRATION_TIME_MAX_MARGIN); __v4l2_ctrl_modify_range(ctrl, ctrl->minimum, max, ctrl->step, max); @@ -649,12 +650,20 @@ static int ccs_set_ctrl(struct v4l2_ctrl *ctrl) container_of(ctrl->handler, struct ccs_subdev, ctrl_handler) ->sensor; struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); + struct v4l2_subdev_state *state; + struct v4l2_rect *pa_src; int pm_status; u32 orient = 0; unsigned int i; int exposure; int rval; + if (ctrl->id == V4L2_CID_VBLANK || ctrl->id == V4L2_CID_HBLANK) { + state = v4l2_subdev_get_locked_active_state(&sensor->pixel_array->sd); + pa_src = v4l2_subdev_state_get_crop(state, CCS_PA_PAD_SRC, + CCS_STREAM_PIXEL); + } + switch (ctrl->id) { case V4L2_CID_HFLIP: case V4L2_CID_VFLIP: @@ -673,7 +682,7 @@ static int ccs_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_VBLANK: exposure = sensor->exposure->val; - __ccs_update_exposure_limits(sensor); + __ccs_update_exposure_limits(sensor, pa_src); if (exposure > sensor->exposure->maximum) { sensor->exposure->val = sensor->exposure->maximum; @@ -765,12 +774,12 @@ static int ccs_set_ctrl(struct v4l2_ctrl *ctrl) break; case V4L2_CID_VBLANK: rval = ccs_write(sensor, FRAME_LENGTH_LINES, - sensor->pa_src.height + ctrl->val); + pa_src->height + ctrl->val); break; case V4L2_CID_HBLANK: rval = ccs_write(sensor, LINE_LENGTH_PCK, - sensor->pa_src.width + ctrl->val); + pa_src->width + ctrl->val); break; case V4L2_CID_TEST_PATTERN: @@ -1225,7 +1234,8 @@ static int ccs_get_mbus_formats(struct ccs_sensor *sensor) return 0; } -static void ccs_update_blanking(struct ccs_sensor *sensor) +static void ccs_update_blanking(struct ccs_sensor *sensor, + struct v4l2_rect *pa_src) { struct v4l2_ctrl *vblank = sensor->vblank; struct v4l2_ctrl *hblank = sensor->hblank; @@ -1248,21 +1258,26 @@ static void ccs_update_blanking(struct ccs_sensor *sensor) min = max_t(int, CCS_LIM(sensor, MIN_FRAME_BLANKING_LINES), - min_fll - sensor->pa_src.height); - max = max_fll - sensor->pa_src.height; + min_fll - pa_src->height); + max = max_fll - pa_src->height; __v4l2_ctrl_modify_range(vblank, min, max, vblank->step, min); - min = max_t(int, min_llp - sensor->pa_src.width, min_lbp); - max = max_llp - sensor->pa_src.width; + min = max_t(int, min_llp - pa_src->width, min_lbp); + max = max_llp - pa_src->width; __v4l2_ctrl_modify_range(hblank, min, max, hblank->step, min); - __ccs_update_exposure_limits(sensor); + __ccs_update_exposure_limits(sensor, pa_src); } static int ccs_pll_blanking_update(struct ccs_sensor *sensor) { + struct v4l2_subdev_state *state = + v4l2_subdev_get_locked_active_state(&sensor->pixel_array->sd); + struct v4l2_rect *pa_src = + v4l2_subdev_state_get_crop(state, CCS_PA_PAD_SRC, + CCS_STREAM_PIXEL); struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); int rval; @@ -1271,15 +1286,15 @@ static int ccs_pll_blanking_update(struct ccs_sensor *sensor) return rval; /* Output from pixel array, including blanking */ - ccs_update_blanking(sensor); + ccs_update_blanking(sensor, pa_src); dev_dbg(&client->dev, "vblank\t\t%d\n", sensor->vblank->val); dev_dbg(&client->dev, "hblank\t\t%d\n", sensor->hblank->val); dev_dbg(&client->dev, "real timeperframe\t100/%d\n", sensor->pll.pixel_rate_pixel_array / - ((sensor->pa_src.width + sensor->hblank->val) * - (sensor->pa_src.height + sensor->vblank->val) / 100)); + ((pa_src->width + sensor->hblank->val) * + (pa_src->height + sensor->vblank->val) / 100)); return 0; } @@ -1788,6 +1803,16 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, u64 streams_mask) { struct ccs_sensor *sensor = to_ccs_sensor(subdev); + struct v4l2_subdev_state *pa_state = + v4l2_subdev_get_locked_active_state(&sensor->pixel_array->sd); + struct v4l2_subdev_state *src_state = + v4l2_subdev_get_locked_active_state(&sensor->src->sd); + struct v4l2_rect *pa_src = + v4l2_subdev_state_get_crop(pa_state, CCS_PA_PAD_SRC, + CCS_STREAM_PIXEL); + struct v4l2_rect *src_src = + v4l2_subdev_state_get_crop(src_state, CCS_PAD_SRC, + CCS_STREAM_PIXEL); struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); unsigned int binning_mode; int rval; @@ -1835,22 +1860,20 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, goto err_pm_put; /* Analog crop start coordinates */ - rval = ccs_write(sensor, X_ADDR_START, sensor->pa_src.left); + rval = ccs_write(sensor, X_ADDR_START, pa_src->left); if (rval < 0) goto err_pm_put; - rval = ccs_write(sensor, Y_ADDR_START, sensor->pa_src.top); + rval = ccs_write(sensor, Y_ADDR_START, pa_src->top); if (rval < 0) goto err_pm_put; /* Analog crop end coordinates */ - rval = ccs_write(sensor, X_ADDR_END, - sensor->pa_src.left + sensor->pa_src.width - 1); + rval = ccs_write(sensor, X_ADDR_END, pa_src->left + pa_src->width - 1); if (rval < 0) goto err_pm_put; - rval = ccs_write(sensor, Y_ADDR_END, - sensor->pa_src.top + sensor->pa_src.height - 1); + rval = ccs_write(sensor, Y_ADDR_END, pa_src->top + pa_src->height - 1); if (rval < 0) goto err_pm_put; @@ -1862,23 +1885,30 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, /* Digital crop */ if (CCS_LIM(sensor, DIGITAL_CROP_CAPABILITY) == CCS_DIGITAL_CROP_CAPABILITY_INPUT_CROP) { + struct v4l2_subdev_state *scaler_state = + v4l2_subdev_get_locked_active_state(&sensor->scaler->sd); + struct v4l2_rect *scaler_sink = + v4l2_subdev_state_get_crop(scaler_state, + sensor->scaler->sink_pad, + CCS_STREAM_PIXEL); + rval = ccs_write(sensor, DIGITAL_CROP_X_OFFSET, - sensor->scaler_sink.left); + scaler_sink->left); if (rval < 0) goto err_pm_put; rval = ccs_write(sensor, DIGITAL_CROP_Y_OFFSET, - sensor->scaler_sink.top); + scaler_sink->top); if (rval < 0) goto err_pm_put; rval = ccs_write(sensor, DIGITAL_CROP_IMAGE_WIDTH, - sensor->scaler_sink.width); + scaler_sink->width); if (rval < 0) goto err_pm_put; rval = ccs_write(sensor, DIGITAL_CROP_IMAGE_HEIGHT, - sensor->scaler_sink.height); + scaler_sink->height); if (rval < 0) goto err_pm_put; } @@ -1896,10 +1926,10 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, } /* Output size from sensor */ - rval = ccs_write(sensor, X_OUTPUT_SIZE, sensor->src_src.width); + rval = ccs_write(sensor, X_OUTPUT_SIZE, src_src->width); if (rval < 0) goto err_pm_put; - rval = ccs_write(sensor, Y_OUTPUT_SIZE, sensor->src_src.height); + rval = ccs_write(sensor, Y_OUTPUT_SIZE, src_src->height); if (rval < 0) goto err_pm_put; @@ -2088,9 +2118,6 @@ static int ccs_enum_mbus_code(struct v4l2_subdev *subdev, struct ccs_sensor *sensor = to_ccs_sensor(subdev); unsigned int i; int idx = -1; - int rval = -EINVAL; - - mutex_lock(&sensor->mutex); dev_err(&client->dev, "subdev %s, pad %u, index %u\n", subdev->name, code->pad, code->index); @@ -2098,12 +2125,11 @@ static int ccs_enum_mbus_code(struct v4l2_subdev *subdev, if (subdev == &sensor->src->sd) { if (code->pad == CCS_PAD_META) { if (code->index) - goto out; + return -EINVAL; code->code = MEDIA_BUS_FMT_CCS_EMBEDDED; - rval = 0; - goto out; + return 0; } if (code->stream == CCS_STREAM_META) { struct v4l2_mbus_framefmt *pix_fmt = @@ -2150,21 +2176,21 @@ static int ccs_enum_mbus_code(struct v4l2_subdev *subdev, } if (WARN_ON(i > ARRAY_SIZE(codes)) || code->index >= i) - goto out; + return -EINVAL; code->code = codes[code->index]; - rval = 0; - goto out; + + return 0; } } if (subdev != &sensor->src->sd || code->pad != CCS_PAD_SRC) { if (code->index) - goto out; + return -EINVAL; code->code = sensor->internal_csi_format->code; - rval = 0; - goto out; + + return 0; } for (i = 0; i < ARRAY_SIZE(ccs_csi_data_formats); i++) { @@ -2175,18 +2201,14 @@ static int ccs_enum_mbus_code(struct v4l2_subdev *subdev, code->code = ccs_csi_data_formats[i].code; dev_err(&client->dev, "found index %u, i %u, code %x\n", code->index, i, code->code); - rval = 0; - break; + return 0; } } -out: - mutex_unlock(&sensor->mutex); - - return rval; + return -EINVAL; } -static u32 __ccs_get_mbus_code(struct v4l2_subdev *subdev, unsigned int pad) +static u32 ccs_get_mbus_code(struct v4l2_subdev *subdev, unsigned int pad) { struct ccs_sensor *sensor = to_ccs_sensor(subdev); @@ -2196,33 +2218,19 @@ static u32 __ccs_get_mbus_code(struct v4l2_subdev *subdev, unsigned int pad) return sensor->internal_csi_format->code; } -static int __ccs_get_format(struct v4l2_subdev *subdev, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_format *fmt) +static int ccs_get_format(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) { fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad, fmt->stream); if (fmt->pad != CCS_PAD_META && fmt->stream != CCS_STREAM_META) - fmt->format.code = __ccs_get_mbus_code(subdev, fmt->pad); + fmt->format.code = ccs_get_mbus_code(subdev, fmt->pad); return 0; } -static int ccs_get_format(struct v4l2_subdev *subdev, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_format *fmt) -{ - struct ccs_sensor *sensor = to_ccs_sensor(subdev); - int rval; - - mutex_lock(&sensor->mutex); - rval = __ccs_get_format(subdev, sd_state, fmt); - mutex_unlock(&sensor->mutex); - - return rval; -} - /* Changes require propagation only on sink pad. */ static void ccs_propagate(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, int which, @@ -2246,7 +2254,6 @@ static void ccs_propagate(struct v4l2_subdev *subdev, sensor->scale_m = CCS_LIM(sensor, SCALER_N_MIN); sensor->scaling_mode = CCS_SCALING_MODE_NO_SCALING; - sensor->scaler_sink = *comp; } else if (ssd == sensor->binner) { sensor->binning_horizontal = 1; sensor->binning_vertical = 1; @@ -2261,8 +2268,6 @@ static void ccs_propagate(struct v4l2_subdev *subdev, CCS_STREAM_PIXEL); fmt->width = comp->width; fmt->height = comp->height; - if (which == V4L2_SUBDEV_FORMAT_ACTIVE && ssd == sensor->src) - sensor->src_src = *crop; break; default: WARN_ON_ONCE(1); @@ -2281,7 +2286,7 @@ static int ccs_set_format_source(struct v4l2_subdev *subdev, unsigned int i; int rval; - rval = __ccs_get_format(subdev, sd_state, fmt); + rval = ccs_get_format(subdev, sd_state, fmt); if (rval) return rval; @@ -2410,13 +2415,9 @@ static int ccs_set_format(struct v4l2_subdev *subdev, if (subdev == &sensor->src->sd && fmt->pad == CCS_PAD_META) return ccs_get_format(subdev, sd_state, fmt); - mutex_lock(&sensor->mutex); - if (subdev == &sensor->src->sd && fmt->stream == CCS_STREAM_META) { ccs_set_format_meta(subdev, sd_state, &fmt->format); - mutex_unlock(&sensor->mutex); - return 0; } @@ -2427,13 +2428,12 @@ static int ccs_set_format(struct v4l2_subdev *subdev, if (sensor->embedded_start != sensor->embedded_end) ccs_set_format_meta(subdev, sd_state, NULL); - mutex_unlock(&sensor->mutex); - return rval; } /* Sink pad. Width and height are changeable here. */ - fmt->format.code = __ccs_get_mbus_code(subdev, fmt->pad); + fmt->format.code = ccs_get_mbus_code(subdev, fmt->pad); + fmt->format.width &= ~1; fmt->format.height &= ~1; fmt->format.field = V4L2_FIELD_NONE; @@ -2456,8 +2456,6 @@ static int ccs_set_format(struct v4l2_subdev *subdev, crop->height = fmt->format.height; ccs_propagate(subdev, sd_state, fmt->which, V4L2_SEL_TGT_CROP); - mutex_unlock(&sensor->mutex); - return 0; } @@ -2765,9 +2763,6 @@ static int ccs_set_crop(struct v4l2_subdev *subdev, if (ssd != sensor->pixel_array && sel->pad == CCS_PAD_SINK) ccs_propagate(subdev, sd_state, sel->which, V4L2_SEL_TGT_CROP); - else if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE && - ssd == sensor->pixel_array) - sensor->pa_src = sel->r; return 0; } @@ -2839,8 +2834,6 @@ static int ccs_set_selection(struct v4l2_subdev *subdev, if (ret) return ret; - mutex_lock(&sensor->mutex); - sel->r.left = max(0, sel->r.left & ~1); sel->r.top = max(0, sel->r.top & ~1); sel->r.width = CCS_ALIGN_DIM(sel->r.width, sel->flags); @@ -2862,7 +2855,6 @@ static int ccs_set_selection(struct v4l2_subdev *subdev, ret = -EINVAL; } - mutex_unlock(&sensor->mutex); return ret; } @@ -3238,6 +3230,7 @@ static int ccs_init_subdev(struct ccs_sensor *sensor, ssd->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; ssd->sd.entity.function = function; + ssd->sd.state_lock = &sensor->mutex; ssd->sensor = sensor; ssd->npads = num_pads; @@ -3277,8 +3270,8 @@ static int ccs_init_subdev(struct ccs_sensor *sensor, return 0; } -static int __ccs_init_state(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state) +static int ccs_init_state(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state) { struct ccs_subdev *ssd = to_ccs_subdev(sd); struct ccs_sensor *sensor = ssd->sensor; @@ -3297,12 +3290,8 @@ static int __ccs_init_state(struct v4l2_subdev *sd, fmt->code = sensor->internal_csi_format->code; fmt->field = V4L2_FIELD_NONE; - if (ssd == sensor->pixel_array) { - if (is_active) - sensor->pa_src = *crop; - + if (ssd == sensor->pixel_array) return 0; - } fmt = v4l2_subdev_state_get_format(sd_state, CCS_PAD_SRC, CCS_STREAM_PIXEL); @@ -3315,20 +3304,6 @@ static int __ccs_init_state(struct v4l2_subdev *sd, return 0; } -static int ccs_init_state(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state) -{ - struct ccs_subdev *ssd = to_ccs_subdev(sd); - struct ccs_sensor *sensor = ssd->sensor; - int rval; - - mutex_lock(&sensor->mutex); - rval = __ccs_init_state(sd, sd_state); - mutex_unlock(&sensor->mutex); - - return rval; -} - static int ccs_src_init_state(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state) { @@ -3353,25 +3328,20 @@ static int ccs_src_init_state(struct v4l2_subdev *sd, struct ccs_sensor *sensor = ssd->sensor; int rval; - mutex_lock(&sensor->mutex); - if (sensor->embedded_start != sensor->embedded_end) routing.num_routes++; rval = v4l2_subdev_set_routing(sd, sd_state, &routing); if (rval) - goto out; + return 0; - rval = __ccs_init_state(sd, sd_state); + rval = ccs_init_state(sd, sd_state); if (rval) - goto out; + return 0; if (sensor->embedded_start != sensor->embedded_end) ccs_set_format_meta(sd, sd_state, NULL); -out: - mutex_unlock(&sensor->mutex); - return rval; } diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h index 477b2fb99aa0..dcca3f88ea67 100644 --- a/drivers/media/i2c/ccs/ccs.h +++ b/drivers/media/i2c/ccs/ccs.h @@ -230,7 +230,6 @@ struct ccs_sensor { u32 mbus_frame_fmts; const struct ccs_csi_data_format *csi_format; const struct ccs_csi_data_format *internal_csi_format; - struct v4l2_rect pa_src, scaler_sink, src_src; u32 default_mbus_frame_fmts; int default_pixel_order; struct ccs_data_container sdata, mdata; From patchwork Tue Apr 16 19:33:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789610 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9125D13B2A2 for ; Tue, 16 Apr 2024 19:34:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296057; cv=none; b=iboz5i3iTzBHMxBYuJ7tPnmmq76jB3pTERMMqul7PzCmPXuAPC3Qe6eC1rU07birYHyTPmxc6YHo7blhNtP41jr/H544WLOLIcQSMbG89eBfoz4Nnb8PmLCwT/YE534KKMIktVjq82Ri7r9PmzKX7JkPZfPkF041bS4p0Ggn/bA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296057; c=relaxed/simple; bh=VseC5ZEVpd8Y3HMrTxnUxiJzqqyabBAr8R5/lBopHaY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bsvc3HwZ3eMOID++/rR9gxQxGNKKxlH8/SD4oa4rg8Hu96jeKE57jPotSqs+ti3S2u3UKIYOYYiartdKbT7oafK8jZZJJtfa4RWS+IdpOvhpvbYysHS5Lk8GJfzdkak1ji6Bx1iXzHUkfYtE+LOBeA1TglT7KZ5j6ikQtPZttCY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Yr/hejd0; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Yr/hejd0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296056; x=1744832056; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VseC5ZEVpd8Y3HMrTxnUxiJzqqyabBAr8R5/lBopHaY=; b=Yr/hejd017IXTU/9vljaX6naAyc3ITsIkPOJCq0EnQrBjhdlLn1kGW8P 2c3uD3bdYvMJIHwHmIMfvYZSjBaxPb2kBzT0j9G3KKs4g611+jsFein1R 4vLCviQWAMkxFDPe9TaY3kCYMKjnK7IYU51rfSKNF3xW5m0z1QGIvYOEb 3nDpOkCTPWcu7snLIpC9la9Lx/ZM2drInY3TjXX3F18EdPGgGQVZxZRrn 8kXWQRzmzBoPWP7iZ0nzn9CWUhnINGtWf3Git8nz6IBrq/C13jKtofqU3 WwRD7gJYqR1WmeYXaVf4A3svYnaXKvVwNgVG55Ulx7/4iCN84lEfz8H0H A==; X-CSE-ConnectionGUID: mDpWB9SsQm69ZKR5NTlABg== X-CSE-MsgGUID: TzuxF3A+Qh2e9lBq0+cz/A== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929867" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929867" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:14 -0700 X-CSE-ConnectionGUID: QlZmTjp5RD6X9jSV0rjiSg== X-CSE-MsgGUID: uNMFb56DQeOa4Wh4cSz9DA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380247" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:11 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 3216611F879; Tue, 16 Apr 2024 22:34:07 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 33/46] media: ccs: Compute binning configuration from sub-device state Date: Tue, 16 Apr 2024 22:33:06 +0300 Message-Id: <20240416193319.778192-34-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Calculate binning configuration from sub-device state so the state related configuration can be removed from the driver's device context struct. Signed-off-by: Sakari Ailus --- drivers/media/i2c/ccs/ccs-core.c | 56 +++++++++++++++++++------------- drivers/media/i2c/ccs/ccs.h | 3 -- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index f82f3ec37c7c..08e719d611fb 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -511,13 +511,36 @@ static int ccs_pll_try(struct ccs_sensor *sensor, struct ccs_pll *pll) return ccs_pll_calculate(&client->dev, &lim, pll); } +static void +ccs_get_binning(struct ccs_sensor *sensor, u8 *binning_mode, u8 *binh, u8 *binv) +{ + struct v4l2_subdev_state *state = + v4l2_subdev_get_locked_active_state(&sensor->binner->sd); + const struct v4l2_rect *sink_crop = + v4l2_subdev_state_get_crop(state, CCS_PAD_SINK, + CCS_STREAM_PIXEL); + const struct v4l2_rect *sink_comp = + v4l2_subdev_state_get_compose(state, CCS_PAD_SINK, + CCS_STREAM_PIXEL); + + if (binning_mode) + *binning_mode = sink_crop->width == sink_comp->width && + sink_crop->height == sink_comp->height ? 0 : 1; + + *binh = sink_crop->width / sink_comp->width; + *binv = sink_crop->height / sink_comp->height; +} + static int ccs_pll_update(struct ccs_sensor *sensor) { struct ccs_pll *pll = &sensor->pll; + u8 binh, binv; int rval; - pll->binning_horizontal = sensor->binning_horizontal; - pll->binning_vertical = sensor->binning_vertical; + ccs_get_binning(sensor, NULL, &binh, &binv); + + pll->binning_horizontal = binh; + pll->binning_vertical = binv; pll->link_freq = sensor->link_freq->qmenu_int[sensor->link_freq->val]; pll->scale_m = sensor->scale_m; @@ -1241,8 +1264,11 @@ static void ccs_update_blanking(struct ccs_sensor *sensor, struct v4l2_ctrl *hblank = sensor->hblank; u16 min_fll, max_fll, min_llp, max_llp, min_lbp; int min, max; + u8 binh, binv; + + ccs_get_binning(sensor, NULL, &binh, &binv); - if (sensor->binning_vertical > 1 || sensor->binning_horizontal > 1) { + if (binv > 1 || binh > 1) { min_fll = CCS_LIM(sensor, MIN_FRAME_LENGTH_LINES_BIN); max_fll = CCS_LIM(sensor, MAX_FRAME_LENGTH_LINES_BIN); min_llp = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK_BIN); @@ -1814,7 +1840,7 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, v4l2_subdev_state_get_crop(src_state, CCS_PAD_SRC, CCS_STREAM_PIXEL); struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); - unsigned int binning_mode; + u8 binning_mode, binh, binv; int rval; if (pad != CCS_PAD_SRC) @@ -1836,19 +1862,12 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, goto err_pm_put; /* Binning configuration */ - if (sensor->binning_horizontal == 1 && - sensor->binning_vertical == 1) { - binning_mode = 0; - } else { - u8 binning_type = - (sensor->binning_horizontal << 4) - | sensor->binning_vertical; + ccs_get_binning(sensor, &binning_mode, &binh, &binv); - rval = ccs_write(sensor, BINNING_TYPE, binning_type); + if (binning_mode) { + rval = ccs_write(sensor, BINNING_TYPE, (binh << 4) | binv); if (rval < 0) goto err_pm_put; - - binning_mode = 1; } rval = ccs_write(sensor, BINNING_MODE, binning_mode); if (rval < 0) @@ -2254,9 +2273,6 @@ static void ccs_propagate(struct v4l2_subdev *subdev, sensor->scale_m = CCS_LIM(sensor, SCALER_N_MIN); sensor->scaling_mode = CCS_SCALING_MODE_NO_SCALING; - } else if (ssd == sensor->binner) { - sensor->binning_horizontal = 1; - sensor->binning_vertical = 1; } } fallthrough; @@ -2530,10 +2546,6 @@ static void ccs_set_compose_binner(struct v4l2_subdev *subdev, best = this; } } - if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) { - sensor->binning_vertical = binv; - sensor->binning_horizontal = binh; - } sel->r.width = (sink_crop->width / binh) & ~1; sel->r.height = (sink_crop->height / binv) & ~1; @@ -3715,8 +3727,6 @@ static int ccs_probe(struct i2c_client *client) sensor->binning_subtypes[i].vertical); } } - sensor->binning_horizontal = 1; - sensor->binning_vertical = 1; if (device_create_file(&client->dev, &dev_attr_ident) != 0) { dev_err(&client->dev, "sysfs ident entry creation failed\n"); diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h index dcca3f88ea67..aadbd4302607 100644 --- a/drivers/media/i2c/ccs/ccs.h +++ b/drivers/media/i2c/ccs/ccs.h @@ -237,9 +237,6 @@ struct ccs_sensor { u32 embedded_mbus_code; u8 emb_data_ctrl; - u8 binning_horizontal; - u8 binning_vertical; - u8 scale_m; u8 scaling_mode; From patchwork Tue Apr 16 19:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789609 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 211F8139CF4 for ; Tue, 16 Apr 2024 19:34:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296059; cv=none; b=nmAeElHfNptBhcUCGyEHTGG0DxVrwDyESrHAd/YR4pXsDhI2YrDXu9vbolVSm8kPwuVrTX+KmDpl+666/riDwRRiw1q7w8hqEIuIH+hXc6FLwnPk77p+78612raFQcQtyV5xEWQEjJMgrYiBgXIrjPh5RUo2BzUXjKYsnPctKVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296059; c=relaxed/simple; bh=0El9SnbozgnjdR4/omqd9AoBKLjopdpOuHyz10wpJJc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RKVnC2hpS7XbMSQNc0z6uRPwyyciZrMSY5pBLGxy7pPWrhBAipnOXJjAut5+kIrraQmY3VoX3ynIwKuXEoaJycaFdX7EQS82nqpUeMkjimHKx/akLNYO9WFPhlq9BVOHUKgKfxFIwniIiemF9FJA7H2ZLf4q9kyvN/yBXM/UShQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FnIn3rxN; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FnIn3rxN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296058; x=1744832058; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0El9SnbozgnjdR4/omqd9AoBKLjopdpOuHyz10wpJJc=; b=FnIn3rxNMpsybY5BkzWMihYkK3DzbYz+ZRqlSQl+e9Th1ljdT9Io4bv7 M5knf/qT3cn8vXB8CXPdasPtXS5Q7AmcKY7stFy2LiiWIbSUIf26vu2bR QUG6+L9TEnpIkzpyFvJvNF9DKQSo6ycUon/tVUqkZuEs8oQ++Lz0bPF0W cIWfW01wHH0SRzxaMAuutB1QAVYR78P0U5ci3tY02vj5CN3iSaPUyYArO aDDYMFxmVvTuUs2eLUwWbBrXzbDOmRtEi+ebLK9eSnvuHTdFbdRc8nE/U 9JKDL86whaaXOuTBOiARR5NxLvdUtRscegEfinLXInCB5t7GTyf7j3FCm g==; X-CSE-ConnectionGUID: 8pgyWGr7Qn2c2nMNJFtFKA== X-CSE-MsgGUID: mQwKuccyT5aVQLA/uSdyWQ== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929882" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929882" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:18 -0700 X-CSE-ConnectionGUID: L9s79xE8SIyRDDThEBqCjA== X-CSE-MsgGUID: 7Vr+JP/zTtil41TEvDSOGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380261" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:15 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 95E5F12053D; Tue, 16 Apr 2024 22:34:11 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 36/46] media: uapi: Add media bus code for ov2740 embedded data Date: Tue, 16 Apr 2024 22:33:09 +0300 Message-Id: <20240416193319.778192-37-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a media bus code for ov2740 camera sensor embedded data and document it. Signed-off-by: Sakari Ailus Reviewed-by: Julien Massot --- .../media/v4l/subdev-formats.rst | 70 +++++++++++++++++++ include/uapi/linux/media-bus-format.h | 3 +- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst index a04756092238..c99b58cb8c7b 100644 --- a/Documentation/userspace-api/media/v4l/subdev-formats.rst +++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst @@ -8596,3 +8596,73 @@ This mbus code are only used for "2-byte simplified tagged data format" (code embedded data format codes. Also see :ref:`CCS driver documentation `. + +Omnivision OV2740 Embedded Data Format +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The Omnivision OV2740 camera sensor produces the following embedded data format, +indicated by mbus code MEDIA_BUS_FMT_OV2740_EMBEDDED. The format conforms to +:ref:`CCS embedded data format ` up to level 1. + +.. flat-table:: Omnivision OV2740 Embedded Data Format. Octets at indices marked + reserved or unused have been omitted from the table. The values + are big endian byte order. + :header-rows: 1 + + * - Offset + - Size in bits (active bits if not the same as size) + - Content description + * - 4 + - 16 (10--0) + - Analogue gain + * - 6 + - 16 + - Coarse integration time + * - 10 + - 8 + - Dpc correction threshold + * - 15 + - 16 + - Output image width + * - 17 + - 16 + - Output image height + * - 23 + - 8 + - MIPI header revision number (2) + * - 31 + - 8 + - Vertical (bit 1) and horizontal flip (bit 0) + * - 32 + - 8 + - Frame duration A + * - 33 + - 8 + - Frame duration B + * - 34 + - 8 + - Context count (2) + * - 35 + - 8 + - Context select + * - 54 + - 8 + - Data pedestal bits 9--2 + * - 63 + - 8 + - Frame average bits 9--2 + * - 64 + - 16 + - Digital gain red + * - 66 + - 16 + - Digital gain greenr + * - 68 + - 16 + - Digital gain blue + * - 70 + - 16 + - Digital gain greenb + * - 89 + - 8 + - Frame counter (starts at 1, wraps to 0 after 255) diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/media-bus-format.h index 03f7e9ab517b..13e68c2ccb61 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -183,7 +183,8 @@ #define MEDIA_BUS_FMT_META_20 0x8006 #define MEDIA_BUS_FMT_META_24 0x8007 -/* Specific metadata formats. Next is 0x9002. */ +/* Specific metadata formats. Next is 0x9003. */ #define MEDIA_BUS_FMT_CCS_EMBEDDED 0x9001 +#define MEDIA_BUS_FMT_OV2740_EMBEDDED 0x9002 #endif /* __LINUX_MEDIA_BUS_FORMAT_H */ From patchwork Tue Apr 16 19:33:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789608 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DDC413B7A4 for ; Tue, 16 Apr 2024 19:34:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296062; cv=none; b=Mkk5QSbDq2qJbQUe9/mVie0jXRYLOlkm4ApfGL8IfKWxwKCXpXR6MpI4QKGdBKtbBNSxN1zkPDiWpeOtLLPiqwmcIjt0semLyCg+FnDoZPTV/B7EzuNyMm4s59h2eBLPSzdUBQ0csD9aSvntazzQ9KY14QAzPh7vXFJNLScmj4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296062; c=relaxed/simple; bh=acCpd9amcw27N+BAvj5e+qX02/JuIUEeeHqfvajd/1E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nk8gnHMa7cQY2ws3pNRki11P2kkA8h2kyBCMyFWcXJXvqc6K/eOMW8irlGcwxsVPHTfN5t9oEtM9azX1x3hE67fAIJjOPetr+p5DT4Ppw+JV8K3mSvHBxLebvoWqRuwwWFVPT3l39uGpiMgI52G5v1CPE+ihTMjoDvG1khdsjzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Wf9C/9Dz; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Wf9C/9Dz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296061; x=1744832061; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=acCpd9amcw27N+BAvj5e+qX02/JuIUEeeHqfvajd/1E=; b=Wf9C/9DzWj1vEmSCrakMV+OmpxOqd3iHu5uqsRwQXV0kESCznmlabvlU KhfIofy40cNjHVJEW4SpyHHl7zfjnXSOCvmeby63V7vjyi7SoZ5a3HZzB SJpVB4etDBQatUVuCvhqzO7NInbGWVZW4O9AzzpTirPSM7QnGrChxkl8+ OhnljJMWvBANDZurWgEizJKopgI5SaKmANp4tnkyUl/1LC7JXSXuaBii/ AFXTVQ8xxtOvS07rPdot9AACQAkC9ge65nUeFXJSo3R6GTkio0RoJDwOk H41JCD/BlcUVYpQDRhDDkC+48bKRzRtI6vxyye+BeXE+45zgHHtlQvnU1 Q==; X-CSE-ConnectionGUID: XbbBrehxTsO1clpEUEjvUA== X-CSE-MsgGUID: 95fex9gaT+KKYENzzuCHdA== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929893" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929893" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:21 -0700 X-CSE-ConnectionGUID: 8O/dFcwlSQu4Cn99LkyDSQ== X-CSE-MsgGUID: JInbr9LWTzGn/6OZRi4uDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380272" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:18 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id A6CAB11F879; Tue, 16 Apr 2024 22:34:14 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 38/46] media: ov2740: Remove shorthand variables Date: Tue, 16 Apr 2024 22:33:11 +0300 Message-Id: <20240416193319.778192-39-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove two variables in ov2740_init_control() that are used as a shorthand for where the information is really located. Make the code more readable by removing them. Signed-off-by: Sakari Ailus Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov2740.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index 57906df7be4e..196a111516b0 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -754,10 +754,8 @@ static const struct v4l2_ctrl_ops ov2740_ctrl_ops = { static int ov2740_init_controls(struct ov2740 *ov2740) { struct v4l2_ctrl_handler *ctrl_hdlr; - const struct ov2740_mode *cur_mode; s64 exposure_max, h_blank, pixel_rate; u32 vblank_min, vblank_max, vblank_default; - int size; int ret; ctrl_hdlr = &ov2740->ctrl_handler; @@ -765,12 +763,10 @@ static int ov2740_init_controls(struct ov2740 *ov2740) if (ret) return ret; - cur_mode = ov2740->cur_mode; - size = ARRAY_SIZE(link_freq_menu_items); - ov2740->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov2740_ctrl_ops, - V4L2_CID_LINK_FREQ, size - 1, + V4L2_CID_LINK_FREQ, + ARRAY_SIZE(link_freq_menu_items) - 1, ov2740->supported_modes->link_freq_index, link_freq_menu_items); if (ov2740->link_freq) @@ -781,14 +777,14 @@ static int ov2740_init_controls(struct ov2740 *ov2740) V4L2_CID_PIXEL_RATE, 0, pixel_rate, 1, pixel_rate); - vblank_min = cur_mode->vts_min - cur_mode->height; - vblank_max = cur_mode->vts_max - cur_mode->height; - vblank_default = cur_mode->vts_def - cur_mode->height; + vblank_min = ov2740->cur_mode->vts_min - ov2740->cur_mode->height; + vblank_max = ov2740->cur_mode->vts_max - ov2740->cur_mode->height; + vblank_default = ov2740->cur_mode->vts_def - ov2740->cur_mode->height; ov2740->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops, V4L2_CID_VBLANK, vblank_min, vblank_max, 1, vblank_default); - h_blank = cur_mode->hts - cur_mode->width; + h_blank = ov2740->cur_mode->hts - ov2740->cur_mode->width; ov2740->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops, V4L2_CID_HBLANK, h_blank, h_blank, 1, h_blank); @@ -801,7 +797,7 @@ static int ov2740_init_controls(struct ov2740 *ov2740) v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops, V4L2_CID_DIGITAL_GAIN, OV2740_DGTL_GAIN_MIN, OV2740_DGTL_GAIN_MAX, OV2740_DGTL_GAIN_STEP, OV2740_DGTL_GAIN_DEFAULT); - exposure_max = cur_mode->vts_def - OV2740_EXPOSURE_MAX_MARGIN; + exposure_max = ov2740->cur_mode->vts_def - OV2740_EXPOSURE_MAX_MARGIN; ov2740->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov2740_ctrl_ops, V4L2_CID_EXPOSURE, OV2740_EXPOSURE_MIN, exposure_max, From patchwork Tue Apr 16 19:33:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789607 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D5DC13BC14 for ; Tue, 16 Apr 2024 19:34:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296066; cv=none; b=rjtg4AgUomdNkqUKHDMhCHKTrat8QXj8LdNKBXGIf6epzk783a6cFco1d8i4NTh6BU8TXyXbpjgiTSQFGbpIQL9L/cr7mSwJbEVsVUCudPpBLjX5VOL0i9PK8olZbpusG5IBQULQZiSw8wnbjp8kRf92BOvdXq70eozj6WRYREI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296066; c=relaxed/simple; bh=ktgBcAIWo1oDPDZ/a47CL3Fb7E4foBgOI2jxkm5ndDg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kdKE0zlAL8Bvh80PsqR0YPutwLjldWWtjWAJs44f8LRfBl5x8em9FIW3wUK/wGC9e/QYSQCCz0llY05c5f1oomUZ60IeavtgCPbySZzCQB6Q8cZ05d9NhaMQsuDGWDO8GiUWoXB2PSQxYiIndLCqfIDRO5zBkINk6GVhMQrfjek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=haLG6l5y; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="haLG6l5y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296065; x=1744832065; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ktgBcAIWo1oDPDZ/a47CL3Fb7E4foBgOI2jxkm5ndDg=; b=haLG6l5y7RFNsrPuXDKABBP/U4C4T2/Q6NRFDsnkxej4iA1Ed1cxsCny yKHMNVL+UlzfQlgswjDQSYlujtxuXoDATdxpRkUdo/8LkdN792SpdHaFS YKZjagpeyYQWvDX2ZdLLQ67uUxmvN9fSJGqZUr3mRoiqBOrftZvFh6a88 cQR5qTFyXE5MUIuvM+RY2rbhhNHhu7qUwnK1Bl73BY4vpgvOhwZ3VKlre 6GS1IPq/f/X4zVS1CHfGlzKQUl4FxmDlD997XTokY1HoICQLAzi2EhnIT Gk21uxOz4h6apPRgCBUDzzbHxdnWp+cc4chU2UULnFNQ9sxLqu1U2AiyL g==; X-CSE-ConnectionGUID: 72UauVXGQyePVA01NLlYxQ== X-CSE-MsgGUID: 53A/ISaFQYqQfSbmS1lu+Q== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929904" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929904" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:24 -0700 X-CSE-ConnectionGUID: 4HOwB6SvRsOQbkt+ezEHeA== X-CSE-MsgGUID: fcb65gt+Ro23FqDmodE/Uw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22380289" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:21 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id C8A4B1204F6; Tue, 16 Apr 2024 22:34:17 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 40/46] media: ov2740: Track streaming state Date: Tue, 16 Apr 2024 22:33:13 +0300 Message-Id: <20240416193319.778192-41-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 With enable_streams and disable_streams, the driver for a device where streams are not independently started and stopped needs to maintain state information on streams that have been requested to be started. Do that now. In the future, a helper function in the framework is a desirable way to do this instead. Signed-off-by: Sakari Ailus Reviewed-by: Julien Massot Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov2740.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index a12dc58fa0c0..c29e9b8cde15 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -539,6 +539,9 @@ struct ov2740 { /* True if the device has been identified */ bool identified; + + /* Track streaming state */ + u8 streaming; }; static inline struct ov2740 *to_ov2740(struct v4l2_subdev *subdev) @@ -926,6 +929,11 @@ static int ov2740_enable_streams(struct v4l2_subdev *sd, int link_freq_index; int ret; + if (ov2740->streaming) { + ov2740->streaming |= streams_mask; + return 0; + } + ret = pm_runtime_resume_and_get(&client->dev); if (ret < 0) return ret; @@ -972,6 +980,8 @@ static int ov2740_enable_streams(struct v4l2_subdev *sd, goto out_pm_put; } + ov2740->streaming |= streams_mask; + return 0; out_pm_put: @@ -988,6 +998,10 @@ static int ov2740_disable_streams(struct v4l2_subdev *sd, struct ov2740 *ov2740 = to_ov2740(sd); int ret; + ov2740->streaming &= ~streams_mask; + if (ov2740->streaming) + return 0; + ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1, OV2740_MODE_STANDBY); From patchwork Tue Apr 16 19:33:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789606 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B591139D19 for ; Tue, 16 Apr 2024 19:34:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296068; cv=none; b=rAS/EwxyniLl8ZFI/mGd5BfCB9KoLS3yWaoltzkG3k2sASgX4Hh8DTc05zu8PA7OeS4UeFGY8tFAuP+ZdA7XdN54z8Z/HPd21zL6Rl1qjUXWfAUg3yEhGsZn0x1OwdLfJlI4RM1U4fV3zYL0S5rX+Yqo97XvEWsMIDkERqB4D0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296068; c=relaxed/simple; bh=AlD2csMLI217TCppbDyg023f1jQwntjFBxAMr4Nxm5k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=eJ7dbvFptN7x7MuV/hhRQgzGwwJwwk8UfrAa4BXD+RuB7YxxmHAfYqzxOMa5sH9aBtr13drr87rR3I/yvbVWOpq7QsQhTsdEALCmhHQT3pzgoW75ISmPghCq69OKxAwIg2JWAybKIRt+kAEdxkakK5K6vXMyMFM/hpN2ROAz8oM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CkBiu0IS; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CkBiu0IS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296067; x=1744832067; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AlD2csMLI217TCppbDyg023f1jQwntjFBxAMr4Nxm5k=; b=CkBiu0ISXEG+J11X7ZauQWSx1KQlDqQnTV22BtRyh1R1gUHdOKnLPf6A JeVNksXsIf1S1F5Lj7vOr3ghqkmI7YFRB9DlmN0/VkKoe6LJ2Lz9eSHeb itsTcSS1L3ypFO6yDe4X/JatgTWP+GwrM39nvLIKkS61WyhFPWQ7cHgbf gk/Ss4UttYNenlg2Txy0x3oosgK4Pc6Utm55woVFLdw5h8JTrHDI7aCg1 QuKz3qFuMgAM2giE09h6wUYeyrCQCcIeyvJkInPXW98pc/HjFQFjwcdeZ VsFLLvVg09ZHsbbcSQJQHRhnV/+4Bw+no7eF/c59vcEJ61crMJ7l4VGy1 A==; X-CSE-ConnectionGUID: cRGhaVzeSdSXB5d1eHJO2w== X-CSE-MsgGUID: ZG1n5nn1Qo2qQOoaVfrz5Q== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929917" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929917" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:27 -0700 X-CSE-ConnectionGUID: elgiOPVHQEOjP4iUZBioVA== X-CSE-MsgGUID: uIGFwab6TNW/ZfGwichXvw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22244785" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:24 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id A795B11F879; Tue, 16 Apr 2024 22:34:20 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 42/46] media: ov2740: Add generic sensor fwnode properties as controls Date: Tue, 16 Apr 2024 22:33:15 +0300 Message-Id: <20240416193319.778192-43-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add generic sensor property information as controĺs by using v4l2_fwnode_device_parse() and v4l2_ctrl_new_fwnode_properties(). Signed-off-by: Sakari Ailus Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov2740.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index dc0931308053..e37d824291fe 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -779,6 +779,8 @@ static const struct v4l2_ctrl_ops ov2740_ctrl_ops = { static int ov2740_init_controls(struct ov2740 *ov2740) { + struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd); + struct v4l2_fwnode_device_properties props; struct v4l2_ctrl_handler *ctrl_hdlr; s64 exposure_max, h_blank, pixel_rate; u32 vblank_min, vblank_max, vblank_default; @@ -789,6 +791,10 @@ static int ov2740_init_controls(struct ov2740 *ov2740) if (ret) return ret; + if (!v4l2_fwnode_device_parse(&client->dev, &props)) + v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov2740_ctrl_ops, + &props); + ov2740->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov2740_ctrl_ops, V4L2_CID_LINK_FREQ, From patchwork Tue Apr 16 19:33:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789605 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71667139D1A for ; Tue, 16 Apr 2024 19:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296071; cv=none; b=LAibgv87XXWr045fL8a6tkIs6MgEKwMH8tb4LgFbEiKlo7Q4+zgvuMOmMsVSX9khyHCG/enMUW/AE59FyRwfMijOkLD/8xCParROvEY4PMps4owGjAk0UHgbIGnUr2dqKLoqTWegT2fl4s/cHDlFE7FL9NamQuv4Yfs8es80smM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296071; c=relaxed/simple; bh=KF12zUFL4m8JlsH4O6dM657+op9z1vQ1HyC4fnTfROo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VPMgVO7cS7w2VmDEOIsFJTZLnoISXMImnulyuNUuilVkQJs5Ukf/FnVW3Qy0NARuaQh31E97/CUuaQ48I5w8RYqRg00E3FiP1x3cHS0sfqmFJzMDt5Lk1Vj4sFHSWb2CgtNeiLrQ8KKhJlllllwsZwMYZetl1Qpl2B/yUgsUgDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bjdQo9kH; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bjdQo9kH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296070; x=1744832070; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KF12zUFL4m8JlsH4O6dM657+op9z1vQ1HyC4fnTfROo=; b=bjdQo9kHU36yZjZUb74H22mF+o1y9yPwB4XRNNtDPdH2CyS5Ox/4N3KI M0Z57h+M9akN6loVTx37MiO1cWDplGK7370MQV7LTR02PghSCCQatL5n0 dpAj4l0VFn/xr/SqAdDIbW8/vtscil4NBQu24s0SyKDZh+eRPUvYM6AL5 pybeQTeG+mrG4ZsLocmYz7Lc3ZkGoN0mdF2+R8sEceiTIIcc2m47uZf30 utA3Ok0LLOSntQGlEd2DVXeLU5As/19mnF4OVdnkh410vxBbxwYFEFj2r PFrZuGl4tJflIXs2CTIN/ga+knxSIVEMNChGPUOTDhNlc35kBftL6+6qc g==; X-CSE-ConnectionGUID: v+2i9XleR2OzBOojw37VGA== X-CSE-MsgGUID: MCXjAK3uR4Om+5SRaJTsdw== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929930" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929930" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:30 -0700 X-CSE-ConnectionGUID: a9c4t4OhTyWmqpb1EieIGQ== X-CSE-MsgGUID: 8M9WdTjCRaawB5grXFMhFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22244797" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:27 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 0324D1204F9; Tue, 16 Apr 2024 22:34:23 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 44/46] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_IMMUTABLE sub-device routing flag Date: Tue, 16 Apr 2024 22:33:17 +0300 Message-Id: <20240416193319.778192-45-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a flag to denote immutable routes, V4L2_SUBDEV_ROUTE_FL_IMMUTABLE. Such routes cannot be changed and they're always active. Signed-off-by: Sakari Ailus --- Documentation/userspace-api/media/v4l/dev-subdev.rst | 4 +++- .../userspace-api/media/v4l/vidioc-subdev-g-routing.rst | 5 +++++ include/uapi/linux/v4l2-subdev.h | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Documentation/userspace-api/media/v4l/dev-subdev.rst b/Documentation/userspace-api/media/v4l/dev-subdev.rst index de8dfd4f11a5..5c63c8c24108 100644 --- a/Documentation/userspace-api/media/v4l/dev-subdev.rst +++ b/Documentation/userspace-api/media/v4l/dev-subdev.rst @@ -572,7 +572,9 @@ internal pad always has a single stream only (0). Routes from an internal sink pad to an external source pad are typically not modifiable but they can be activated and deactivated using the :ref:`V4L2_SUBDEV_ROUTE_FL_ACTIVE ` flag, depending -on driver capabilities. +on driver capabilities. The :ref:`V4L2_SUBDEV_ROUTE_FL_IMMUTABLE +` flag indicates that the +``V4L2_SUBDEV_ROUTE_FLAG_ACTIVE`` of the route may not be unset. Interaction between routes, streams, formats and selections ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst index 88df7bf80b00..c0f6d49cac6d 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst @@ -150,6 +150,11 @@ Also ``VIDIOC_SUBDEV_S_ROUTING`` may return more route than the user provided in * - V4L2_SUBDEV_ROUTE_FL_ACTIVE - 0x0001 - The route is enabled. Set by applications. + * - V4L2_SUBDEV_ROUTE_FL_IMMUTABLE + - 0x0002 + - The route is immutable. Set by the driver. Indicates that the + ``V4L2_SUBDEV_ROUTE_FL_ACTIVE`` flag of an immutable route may not be + unset. Return Value ============ diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h index 6a39128d0606..c6f1228d43b1 100644 --- a/include/uapi/linux/v4l2-subdev.h +++ b/include/uapi/linux/v4l2-subdev.h @@ -204,6 +204,11 @@ struct v4l2_subdev_capability { * on a video node. */ #define V4L2_SUBDEV_ROUTE_FL_ACTIVE (1U << 0) +/* + * Is the route immutable. The ACTIVE flag of an immutable route may not be + * changed. + */ +#define V4L2_SUBDEV_ROUTE_FL_IMMUTABLE (1U << 1) /** * struct v4l2_subdev_route - A route inside a subdev From patchwork Tue Apr 16 19:33:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 789604 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16C5D13C3CF for ; Tue, 16 Apr 2024 19:34:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296074; cv=none; b=rK94UM9arONEZCFtsdVj3kBoaKmwMhpW8jILUu69AQoMe1ET58j2DfGGS6g4wBNCT+e531BGqyQvpAlYOTwCnBKYnU5AK6xPuQ5WuPwJCBNPeIhn5eoczKklH1HPd32k01r2ZLGDUnJWHU1JxFoPD3slj/2mZVaOeQfeHAfuA7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713296074; c=relaxed/simple; bh=OX023vCDSksV4n94n8TNZmtzkek33LCJzZFZ+Xt33C8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qb1eqwoLJ4QguknDk3DDoDIa/V8Mw7hbtN4kJdRnKsK/xaqeusOOoKqejJHEbRLC9fX1mXhr16fPMci3M6mkK0ACUoHW9qj/Ta3hnQEaXL9mzG+yD4jCq5OuKeiWjvEKC5BcZU7JEX6cuKNVZvaH1VSfB/g5X4gQh+RcB+UUeBE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IeB8kjTX; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IeB8kjTX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713296073; x=1744832073; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OX023vCDSksV4n94n8TNZmtzkek33LCJzZFZ+Xt33C8=; b=IeB8kjTXcPQ3uTLcH1qgwbbKum/uscSzDSJkNBCcyIJlVo2xEzMPCDz6 qF1abHUGN0XBMzTJqE8lzbiFVlcSCkvCZh/BKtf+Eqpi0nyUxqukx+cUb 0d5u76oXZZ4uwrBNhPBkrRMOPpipNPyIGEq/joPF/N43LYSDto3zphvH4 sGyJdHkk+W6w4JJpuevjAjim5wwlTS8lufwaaTNLtjcEziDhIhBF/+lUN L5daIk5kdyAbtsJzUCjiQ8RDbMq/kKaUOcOSiWagXt+pYnqkmodqDw5rb sHBYpGeHH2nkAtNVs2n9WKpgxlyhPjnL4NCtrDrtGC3AO0I1VZfCZ/QiF w==; X-CSE-ConnectionGUID: na5X6uiwT8aIkcyJslA4/Q== X-CSE-MsgGUID: zinJLPhKRYKKbynkt8/zaA== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="8929946" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="8929946" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:33 -0700 X-CSE-ConnectionGUID: AyKuSJZkQFmm7rYtQ1jJ8g== X-CSE-MsgGUID: KfhjWzIfQdSkChMvgAXnug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="22244803" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:34:30 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 6D77C12053D; Tue, 16 Apr 2024 22:34:26 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Laurent Pinchart , tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl, Andrey Konovalov , Jacopo Mondi , Dmitry Perchanov , "Ng, Khai Wen" , Alain Volmat Subject: [PATCH v9 46/46] media: ov2740: Add IMMUTABLE route flag Date: Tue, 16 Apr 2024 22:33:19 +0300 Message-Id: <20240416193319.778192-47-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416193319.778192-1-sakari.ailus@linux.intel.com> References: <20240416193319.778192-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add immutable route flag to the routing table. The driver does not support disabling the embedded data whereas the sensor itself does. Signed-off-by: Sakari Ailus Reviewed-by: Julien Massot Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov2740.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index 6e355e986b88..d6b4533a834a 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -1185,12 +1185,14 @@ static int ov2740_init_state(struct v4l2_subdev *sd, .sink_pad = OV2740_PAD_PIXEL, .source_pad = OV2740_PAD_SOURCE, .source_stream = OV2740_STREAM_PIXEL, - .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE, + .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE | + V4L2_SUBDEV_ROUTE_FL_IMMUTABLE, }, { .sink_pad = OV2740_PAD_META, .source_pad = OV2740_PAD_SOURCE, .source_stream = OV2740_STREAM_META, - .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE, + .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE | + V4L2_SUBDEV_ROUTE_FL_IMMUTABLE, }, }; struct v4l2_subdev_krouting routing = {