Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH v4 0/3] media: venus: Provide support for selecting encoder/decoder from in-driver
@ 2024-11-28 16:21 Bryan O'Donoghue
  2024-11-28 16:21 ` [PATCH v4 1/3] media: venus: Add support for static video encoder/decoder declarations Bryan O'Donoghue
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Bryan O'Donoghue @ 2024-11-28 16:21 UTC (permalink / raw)
  To: Stanimir Varbanov, Vikash Garodia, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: quic_renjiang, quic_vnagar, quic_dikshita, konradybcio,
	linux-media, linux-arm-msm, linux-kernel, devicetree,
	Bryan O'Donoghue, Krzysztof Kozlowski

v4:

- Adds some unavoidable conditional CONFIG_OF_DYNAMIC to fix media-ci testcase # Test build:OF x86_64
- Added logic for of_changeset_revert() and of_changeset_destroy() on
  error/remove paths - Bryan
- Link to v3: https://lore.kernel.org/r/20241127-media-staging-24-11-25-rb3-hw-compat-string-v3-0-ef6bd25e98db@linaro.org

v3:
- Adds select OF_DYNAMIC to venus/Kconfig to ensure of_changeset_*() is
  available. Instead of ifdefing and have the fix not work without
  OF_DYNAMIC, select OF_DYANMIC with venus - linux-media-ci
- Link to v2: https://lore.kernel.org/r/20241127-media-staging-24-11-25-rb3-hw-compat-string-v2-0-c010fd45f7ff@linaro.org

v2:
- Removes useless dev_info() leftover from debugging - Bryan
  Link: https://lore.kernel.org/r/ce9ac473-2f73-4c7a-97b1-08be39f3adb4@linaro.org
- Trivial newline change @ np = of_changeset_create_node(ocs, dev->of_node, node_name); - Bryan
- Fixes a missing goto identified by smatch - Smatch/Bryan
- Adds Krzysztof's RB to deprecated - Krzysztof
- Link to v1: https://lore.kernel.org/r/20241127-media-staging-24-11-25-rb3-hw-compat-string-v1-0-99c16f266b46@linaro.org

v1:
Various venus patches have been held up due to the misuse of DT to provide
a configuration input to venus as to which mode a given transcoder should
be in.

Link: https://lore.kernel.org/linux-arm-msm/436145fd-d65f-44ec-b950-c434775187ca@kernel.org
Link: https://lore.kernel.org/linux-media/ba40de82-b308-67b1-5751-bb2d95f2b8a5@linaro.org/

This series provides support for static configuration of venus from the resource
structure via:

1. Adding two strings to the resource structure.
   One string for the decoder one for the encoder.
2. The string for each SoC has been matched to the existing in the
   DT which currently specifies the mode as decoder or encoder.
3. New logic in the driver parses the DTB looking for the node name
   specified for the decoder and encoder .
4. If the DTB contains the node name, then no new node is added as
   we assume to be working with an "old" DTB.
5. If the DTB does not contain the specified decoder/encoder string
   then a new in-memory node is added which contains a compat string
   consistent with upstream compat strings used to currently select
   between the decoder and encoder respectively.
6. In this way new venus driver entries may be added which respect
   the requirement to move mode selection out of DTB and into driver.
7. Simple instances of decoder/encoder nodes in the yaml schema have been
   marked as deprecated.
8. Since the proposed scheme here always defers to what the DTB says that
   means it would be possible to remove decoder/encoder entries for the
   deprecated schema should we choose to do so at a later date but,
   that step is not taken in this series.
9. Some of the upstream encoder/decoder nodes for example sdm630/sdm660
   also contain clock and power-domain information and have not been
   updated with the static configuration data or had the schema amended to
   deprecate values. Because these nodes impart hardware specific
   information and are already upstream this series proposes to leave
   those as-is.

However if this scheme is adopted it should allow for addition of venus for
both qcs615[1] and sc8280xp[2].

Other SoCs such as sm8550, sm8650 and beyond are expected to be supported
by Iris.

The sm8350 and sm8280xp in the second series would then be able to excise
the offending compat = "video-encoder" | "video-decoder" in the schema and
DT.

I considered making this series an all singing all dancing method to select
between encoder and decoder for all SoCs but, the objective here is not to
add functionality but to provide support for configuration in-driver
consistent with current usage and to do so with a minimal code
intervention.

So far I've tested on RB3 by removing:

video-core0 {
	compatible = "venus-decoder";
};

video-core1 {
	compatible = "venus-encoder";
};

This works - the code adds the nodes into memory and the video
encoder/decoder logic in the plaform code runs.

Similarly if the nodes are left in-place then no new nodes are added by the
code in this series and still both encoder and decoder probe.

Thus proving the code works and will provide support for new platforms
while also leaving open the option of dropping nodes from upstream.

I've left the dropping step out for now, it can be implemented later.

[1] https://lore.kernel.org/linux-arm-msm/20241125-add-venus-for-qcs615-v3-0-5a376b97a68e@quicinc.com
[2] https://lore.kernel.org/linux-media/20230731-topic-8280_venus-v1-0-8c8bbe1983a5@linaro.org/

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
Bryan O'Donoghue (3):
      media: venus: Add support for static video encoder/decoder declarations
      media: venus: Populate video encoder/decoder nodename entries
      media: dt-bindings: qcom-venus: Deprecate video-decoder and video-encoder where applicable

 .../bindings/media/qcom,msm8916-venus.yaml         |  12 +--
 .../bindings/media/qcom,sc7180-venus.yaml          |  12 +--
 .../bindings/media/qcom,sc7280-venus.yaml          |  12 +--
 .../bindings/media/qcom,sdm845-venus-v2.yaml       |  12 +--
 .../bindings/media/qcom,sm8250-venus.yaml          |  12 +--
 drivers/media/platform/qcom/venus/Kconfig          |   1 +
 drivers/media/platform/qcom/venus/core.c           | 100 +++++++++++++++++++++
 drivers/media/platform/qcom/venus/core.h           |   4 +
 8 files changed, 115 insertions(+), 50 deletions(-)
---
base-commit: 72ad4ff638047bbbdf3232178fea4bec1f429319
change-id: 20241127-media-staging-24-11-25-rb3-hw-compat-string-ea3c99938021

Best regards,
-- 
Bryan O'Donoghue <bryan.odonoghue@linaro.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v4 1/3] media: venus: Add support for static video encoder/decoder declarations
  2024-11-28 16:21 [PATCH v4 0/3] media: venus: Provide support for selecting encoder/decoder from in-driver Bryan O'Donoghue
@ 2024-11-28 16:21 ` Bryan O'Donoghue
  2024-12-09  6:29   ` Dikshita Agarwal
  2024-11-28 16:21 ` [PATCH v4 2/3] media: venus: Populate video encoder/decoder nodename entries Bryan O'Donoghue
  2024-11-28 16:21 ` [PATCH v4 3/3] media: dt-bindings: qcom-venus: Deprecate video-decoder and video-encoder where applicable Bryan O'Donoghue
  2 siblings, 1 reply; 7+ messages in thread
From: Bryan O'Donoghue @ 2024-11-28 16:21 UTC (permalink / raw)
  To: Stanimir Varbanov, Vikash Garodia, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: quic_renjiang, quic_vnagar, quic_dikshita, konradybcio,
	linux-media, linux-arm-msm, linux-kernel, devicetree,
	Bryan O'Donoghue

Add resource structure data and probe() logic to support static
declarations of encoder and decoder.

Right now we rely on video encoder/decoder selection happening in the dtb
but, this goes against the remit of device tree which is supposed to
describe hardware, not select functional logic in Linux drivers.

Provide two strings in the venus resource structure enc_nodename and
dec_nodename.

When set the venus driver will create an OF entry in-memory consistent
with:

dec_nodename {
    compat = "video-decoder";
};

and/or

enc_nodename {
    compat = "video-encoder";
};

This will allow us to reuse the existing driver scheme of relying on compat
names maintaining compatibility with old dtb files.

dec_nodename can be "video-decoder" or "video0"
enc_nodename can be "video-encoder" or "video1"

This change relies on of_changeset() API as a result select OF_DYNAMIC will
be added to venus/Kconfig

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/media/platform/qcom/venus/Kconfig |  1 +
 drivers/media/platform/qcom/venus/core.c  | 90 +++++++++++++++++++++++++++++++
 drivers/media/platform/qcom/venus/core.h  |  4 ++
 3 files changed, 95 insertions(+)

diff --git a/drivers/media/platform/qcom/venus/Kconfig b/drivers/media/platform/qcom/venus/Kconfig
index bfd50e8f34219db8a1de7960d7ea93b20db2982a..bc2e410b29cb415a36540a4f98709eae44f4ec35 100644
--- a/drivers/media/platform/qcom/venus/Kconfig
+++ b/drivers/media/platform/qcom/venus/Kconfig
@@ -3,6 +3,7 @@ config VIDEO_QCOM_VENUS
 	depends on V4L_MEM2MEM_DRIVERS
 	depends on VIDEO_DEV && QCOM_SMEM
 	depends on (ARCH_QCOM && IOMMU_DMA) || COMPILE_TEST
+	select OF_DYNAMIC if ARCH_QCOM
 	select QCOM_MDT_LOADER if ARCH_QCOM
 	select QCOM_SCM
 	select VIDEOBUF2_DMA_CONTIG
diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 4e26b18790537885a77d66c1917a4e7a146eaf57..8a085611443cfda89ae71496e320dfc1f02ade88 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -286,6 +286,89 @@ static irqreturn_t venus_isr_thread(int irq, void *dev_id)
 	return ret;
 }
 
+#if defined(CONFIG_OF_DYNAMIC)
+static int venus_add_video_core(struct venus_core *core, const char *node_name,
+				const char *compat)
+{
+	struct of_changeset *ocs = core->ocs;
+	struct device *dev = core->dev;
+	struct device_node *np, *enp;
+	int ret;
+
+	if (!node_name)
+		return 0;
+
+	enp = of_find_node_by_name(dev->of_node, node_name);
+	if (enp) {
+		of_node_put(enp);
+		return 0;
+	}
+
+	np = of_changeset_create_node(ocs, dev->of_node, node_name);
+	if (!np) {
+		dev_err(dev, "Unable to create new node\n");
+		return -ENODEV;
+	}
+
+	ret = of_changeset_add_prop_string(ocs, np, "compatible", compat);
+	if (ret)
+		dev_err(dev, "unable to add %s\n", compat);
+
+	of_node_put(np);
+
+	return ret;
+}
+
+static int venus_add_dynamic_nodes(struct venus_core *core)
+{
+	struct device *dev = core->dev;
+	int ret;
+
+	core->ocs = kmalloc(sizeof(*core->ocs), GFP_KERNEL);
+	if (!core->ocs)
+		return -ENOMEM;
+
+	of_changeset_init(core->ocs);
+
+	ret = venus_add_video_core(core, core->res->dec_nodename, "venus-decoder");
+	if (ret)
+		goto err;
+
+	ret = venus_add_video_core(core, core->res->enc_nodename, "venus-encoder");
+	if (ret)
+		goto err;
+
+	ret = of_changeset_apply(core->ocs);
+	if (ret) {
+		dev_err(dev, "applying changeset fail ret %d\n", ret);
+		goto err;
+	}
+
+	return 0;
+err:
+	of_changeset_destroy(core->ocs);
+	kfree(core->ocs);
+	core->ocs = NULL;
+	return ret;
+}
+
+static void venus_remove_dynamic_nodes(struct venus_core *core)
+{
+	if (core->ocs) {
+		of_changeset_revert(core->ocs);
+		of_changeset_destroy(core->ocs);
+		kfree(core->ocs);
+	}
+}
+#else
+static int venus_add_dynamic_nodes(struct venus_core *core)
+{
+	return 0;
+}
+
+static void venus_remove_dynamic_nodes(struct venus_core *core) {}
+#endif
+
 static int venus_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -365,6 +448,11 @@ static int venus_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_runtime_disable;
 
+	if (core->res->dec_nodename || core->res->enc_nodename) {
+		if (venus_add_dynamic_nodes(core))
+			goto err_runtime_disable;
+	}
+
 	ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
 	if (ret)
 		goto err_runtime_disable;
@@ -443,6 +531,8 @@ static void venus_remove(struct platform_device *pdev)
 
 	venus_firmware_deinit(core);
 
+	venus_remove_dynamic_nodes(core);
+
 	pm_runtime_put_sync(dev);
 	pm_runtime_disable(dev);
 
diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index 27784fd7082c321222b23ca4b2902a04c49e19ca..306231b4f7d0201175974b4a42574f30d23e08f0 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -90,6 +90,8 @@ struct venus_resources {
 	u32 cp_nonpixel_start;
 	u32 cp_nonpixel_size;
 	const char *fwname;
+	const char *enc_nodename;
+	const char *dec_nodename;
 };
 
 enum venus_fmt {
@@ -171,6 +173,7 @@ struct venus_format {
  * @root:	debugfs root directory
  * @venus_ver:	the venus firmware version
  * @dump_core:	a flag indicating that a core dump is required
+ * @ocs:	OF changeset pointer
  */
 struct venus_core {
 	void __iomem *base;
@@ -235,6 +238,7 @@ struct venus_core {
 		u32 rev;
 	} venus_ver;
 	unsigned long dump_core;
+	struct of_changeset *ocs;
 };
 
 struct vdec_controls {

-- 
2.47.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 2/3] media: venus: Populate video encoder/decoder nodename entries
  2024-11-28 16:21 [PATCH v4 0/3] media: venus: Provide support for selecting encoder/decoder from in-driver Bryan O'Donoghue
  2024-11-28 16:21 ` [PATCH v4 1/3] media: venus: Add support for static video encoder/decoder declarations Bryan O'Donoghue
@ 2024-11-28 16:21 ` Bryan O'Donoghue
  2024-11-28 16:21 ` [PATCH v4 3/3] media: dt-bindings: qcom-venus: Deprecate video-decoder and video-encoder where applicable Bryan O'Donoghue
  2 siblings, 0 replies; 7+ messages in thread
From: Bryan O'Donoghue @ 2024-11-28 16:21 UTC (permalink / raw)
  To: Stanimir Varbanov, Vikash Garodia, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: quic_renjiang, quic_vnagar, quic_dikshita, konradybcio,
	linux-media, linux-arm-msm, linux-kernel, devicetree,
	Bryan O'Donoghue

Populate encoder and decoder node-name entries for the upstream parts. Once
done the compat="video-encoder" and compat="video-decoder" in the dtsi can
be dropped though the venus driver will continue to favour DT declared
video-encoder/video-decoder declarations over static declarations for
compatibility.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/media/platform/qcom/venus/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 8a085611443cfda89ae71496e320dfc1f02ade88..1a408c1c2277d77c5fcb67cb94baff6b98c26a2b 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -672,6 +672,8 @@ static const struct venus_resources msm8916_res = {
 	.vmem_addr = 0,
 	.dma_mask = 0xddc00000 - 1,
 	.fwname = "qcom/venus-1.8/venus.mbn",
+	.dec_nodename = "video-decoder",
+	.enc_nodename = "video-encoder",
 };
 
 static const struct freq_tbl msm8996_freq_table[] = {
@@ -881,6 +883,8 @@ static const struct venus_resources sdm845_res_v2 = {
 	.cp_nonpixel_start = 0x1000000,
 	.cp_nonpixel_size = 0x24800000,
 	.fwname = "qcom/venus-5.2/venus.mbn",
+	.dec_nodename = "video-core0",
+	.enc_nodename = "video-core1",
 };
 
 static const struct freq_tbl sc7180_freq_table[] = {
@@ -929,6 +933,8 @@ static const struct venus_resources sc7180_res = {
 	.cp_nonpixel_start = 0x1000000,
 	.cp_nonpixel_size = 0x24800000,
 	.fwname = "qcom/venus-5.4/venus.mbn",
+	.dec_nodename = "video-decoder",
+	.enc_nodename = "video-encoder",
 };
 
 static const struct freq_tbl sm8250_freq_table[] = {
@@ -984,6 +990,8 @@ static const struct venus_resources sm8250_res = {
 	.vmem_addr = 0,
 	.dma_mask = 0xe0000000 - 1,
 	.fwname = "qcom/vpu-1.0/venus.mbn",
+	.dec_nodename = "video-decoder",
+	.enc_nodename = "video-encoder",
 };
 
 static const struct freq_tbl sc7280_freq_table[] = {
@@ -1046,6 +1054,8 @@ static const struct venus_resources sc7280_res = {
 	.cp_nonpixel_start = 0x1000000,
 	.cp_nonpixel_size = 0x24800000,
 	.fwname = "qcom/vpu-2.0/venus.mbn",
+	.dec_nodename = "video-decoder",
+	.enc_nodename = "video-encoder",
 };
 
 static const struct of_device_id venus_dt_match[] = {

-- 
2.47.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 3/3] media: dt-bindings: qcom-venus: Deprecate video-decoder and video-encoder where applicable
  2024-11-28 16:21 [PATCH v4 0/3] media: venus: Provide support for selecting encoder/decoder from in-driver Bryan O'Donoghue
  2024-11-28 16:21 ` [PATCH v4 1/3] media: venus: Add support for static video encoder/decoder declarations Bryan O'Donoghue
  2024-11-28 16:21 ` [PATCH v4 2/3] media: venus: Populate video encoder/decoder nodename entries Bryan O'Donoghue
@ 2024-11-28 16:21 ` Bryan O'Donoghue
  2024-12-06 10:03   ` Dikshita Agarwal
  2 siblings, 1 reply; 7+ messages in thread
From: Bryan O'Donoghue @ 2024-11-28 16:21 UTC (permalink / raw)
  To: Stanimir Varbanov, Vikash Garodia, Mauro Carvalho Chehab,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: quic_renjiang, quic_vnagar, quic_dikshita, konradybcio,
	linux-media, linux-arm-msm, linux-kernel, devicetree,
	Bryan O'Donoghue, Krzysztof Kozlowski

For the list of yaml files here the video-decoder and video-encoder nodes
provide nothing more than configuration input for the driver. These entries
do not in fact impart hardware specific data and should be deprecated.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 .../devicetree/bindings/media/qcom,msm8916-venus.yaml        | 12 ++----------
 .../devicetree/bindings/media/qcom,sc7180-venus.yaml         | 12 ++----------
 .../devicetree/bindings/media/qcom,sc7280-venus.yaml         | 12 ++----------
 .../devicetree/bindings/media/qcom,sdm845-venus-v2.yaml      | 12 ++----------
 .../devicetree/bindings/media/qcom,sm8250-venus.yaml         | 12 ++----------
 5 files changed, 10 insertions(+), 50 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/qcom,msm8916-venus.yaml b/Documentation/devicetree/bindings/media/qcom,msm8916-venus.yaml
index 9410f13ca97c181973c62fe62d0399fc9e82f05d..da140c2e3d3f3c3e886496e3e2303eda1df99bb4 100644
--- a/Documentation/devicetree/bindings/media/qcom,msm8916-venus.yaml
+++ b/Documentation/devicetree/bindings/media/qcom,msm8916-venus.yaml
@@ -45,6 +45,7 @@ properties:
     required:
       - compatible
 
+    deprecated: true
     additionalProperties: false
 
   video-encoder:
@@ -57,13 +58,12 @@ properties:
     required:
       - compatible
 
+    deprecated: true
     additionalProperties: false
 
 required:
   - compatible
   - iommus
-  - video-decoder
-  - video-encoder
 
 unevaluatedProperties: false
 
@@ -83,12 +83,4 @@ examples:
         power-domains = <&gcc VENUS_GDSC>;
         iommus = <&apps_iommu 5>;
         memory-region = <&venus_mem>;
-
-        video-decoder {
-            compatible = "venus-decoder";
-        };
-
-        video-encoder {
-            compatible = "venus-encoder";
-        };
     };
diff --git a/Documentation/devicetree/bindings/media/qcom,sc7180-venus.yaml b/Documentation/devicetree/bindings/media/qcom,sc7180-venus.yaml
index 5cec1d077cda77817f6d876109defcb0abbfeb2c..83c4a5d95f020437bd160d6456850bc84a2cf5ff 100644
--- a/Documentation/devicetree/bindings/media/qcom,sc7180-venus.yaml
+++ b/Documentation/devicetree/bindings/media/qcom,sc7180-venus.yaml
@@ -70,6 +70,7 @@ properties:
     required:
       - compatible
 
+    deprecated: true
     additionalProperties: false
 
   video-encoder:
@@ -82,14 +83,13 @@ properties:
     required:
       - compatible
 
+    deprecated: true
     additionalProperties: false
 
 required:
   - compatible
   - power-domain-names
   - iommus
-  - video-decoder
-  - video-encoder
 
 unevaluatedProperties: false
 
@@ -114,12 +114,4 @@ examples:
                       "vcodec0_core", "vcodec0_bus";
         iommus = <&apps_smmu 0x0c00 0x60>;
         memory-region = <&venus_mem>;
-
-        video-decoder {
-            compatible = "venus-decoder";
-        };
-
-        video-encoder {
-            compatible = "venus-encoder";
-        };
     };
diff --git a/Documentation/devicetree/bindings/media/qcom,sc7280-venus.yaml b/Documentation/devicetree/bindings/media/qcom,sc7280-venus.yaml
index 10c334e6b3dcf25967fa438f8e6e5035448af1b9..413c5b4ee6504ba1d5fe9f74d5be04ad8c90c318 100644
--- a/Documentation/devicetree/bindings/media/qcom,sc7280-venus.yaml
+++ b/Documentation/devicetree/bindings/media/qcom,sc7280-venus.yaml
@@ -68,6 +68,7 @@ properties:
     required:
       - compatible
 
+    deprecated: true
     additionalProperties: false
 
   video-encoder:
@@ -80,14 +81,13 @@ properties:
     required:
       - compatible
 
+    deprecated: true
     additionalProperties: false
 
 required:
   - compatible
   - power-domain-names
   - iommus
-  - video-decoder
-  - video-encoder
 
 unevaluatedProperties: false
 
@@ -125,14 +125,6 @@ examples:
 
         memory-region = <&video_mem>;
 
-        video-decoder {
-            compatible = "venus-decoder";
-        };
-
-        video-encoder {
-            compatible = "venus-encoder";
-        };
-
         video-firmware {
             iommus = <&apps_smmu 0x21a2 0x0>;
         };
diff --git a/Documentation/devicetree/bindings/media/qcom,sdm845-venus-v2.yaml b/Documentation/devicetree/bindings/media/qcom,sdm845-venus-v2.yaml
index 6228fd2b324631f3138e128c918266da58f6b544..c839cb1ebc0999e10b865f4bb43ea76ffa2bf46d 100644
--- a/Documentation/devicetree/bindings/media/qcom,sdm845-venus-v2.yaml
+++ b/Documentation/devicetree/bindings/media/qcom,sdm845-venus-v2.yaml
@@ -70,6 +70,7 @@ properties:
     required:
       - compatible
 
+    deprecated: true
     additionalProperties: false
 
   video-core1:
@@ -82,14 +83,13 @@ properties:
     required:
       - compatible
 
+    deprecated: true
     additionalProperties: false
 
 required:
   - compatible
   - power-domain-names
   - iommus
-  - video-core0
-  - video-core1
 
 unevaluatedProperties: false
 
@@ -119,12 +119,4 @@ examples:
         iommus = <&apps_smmu 0x10a0 0x8>,
                  <&apps_smmu 0x10b0 0x0>;
         memory-region = <&venus_mem>;
-
-        video-core0 {
-            compatible = "venus-decoder";
-        };
-
-        video-core1 {
-            compatible = "venus-encoder";
-        };
     };
diff --git a/Documentation/devicetree/bindings/media/qcom,sm8250-venus.yaml b/Documentation/devicetree/bindings/media/qcom,sm8250-venus.yaml
index f66033ae8b590e7b6f1e344c368994744411aca2..da54493220c9dc90e7d9f5fcfce7590acb241c85 100644
--- a/Documentation/devicetree/bindings/media/qcom,sm8250-venus.yaml
+++ b/Documentation/devicetree/bindings/media/qcom,sm8250-venus.yaml
@@ -73,6 +73,7 @@ properties:
     required:
       - compatible
 
+    deprecated: true
     additionalProperties: false
 
   video-encoder:
@@ -85,6 +86,7 @@ properties:
     required:
       - compatible
 
+    deprecated: true
     additionalProperties: false
 
 required:
@@ -95,8 +97,6 @@ required:
   - iommus
   - resets
   - reset-names
-  - video-decoder
-  - video-encoder
 
 unevaluatedProperties: false
 
@@ -132,12 +132,4 @@ examples:
         resets = <&gcc GCC_VIDEO_AXI0_CLK_ARES>,
                  <&videocc VIDEO_CC_MVS0C_CLK_ARES>;
         reset-names = "bus", "core";
-
-        video-decoder {
-            compatible = "venus-decoder";
-        };
-
-        video-encoder {
-            compatible = "venus-encoder";
-        };
     };

-- 
2.47.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 3/3] media: dt-bindings: qcom-venus: Deprecate video-decoder and video-encoder where applicable
  2024-11-28 16:21 ` [PATCH v4 3/3] media: dt-bindings: qcom-venus: Deprecate video-decoder and video-encoder where applicable Bryan O'Donoghue
@ 2024-12-06 10:03   ` Dikshita Agarwal
  2024-12-06 21:25     ` Bryan O'Donoghue
  0 siblings, 1 reply; 7+ messages in thread
From: Dikshita Agarwal @ 2024-12-06 10:03 UTC (permalink / raw)
  To: Bryan O'Donoghue, Stanimir Varbanov, Vikash Garodia,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: quic_renjiang, quic_vnagar, konradybcio, linux-media,
	linux-arm-msm, linux-kernel, devicetree, Krzysztof Kozlowski



On 11/28/2024 9:51 PM, Bryan O'Donoghue wrote:
> For the list of yaml files here the video-decoder and video-encoder nodes
> provide nothing more than configuration input for the driver. These entries
> do not in fact impart hardware specific data and should be deprecated.
> 
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  .../devicetree/bindings/media/qcom,msm8916-venus.yaml        | 12 ++----------
>  .../devicetree/bindings/media/qcom,sc7180-venus.yaml         | 12 ++----------
>  .../devicetree/bindings/media/qcom,sc7280-venus.yaml         | 12 ++----------
>  .../devicetree/bindings/media/qcom,sdm845-venus-v2.yaml      | 12 ++----------
>  .../devicetree/bindings/media/qcom,sm8250-venus.yaml         | 12 ++----------
>  5 files changed, 10 insertions(+), 50 deletions(-)
> 
A general query, this change is not done for 8996-venus, sdm660-venus and
sdm845-venus, was that intentional? may be because these are not active
SOCs in upstream?

Thanks,
Dikshita
> diff --git a/Documentation/devicetree/bindings/media/qcom,msm8916-venus.yaml b/Documentation/devicetree/bindings/media/qcom,msm8916-venus.yaml
> index 9410f13ca97c181973c62fe62d0399fc9e82f05d..da140c2e3d3f3c3e886496e3e2303eda1df99bb4 100644
> --- a/Documentation/devicetree/bindings/media/qcom,msm8916-venus.yaml
> +++ b/Documentation/devicetree/bindings/media/qcom,msm8916-venus.yaml
> @@ -45,6 +45,7 @@ properties:
>      required:
>        - compatible
>  
> +    deprecated: true
>      additionalProperties: false
>  
>    video-encoder:
> @@ -57,13 +58,12 @@ properties:
>      required:
>        - compatible
>  
> +    deprecated: true
>      additionalProperties: false
>  
>  required:
>    - compatible
>    - iommus
> -  - video-decoder
> -  - video-encoder
>  
>  unevaluatedProperties: false
>  
> @@ -83,12 +83,4 @@ examples:
>          power-domains = <&gcc VENUS_GDSC>;
>          iommus = <&apps_iommu 5>;
>          memory-region = <&venus_mem>;
> -
> -        video-decoder {
> -            compatible = "venus-decoder";
> -        };
> -
> -        video-encoder {
> -            compatible = "venus-encoder";
> -        };
>      };
> diff --git a/Documentation/devicetree/bindings/media/qcom,sc7180-venus.yaml b/Documentation/devicetree/bindings/media/qcom,sc7180-venus.yaml
> index 5cec1d077cda77817f6d876109defcb0abbfeb2c..83c4a5d95f020437bd160d6456850bc84a2cf5ff 100644
> --- a/Documentation/devicetree/bindings/media/qcom,sc7180-venus.yaml
> +++ b/Documentation/devicetree/bindings/media/qcom,sc7180-venus.yaml
> @@ -70,6 +70,7 @@ properties:
>      required:
>        - compatible
>  
> +    deprecated: true
>      additionalProperties: false
>  
>    video-encoder:
> @@ -82,14 +83,13 @@ properties:
>      required:
>        - compatible
>  
> +    deprecated: true
>      additionalProperties: false
>  
>  required:
>    - compatible
>    - power-domain-names
>    - iommus
> -  - video-decoder
> -  - video-encoder
>  
>  unevaluatedProperties: false
>  
> @@ -114,12 +114,4 @@ examples:
>                        "vcodec0_core", "vcodec0_bus";
>          iommus = <&apps_smmu 0x0c00 0x60>;
>          memory-region = <&venus_mem>;
> -
> -        video-decoder {
> -            compatible = "venus-decoder";
> -        };
> -
> -        video-encoder {
> -            compatible = "venus-encoder";
> -        };
>      };
> diff --git a/Documentation/devicetree/bindings/media/qcom,sc7280-venus.yaml b/Documentation/devicetree/bindings/media/qcom,sc7280-venus.yaml
> index 10c334e6b3dcf25967fa438f8e6e5035448af1b9..413c5b4ee6504ba1d5fe9f74d5be04ad8c90c318 100644
> --- a/Documentation/devicetree/bindings/media/qcom,sc7280-venus.yaml
> +++ b/Documentation/devicetree/bindings/media/qcom,sc7280-venus.yaml
> @@ -68,6 +68,7 @@ properties:
>      required:
>        - compatible
>  
> +    deprecated: true
>      additionalProperties: false
>  
>    video-encoder:
> @@ -80,14 +81,13 @@ properties:
>      required:
>        - compatible
>  
> +    deprecated: true
>      additionalProperties: false
>  
>  required:
>    - compatible
>    - power-domain-names
>    - iommus
> -  - video-decoder
> -  - video-encoder
>  
>  unevaluatedProperties: false
>  
> @@ -125,14 +125,6 @@ examples:
>  
>          memory-region = <&video_mem>;
>  
> -        video-decoder {
> -            compatible = "venus-decoder";
> -        };
> -
> -        video-encoder {
> -            compatible = "venus-encoder";
> -        };
> -
>          video-firmware {
>              iommus = <&apps_smmu 0x21a2 0x0>;
>          };
> diff --git a/Documentation/devicetree/bindings/media/qcom,sdm845-venus-v2.yaml b/Documentation/devicetree/bindings/media/qcom,sdm845-venus-v2.yaml
> index 6228fd2b324631f3138e128c918266da58f6b544..c839cb1ebc0999e10b865f4bb43ea76ffa2bf46d 100644
> --- a/Documentation/devicetree/bindings/media/qcom,sdm845-venus-v2.yaml
> +++ b/Documentation/devicetree/bindings/media/qcom,sdm845-venus-v2.yaml
> @@ -70,6 +70,7 @@ properties:
>      required:
>        - compatible
>  
> +    deprecated: true
>      additionalProperties: false
>  
>    video-core1:
> @@ -82,14 +83,13 @@ properties:
>      required:
>        - compatible
>  
> +    deprecated: true
>      additionalProperties: false
>  
>  required:
>    - compatible
>    - power-domain-names
>    - iommus
> -  - video-core0
> -  - video-core1
>  
>  unevaluatedProperties: false
>  
> @@ -119,12 +119,4 @@ examples:
>          iommus = <&apps_smmu 0x10a0 0x8>,
>                   <&apps_smmu 0x10b0 0x0>;
>          memory-region = <&venus_mem>;
> -
> -        video-core0 {
> -            compatible = "venus-decoder";
> -        };
> -
> -        video-core1 {
> -            compatible = "venus-encoder";
> -        };
>      };
> diff --git a/Documentation/devicetree/bindings/media/qcom,sm8250-venus.yaml b/Documentation/devicetree/bindings/media/qcom,sm8250-venus.yaml
> index f66033ae8b590e7b6f1e344c368994744411aca2..da54493220c9dc90e7d9f5fcfce7590acb241c85 100644
> --- a/Documentation/devicetree/bindings/media/qcom,sm8250-venus.yaml
> +++ b/Documentation/devicetree/bindings/media/qcom,sm8250-venus.yaml
> @@ -73,6 +73,7 @@ properties:
>      required:
>        - compatible
>  
> +    deprecated: true
>      additionalProperties: false
>  
>    video-encoder:
> @@ -85,6 +86,7 @@ properties:
>      required:
>        - compatible
>  
> +    deprecated: true
>      additionalProperties: false
>  
>  required:
> @@ -95,8 +97,6 @@ required:
>    - iommus
>    - resets
>    - reset-names
> -  - video-decoder
> -  - video-encoder
>  
>  unevaluatedProperties: false
>  
> @@ -132,12 +132,4 @@ examples:
>          resets = <&gcc GCC_VIDEO_AXI0_CLK_ARES>,
>                   <&videocc VIDEO_CC_MVS0C_CLK_ARES>;
>          reset-names = "bus", "core";
> -
> -        video-decoder {
> -            compatible = "venus-decoder";
> -        };
> -
> -        video-encoder {
> -            compatible = "venus-encoder";
> -        };
>      };
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 3/3] media: dt-bindings: qcom-venus: Deprecate video-decoder and video-encoder where applicable
  2024-12-06 10:03   ` Dikshita Agarwal
@ 2024-12-06 21:25     ` Bryan O'Donoghue
  0 siblings, 0 replies; 7+ messages in thread
From: Bryan O'Donoghue @ 2024-12-06 21:25 UTC (permalink / raw)
  To: Dikshita Agarwal, Stanimir Varbanov, Vikash Garodia,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: quic_renjiang, quic_vnagar, konradybcio, linux-media,
	linux-arm-msm, linux-kernel, devicetree, Krzysztof Kozlowski

On 06/12/2024 10:03, Dikshita Agarwal wrote:
> On 11/28/2024 9:51 PM, Bryan O'Donoghue wrote:
>> For the list of yaml files here the video-decoder and video-encoder nodes
>> provide nothing more than configuration input for the driver. These entries
>> do not in fact impart hardware specific data and should be deprecated.
>>
>> Reviewed-by: Krzysztof Kozlowski<krzysztof.kozlowski@linaro.org>
>> Signed-off-by: Bryan O'Donoghue<bryan.odonoghue@linaro.org>
>> ---
>>   .../devicetree/bindings/media/qcom,msm8916-venus.yaml        | 12 ++----------
>>   .../devicetree/bindings/media/qcom,sc7180-venus.yaml         | 12 ++----------
>>   .../devicetree/bindings/media/qcom,sc7280-venus.yaml         | 12 ++----------
>>   .../devicetree/bindings/media/qcom,sdm845-venus-v2.yaml      | 12 ++----------
>>   .../devicetree/bindings/media/qcom,sm8250-venus.yaml         | 12 ++----------
>>   5 files changed, 10 insertions(+), 50 deletions(-)
>>
> A general query, this change is not done for 8996-venus, sdm660-venus and
> sdm845-venus, was that intentional? may be because these are not active
> SOCs in upstream?

No per the cover letter, those SoCs have power-domains and clocks inside 
of them, so the dtsi entries actually does relate to a hardware 
description in that case.

---
bod



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/3] media: venus: Add support for static video encoder/decoder declarations
  2024-11-28 16:21 ` [PATCH v4 1/3] media: venus: Add support for static video encoder/decoder declarations Bryan O'Donoghue
@ 2024-12-09  6:29   ` Dikshita Agarwal
  0 siblings, 0 replies; 7+ messages in thread
From: Dikshita Agarwal @ 2024-12-09  6:29 UTC (permalink / raw)
  To: Bryan O'Donoghue, Stanimir Varbanov, Vikash Garodia,
	Mauro Carvalho Chehab, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: quic_renjiang, quic_vnagar, konradybcio, linux-media,
	linux-arm-msm, linux-kernel, devicetree



On 11/28/2024 9:51 PM, Bryan O'Donoghue wrote:
> Add resource structure data and probe() logic to support static
> declarations of encoder and decoder.
> 
> Right now we rely on video encoder/decoder selection happening in the dtb
> but, this goes against the remit of device tree which is supposed to
> describe hardware, not select functional logic in Linux drivers.
> 
> Provide two strings in the venus resource structure enc_nodename and
> dec_nodename.
> 
> When set the venus driver will create an OF entry in-memory consistent
> with:
> 
> dec_nodename {
>     compat = "video-decoder";
> };
> 
> and/or
> 
> enc_nodename {
>     compat = "video-encoder";
> };
> 
> This will allow us to reuse the existing driver scheme of relying on compat
> names maintaining compatibility with old dtb files.
> 
> dec_nodename can be "video-decoder" or "video0"
> enc_nodename can be "video-encoder" or "video1"
> 
> This change relies on of_changeset() API as a result select OF_DYNAMIC will
> be added to venus/Kconfig
> 
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  drivers/media/platform/qcom/venus/Kconfig |  1 +
>  drivers/media/platform/qcom/venus/core.c  | 90 +++++++++++++++++++++++++++++++
>  drivers/media/platform/qcom/venus/core.h  |  4 ++
>  3 files changed, 95 insertions(+)
> 
> diff --git a/drivers/media/platform/qcom/venus/Kconfig b/drivers/media/platform/qcom/venus/Kconfig
> index bfd50e8f34219db8a1de7960d7ea93b20db2982a..bc2e410b29cb415a36540a4f98709eae44f4ec35 100644
> --- a/drivers/media/platform/qcom/venus/Kconfig
> +++ b/drivers/media/platform/qcom/venus/Kconfig
> @@ -3,6 +3,7 @@ config VIDEO_QCOM_VENUS
>  	depends on V4L_MEM2MEM_DRIVERS
>  	depends on VIDEO_DEV && QCOM_SMEM
>  	depends on (ARCH_QCOM && IOMMU_DMA) || COMPILE_TEST
> +	select OF_DYNAMIC if ARCH_QCOM
>  	select QCOM_MDT_LOADER if ARCH_QCOM
>  	select QCOM_SCM
>  	select VIDEOBUF2_DMA_CONTIG
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index 4e26b18790537885a77d66c1917a4e7a146eaf57..8a085611443cfda89ae71496e320dfc1f02ade88 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -286,6 +286,89 @@ static irqreturn_t venus_isr_thread(int irq, void *dev_id)
>  	return ret;
>  }
>  
> +#if defined(CONFIG_OF_DYNAMIC)
> +static int venus_add_video_core(struct venus_core *core, const char *node_name,
> +				const char *compat)
> +{
> +	struct of_changeset *ocs = core->ocs;
> +	struct device *dev = core->dev;
> +	struct device_node *np, *enp;
> +	int ret;
> +
> +	if (!node_name)
> +		return 0;> +
> +	enp = of_find_node_by_name(dev->of_node, node_name);
> +	if (enp) {
> +		of_node_put(enp);
> +		return 0;
> +	}
> +
> +	np = of_changeset_create_node(ocs, dev->of_node, node_name);
> +	if (!np) {
> +		dev_err(dev, "Unable to create new node\n");
> +		return -ENODEV;
> +	}
> +
> +	ret = of_changeset_add_prop_string(ocs, np, "compatible", compat);
> +	if (ret)
> +		dev_err(dev, "unable to add %s\n", compat);
> +
> +	of_node_put(np);
> +
> +	return ret;
> +}
> +
> +static int venus_add_dynamic_nodes(struct venus_core *core)
> +{
> +	struct device *dev = core->dev;
> +	int ret;
> +
> +	core->ocs = kmalloc(sizeof(*core->ocs), GFP_KERNEL);
> +	if (!core->ocs)
> +		return -ENOMEM;
> +
> +	of_changeset_init(core->ocs);
> +
> +	ret = venus_add_video_core(core, core->res->dec_nodename, "venus-decoder");
> +	if (ret)
> +		goto err;
> +
> +	ret = venus_add_video_core(core, core->res->enc_nodename, "venus-encoder");
> +	if (ret)
> +		goto err;
> +
> +	ret = of_changeset_apply(core->ocs);
> +	if (ret) {
> +		dev_err(dev, "applying changeset fail ret %d\n", ret);
> +		goto err;
> +	}
> +
> +	return 0;
> +err:
> +	of_changeset_destroy(core->ocs);
> +	kfree(core->ocs);
> +	core->ocs = NULL;
> +	return ret;
> +}
> +
> +static void venus_remove_dynamic_nodes(struct venus_core *core)
> +{
> +	if (core->ocs) {
> +		of_changeset_revert(core->ocs);
> +		of_changeset_destroy(core->ocs);
> +		kfree(core->ocs);
> +	}
> +}
> +#else
> +static int venus_add_dynamic_nodes(struct venus_core *core)
> +{
> +	return 0;
> +}
> +
> +static void venus_remove_dynamic_nodes(struct venus_core *core) {}
> +#endif
> +
>  static int venus_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -365,6 +448,11 @@ static int venus_probe(struct platform_device *pdev)
>  	if (ret < 0)
>  		goto err_runtime_disable;
>  
> +	if (core->res->dec_nodename || core->res->enc_nodename) {
> +		if (venus_add_dynamic_nodes(core))
> +			goto err_runtime_disable;
> +	}
> +
>  	ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
>  	if (ret)
>  		goto err_runtime_disable;
venus_remove_dynamic_nodes should be called in error handling in probe as
well I think.

Thanks,
Dikshita
> @@ -443,6 +531,8 @@ static void venus_remove(struct platform_device *pdev)
>  
>  	venus_firmware_deinit(core);
>  
> +	venus_remove_dynamic_nodes(core);
> +
>  	pm_runtime_put_sync(dev);
>  	pm_runtime_disable(dev);
>  
> diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
> index 27784fd7082c321222b23ca4b2902a04c49e19ca..306231b4f7d0201175974b4a42574f30d23e08f0 100644
> --- a/drivers/media/platform/qcom/venus/core.h
> +++ b/drivers/media/platform/qcom/venus/core.h
> @@ -90,6 +90,8 @@ struct venus_resources {
>  	u32 cp_nonpixel_start;
>  	u32 cp_nonpixel_size;
>  	const char *fwname;
> +	const char *enc_nodename;
> +	const char *dec_nodename;
>  };
>  
>  enum venus_fmt {
> @@ -171,6 +173,7 @@ struct venus_format {
>   * @root:	debugfs root directory
>   * @venus_ver:	the venus firmware version
>   * @dump_core:	a flag indicating that a core dump is required
> + * @ocs:	OF changeset pointer
>   */
>  struct venus_core {
>  	void __iomem *base;
> @@ -235,6 +238,7 @@ struct venus_core {
>  		u32 rev;
>  	} venus_ver;
>  	unsigned long dump_core;
> +	struct of_changeset *ocs;
>  };
>  
>  struct vdec_controls {
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-12-09  6:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-28 16:21 [PATCH v4 0/3] media: venus: Provide support for selecting encoder/decoder from in-driver Bryan O'Donoghue
2024-11-28 16:21 ` [PATCH v4 1/3] media: venus: Add support for static video encoder/decoder declarations Bryan O'Donoghue
2024-12-09  6:29   ` Dikshita Agarwal
2024-11-28 16:21 ` [PATCH v4 2/3] media: venus: Populate video encoder/decoder nodename entries Bryan O'Donoghue
2024-11-28 16:21 ` [PATCH v4 3/3] media: dt-bindings: qcom-venus: Deprecate video-decoder and video-encoder where applicable Bryan O'Donoghue
2024-12-06 10:03   ` Dikshita Agarwal
2024-12-06 21:25     ` Bryan O'Donoghue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox