From patchwork Tue Sep 11 15:09:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Jourdan X-Patchwork-Id: 10595807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F3CA14F9 for ; Tue, 11 Sep 2018 15:10:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4558F297AA for ; Tue, 11 Sep 2018 15:10:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 437C8297E6; Tue, 11 Sep 2018 15:10:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96637297AA for ; Tue, 11 Sep 2018 15:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=9JklN8sW8kpvjAIUwUOcQL1lHHbUHxhhVEyz1gHgXFM=; b=qV+ uwFKslwZ6/dEvIfZddolKWI5YqrP7kJ4VAwq/tbtSoV2jmEjni1n6IkPtDzufwn/rl2iNuPzVDA7r Dfmie+e/8vgt4uiuVaszpJtXiKIQanu0mmMt0Nt1hYCc9qOhMFRALyiYzIyfoAtGSej7Bb2jzWoh0 awVx5oFZlIrnlfPId0do7BQjNiyW7Q/b+L/F9PTMbqpCA1d+KeLqxUIeVgXSmoJxtaYo0bynu1r/E 1fV1XI9pLTxzXc9ysKUNDhzXJtQSZRTtY9HR0T0lCpnyu682hpgCfLpkyskApY5qOiDWktqgl1G5n w3HlzIx+Vsx9WbKd+NKUW2VzM6R/krg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fzkIo-0003KW-Ab; Tue, 11 Sep 2018 15:10:06 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fzkIj-00036w-40 for linux-amlogic@lists.infradead.org; Tue, 11 Sep 2018 15:10:04 +0000 Received: by mail-wr1-x444.google.com with SMTP id j26-v6so26472185wre.2 for ; Tue, 11 Sep 2018 08:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=JKs3NDGL8iqqz0I+G9xiz+dNNdbLmBVlO1jvFs8hl5w=; b=HD+aw0VqekEPaBsx5ql88mC2qXrO2h5iliQevNSXUlmTtWilonAlM8Uyn+ouqI6y7S YoQ0uB62egbd+wjzs2/DqBzi2PFrEJtnlPiujJWSN8F9XwGMMhNy6V6vLxtyx1jPxTzH 7d1t2Hu/nEKS8xzUWjW0ehRLuo0tSMsX7yQXimrOga6rvqXJfNDHN9VQlmkd+FOzk7rM daNPFgN2IbD9FaF8Zd/df6tIecJpXn5RidjaNnO0YESft/3ue1CVDhusiX55pg8e0+EW Pc9nBo04f4ikK6guV7hILacN+f1oWeTA38Gg4mFIwjwYtW02Zm9DkMgK5nY1GA9lcmRO dmgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JKs3NDGL8iqqz0I+G9xiz+dNNdbLmBVlO1jvFs8hl5w=; b=kEjxiYKDoWVDOVslMK9t70e+yf1iXf9RMX9grytJ2Kd86fqYQRQi9lc/WlAuWBphNw zpphu54Oc5TZIAkz3wEjxgOUmUERE+yCSnuD369BbKHBa/H0gcnGMI6yG1Tf9DcDwwCO d65MzusUszhYI4lJdXF8x+pph+Vq9cH1BK4fNr54ArOfxy5r4f9VmZRXMyEjgTzspQm3 Z0+Q1Am4qrvwi4Z5mUqxJY3IOGO7Nik3sTmjDKeiWQHvM4gMx8WIkrZVEAdPBMzPVg8L t8Rr948FjlWdpCAZYEt0S2EuWzH2CCDsXlF+uT9zuopEdHnIDqFTe2bMAdR3xM2ksjo9 62ww== X-Gm-Message-State: APzg51BcvbOczbvEgTvhqbu4GE+qWBipIWCmmwL4PxE4ZKkBAqYVf7RL hEiU6t2AjvaXn2uCsEvJcZTKIA== X-Google-Smtp-Source: ANB0VdbVsTAT+K5nYzHuTfB4Ag+xFssgPOiGF7okEirlU+MCRM6rURQynM8nWSTH8LFfU6TiJkD6yw== X-Received: by 2002:a5d:4e8b:: with SMTP id e11-v6mr20347269wru.32.1536678588823; Tue, 11 Sep 2018 08:09:48 -0700 (PDT) Received: from localhost.localdomain (81-67-76-113.rev.numericable.fr. [81.67.76.113]) by smtp.gmail.com with ESMTPSA id x65-v6sm618625wmg.39.2018.09.11.08.09.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 08:09:47 -0700 (PDT) From: Maxime Jourdan To: Mauro Carvalho Chehab Subject: [PATCH v2 0/3] Add Amlogic video decoder driver Date: Tue, 11 Sep 2018 17:09:35 +0200 Message-Id: <20180911150938.3844-1-mjourdan@baylibre.com> X-Mailer: git-send-email 2.18.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180911_081001_196742_5C51E361 X-CRM114-Status: GOOD ( 14.42 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Jourdan , devicetree@vger.kernel.org, Neil Armstrong , Martin Blumenstingl , Kevin Hilman , linux-kernel@vger.kernel.org, Hans Verkuil , linux-amlogic@lists.infradead.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi everyone, This patch series adds support for the Amlogic video decoder, as well as the corresponding dt bindings for GXBB/GXL/GXM chips. It features decoding for the following formats: - MPEG 1 - MPEG 2 The following formats will be added in future patches: - MJPEG - MPEG 4 (incl. Xvid, H.263) - H.264 - HEVC (incl. 10-bit) The following formats' development has still not started, but they are supported by the hardware: - VC1 - VP9 The code was made in such a way to allow easy inclusion of those formats in the future. The decoder is single instance. Files: - vdec.c handles the V4L2 M2M logic - esparser.c manages the hardware bitstream parser - vdec_helpers.c provides helpers to DONE the dst buffers as well as various common code used by the codecs - vdec_1.c manages the VDEC_1 block of the vdec IP - codec_mpeg12.c enables decoding for MPEG 1/2. - vdec_platform.c links codec units with vdec units (e.g vdec_1 with codec_mpeg12) and lists all the available src/dst formats and requirements (max width/height, etc.), per compatible chip. Firmwares are necessary to run the vdec. They can currently be found at: https://github.com/chewitt/meson-firmware It was tested primarily with ffmpeg's v4l2-m2m implementation. For instance: $ ffmpeg -c:v mpeg2_v4l2m2m -i sample_mpeg2.mkv -f null - Note: This patch series depends on "[PATCH v3 0/3] soc: amlogic: add meson-canvas" https://patchwork.kernel.org/cover/10573763/ The v4l2-compliance results are available below the patch diff. Changes since v1 [0]: - use named interrupts in the bindings - rewrite description in the bindings doc - don't include the dts changes in the patch series - fill the vb2 queues locks - fill the video_device lock - use helpers for wait_prepare and wait_finish vb2_ops - remove unnecessary usleep in between esparser writes. Extensive testing of every codec on GXBB/GXL didn't reveal any fails without it, so just remove it. - compile v4l2_compliance inside the git repo - Check for plane number/plane size to pass the latest v4l2-compliance test - Moved the single instance check (returning -EBUSY) to start/stop streaming The check was previously in queue_setup but there was no great location to clear it except for .close(). - Slight rework of the way CAPTURE frames are timestamped for better accuracy - Implement PAR reporting via VIDIOC_CROPCAP [0] https://patchwork.kernel.org/cover/10583391/ Maxime Jourdan (3): dt-bindings: media: add Amlogic Video Decoder Bindings media: meson: add v4l2 m2m video decoder driver MAINTAINERS: Add meson video decoder .../bindings/media/amlogic,vdec.txt | 71 ++ MAINTAINERS | 8 + drivers/media/platform/Kconfig | 10 + drivers/media/platform/meson/Makefile | 1 + drivers/media/platform/meson/vdec/Makefile | 8 + .../media/platform/meson/vdec/codec_mpeg12.c | 200 ++++ .../media/platform/meson/vdec/codec_mpeg12.h | 14 + drivers/media/platform/meson/vdec/dos_regs.h | 98 ++ drivers/media/platform/meson/vdec/esparser.c | 366 ++++++ drivers/media/platform/meson/vdec/esparser.h | 32 + drivers/media/platform/meson/vdec/vdec.c | 1013 +++++++++++++++++ drivers/media/platform/meson/vdec/vdec.h | 247 ++++ drivers/media/platform/meson/vdec/vdec_1.c | 235 ++++ drivers/media/platform/meson/vdec/vdec_1.h | 14 + .../media/platform/meson/vdec/vdec_helpers.c | 437 +++++++ .../media/platform/meson/vdec/vdec_helpers.h | 48 + .../media/platform/meson/vdec/vdec_platform.c | 101 ++ .../media/platform/meson/vdec/vdec_platform.h | 30 + 18 files changed, 2933 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/amlogic,vdec.txt create mode 100644 drivers/media/platform/meson/vdec/Makefile create mode 100644 drivers/media/platform/meson/vdec/codec_mpeg12.c create mode 100644 drivers/media/platform/meson/vdec/codec_mpeg12.h create mode 100644 drivers/media/platform/meson/vdec/dos_regs.h create mode 100644 drivers/media/platform/meson/vdec/esparser.c create mode 100644 drivers/media/platform/meson/vdec/esparser.h create mode 100644 drivers/media/platform/meson/vdec/vdec.c create mode 100644 drivers/media/platform/meson/vdec/vdec.h create mode 100644 drivers/media/platform/meson/vdec/vdec_1.c create mode 100644 drivers/media/platform/meson/vdec/vdec_1.h create mode 100644 drivers/media/platform/meson/vdec/vdec_helpers.c create mode 100644 drivers/media/platform/meson/vdec/vdec_helpers.h create mode 100644 drivers/media/platform/meson/vdec/vdec_platform.c create mode 100644 drivers/media/platform/meson/vdec/vdec_platform.h root@libretech-cc:~# v4l2-compliance -d /dev/video0 v4l2-compliance SHA: d26e4941419b05fcb2b6708ee32aef367c2ec4af, 64 bits Compliance test for device /dev/video0: Driver Info: Driver name : meson-vdec Card type : Amlogic Video Decoder Bus info : platform:meson-vdec Driver version : 4.19.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 Required ioctls: test VIDIOC_QUERYCAP: OK Allow for multiple opens: test second /dev/video0 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 (Not Supported) 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 Buffer ioctls: test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK Total: 43, Succeeded: 43, Failed: 0, Warnings: 0