mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dikshita Agarwal <quic_dikshita@quicinc.com>
To: Vikash Garodia <quic_vgarodia@quicinc.com>,
	Abhinav Kumar <quic_abhinavk@quicinc.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>
Cc: "Hans Verkuil" <hverkuil@xs4all.nl>,
	"Sebastian Fricke" <sebastian.fricke@collabora.com>,
	"Bryan O'Donoghue" <bryan.odonoghue@linaro.org>,
	"Dmitry Baryshkov" <dmitry.baryshkov@linaro.org>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	"Nicolas Dufresne" <nicolas@ndufresne.ca>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Jianhua Lu" <lujianhua000@gmail.com>,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Dikshita Agarwal" <quic_dikshita@quicinc.com>,
	"Vedang Nagar" <quic_vnagar@quicinc.com>
Subject: [PATCH v7 24/28] media: iris: add check whether the video session is supported or not
Date: Mon, 9 Dec 2024 18:22:09 +0530	[thread overview]
Message-ID: <20241209-qcom-video-iris-v7-24-05c6bdead47b@quicinc.com> (raw)
In-Reply-To: <20241209-qcom-video-iris-v7-0-05c6bdead47b@quicinc.com>

From: Vedang Nagar <quic_vnagar@quicinc.com>

Based on the hardware capabilities, add check to restrict whether the
video session is supported or not by the hardware during start_streaming
and queue_setup.

Signed-off-by: Vedang Nagar <quic_vnagar@quicinc.com>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
---
 .../platform/qcom/iris/iris_platform_common.h      |  1 +
 .../platform/qcom/iris/iris_platform_sm8550.c      |  1 +
 drivers/media/platform/qcom/iris/iris_vb2.c        | 96 ++++++++++++++++++++++
 3 files changed, 98 insertions(+)

diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/drivers/media/platform/qcom/iris/iris_platform_common.h
index de0388a100c3..a5a7d6838d16 100644
--- a/drivers/media/platform/qcom/iris/iris_platform_common.h
+++ b/drivers/media/platform/qcom/iris/iris_platform_common.h
@@ -144,6 +144,7 @@ struct iris_platform_data {
 	struct ubwc_config_data *ubwc_config;
 	u32 num_vpp_pipe;
 	u32 max_session_count;
+	u32 max_core_mbpf;
 	const u32 *input_config_params;
 	unsigned int input_config_params_size;
 	const u32 *output_config_params;
diff --git a/drivers/media/platform/qcom/iris/iris_platform_sm8550.c b/drivers/media/platform/qcom/iris/iris_platform_sm8550.c
index 2a45e605e140..68907ba6986f 100644
--- a/drivers/media/platform/qcom/iris/iris_platform_sm8550.c
+++ b/drivers/media/platform/qcom/iris/iris_platform_sm8550.c
@@ -232,6 +232,7 @@ struct iris_platform_data sm8550_data = {
 	.ubwc_config = &ubwc_config_sm8550,
 	.num_vpp_pipe = 4,
 	.max_session_count = 16,
+	.max_core_mbpf = ((8192 * 4352) / 256) * 2,
 	.input_config_params =
 		sm8550_vdec_input_config_params,
 	.input_config_params_size =
diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/platform/qcom/iris/iris_vb2.c
index 59fc133c9f98..712d37723ec3 100644
--- a/drivers/media/platform/qcom/iris/iris_vb2.c
+++ b/drivers/media/platform/qcom/iris/iris_vb2.c
@@ -11,6 +11,94 @@
 #include "iris_vb2.h"
 #include "iris_vdec.h"
 
+static int iris_check_core_mbpf(struct iris_inst *inst)
+{
+	struct iris_core *core = inst->core;
+	struct iris_inst *instance;
+	u32 total_mbpf = 0;
+
+	mutex_lock(&core->lock);
+	list_for_each_entry(instance, &core->instances, list)
+		total_mbpf += iris_get_mbpf(instance);
+	mutex_unlock(&core->lock);
+
+	if (total_mbpf > core->iris_platform_data->max_core_mbpf)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static int iris_check_inst_mbpf(struct iris_inst *inst)
+{
+	struct platform_inst_caps *caps;
+	u32 mbpf, max_mbpf;
+
+	caps = inst->core->iris_platform_data->inst_caps;
+	max_mbpf = caps->max_mbpf;
+	mbpf = iris_get_mbpf(inst);
+	if (mbpf > max_mbpf)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static int iris_check_resolution_supported(struct iris_inst *inst)
+{
+	u32 width, height, min_width, min_height, max_width, max_height;
+	struct platform_inst_caps *caps;
+
+	caps = inst->core->iris_platform_data->inst_caps;
+	width = inst->fmt_src->fmt.pix_mp.width;
+	height = inst->fmt_src->fmt.pix_mp.height;
+
+	min_width = caps->min_frame_width;
+	max_width = caps->max_frame_width;
+	min_height = caps->min_frame_height;
+	max_height = caps->max_frame_height;
+
+	if (!(min_width <= width && width <= max_width) ||
+	    !(min_height <= height && height <= max_height))
+		return -EINVAL;
+
+	return 0;
+}
+
+static int iris_check_session_supported(struct iris_inst *inst)
+{
+	struct iris_core *core = inst->core;
+	struct iris_inst *instance = NULL;
+	bool found = false;
+	int ret;
+
+	list_for_each_entry(instance, &core->instances, list) {
+		if (instance == inst)
+			found = true;
+	}
+
+	if (!found) {
+		ret = -EINVAL;
+		goto exit;
+	}
+
+	ret = iris_check_core_mbpf(inst);
+	if (ret)
+		goto exit;
+
+	ret = iris_check_inst_mbpf(inst);
+	if (ret)
+		goto exit;
+
+	ret = iris_check_resolution_supported(inst);
+	if (ret)
+		goto exit;
+
+	return 0;
+exit:
+	dev_err(inst->core->dev, "current session not supported(%d)\n", ret);
+
+	return ret;
+}
+
 int iris_vb2_buf_init(struct vb2_buffer *vb2)
 {
 	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb2);
@@ -48,6 +136,10 @@ int iris_vb2_queue_setup(struct vb2_queue *q,
 		goto unlock;
 	}
 
+	ret = iris_check_session_supported(inst);
+	if (ret)
+		goto unlock;
+
 	if (!inst->once_per_session_set) {
 		inst->once_per_session_set = true;
 
@@ -95,6 +187,10 @@ int iris_vb2_start_streaming(struct vb2_queue *q, unsigned int count)
 		goto error;
 	}
 
+	ret = iris_check_session_supported(inst);
+	if (ret)
+		goto error;
+
 	if (V4L2_TYPE_IS_OUTPUT(q->type))
 		ret = iris_vdec_streamon_input(inst);
 	else if (V4L2_TYPE_IS_CAPTURE(q->type))

-- 
2.34.1


  parent reply	other threads:[~2024-12-09 12:55 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09 12:51 [PATCH v7 00/28] Qualcomm iris video decoder driver Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 01/28] dt-bindings: media: Add video support for QCOM SM8550 SoC Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 02/28] media: iris: add platform driver for iris video device Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 03/28] media: iris: implement iris v4l2 file ops Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 04/28] media: iris: introduce iris core state management with shared queues Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 05/28] media: iris: implement video firmware load/unload Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 06/28] media: iris: implement boot sequence of the firmware Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 07/28] media: iris: introduce host firmware interface with necessary hooks Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 08/28] media: iris: implement power management Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 09/28] media: iris: implement reqbuf ioctl with vb2_queue_setup Dikshita Agarwal
2024-12-10  9:56   ` Stefan Schmidt
2024-12-09 12:51 ` [PATCH v7 10/28] media: iris: implement s_fmt, g_fmt and try_fmt ioctls Dikshita Agarwal
2024-12-09 16:09   ` Hans Verkuil
2024-12-09 12:51 ` [PATCH v7 11/28] media: iris: implement g_selection ioctl Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 12/28] media: iris: implement enum_fmt and enum_framesizes ioctls Dikshita Agarwal
2024-12-09 12:51 ` [PATCH v7 13/28] media: iris: implement subscribe_event and unsubscribe_event ioctls Dikshita Agarwal
2024-12-09 16:09   ` Hans Verkuil
2024-12-09 12:51 ` [PATCH v7 14/28] media: iris: implement iris v4l2_ctrl_ops Dikshita Agarwal
2024-12-10 12:23   ` Stefan Schmidt
2024-12-09 12:52 ` [PATCH v7 15/28] media: iris: implement query_cap ioctl Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 16/28] media: iris: implement vb2 streaming ops Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 17/28] media: iris: implement set properties to firmware during streamon Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 18/28] media: iris: subscribe parameters and properties to firmware for hfi_gen2 Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 19/28] media: iris: allocate, initialize and queue internal buffers Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 20/28] media: iris: implement vb2 ops for buf_queue and firmware response Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 21/28] media: iris: add support for dynamic resolution change Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 22/28] media: iris: handle streamoff/on from client in " Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 23/28] media: iris: add support for drain sequence Dikshita Agarwal
2024-12-09 12:52 ` Dikshita Agarwal [this message]
2024-12-09 12:52 ` [PATCH v7 25/28] media: iris: implement power scaling for vpu2 and vpu3 Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 26/28] media: iris: add check to allow sub states transitions Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 27/28] media: iris: enable video driver probe of SM8250 SoC Dikshita Agarwal
2024-12-09 12:52 ` [PATCH v7 28/28] media: MAINTAINERS: add Qualcomm iris video accelerator driver Dikshita Agarwal

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=20241209-qcom-video-iris-v7-24-05c6bdead47b@quicinc.com \
    --to=quic_dikshita@quicinc.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=hverkuil@xs4all.nl \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=lujianhua000@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=nicolas@ndufresne.ca \
    --cc=p.zabel@pengutronix.de \
    --cc=quic_abhinavk@quicinc.com \
    --cc=quic_vgarodia@quicinc.com \
    --cc=quic_vnagar@quicinc.com \
    --cc=robh@kernel.org \
    --cc=sebastian.fricke@collabora.com \
    --cc=u.kleine-koenig@baylibre.com \
    /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

all inboxes | Powered by JetHome®