Support multi-hardware jpeg decoder for MT8195
Subsystems (4)
v3 cover Support multi-hardware jpeg decoder for MT8195
From: kyrie wu <[email protected]>
This series adds support for multi hardware jpeg decoding, by first adding use of_platform_populate to manage each hardware
information: interrupt, clock, register bases and power. Secondly add decoding work queue to deal with the decoding requests of multi-hardware at the same time. Lastly, add output picture reorder function interface to eliminate the out of order images.
This series has been tested with both MT8195.
Decoding worked for this chip.
Patch 1 Adds jpeg decoder dt-bindings for mt8195
Patches 2 jpeg decoder builds three module for using Multi-HW, export some functions to make them visible by other modules.
Patch 3 use of_platform_populate to manage multi-hardware.
Patch 4 add jpeg decoding timeout function to judge hardware timeout.
Patch 5 add decoding work queue to deal with multi-hardware decoding at the same time.
Patch 6 add output picture reorder function to order images.
Patch 7 refactor jpegdec func interface for HW working.
Patch 8 add stop cmd function to deal with EOS operation.
---
This series patches dependent on:media_stage tree:
[1]
https://git.linuxtv.org/media_stage.git/commit/?id=b3627647f9ea7473d10fb08a95fd7c4133a17ca4
patch1 new jpegdec dt-bindings included files
[2] MM IOMMU binding:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
[3] MT8195 power domain:
https://patchwork.kernel.org/project/linux-mediatek/list/?series=580579
Changes compared with v2:
- add stop cmd function.
- some modifications for patch v1's review comments.
Changes compared with v1:
- new yaml file for mt8195 jpeg decoder.
- some modifications for patch v1's review comments.
kyrie wu (8):
dt-bindings: mediatek: Add mediatek,mt8195-jpgdec compatible
media: mtk-jpegdec: export jpeg decoder functions
media: mtk-jpegdec: manage jpegdec multi-hardware
media: mtk-jpegdec: add jpegdec timeout func interface
media: mtk-jpegdec: add jpeg decode worker interface
media: mtk-jpegdec: add output pic reorder interface
media: mtk-jpegdec: refactor jpegdec func interface
mtk-jpegdec: add stop cmd interface for jpgdec
.../media/mediatek,mt8195-jpegdec.yaml | 175 ++++++++++ drivers/media/platform/mediatek/jpeg/Makefile | 5 +- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 244 +++++++++++++- .../platform/mediatek/jpeg/mtk_jpeg_core.h | 46 +++ .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 309 ++++++++++++++++-- .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.h | 3 +- .../platform/mediatek/jpeg/mtk_jpeg_dec_reg.h | 1 + 7 files changed, 751 insertions(+), 32 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/mediatek,mt8195-jpegdec.yaml
Signature · 1 line
2.18.0
PATCH RESEND v3 1/8 dt-bindings: mediatek: Add mediatek,mt8195-jpgdec compatible
From: kyrie wu <[email protected]>
Add mediatek,mt8195-jpgdec compatible to binding document.
--- .../media/mediatek,mt8195-jpegdec.yaml | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/mediatek,mt8195-jpegdec.yaml
Documentation/devicetree/bindings/media/mediatek,mt8195-jpegdec.yaml new file +175 -0
@@ -0,0 +1,175 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/mediatek,mt8195-jpegdec.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek JPEG Encoder Device Tree Bindings + +maintainers: + - kyrie wu <[email protected]> + +description: |- + MediaTek JPEG Decoder is the JPEG decode hardware present in MediaTek SoCs + +properties: + compatible: + items: + - const: mediatek,mt8195-jpgdec + + mediatek,jpegdec-multi-core: + type: boolean + description: | + Indicates whether the jpeg encoder has multiple cores or not. + + power-domains: + maxItems: 1 + + iommus: + maxItems: 6 + description: | + Points to the respective IOMMU block with master port as argument, see + Documentation/devicetree/bindings/iommu/mediatek,iommu.yaml for details. + Ports are according to the HW. + + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +# Required child node: +patternProperties: + "^jpgdec@[0-9a-f]+$": + type: object + description: | + The jpeg decoder hardware device node which should be added as subnodes to + the main jpeg node. + + properties: + compatible: + const: mediatek,mt8195-jpgdec-hw + + reg: + maxItems: 1 + + hw_id: + description: | + Current jpegdec hw id. + + iommus: + minItems: 1 + maxItems: 32 + description: | + List of the hardware port in respective IOMMU block for current Socs. + Refer to bindings/iommu/mediatek,iommu.yaml. + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: jpgdec + + power-domains: + maxItems: 1 + + required: + - compatible + - reg + - hw_id + - iommus + - interrupts + - clocks + - clock-names + - power-domains + + additionalProperties: false + +required: + - compatible + - power-domains + - iommus + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/memory/mt8195-memory-port.h> + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/clock/mt8195-clk.h> + #include <dt-bindings/power/mt8195-power.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + jpgdec_master { + compatible = "mediatek,mt8195-jpgdec"; + mediatek,jpegdec-multi-core; + power-domains = <&spm MT8195_POWER_DOMAIN_VDEC1>; + iommus = <&iommu_vpp M4U_PORT_L19_JPGDEC_WDMA0>, + <&iommu_vpp M4U_PORT_L19_JPGDEC_BSDMA0>, + <&iommu_vpp M4U_PORT_L19_JPGDEC_WDMA1>, + <&iommu_vpp M4U_PORT_L19_JPGDEC_BSDMA1>, + <&iommu_vpp M4U_PORT_L19_JPGDEC_BUFF_OFFSET1>, + <&iommu_vpp M4U_PORT_L19_JPGDEC_BUFF_OFFSET0>; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + jpgdec@1a040000 { + compatible = "mediatek,mt8195-jpgdec-hw"; + reg = <0 0x1a040000 0 0x10000>;/* JPGDEC_C0 */ + hw_id = <0>; + iommus = <&iommu_vdo M4U_PORT_L19_JPGDEC_WDMA0>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BSDMA0>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_WDMA1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BSDMA1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BUFF_OFFSET1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BUFF_OFFSET0>; + interrupts = <GIC_SPI 343 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&vencsys CLK_VENC_JPGDEC>; + clock-names = "jpgdec"; + power-domains = <&spm MT8195_POWER_DOMAIN_VDEC0>; + }; + + jpgdec@1a050000 { + compatible = "mediatek,mt8195-jpgdec-hw"; + reg = <0 0x1a050000 0 0x10000>;/* JPGDEC_C1 */ + hw_id = <1>; + iommus = <&iommu_vdo M4U_PORT_L19_JPGDEC_WDMA0>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BSDMA0>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_WDMA1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BSDMA1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BUFF_OFFSET1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BUFF_OFFSET0>; + interrupts = <GIC_SPI 344 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&vencsys CLK_VENC_JPGDEC_C1>; + clock-names = "jpgdec"; + power-domains = <&spm MT8195_POWER_DOMAIN_VDEC1>; + }; + + jpgdec@1b040000 { + compatible = "mediatek,mt8195-jpgdec-hw"; + reg = <0 0x1b040000 0 0x10000>;/* JPGDEC_C2 */ + hw_id = <2>; + iommus = <&iommu_vpp M4U_PORT_L20_JPGDEC_WDMA0>, + <&iommu_vpp M4U_PORT_L20_JPGDEC_BSDMA0>, + <&iommu_vpp M4U_PORT_L20_JPGDEC_WDMA1>, + <&iommu_vpp M4U_PORT_L20_JPGDEC_BSDMA1>, + <&iommu_vpp M4U_PORT_L20_JPGDEC_BUFF_OFFSET1>, + <&iommu_vpp M4U_PORT_L20_JPGDEC_BUFF_OFFSET0>; + interrupts = <GIC_SPI 348 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&vencsys_core1 CLK_VENC_CORE1_JPGDEC>; + clock-names = "jpgdec"; + power-domains = <&spm MT8195_POWER_DOMAIN_VDEC2>; + }; + }; + };
Signature · 1 line
2.18.0
Rob Herring
maintainerRe: [RESEND V3,1/8] dt-bindings: mediatek: Add mediatek,mt8195-jpgdec compatible
Quoted 66 lines · Irui Wang
From: kyrie wu <[email protected]>
Add mediatek,mt8195-jpgdec compatible to binding document.
Signed-off-by kyrie wu <[email protected]>--- .../media/mediatek,mt8195-jpegdec.yaml | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/mediatek,mt8195-jpegdec.yamlDocumentation/devicetree/bindings/media/mediatek,mt8195-jpegdec.yaml new file +50
-0@@ -0,0 +1,175 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/mediatek,mt8195-jpegdec.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek JPEG Encoder Device Tree Bindings + +maintainers: + - kyrie wu <[email protected]> + +description: |- + MediaTek JPEG Decoder is the JPEG decode hardware present in MediaTek SoCs + +properties: + compatible: + items: + - const: mediatek,mt8195-jpgdec + + mediatek,jpegdec-multi-core: + type: boolean + description: | + Indicates whether the jpeg encoder has multiple cores or not. + + power-domains: + maxItems: 1 + + iommus: + maxItems: 6 + description: | + Points to the respective IOMMU block with master port as argument, see + Documentation/devicetree/bindings/iommu/mediatek,iommu.yaml for details. + Ports are according to the HW. + + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +# Required child node: +patternProperties: + "^jpgdec@[0-9a-f]+$": + type: object + description: | + The jpeg decoder hardware device node which should be added as subnodes to + the main jpeg node. +
Documentation/devicetree/bindings/media/mediatek,mt8195-jpegdec.yaml line 60
Quoted 10 lines
Documentation/devicetree/bindings/media/mediatek,mt8195-jpegdec.yaml new file +10
-0+ properties: + compatible: + const: mediatek,mt8195-jpgdec-hw + + reg: + maxItems: 1 + + hw_id: + description: | + Current jpegdec hw id.
What's this for and how is it used? We generally don't do indexes in DT.
Quoted 119 lines
Documentation/devicetree/bindings/media/mediatek,mt8195-jpegdec.yaml new file +115
-0+ + iommus: + minItems: 1 + maxItems: 32 + description: | + List of the hardware port in respective IOMMU block for current Socs. + Refer to bindings/iommu/mediatek,iommu.yaml. + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: jpgdec + + power-domains: + maxItems: 1 + + required: + - compatible + - reg + - hw_id + - iommus + - interrupts + - clocks + - clock-names + - power-domains + + additionalProperties: false + +required: + - compatible + - power-domains + - iommus + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/memory/mt8195-memory-port.h> + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/clock/mt8195-clk.h> + #include <dt-bindings/power/mt8195-power.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + jpgdec_master { + compatible = "mediatek,mt8195-jpgdec"; + mediatek,jpegdec-multi-core; + power-domains = <&spm MT8195_POWER_DOMAIN_VDEC1>; + iommus = <&iommu_vpp M4U_PORT_L19_JPGDEC_WDMA0>, + <&iommu_vpp M4U_PORT_L19_JPGDEC_BSDMA0>, + <&iommu_vpp M4U_PORT_L19_JPGDEC_WDMA1>, + <&iommu_vpp M4U_PORT_L19_JPGDEC_BSDMA1>, + <&iommu_vpp M4U_PORT_L19_JPGDEC_BUFF_OFFSET1>, + <&iommu_vpp M4U_PORT_L19_JPGDEC_BUFF_OFFSET0>; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + jpgdec@1a040000 { + compatible = "mediatek,mt8195-jpgdec-hw"; + reg = <0 0x1a040000 0 0x10000>;/* JPGDEC_C0 */ + hw_id = <0>; + iommus = <&iommu_vdo M4U_PORT_L19_JPGDEC_WDMA0>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BSDMA0>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_WDMA1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BSDMA1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BUFF_OFFSET1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BUFF_OFFSET0>; + interrupts = <GIC_SPI 343 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&vencsys CLK_VENC_JPGDEC>; + clock-names = "jpgdec"; + power-domains = <&spm MT8195_POWER_DOMAIN_VDEC0>; + }; + + jpgdec@1a050000 { + compatible = "mediatek,mt8195-jpgdec-hw"; + reg = <0 0x1a050000 0 0x10000>;/* JPGDEC_C1 */ + hw_id = <1>; + iommus = <&iommu_vdo M4U_PORT_L19_JPGDEC_WDMA0>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BSDMA0>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_WDMA1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BSDMA1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BUFF_OFFSET1>, + <&iommu_vdo M4U_PORT_L19_JPGDEC_BUFF_OFFSET0>; + interrupts = <GIC_SPI 344 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&vencsys CLK_VENC_JPGDEC_C1>; + clock-names = "jpgdec"; + power-domains = <&spm MT8195_POWER_DOMAIN_VDEC1>; + }; + + jpgdec@1b040000 { + compatible = "mediatek,mt8195-jpgdec-hw"; + reg = <0 0x1b040000 0 0x10000>;/* JPGDEC_C2 */ + hw_id = <2>; + iommus = <&iommu_vpp M4U_PORT_L20_JPGDEC_WDMA0>, + <&iommu_vpp M4U_PORT_L20_JPGDEC_BSDMA0>, + <&iommu_vpp M4U_PORT_L20_JPGDEC_WDMA1>, + <&iommu_vpp M4U_PORT_L20_JPGDEC_BSDMA1>, + <&iommu_vpp M4U_PORT_L20_JPGDEC_BUFF_OFFSET1>, + <&iommu_vpp M4U_PORT_L20_JPGDEC_BUFF_OFFSET0>; + interrupts = <GIC_SPI 348 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&vencsys_core1 CLK_VENC_CORE1_JPGDEC>; + clock-names = "jpgdec"; + power-domains = <&spm MT8195_POWER_DOMAIN_VDEC2>; + }; + }; + };Signature · 1 line
2.18.0
PATCH RESEND v3 2/8 media: mtk-jpegdec: export jpeg decoder functions
In reply to Irui WangFrom: kyrie wu <[email protected]>
mtk jpeg decoder is built as a module, export some functions to make them visible by other modules.
--- drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +6 -0
@@ -189,6 +189,7 @@ int mtk_jpeg_dec_fill_param(struct mtk_jpeg_dec_param *param)return 0 ; } +EXPORT_SYMBOL_GPL (mtk_jpeg_dec_fill_param);u32 mtk_jpeg_dec_get_int_status (void __iomem *base) {
@@ -200,6 +201,7 @@ u32 mtk_jpeg_dec_get_int_status(void __iomem *base)return ret; } +EXPORT_SYMBOL_GPL (mtk_jpeg_dec_get_int_status);u32 mtk_jpeg_dec_enum_result (u32 irq_result) {
@@ -216,11 +218,13 @@ u32 mtk_jpeg_dec_enum_result(u32 irq_result)return MTK_JPEG_DEC_RESULT_ERROR_UNKNOWN ; } +EXPORT_SYMBOL_GPL (mtk_jpeg_dec_enum_result);void mtk_jpeg_dec_start (void __iomem *base) {writel (0 , base +JPGDEC_REG_TRIG ); } +EXPORT_SYMBOL_GPL (mtk_jpeg_dec_start);static void mtk_jpeg_dec_soft_reset (void __iomem *base) {
@@ -240,6 +244,7 @@ void mtk_jpeg_dec_reset(void __iomem *base)mtk_jpeg_dec_soft_reset (base);mtk_jpeg_dec_hard_reset (base); } +EXPORT_SYMBOL_GPL (mtk_jpeg_dec_reset);static void mtk_jpeg_dec_set_brz_factor (void __iomem *base,u8 yscale_w,u8 yscale_h,u8 uvscale_w,u8 uvscale_h)
@@ -408,3 +413,4 @@ void mtk_jpeg_dec_set_config(void __iomem *base, config->dma_last_mcu);mtk_jpeg_dec_set_pause_mcu_idx (base, config->total_mcu); } +EXPORT_SYMBOL_GPL (mtk_jpeg_dec_set_config);
Signature · 1 line
2.18.0
PATCH RESEND v3 3/8 media: mtk-jpegdec: manage jpegdec multi-hardware
In reply to Irui WangFrom: kyrie wu <[email protected]>
manage each hardware information, including irq/clk/power. the hardware includes HW0/HW1/HW2.
--- drivers/media/platform/mediatek/jpeg/Makefile | 5 +- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 16 ++ .../platform/mediatek/jpeg/mtk_jpeg_core.h | 37 ++++ .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 168 ++++++++++++++++++ 4 files changed, 224 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/jpeg/Makefile +3 -2
@@ -1,9 +1,10 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_VIDEO_MEDIATEK_JPEG) += mtk_jpeg.o \ - mtk-jpeg-enc-hw.o + mtk-jpeg-enc-hw.o \ + mtk-jpeg-dec-hw.o mtk_jpeg-y := mtk_jpeg_core.o \ - mtk_jpeg_dec_hw.o \ mtk_jpeg_dec_parse.o mtk-jpeg-enc-hw-y := mtk_jpeg_enc_hw.o +mtk-jpeg-dec-hw-y := mtk_jpeg_dec_hw.o
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +16 -0
@@ -1700,6 +1700,18 @@ static const struct mtk_jpeg_variant mtk8195_jpegenc_drvdata = { .cap_q_default_fourcc = V4L2_PIX_FMT_JPEG, }; +static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = { + .is_multihw = true, + .formats = mtk_jpeg_dec_formats, + .num_formats =MTK_JPEG_DEC_NUM_FORMATS , + .qops = &mtk_jpeg_dec_qops, + .m2m_ops = &mtk_jpeg_dec_m2m_ops, + .dev_name ="mtk-jpeg-dec" , + .ioctl_ops = &mtk_jpeg_dec_ioctl_ops, + .out_q_default_fourcc =V4L2_PIX_FMT_JPEG , + .cap_q_default_fourcc =V4L2_PIX_FMT_YUV420M , +}; + #if defined(CONFIG_OF) static const struct of_device_id mtk_jpeg_match[] = { {
@@ -1718,6 +1730,10 @@ static const struct of_device_id mtk_jpeg_match[] = { .compatible = "mediatek,mt8195-jpgenc", .data = &mtk8195_jpegenc_drvdata, }, + { + .compatible = "mediatek,mt8195-jpgdec", + .data = &mtk8195_jpegdec_drvdata, + }, {}, };
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +37 -0
@@ -103,6 +103,13 @@ enum mtk_jpegenc_hw_id { MTK_JPEGENC_HW_MAX, }; +enum mtk_jpegdec_hw_id { +MTK_JPEGDEC_HW0 , +MTK_JPEGDEC_HW1 , +MTK_JPEGDEC_HW2 , +MTK_JPEGDEC_HW_MAX , +}; +/** * struct mtk_vcodec_clk - Structure used to store vcodec clock information */
@@ -111,6 +118,14 @@ struct mtk_jpegenc_clk {int clk_num; }; +/** +* struct mtk_vcodec_clk - Structure used to store vcodec clock information +*/ +struct mtk_jpegdec_clk { +struct clk_bulk_data *clks; +int clk_num; +}; +/** * struct mtk_jpegenc_comp_dev - JPEG COREX abstraction * @dev: JPEG device
@@ -141,6 +156,25 @@ struct mtk_jpegenc_comp_dev {spinlock_t hw_lock; }; +/** +* struct mtk_jpegdec_comp_dev - JPEG COREX abstraction +* @dev: JPEG device +* @plat_dev: platform device data +* @reg_base: JPEG registers mapping +* @master_dev: mtk_jpeg_dev device +* @jdec_clk: mtk_jpegdec_clk +* @jpegdec_irq: jpeg decode irq num +*/ +struct mtk_jpegdec_comp_dev { +struct device *dev; +struct platform_device *plat_dev; +void __iomem *reg_base; +struct mtk_jpeg_dev *master_dev; +struct mtk_jpegdec_clk jdec_clk; +int jpegdec_irq; +int hw_id; +}; +/** * struct mtk_jpeg_dev - JPEG IP abstraction * @lock: the mutex protecting this structure
@@ -171,6 +205,9 @@ struct mtk_jpeg_dev {void __iomem *reg_encbase[MTK_JPEGENC_HW_MAX ];struct mtk_jpegenc_comp_dev *enc_hw_dev[MTK_JPEGENC_HW_MAX ];wait_queue_head_t enc_hw_wq; + +void __iomem *reg_decbase[MTK_JPEGDEC_HW_MAX ]; +struct mtk_jpegdec_comp_dev *dec_hw_dev[MTK_JPEGDEC_HW_MAX ]; };/**
drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +168 -0
186 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH RESEND v3 4/8 media: mtk-jpegdec: add jpegdec timeout func interface
In reply to Irui WangFrom: kyrie wu <[email protected]>
Generalizes jpegdec timeout func interfaces to handle HW timeout.
--- .../platform/mediatek/jpeg/mtk_jpeg_core.h | 2 ++ .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +2 -0
@@ -173,6 +173,8 @@ struct mtk_jpegdec_comp_dev {struct mtk_jpegdec_clk jdec_clk;int jpegdec_irq;int hw_id; +struct delayed_work job_timeout_work; +struct mtk_jpeg_hw_param hw_param; };/**
drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +24 -0
@@ -440,6 +440,24 @@ void mtk_jpeg_dec_set_config(void __iomem *base, }EXPORT_SYMBOL_GPL (mtk_jpeg_dec_set_config); +static void mtk_jpegdec_timeout_work (struct work_struct *work) +{ +enum vb2_buffer_state buf_state =VB2_BUF_STATE_ERROR ; +struct mtk_jpegdec_comp_dev *cjpeg = + container_of(work, struct mtk_jpegdec_comp_dev, + job_timeout_work.work); +struct vb2_v4l2_buffer *src_buf, *dst_buf; + + src_buf = cjpeg->hw_param.src_buffer; + dst_buf = cjpeg->hw_param.dst_buffer; + +mtk_jpeg_dec_reset (cjpeg->reg_base); +clk_disable_unprepare (cjpeg->jdec_clk.clks->clk); +pm_runtime_put (cjpeg->dev); +v4l2_m2m_buf_done (src_buf, buf_state); +v4l2_m2m_buf_done (dst_buf, buf_state); +} +static irqreturn_t mtk_jpegdec_hw_irq_handler (int irq,void *priv) {struct vb2_v4l2_buffer *src_buf, *dst_buf;
@@ -453,6 +471,8 @@ static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv)struct mtk_jpegdec_comp_dev *jpeg = priv;struct mtk_jpeg_dev *master_jpeg = jpeg->master_dev; +cancel_delayed_work (&jpeg->job_timeout_work); + irq_status =mtk_jpeg_dec_get_int_status (jpeg->reg_base); dec_irq_ret =mtk_jpeg_dec_enum_result (irq_status);if (dec_irq_ret >=MTK_JPEG_DEC_RESULT_UNDERFLOW )
@@ -533,6 +553,10 @@ static int mtk_jpegdec_hw_probe(struct platform_device *pdev) dev->plat_dev = pdev; dev->dev = &pdev->dev; + +INIT_DELAYED_WORK (&dev->job_timeout_work, + mtk_jpegdec_timeout_work); + jpegdec_clk = &dev->jdec_clk; jpegdec_clk->clk_num = devm_clk_bulk_get_all(&pdev->dev,
Signature · 1 line
2.18.0
PATCH RESEND v3 5/8 media: mtk-jpegdec: add jpeg decode worker interface
In reply to Irui WangFrom: kyrie wu <[email protected]>
Add jpeg decoding worker to ensure that three HWs
run in parallel in MT8195.
--- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 191 ++++++++++++++++++ .../platform/mediatek/jpeg/mtk_jpeg_core.h | 6 + .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 35 ++-- 3 files changed, 220 insertions(+), 12 deletions(-)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +191 -0
@@ -1100,6 +1100,176 @@ static void mtk_jpeg_enc_device_run(void *priv) } } +static int mtk_jpegdec_select_hw (struct mtk_jpeg_ctx *ctx) +{ +struct mtk_jpegdec_comp_dev *comp_jpeg; +struct mtk_jpeg_dev *jpeg = ctx->jpeg; +unsigned long flags; +int hw_id =-1 ; +int i; + +spin_lock_irqsave (&jpeg->hw_lock, flags); +for (i =0 ; i <MTK_JPEGDEC_HW_MAX ; i++) { + comp_jpeg = jpeg->dec_hw_dev[i]; +if (comp_jpeg->hw_state ==MTK_JPEG_HW_IDLE ) { + hw_id = i; + comp_jpeg->hw_state =MTK_JPEG_HW_BUSY ; +break ; + } + } +spin_unlock_irqrestore (&jpeg->hw_lock, flags); + +return hw_id; +} + +static int mtk_jpegdec_deselect_hw (struct mtk_jpeg_dev *jpeg,int hw_id) +{ +unsigned long flags; + +spin_lock_irqsave (&jpeg->hw_lock, flags); + jpeg->dec_hw_dev[hw_id]->hw_state = +MTK_JPEG_HW_IDLE ; +spin_unlock_irqrestore (&jpeg->hw_lock, flags); + +return 0 ; +} + +static int mtk_jpegdec_set_hw_param (struct mtk_jpeg_ctx *ctx, +int hw_id, +struct vb2_v4l2_buffer *src_buf, +struct vb2_v4l2_buffer *dst_buf) +{ +struct mtk_jpegdec_comp_dev *jpeg = + ctx->jpeg->dec_hw_dev[hw_id]; + + jpeg->hw_param.curr_ctx = ctx; + jpeg->hw_param.src_buffer = src_buf; + jpeg->hw_param.dst_buffer = dst_buf; + +return 0 ; +} + +static void mtk_jpegdec_worker (struct work_struct *work) +{ + struct mtk_jpeg_ctx *ctx = container_of(work, struct mtk_jpeg_ctx, + jpeg_work); +struct mtk_jpegdec_comp_dev *comp_jpeg[MTK_JPEGDEC_HW_MAX ]; +enum vb2_buffer_state buf_state =VB2_BUF_STATE_ERROR ; +struct mtk_jpeg_src_buf *jpeg_src_buf, *jpeg_dst_buf; +struct vb2_v4l2_buffer *src_buf, *dst_buf; +struct mtk_jpeg_dev *jpeg = ctx->jpeg; +atomic_t *hw_rdy[MTK_JPEGDEC_HW_MAX ]; +int ret, i, hw_id =0 ; +struct mtk_jpeg_bs bs; +struct mtk_jpeg_fb fb; +unsigned long flags; + +for (i =0 ; i <MTK_JPEGDEC_HW_MAX ; i++) { + comp_jpeg[i] = jpeg->dec_hw_dev[i]; + hw_rdy[i] = &comp_jpeg[i]->hw_rdy; + } + +retry_select: + hw_id =mtk_jpegdec_select_hw (ctx); +if (hw_id <0 ) { + ret =wait_event_interruptible_timeout (jpeg->dec_hw_wq, + (atomic_read (hw_rdy[0 ]) || +atomic_read (hw_rdy[1 ]) || +atomic_read (hw_rdy[2 ])) >0 , +MTK_JPEG_HW_TIMEOUT_MSEC ); +if (ret !=0 ) { +dev_err (jpeg->dev,"%s : %d, all HW are busy\n" , + __func__, __LINE__); +v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); +return ; + } + + goto retry_select; + } + +atomic_dec (&comp_jpeg[hw_id]->hw_rdy); + src_buf =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); +if (!src_buf) + goto getbuf_fail; + + dst_buf =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx); +if (!dst_buf) + goto getbuf_fail; + +v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx); +v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx); + +v4l2_m2m_buf_copy_metadata (src_buf, dst_buf, true); + jpeg_src_buf =mtk_jpeg_vb2_to_srcbuf (&src_buf->vb2_buf); + jpeg_dst_buf =mtk_jpeg_vb2_to_srcbuf (&dst_buf->vb2_buf); + +if (mtk_jpeg_check_resolution_change (ctx, + &jpeg_src_buf->dec_param)) { +mtk_jpeg_queue_src_chg_event (ctx); + ctx->state =MTK_JPEG_SOURCE_CHANGE ; + goto dec_end; + } + + jpeg_src_buf->curr_ctx = ctx; + jpeg_src_buf->frame_num = ctx->total_frame_num; + jpeg_dst_buf->curr_ctx = ctx; + jpeg_dst_buf->frame_num = ctx->total_frame_num; + ctx->total_frame_num++; + +mtk_jpegdec_set_hw_param (ctx, hw_id, src_buf, dst_buf); + ret =pm_runtime_get_sync (comp_jpeg[hw_id]->dev); +if (ret <0 ) { +dev_err (jpeg->dev,"%s : %d, pm_runtime_get_sync fail !!!\n" , + __func__, __LINE__); + goto dec_end; + } + + ret =clk_prepare_enable (comp_jpeg[hw_id]->jdec_clk.clks->clk); +if (ret) { +dev_err (jpeg->dev,"%s : %d, jpegdec clk_prepare_enable fail\n" , + __func__, __LINE__); + goto clk_end; + } + +schedule_delayed_work (&comp_jpeg[hw_id]->job_timeout_work, +msecs_to_jiffies (MTK_JPEG_HW_TIMEOUT_MSEC )); + +mtk_jpeg_set_dec_src (ctx, &src_buf->vb2_buf, &bs); +if (mtk_jpeg_set_dec_dst (ctx, + &jpeg_src_buf->dec_param, + &dst_buf->vb2_buf, &fb)) { +dev_err (jpeg->dev,"%s : %d, mtk_jpeg_set_dec_dst fail\n" , + __func__, __LINE__); + goto setdst_end; + } + +spin_lock_irqsave (&comp_jpeg[hw_id]->hw_lock, flags); +mtk_jpeg_dec_reset (comp_jpeg[hw_id]->reg_base); +mtk_jpeg_dec_set_config (jpeg->reg_base, + &jpeg_src_buf->dec_param, + &bs, + &fb); +mtk_jpeg_dec_start (comp_jpeg[hw_id]->reg_base); +v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); +spin_unlock_irqrestore (&comp_jpeg[hw_id]->hw_lock, flags); + +return ; + +setdst_end: +clk_disable_unprepare (comp_jpeg[hw_id]->jdec_clk.clks->clk); +clk_end: +pm_runtime_put (comp_jpeg[hw_id]->dev); +dec_end: +v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx); +v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx); +v4l2_m2m_buf_done (src_buf, buf_state); +v4l2_m2m_buf_done (dst_buf, buf_state); +getbuf_fail: +atomic_inc (&comp_jpeg[hw_id]->hw_rdy); +mtk_jpegdec_deselect_hw (jpeg, hw_id); +v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); +} +static void mtk_jpeg_dec_device_run (void *priv) {struct mtk_jpeg_ctx *ctx = priv;
@@ -1112,6 +1282,7 @@ static void mtk_jpeg_dec_device_run(void *priv)struct mtk_jpeg_fb fb;int ret; +if (!jpeg->variant->is_multihw) { src_buf =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx); dst_buf =v4l2_m2m_next_dst_buf (ctx->fh.m2m_ctx); jpeg_src_buf =mtk_jpeg_vb2_to_srcbuf (&src_buf->vb2_buf);
@@ -1149,6 +1320,9 @@ static void mtk_jpeg_dec_device_run(void *priv)v4l2_m2m_buf_done (src_buf, buf_state);v4l2_m2m_buf_done (dst_buf, buf_state);v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); +}else { +queue_work (jpeg->workqueue, &ctx->jpeg_work); +} }static int mtk_jpeg_dec_job_ready (void *priv)
@@ -1367,6 +1541,11 @@ static int mtk_jpeg_open(struct file *file) "mediatek,jpegenc-multi-core")) {INIT_WORK (&ctx->jpeg_work, mtk_jpegenc_worker); } + +if (of_property_read_bool (jpeg->dev->of_node, +"mediatek,jpegdec-multi-core" )) { +INIT_WORK (&ctx->jpeg_work, mtk_jpegdec_worker); + } }INIT_LIST_HEAD (&ctx->dst_done_queue);
@@ -1518,6 +1697,18 @@ static int mtk_jpeg_probe(struct platform_device *pdev) goto err_alloc_workqueue; } } + +if (of_property_read_bool (pdev->dev.of_node, +"mediatek,jpegdec-multi-core" )) { +init_waitqueue_head (&jpeg->dec_hw_wq); + jpeg->workqueue =alloc_ordered_workqueue (MTK_JPEG_NAME , +WQ_MEM_RECLAIM + |WQ_FREEZABLE ); +if (!jpeg->workqueue) { + ret = -EINVAL ; + goto err_alloc_workqueue; + } + } } ret =v4l2_device_register (&pdev->dev, &jpeg->v4l2_dev);
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +6 -0
@@ -175,6 +175,10 @@ struct mtk_jpegdec_comp_dev {int hw_id;struct delayed_work job_timeout_work;struct mtk_jpeg_hw_param hw_param; +atomic_t hw_rdy; +enum mtk_jpeg_hw_state hw_state; +//spinlock protecting the hw device resource +spinlock_t hw_lock; };/**
@@ -210,6 +214,8 @@ struct mtk_jpeg_dev {void __iomem *reg_decbase[MTK_JPEGDEC_HW_MAX ];struct mtk_jpegdec_comp_dev *dec_hw_dev[MTK_JPEGDEC_HW_MAX ]; +wait_queue_head_t dec_hw_wq; +struct workqueue_struct *dec_workqueue; };/**
drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +23 -12
@@ -446,14 +446,19 @@ static void mtk_jpegdec_timeout_work(struct work_struct *work)struct mtk_jpegdec_comp_dev *cjpeg = container_of(work, struct mtk_jpegdec_comp_dev, job_timeout_work.work); +struct mtk_jpeg_dev *master_jpeg = cjpeg->master_dev;struct vb2_v4l2_buffer *src_buf, *dst_buf; src_buf = cjpeg->hw_param.src_buffer; dst_buf = cjpeg->hw_param.dst_buffer; + dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;mtk_jpeg_dec_reset (cjpeg->reg_base);clk_disable_unprepare (cjpeg->jdec_clk.clks->clk);pm_runtime_put (cjpeg->dev); + cjpeg->hw_state =MTK_JPEG_HW_IDLE ; +atomic_inc (&cjpeg->hw_rdy); +wake_up (&master_jpeg->dec_hw_wq);v4l2_m2m_buf_done (src_buf, buf_state);v4l2_m2m_buf_done (dst_buf, buf_state); }
@@ -473,22 +478,20 @@ static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv)cancel_delayed_work (&jpeg->job_timeout_work); + ctx = jpeg->hw_param.curr_ctx; + src_buf = jpeg->hw_param.src_buffer; + dst_buf = jpeg->hw_param.dst_buffer; + dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp; + irq_status =mtk_jpeg_dec_get_int_status (jpeg->reg_base); dec_irq_ret =mtk_jpeg_dec_enum_result (irq_status);if (dec_irq_ret >=MTK_JPEG_DEC_RESULT_UNDERFLOW )mtk_jpeg_dec_reset (jpeg->reg_base); -if (dec_irq_ret !=MTK_JPEG_DEC_RESULT_EOF_DONE ) -return IRQ_NONE ; - - ctx =v4l2_m2m_get_curr_priv (master_jpeg->m2m_dev); -if (!ctx) { -dev_err (jpeg->dev,"Context is NULL\n" ); -return IRQ_HANDLED ; +if (dec_irq_ret !=MTK_JPEG_DEC_RESULT_EOF_DONE ) { +dev_err (jpeg->dev," Not MTK_JPEG_DEC_RESULT_EOF_DONE\n" ); + goto irq_handled; } - src_buf =v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx); - dst_buf =v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx); - dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp; jpeg_src_buf = container_of(src_buf, struct mtk_jpeg_src_buf, b);
@@ -496,12 +499,16 @@ static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv)vb2_set_plane_payload (&dst_buf->vb2_buf, i, jpeg_src_buf->dec_param.comp_size[i]); +irq_handled: buf_state =VB2_BUF_STATE_DONE ; -v4l2_m2m_buf_done (src_buf, buf_state);v4l2_m2m_buf_done (dst_buf, buf_state); -v4l2_m2m_job_finish (master_jpeg->m2m_dev, ctx->fh.m2m_ctx);pm_runtime_put (ctx->jpeg->dev); +clk_disable_unprepare (jpeg->jdec_clk.clks->clk); + + jpeg->hw_state =MTK_JPEG_HW_IDLE ; +wake_up (&master_jpeg->dec_hw_wq); +atomic_inc (&jpeg->hw_rdy);return IRQ_HANDLED ; }
@@ -554,6 +561,10 @@ static int mtk_jpegdec_hw_probe(struct platform_device *pdev) dev->plat_dev = pdev; dev->dev = &pdev->dev; +atomic_set (&dev->hw_rdy,1U ); +spin_lock_init (&dev->hw_lock); + dev->hw_state =MTK_JPEG_HW_IDLE ; +INIT_DELAYED_WORK (&dev->job_timeout_work, mtk_jpegdec_timeout_work);
Signature · 1 line
2.18.0
PATCH RESEND v3 6/8 media: mtk-jpegdec: add output pic reorder interface
In reply to Irui WangFrom: kyrie wu <[email protected]>
add output reorder func to reorder the output images to ensure the output pic is consistent with the input images.
--- .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +47 -2
@@ -440,6 +440,51 @@ void mtk_jpeg_dec_set_config(void __iomem *base, }EXPORT_SYMBOL_GPL (mtk_jpeg_dec_set_config); +static void mtk_jpegdec_put_buf (struct mtk_jpegdec_comp_dev *jpeg) +{ +struct mtk_jpeg_src_buf *dst_done_buf, *tmp_dst_done_buf; +struct vb2_v4l2_buffer *dst_buffer; +struct list_head *temp_entry; +struct list_head *pos =NULL ; +struct mtk_jpeg_ctx *ctx; +unsigned long flags; + + ctx = jpeg->hw_param.curr_ctx; +if (unlikely (!ctx)) { +dev_err (jpeg->dev,"comp_jpeg ctx fail !!!\n" ); +return ; + } + + dst_buffer = jpeg->hw_param.dst_buffer; +if (!dst_buffer) { +dev_err (jpeg->dev,"comp_jpeg dst_buffer fail !!!\n" ); +return ; + } + + dst_done_buf = container_of(dst_buffer, struct mtk_jpeg_src_buf, b); + +spin_lock_irqsave (&ctx->done_queue_lock, flags); +list_add_tail (&dst_done_buf->list, &ctx->dst_done_queue); +while (!list_empty (&ctx->dst_done_queue) && + (pos != &ctx->dst_done_queue)) { +list_for_each_prev_safe (pos, + temp_entry, + (&ctx->dst_done_queue)) { + tmp_dst_done_buf =list_entry (pos, + struct mtk_jpeg_src_buf, + list); +if (tmp_dst_done_buf->frame_num == + ctx->last_done_frame_num) { +list_del (&tmp_dst_done_buf->list); +v4l2_m2m_buf_done (&tmp_dst_done_buf->b, +VB2_BUF_STATE_DONE ); + ctx->last_done_frame_num++; + } + } + } +spin_unlock_irqrestore (&ctx->done_queue_lock, flags); +} +static void mtk_jpegdec_timeout_work (struct work_struct *work) {enum vb2_buffer_state buf_state =VB2_BUF_STATE_ERROR ;
@@ -460,7 +505,7 @@ static void mtk_jpegdec_timeout_work(struct work_struct *work)atomic_inc (&cjpeg->hw_rdy);wake_up (&master_jpeg->dec_hw_wq);v4l2_m2m_buf_done (src_buf, buf_state); -v4l2_m2m_buf_done (dst_buf, buf_state); +mtk_jpegdec_put_buf (cjpeg); }static irqreturn_t mtk_jpegdec_hw_irq_handler (int irq,void *priv)
@@ -502,7 +547,7 @@ static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv) irq_handled: buf_state =VB2_BUF_STATE_DONE ;v4l2_m2m_buf_done (src_buf, buf_state); -v4l2_m2m_buf_done (dst_buf, buf_state); +mtk_jpegdec_put_buf (jpeg);pm_runtime_put (ctx->jpeg->dev);clk_disable_unprepare (jpeg->jdec_clk.clks->clk);
Signature · 1 line
2.18.0
PATCH RESEND v3 7/8 media: mtk-jpegdec: refactor jpegdec func interface
In reply to Irui WangFrom: kyrie wu <[email protected]>
refactor the func interface of mtk_jpeg_dec_set_config for decode
--- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 38 +++++++++++-- .../platform/mediatek/jpeg/mtk_jpeg_core.h | 1 + .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 55 ++++++++++--------- .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.h | 3 +- .../platform/mediatek/jpeg/mtk_jpeg_dec_reg.h | 1 + 5 files changed, 66 insertions(+), 32 deletions(-)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +33 -5
@@ -587,6 +587,31 @@ static int mtk_jpeg_enc_s_selection(struct file *file, void *priv,return 0 ; } +static int mtk_jpeg_qbuf (struct file *file,void *priv,struct v4l2_buffer *buf) +{ +struct v4l2_fh *fh = file->private_data; +struct mtk_jpeg_ctx *ctx =mtk_jpeg_fh_to_ctx (priv); +struct vb2_queue *vq; +struct vb2_buffer *vb; +struct mtk_jpeg_src_buf *jpeg_src_buf; + +if (buf->type !=V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) + goto end; + + vq =v4l2_m2m_get_vq (fh->m2m_ctx, buf->type); +if (buf->index >= vq->num_buffers) { +dev_err (ctx->jpeg->dev,"buffer index out of range\n" ); +return -EINVAL ; + } + + vb = vq->bufs[buf->index]; + jpeg_src_buf =mtk_jpeg_vb2_to_srcbuf (vb); + jpeg_src_buf->bs_size = buf->m.planes[0 ].bytesused; + +end: +return v4l2_m2m_qbuf (file, fh->m2m_ctx, buf); +} +static const struct v4l2_ioctl_ops mtk_jpeg_enc_ioctl_ops = { .vidioc_querycap = mtk_jpeg_querycap, .vidioc_enum_fmt_vid_cap = mtk_jpeg_enum_fmt_vid_cap,
@@ -627,7 +652,7 @@ static const struct v4l2_ioctl_ops mtk_jpeg_dec_ioctl_ops = { .vidioc_g_fmt_vid_out_mplane = mtk_jpeg_g_fmt_vid_mplane, .vidioc_s_fmt_vid_cap_mplane = mtk_jpeg_s_fmt_vid_cap_mplane, .vidioc_s_fmt_vid_out_mplane = mtk_jpeg_s_fmt_vid_out_mplane, - .vidioc_qbuf = v4l2_m2m_ioctl_qbuf, + .vidioc_qbuf = mtk_jpeg_qbuf, .vidioc_subscribe_event = mtk_jpeg_subscribe_event, .vidioc_g_selection = mtk_jpeg_dec_g_selection,
@@ -1214,7 +1239,6 @@ static void mtk_jpegdec_worker(struct work_struct *work) jpeg_src_buf->frame_num = ctx->total_frame_num; jpeg_dst_buf->curr_ctx = ctx; jpeg_dst_buf->frame_num = ctx->total_frame_num; - ctx->total_frame_num++;mtk_jpegdec_set_hw_param (ctx, hw_id, src_buf, dst_buf); ret =pm_runtime_get_sync (comp_jpeg[hw_id]->dev);
@@ -1244,9 +1268,11 @@ static void mtk_jpegdec_worker(struct work_struct *work) }spin_lock_irqsave (&comp_jpeg[hw_id]->hw_lock, flags); + ctx->total_frame_num++;mtk_jpeg_dec_reset (comp_jpeg[hw_id]->reg_base); -mtk_jpeg_dec_set_config (jpeg->reg_base, +mtk_jpeg_dec_set_config (comp_jpeg[hw_id]->reg_base, &jpeg_src_buf->dec_param, + jpeg_src_buf->bs_size, &bs, &fb);mtk_jpeg_dec_start (comp_jpeg[hw_id]->reg_base);
@@ -1308,8 +1334,10 @@ if (!jpeg->variant->is_multihw) {spin_lock_irqsave (&jpeg->hw_lock, flags);mtk_jpeg_dec_reset (jpeg->reg_base);mtk_jpeg_dec_set_config (jpeg->reg_base, - &jpeg_src_buf->dec_param, &bs, &fb); - + &jpeg_src_buf->dec_param, + jpeg_src_buf->bs_size, + &bs, + &fb);mtk_jpeg_dec_start (jpeg->reg_base);spin_unlock_irqrestore (&jpeg->hw_lock, flags);return ;
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +1 -0
@@ -81,6 +81,7 @@ struct mtk_jpeg_src_buf {u32 frame_num;struct vb2_v4l2_buffer b;struct list_head list; +u32 bs_size;struct mtk_jpeg_dec_param dec_param;struct mtk_jpeg_ctx *curr_ctx;
drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +29 -26
80 lines not on this page · raw message
drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.h +2 -1
@@ -71,7 +71,8 @@ int mtk_jpeg_dec_fill_param(struct mtk_jpeg_dec_param *param);u32 mtk_jpeg_dec_get_int_status (void __iomem *dec_reg_base);u32 mtk_jpeg_dec_enum_result (u32 irq_result);void mtk_jpeg_dec_set_config (void __iomem *base, -struct mtk_jpeg_dec_param *config, +struct mtk_jpeg_dec_param *cfg, +u32 bitstream_size,struct mtk_jpeg_bs *bs,struct mtk_jpeg_fb *fb);void mtk_jpeg_dec_reset (void __iomem *dec_reg_base);
drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_reg.h +1 -0
@@ -45,5 +45,6 @@#define JPGDEC_REG_QT_ID 0x0270#define JPGDEC_REG_INTERRUPT_STATUS 0x0274#define JPGDEC_REG_STATUS 0x0278 +#define JPGDEC_REG_BIT_STREAM_SIZE 0x0344#endif /* _MTK_JPEG_REG_H */
Signature · 1 line
2.18.0
PATCH RESEND v3 8/8 mtk-jpegdec: add stop cmd interface for jpgdec
In reply to Irui WangFrom: kyrie wu <[email protected]>
Add stop cmd interface for jpgdec to stop stream
--- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +3 -0
@@ -666,6 +666,9 @@ static const struct v4l2_ioctl_ops mtk_jpeg_dec_ioctl_ops = { .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, + + .vidioc_decoder_cmd = v4l2_m2m_ioctl_decoder_cmd, + .vidioc_try_decoder_cmd = v4l2_m2m_ioctl_try_decoder_cmd, }; static int mtk_jpeg_queue_setup(struct vb2_queue *q,
Signature · 1 line
2.18.0
Why resend this series and the v9 series?
There is generally no reason to do so. If you want to remind people that something has to be reviewed, then just reply to the cover letter asking for that.
A resend is only needed if the original series didn't make it to
https://patchwork.linuxtv.org/ for some reason.
Regards,
Hans
Quoted 71 lines · Irui Wang
From: kyrie wu <[email protected]>
This series adds support for multi hardware jpeg decoding, by first adding use
of_platform_populateto manage each hardware
information: interrupt, clock, register bases and power. Secondly add decoding work queue to deal with the decoding requests of multi-hardware at the same time. Lastly, add output picture reorder function interface to eliminate the out of order images.This series has been tested with both MT8195.
Decoding worked for this chip.Patch 1 Adds jpeg decoder dt-bindings for mt8195
Patches 2 jpeg decoder builds three module for using Multi-HW, export some functions to make them visible by other modules.
Patch 3 use
of_platform_populateto manage multi-hardware.Patch 4 add jpeg decoding timeout function to judge hardware timeout.
Patch 5 add decoding work queue to deal with multi-hardware decoding at the same time.
Patch 6 add output picture reorder function to order images.
Patch 7 refactor jpegdec func interface for HW working.
Patch 8 add stop cmd function to deal with EOS operation.
---
This series patches dependent on:media_stagetree:
[1]
https://git.linuxtv.org/media_stage.git/commit/?id=b3627647f9ea7473d10fb08a95fd7c4133a17ca4patch1 new jpegdec dt-bindings included files
[2] MM IOMMU binding:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/[3] MT8195 power domain:
https://patchwork.kernel.org/project/linux-mediatek/list/?series=580579Changes compared with v2:
- add stop cmd function.
- some modifications for patch v1's review comments.Changes compared with v1:
- new yaml file for mt8195 jpeg decoder.
- some modifications for patch v1's review comments.kyrie wu (8):
dt-bindings: mediatek: Add mediatek,mt8195-jpgdec compatible
media: mtk-jpegdec: export jpeg decoder functions
media: mtk-jpegdec: manage jpegdec multi-hardware
media: mtk-jpegdec: add jpegdec timeout func interface
media: mtk-jpegdec: add jpeg decode worker interface
media: mtk-jpegdec: add output pic reorder interface
media: mtk-jpegdec: refactor jpegdec func interface
mtk-jpegdec: add stop cmd interface for jpgdec.../media/mediatek,mt8195-jpegdec.yaml | 175 ++++++++++ drivers/media/platform/mediatek/jpeg/Makefile | 5 +- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 244 +++++++++++++- .../platform/mediatek/jpeg/mtk_jpeg_core.h | 46 +++ .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 309 ++++++++++++++++-- .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.h | 3 +- .../platform/mediatek/jpeg/mtk_jpeg_dec_reg.h | 1 + 7 files changed, 751 insertions(+), 32 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/mediatek,mt8195-jpegdec.yaml