Add Mediatek JPEG Decoder
Subsystems (3)
v3 cover Add Mediatek JPEG Decoder
This series of patches provide a v4l2 driver to control Mediatek JPEG decoder for decoding JPEG image and Motion JPEG bitstream.
changes since v2:
- Revise DT binding documentation
changes since v1:
- Rebase for v4.9-rc1.
- Update Compliance test version and result
- Remove redundant path in Makefile
- Fix potential build error without CONFIG_PM_RUNTIME and CONFIG_PM_SLEEP
- Fix warnings from patch check and smatch check
* Dependency
The patch "arm: dts: mt2701: Add node for JPEG decoder" depends on:
CCF "Add clock support for Mediatek MT2701"[1]
iommu and smi "Add the dtsi node of iommu and smi for mt2701"[2]
[1] http://lists.infradead.org/pipermail/linux-mediatek/2016-October/007271.html
[2] https://patchwork.kernel.org/patch/9164013/
* Compliance test
v4l2-compliance SHA : 4ad7174b908a36c4f315e3fe2efa7e2f8a6f375a
Driver Info:
Driver name : mtk-jpeg decode
Card type : mtk-jpeg decoder
Bus info : platform:15004000.jpegdec Driver version: 4.9.0
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Compliance test for device /dev/video3 (not using libv4l2):
Required ioctls:
test VIDIOC_QUERYCAP: OK
Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK (Not Supported) test VIDIOC_QUERYCTRL: OK (Not Supported)
test VIDIOC_G/S_CTRL: OK (Not Supported)
test VIDIOC_G/S/TRY_EXT_CTRLS: OK (Not Supported) test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK (Not Supported) test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 0 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK
test Scaling: OK
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK
Test input 0:
Total: 43, Succeeded: 43, Failed: 0, Warnings: 0
Rick Chang (3):
dt-bindings: mediatek: Add a binding for Mediatek JPEG Decoder
vcodec: mediatek: Add Mediatek JPEG Decoder Driver
arm: dts: mt2701: Add node for Mediatek JPEG Decoder
.../bindings/media/mediatek-jpeg-codec.txt | 35 + arch/arm/boot/dts/mt2701.dtsi | 14 + drivers/media/platform/Kconfig | 15 + drivers/media/platform/Makefile | 2 + drivers/media/platform/mtk-jpeg/Makefile | 2 + drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 1271 ++++++++++++++++++++ drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h | 141 +++ drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.c | 417 +++++++ drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.h | 91 ++ drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.c | 160 +++ drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.h | 25 + drivers/media/platform/mtk-jpeg/mtk_jpeg_reg.h | 58 + 12 files changed, 2231 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt create mode 100644 drivers/media/platform/mtk-jpeg/Makefile create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.c create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.h create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.c create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.h create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_reg.h
Signature · 1 line
1.9.1
PATCH v3 1/3 dt-bindings: mediatek: Add a binding for Mediatek JPEG Decoder
Add a DT binding documentation for Mediatek JPEG Decoder of MT2701 SoC.
--- .../bindings/media/mediatek-jpeg-codec.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt new file +35 -0
@@ -0,0 +1,35 @@ +* Mediatek JPEG Decoder + +Mediatek JPEG Decoder is the JPEG decode hw present in Mediatek SoCs + +Required properties: +- compatible : "mediatek,mt2701-jpgdec" +- reg : physical base address of the jpeg decoder registers and length of + memory mapped region. +- interrupts : interrupt number to the interrupt controller. +- clocks: device clocks, see + Documentation/devicetree/bindings/clock/clock-bindings.txt for details. +- clock-names: must contain "jpgdec-smi" and "jpgdec". +- power-domains: a phandle to the power domain, see + Documentation/devicetree/bindings/power/power_domain.txt for details. +- mediatek,larb: must contain the local arbiters in the current Socs, see + Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt + for details. +- iommus: should point to the respective IOMMU block with master port as + argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt + for details. + +Example: + jpegdec: jpegdec@15004000 { + compatible = "mediatek,mt2701-jpgdec"; + reg = <0 0x15004000 0 0x1000>; + interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_LOW>; + clocks = <&imgsys CLK_IMG_JPGDEC_SMI>, + <&imgsys CLK_IMG_JPGDEC>; + clock-names = "jpgdec-smi", + "jpgdec"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ISP>; + mediatek,larb = <&larb2>; + iommus = <&iommu MT2701_M4U_PORT_JPGDEC_WDMA>, + <&iommu MT2701_M4U_PORT_JPGDEC_BSDMA>; + };
Signature · 1 line
1.9.1
Re: [PATCH v3 1/3] dt-bindings: mediatek: Add a binding for Mediatek JPEG Decoder
Hi Rick,
Thank you for the patch.
Quoted 2 lines · On Friday 04 Nov 2016 13:51:18 Rick Chang wrote:
Add a DT binding documentation for Mediatek JPEG Decoder of MT2701 SoC.
This version looks much better !
Quoted 15 lines
Signed-off-by Rick Chang <[email protected]>Signed-off-by Minghsiu Tsai <[email protected]>--- .../bindings/media/mediatek-jpeg-codec.txt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt(quoted diff) +0
-0
b/Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txtnew file mode 100644
index 0000000..b2b19ed
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt line 3
Quoted 3 lines
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt new file +3
-0@@ -0,0 +1,35 @@ +* Mediatek JPEG Decoder + +Mediatek JPEG Decoder is the JPEG decode hw present in Mediatek SoCs
Nitpicking, I'd write hardware instead of hw.
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt line 6
Quoted 2 lines
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt new file +2
-0+Required properties: +- compatible : "mediatek,mt2701-jpgdec"
As commented on the previous version, is this JPEG decoder unique to the MT2701, or is it also used (possibly with different interrupts, clocks, ...) in other SoCs ? In the latter case, if the JPEG decoder IP core is identical in multiple SoCs, a more generic compatible string would be better.
Quoted 30 lines
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt new file +10
-0+- reg : physical base address of the jpeg decoder registers and length of + memory mapped region. +- interrupts : interrupt number to the interrupt controller. +- clocks: device clocks, see + Documentation/devicetree/bindings/clock/clock-bindings.txt for details. +- clock-names: must contain "jpgdec-smi" and "jpgdec". +- power-domains: a phandle to the power domain, see + Documentation/devicetree/bindings/power/power_domain.txt for details. +- mediatek,larb: must contain the local arbiters in the current Socs, see +
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txtDocumentation/devicetree/bindings/media/mediatek-jpeg-codec.txt new file +19
-0+ for details. +- iommus: should point to the respective IOMMU block with master port as + argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt + for details. + +Example: + jpegdec: jpegdec@15004000 { + compatible = "mediatek,mt2701-jpgdec"; + reg = <0 0x15004000 0 0x1000>; + interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_LOW>; + clocks = <&imgsys CLK_IMG_JPGDEC_SMI>, + <&imgsys CLK_IMG_JPGDEC>; + clock-names = "jpgdec-smi", + "jpgdec"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ISP>; + mediatek,larb = <&larb2>; + iommus = <&iommu MT2701_M4U_PORT_JPGDEC_WDMA>, + <&iommu MT2701_M4U_PORT_JPGDEC_BSDMA>; + };
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v3 1/3] dt-bindings: mediatek: Add a binding for Mediatek JPEG Decoder
Hi Laurent,
Thanks for your prompt reply. I will fix them in patch v4.
Quoted 9 lines · Laurent Pinchart
Hi Rick,
Thank you for the patch.
Quoted 2 lines · On Friday 04 Nov 2016 13:51:18 Rick Chang wrote:
Add a DT binding documentation for Mediatek JPEG Decoder of MT2701 SoC.
This version looks much better !
I'm glad to hear that!
Quoted 8 lines
Quoted 8 lines
--- .../bindings/media/mediatek-jpeg-codec.txt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt
Quoted 12 lines
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt line 3
Quoted 10 lines
(quoted diff) +0
-0
b/Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txtnew file mode 100644
index 0000000..b2b19edDocumentation/devicetree/bindings/media/mediatek-jpeg-codec.txt new file +3
-0@@ -0,0 +1,35 @@ +* Mediatek JPEG Decoder + +Mediatek JPEG Decoder is the JPEG decode hw present in Mediatek SoCsNitpicking, I'd write hardware instead of hw.
OK.
Quoted 7 lines
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt line 6
Quoted 2 lines
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt new file +2
-0+Required properties: +- compatible : "mediatek,mt2701-jpgdec"As commented on the previous version, is this JPEG decoder unique to the MT2701, or is it also used (possibly with different interrupts, clocks, ...) in other SoCs ? In the latter case, if the JPEG decoder IP core is identical in multiple SoCs, a more generic compatible string would be better.
I understand your question. The essence of this patch series targeting is the JPEG decoder IP which is integrated in mt2701.I will check it with our hardware engineer and making a more generic compatible string if the IP is used in multiple SoCs.
Quoted 31 lines
Quoted 30 lines
Documentation/devicetree/bindings/media/mediatek-jpeg-codec.txt new file +10
-0+- reg : physical base address of the jpeg decoder registers and length of + memory mapped region. +- interrupts : interrupt number to the interrupt controller. +- clocks: device clocks, see + Documentation/devicetree/bindings/clock/clock-bindings.txt for details. +- clock-names: must contain "jpgdec-smi" and "jpgdec". +- power-domains: a phandle to the power domain, see + Documentation/devicetree/bindings/power/power_domain.txt for details. +- mediatek,larb: must contain the local arbiters in the current Socs, see +
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txtDocumentation/devicetree/bindings/media/mediatek-jpeg-codec.txt new file +19
-0+ for details. +- iommus: should point to the respective IOMMU block with master port as + argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt + for details. + +Example: + jpegdec: jpegdec@15004000 { + compatible = "mediatek,mt2701-jpgdec"; + reg = <0 0x15004000 0 0x1000>; + interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_LOW>; + clocks = <&imgsys CLK_IMG_JPGDEC_SMI>, + <&imgsys CLK_IMG_JPGDEC>; + clock-names = "jpgdec-smi", + "jpgdec"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ISP>; + mediatek,larb = <&larb2>; + iommus = <&iommu MT2701_M4U_PORT_JPGDEC_WDMA>, + <&iommu MT2701_M4U_PORT_JPGDEC_BSDMA>; + };
PATCH v3 2/3 vcodec: mediatek: Add Mediatek JPEG Decoder Driver
In reply to Rick ChangAdd v4l2 driver for Mediatek JPEG Decoder
--- drivers/media/platform/Kconfig | 15 + drivers/media/platform/Makefile | 2 + drivers/media/platform/mtk-jpeg/Makefile | 2 + drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 1271 ++++++++++++++++++++++ drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h | 141 +++ drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.c | 417 +++++++ drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.h | 91 ++ drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.c | 160 +++ drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.h | 25 + drivers/media/platform/mtk-jpeg/mtk_jpeg_reg.h | 58 + 10 files changed, 2182 insertions(+) create mode 100644 drivers/media/platform/mtk-jpeg/Makefile create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.c create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.h create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.c create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.h create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_reg.h
drivers/media/platform/Kconfig +15 -0
@@ -162,6 +162,21 @@ config VIDEO_CODA Coda is a range of video codec IPs that supports H.264, MPEG-4, and other video formats. +config VIDEO_MEDIATEK_JPEG + tristate "Mediatek JPEG Codec driver" + depends on MTK_IOMMU_V1 || COMPILE_TEST + depends on VIDEO_DEV && VIDEO_V4L2 + depends on ARCH_MEDIATEK || COMPILE_TEST + depends on HAS_DMA + select VIDEOBUF2_DMA_CONTIG + select V4L2_MEM2MEM_DEV + ---help--- + Mediatek jpeg codec driver provides HW capability to decode + JPEG format + + To compile this driver as a module, choose M here: the + module will be called mtk-jpeg + config VIDEO_MEDIATEK_VPU tristate "Mediatek Video Processor Unit" depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
drivers/media/platform/Makefile +2 -0
@@ -68,3 +68,5 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VPU) += mtk-vpu/ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec/ obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp/ + +obj-$(CONFIG_VIDEO_MEDIATEK_JPEG) += mtk-jpeg/
drivers/media/platform/mtk-jpeg/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +mtk_jpeg-objs := mtk_jpeg_core.o mtk_jpeg_hw.o mtk_jpeg_parse.o +obj-$(CONFIG_VIDEO_MEDIATEK_JPEG) += mtk_jpeg.o
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c new file +1271 -0
1,271 lines not on this page · raw message
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h new file +141 -0
141 lines not on this page · raw message
drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.c new file +417 -0
417 lines not on this page · raw message
drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.h new file +91 -0
91 lines not on this page · raw message
drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.c new file +160 -0
160 lines not on this page · raw message
drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (c) 2016 MediaTek Inc. +* Author: Ming Hsiu Tsai <[email protected]> +* Rick Chang <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef _MTK_JPEG_PARSE_H +#define _MTK_JPEG_PARSE_H + +#include "mtk_jpeg_hw.h" + +bool mtk_jpeg_parse (struct mtk_jpeg_dec_param *param,u8 *src_addr_va, +u32 src_size); + +#endif /* _MTK_JPEG_PARSE_H */ +
drivers/media/platform/mtk-jpeg/mtk_jpeg_reg.h new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v3 3/3 arm: dts: mt2701: Add node for Mediatek JPEG Decoder
In reply to Rick Chang---
This patch depends on:
CCF "Add clock support for Mediatek MT2701"[1]
iommu and smi "Add the dtsi node of iommu and smi for mt2701"[2]
[1] http://lists.infradead.org/pipermail/linux-mediatek/2016-October/007271.html
[2] https://patchwork.kernel.org/patch/9164013/
--- arch/arm/boot/dts/mt2701.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm/boot/dts/mt2701.dtsi +14 -0
@@ -298,6 +298,20 @@ power-domains = <&scpsys MT2701_POWER_DOMAIN_ISP>; }; + jpegdec: jpegdec@15004000 { + compatible = "mediatek,mt2701-jpgdec"; + reg = <0 0x15004000 0 0x1000>; + interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_LOW>; + clocks = <&imgsys CLK_IMG_JPGDEC_SMI>, + <&imgsys CLK_IMG_JPGDEC>; + clock-names = "jpgdec-smi", + "jpgdec"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ISP>; + mediatek,larb = <&larb2>; + iommus = <&iommu MT2701_M4U_PORT_JPGDEC_WDMA>, + <&iommu MT2701_M4U_PORT_JPGDEC_BSDMA>; + }; + vdecsys: syscon@16000000 { compatible = "mediatek,mt2701-vdecsys", "syscon"; reg = <0 0x16000000 0 0x1000>;
Signature · 1 line
1.9.1