From: "Gjorgji Rosikopulos (Consultant)" <gjorgji.rosikopulos@oss.qualcomm.com>
To: Loic Poulain <loic.poulain@oss.qualcomm.com>,
Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org,
devicetree@vger.kernel.org,
Hans de Goede <johannes.goede@oss.qualcomm.com>
Subject: Re: [PATCH v5 4/5] media: qcom: camss: Add CAMSS Offline Processing Engine driver
Date: Wed, 29 Jul 2026 22:53:21 +0300 [thread overview]
Message-ID: <2c81c1b3-59fb-4ae0-bc2e-457b585e0732@oss.qualcomm.com> (raw)
In-Reply-To: <20260724-camss-isp-ope-v5-4-e70ad4fa39ce@oss.qualcomm.com>
Hi Loic,
On 7/24/2026 3:42 PM, Loic Poulain wrote:
> Add an image processing driver for the Qualcomm Offline Processing Engine
> (OPE). OPE is a memory-to-memory ISP block that converts raw Bayer
> frames to YUV, performing white balance, demosaic, chroma enhancement,
> color correction and downscaling.
>
> The hardware architecture consists of Fetch Engines and Write Engines,
> connected through intermediate pipeline modules for pix processing.
>
> The driver exposes three video nodes per pipeline instance:
> - ope_input: Bayer RAW input (V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
> - ope_disp_output: YUV output (V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> - ope_params: ISP parameters (V4L2_BUF_TYPE_META_OUTPUT)
>
> Hardware features:
> - Stripe-based processing (up to 336 pixels wide per stripe)
> - White balance (CLC_WB)
> - Demosaic / Bayer-to-RGB (CLC_DEMO)
> - RGB-to-YUV conversion (CLC_CHROMA_ENHAN)
> - Color correction matrix (CLC_CC)
> - MN downscaler for chroma and luma planes
>
> Default configuration values are based on public standards such as BT.601.
>
> Processing Model:
> OPE processes frames in stripes of up to 336 pixels. Therefore, frames
> must be split into stripes for processing. Each stripe is configured after
> the previous one has been acquired (double buffered registers). To minimize
> inter-stripe latency, stripe configurations are generated ahead of time.
>
> The driver is split into three source files under the ope/ directory:
>
> - core.c: the OPE m2m driver itself: probe, power management, V4L2/media
> device setup, format handling, stripe generation and hardware
> programming.
>
> - pipeline.c/.h: a small declarative media-controller topology builder.
> Drivers describe their entire media graph, entities (video devices,
> subdevs, or base entities), their pads, and the links between them, in
> a static descriptor table. The builder validates the table, allocates
> and registers all entities, and creates all MC pad links. It is kept
> generic but currently only used by OPE.
>
> - params.c/.h: V4L2 ISP parameter buffer validation and dispatch. It
> wraps the extensible V4L2 ISP parameters buffer format, validating
> the buffer size and each per-block header before forwarding every
> block to its driver-supplied handler.
>
> Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
> Co-developed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> ---
> drivers/media/platform/qcom/camss/Kconfig | 2 +
> drivers/media/platform/qcom/camss/Makefile | 2 +
> drivers/media/platform/qcom/camss/ope/Kconfig | 16 +
> drivers/media/platform/qcom/camss/ope/Makefile | 9 +
> drivers/media/platform/qcom/camss/ope/core.c | 3353 ++++++++++++++++++++++
> drivers/media/platform/qcom/camss/ope/params.c | 75 +
> drivers/media/platform/qcom/camss/ope/params.h | 62 +
> drivers/media/platform/qcom/camss/ope/pipeline.c | 399 +++
> drivers/media/platform/qcom/camss/ope/pipeline.h | 237 ++
> 9 files changed, 4155 insertions(+)
>
<snip>
> +static int ope_open(struct file *file)
> +{
> + struct video_device *vdev = video_devdata(file);
> + struct ope_dev *ope = container_of(vdev->v4l2_dev, struct ope_dev, v4l2_dev);
> + struct ope_ctx *ctx;
> + struct v4l2_fh *fh;
> + int ret = 0;
> +
> + fh = kzalloc(sizeof(*fh), GFP_KERNEL);
> + if (!fh)
> + return -ENOMEM;
> +
> + if (mutex_lock_interruptible(&ope->mutex)) {
> + kfree(fh);
> + return -ERESTARTSYS;
> + }
> +
> + /*
> + * For now, only a single shared context is supported,
> + * until media multi-context support is available.
> + */
> + if (!ope->shared_ctx) {
> + ctx = ope_ctx_create(ope);
> + if (IS_ERR(ctx)) {
> + ret = PTR_ERR(ctx);
> + goto unlock;
> + }
> + } else {
> + ctx = ope->shared_ctx;
> + }
I am sure there were multiple discussions on how to implement multi-context. But this exact implementation somehow confuses me (maybe just me).
This allows opening the same video node twice (e.g. the output node). vb2_is_busy protection is present everywhere to prevent races,
but if two applications open the same video node the driver may end up in a situation where the format set by the first application is overridden
by the second, but streaming somehow gets started on the first with the wrong format. The danger is not at the format-set call itself but at start_streaming,
when the hardware gets programmed with whatever format is current in the shared context.
Maybe it makes sense to have a tiny wrapper on each OPE V4L2 video device that holds an open count and prevents opening the same video node twice,
returning -EBUSY on a second open(), until multi-context support is available as mentioned here.
Regards,
~Gjorgji
next prev parent reply other threads:[~2026-07-29 19:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 12:42 [PATCH v5 0/5] media: qcom: camss: CAMSS Offline Processing Engine support Loic Poulain
2026-07-24 12:42 ` [PATCH v5 1/5] media: qcom: camss: Add V4L2 meta format for CAMSS ISP parameters Loic Poulain
2026-07-29 18:28 ` Gjorgji Rosikopulos (Consultant)
2026-07-30 11:44 ` Loic Poulain
2026-07-30 11:57 ` Bryan O'Donoghue
2026-07-30 12:34 ` Loic Poulain
2026-07-30 13:15 ` Gjorgji Rosikopulos (Consultant)
2026-07-24 12:42 ` [PATCH v5 2/5] dt-bindings: media: qcom: Add CAMSS Offline Processing Engine (OPE) Loic Poulain
2026-07-24 12:42 ` [PATCH v5 3/5] media: uapi: Add CAMSS OPE ISP configuration definition Loic Poulain
2026-07-29 13:27 ` johannes.goede
2026-07-29 18:31 ` Gjorgji Rosikopulos (Consultant)
2026-07-24 12:42 ` [PATCH v5 4/5] media: qcom: camss: Add CAMSS Offline Processing Engine driver Loic Poulain
2026-07-29 19:53 ` Gjorgji Rosikopulos (Consultant) [this message]
2026-08-21 6:34 ` Nihal Kumar Gupta
2026-07-24 12:42 ` [PATCH v5 5/5] arm64: dts: qcom: agatti: Add OPE node Loic Poulain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c81c1b3-59fb-4ae0-bc2e-457b585e0732@oss.qualcomm.com \
--to=gjorgji.rosikopulos@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gustavoars@kernel.org \
--cc=johannes.goede@oss.qualcomm.com \
--cc=kees@kernel.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=vladimir.zapolskiy@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox