Skip to contentSkip to conversation

media: qcom: venus: add MSM8939 support

RFC PATCH Superseded Erikas Bitovtas 3 participants 22 messages Apr 27 – Apr 29

Subsystems (8)

v3 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v3 cover media: qcom: venus: add MSM8939 support

This patch series adds support for Venus on MSM8939. It is mostly similar to MSM8916 Venus, except it needs two additional cores to be powered on before it can start decoding.

This patch series is marked as an RFC. Before submitting a non-RFC series, I would like to have some details clarified regarding how Venus works in order to improve and eventually upstream support for MSM8939.

1. In downstream, particularly in LA.BR.1.2.9.1_rb1.5, the buses for vcodec0 cores have only decoding bits enabled, as depicted by qcom,bus-configs property of qcom,msm-bus-clients children in qcom,vidc node. Do I understand correctly that these cores are only needed for decoding, and not for encoding?
2. Currently in device tree there is a video-decoder subnode for Venus node, however, for SDM845-v2 (and newer) chipsets, Venus does not use subnodes. Does this mean it should be dropped for MSM8939 as well?
3. MSM8939 supports HEVC decoding, however, as the patchset is written now, it does not work. It can be enabled, however, it will result in breakage of Venus for faulty MSM8916 firmwares, because the code disabling HEVC for HFI v1 needs to be removed, and as per commit c50cc6dc6c48 ("media: venus: hfi_parser: Ignore HEVC encoding for V1"), this would break support for some MSM8916 devices. What could be the best way to work around this?
4. To attach vcodec0 power domain list to dev_{dec,enc}, I had to move vdec_get and venc_get later in the probe. Should this be avoided, and is there a better way to attach vcodec power domains?

There may be some other issues with this patchset - this is WIP code, so feedback is very appreciated. Thank you!

Also, as per Dmitry's request, I am attaching Fluster results and v4l2-compliance output. Fluster results were very inconsistent and caused power collapse fails.
H.264: https://pastebin.com/C15qeq5W
H.265 (HEVC): https://pastebin.com/WDsnxvuk
VP8: https://pastebin.com/egAgEm15
v4l2-compliance: https://pastebin.com/VpBhEFc1
Power collapse fail log: https://pastebin.com/rTivMcpK

---
Changes in v3:
- Added missing vcodec1_clks to resource struct.
- Removed enc_nodename from resource struct since we include
video-decoder now.
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Enabled GDSCs during encoding as well.
- Merged vcodec{0,1}_pmdomains_num into vcodec_pmdomains_num.
- Reworded commit for marking GDSCs as hardware controlled. Same
situation as in cdc59600bccf ("clk: qcom: gcc-msm8953: fix stuck venus0_core0 clock")
- Clarified the reason for missing firmware-name property in device
tree.
- Clarified the reason for moving vdec_get and venc_get for later.
- Link to v1: https://patch.msgid.link/[email protected]

To: Bryan O'Donoghue <[email protected]>
To: Vikash Garodia <[email protected]>
To: Dikshita Agarwal <[email protected]>
To: Mauro Carvalho Chehab <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: André Apitzsch <[email protected]>
To: Erikas Bitovtas <[email protected]>
To: Bjorn Andersson <[email protected]>
To: Konrad Dybcio <[email protected]>
To: Michael Turquette <[email protected]>
To: Stephen Boyd <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
André Apitzsch (4):
media: dt-bindings: venus: Add qcom,msm8939 schema
media: qcom: venus: Add msm8939 resource struct
arm64: dts: qcom: msm8939: Add venus node
arm64: dts: qcom: msm8939-longcheer-l9100: Enable venus node

Erikas Bitovtas (7):
media: qcom: venus: add pmdomains to the struct based on the purpose of cores
arm64: dts: qcom: msm8939-asus-z00t: add Venus
clk: qcom: gcc-msm8939: mark Venus core GDSCs as hardware controlled
media: qcom: venus: move getting vdec and venc for later
media: qcom: venus: Move HFI v3 venc and vdec methods to HFI v1
media: qcom: venus: add power domain enable logic for Venus cores
media: qcom: venus: Enable HEVC decoding for MSM8939

 .../bindings/media/qcom,msm8939-venus.yaml         | 147 ++++++++++++++++
 arch/arm64/boot/dts/qcom/msm8939-asus-z00t.dts     |   8 +
 .../boot/dts/qcom/msm8939-longcheer-l9100.dts      |   8 +
 arch/arm64/boot/dts/qcom/msm8939.dtsi              |  34 ++++
 drivers/clk/qcom/gcc-msm8939.c                     |   4 +
 drivers/media/platform/qcom/venus/core.c           |  42 +++++
 drivers/media/platform/qcom/venus/core.h           |   6 +
 drivers/media/platform/qcom/venus/hfi_parser.c     |   3 +-
 drivers/media/platform/qcom/venus/pm_helpers.c     | 187 ++++++++++++++++++---
 drivers/media/platform/qcom/venus/vdec.c           |  12 +-
 drivers/media/platform/qcom/venus/venc.c           |  12 +-
 11 files changed, 430 insertions(+), 33 deletions(-)

---
base-commit: 7080e32d3f09d8688c4a87d81bdcc71f7f606b16
change-id: 20260416-msm8939-venus-rfc-c025c4c74fae

Best regards,

Signature · 1 line
Erikas Bitovtas <[email protected]>
#1 lore raw

RFC PATCH v3 1/11 media: dt-bindings: venus: Add qcom,msm8939 schema

From: André Apitzsch <[email protected]>

Add a schema description for the Venus video decoder/encoder IP in MSM8939.

---
 .../bindings/media/qcom,msm8939-venus.yaml         | 147 +++++++++++++++++++++
 1 file changed, 147 insertions(+)
Documentation/devicetree/bindings/media/qcom,msm8939-venus.yaml new file +147 -0
new file mode 100644
index 000000000000..5790b3bf5aef
@@ -0,0 +1,147 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/qcom,msm8939-venus.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm MSM8939 Venus video encode and decode accelerators
+
+maintainers:
+  - André Apitzsch <[email protected]>
+  - Erikas Bitovtas <[email protected]>
+
+description: |
+  The Venus IP is a video encode and decode accelerator present
+  on Qualcomm platforms
+
+allOf:
+  - $ref: qcom,venus-common.yaml#
+
+properties:
+  compatible:
+    const: qcom,msm8939-venus
+
+  power-domains:
+    maxItems: 1
+
+  clocks:
+    maxItems: 3
+
+  clock-names:
+    items:
+      - const: core
+      - const: iface
+      - const: bus
+
+  iommus:
+    maxItems: 1
+
+  video-decoder:
+    type: object
+
+    properties:
+      compatible:
+        const: venus-decoder
+
+      clocks:
+        maxItems: 2
+
+      clock-names:
+        items:
+          - const: core0
+          - const: core1
+
+      power-domains:
+        maxItems: 2
+
+      power-domain-names:
+        items:
+          - const: core0
+          - const: core1
+
+    required:
+      - compatible
+      - clocks
+      - clock-names
+      - power-domains
+      - power-domain-names
+
+    additionalProperties: false
+
+  video-encoder:
+    type: object
+
+    properties:
+      compatible:
+        const: venus-encoder
+
+      clocks:
+        maxItems: 2
+
+      clock-names:
+        items:
+          - const: core0
+          - const: core1
+
+      power-domains:
+        maxItems: 2
+
+      power-domain-names:
+        items:
+          - const: core0
+          - const: core1
+
+    required:
+      - compatible
+      - clocks
+      - clock-names
+      - power-domains
+      - power-domain-names
+
+    additionalProperties: false
+
+required:
+  - compatible
+  - iommus
+  - video-decoder
+  - video-encoder
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/qcom,gcc-msm8939.h>
+
+    video-codec@1d00000 {
+        compatible = "qcom,msm8939-venus";
+        reg = <0x01d00000 0xff000>;
+        interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&gcc GCC_VENUS0_VCODEC0_CLK>,
+                 <&gcc GCC_VENUS0_AHB_CLK>,
+                 <&gcc GCC_VENUS0_AXI_CLK>;
+        clock-names = "core", "iface", "bus";
+        power-domains = <&gcc VENUS_GDSC>;
+        iommus = <&apps_iommu 5>;
+        memory-region = <&venus_mem>;
+
+        video-decoder {
+          compatible = "venus-decoder";
+          clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>,
+                   <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>;
+          clock-names = "core0", "core1";
+          power-domains = <&gcc VENUS_CORE0_GDSC>,
+                          <&gcc VENUS_CORE1_GDSC>;
+          power-domain-names = "core0", "core1";
+        };
+
+        video-encoder {
+          compatible = "venus-encoder";
+          clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>,
+                   <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>;
+          clock-names = "core0", "core1";
+          power-domains = <&gcc VENUS_CORE0_GDSC>,
+                          <&gcc VENUS_CORE1_GDSC>;
+          power-domain-names = "core0", "core1";
+        };
+    };
Signature · 1 line
2.54.0
maintainer
#2 lore raw

Re: [PATCH RFC v3 01/11] media: dt-bindings: venus: Add qcom,msm8939 schema

Documentation/devicetree/bindings/media/qcom,msm8939-venus.yaml line 76

Quoted 6 lines · Erikas Bitovtas
Documentation/devicetree/bindings/media/qcom,msm8939-venus.yaml new file +6 -0
+  video-encoder:
+    type: object
+
+    properties:
+      compatible:
+        const: venus-encoder

This should be dropped.

The new way is to declare encoder/decoder inline in the driver, I pointed this out to you at the last revision.

---
bod

#3 lore raw

RFC PATCH v3 2/11 media: qcom: venus: add pmdomains to the struct based on the purpose of cores

In reply to Erikas Bitovtas

Add vcodec0_pmdomains and vcodec1_pmdomains to indicate power domains for Venus cores.

---
 drivers/media/platform/qcom/venus/core.h | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/platform/qcom/venus/core.h +6 -0
index 7506f5d0f609..1a919439abc1 100644
@@ -80,6 +80,8 @@ struct venus_resources {
 	const char * const vcodec0_clks[VIDC_VCODEC_CLKS_NUM_MAX];
 	const char * const vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX];
 	unsigned int vcodec_clks_num;
+	const char **vcodec0_pmdomains;
+	const char **vcodec1_pmdomains;
 	const char **vcodec_pmdomains;
 	unsigned int vcodec_pmdomains_num;
 	const char **opp_pmdomain;
@@ -144,6 +146,8 @@ struct venus_format {
  * @vcodec1_clks: an array of vcodec1 struct clk pointers
  * @video_path: an interconnect handle to video to/from memory path
  * @cpucfg_path: an interconnect handle to cpu configuration path
+ * @vcodec0_pmdomans: a pointer to a list of pmdomains for vcodec0 cores
+ * @vcodec1_pmdomans: a pointer to a list of pmdomains for vcodec1 cores
  * @pmdomains:	a pointer to a list of pmdomains
  * @opp_pmdomain: an OPP power-domain
  * @resets: an array of reset signals
@@ -198,6 +202,8 @@ struct venus_core {
 	struct clk *vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX];
 	struct icc_path *video_path;
 	struct icc_path *cpucfg_path;
+	struct dev_pm_domain_list *vcodec0_pmdomains;
+	struct dev_pm_domain_list *vcodec1_pmdomains;
 	struct dev_pm_domain_list *pmdomains;
 	struct dev_pm_domain_list *opp_pmdomain;
 	struct reset_control *resets[VIDC_RESETS_NUM_MAX];
Signature · 1 line
2.54.0
#4 lore raw

RFC PATCH v3 3/11 media: qcom: venus: Add msm8939 resource struct

In reply to Erikas Bitovtas

From: André Apitzsch <[email protected]>

Add msm8939 configuration data and related compatible.

---
 drivers/media/platform/qcom/venus/core.c | 40 ++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
drivers/media/platform/qcom/venus/core.c +40 -0
index 7e639760c41d..5bd3ad21b366 100644
@@ -688,6 +688,45 @@ static const struct venus_resources msm8916_res = {
 	.enc_nodename = "video-encoder",
 };
 
+static const struct freq_tbl msm8939_freq_table[] = {
+	{ 489600, 266670000 },	/* 1080p @ 60 */
+	{ 244800, 133330000 },	/* 1080p @ 30 */
+	{ 244800, 200000000 },	/* 1080p @ 30 */
+	{ 220800, 133330000 },	/* 720p @ 60 */
+	{ 108000, 133330000 },	/* 720p @ 30 */
+	{ 108000, 200000000 },	/* 720p @ 30 */
+	{ 72000, 133330000 },	/* VGA @ 60 */
+	{ 36000, 133330000 },	/* VGA @ 30 */
+};
+
+static const struct reg_val msm8939_reg_preset[] = {
+	{ 0xe0020, 0x0aaaaaaa },
+	{ 0xe0024, 0x0aaaaaaa },
+	{ 0x80124, 0x00000003 },
+};
+
+static const struct venus_resources msm8939_res = {
+	.freq_tbl = msm8939_freq_table,
+	.freq_tbl_size = ARRAY_SIZE(msm8939_freq_table),
+	.reg_tbl = msm8939_reg_preset,
+	.reg_tbl_size = ARRAY_SIZE(msm8939_reg_preset),
+	.clks = { "core", "iface", "bus", },
+	.clks_num = 3,
+	.vcodec0_clks = { "core0", "core1" },
+	.vcodec1_clks = { "core0", "core1" },
+	.vcodec_clks_num = 2,
+	.vcodec0_pmdomains = (const char *[]) { "core0", "core1" },
+	.vcodec1_pmdomains = (const char *[]) { "core0", "core1" },
+	.vcodec_pmdomains_num = 2,
+	.max_load = 489600, /* 1080p@30 + 1080p@30 */
+	.hfi_version = HFI_VERSION_1XX,
+	.vmem_id = VIDC_RESOURCE_NONE,
+	.vmem_size = 0,
+	.vmem_addr = 0,
+	.dma_mask = 0xddc00000 - 1,
+	.fwname = "qcom/venus-1.8/venus.mbn",
+};
+
 static const struct freq_tbl msm8996_freq_table[] = {
 	{ 1944000, 520000000 },	/* 4k UHD @ 60 (decode only) */
 	{  972000, 520000000 },	/* 4k UHD @ 30 */
@@ -1121,6 +1160,7 @@ static const struct venus_resources qcm2290_res = {
 
 static const struct of_device_id venus_dt_match[] = {
 	{ .compatible = "qcom,msm8916-venus", .data = &msm8916_res, },
+	{ .compatible = "qcom,msm8939-venus", .data = &msm8939_res, },
 	{ .compatible = "qcom,msm8996-venus", .data = &msm8996_res, },
 	{ .compatible = "qcom,msm8998-venus", .data = &msm8998_res, },
 	{ .compatible = "qcom,qcm2290-venus", .data = &qcm2290_res, },
Signature · 1 line
2.54.0
#5 lore raw

RFC PATCH v3 4/11 arm64: dts: qcom: msm8939: Add venus node

In reply to Erikas Bitovtas

From: André Apitzsch <[email protected]>

Add DT entries for the msm8939 venus encoder/decoder.

---
 arch/arm64/boot/dts/qcom/msm8939.dtsi | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
arch/arm64/boot/dts/qcom/msm8939.dtsi +34 -0
index d4d7b0c9206c..6b295d3f8256 100644
@@ -1627,6 +1627,40 @@ opp-19200000 {
 			};
 		};
 
+		venus: video-codec@1d00000 {
+			compatible = "qcom,msm8939-venus";
+			reg = <0x01d00000 0xff000>;
+			interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&gcc GCC_VENUS0_VCODEC0_CLK>,
+				 <&gcc GCC_VENUS0_AHB_CLK>,
+				 <&gcc GCC_VENUS0_AXI_CLK>;
+			clock-names = "core", "iface", "bus";
+			power-domains = <&gcc VENUS_GDSC>;
+			iommus = <&apps_iommu 5>;
+			memory-region = <&venus_mem>;
+			status = "disabled";
+
+			video-decoder {
+				compatible = "venus-decoder";
+				clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>,
+					 <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>;
+				clock-names = "core0", "core1";
+				power-domains = <&gcc VENUS_CORE0_GDSC>,
+						<&gcc VENUS_CORE1_GDSC>;
+				power-domain-names = "core0", "core1";
+			};
+
+			video-encoder {
+				compatible = "venus-encoder";
+				clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>,
+					 <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>;
+				clock-names = "core0", "core1";
+				power-domains = <&gcc VENUS_CORE0_GDSC>,
+						<&gcc VENUS_CORE1_GDSC>;
+				power-domain-names = "core0", "core1";
+			};
+		};
+
 		apps_iommu: iommu@1ef0000 {
 			compatible = "qcom,msm8916-iommu", "qcom,msm-iommu-v1";
 			reg = <0x01ef0000 0x3000>;
Signature · 1 line
2.54.0
maintainer
#6 lore raw

Re: [PATCH RFC v3 04/11] arm64: dts: qcom: msm8939: Add venus node

Quoted 9 lines · Erikas Bitovtas
arch/arm64/boot/dts/qcom/msm8939.dtsi +9 -0
+			video-decoder {
+				compatible = "venus-decoder";
+				clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>,
+					 <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>;
+				clock-names = "core0", "core1";
+				power-domains = <&gcc VENUS_CORE0_GDSC>,
+						<&gcc VENUS_CORE1_GDSC>;
+				power-domain-names = "core0", "core1";
+			};

arch/arm64/boot/dts/qcom/msm8939.dtsi opp-19200000 { · line 1661

Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8939.dtsi +10 -0
+
+			video-encoder {
+				compatible = "venus-encoder";
+				clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>,
+					 <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>;
+				clock-names = "core0", "core1";
+				power-domains = <&gcc VENUS_CORE0_GDSC>,
+						<&gcc VENUS_CORE1_GDSC>;
+				power-domain-names = "core0", "core1";
+			};

So to be fair in this case you do have a reason to have an encoder and decoder compatible here _but_ it should be the case that one one of the sub-devices contains CORE0 related stuff and the other CORE1 related stuff.

Because in that case the sub-devices actually represent individual hardware settings.

So listing power-domains and clocks for both cores in each node like this militates against that.

The other thing is to double check of the encoder and decoder are inter-changable here i.e. can either core be encoder or decoder or is it fixed ?

I believe on older generations - perhaps not on 8939 it is not interchangable.

If it is interchangable then declaring either node specifically encoder or decoder is incorrect so you should declare that inline in venus itself.

Perhaps Vikash or Dikshita could confirm whether or not the cores have fixed encoder/decoder functionality.

TBH I think you should stick to the inline declaration.

---
bod

#7 lore raw

Re: [PATCH RFC v3 04/11] arm64: dts: qcom: msm8939: Add venus node

Quoted 28 lines · Bryan O'Donoghue
Quoted 11 lines · Erikas Bitovtas

+            video-decoder {
+                compatible = "venus-decoder";
+                clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>, +                     <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>; +                clock-names = "core0", "core1";
+                power-domains = <&gcc VENUS_CORE0_GDSC>, +                        <&gcc VENUS_CORE1_GDSC>;
+                power-domain-names = "core0", "core1"; +            };
+
+            video-encoder {

Quoted 8 lines

+                compatible = "venus-encoder";
+                clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>, +                     <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>; +                clock-names = "core0", "core1";
+                power-domains = <&gcc VENUS_CORE0_GDSC>, +                        <&gcc VENUS_CORE1_GDSC>;
+                power-domain-names = "core0", "core1"; +            };

So to be fair in this case you do have a reason to have an encoder and decoder compatible here _but_ it should be the case that one one of the sub-devices contains CORE0 related stuff and the other CORE1 related stuff.

Because in that case the sub-devices actually represent individual hardware settings.

Quoted 9 lines

So listing power-domains and clocks for both cores in each node like this militates against that.

The other thing is to double check of the encoder and decoder are inter- changable here i.e. can either core be encoder or decoder or is it fixed ?

I believe on older generations - perhaps not on 8939 it is not interchangable.

I found this in LA.BR.1.2.9.1_rb1.5:
https://github.com/msm8916-mainline/linux-downstream/blob/b20608408caff817ec874f325127b07609fbaeb8/arch/arm/boot/dts/qcom/msm8939-common.dtsi#L1589
Only decoder bits are being set in bus configs. This suggests that the cores are not interchangeable.
Then again, I never managed to get encoding working on MSM8939. Testing it with
gst-launch-1.0 videotestsrc ! videoconvert ! v4l2vp8enc ! queue ! v4l2vp8dec ! xvimagesink
Fails with the following log: https://pastebin.com/nmZcLgPV
And in dmesg it reports a firmware error:

[  784.461031] qcom-venus 1d00000.video-codec: no valid instance(pkt
session_id:dead, pkt:21001)
[  784.461126] qcom-venus-decoder 1d00000.video-codec:video-decoder:
dec: event session error 0
[  784.461200] qcom-venus-encoder 1d00000.video-codec:video-encoder:
enc: event session error 0
[  784.468799] qcom-venus 1d00000.video-codec: SFR message from FW:
QC_IMAGE_VERSION_STRING=VIDEO.VE.1.8-00099, Err_Fatal -
Z:\b\venus\utils\src\vbuffer.c:1319:
[  785.791641] qcom-venus 1d00000.video-codec: System error has
occurred, recovery failed to init HFI
[  787.018339] qcom-venus 1d00000.video-codec: System error has
occurred, recovery failed to init HFI
[  787.097253] qcom-venus 1d00000.video-codec: system error has occurred

(recovered)
This happens regardless of whether I enable the cores for encoding too or not. The same errors were happening on MSM8916 as well. So I can't tell if these cores are interchangeable just by testing.

maintainer
#8 lore raw

Re: [PATCH RFC v3 04/11] arm64: dts: qcom: msm8939: Add venus node

Quoted 64 lines · Erikas Bitovtas
Quoted 28 lines · Bryan O'Donoghue
Quoted 11 lines · Erikas Bitovtas

+            video-decoder {
+                compatible = "venus-decoder";
+                clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>, +                     <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>; +                clock-names = "core0", "core1";
+                power-domains = <&gcc VENUS_CORE0_GDSC>, +                        <&gcc VENUS_CORE1_GDSC>;
+                power-domain-names = "core0", "core1"; +            };
+
+            video-encoder {

Quoted 8 lines

+                compatible = "venus-encoder";
+                clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>, +                     <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>; +                clock-names = "core0", "core1";
+                power-domains = <&gcc VENUS_CORE0_GDSC>, +                        <&gcc VENUS_CORE1_GDSC>;
+                power-domain-names = "core0", "core1"; +            };

So to be fair in this case you do have a reason to have an encoder and decoder compatible here _but_ it should be the case that one one of the sub-devices contains CORE0 related stuff and the other CORE1 related stuff.

Because in that case the sub-devices actually represent individual hardware settings.

Quoted 9 lines

So listing power-domains and clocks for both cores in each node like this militates against that.

The other thing is to double check of the encoder and decoder are inter- changable here i.e. can either core be encoder or decoder or is it fixed ?

I believe on older generations - perhaps not on 8939 it is not interchangable.

I found this in LA.BR.1.2.9.1_rb1.5:
https://github.com/msm8916-mainline/linux-downstream/blob/b20608408caff817ec874f325127b07609fbaeb8/arch/arm/boot/dts/qcom/msm8939-common.dtsi#L1589
Only decoder bits are being set in bus configs. This suggests that the cores are not interchangeable.
Then again, I never managed to get encoding working on MSM8939. Testing it with
gst-launch-1.0 videotestsrc ! videoconvert ! v4l2vp8enc ! queue ! v4l2vp8dec ! xvimagesink
Fails with the following log: https://pastebin.com/nmZcLgPV
And in dmesg it reports a firmware error:

[  784.461031] qcom-venus 1d00000.video-codec: no valid instance(pkt
session_id:dead, pkt:21001)
[  784.461126] qcom-venus-decoder 1d00000.video-codec:video-decoder:
dec: event session error 0
[  784.461200] qcom-venus-encoder 1d00000.video-codec:video-encoder:
enc: event session error 0
[  784.468799] qcom-venus 1d00000.video-codec: SFR message from FW:
QC_IMAGE_VERSION_STRING=VIDEO.VE.1.8-00099, Err_Fatal -
Z:\b\venus\utils\src\vbuffer.c:1319:
[  785.791641] qcom-venus 1d00000.video-codec: System error has
occurred, recovery failed to init HFI
[  787.018339] qcom-venus 1d00000.video-codec: System error has
occurred, recovery failed to init HFI
[  787.097253] qcom-venus 1d00000.video-codec: system error has occurred
Quoted 4 lines

(recovered)
This happens regardless of whether I enable the cores for encoding too or not. The same errors were happening on MSM8916 as well. So I can't tell if these cores are interchangeable just by testing.

Right so if you swap around the definition of which core is encoder and which decoder do you get the same or different result ?

i.e. is it because you are trying to get encoder running generally or because of the core you are doing it on ?

How about declaring both cores a decoder ?

---
bod

#9 lore raw

Re: [PATCH RFC v3 04/11] arm64: dts: qcom: msm8939: Add venus node

Quoted 74 lines · Bryan O'Donoghue
Quoted 64 lines · Erikas Bitovtas
Quoted 32 lines · Bryan O'Donoghue
Quoted 11 lines · Erikas Bitovtas

+            video-decoder {
+                compatible = "venus-decoder";
+                clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>, +                     <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>; +                clock-names = "core0", "core1";
+                power-domains = <&gcc VENUS_CORE0_GDSC>, +                        <&gcc VENUS_CORE1_GDSC>;
+                power-domain-names = "core0", "core1"; +            };
+
+            video-encoder {

Quoted 8 lines

+                compatible = "venus-encoder";
+                clocks = <&gcc GCC_VENUS0_CORE0_VCODEC0_CLK>, +                     <&gcc GCC_VENUS0_CORE1_VCODEC0_CLK>; +                clock-names = "core0", "core1";
+                power-domains = <&gcc VENUS_CORE0_GDSC>, +                        <&gcc VENUS_CORE1_GDSC>;
+                power-domain-names = "core0", "core1"; +            };

So to be fair in this case you do have a reason to have an encoder and decoder compatible here _but_ it should be the case that one one of the sub-devices contains CORE0 related stuff and the other CORE1 related stuff.

Because in that case the sub-devices actually represent individual hardware settings.

So listing power-domains and clocks for both cores in each node like this militates against that.

Quoted 7 lines

The other thing is to double check of the encoder and decoder are inter- changable here i.e. can either core be encoder or decoder or is it fixed ?

I believe on older generations - perhaps not on 8939 it is not interchangable.

I found this in LA.BR.1.2.9.1_rb1.5:
https://github.com/msm8916-mainline/linux-downstream/blob/
b20608408caff817ec874f325127b07609fbaeb8/arch/arm/boot/dts/qcom/ msm8939-common.dtsi#L1589
Only decoder bits are being set in bus configs. This suggests that the cores are not interchangeable.
Then again, I never managed to get encoding working on MSM8939. Testing it with
gst-launch-1.0 videotestsrc ! videoconvert ! v4l2vp8enc ! queue ! v4l2vp8dec ! xvimagesink
Fails with the following log: https://pastebin.com/nmZcLgPV
And in dmesg it reports a firmware error:
[  784.461031] qcom-venus 1d00000.video-codec: no valid instance(pkt session_id:dead, pkt:21001)
[  784.461126] qcom-venus-decoder 1d00000.video-codec:video-decoder:
dec: event session error 0
[  784.461200] qcom-venus-encoder 1d00000.video-codec:video-encoder:
enc: event session error 0
[  784.468799] qcom-venus 1d00000.video-codec: SFR message from FW:
QC_IMAGE_VERSION_STRING=VIDEO.VE.1.8-00099, Err_Fatal - Z:\b\venus\utils\src\vbuffer.c:1319:
[  785.791641] qcom-venus 1d00000.video-codec: System error has

Quoted 8 lines

occurred, recovery failed to init HFI
[  787.018339] qcom-venus 1d00000.video-codec: System error has occurred, recovery failed to init HFI
[  787.097253] qcom-venus 1d00000.video-codec: system error has occurred (recovered)
This happens regardless of whether I enable the cores for encoding too or not. The same errors were happening on MSM8916 as well. So I can't tell if these cores are interchangeable just by testing.

Quoted 3 lines

Right so if you swap around the definition of which core is encoder and which decoder do you get the same or different result ?

If I set the core0 to be decoder, only HEVC decoding works. If I set core1, only non-HEVC decoding works. Encoding doesn't work regardless.> i.e. is it because you are trying to get encoder running generally or

Quoted 4 lines

because of the core you are doing it on ?

How about declaring both cores a decoder ?

That is what I did on v1. Ideally we'd decide which core we want to power up based on what codec we are dealing with, but given there is no easy way to do so on mainline yet, it could work.> ---

Quoted 1 line

bod

maintainer
#10 lore raw

Re: [PATCH RFC v3 04/11] arm64: dts: qcom: msm8939: Add venus node

Quoted 5 lines · Erikas Bitovtas
Quoted 2 lines

How about declaring both cores a decoder ?

That is what I did on v1. Ideally we'd decide which core we want to power up based on what codec we are dealing with, but given there is no easy way to do so on mainline yet, it could work.> ---

@Vikash @Dikshita

Could you possibly check up on whether 8936/8939 has fixed core assignments ?

@Erikas please give a try my suggested change on hardware GDSC control - perhaps this is the reason why encoder doesn't work.

---
bod

#11 lore raw

RFC PATCH v3 5/11 arm64: dts: qcom: msm8939-longcheer-l9100: Enable venus node

In reply to Erikas Bitovtas

From: André Apitzsch <[email protected]>

Enable the venus node so that the video encoder/decoder will start working.

Default paths for firmware work on BQ Aquaris M5, which means firmware-name property can be left out.

---
 arch/arm64/boot/dts/qcom/msm8939-longcheer-l9100.dts | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/qcom/msm8939-longcheer-l9100.dts +8 -0
index 13422a19c26a..48514c3df718 100644
@@ -314,6 +314,14 @@ &usb_hs_phy {
 	extcon = <&usb_id>;
 };
 
+&venus {
+	status = "okay";
+};
+
+&venus_mem {
+	status = "okay";
+};
+
 &wcnss {
 	status = "okay";
 };
Signature · 1 line
2.54.0
#12 lore raw

RFC PATCH v3 6/11 arm64: dts: qcom: msm8939-asus-z00t: add Venus

In reply to Erikas Bitovtas

Enable Venus video encoder/decoder for Asus ZenFone 2 Laser/Selfie.

Default firmware paths work on Asus ZenFone 2 Laser/Selfie, which means firmware-name property can be left out.

---
 arch/arm64/boot/dts/qcom/msm8939-asus-z00t.dts | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/qcom/msm8939-asus-z00t.dts +8 -0
index 90e966242720..231a3e9c1929 100644
@@ -267,6 +267,14 @@ &usb_hs_phy {
 	extcon = <&usb_id>;
 };
 
+&venus {
+	status = "okay";
+};
+
+&venus_mem {
+	status = "okay";
+};
+
 &wcnss {
 	status = "okay";
 };
Signature · 1 line
2.54.0
#13 lore raw

RFC PATCH v3 7/11 clk: qcom: gcc-msm8939: mark Venus core GDSCs as hardware controlled

In reply to Erikas Bitovtas

Since in downstream kernel VENUS_CORE0_GDSC and VENUS_CORE1_GDSC have a device tree property "qcom,supports-hw-trigger", add a HW_CTRL flag to these GDSCs to indicate that they are hardware controlled.

Venus core clock cannot be enabled if Venus core GDSCs are switched off. But since they are hardware controlled, they can be switched off at any moment. Vote for the Venus core clock to enable it later when GDSCs get turned on.

---
 drivers/clk/qcom/gcc-msm8939.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/clk/qcom/gcc-msm8939.c +4 -0
index 45193b3d714b..420997b00ae0 100644
@@ -3664,6 +3664,7 @@ static struct clk_branch gcc_venus0_vcodec0_clk = {
 
 static struct clk_branch gcc_venus0_core0_vcodec0_clk = {
 	.halt_reg = 0x4c02c,
+	.halt_check = BRANCH_HALT_SKIP,
 	.clkr = {
 		.enable_reg = 0x4c02c,
 		.enable_mask = BIT(0),
@@ -3681,6 +3682,7 @@ static struct clk_branch gcc_venus0_core0_vcodec0_clk = {
 
 static struct clk_branch gcc_venus0_core1_vcodec0_clk = {
 	.halt_reg = 0x4c034,
+	.halt_check = BRANCH_HALT_SKIP,
 	.clkr = {
 		.enable_reg = 0x4c034,
 		.enable_mask = BIT(0),
@@ -3753,6 +3755,7 @@ static struct gdsc venus_core0_gdsc = {
 	.pd = {
 		.name = "venus_core0",
 	},
+	.flags = HW_CTRL,
 	.pwrsts = PWRSTS_OFF_ON,
 };
 
@@ -3761,6 +3764,7 @@ static struct gdsc venus_core1_gdsc = {
 	.pd = {
 		.name = "venus_core1",
 	},
+	.flags = HW_CTRL,
 	.pwrsts = PWRSTS_OFF_ON,
 };
 
Signature · 1 line
2.54.0
maintainer
#14 lore raw

Re: [PATCH RFC v3 07/11] clk: qcom: gcc-msm8939: mark Venus core GDSCs as hardware controlled

Quoted 52 lines · Erikas Bitovtas

Since in downstream kernel VENUS_CORE0_GDSC and VENUS_CORE1_GDSC have a device tree property "qcom,supports-hw-trigger", add a HW_CTRL flag to these GDSCs to indicate that they are hardware controlled.

Venus core clock cannot be enabled if Venus core GDSCs are switched off. But since they are hardware controlled, they can be switched off at any moment. Vote for the Venus core clock to enable it later when GDSCs get turned on.

---
  drivers/clk/qcom/gcc-msm8939.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/clk/qcom/gcc-msm8939.c +4 -1
index 45193b3d714b..420997b00ae0 100644
@@ -3664,6 +3664,7 @@ static struct clk_branch gcc_venus0_vcodec0_clk = {
 
  static struct clk_branch gcc_venus0_core0_vcodec0_clk = {
  	.halt_reg = 0x4c02c,
+	.halt_check = BRANCH_HALT_SKIP,
  	.clkr = {
  		.enable_reg = 0x4c02c,
  		.enable_mask = BIT(0),
@@ -3681,6 +3682,7 @@ static struct clk_branch gcc_venus0_core0_vcodec0_clk = {
 
  static struct clk_branch gcc_venus0_core1_vcodec0_clk = {
  	.halt_reg = 0x4c034,
+	.halt_check = BRANCH_HALT_SKIP,
  	.clkr = {
  		.enable_reg = 0x4c034,
  		.enable_mask = BIT(0),
@@ -3753,6 +3755,7 @@ static struct gdsc venus_core0_gdsc = {
  	.pd = {
  		.name = "venus_core0",
  	},
+	.flags = HW_CTRL,
  	.pwrsts = PWRSTS_OFF_ON,
  };
 
@@ -3761,6 +3764,7 @@ static struct gdsc venus_core1_gdsc = {
  	.pd = {
  		.name = "venus_core1",
  	},
+	.flags = HW_CTRL,
  	.pwrsts = PWRSTS_OFF_ON,
  };
 
 
--
Quoted 2 lines

2.54.0

The downstream opts to put the GDSC under hw control, which is not the same thing as it being under hw control, its up to you to put it under hw control.

So you might want to be more conservative especially given you have a problem getting the encoder and decoder to run simultaneously - I might try parking this patch and then see what happens.

---
bod

#15 lore raw

Re: [PATCH RFC v3 07/11] clk: qcom: gcc-msm8939: mark Venus core GDSCs as hardware controlled

Quoted 52 lines · Bryan O'Donoghue
Quoted 51 lines · Erikas Bitovtas

Since in downstream kernel VENUS_CORE0_GDSC and VENUS_CORE1_GDSC have a device tree property "qcom,supports-hw-trigger", add a HW_CTRL flag to these GDSCs to indicate that they are hardware controlled.

Venus core clock cannot be enabled if Venus core GDSCs are switched off. But since they are hardware controlled, they can be switched off at any moment. Vote for the Venus core clock to enable it later when GDSCs get turned on.

---
  drivers/clk/qcom/gcc-msm8939.c | 4 ++++

  1 file changed, 4 insertions(+)
drivers/clk/qcom/gcc-msm8939.c +4 -0
index 45193b3d714b..420997b00ae0 100644
@@ -3664,6 +3664,7 @@ static struct clk_branch gcc_venus0_vcodec0_clk = {
 
   static struct clk_branch gcc_venus0_core0_vcodec0_clk = {
       .halt_reg = 0x4c02c,
+    .halt_check = BRANCH_HALT_SKIP,
       .clkr = {
           .enable_reg = 0x4c02c,
           .enable_mask = BIT(0),
@@ -3681,6 +3682,7 @@ static struct clk_branch gcc_venus0_core0_vcodec0_clk = {
 
   static struct clk_branch gcc_venus0_core1_vcodec0_clk = {
       .halt_reg = 0x4c034,
+    .halt_check = BRANCH_HALT_SKIP,
       .clkr = {
           .enable_reg = 0x4c034,
           .enable_mask = BIT(0),
@@ -3753,6 +3755,7 @@ static struct gdsc venus_core0_gdsc = {
       .pd = {
           .name = "venus_core0",
       },
+    .flags = HW_CTRL,
       .pwrsts = PWRSTS_OFF_ON,
   };
 
@@ -3761,6 +3764,7 @@ static struct gdsc venus_core1_gdsc = {
       .pd = {
           .name = "venus_core1",
       },
+    .flags = HW_CTRL,
       .pwrsts = PWRSTS_OFF_ON,
   };
 
Quoted 7 lines
Quoted 3 lines
Signature · 1 line
2.54.0

The downstream opts to put the GDSC under hw control, which is not the same thing as it being under hw control, its up to you to put it under hw control.

So you might want to be more conservative especially given you have a problem getting the encoder and decoder to run simultaneously - I might try parking this patch and then see what happens.

i.e., Bryan is asking you to replace HW_CTRL with HW_CTRL_TRIGGER

Konrad

#16 lore raw

Re: [PATCH RFC v3 07/11] clk: qcom: gcc-msm8939: mark Venus core GDSCs as hardware controlled

Quoted 59 lines · Konrad Dybcio
Quoted 58 lines · Bryan O'Donoghue
Quoted 54 lines · Erikas Bitovtas

Since in downstream kernel VENUS_CORE0_GDSC and VENUS_CORE1_GDSC have a device tree property "qcom,supports-hw-trigger", add a HW_CTRL flag to these GDSCs to indicate that they are hardware controlled.

Venus core clock cannot be enabled if Venus core GDSCs are switched off. But since they are hardware controlled, they can be switched off at any moment. Vote for the Venus core clock to enable it later when GDSCs get turned on.

---
  drivers/clk/qcom/gcc-msm8939.c | 4 ++++

  1 file changed, 4 insertions(+)
drivers/clk/qcom/gcc-msm8939.c +4 -0
index 45193b3d714b..420997b00ae0 100644
@@ -3664,6 +3664,7 @@ static struct clk_branch gcc_venus0_vcodec0_clk = {
 
   static struct clk_branch gcc_venus0_core0_vcodec0_clk = {
       .halt_reg = 0x4c02c,
+    .halt_check = BRANCH_HALT_SKIP,
       .clkr = {
           .enable_reg = 0x4c02c,
           .enable_mask = BIT(0),
@@ -3681,6 +3682,7 @@ static struct clk_branch gcc_venus0_core0_vcodec0_clk = {
 
   static struct clk_branch gcc_venus0_core1_vcodec0_clk = {
       .halt_reg = 0x4c034,
+    .halt_check = BRANCH_HALT_SKIP,
       .clkr = {
           .enable_reg = 0x4c034,
           .enable_mask = BIT(0),
@@ -3753,6 +3755,7 @@ static struct gdsc venus_core0_gdsc = {
       .pd = {
           .name = "venus_core0",
       },
+    .flags = HW_CTRL,
       .pwrsts = PWRSTS_OFF_ON,
   };
 
@@ -3761,6 +3764,7 @@ static struct gdsc venus_core1_gdsc = {
       .pd = {
           .name = "venus_core1",
       },
+    .flags = HW_CTRL,
       .pwrsts = PWRSTS_OFF_ON,
   };
 
Signature · 2 lines
-- 
2.54.0

The downstream opts to put the GDSC under hw control, which is not the same thing as it being under hw control, its up to you to put it under hw control.

Quoted 4 lines
Quoted 1 line

So you might want to be more conservative especially given you have a problem getting the encoder and decoder to run simultaneously - I might try parking this patch and then see what happens.

i.e., Bryan is asking you to replace HW_CTRL with HW_CTRL_TRIGGER

I tried to revert the patch and replace HW_CTRL with HW_CTRL_TRIGGER - both result in power collapse fails.> Konrad

maintainer
#17 lore raw

Re: [PATCH RFC v3 07/11] clk: qcom: gcc-msm8939: mark Venus core GDSCs as hardware controlled

Quoted 62 lines · Erikas Bitovtas
Quoted 59 lines · Konrad Dybcio
Quoted 58 lines · Bryan O'Donoghue
Quoted 52 lines · Erikas Bitovtas

Since in downstream kernel VENUS_CORE0_GDSC and VENUS_CORE1_GDSC have a device tree property "qcom,supports-hw-trigger", add a HW_CTRL flag to these GDSCs to indicate that they are hardware controlled.

Venus core clock cannot be enabled if Venus core GDSCs are switched off. But since they are hardware controlled, they can be switched off at any moment. Vote for the Venus core clock to enable it later when GDSCs get turned on.

---
   drivers/clk/qcom/gcc-msm8939.c | 4 ++++
   1 file changed, 4 insertions(+)
drivers/clk/qcom/gcc-msm8939.c +4 -1
index 45193b3d714b..420997b00ae0 100644
@@ -3664,6 +3664,7 @@ static struct clk_branch gcc_venus0_vcodec0_clk = {
 
   static struct clk_branch gcc_venus0_core0_vcodec0_clk = {
       .halt_reg = 0x4c02c,
+    .halt_check = BRANCH_HALT_SKIP,
       .clkr = {
           .enable_reg = 0x4c02c,
           .enable_mask = BIT(0),
@@ -3681,6 +3682,7 @@ static struct clk_branch gcc_venus0_core0_vcodec0_clk = {
 
   static struct clk_branch gcc_venus0_core1_vcodec0_clk = {
       .halt_reg = 0x4c034,
+    .halt_check = BRANCH_HALT_SKIP,
       .clkr = {
           .enable_reg = 0x4c034,
           .enable_mask = BIT(0),
@@ -3753,6 +3755,7 @@ static struct gdsc venus_core0_gdsc = {
       .pd = {
           .name = "venus_core0",
       },
+    .flags = HW_CTRL,
       .pwrsts = PWRSTS_OFF_ON,
   };
 
@@ -3761,6 +3764,7 @@ static struct gdsc venus_core1_gdsc = {
       .pd = {
           .name = "venus_core1",
       },
+    .flags = HW_CTRL,
       .pwrsts = PWRSTS_OFF_ON,
   };
 
 
--
Quoted 2 lines

2.54.0

The downstream opts to put the GDSC under hw control, which is not the same thing as it being under hw control, its up to you to put it under hw control.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

So you might want to be more conservative especially given you have a problem getting the encoder and decoder to run simultaneously - I might try parking this patch and then see what happens.

i.e., Bryan is asking you to replace HW_CTRL with HW_CTRL_TRIGGER

I tried to revert the patch and replace HW_CTRL with HW_CTRL_TRIGGER - both result in power collapse fails.> Konrad

I assume you still can't bring either core up as encoder in this case ?

i.e. what we'd like to understand is if perhaps for some reason the GDSC on/off control is the cause of the encoder failure.

I'm OOO at the moment but from memory I think the documentation for 8939 states that it can do the same things 8916 can but with higher resolution - and clocks obviously.

Another core if I remember and something about HVEC.

I'm not sure what it says about HEVC.

Meh - two upstream decoders is better than zero upstream support.

Probably time to transition this series away from RFC..

---
bod

#18 lore raw

RFC PATCH v3 8/11 media: qcom: venus: move getting vdec and venc for later

In reply to Erikas Bitovtas

Call vdec_get() and venc_get() later in the probe so dev_dec and dev_enc are initialized when getting clocks and power domains. This allows us to attach necessary power domains to dev_dec and dev_enc.
This is required for the subsequent patch which adds power domains for HFI v1 and attaches them to dev_dec and dev_enc.

---
 drivers/media/platform/qcom/venus/vdec.c | 12 ++++++------
 drivers/media/platform/qcom/venus/venc.c | 12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/media/platform/qcom/venus/vdec.c +6 -6
index daa8f56610c7..a4aacf5e535b 100644
@@ -1792,12 +1792,6 @@ static int vdec_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, core);
 
-	if (core->pm_ops->vdec_get) {
-		ret = core->pm_ops->vdec_get(dev);
-		if (ret)
-			return ret;
-	}
-
 	vdev = video_device_alloc();
 	if (!vdev)
 		return -ENOMEM;
@@ -1817,6 +1811,12 @@ static int vdec_probe(struct platform_device *pdev)
 	core->vdev_dec = vdev;
 	core->dev_dec = dev;
 
+	if (core->pm_ops->vdec_get) {
+		ret = core->pm_ops->vdec_get(dev);
+		if (ret)
+			return ret;
+	}
+
 	video_set_drvdata(vdev, core);
 	pm_runtime_set_autosuspend_delay(dev, 2000);
 	pm_runtime_use_autosuspend(dev);
drivers/media/platform/qcom/venus/venc.c +6 -6
index bf53267cb68d..5f6844d3d9d0 100644
@@ -1568,12 +1568,6 @@ static int venc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, core);
 
-	if (core->pm_ops->venc_get) {
-		ret = core->pm_ops->venc_get(dev);
-		if (ret)
-			return ret;
-	}
-
 	vdev = video_device_alloc();
 	if (!vdev)
 		return -ENOMEM;
@@ -1593,6 +1587,12 @@ static int venc_probe(struct platform_device *pdev)
 	core->vdev_enc = vdev;
 	core->dev_enc = dev;
 
+	if (core->pm_ops->venc_get) {
+		ret = core->pm_ops->venc_get(dev);
+		if (ret)
+			return ret;
+	}
+
 	video_set_drvdata(vdev, core);
 	pm_runtime_set_autosuspend_delay(dev, 2000);
 	pm_runtime_use_autosuspend(dev);
Signature · 1 line
2.54.0
#19 lore raw

RFC PATCH v3 9/11 media: qcom: venus: Move HFI v3 venc and vdec methods to HFI v1

In reply to Erikas Bitovtas

Some Qualcomm SoCs which come with HFI v1 like MSM8909 and MSM8939 also have dedicated cores for Venus, like in HFI v3. Move methods from HFI v3 to HFI v1 so they can be reused.

---
 drivers/media/platform/qcom/venus/pm_helpers.c | 66 +++++++++++++++++++-------
 1 file changed, 48 insertions(+), 18 deletions(-)
drivers/media/platform/qcom/venus/pm_helpers.c +48 -18
index f0269524ac70..cc21a4762188 100644
@@ -328,10 +328,56 @@ static int core_power_v1(struct venus_core *core, int on)
 	return ret;
 }
 
+static int vdec_get_v1(struct device *dev)
+{
+	struct venus_core *core = dev_get_drvdata(dev);
+
+	return vcodec_clks_get(core, dev, core->vcodec0_clks,
+			       core->res->vcodec0_clks);
+}
+
+static int vdec_power_v1(struct device *dev, int on)
+{
+	struct venus_core *core = dev_get_drvdata(dev);
+	int ret = 0;
+
+	if (on == POWER_ON)
+		ret = vcodec_clks_enable(core, core->vcodec0_clks);
+	else
+		vcodec_clks_disable(core, core->vcodec0_clks);
+
+	return ret;
+}
+
+static int venc_get_v1(struct device *dev)
+{
+	struct venus_core *core = dev_get_drvdata(dev);
+
+	return vcodec_clks_get(core, dev, core->vcodec1_clks,
+			       core->res->vcodec1_clks);
+}
+
+static int venc_power_v1(struct device *dev, int on)
+{
+	struct venus_core *core = dev_get_drvdata(dev);
+	int ret = 0;
+
+	if (on == POWER_ON)
+		ret = vcodec_clks_enable(core, core->vcodec1_clks);
+	else
+		vcodec_clks_disable(core, core->vcodec1_clks);
+
+	return ret;
+}
+
 static const struct venus_pm_ops pm_ops_v1 = {
 	.core_get = core_get_v1,
 	.core_put = core_put_v1,
 	.core_power = core_power_v1,
+	.vdec_get = vdec_get_v1,
+	.vdec_power = vdec_power_v1,
+	.venc_get = venc_get_v1,
+	.venc_power = venc_power_v1,
 	.load_scale = load_scale_v1,
 };
 
@@ -351,14 +397,6 @@ vcodec_control_v3(struct venus_core *core, u32 session_type, bool enable)
 		writel(1, ctrl);
 }
 
-static int vdec_get_v3(struct device *dev)
-{
-	struct venus_core *core = dev_get_drvdata(dev);
-
-	return vcodec_clks_get(core, dev, core->vcodec0_clks,
-			       core->res->vcodec0_clks);
-}
-
 static int vdec_power_v3(struct device *dev, int on)
 {
 	struct venus_core *core = dev_get_drvdata(dev);
@@ -376,14 +414,6 @@ static int vdec_power_v3(struct device *dev, int on)
 	return ret;
 }
 
-static int venc_get_v3(struct device *dev)
-{
-	struct venus_core *core = dev_get_drvdata(dev);
-
-	return vcodec_clks_get(core, dev, core->vcodec1_clks,
-			       core->res->vcodec1_clks);
-}
-
 static int venc_power_v3(struct device *dev, int on)
 {
 	struct venus_core *core = dev_get_drvdata(dev);
@@ -405,9 +435,9 @@ static const struct venus_pm_ops pm_ops_v3 = {
 	.core_get = core_get_v1,
 	.core_put = core_put_v1,
 	.core_power = core_power_v1,
-	.vdec_get = vdec_get_v3,
+	.vdec_get = vdec_get_v1,
 	.vdec_power = vdec_power_v3,
-	.venc_get = venc_get_v3,
+	.venc_get = venc_get_v1,
 	.venc_power = venc_power_v3,
 	.load_scale = load_scale_v1,
 };
Signature · 1 line
2.54.0
#20 lore raw

RFC PATCH v3 10/11 media: qcom: venus: add power domain enable logic for Venus cores

In reply to Erikas Bitovtas

Attach power domains for vdec and venc cores and power them up if a vdec or venc session is started.

---
 drivers/media/platform/qcom/venus/pm_helpers.c | 121 ++++++++++++++++++++++++-
 1 file changed, 119 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/pm_helpers.c +119 -2
index cc21a4762188..41272c194a6d 100644
@@ -246,6 +246,94 @@ static int load_scale_bw(struct venus_core *core)
 	return icc_set_bw(core->video_path, total_avg, total_peak);
 }
 
+static int vcodec_domains_get_v1(struct venus_core *core, struct device *dev,
+				 struct dev_pm_domain_list **pmdomains,
+				 const char **pmdomain_names,
+				 unsigned int pmdomains_num)
+{
+	int ret;
+	struct dev_pm_domain_attach_data vcodec_data = {
+		.pd_names = pmdomain_names,
+		.num_pd_names = pmdomains_num,
+		.pd_flags = PD_FLAG_NO_DEV_LINK,
+	};
+
+	if (!pmdomain_names)
+		return 0;
+
+	ret = devm_pm_domain_attach_list(dev, &vcodec_data, pmdomains);
+	return ret;
+}
+
+static int vdec_domains_attach(struct venus_core *core)
+{
+	struct device *dev = core->dev_dec;
+	const struct venus_resources *res = core->res;
+
+	return vcodec_domains_get_v1(core, dev, &core->vcodec0_pmdomains,
+				     res->vcodec0_pmdomains,
+				     res->vcodec_pmdomains_num);
+}
+
+static int venc_domains_attach(struct venus_core *core)
+{
+	struct device *dev = core->dev_enc;
+	const struct venus_resources *res = core->res;
+
+	return vcodec_domains_get_v1(core, dev, &core->vcodec1_pmdomains,
+				     res->vcodec1_pmdomains,
+				     res->vcodec_pmdomains_num);
+}
+
+static int vcodec_domains_enable_v1(struct venus_core *core,
+				    struct dev_pm_domain_list *pmdomains,
+				    unsigned int pmdomains_num)
+{
+	int i, ret;
+
+	if (!pmdomains)
+		return 0;
+
+	for (i = 0; i < pmdomains_num; i++) {
+		ret = pm_runtime_resume_and_get(pmdomains->pd_devs[i]);
+		if (ret)
+			goto err;
+	}
+
+	return ret;
+
+err:
+	while (i--)
+		pm_runtime_put_sync(pmdomains->pd_devs[i]);
+
+	return ret;
+}
+
+static int vdec_domains_get(struct venus_core *core)
+{
+	const struct venus_resources *res = core->res;
+
+	return vcodec_domains_enable_v1(core, core->vcodec0_pmdomains,
+					res->vcodec_pmdomains_num);
+}
+
+static int venc_domains_get(struct venus_core *core)
+{
+	const struct venus_resources *res = core->res;
+
+	return vcodec_domains_enable_v1(core, core->vcodec1_pmdomains,
+					res->vcodec_pmdomains_num);
+}
+
+static void vcodec_domains_put_v1(struct dev_pm_domain_list *pmdomains,
+				  unsigned int pmdomains_num)
+{
+	unsigned int i = pmdomains_num;
+
+	while (i--)
+		pm_runtime_put_sync(pmdomains->pd_devs[i]);
+}
+
 static int load_scale_v1(struct venus_inst *inst)
 {
 	struct venus_core *core = inst->core;
@@ -331,6 +419,11 @@ static int core_power_v1(struct venus_core *core, int on)
 static int vdec_get_v1(struct device *dev)
 {
 	struct venus_core *core = dev_get_drvdata(dev);
+	int ret;
+
+	ret = vdec_domains_attach(core);
+	if (ret < 0)
+		return ret;
 
 	return vcodec_clks_get(core, dev, core->vcodec0_clks,
 			       core->res->vcodec0_clks);
@@ -339,8 +432,18 @@ static int vdec_get_v1(struct device *dev)
 static int vdec_power_v1(struct device *dev, int on)
 {
 	struct venus_core *core = dev_get_drvdata(dev);
+	const struct venus_resources *res = core->res;
 	int ret = 0;
 
+	if (on == POWER_ON)
+		ret = vdec_domains_get(core);
+	else
+		vcodec_domains_put_v1(core->vcodec0_pmdomains,
+				      res->vcodec_pmdomains_num);
+
+	if (ret)
+		return ret;
+
 	if (on == POWER_ON)
 		ret = vcodec_clks_enable(core, core->vcodec0_clks);
 	else
@@ -352,6 +455,11 @@ static int vdec_power_v1(struct device *dev, int on)
 static int venc_get_v1(struct device *dev)
 {
 	struct venus_core *core = dev_get_drvdata(dev);
+	int ret;
+
+	ret = venc_domains_attach(core);
+	if (ret < 0)
+		return ret;
 
 	return vcodec_clks_get(core, dev, core->vcodec1_clks,
 			       core->res->vcodec1_clks);
@@ -360,8 +468,17 @@ static int venc_get_v1(struct device *dev)
 static int venc_power_v1(struct device *dev, int on)
 {
 	struct venus_core *core = dev_get_drvdata(dev);
+	const struct venus_resources *res = core->res;
 	int ret = 0;
 
+	if (on == POWER_ON)
+		ret = venc_domains_get(core);
+	else
+		vcodec_domains_put_v1(core->vcodec1_pmdomains,
+				      res->vcodec_pmdomains_num);
+	if (ret)
+		return ret;
+
 	if (on == POWER_ON)
 		ret = vcodec_clks_enable(core, core->vcodec1_clks);
 	else
@@ -905,7 +1022,7 @@ static int venc_power_v4(struct device *dev, int on)
 	return ret;
 }
 
-static int vcodec_domains_get(struct venus_core *core)
+static int vcodec_domains_get_v4(struct venus_core *core)
 {
 	int ret;
 	struct device *dev = core->dev;
@@ -1023,7 +1140,7 @@ static int core_get_v4(struct venus_core *core)
 	if (ret)
 		return ret;
 
-	ret = vcodec_domains_get(core);
+	ret = vcodec_domains_get_v4(core);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.54.0
#21 lore raw

RFC PATCH v3 11/11 media: qcom: venus: Enable HEVC decoding for MSM8939

In reply to Erikas Bitovtas

MSM8939 supports HEVC decoding. Do not disable the HEVC codec HFI bit and add it to codec type converter method so it can be recognized.

---
 drivers/media/platform/qcom/venus/core.c       | 2 ++
 drivers/media/platform/qcom/venus/hfi_parser.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/venus/core.c +2 -0
index 5bd3ad21b366..943d498f4e4e 100644
@@ -178,6 +178,8 @@ static void venus_sys_error_handler(struct work_struct *work)
 static u32 to_v4l2_codec_type(u32 codec)
 {
 	switch (codec) {
+	case HFI_VIDEO_CODEC_HEVC:
+		return V4L2_PIX_FMT_HEVC;
 	case HFI_VIDEO_CODEC_H264:
 		return V4L2_PIX_FMT_H264;
 	case HFI_VIDEO_CODEC_H263:
drivers/media/platform/qcom/venus/hfi_parser.c +2 -1
index 92765f9c8873..178274d10c02 100644
@@ -207,7 +207,8 @@ static int parse_codecs(struct venus_core *core, void *data)
 	core->enc_codecs = codecs->enc_codecs;
 
 	if (IS_V1(core)) {
-		core->dec_codecs &= ~HFI_VIDEO_CODEC_HEVC;
+		if (!device_is_compatible(core->dev, "qcom,msm8939-venus"))
+			core->dec_codecs &= ~HFI_VIDEO_CODEC_HEVC;
 		core->dec_codecs &= ~HFI_VIDEO_CODEC_SPARK;
 		core->enc_codecs &= ~HFI_VIDEO_CODEC_HEVC;
 	}
Signature · 1 line
2.54.0