summaryrefslogtreecommitdiff
authorapollo.ling <apollo.ling@amlogic.com>2020-03-05 09:31:42 (GMT)
committer apollo.ling <apollo.ling@amlogic.com>2020-03-06 05:55:21 (GMT)
commit0548bdac0018109e546443d39b301fb7eecb82a6 (patch)
treeb6e8ce547f0f1643e300d8222ef4752ef4caae68
parent2c8d715502abc9dc641b898863f2b1100c4ea854 (diff)
downloadmedia_modules-0548bdac0018109e546443d39b301fb7eecb82a6.zip
media_modules-0548bdac0018109e546443d39b301fb7eecb82a6.tar.gz
media_modules-0548bdac0018109e546443d39b301fb7eecb82a6.tar.bz2
media: media_modules for sm1 in 5.4 for android Q [1/2]
PD#SWPL-19054 Problem: The current media_modules version not fit for 5.4 Solution: update the media_modules version to fit 5.4 Verify: ac214 Change-Id: I7df8bcf057a2f07ec7854441e6e6320d76e12a25 Signed-off-by: apollo.ling <apollo.ling@amlogic.com>
Diffstat
-rwxr-xr-xMedia.mk12
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/amvdec_ports/aml_vcodec_dec.c2
-rw-r--r--drivers/amvdec_ports/aml_vcodec_dec_pm.c206
-rw-r--r--drivers/amvdec_ports/aml_vcodec_dec_pm.h34
-rw-r--r--drivers/amvdec_ports/decoder/h264_parse.c389
-rw-r--r--drivers/amvdec_ports/decoder/h264_parse.h141
-rw-r--r--drivers/amvdec_ports/decoder/h264_stream.c111
-rw-r--r--drivers/amvdec_ports/decoder/h264_stream.h39
-rw-r--r--drivers/common/chips/decoder_cpu_ver_info.c9
-rw-r--r--drivers/common/chips/decoder_cpu_ver_info.h72
-rw-r--r--drivers/common/firmware/firmware_drv.c114
-rw-r--r--drivers/common/firmware/firmware_priv.h4
-rw-r--r--drivers/common/firmware/firmware_type.c1
-rw-r--r--drivers/common/media_clock/clk/clk.h2
-rw-r--r--drivers/common/media_clock/clk/clkg12.c6
-rw-r--r--drivers/common/media_clock/switch/amports_gate.c4
-rw-r--r--drivers/frame_provider/decoder/Makefile1
-rw-r--r--drivers/frame_provider/decoder/avs/avs.c64
-rw-r--r--drivers/frame_provider/decoder/avs2/avs2_bufmgr.c4
-rw-r--r--drivers/frame_provider/decoder/avs2/vavs2.c115
-rw-r--r--drivers/frame_provider/decoder/h264/vh264.c57
-rw-r--r--drivers/frame_provider/decoder/h264/vh264_4k2k.c3
-rw-r--r--drivers/frame_provider/decoder/h264/vh264_mvc.c43
-rw-r--r--drivers/frame_provider/decoder/h264_multi/h264_dpb.c20
-rw-r--r--drivers/frame_provider/decoder/h264_multi/h264_dpb.h13
-rw-r--r--drivers/frame_provider/decoder/h264_multi/vmh264.c82
-rw-r--r--drivers/frame_provider/decoder/h265/vh265.c98
-rw-r--r--drivers/frame_provider/decoder/mjpeg/vmjpeg.c37
-rw-r--r--drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c89
-rw-r--r--drivers/frame_provider/decoder/mpeg12/vmpeg12.c38
-rw-r--r--drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c140
-rw-r--r--drivers/frame_provider/decoder/mpeg4/vmpeg4.c40
-rw-r--r--drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c50
-rw-r--r--drivers/frame_provider/decoder/real/vreal.c41
-rw-r--r--drivers/frame_provider/decoder/utils/amstream_profile.c2
-rw-r--r--drivers/frame_provider/decoder/utils/amvdec.c3
-rw-r--r--drivers/frame_provider/decoder/utils/decoder_bmmu_box.c27
-rw-r--r--drivers/frame_provider/decoder/utils/decoder_mmu_box.c21
-rw-r--r--drivers/frame_provider/decoder/utils/firmware.h15
-rw-r--r--drivers/frame_provider/decoder/utils/frame_check.c42
-rw-r--r--drivers/frame_provider/decoder/utils/secprot.c10
-rw-r--r--drivers/frame_provider/decoder/utils/vdec.c170
-rw-r--r--drivers/frame_provider/decoder/utils/vdec.h5
-rw-r--r--drivers/frame_provider/decoder/utils/vdec_input.c14
-rw-r--r--drivers/frame_provider/decoder/utils/vdec_profile.c10
-rw-r--r--drivers/frame_provider/decoder/vc1/vvc1.c43
-rw-r--r--drivers/frame_provider/decoder/vp9/vvp9.c75
-rw-r--r--drivers/stream_input/Makefile7
-rw-r--r--drivers/stream_input/amports/adec.c32
-rw-r--r--drivers/stream_input/amports/amports_priv.h1
-rw-r--r--drivers/stream_input/amports/amstream.c333
-rw-r--r--drivers/stream_input/parser/esparser.c54
-rw-r--r--drivers/stream_input/parser/psparser.c5
-rw-r--r--drivers/stream_input/parser/rmparser.c5
-rw-r--r--drivers/stream_input/parser/streambuf.c19
-rw-r--r--drivers/stream_input/parser/streambuf_reg.h6
-rw-r--r--drivers/stream_input/parser/thread_rw.c20
-rw-r--r--drivers/stream_input/parser/tsdemux.c18
59 files changed, 1728 insertions, 1292 deletions
diff --git a/Media.mk b/Media.mk
index 7fa3c48..eb2b108 100755
--- a/Media.mk
+++ b/Media.mk
@@ -18,10 +18,13 @@ CONFIGS := CONFIG_AMLOGIC_MEDIA_VDEC_MPEG12=m \
CONFIG_AMLOGIC_MEDIA_VDEC_MJPEG_MULTI=m \
CONFIG_AMLOGIC_MEDIA_VDEC_REAL=m \
CONFIG_AMLOGIC_MEDIA_VDEC_AVS=m \
- CONFIG_AMLOGIC_MEDIA_VDEC_AVS_MULTI=m \
CONFIG_AMLOGIC_MEDIA_VDEC_AVS2=m \
CONFIG_AMLOGIC_MEDIA_VENC_H264=m \
- CONFIG_AMLOGIC_MEDIA_VENC_H265=m
+ CONFIG_AMLOGIC_MEDIA_VENC_H265=m \
+ CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION=y \
+ CONFIG_AMLOGIC_MEDIA_GE2D=y \
+ CONFIG_AMLOGIC_MEDIA_VENC_MULTI=m \
+ CONFIG_AMLOGIC_MEDIA_VENC_JPEG=m
define copy-media-modules
$(foreach m, $(shell find $(strip $(1)) -name "*.ko"),\
@@ -89,12 +92,11 @@ $(shell mkdir $(MODS_OUT) -p)
endif
ifeq ($(KERNEL_A32_SUPPORT), true)
-TOOLS := /opt/gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
+TOOLS := /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
else
-TOOLS := /opt/gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
+TOOLS := /opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-
endif
-
modules:
CCACHE_NODIRECT="true" PATH=$$(cd ./$(TARGET_HOST_TOOL_PATH); pwd):$$PATH \
$(MAKE) -C $(KDIR) M=$(MEDIA_DRIVERS) ARCH=$(KERNEL_ARCH) \
diff --git a/drivers/Makefile b/drivers/Makefile
index 018c8fe..1af0482 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -2,4 +2,4 @@ obj-y += common/
obj-y += frame_provider/
obj-y += frame_sink/
obj-y += stream_input/
-obj-y += amvdec_ports/
+#obj-y += amvdec_ports/
diff --git a/drivers/amvdec_ports/aml_vcodec_dec.c b/drivers/amvdec_ports/aml_vcodec_dec.c
index 1a186d4..880f3a5 100644
--- a/drivers/amvdec_ports/aml_vcodec_dec.c
+++ b/drivers/amvdec_ports/aml_vcodec_dec.c
@@ -1179,7 +1179,7 @@ static int vidioc_decoder_reqbufs(struct file *file, void *priv,
v4l_dbg(ctx, V4L_DEBUG_CODEC_PROT,
"reqbufs (st:%d) %d -> %d\n",
ctx->state, rb->count, ctx->dpb_size);
- //rb->count = ctx->dpb_size;
+ rb->count = ctx->dpb_size;
}
}
diff --git a/drivers/amvdec_ports/aml_vcodec_dec_pm.c b/drivers/amvdec_ports/aml_vcodec_dec_pm.c
new file mode 100644
index 0000000..c801e87
--- a/dev/null
+++ b/drivers/amvdec_ports/aml_vcodec_dec_pm.c
@@ -0,0 +1,206 @@
+/*
+* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* 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.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*
+* Description:
+*/
+#include <linux/clk.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/pm_runtime.h>
+
+#include "aml_vcodec_dec_pm.h"
+#include "aml_vcodec_util.h"
+//#include "aml_vpu.h"
+
+int aml_vcodec_init_dec_pm(struct aml_vcodec_dev *amldev)
+{
+ struct device_node *node;
+ struct platform_device *pdev;
+ struct aml_vcodec_pm *pm;
+ int ret = 0;
+
+ pdev = amldev->plat_dev;
+ pm = &amldev->pm;
+ pm->amldev = amldev;
+ node = of_parse_phandle(pdev->dev.of_node, "larb", 0);
+ if (!node) {
+ aml_v4l2_err("of_parse_phandle larb fail!");
+ return -1;
+ }
+
+ pdev = of_find_device_by_node(node);
+ if (WARN_ON(!pdev)) {
+ of_node_put(node);
+ return -1;
+ }
+ pm->larbvdec = &pdev->dev;
+ pdev = amldev->plat_dev;
+ pm->dev = &pdev->dev;
+
+ pm->vcodecpll = devm_clk_get(&pdev->dev, "vcodecpll");
+ if (IS_ERR(pm->vcodecpll)) {
+ aml_v4l2_err("devm_clk_get vcodecpll fail");
+ ret = PTR_ERR(pm->vcodecpll);
+ }
+
+ pm->univpll_d2 = devm_clk_get(&pdev->dev, "univpll_d2");
+ if (IS_ERR(pm->univpll_d2)) {
+ aml_v4l2_err("devm_clk_get univpll_d2 fail");
+ ret = PTR_ERR(pm->univpll_d2);
+ }
+
+ pm->clk_cci400_sel = devm_clk_get(&pdev->dev, "clk_cci400_sel");
+ if (IS_ERR(pm->clk_cci400_sel)) {
+ aml_v4l2_err("devm_clk_get clk_cci400_sel fail");
+ ret = PTR_ERR(pm->clk_cci400_sel);
+ }
+
+ pm->vdec_sel = devm_clk_get(&pdev->dev, "vdec_sel");
+ if (IS_ERR(pm->vdec_sel)) {
+ aml_v4l2_err("devm_clk_get vdec_sel fail");
+ ret = PTR_ERR(pm->vdec_sel);
+ }
+
+ pm->vdecpll = devm_clk_get(&pdev->dev, "vdecpll");
+ if (IS_ERR(pm->vdecpll)) {
+ aml_v4l2_err("devm_clk_get vdecpll fail");
+ ret = PTR_ERR(pm->vdecpll);
+ }
+
+ pm->vencpll = devm_clk_get(&pdev->dev, "vencpll");
+ if (IS_ERR(pm->vencpll)) {
+ aml_v4l2_err("devm_clk_get vencpll fail");
+ ret = PTR_ERR(pm->vencpll);
+ }
+
+ pm->venc_lt_sel = devm_clk_get(&pdev->dev, "venc_lt_sel");
+ if (IS_ERR(pm->venc_lt_sel)) {
+ aml_v4l2_err("devm_clk_get venc_lt_sel fail");
+ ret = PTR_ERR(pm->venc_lt_sel);
+ }
+
+ pm->vdec_bus_clk_src = devm_clk_get(&pdev->dev, "vdec_bus_clk_src");
+ if (IS_ERR(pm->vdec_bus_clk_src)) {
+ aml_v4l2_err("devm_clk_get vdec_bus_clk_src");
+ ret = PTR_ERR(pm->vdec_bus_clk_src);
+ }
+
+ pm_runtime_enable(&pdev->dev);
+
+ return ret;
+}
+
+void aml_vcodec_release_dec_pm(struct aml_vcodec_dev *dev)
+{
+ pm_runtime_disable(dev->pm.dev);
+}
+
+void aml_vcodec_dec_pw_on(struct aml_vcodec_pm *pm)
+{
+ int ret;
+
+ ret = pm_runtime_get_sync(pm->dev);
+ if (ret)
+ aml_v4l2_err("pm_runtime_get_sync fail %d", ret);
+}
+
+void aml_vcodec_dec_pw_off(struct aml_vcodec_pm *pm)
+{
+ int ret;
+
+ ret = pm_runtime_put_sync(pm->dev);
+ if (ret)
+ aml_v4l2_err("pm_runtime_put_sync fail %d", ret);
+}
+
+void aml_vcodec_dec_clock_on(struct aml_vcodec_pm *pm)
+{
+ int ret;
+
+ ret = clk_set_rate(pm->vcodecpll, 1482 * 1000000);
+ if (ret)
+ aml_v4l2_err("clk_set_rate vcodecpll fail %d", ret);
+
+ ret = clk_set_rate(pm->vencpll, 800 * 1000000);
+ if (ret)
+ aml_v4l2_err("clk_set_rate vencpll fail %d", ret);
+
+ ret = clk_prepare_enable(pm->vcodecpll);
+ if (ret)
+ aml_v4l2_err("clk_prepare_enable vcodecpll fail %d", ret);
+
+ ret = clk_prepare_enable(pm->vencpll);
+ if (ret)
+ aml_v4l2_err("clk_prepare_enable vencpll fail %d", ret);
+
+ ret = clk_prepare_enable(pm->vdec_bus_clk_src);
+ if (ret)
+ aml_v4l2_err("clk_prepare_enable vdec_bus_clk_src fail %d",
+ ret);
+
+ ret = clk_prepare_enable(pm->venc_lt_sel);
+ if (ret)
+ aml_v4l2_err("clk_prepare_enable venc_lt_sel fail %d", ret);
+
+ ret = clk_set_parent(pm->venc_lt_sel, pm->vdec_bus_clk_src);
+ if (ret)
+ aml_v4l2_err("clk_set_parent venc_lt_sel vdec_bus_clk_src fail %d",
+ ret);
+
+ ret = clk_prepare_enable(pm->univpll_d2);
+ if (ret)
+ aml_v4l2_err("clk_prepare_enable univpll_d2 fail %d", ret);
+
+ ret = clk_prepare_enable(pm->clk_cci400_sel);
+ if (ret)
+ aml_v4l2_err("clk_prepare_enable clk_cci400_sel fail %d", ret);
+
+ ret = clk_set_parent(pm->clk_cci400_sel, pm->univpll_d2);
+ if (ret)
+ aml_v4l2_err("clk_set_parent clk_cci400_sel univpll_d2 fail %d",
+ ret);
+
+ ret = clk_prepare_enable(pm->vdecpll);
+ if (ret)
+ aml_v4l2_err("clk_prepare_enable vdecpll fail %d", ret);
+
+ ret = clk_prepare_enable(pm->vdec_sel);
+ if (ret)
+ aml_v4l2_err("clk_prepare_enable vdec_sel fail %d", ret);
+
+ ret = clk_set_parent(pm->vdec_sel, pm->vdecpll);
+ if (ret)
+ aml_v4l2_err("clk_set_parent vdec_sel vdecpll fail %d", ret);
+
+ //ret = aml_smi_larb_get(pm->larbvdec);
+ if (ret)
+ aml_v4l2_err("aml_smi_larb_get larbvdec fail %d", ret);
+
+}
+
+void aml_vcodec_dec_clock_off(struct aml_vcodec_pm *pm)
+{
+ //aml_smi_larb_put(pm->larbvdec);
+ clk_disable_unprepare(pm->vdec_sel);
+ clk_disable_unprepare(pm->vdecpll);
+ clk_disable_unprepare(pm->univpll_d2);
+ clk_disable_unprepare(pm->clk_cci400_sel);
+ clk_disable_unprepare(pm->venc_lt_sel);
+ clk_disable_unprepare(pm->vdec_bus_clk_src);
+ clk_disable_unprepare(pm->vencpll);
+ clk_disable_unprepare(pm->vcodecpll);
+}
diff --git a/drivers/amvdec_ports/aml_vcodec_dec_pm.h b/drivers/amvdec_ports/aml_vcodec_dec_pm.h
new file mode 100644
index 0000000..ccdf313
--- a/dev/null
+++ b/drivers/amvdec_ports/aml_vcodec_dec_pm.h
@@ -0,0 +1,34 @@
+/*
+* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* 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.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*
+* Description:
+*/
+
+#ifndef _AML_VCODEC_DEC_PM_H_
+#define _AML_VCODEC_DEC_PM_H_
+
+#include "aml_vcodec_drv.h"
+
+int aml_vcodec_init_dec_pm(struct aml_vcodec_dev *dev);
+void aml_vcodec_release_dec_pm(struct aml_vcodec_dev *dev);
+
+void aml_vcodec_dec_pw_on(struct aml_vcodec_pm *pm);
+void aml_vcodec_dec_pw_off(struct aml_vcodec_pm *pm);
+void aml_vcodec_dec_clock_on(struct aml_vcodec_pm *pm);
+void aml_vcodec_dec_clock_off(struct aml_vcodec_pm *pm);
+
+#endif /* _AML_VCODEC_DEC_PM_H_ */
diff --git a/drivers/amvdec_ports/decoder/h264_parse.c b/drivers/amvdec_ports/decoder/h264_parse.c
new file mode 100644
index 0000000..1c3b73d
--- a/dev/null
+++ b/drivers/amvdec_ports/decoder/h264_parse.c
@@ -0,0 +1,389 @@
+/*
+ * drivers/amlogic/media_modules/amvdec_ports/decoder/h264_parse.c
+ *
+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include "h264_parse.h"
+#include "h264_stream.h"
+
+static unsigned char h264_exp_golomb_bits[256] = {
+ 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0,
+};
+
+static unsigned char ZZ_SCAN[16] = {
+ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
+};
+
+static unsigned char ZZ_SCAN8[64] = {
+ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
+ 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
+ 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
+ 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
+};
+
+unsigned int h264_u(struct h264_stream_t *s, unsigned int n)
+{
+ //if (n % 8 == 0) {
+ // return h264_stream_read_bytes(s, n / 8);
+ //}
+ return h264_stream_read_bits(s, n);
+}
+
+unsigned int h264_ue(struct h264_stream_t *s)
+{
+ unsigned int bits, read;
+ unsigned char coded;
+
+ bits = 0;
+ while (true) {
+ if (h264_stream_bytes_remaining(s) < 1) {
+ read = h264_stream_peek_bits(s, s->bit_pos) <<
+ (8 - s->bit_pos);
+ break;
+ }
+
+ read = h264_stream_peek_bits(s, 8);
+ if (bits > 16)
+ break;
+
+ if (read)
+ break;
+
+ h264_stream_read_bits(s, 8);
+ bits += 8;
+ }
+
+ coded = h264_exp_golomb_bits[read];
+ h264_stream_read_bits(s, coded);
+ bits += coded;
+ return h264_stream_read_bits(s, bits + 1) - 1;
+}
+
+int h264_se(struct h264_stream_t *s)
+{
+ unsigned int ret;
+
+ ret = h264_ue(s);
+ if (!(ret & 0x1)) {
+ ret >>= 1;
+ return (int)(-ret);
+ }
+
+ return (ret + 1) >> 1;
+}
+
+void h264_f(struct h264_stream_t *s, unsigned int n, unsigned int pattern)
+{
+ unsigned int val = h264_u(s, n);
+
+ if (val != pattern) {
+ pr_err("fixed-pattern doesn't match. expected: %x actual: %x\n",
+ pattern, (unsigned int)val);
+ return;
+ }
+}
+
+void h264_rbsp_trailing_bits(struct h264_stream_t *s)
+{
+ h264_f(s, 1, 1);
+ h264_f(s, s->bit_pos, 0);
+}
+
+// syntax for scaling list matrix values
+void Scaling_List(int *scalingList, int sizeOfScalingList,
+ bool *UseDefaultScalingMatrix, struct h264_stream_t *s)
+{
+ int j, scanj;
+ int delta_scale, lastScale, nextScale;
+
+ lastScale = 8;
+ nextScale = 8;
+
+ for (j = 0; j < sizeOfScalingList; j++) {
+ scanj = (sizeOfScalingList == 16) ? ZZ_SCAN[j] : ZZ_SCAN8[j];
+
+ if (nextScale != 0) {
+ delta_scale = h264_ue(s);
+ nextScale = (lastScale + delta_scale + 256) % 256;
+ *UseDefaultScalingMatrix =
+ (bool) (scanj == 0 && nextScale == 0);
+ }
+
+ scalingList[scanj] = (nextScale == 0) ? lastScale : nextScale;
+ lastScale = scalingList[scanj];
+ }
+}
+
+void h264_sps_parse(struct h264_stream_t *s, struct h264_SPS_t *sps)
+{
+ unsigned int i, n_ScalingList;
+
+ sps->profile_idc = h264_u(s, 8);
+
+ if ((sps->profile_idc != BASELINE) &&
+ (sps->profile_idc != MAIN) &&
+ (sps->profile_idc != EXTENDED) &&
+ (sps->profile_idc != FREXT_HP) &&
+ (sps->profile_idc != FREXT_Hi10P) &&
+ (sps->profile_idc != FREXT_Hi422) &&
+ (sps->profile_idc != FREXT_Hi444) &&
+ (sps->profile_idc != FREXT_CAVLC444)
+ && (sps->profile_idc != MVC_HIGH)
+ && (sps->profile_idc != STEREO_HIGH)) {
+ pr_err("Invalid Profile IDC (%d) encountered.\n",
+ sps->profile_idc);
+ return;
+ }
+
+ sps->constrained_set0_flag = h264_u(s, 1);
+ sps->constrained_set1_flag = h264_u(s, 1);
+ sps->constrained_set2_flag = h264_u(s, 1);
+ h264_u(s, 5); // reserved_zero_5bits
+ sps->level_idc = h264_u(s, 8);
+ sps->seq_parameter_set_id = h264_ue(s);
+
+ // Fidelity Range Extensions stuff
+ sps->chroma_format_idc = 1;
+ sps->bit_depth_luma_minus8 = 0;
+ sps->bit_depth_chroma_minus8 = 0;
+ sps->lossless_qpprime_flag = 0;
+ sps->separate_colour_plane_flag = 0;
+
+ if ((sps->profile_idc == FREXT_HP) ||
+ (sps->profile_idc == FREXT_Hi10P) ||
+ (sps->profile_idc == FREXT_Hi422) ||
+ (sps->profile_idc == FREXT_Hi444) ||
+ (sps->profile_idc == FREXT_CAVLC444)) {
+ sps->chroma_format_idc = h264_ue(s);
+
+ if (sps->chroma_format_idc == YUV444)
+ sps->separate_colour_plane_flag = h264_u(s, 1);
+
+ sps->bit_depth_luma_minus8 = h264_ue(s);
+ sps->bit_depth_chroma_minus8 = h264_ue(s);
+ //checking;
+ if ((sps->bit_depth_luma_minus8 + 8 > sizeof(unsigned short) * 8) ||
+ (sps->bit_depth_chroma_minus8 + 8 > sizeof(unsigned short) * 8)) {
+ pr_err("Source picture has higher bit depth than imgpel data type.\n");
+ pr_err("Please recompile with larger data type for imgpel.\n");
+ }
+
+ sps->lossless_qpprime_flag = h264_u(s, 1);
+ sps->seq_scaling_matrix_present_flag = h264_u(s, 1);
+ if (sps->seq_scaling_matrix_present_flag) {
+ n_ScalingList = (sps->chroma_format_idc != YUV444) ? 8 : 12;
+ for (i = 0; i < n_ScalingList; i++) {
+ sps->seq_scaling_list_present_flag[i] = h264_u(s, 1);
+ if (sps->seq_scaling_list_present_flag[i]) {
+ if (i < 6)
+ Scaling_List(sps->ScalingList4x4[i], 16,
+ &sps->UseDefaultScalingMatrix4x4Flag[i], s);
+ else
+ Scaling_List(sps->ScalingList8x8[i - 6],
+ 64, &sps->UseDefaultScalingMatrix8x8Flag[i - 6], s);
+ }
+ }
+ }
+ }
+
+ sps->log2_max_frame_num_minus4 = h264_ue(s);
+ sps->pic_order_cnt_type = h264_ue(s);
+ if (sps->pic_order_cnt_type == 0) {
+ sps->log2_max_pic_order_cnt_lsb_minus4 = h264_ue(s);
+ } else if (sps->pic_order_cnt_type == 1) {
+ sps->delta_pic_order_always_zero_flag = h264_se(s);
+ sps->offset_for_non_ref_pic = h264_se(s);
+ sps->offset_for_top_to_bottom_field = h264_se(s);
+ sps->num_ref_frames_in_poc_cycle = h264_se(s);
+ for (i = 0; i < sps->num_ref_frames_in_poc_cycle; ++i)
+ sps->offset_for_ref_frame[i] = h264_se(s);
+ }
+
+ sps->num_ref_frames = h264_ue(s);
+ sps->gaps_in_frame_num_value_allowed_flag = h264_u(s, 1);
+ sps->pic_width_in_mbs_minus1 = h264_ue(s);
+ sps->pic_height_in_map_units_minus1 = h264_ue(s);
+ sps->frame_mbs_only_flag = h264_u(s, 1);
+ if (!sps->frame_mbs_only_flag)
+ sps->mb_adaptive_frame_field_flag = h264_u(s, 1);
+
+ sps->direct_8x8_inference_flag = h264_u(s, 1);
+ sps->frame_cropping_flag = h264_u(s, 1);
+ if (sps->frame_cropping_flag) {
+ sps->frame_crop_left_offset = h264_ue(s);
+ sps->frame_crop_right_offset = h264_ue(s);
+ sps->frame_crop_top_offset = h264_ue(s);
+ sps->frame_crop_bottom_offset = h264_ue(s);
+ }
+
+ sps->vui_parameters_present_flag = h264_u(s, 1);
+ //if (sps->vui_parameters_present_flag) {
+ // sps->vui_parameters = h264_vui_parameters(s);
+ //}
+ h264_rbsp_trailing_bits(s);
+}
+
+void h264_pps_parse(struct h264_stream_t *s, struct h264_PPS_t *pps)
+{
+ pps->pic_parameter_set_id = h264_ue(s);
+ pps->seq_parameter_set_id = h264_ue(s);
+ pps->entropy_coding_mode_flag = h264_u(s, 1);
+ pps->pic_order_present_flag = h264_u(s, 1);
+ pps->num_slice_groups_minus1 = h264_ue(s);
+ if (pps->num_slice_groups_minus1 > 0) {
+ pps->slice_group_map_type = h264_ue(s);
+ if (pps->slice_group_map_type == 0) {
+ pps->run_length_minus1 = h264_ue(s);
+ } else if (pps->slice_group_map_type == 2) {
+ pps->top_left = h264_ue(s);
+ pps->bottom_right = h264_ue(s);
+ } else if (pps->slice_group_map_type == 3 ||
+ pps->slice_group_map_type == 4 ||
+ pps->slice_group_map_type == 5) {
+ pps->slice_group_change_direction_flag = h264_u(s, 1);
+ pps->slice_group_change_rate_minus1 = h264_ue(s);
+ } else if (pps->slice_group_map_type == 6) {
+ pps->pic_size_in_map_units_minus1 = h264_ue(s);
+ pps->slice_group_id = h264_ue(s);
+ }
+ }
+ pps->num_ref_idx_l0_active_minus1 = h264_ue(s);
+ pps->num_ref_idx_l1_active_minus1 = h264_ue(s);
+ pps->weighted_pred_flag = h264_u(s, 1);
+ pps->weighted_bipred_idc = h264_u(s, 2);
+ pps->pic_init_qp_minus26 = h264_se(s);
+ pps->pic_init_qs_minus26 = h264_se(s);
+ pps->chroma_qp_index_offset = h264_se(s);
+ pps->deblocking_filter_control_present_flag = h264_u(s, 1);
+ pps->constrained_intra_pred_flag = h264_u(s, 1);
+ pps->redundant_pic_cnt_present_flag = h264_u(s, 1);
+ h264_rbsp_trailing_bits(s);
+}
+
+void h264_sps_info(struct h264_SPS_t *sps)
+{
+ int i;
+
+ pr_info("sequence_parameter_set {\n");
+ pr_info(" profile_idc: %d\n", sps->profile_idc);
+ pr_info(" constraint_set0_flag: %d\n", sps->constrained_set0_flag);
+ pr_info(" constraint_set1_flag: %d\n", sps->constrained_set1_flag);
+ pr_info(" constraint_set2_flag: %d\n", sps->constrained_set2_flag);
+ pr_info(" level_idc: %d\n", sps->level_idc);
+ pr_info(" seq_parameter_set_id: %d\n", sps->seq_parameter_set_id);
+
+ pr_info(" log2_max_frame_num_minus4: %d\n",
+ sps->log2_max_frame_num_minus4);
+ pr_info(" pic_order_cnt_type: %d\n", sps->pic_order_cnt_type);
+ if (sps->pic_order_cnt_type == 0) {
+ pr_info(" log2_max_pic_order_cnt_lsb_minus4: %d\n",
+ sps->log2_max_pic_order_cnt_lsb_minus4);
+ } else if (sps->pic_order_cnt_type == 1) {
+ pr_info(" delta_pic_order_always_zero_flag: %d\n",
+ sps->delta_pic_order_always_zero_flag);
+ pr_info(" offset_for_non_ref_pic: %d\n",
+ sps->offset_for_non_ref_pic);
+ pr_info(" offset_for_top_to_bottom_field: %d\n",
+ sps->offset_for_top_to_bottom_field);
+ pr_info(" num_ref_frames_in_pic_order_cnt_cycle: %d\n",
+ sps->num_ref_frames_in_poc_cycle);
+ for (i = 0; i < sps->num_ref_frames_in_poc_cycle; ++i) {
+ pr_info(" offset_for_ref_frame[%d]: %d\n", i,
+ sps->offset_for_ref_frame[i]);
+ }
+ }
+ pr_info(" num_ref_frames: %d\n", sps->num_ref_frames);
+ pr_info(" gaps_in_frame_num_value_allowed_flag: %d\n",
+ sps->gaps_in_frame_num_value_allowed_flag);
+ pr_info(" pic_width_in_mbs_minus1: %d\n",
+ sps->pic_width_in_mbs_minus1);
+ pr_info(" pic_height_in_map_units_minus1: %d\n",
+ sps->pic_height_in_map_units_minus1);
+ pr_info(" frame_mbs_only_flag: %d\n",
+ sps->frame_mbs_only_flag);
+ pr_info(" mb_adaptive_frame_field_flag: %d\n",
+ sps->mb_adaptive_frame_field_flag);
+ pr_info(" direct_8x8_inference_flag: %d\n",
+ sps->direct_8x8_inference_flag);
+ pr_info(" frame_cropping_flag: %d\n",
+ sps->frame_cropping_flag);
+ if (sps->frame_cropping_flag) {
+ pr_info(" frame_crop_left_offset: %d\n",
+ sps->frame_crop_left_offset);
+ pr_info(" frame_crop_right_offset: %d\n",
+ sps->frame_crop_right_offset);
+ pr_info(" frame_crop_top_offset: %d\n",
+ sps->frame_crop_top_offset);
+ pr_info(" frame_crop_bottom_offset: %d\n",
+ sps->frame_crop_bottom_offset);
+ }
+ pr_info(" vui_parameters_present_flag: %d\n",
+ sps->vui_parameters_present_flag);
+ //if (sps->vui_parameters_present_flag) {
+ // h264_print_vui_parameters(sps->vui_parameters);
+ //}
+
+ pr_info(" }\n");
+}
+
+void h264_pps_info(struct h264_PPS_t *pps)
+{
+ pr_info("pic_parameter_set {\n");
+ pr_info(" pic_parameter_set_id: %d\n",
+ pps->pic_parameter_set_id);
+ pr_info(" seq_parameter_set_id: %d\n",
+ pps->seq_parameter_set_id);
+ pr_info(" entropy_coding_mode_flag: %d\n",
+ pps->entropy_coding_mode_flag);
+ pr_info(" pic_order_present_flag: %d\n",
+ pps->pic_order_present_flag);
+ pr_info(" num_slice_groups_minus1: %d\n",
+ pps->num_slice_groups_minus1);
+ // FIXME: Code for slice groups is missing here.
+ pr_info(" num_ref_idx_l0_active_minus1: %d\n",
+ pps->num_ref_idx_l0_active_minus1);
+ pr_info(" num_ref_idx_l1_active_minus1: %d\n",
+ pps->num_ref_idx_l1_active_minus1);
+ pr_info(" weighted_pred_flag: %d\n", pps->weighted_pred_flag);
+ pr_info(" weighted_bipred_idc: %d\n", pps->weighted_bipred_idc);
+ pr_info(" pic_init_qp_minus26: %d\n", pps->pic_init_qp_minus26);
+ pr_info(" pic_init_qs_minus26: %d\n", pps->pic_init_qs_minus26);
+ pr_info(" chroma_qp_index_offset: %d\n",
+ pps->chroma_qp_index_offset);
+ pr_info(" deblocking_filter_control_present_flag: %d\n",
+ pps->deblocking_filter_control_present_flag);
+ pr_info(" constrained_intra_pred_flag: %d\n",
+ pps->constrained_intra_pred_flag);
+ pr_info(" redundant_pic_cnt_present_flag: %d\n",
+ pps->redundant_pic_cnt_present_flag);
+ pr_info(" }\n");
+}
+
diff --git a/drivers/amvdec_ports/decoder/h264_parse.h b/drivers/amvdec_ports/decoder/h264_parse.h
new file mode 100644
index 0000000..e54e4d3
--- a/dev/null
+++ b/drivers/amvdec_ports/decoder/h264_parse.h
@@ -0,0 +1,141 @@
+/*
+ * drivers/amlogic/media_modules/amvdec_ports/decoder/h264_parse.h
+ *
+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 _H264_PARSE_H
+#define _H264_PARSE_H
+
+#include "h264_stream.h"
+
+enum color_model {
+ CM_UNKNOWN = -1,
+ CM_YUV = 0,
+ CM_RGB = 1,
+ CM_XYZ = 2
+};
+
+enum color_format {
+ CF_UNKNOWN = -1, //!< Unknown color format
+ YUV400 = 0, //!< Monochrome
+ YUV420 = 1, //!< 4:2:0
+ YUV422 = 2, //!< 4:2:2
+ YUV444 = 3 //!< 4:4:4
+};
+
+enum pixel_format {
+ PF_UNKNOWN = -1, //!< Unknown color ordering
+ UYVY = 0, //!< UYVY
+ YUY2 = 1, //!< YUY2
+ YUYV = 1, //!< YUYV
+ YVYU = 2, //!< YVYU
+ BGR = 3, //!< BGR
+ V210 = 4 //!< Video Clarity 422 format (10 bits)
+};
+
+//AVC Profile IDC definitions
+enum profile_idc{
+ NO_PROFILE = 0, //!< disable profile checking for experimental coding (enables FRExt, but disables MV)
+ FREXT_CAVLC444 = 44, //!< YUV 4:4:4/14 "CAVLC 4:4:4"
+ BASELINE = 66, //!< YUV 4:2:0/8 "Baseline"
+ MAIN = 77, //!< YUV 4:2:0/8 "Main"
+ EXTENDED = 88, //!< YUV 4:2:0/8 "Extended"
+ FREXT_HP = 100, //!< YUV 4:2:0/8 "High"
+ FREXT_Hi10P = 110, //!< YUV 4:2:0/10 "High 10"
+ FREXT_Hi422 = 122, //!< YUV 4:2:2/10 "High 4:2:2"
+ FREXT_Hi444 = 244, //!< YUV 4:4:4/14 "High 4:4:4"
+ MVC_HIGH = 118, //!< YUV 4:2:0/8 "Multiview High"
+ STEREO_HIGH = 128 //!< YUV 4:2:0/8 "Stereo High"
+};
+
+/* sequence parameter set */
+struct h264_SPS_t {
+ bool vailid;
+ unsigned int profile_idc;
+ bool constrained_set0_flag;
+ bool constrained_set1_flag;
+ bool constrained_set2_flag;
+ bool constrained_set3_flag;
+ unsigned int level_idc;
+ unsigned int seq_parameter_set_id;
+ unsigned int chroma_format_idc;
+ bool seq_scaling_matrix_present_flag;
+ int seq_scaling_list_present_flag[12];
+ int ScalingList4x4[6][16];
+ int ScalingList8x8[6][64];
+ bool UseDefaultScalingMatrix4x4Flag[6];
+ bool UseDefaultScalingMatrix8x8Flag[6];
+ unsigned int bit_depth_luma_minus8;
+ unsigned int bit_depth_chroma_minus8;
+ unsigned int log2_max_frame_num_minus4;
+ unsigned int pic_order_cnt_type;
+ unsigned int log2_max_pic_order_cnt_lsb_minus4;
+ bool delta_pic_order_always_zero_flag;
+ int offset_for_non_ref_pic;
+ int offset_for_top_to_bottom_field;
+ unsigned int num_ref_frames_in_poc_cycle;
+ int offset_for_ref_frame[255];
+ int num_ref_frames;
+ bool gaps_in_frame_num_value_allowed_flag;
+ unsigned int pic_width_in_mbs_minus1;
+ unsigned int pic_height_in_map_units_minus1;
+ bool frame_mbs_only_flag;
+ bool mb_adaptive_frame_field_flag;
+ bool direct_8x8_inference_flag;
+ bool frame_cropping_flag;
+ unsigned int frame_crop_left_offset;
+ unsigned int frame_crop_right_offset;
+ unsigned int frame_crop_top_offset;
+ unsigned int frame_crop_bottom_offset;
+ bool vui_parameters_present_flag;
+ //h264_vui_parameters_t *vui_parameters;
+ unsigned separate_colour_plane_flag;
+ int lossless_qpprime_flag;
+};
+
+/* pic parameter set */
+struct h264_PPS_t {
+ int pic_parameter_set_id;
+ int seq_parameter_set_id;
+ int entropy_coding_mode_flag;
+ int pic_order_present_flag;
+ int num_slice_groups_minus1;
+ int slice_group_map_type;
+ int run_length_minus1;
+ int top_left;
+ int bottom_right;
+ int slice_group_change_direction_flag;
+ int slice_group_change_rate_minus1;
+ int pic_size_in_map_units_minus1;
+ int slice_group_id;
+ int num_ref_idx_l0_active_minus1;
+ int num_ref_idx_l1_active_minus1;
+ int weighted_pred_flag;
+ int weighted_bipred_idc;
+ int pic_init_qp_minus26;
+ int pic_init_qs_minus26;
+ int chroma_qp_index_offset;
+ int deblocking_filter_control_present_flag;
+ int constrained_intra_pred_flag;
+ int redundant_pic_cnt_present_flag;
+};
+
+void h264_sps_parse(struct h264_stream_t *s, struct h264_SPS_t *sps);
+void h264_pps_parse(struct h264_stream_t *s, struct h264_PPS_t *pps);
+
+void h264_sps_info(struct h264_SPS_t *sps);
+void h264_pps_info(struct h264_PPS_t *pps);
+
+#endif //_H264_PARSE_H
diff --git a/drivers/amvdec_ports/decoder/h264_stream.c b/drivers/amvdec_ports/decoder/h264_stream.c
new file mode 100644
index 0000000..3061568
--- a/dev/null
+++ b/drivers/amvdec_ports/decoder/h264_stream.c
@@ -0,0 +1,111 @@
+/*
+ * drivers/amlogic/media_modules/amvdec_ports/decoder/h264_stream.c
+ *
+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ */
+
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include "h264_stream.h"
+
+void h264_stream_set(struct h264_stream_t *s, unsigned char *data, int size)
+{
+ s->data = data;
+ s->size = size;
+ s->bit_pos = 7;
+ s->byte_pos = 0;
+}
+
+unsigned int h264_stream_read_bits(struct h264_stream_t *s, unsigned int n)
+{
+ unsigned int ret = 0;
+ unsigned char b = 0;
+ int i;
+
+ if (n == 0)
+ return 0;
+
+ for (i = 0; i < n; ++i) {
+ if (h264_stream_bits_remaining(s) == 0)
+ ret <<= n - i - 1;
+
+ b = s->data[s->byte_pos];
+ if (n - i <= 32)
+ ret = ret << 1 | BITAT(b, s->bit_pos);
+
+ if (s->bit_pos == 0) {
+ s->bit_pos = 7;
+ s->byte_pos++;
+ } else
+ s->bit_pos--;
+ }
+
+ return ret;
+}
+
+unsigned int h264_stream_peek_bits(struct h264_stream_t *s, unsigned int n)
+{
+ int prev_bit_pos = s->bit_pos;
+ int prev_byte_pos = s->byte_pos;
+ unsigned int ret = h264_stream_read_bits(s, n);
+
+ s->bit_pos = prev_bit_pos;
+ s->byte_pos = prev_byte_pos;
+
+ return ret;
+}
+
+unsigned int h264_stream_read_bytes(struct h264_stream_t *s, unsigned int n)
+{
+ unsigned int ret = 0;
+ int i;
+
+ if (n == 0)
+ return 0;
+
+ for (i = 0; i < n; ++i) {
+ if (h264_stream_bytes_remaining(s) == 0) {
+ ret <<= (n - i - 1) * 8;
+ break;
+ }
+
+ if (n - i <= 4)
+ ret = ret << 8 | s->data[s->byte_pos];
+
+ s->byte_pos++;
+ }
+
+ return ret;
+}
+
+unsigned int h264_stream_peek_bytes(struct h264_stream_t *s, unsigned int n)
+{
+ int prev_byte_pos = s->byte_pos;
+ unsigned int ret = h264_stream_read_bytes(s, n);
+
+ s->byte_pos = prev_byte_pos;
+
+ return ret;
+}
+
+int h264_stream_bits_remaining(struct h264_stream_t *s)
+{
+ return (s->size - s->byte_pos) * 8 + s->bit_pos;
+}
+
+int h264_stream_bytes_remaining(struct h264_stream_t *s)
+{
+ return s->size - s->byte_pos;
+}
+
diff --git a/drivers/amvdec_ports/decoder/h264_stream.h b/drivers/amvdec_ports/decoder/h264_stream.h
new file mode 100644
index 0000000..d6d2eac
--- a/dev/null
+++ b/drivers/amvdec_ports/decoder/h264_stream.h
@@ -0,0 +1,39 @@
+/*
+ * drivers/amlogic/media_modules/amvdec_ports/decoder/h264_stream.h
+ *
+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 _H264_STREAM_H
+#define _H264_STREAM_H
+
+#include "utils.h"
+
+struct h264_stream_t {
+ unsigned char *data;
+ unsigned int size;
+ int bit_pos;
+ int byte_pos;
+};
+
+void h264_stream_set(struct h264_stream_t *s, unsigned char *data, int size);
+unsigned int h264_stream_read_bits(struct h264_stream_t *s, unsigned int n);
+unsigned int h264_stream_peek_bits(struct h264_stream_t *s, unsigned int n);
+unsigned int h264_stream_read_bytes(struct h264_stream_t *s, unsigned int n);
+unsigned int h264_stream_peek_bytes(struct h264_stream_t *s, unsigned int n);
+int h264_stream_bits_remaining(struct h264_stream_t *s);
+int h264_stream_bytes_remaining(struct h264_stream_t *s);
+
+#endif //_H264_STREAM_H
+
diff --git a/drivers/common/chips/decoder_cpu_ver_info.c b/drivers/common/chips/decoder_cpu_ver_info.c
index 7818a21..830b89d 100644
--- a/drivers/common/chips/decoder_cpu_ver_info.c
+++ b/drivers/common/chips/decoder_cpu_ver_info.c
@@ -57,9 +57,10 @@ static enum AM_MESON_CPU_MAJOR_ID cpu_ver_info[AM_MESON_CPU_MAJOR_ID_MAX - MAJOR
AM_MESON_CPU_MAJOR_ID_G12B,
AM_MESON_CPU_MAJOR_ID_GXLX2,
AM_MESON_CPU_MAJOR_ID_SM1,
- AM_MESON_CPU_MAJOR_ID_RES_0x2c,
- AM_MESON_CPU_MAJOR_ID_RES_0x2d,
+ AM_MESON_CPU_MAJOR_ID_A1,
+ AM_MESON_CPU_MAJOR_ID_TXLX2,
AM_MESON_CPU_MAJOR_ID_TL1,
+ AM_MESON_CPU_MAJOR_ID_C1,
AM_MESON_CPU_MAJOR_ID_TM2,
};
@@ -107,6 +108,10 @@ static const struct of_device_id cpu_ver_of_match[] = {
.compatible = "amlogic, cpu-major-id-tm2",
.data = &cpu_ver_info[AM_MESON_CPU_MAJOR_ID_TM2 - MAJOR_ID_START],
},
+ {
+ .compatible = "amlogic, cpu-major-id-c1",
+ .data = &cpu_ver_info[AM_MESON_CPU_MAJOR_ID_C1 - MAJOR_ID_START],
+ },
{},
};
diff --git a/drivers/common/chips/decoder_cpu_ver_info.h b/drivers/common/chips/decoder_cpu_ver_info.h
index 494f5f6..8889c65 100644
--- a/drivers/common/chips/decoder_cpu_ver_info.h
+++ b/drivers/common/chips/decoder_cpu_ver_info.h
@@ -19,6 +19,7 @@
*/
#ifndef DECODER_CPU_VER_INFO_H
#define DECODER_CPU_VER_INFO_H
+#include <linux/amlogic/cpu_version.h>
enum AM_MESON_CPU_MAJOR_ID
{
@@ -44,12 +45,79 @@ enum AM_MESON_CPU_MAJOR_ID
AM_MESON_CPU_MAJOR_ID_G12B = 0x29,
AM_MESON_CPU_MAJOR_ID_GXLX2 = 0x2a,
AM_MESON_CPU_MAJOR_ID_SM1 = 0x2b,
- AM_MESON_CPU_MAJOR_ID_RES_0x2c,
- AM_MESON_CPU_MAJOR_ID_RES_0x2d,
+ AM_MESON_CPU_MAJOR_ID_A1 = 0x2c,
+ AM_MESON_CPU_MAJOR_ID_TXLX2 = 0x2d,
AM_MESON_CPU_MAJOR_ID_TL1 = 0x2e,
AM_MESON_CPU_MAJOR_ID_TM2 = 0x2f,
+ AM_MESON_CPU_MAJOR_ID_C1 = 0x30,
AM_MESON_CPU_MAJOR_ID_MAX,
};
enum AM_MESON_CPU_MAJOR_ID get_cpu_major_id(void);
+
+/* porting cpu version from kernel */
+#define MESON_CPU_VERSION_LVL_MAJOR 0
+#define MESON_CPU_VERSION_LVL_MINOR 1
+#define MESON_CPU_VERSION_LVL_PACK 2
+#define MESON_CPU_VERSION_LVL_MISC 3
+#define MESON_CPU_VERSION_LVL_MAX MESON_CPU_VERSION_LVL_MISC
+
+#ifdef CONFIG_AMLOGIC_CPU_VERSION
+unsigned char get_meson_cpu_version(int level);
+int arch_big_cpu(int cpu);
+#else
+unsigned char get_meson_cpu_version(int level);
+#if 0
+{
+ return -1;
+}
+#endif
+
+static inline int arch_big_cpu(int cpu)
+{
+ return 0;
+}
+#endif
+static inline bool is_meson_rev_a(void);
+static inline bool is_meson_rev_b(void);
+static inline bool is_meson_rev_c(void);
+static inline bool is_meson_gxl_package_805X(void);
+
+#if 0
+static inline u32 get_cpu_package(void)
+{
+ unsigned int pk;
+
+ pk = get_meson_cpu_version(MESON_CPU_VERSION_LVL_PACK) & 0xF0;
+ return pk;
+}
+
+static inline bool package_id_is(unsigned int id)
+{
+ return get_cpu_package() == id;
+}
+#endif
+
+#if 0
+static inline bool is_meson_rev_a(void)
+{
+ return (get_meson_cpu_version(MESON_CPU_VERSION_LVL_MINOR) == 0xA);
+}
+
+static inline bool is_meson_rev_b(void)
+{
+ return (get_meson_cpu_version(MESON_CPU_VERSION_LVL_MINOR) == 0xB);
+}
+
+static inline bool is_meson_rev_c(void)
+{
+ return (get_meson_cpu_version(MESON_CPU_VERSION_LVL_MINOR) == 0xC);
+}
+
+static inline bool is_meson_gxl_package_805X(void)
+{
+ return is_meson_gxl_cpu() && package_id_is(0x30);
+}
+#endif
+
#endif
diff --git a/drivers/common/firmware/firmware_drv.c b/drivers/common/firmware/firmware_drv.c
index fa21f0c..e0ee76e 100644
--- a/drivers/common/firmware/firmware_drv.c
+++ b/drivers/common/firmware/firmware_drv.c
@@ -28,13 +28,15 @@
#include <linux/amlogic/cpu_version.h>
#include "../../stream_input/amports/amports_priv.h"
#include "../../frame_provider/decoder/utils/vdec.h"
+#include "../../frame_provider/decoder/utils/firmware.h"
#include "firmware_priv.h"
#include "../chips/chips.h"
#include <linux/string.h>
#include <linux/amlogic/media/utils/log.h>
#include <linux/firmware.h>
#include <linux/amlogic/tee.h>
-#include <linux/amlogic/major.h>
+//#include <linux/amlogic/major.h> //if kernel is 4.9 then use this one
+#include <uapi/linux/major.h>
#include <linux/cdev.h>
#include <linux/crc32.h>
#include "../chips/decoder_cpu_ver_info.h"
@@ -371,7 +373,8 @@ static ssize_t info_show(struct class *class,
secs = info->data->head.time
- sys_tz.tz_minuteswest * 60;
- time_to_tm(secs, 0, &tm);
+ //time_to_tm(secs, 0, &tm);//kernel4.9
+ time64_to_tm(secs, 0, &tm);
pr_info("%s %-16s, %02d:%02d:%02d %d/%d/%ld, %s %-8s, %s %-8s, %s %s\n",
"fmt:", info->data->head.format,
@@ -442,7 +445,8 @@ static int fw_info_fill(void)
return ret;
}
-static int fw_data_check_sum(struct firmware_s *fw)
+//static int fw_data_check_sum(struct firmware_s *fw) //kernel4.9
+static int fw_data_check_sum(struct firmware_data_s *fw)
{
unsigned int crc;
@@ -453,7 +457,8 @@ static int fw_data_check_sum(struct firmware_s *fw)
return fw->head.checksum != (crc ^ ~0U) ? 0 : 1;
}
-static int fw_data_filter(struct firmware_s *fw,
+//static int fw_data_filter(struct firmware_s *fw,//kernel4.9
+static int fw_data_filter(struct firmware_data_s *fw,
struct fw_info_s *fw_info)
{
struct fw_mgr_s *mgr = g_mgr;
@@ -508,59 +513,10 @@ static int fw_data_filter(struct firmware_s *fw,
return 0;
}
-static int fw_replace_dup_data(char *buf)
-{
- int ret = 0;
- struct fw_mgr_s *mgr = g_mgr;
- struct package_s *pkg =
- (struct package_s *) buf;
- struct package_info_s *pinfo =
- (struct package_info_s *) pkg->data;
- struct fw_info_s *info = NULL;
- char *pdata = pkg->data;
- int try_cnt = TRY_PARSE_MAX;
-
- do {
- if (!pinfo->head.length)
- break;
- list_for_each_entry(info, &mgr->fw_head, node) {
- struct firmware_s *comp = NULL;
- struct firmware_s *data = NULL;
- int len = 0;
-
- comp = (struct firmware_s *)pinfo->data;
- if (comp->head.duplicate)
- break;
-
- if (!info->data->head.duplicate ||
- comp->head.checksum !=
- info->data->head.checksum)
- continue;
-
- len = pinfo->head.length;
- data = kzalloc(len, GFP_KERNEL);
- if (data == NULL) {
- ret = -ENOMEM;
- goto out;
- }
-
- memcpy(data, pinfo->data, len);
- memcpy(data, info->data, sizeof(*data));
-
- kfree(info->data);
- info->data = data;
- }
- pdata += (pinfo->head.length + sizeof(*pinfo));
- pinfo = (struct package_info_s *)pdata;
- } while (try_cnt--);
-out:
- return ret;
-}
-
static int fw_check_pack_version(char *buf)
{
struct package_s *pack = NULL;
- int major, minor, major_fw, minor_fw;
+ int major, minor, major_fw, minor_fw, ver = 0;
int ret;
pack = (struct package_s *) buf;
@@ -568,6 +524,11 @@ static int fw_check_pack_version(char *buf)
if (ret != 2)
return -1;
+ ver = (major << 16 | minor);
+
+ if (debug)
+ pr_info("the package has %d fws totally.\n", pack->head.total);
+
major_fw = (pack->head.version >> 16) & 0xff;
minor_fw = pack->head.version & 0xff;
@@ -577,16 +538,9 @@ static int fw_check_pack_version(char *buf)
return -1;
}
- if (minor < minor_fw) {
- pr_info("The fw driver version (v%d.%d) is lower than the pkg version (v%d.%d).\n",
- major, minor, major_fw, minor_fw);
- pr_info("The driver version is too low that may affect the work please update asap.\n");
- }
-
- if (debug) {
- pr_info("The package has %d fws totally.\n", pack->head.total);
- pr_info("The driver ver is v%d.%d\n", major, minor);
- pr_info("The firmware ver is v%d.%d\n", major_fw, minor_fw);
+ if (ver != pack->head.version) {
+ pr_info("the fw pack ver v%d.%d is too lower.\n", major_fw, minor_fw);
+ pr_info("it may work abnormally so need to be update in time.\n");
}
return 0;
@@ -598,10 +552,11 @@ static int fw_package_parse(struct fw_files_s *files,
int ret = 0;
struct package_info_s *pack_info;
struct fw_info_s *info;
- struct firmware_s *data;
+// struct firmware_s *data;//kernel4.9
+ struct firmware_data_s *data;
char *pack_data;
int info_len, len;
- int try_cnt = TRY_PARSE_MAX;
+ int try_cnt = 100;
char *path = __getname();
if (path == NULL)
@@ -648,8 +603,7 @@ static int fw_package_parse(struct fw_files_s *files,
pack_data += (pack_info->head.length + info_len);
pack_info = (struct package_info_s *)pack_data;
- if (!data->head.duplicate &&
- !fw_data_check_sum(data)) {
+ if (!fw_data_check_sum(data)) {
pr_info("check sum fail !\n");
kfree(data);
kfree(info);
@@ -666,10 +620,6 @@ static int fw_package_parse(struct fw_files_s *files,
fw_add_info(info);
} while (try_cnt--);
- /* process the fw of dup attribute. */
- ret = fw_replace_dup_data(buf);
- if (ret)
- pr_err("replace dup fw failed.\n");
out:
__putname(path);
@@ -901,6 +851,7 @@ static ssize_t debug_store(struct class *cls,
return count;
}
+#if 0 //kernel4.9
static struct class_attribute fw_class_attrs[] = {
__ATTR(info, 0664, info_show, info_store),
__ATTR(reload, 0664, reload_show, reload_store),
@@ -912,7 +863,26 @@ static struct class fw_class = {
.name = CLASS_NAME,
.class_attrs = fw_class_attrs,
};
+#else //below is for kernel 4.19 and 5.4
+static CLASS_ATTR_RW(info);
+static CLASS_ATTR_RW(reload);
+static CLASS_ATTR_RW(debug);
+
+static struct attribute *fw_class_attrs[] = {
+ &class_attr_info.attr,
+ &class_attr_reload.attr,
+ &class_attr_debug.attr,
+ NULL
+};
+ATTRIBUTE_GROUPS(fw_class);
+
+static struct class fw_class = {
+ .name = CLASS_NAME,
+ .class_groups = fw_class_groups,
+};
+
+#endif
static int fw_driver_init(void)
{
int ret = -1;
diff --git a/drivers/common/firmware/firmware_priv.h b/drivers/common/firmware/firmware_priv.h
index 410745b..d3af54d 100644
--- a/drivers/common/firmware/firmware_priv.h
+++ b/drivers/common/firmware/firmware_priv.h
@@ -50,7 +50,7 @@ struct fw_info_s {
char src_from[32];
int file_type;
unsigned int format;
- struct firmware_s *data;
+ struct firmware_data_s *data;
};
struct fw_head_s {
@@ -71,7 +71,7 @@ struct fw_head_s {
char reserved[92];
};
-struct firmware_s {
+struct firmware_data_s {
union {
struct fw_head_s head;
char buf[512];
diff --git a/drivers/common/firmware/firmware_type.c b/drivers/common/firmware/firmware_type.c
index e781a51..609ff6e 100644
--- a/drivers/common/firmware/firmware_type.c
+++ b/drivers/common/firmware/firmware_type.c
@@ -39,7 +39,6 @@ static const struct format_name_s format_name[] = {
{VIDEO_DEC_AVS, "avs"},
{VIDEO_DEC_AVS_GXM, "avs_gxm"},
{VIDEO_DEC_AVS_NOCABAC, "avs_no_cabac"},
- {VIDEO_DEC_AVS_MULTI, "avs_multi"},
{VIDEO_DEC_H264, "h264"},
{VIDEO_DEC_H264_MVC, "h264_mvc"},
{VIDEO_DEC_H264_MVC_GXM, "h264_mvc_gxm"},
diff --git a/drivers/common/media_clock/clk/clk.h b/drivers/common/media_clock/clk/clk.h
index 9e6c025..c777aa1 100644
--- a/drivers/common/media_clock/clk/clk.h
+++ b/drivers/common/media_clock/clk/clk.h
@@ -130,7 +130,7 @@ static int __init vdec_init_clk(void)
#endif
#ifdef VDEC_HAS_HEVC
register_vdec_clk_mgr(cpus, VDEC_HEVC, &vdec_hevc_clk_mgr);
- if (get_cpu_major_id() >= MESON_CPU_MAJOR_ID_G12A)
+ if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A)
register_vdec_clk_mgr(cpus, VDEC_HEVCB, &vdec_hevc_back_clk_mgr);
#endif
#ifdef VDEC_HAS_VDEC_HCODEC
diff --git a/drivers/common/media_clock/clk/clkg12.c b/drivers/common/media_clock/clk/clkg12.c
index f045bd3..20f2482 100644
--- a/drivers/common/media_clock/clk/clkg12.c
+++ b/drivers/common/media_clock/clk/clkg12.c
@@ -500,12 +500,12 @@ static int vdec_clock_init(void)
{
gp_pll_user_vdec = gp_pll_user_register("vdec", 0,
gp_pll_user_cb_vdec);
- if (get_cpu_major_id() >= MESON_CPU_MAJOR_ID_GXL)
+ if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_GXL)
is_gp0_div2 = false;
else
is_gp0_div2 = true;
- if (get_cpu_major_id() >= MESON_CPU_MAJOR_ID_GXL) {
+ if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_GXL) {
pr_info("used fix clk for vdec clk source!\n");
//update_vdec_clk_config_settings(1);
}
@@ -780,7 +780,7 @@ static int hevc_back_clock_set(int clk)
clk = hevcb_frq;
}
- if (get_cpu_major_id() >= MESON_CPU_MAJOR_ID_TXLX) {
+ if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_TXLX) {
if ((READ_EFUSE_REG(EFUSE_LIC1) >> 28 & 0x1) && clk > 333) {
pr_info("The hevcb clock limit to 333MHz.\n");
clk = 333;
diff --git a/drivers/common/media_clock/switch/amports_gate.c b/drivers/common/media_clock/switch/amports_gate.c
index beaea53..4f780b9 100644
--- a/drivers/common/media_clock/switch/amports_gate.c
+++ b/drivers/common/media_clock/switch/amports_gate.c
@@ -96,11 +96,11 @@ int amports_clock_gate_init(struct device *dev)
gates[i].clk = devm_clk_get(dev, gates[i].name);
if (IS_ERR_OR_NULL(gates[i].clk)) {
gates[i].clk = NULL;
- pr_info("get gate %s control failed %p\n",
+ pr_info("get gate %s control failed %px\n",
gates[i].name,
gates[i].clk);
} else {
- pr_info("get gate %s control ok %p\n",
+ pr_info("get gate %s control ok %px\n",
gates[i].name,
gates[i].clk);
}
diff --git a/drivers/frame_provider/decoder/Makefile b/drivers/frame_provider/decoder/Makefile
index 6511f25..12121b4 100644
--- a/drivers/frame_provider/decoder/Makefile
+++ b/drivers/frame_provider/decoder/Makefile
@@ -10,4 +10,3 @@ obj-y += mjpeg/
obj-y += real/
obj-y += avs/
obj-y += avs2/
-obj-y += avs_multi/
diff --git a/drivers/frame_provider/decoder/avs/avs.c b/drivers/frame_provider/decoder/avs/avs.c
index b97cb33..5e90117 100644
--- a/drivers/frame_provider/decoder/avs/avs.c
+++ b/drivers/frame_provider/decoder/avs/avs.c
@@ -43,8 +43,8 @@
#include "../utils/decoder_bmmu_box.h"
#include "../utils/firmware.h"
#include "../../../common/chips/decoder_cpu_ver_info.h"
-#include <linux/amlogic/tee.h>
-
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
#define DRIVER_NAME "amvdec_avs"
#define MODULE_NAME "amvdec_avs"
@@ -160,7 +160,6 @@ static u32 canvas_base = 128;
int canvas_num = 3;
#endif
-
static struct vframe_s vfpool[VF_POOL_SIZE];
/*static struct vframe_s vfpool2[VF_POOL_SIZE];*/
static struct vframe_s *cur_vfpool;
@@ -644,6 +643,7 @@ static void vavs_isr(void)
decoder_bmmu_box_get_mem_handle(
mm_blk_handle,
buffer_index);
+
kfifo_put(&display_q,
(const struct vframe_s *)vf);
ATRACE_COUNTER(MODULE_NAME, vf->pts);
@@ -726,7 +726,6 @@ static void vavs_isr(void)
mm_blk_handle,
buffer_index);
decoder_do_frame_check(NULL, vf);
-
kfifo_put(&display_q,
(const struct vframe_s *)vf);
ATRACE_COUNTER(MODULE_NAME, vf->pts);
@@ -1179,20 +1178,20 @@ static void vavs_local_init(bool is_reset)
#endif
if (!is_reset) {
- INIT_KFIFO(display_q);
- INIT_KFIFO(recycle_q);
- INIT_KFIFO(newframe_q);
+ INIT_KFIFO(display_q);
+ INIT_KFIFO(recycle_q);
+ INIT_KFIFO(newframe_q);
- for (i = 0; i < VF_POOL_SIZE; i++) {
- const struct vframe_s *vf = &vfpool[i];
+ for (i = 0; i < VF_POOL_SIZE; i++) {
+ const struct vframe_s *vf = &vfpool[i];
- vfpool[i].index = vf_buf_num;
- vfpool[i].bufWidth = 1920;
- kfifo_put(&newframe_q, vf);
- }
+ vfpool[i].index = vf_buf_num;
+ vfpool[i].bufWidth = 1920;
+ kfifo_put(&newframe_q, vf);
+ }
- for (i = 0; i < vf_buf_num; i++)
- vfbuf_use[i] = 0;
+ for (i = 0; i < vf_buf_num; i++)
+ vfbuf_use[i] = 0;
}
cur_vfpool = vfpool;
@@ -1323,10 +1322,8 @@ static void avs_set_clk(struct work_struct *work)
}
}
-static void vavs_put_timer_func(unsigned long arg)
+static void vavs_put_timer_func(struct timer_list *timer)
{
- struct timer_list *timer = (struct timer_list *)arg;
-
#ifndef HANDLE_AVS_IRQ
vavs_isr();
#endif
@@ -1414,7 +1411,7 @@ static void vavs_put_timer_func(unsigned long arg)
if (frame_dur > 0 && saved_resolution !=
frame_width * frame_height * (96000 / frame_dur))
- schedule_work(&set_clk_work);
+ schedule_work(&set_clk_work);
timer->expires = jiffies + PUT_INTERVAL;
@@ -1543,7 +1540,6 @@ static s32 vavs_init(void)
return -ENOMEM;
pr_info("vavs_init\n");
- init_timer(&recycle_timer);
stat |= STAT_TIMER_INIT;
@@ -1627,10 +1623,8 @@ static s32 vavs_init(void)
stat |= STAT_VF_HOOK;
- recycle_timer.data = (ulong)(&recycle_timer);
- recycle_timer.function = vavs_put_timer_func;
+ timer_setup(&recycle_timer, vavs_put_timer_func, 0);
recycle_timer.expires = jiffies + PUT_INTERVAL;
-
add_timer(&recycle_timer);
stat |= STAT_TIMER_ARM;
@@ -1811,40 +1805,20 @@ static int amvdec_avs_remove(struct platform_device *pdev)
pr_debug("total frame %d, avi_flag %d, rate %d\n", total_frame, avi_flag,
vavs_amstream_dec_info.rate);
#endif
- kfree(gvs);
- gvs = NULL;
+ kfree(gvs);
+ gvs = NULL;
cancel_work_sync(&set_clk_work);
return 0;
}
/****************************************/
-#ifdef CONFIG_PM
-static int avs_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int avs_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops avs_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(avs_suspend, avs_resume)
-};
-#endif
static struct platform_driver amvdec_avs_driver = {
.probe = amvdec_avs_probe,
.remove = amvdec_avs_remove,
.driver = {
.name = DRIVER_NAME,
-#ifdef CONFIG_PM
- .pm = &avs_pm_ops,
-#endif
}
};
diff --git a/drivers/frame_provider/decoder/avs2/avs2_bufmgr.c b/drivers/frame_provider/decoder/avs2/avs2_bufmgr.c
index 3da87e4..de9a3d2 100644
--- a/drivers/frame_provider/decoder/avs2/avs2_bufmgr.c
+++ b/drivers/frame_provider/decoder/avs2/avs2_bufmgr.c
@@ -39,7 +39,9 @@
#include <linux/dma-mapping.h>
#include <linux/dma-contiguous.h>
#include <linux/slab.h>
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
+#include <linux/sched/clock.h>
#include "../../../stream_input/amports/amports_priv.h"
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include "../utils/decoder_mmu_box.h"
diff --git a/drivers/frame_provider/decoder/avs2/vavs2.c b/drivers/frame_provider/decoder/avs2/vavs2.c
index 938312e..b3aa836 100644
--- a/drivers/frame_provider/decoder/avs2/vavs2.c
+++ b/drivers/frame_provider/decoder/avs2/vavs2.c
@@ -37,7 +37,9 @@
#include <linux/dma-mapping.h>
#include <linux/dma-contiguous.h>
#include <linux/slab.h>
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
+#include <linux/sched/clock.h>
#include "../../../stream_input/amports/amports_priv.h"
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include "../utils/decoder_mmu_box.h"
@@ -55,7 +57,6 @@
#include "../utils/config_parser.h"
#include "../utils/firmware.h"
#include "../../../common/chips/decoder_cpu_ver_info.h"
-#include <linux/amlogic/tee.h>
#define I_ONLY_SUPPORT
@@ -67,8 +68,6 @@
#define HEVC_SHIFT_LENGTH_PROTECT 0x313a
#define HEVC_MPRED_CTRL9 0x325b
#define HEVC_DBLK_CFGD 0x350d
-
-
#define HEVC_CM_HEADER_START_ADDR 0x3628
#define HEVC_DBLK_CFGB 0x350b
#define HEVCD_MPP_ANC2AXI_TBL_DATA 0x3464
@@ -297,7 +296,7 @@ static int vavs2_stop(struct AVS2Decoder_s *dec);
static s32 vavs2_init(struct vdec_s *vdec);
static void vavs2_prot_init(struct AVS2Decoder_s *dec);
static int vavs2_local_init(struct AVS2Decoder_s *dec);
-static void vavs2_put_timer_func(unsigned long arg);
+static void vavs2_put_timer_func(struct timer_list *timer);
static void dump_data(struct AVS2Decoder_s *dec, int size);
static unsigned char get_data_check_sum
(struct AVS2Decoder_s *dec, int size);
@@ -3776,10 +3775,6 @@ static void config_avs2_clk_forced_on(void)
}
#endif
-
-
-
-
static struct AVS2Decoder_s gAVS2Decoder;
static void avs2_local_uninit(struct AVS2Decoder_s *dec)
@@ -3921,7 +3916,17 @@ static int avs2_local_init(struct AVS2Decoder_s *dec)
avs2_print(dec, AVS2_DBG_BUFMGR,
"%s, lmem_phy_addr %x\n",
__func__, (u32)dec->lmem_phy_addr);
-
+/*
+ dec->lmem_phy_addr = dma_map_single(amports_get_dma_device(),
+ dec->lmem_addr, LMEM_BUF_SIZE, DMA_BIDIRECTIONAL);
+ if (dma_mapping_error(amports_get_dma_device(),
+ dec->lmem_phy_addr)) {
+ pr_err("%s: failed to map lmem buffer\n", __func__);
+ kfree(dec->lmem_addr);
+ dec->lmem_addr = NULL;
+ return -1;
+ }
+*/
dec->lmem_ptr = dec->lmem_addr;
@@ -3934,6 +3939,15 @@ static int avs2_local_init(struct AVS2Decoder_s *dec)
return -1;
}
memset(dec->frame_mmu_map_addr, 0, get_frame_mmu_map_size(dec));
+/* dec->frame_mmu_map_phy_addr = dma_map_single(amports_get_dma_device(),
+ dec->frame_mmu_map_addr, FRAME_MMU_MAP_SIZE, DMA_BIDIRECTIONAL);
+ if (dma_mapping_error(amports_get_dma_device(),
+ dec->frame_mmu_map_phy_addr)) {
+ pr_err("%s: failed to map count_buffer\n", __func__);
+ kfree(dec->frame_mmu_map_addr);
+ dec->frame_mmu_map_addr = NULL;
+ return -1;
+ }*/
#endif
ret = 0;
@@ -4550,7 +4564,6 @@ static inline void dec_update_gvs(struct AVS2Decoder_s *dec)
dec->gvs->status = dec->stat | dec->fatal_error;
}
-
static int avs2_prepare_display_buf(struct AVS2Decoder_s *dec)
{
#ifndef NO_DISPLAY
@@ -5904,10 +5917,10 @@ static irqreturn_t vavs2_isr(int irq, void *data)
return IRQ_WAKE_THREAD;
}
-static void vavs2_put_timer_func(unsigned long arg)
+static void vavs2_put_timer_func(struct timer_list *timer)
{
- struct AVS2Decoder_s *dec = (struct AVS2Decoder_s *)arg;
- struct timer_list *timer = &dec->timer;
+ struct AVS2Decoder_s *dec = container_of(timer,
+ struct AVS2Decoder_s, timer);
uint8_t empty_flag;
unsigned int buf_level;
@@ -6025,6 +6038,7 @@ static void vavs2_put_timer_func(unsigned long arg)
}
if (debug & AVS2_DBG_DUMP_RPM_BUF) {
int i;
+
pr_info("RPM:\n");
for (i = 0; i < RPM_BUF_SIZE; i += 4) {
int ii;
@@ -6041,6 +6055,7 @@ static void vavs2_put_timer_func(unsigned long arg)
}
if (debug & AVS2_DBG_DUMP_LMEM_BUF) {
int i;
+
pr_info("LMEM:\n");
for (i = 0; i < LMEM_BUF_SIZE; i += 4) {
int ii;
@@ -6312,7 +6327,8 @@ static s32 vavs2_init(struct vdec_s *vdec)
int fw_size = 0x1000 * 16;
struct firmware_s *fw = NULL;
struct AVS2Decoder_s *dec = (struct AVS2Decoder_s *)vdec->private;
- init_timer(&dec->timer);
+
+ timer_setup(&dec->timer, vavs2_put_timer_func, 0);
dec->stat |= STAT_TIMER_INIT;
if (vavs2_local_init(dec) < 0)
@@ -6334,8 +6350,6 @@ static s32 vavs2_init(struct vdec_s *vdec)
fw->len = fw_size;
if (dec->m_ins_flag) {
- dec->timer.data = (ulong) dec;
- dec->timer.function = vavs2_put_timer_func;
dec->timer.expires = jiffies + PUT_INTERVAL;
/*add_timer(&dec->timer);
@@ -6348,7 +6362,9 @@ static s32 vavs2_init(struct vdec_s *vdec)
return 0;
}
+
amhevc_enable();
+
ret = amhevc_loadmc_ex(VFORMAT_AVS2, NULL, fw->data);
if (ret < 0) {
amhevc_disable();
@@ -6391,11 +6407,7 @@ static s32 vavs2_init(struct vdec_s *vdec)
}
dec->stat |= STAT_VF_HOOK;
- dec->timer.data = (ulong)dec;
- dec->timer.function = vavs2_put_timer_func;
dec->timer.expires = jiffies + PUT_INTERVAL;
-
-
add_timer(&dec->timer);
dec->stat |= STAT_TIMER_ARM;
@@ -6518,15 +6530,25 @@ static int amvdec_avs2_mmu_init(struct AVS2Decoder_s *dec)
static int amvdec_avs2_probe(struct platform_device *pdev)
{
struct vdec_s *pdata = *(struct vdec_s **)pdev->dev.platform_data;
- struct BUF_s BUF[MAX_BUF_NUM];
+ /*struct BUF_s BUF[MAX_BUF_NUM];*/
struct AVS2Decoder_s *dec = &gAVS2Decoder;
int ret;
pr_info("%s\n", __func__);
+
+ dec = vzalloc(sizeof(struct AVS2Decoder_s));
+ if (!dec)
+ return -ENOMEM;
+
+ pdata->private = dec;
+ platform_set_drvdata(pdev, pdata);
+
mutex_lock(&vavs2_mutex);
- memcpy(&BUF[0], &dec->m_BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
- memset(dec, 0, sizeof(struct AVS2Decoder_s));
- memcpy(&dec->m_BUF[0], &BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
+ /*
+ *memcpy(&BUF[0], &dec->m_BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
+ *memset(dec, 0, sizeof(struct AVS2Decoder_s));
+ *memcpy(&dec->m_BUF[0], &BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
+ */
dec->init_flag = 0;
dec->first_sc_checked = 0;
@@ -6625,32 +6647,16 @@ static int amvdec_avs2_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int avs2_suspend(struct device *dev)
-{
- amhevc_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int avs2_resume(struct device *dev)
-{
- amhevc_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops avs2_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(avs2_suspend, avs2_resume)
-};
-#endif
static struct platform_driver amvdec_avs2_driver = {
.probe = amvdec_avs2_probe,
.remove = amvdec_avs2_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &avs2_pm_ops,
+ .suspend = amhevc_suspend,
+ .resume = amhevc_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
@@ -7279,9 +7285,9 @@ static int ammvdec_avs2_probe(struct platform_device *pdev)
int config_val;
struct vframe_content_light_level_s content_light_level;
struct vframe_master_display_colour_s vf_dp;
-
- struct BUF_s BUF[MAX_BUF_NUM];
+ /*struct BUF_s BUF[MAX_BUF_NUM];*/
struct AVS2Decoder_s *dec = NULL;
+
pr_info("%s\n", __func__);
if (pdata == NULL) {
pr_info("\nammvdec_avs2 memory resource undefined.\n");
@@ -7315,9 +7321,11 @@ static int ammvdec_avs2_probe(struct platform_device *pdev)
pdata->threaded_irq_handler = avs2_threaded_irq_cb;
pdata->dump_state = avs2_dump_state;
- memcpy(&BUF[0], &dec->m_BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
- memset(dec, 0, sizeof(struct AVS2Decoder_s));
- memcpy(&dec->m_BUF[0], &BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
+ /*
+ * memcpy(&BUF[0], &dec->m_BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
+ * memset(dec, 0, sizeof(struct AVS2Decoder_s));
+ * memcpy(&dec->m_BUF[0], &BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
+ */
dec->index = pdev->id;
dec->m_ins_flag = 1;
@@ -7512,11 +7520,12 @@ static int ammvdec_avs2_remove(struct platform_device *pdev)
static struct platform_driver ammvdec_avs2_driver = {
.probe = ammvdec_avs2_probe,
.remove = ammvdec_avs2_remove,
- .driver = {
- .name = MULTI_DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &avs2_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = MULTI_DRIVER_NAME,
}
};
#endif
diff --git a/drivers/frame_provider/decoder/h264/vh264.c b/drivers/frame_provider/decoder/h264/vh264.c
index 3470147..2d2bc80 100644
--- a/drivers/frame_provider/decoder/h264/vh264.c
+++ b/drivers/frame_provider/decoder/h264/vh264.c
@@ -23,7 +23,6 @@
#include <linux/timer.h>
#include <linux/kfifo.h>
#include <linux/platform_device.h>
-
#include <linux/amlogic/media/utils/amstream.h>
#include <linux/amlogic/media/frame_sync/ptsserv.h>
#include <linux/amlogic/media/vfm/vframe.h>
@@ -38,7 +37,6 @@
#include <linux/slab.h>
#include "../../../stream_input/amports/amports_priv.h"
#include <linux/amlogic/media/canvas/canvas.h>
-
#include "../utils/vdec.h"
#include <linux/amlogic/media/utils/vdec_reg.h>
#include "../utils/amvdec.h"
@@ -46,19 +44,17 @@
#include "../../../stream_input/parser/streambuf.h"
#include <linux/delay.h>
#include <linux/amlogic/media/video_sink/video.h>
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
#include <linux/amlogic/media/ge2d/ge2d.h>
#include "../utils/decoder_mmu_box.h"
#include "../utils/decoder_bmmu_box.h"
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include <linux/amlogic/media/codec_mm/configs.h>
#include "../utils/firmware.h"
-#include <linux/amlogic/tee.h>
#include "../../../common/chips/decoder_cpu_ver_info.h"
#include <linux/uaccess.h>
-
-
#define DRIVER_NAME "amvdec_h264"
#define MODULE_NAME "amvdec_h264"
#define MEM_NAME "codec_264"
@@ -160,7 +156,7 @@ static int vh264_event_cb(int type, void *data, void *private_data);
static void vh264_prot_init(void);
static int vh264_local_init(void);
-static void vh264_put_timer_func(unsigned long arg);
+static void vh264_put_timer_func(struct timer_list *timer);
static void stream_switching_done(void);
static const char vh264_dec_id[] = "vh264-dev";
@@ -253,14 +249,6 @@ static u32 bad_block_scale;
#endif
static u32 enable_userdata_debug;
-/* if not define, must clear AV_SCRATCH_J in isr when
- * ITU_T35 code enabled in ucode, otherwise may fatal
- * error repeatly.
- */
-//#define ENABLE_SEI_ITU_T35
-
-
-
static unsigned int enable_switch_fense = 1;
#define EN_SWITCH_FENCE() (enable_switch_fense && !is_4k)
static struct vframe_qos_s s_vframe_qos;
@@ -2599,7 +2587,6 @@ static inline void h264_update_gvs(void)
gvs->ratio_control = ratio_control;
}
-
#ifdef HANDLE_H264_IRQ
static irqreturn_t vh264_isr(int irq, void *dev_id)
#else
@@ -3348,9 +3335,8 @@ static void vh264_set_clk(struct work_struct *work)
frame_width, frame_height, fps);
}
-static void vh264_put_timer_func(unsigned long arg)
+static void vh264_put_timer_func(struct timer_list *timer)
{
- struct timer_list *timer = (struct timer_list *)arg;
unsigned int wait_buffer_status;
unsigned int wait_i_pass_frames;
unsigned int reg_val;
@@ -3477,7 +3463,7 @@ static void vh264_put_timer_func(unsigned long arg)
(clk_adj_frame_count > VDEC_CLOCK_ADJUST_FRAME) &&
frame_dur > 0 && saved_resolution !=
frame_width * frame_height * (96000 / frame_dur))
- schedule_work(&set_clk_work);
+ schedule_work(&set_clk_work);
exit:
timer->expires = jiffies + PUT_INTERVAL;
@@ -3800,7 +3786,7 @@ static s32 vh264_init(void)
int firmwareloaded = 0;
/* pr_info("\nvh264_init\n"); */
- init_timer(&recycle_timer);
+ timer_setup(&recycle_timer, vh264_put_timer_func, 0);
stat |= STAT_TIMER_INIT;
@@ -3992,10 +3978,7 @@ static s32 vh264_init(void)
stat |= STAT_VF_HOOK;
- recycle_timer.data = (ulong) &recycle_timer;
- recycle_timer.function = vh264_put_timer_func;
recycle_timer.expires = jiffies + PUT_INTERVAL;
-
add_timer(&recycle_timer);
stat |= STAT_TIMER_ARM;
@@ -4351,8 +4334,6 @@ static int amvdec_h264_probe(struct platform_device *pdev)
INIT_WORK(&userdata_push_work, userdata_push_do_work);
INIT_WORK(&qos_work, qos_do_work);
-
-
atomic_set(&vh264_active, 1);
mutex_unlock(&vh264_mutex);
@@ -4395,32 +4376,16 @@ static int amvdec_h264_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int h264_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int h264_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops h264_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(h264_suspend, h264_resume)
-};
-#endif
static struct platform_driver amvdec_h264_driver = {
.probe = amvdec_h264_probe,
.remove = amvdec_h264_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &h264_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
@@ -4490,7 +4455,7 @@ module_param(dec_control, uint, 0664);
MODULE_PARM_DESC(dec_control, "\n amvdec_h264 decoder control\n");
module_param(frame_count, uint, 0664);
MODULE_PARM_DESC(frame_count,
- "\n amvdec_h264 decoded total count\n");
+ "\n amvdec_h264 decoded total count\n");
module_param(fatal_error_reset, uint, 0664);
MODULE_PARM_DESC(fatal_error_reset,
"\n amvdec_h264 decoder reset when fatal error happens\n");
diff --git a/drivers/frame_provider/decoder/h264/vh264_4k2k.c b/drivers/frame_provider/decoder/h264/vh264_4k2k.c
index 44465ad..ef6c5bd 100644
--- a/drivers/frame_provider/decoder/h264/vh264_4k2k.c
+++ b/drivers/frame_provider/decoder/h264/vh264_4k2k.c
@@ -33,15 +33,12 @@
#include <linux/dma-mapping.h>
#include <linux/dma-contiguous.h>
#include <linux/delay.h>
-
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include <linux/amlogic/media/video_sink/video_keeper.h>
#include "../utils/firmware.h"
#include <linux/amlogic/tee.h>
#include "../../../common/chips/decoder_cpu_ver_info.h"
-
-
#define MEM_NAME "codec_264_4k"
/* #include <mach/am_regs.h> */
diff --git a/drivers/frame_provider/decoder/h264/vh264_mvc.c b/drivers/frame_provider/decoder/h264/vh264_mvc.c
index 821b3c1..b7fbdf8 100644
--- a/drivers/frame_provider/decoder/h264/vh264_mvc.c
+++ b/drivers/frame_provider/decoder/h264/vh264_mvc.c
@@ -31,11 +31,8 @@
#include <linux/workqueue.h>
#include <linux/dma-mapping.h>
#include <linux/atomic.h>
-#include <linux/amlogic/tee.h>
-
#include <linux/module.h>
#include <linux/slab.h>
-
#include <linux/amlogic/media/utils/vdec_reg.h>
#include "../../../stream_input/amports/amports_priv.h"
#include "../utils/vdec.h"
@@ -45,7 +42,6 @@
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include <linux/amlogic/media/codec_mm/configs.h>
#include "../utils/firmware.h"
-#include <linux/amlogic/tee.h>
#include "../utils/config_parser.h"
#define TIME_TASK_PRINT_ENABLE 0x100
@@ -82,7 +78,7 @@ static int vh264mvc_event_cb(int type, void *data, void *private_data);
static void vh264mvc_prot_init(void);
static int vh264mvc_local_init(void);
-static void vh264mvc_put_timer_func(unsigned long arg);
+static void vh264mvc_put_timer_func(struct timer_list *timer);
static const char vh264mvc_dec_id[] = "vh264mvc-dev";
@@ -454,7 +450,7 @@ static struct vframe_s *vh264mvc_vf_get(void *op_arg)
vf->right_eye.start_y = 0;
vf->right_eye.width = vf->width;
vf->right_eye.height = vf->height;
- vf->trans_fmt = TVIN_TFMT_3D_TB;
+ //vf->trans_fmt = TVIN_TFMT_3D_TB;
if (view_mode == 2) {
vf->canvas0Addr =
@@ -1086,10 +1082,8 @@ static void vh264_mvc_set_clk(struct work_struct *work)
}
}
-static void vh264mvc_put_timer_func(unsigned long arg)
+static void vh264mvc_put_timer_func(struct timer_list *timer)
{
- struct timer_list *timer = (struct timer_list *)arg;
-
int valid_frame = 0;
if (enable_recycle == 0) {
@@ -1376,7 +1370,6 @@ static int vh264mvc_local_init(void)
max_dec_frame_buffering[1] = -1;
fill_ptr = get_ptr = put_ptr = putting_ptr = 0;
dirty_frame_num = 0;
-
for (i = 0; i < DECODE_BUFFER_NUM_MAX; i++) {
view0_vfbuf_use[i] = 0;
view1_vfbuf_use[i] = 0;
@@ -1420,11 +1413,12 @@ static s32 vh264mvc_init(void)
{
int ret = -1;
char *buf = vmalloc(0x1000 * 16);
+
if (buf == NULL)
return -ENOMEM;
pr_info("\nvh264mvc_init\n");
- init_timer(&recycle_timer);
+ timer_setup(&recycle_timer, vh264mvc_put_timer_func, 0);
stat |= STAT_TIMER_INIT;
@@ -1514,10 +1508,7 @@ static s32 vh264mvc_init(void)
stat |= STAT_VF_HOOK;
- recycle_timer.data = (ulong) (&recycle_timer);
- recycle_timer.function = vh264mvc_put_timer_func;
recycle_timer.expires = jiffies + PUT_INTERVAL;
-
add_timer(&recycle_timer);
stat |= STAT_TIMER_ARM;
@@ -1681,32 +1672,16 @@ static int amvdec_h264mvc_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int h264mvc_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int h264mvc_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops h264mvc_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(h264mvc_suspend, h264mvc_resume)
-};
-#endif
static struct platform_driver amvdec_h264mvc_driver = {
.probe = amvdec_h264mvc_probe,
.remove = amvdec_h264mvc_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &h264mvc_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
diff --git a/drivers/frame_provider/decoder/h264_multi/h264_dpb.c b/drivers/frame_provider/decoder/h264_multi/h264_dpb.c
index 06e3621..106b99e 100644
--- a/drivers/frame_provider/decoder/h264_multi/h264_dpb.c
+++ b/drivers/frame_provider/decoder/h264_multi/h264_dpb.c
@@ -37,15 +37,18 @@ int dpb_print(int index, int debug_flag, const char *fmt, ...)
if (((h264_debug_flag & debug_flag) &&
((1 << index) & h264_debug_mask))
|| (debug_flag == PRINT_FLAG_ERROR)) {
- unsigned char buf[512];
+ unsigned char *buf = vzalloc(512);
int len = 0;
va_list args;
+ if (!buf)
+ return 0;
va_start(args, fmt);
len = sprintf(buf, "%d: ", index);
vsnprintf(buf + len, 512-len, fmt, args);
pr_debug("%s", buf);
va_end(args);
+ vfree(buf);
}
return 0;
}
@@ -55,13 +58,17 @@ int dpb_print_cont(int index, int debug_flag, const char *fmt, ...)
if (((h264_debug_flag & debug_flag) &&
((1 << index) & h264_debug_mask))
|| (debug_flag == PRINT_FLAG_ERROR)) {
- unsigned char buf[512];
+ unsigned char *buf = vzalloc(512);
int len = 0;
va_list args;
+
+ if (!buf)
+ return 0;
va_start(args, fmt);
vsnprintf(buf + len, 512-len, fmt, args);
pr_info("%s", buf);
va_end(args);
+ vfree(buf);
}
return 0;
}
@@ -652,7 +659,7 @@ static void decode_poc(struct VideoParameters *p_Vid, struct Slice *pSlice)
(pSlice->toppoc < pSlice->bottompoc) ?
pSlice->toppoc : pSlice->bottompoc;
/* POC200301 */
- } else if (pSlice->bottom_field_flag == FALSE) {
+ } else if (pSlice->bottom_field_flag == 0) {
/* top field */
pSlice->ThisPOC = pSlice->toppoc =
pSlice->PicOrderCntMsb +
@@ -770,7 +777,7 @@ static void decode_poc(struct VideoParameters *p_Vid, struct Slice *pSlice)
(pSlice->toppoc < pSlice->bottompoc) ?
pSlice->toppoc : pSlice->bottompoc;
/* POC200301 */
- } else if (pSlice->bottom_field_flag == FALSE) {
+ } else if (pSlice->bottom_field_flag == 0) {
/* top field */
pSlice->ThisPOC = pSlice->toppoc =
p_Vid->ExpectedPicOrderCnt +
@@ -824,7 +831,7 @@ static void decode_poc(struct VideoParameters *p_Vid, struct Slice *pSlice)
if (pSlice->field_pic_flag == 0)
pSlice->toppoc = pSlice->bottompoc =
pSlice->framepoc = pSlice->ThisPOC;
- else if (pSlice->bottom_field_flag == FALSE)
+ else if (pSlice->bottom_field_flag == 0)
pSlice->toppoc = pSlice->framepoc =
pSlice->ThisPOC;
else
@@ -870,7 +877,6 @@ void fill_frame_num_gap(struct VideoParameters *p_Vid, struct Slice *currSlice)
CurrFrameNum = currSlice->frame_num; /*p_Vid->frame_num;*/
while (CurrFrameNum != UnusedShortTermFrameNum) {
- /*pr_err("CurrFrameNum = %d, UnusedShortTermFrameNum = %d\n", CurrFrameNum, UnusedShortTermFrameNum);*/
/*picture = alloc_storable_picture
*(p_Vid, FRAME, p_Vid->width,
*p_Vid->height,
@@ -5459,7 +5465,7 @@ void init_old_slice(OldSliceParams *p_old_slice)
p_old_slice->pps_id = INT_MAX;
p_old_slice->frame_num = INT_MAX;
p_old_slice->nal_ref_idc = INT_MAX;
- p_old_slice->idr_flag = FALSE;
+ p_old_slice->idr_flag = 0;
p_old_slice->pic_oder_cnt_lsb = UINT_MAX;
p_old_slice->delta_pic_oder_cnt_bottom = INT_MAX;
diff --git a/drivers/frame_provider/decoder/h264_multi/h264_dpb.h b/drivers/frame_provider/decoder/h264_multi/h264_dpb.h
index 5c7645f..df21f22 100644
--- a/drivers/frame_provider/decoder/h264_multi/h264_dpb.h
+++ b/drivers/frame_provider/decoder/h264_multi/h264_dpb.h
@@ -41,16 +41,7 @@
#define PRINT_FLAG_V4L_DETAIL 0x8000
#define DISABLE_ERROR_HANDLE 0x10000
#define DEBUG_DUMP_STAT 0x80000
-/*setting canvas mode and endian.
- if this flag is set, value of canvas mode
- will according to the value of mem_map_mode.
- endian will be forced set to 0 in
- CANVAS_BLKMODE_LINEAR mode.
- otherwise picture will display abnormal.
- if this flag is not set, value of canvas mode
- will be determined by the user speace config.
- endian will be set 7 in CANVAS_BLKMODE_LINEAR mode.
-*/
+
#define IGNORE_PARAM_FROM_CONFIG 0x8000000
#define MVC_EXTENSION_ENABLE 0
@@ -61,7 +52,7 @@
#define H264_OUTPUT_MODE_NORMAL 0x4
#define H264_OUTPUT_MODE_FAST 0x8
-#define FALSE 0
+//#define FALSE 0
#define H264_SLICE_HEAD_DONE 0x01
#define H264_PIC_DATA_DONE 0x02
diff --git a/drivers/frame_provider/decoder/h264_multi/vmh264.c b/drivers/frame_provider/decoder/h264_multi/vmh264.c
index ed9b2bd..a850134 100644
--- a/drivers/frame_provider/decoder/h264_multi/vmh264.c
+++ b/drivers/frame_provider/decoder/h264_multi/vmh264.c
@@ -23,7 +23,6 @@
#include <linux/kfifo.h>
#include <linux/platform_device.h>
#include <linux/random.h>
-
#include <linux/amlogic/media/utils/amstream.h>
#include <linux/amlogic/media/frame_sync/ptsserv.h>
#include <linux/amlogic/media/canvas/canvas.h>
@@ -41,10 +40,10 @@
#include <linux/dma-contiguous.h>
#include "../../../stream_input/amports/amports_priv.h"
#include <linux/amlogic/media/codec_mm/codec_mm.h>
-
#include "../utils/vdec_input.h"
-#include <linux/amlogic/tee.h>
-
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
+#include <linux/sched/clock.h>
#include <linux/amlogic/media/utils/vdec_reg.h>
#include "../utils/vdec.h"
#include "../utils/amvdec.h"
@@ -55,9 +54,9 @@
#include "../utils/decoder_mmu_box.h"
#include "../utils/decoder_bmmu_box.h"
#include "../utils/firmware.h"
-#include <linux/amlogic/tee.h>
#include <linux/uaccess.h>
#include "../utils/config_parser.h"
+#include "../../../amvdec_ports/vdec_drv_base.h"
#include "../../../common/chips/decoder_cpu_ver_info.h"
#include "../utils/vdec_v4l2_buffer_ops.h"
#include <linux/crc32.h>
@@ -977,10 +976,10 @@ static int hevc_alloc_mmu(struct vdec_h264_hw_s *hw, int pic_idx,
}
return decoder_mmu_box_alloc_idx(
- hw->mmu_box,
- cur_buf_idx,
- cur_mmu_4k_number,
- mmu_index_adr);
+ hw->mmu_box,
+ cur_buf_idx,
+ cur_mmu_4k_number,
+ mmu_index_adr);
}
static int compute_losless_comp_body_size(int width,
@@ -1358,7 +1357,7 @@ static void hevc_mcr_sao_global_hw_init(struct vdec_h264_hw_s *hw,
/* ipp_enable*/
WRITE_VREG(HEVCD_IPP_TOP_CNTL, 0x1 << 1);
- if (get_cpu_major_id() >= MESON_CPU_MAJOR_ID_G12A) {
+ if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A) {
WRITE_VREG(HEVC_DBLK_CFG1, 0x2); // set ctusize==16
WRITE_VREG(HEVC_DBLK_CFG2, ((height & 0xffff)<<16) | (width & 0xffff));
if (dw_mode)
@@ -1522,7 +1521,7 @@ static void hevc_sao_set_pic_buffer(struct vdec_h264_hw_s *hw,
}
/*Reset SAO + Enable SAO slice_start*/
- if (hw->mmu_enable && get_cpu_major_id() >= MESON_CPU_MAJOR_ID_G12A)
+ if (hw->mmu_enable && get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A)
WRITE_VREG(HEVC_DBLK_CFG0, 0x1); // reset buffer32x4 in lpf for every picture
WRITE_VREG(HEVC_SAO_INT_STATUS,
READ_VREG(HEVC_SAO_INT_STATUS) | 0x1 << 28);
@@ -1531,7 +1530,7 @@ static void hevc_sao_set_pic_buffer(struct vdec_h264_hw_s *hw,
/*pr_info("hevc_sao_set_pic_buffer:mc_y_adr: %x\n", mc_y_adr);*/
/*Send coommand to hevc-code to supply 4k buffers to sao*/
- if (get_cpu_major_id() < MESON_CPU_MAJOR_ID_G12A) {
+ if (get_cpu_major_id() < AM_MESON_CPU_MAJOR_ID_G12A) {
WRITE_VREG(H265_SAO_4K_SET_BASE, (u32)hw->frame_mmu_map_phy_addr);
WRITE_VREG(H265_SAO_4K_SET_COUNT, MAX_FRAME_4K_NUM);
} else
@@ -1606,7 +1605,7 @@ static void hevc_sao_wait_done(struct vdec_h264_hw_s *hw)
}
timeout = jiffies + HZ;
if ((hw->frame_busy == 1) && (hw->frame_done == 1) ) {
- if (get_cpu_major_id() < MESON_CPU_MAJOR_ID_G12A) {
+ if (get_cpu_major_id() < AM_MESON_CPU_MAJOR_ID_G12A) {
WRITE_VREG(SYS_COMMAND, H265_ABORT_SAO_4K_SET);
while ((READ_VREG(SYS_COMMAND) & 0xff) !=
H265_ABORT_SAO_4K_SET_DONE) {
@@ -1661,7 +1660,6 @@ static void buf_spec_init(struct vdec_h264_hw_s *hw)
hw->buffer_spec[i].used = -1;
hw->buffer_spec[i].canvas_pos = -1;
}
-
if (dpb_is_debug(DECODE_ID(hw),
PRINT_FLAG_DUMP_BUFSPEC))
dump_bufspec(hw, __func__);
@@ -1955,7 +1953,6 @@ static void config_decode_canvas(struct vdec_h264_hw_s *hw, int i)
CANVAS_ADDR_NOWRAP,
blkmode,
endian);
-
if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A) {
WRITE_VREG(VDEC_ASSIST_CANVAS_BLK32,
(1 << 11) | /* canvas_blk32_wr */
@@ -1973,7 +1970,6 @@ static void config_decode_canvas(struct vdec_h264_hw_s *hw, int i)
CANVAS_ADDR_NOWRAP,
blkmode,
endian);
-
if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A) {
WRITE_VREG(VDEC_ASSIST_CANVAS_BLK32,
(1 << 11) |
@@ -1981,7 +1977,6 @@ static void config_decode_canvas(struct vdec_h264_hw_s *hw, int i)
(1 << 8) |
(hw->buffer_spec[i].u_canvas_index << 0));
}
-
WRITE_VREG(ANC0_CANVAS_ADDR + hw->buffer_spec[i].canvas_pos,
spec2canvas(&hw->buffer_spec[i]));
@@ -2482,7 +2477,6 @@ unsigned char have_free_buf_spec(struct vdec_s *vdec)
}
mutex_unlock(&vmh264_mutex);
}
-
return ret;
}
@@ -2557,7 +2551,6 @@ static int check_force_interlace(struct vdec_h264_hw_s *hw,
static void fill_frame_info(struct vdec_h264_hw_s *hw, struct FrameStore *frame)
{
struct vframe_qos_s *vframe_qos = &hw->vframe_qos;
-
if (frame->slice_type == I_SLICE)
vframe_qos->type = 1;
else if (frame->slice_type == P_SLICE)
@@ -2611,8 +2604,6 @@ static int is_iframe(struct FrameStore *frame) {
return 0;
}
-
-
int prepare_display_buf(struct vdec_s *vdec, struct FrameStore *frame)
{
struct vdec_h264_hw_s *hw = (struct vdec_h264_hw_s *)vdec->private;
@@ -4114,10 +4105,8 @@ static void set_frame_info(struct vdec_h264_hw_s *hw, struct vframe_s *vf,
(min(hw->h264_ar, (u32) DISP_RATIO_ASPECT_RATIO_MAX)) <<
DISP_RATIO_ASPECT_RATIO_BIT;
vf->orientation = hw->vh264_rotation;
-
if (hw->mmu_enable)
return;
-
vf->canvas0Addr = vf->canvas1Addr = -1;
#ifdef NV21
vf->plane_num = 2;
@@ -4649,7 +4638,6 @@ static int vh264_set_params(struct vdec_h264_hw_s *hw,
unsigned int used_reorder_dpb_size_margin
= hw->reorder_dpb_size_margin;
u8 *colocate_vaddr = NULL;
-
#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
if (vdec->master || vdec->slave)
used_reorder_dpb_size_margin =
@@ -4772,7 +4760,6 @@ static int vh264_set_params(struct vdec_h264_hw_s *hw,
mb_height, mb_width, mb_total,
level_idc, max_reference_size);
-
p_H264_Dpb->colocated_buf_size = mb_total * 96;
hw->dpb.reorder_pic_num =
get_max_dec_frame_buf_size(level_idc,
@@ -5692,7 +5679,6 @@ static int vh264_pic_done_proc(struct vdec_s *vdec)
return 0;
}
-
static irqreturn_t vh264_isr_thread_fn(struct vdec_s *vdec, int irq)
{
int i;
@@ -6645,8 +6631,6 @@ static void vmh264_dump_state(struct vdec_s *vdec)
hw->cur_picture_slice_count,
hw->multi_slice_pic_flag);
#endif
-
-
if (vf_get_receiver(vdec->vf_provider_name)) {
enum receviver_start_e state =
vf_notify_receiver(vdec->vf_provider_name,
@@ -6753,9 +6737,10 @@ static void vmh264_dump_state(struct vdec_s *vdec)
}
-static void check_timer_func(unsigned long arg)
+static void check_timer_func(struct timer_list *timer)
{
- struct vdec_h264_hw_s *hw = (struct vdec_h264_hw_s *)arg;
+ struct vdec_h264_hw_s *hw = container_of(timer,
+ struct vdec_h264_hw_s, check_timer);
struct vdec_s *vdec = hw_to_vdec(hw);
int error_skip_frame_count = error_skip_count & 0xfff;
unsigned int timeout_val = decode_timeout_val;
@@ -7079,6 +7064,7 @@ static void vh264_local_init(struct vdec_h264_hw_s *hw, bool is_reset)
hw->vld_dec_control = 0;
hw->decode_timeout_count = 0;
hw->no_mem_count = 0;
+
hw->vh264_ratio = hw->vh264_amstream_dec_info.ratio;
/* vh264_ratio = 0x100; */
@@ -7164,10 +7150,7 @@ static s32 vh264_init(struct vdec_h264_hw_s *hw)
/* init_timer(&hw->recycle_timer); */
/* timer init */
- init_timer(&hw->check_timer);
-
- hw->check_timer.data = (unsigned long)hw;
- hw->check_timer.function = check_timer_func;
+ timer_setup(&hw->check_timer, check_timer_func, 0);
hw->check_timer.expires = jiffies + CHECK_INTERVAL;
/* add_timer(&hw->check_timer); */
@@ -7384,7 +7367,6 @@ static int vh264_stop(struct vdec_h264_hw_s *hw)
cancel_work_sync(&hw->timeout_work);
cancel_work_sync(&hw->work);
-
if (hw->stat & STAT_MC_LOAD) {
if (hw->mc_cpu_addr != NULL) {
dma_free_coherent(amports_get_dma_device(),
@@ -8302,6 +8284,7 @@ result_done:
}
decode_frame_count[DECODE_ID(hw)]++;
amvdec_stop();
+
if (!vdec_is_support_4k()) {
if (clk_adj_frame_count < VDEC_CLOCK_ADJUST_FRAME) {
clk_adj_frame_count++;
@@ -8792,7 +8775,7 @@ static void run(struct vdec_s *vdec, unsigned long mask,
WRITE_VREG(AV_SCRATCH_K, udebug_flag);
mod_timer(&hw->check_timer, jiffies + CHECK_INTERVAL);
- if (get_cpu_major_id() >= MESON_CPU_MAJOR_ID_G12A) {
+ if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A) {
if (hw->mmu_enable)
SET_VREG_MASK(VDEC_ASSIST_MMC_CTRL1, 1 << 3);
@@ -9023,7 +9006,6 @@ static void h264_reset_bufmgr(struct vdec_s *vdec)
hw->skip_frame_count);
flush_dpb(&hw->dpb);
-
timeout = jiffies + HZ;
while (kfifo_len(&hw->display_q) > 0) {
if (time_after(jiffies, timeout))
@@ -9282,7 +9264,7 @@ static int ammvdec_h264_probe(struct platform_device *pdev)
DCAC_READ_MARGIN;
if (hw->mmu_enable) {
u32 extif_size = EXTIF_BUF_SIZE;
- if (get_cpu_major_id() >= MESON_CPU_MAJOR_ID_G12A)
+ if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A)
extif_size <<= 1;
if (decoder_bmmu_box_alloc_buf_phy(hw->bmmu_box, BMMU_EXTIF_IDX,
extif_size, DRIVER_NAME, &hw->extif_addr) < 0) {
@@ -9458,32 +9440,16 @@ static int ammvdec_h264_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int mh264_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int mh264_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops mh264_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(mh264_suspend, mh264_resume)
-};
-#endif
static struct platform_driver ammvdec_h264_driver = {
.probe = ammvdec_h264_probe,
.remove = ammvdec_h264_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &mh264_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
diff --git a/drivers/frame_provider/decoder/h265/vh265.c b/drivers/frame_provider/decoder/h265/vh265.c
index ceed425..323fc00 100644
--- a/drivers/frame_provider/decoder/h265/vh265.c
+++ b/drivers/frame_provider/decoder/h265/vh265.c
@@ -38,7 +38,10 @@
#include <linux/dma-contiguous.h>
#include <linux/slab.h>
#include <linux/mm.h>
-#include <linux/amlogic/tee.h>
+#include <linux/timer.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
+#include <linux/sched/clock.h>
#include "../../../stream_input/amports/amports_priv.h"
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include "../utils/decoder_mmu_box.h"
@@ -158,7 +161,7 @@ static s32 vh265_init(struct hevc_state_s *hevc);
#endif
static void vh265_prot_init(struct hevc_state_s *hevc);
static int vh265_local_init(struct hevc_state_s *hevc);
-static void vh265_check_timer_func(unsigned long arg);
+static void vh265_check_timer_func(struct timer_list *timer);
static void config_decode_mode(struct hevc_state_s *hevc);
static const char vh265_dec_id[] = "vh265-dev";
@@ -226,16 +229,12 @@ static const char * const matrix_coeffs_names[] = {
#define HEVC_SAO_CTRL9 0x362d
#define LOSLESS_COMPRESS_MODE
/* DOUBLE_WRITE_MODE is enabled only when NV21 8 bit output is needed */
-/* double_write_mode:
+/* hevc->double_write_mode:
* 0, no double write;
* 1, 1:1 ratio;
* 2, (1/4):(1/4) ratio;
* 3, (1/4):(1/4) ratio, with both compressed frame included
- * 4, (1/2):(1/2) ratio;
* 0x10, double write only
- * 0x100, if > 1080p,use mode 4,else use mode 1;
- * 0x200, if > 1080p,use mode 2,else use mode 1;
- * 0x300, if > 720p, use mode 4, else use mode 1;
*/
static u32 double_write_mode;
@@ -277,10 +276,10 @@ static u32 pts_unstable;
#define H265_DEBUG_WAIT_DECODE_DONE_WHEN_STOP 0x4000000
#ifdef MULTI_INSTANCE_SUPPORT
#define PRINT_FLAG_ERROR 0x0
-#define IGNORE_PARAM_FROM_CONFIG 0x08000000
-#define PRINT_FRAMEBASE_DATA 0x10000000
-#define PRINT_FLAG_VDEC_STATUS 0x20000000
-#define PRINT_FLAG_VDEC_DETAIL 0x40000000
+#define IGNORE_PARAM_FROM_CONFIG 0x08000000
+#define PRINT_FRAMEBASE_DATA 0x10000000
+#define PRINT_FLAG_VDEC_STATUS 0x20000000
+#define PRINT_FLAG_VDEC_DETAIL 0x40000000
#define PRINT_FLAG_V4L_DETAIL 0x80000000
#endif
@@ -474,7 +473,6 @@ static unsigned int disp_vframe_valve_level;
static int pre_decode_buf_level = 0x1000;
static unsigned int pic_list_debug;
-
#ifdef MULTI_INSTANCE_SUPPORT
static unsigned int max_decode_instance_num
= MAX_DECODE_INSTANCE_NUM;
@@ -1734,6 +1732,7 @@ struct hevc_state_s {
u32 skip_first_nal;
bool is_swap;
bool is_4k;
+
int frameinfo_enable;
struct vframe_qos_s vframe_qos;
bool is_used_v4l;
@@ -2394,7 +2393,7 @@ static void corrRefillWithAmrisc (
uint16_t ctuy = (ctuPosition>> 0) & 0xffff;
int32_t aboveCtuAvailable = (ctuy) ? 1 : 0;
- uint16_t cmBodyBuf[32 * 18];
+ uint16_t *cmBodyBuf = NULL;
uint32_t pic_width_x64_pre = picWidth + 0x3f;
uint32_t pic_width_x64 = pic_width_x64_pre >> 6;
@@ -2416,6 +2415,10 @@ static void corrRefillWithAmrisc (
int32_t blkIdx;
+ cmBodyBuf = vzalloc(sizeof(uint16_t) * 32 * 18);
+ if (!cmBodyBuf)
+ return;
+
WRITE_VREG(HEVC_SAO_CTRL10, cmHeaderAddrAbv);
WRITE_VREG(HEVC_SAO_CTRL11, cmHeaderAddrCur);
WRITE_VREG(HEVC_SAO_DBG_MODE0, hevc->detbuf_adr);
@@ -2534,6 +2537,7 @@ static void corrRefillWithAmrisc (
} while (tmpData32);
hevc_print(hevc, H265_DEBUG_BUFMGR_MORE,
"%s, %d\n", __func__, __LINE__);
+ vfree(cmBodyBuf);
}
static void delrefill(struct hevc_state_s *hevc)
@@ -2756,17 +2760,14 @@ static int init_mmu_buffers(struct hevc_state_s *hevc)
int tvp_flag = vdec_secure(hw_to_vdec(hevc)) ?
CODEC_MM_FLAGS_TVP : 0;
int buf_size = 64;
-
if ((hevc->max_pic_w * hevc->max_pic_h) > 0 &&
(hevc->max_pic_w * hevc->max_pic_h) <= 1920*1088) {
buf_size = 24;
}
-
if (get_dbg_flag(hevc)) {
hevc_print(hevc, 0, "%s max_w %d max_h %d\n",
__func__, hevc->max_pic_w, hevc->max_pic_h);
}
-
hevc->need_cache_size = buf_size * SZ_1M;
hevc->sc_start_time = get_jiffies_64();
if (hevc->mmu_enable
@@ -3156,7 +3157,6 @@ static int alloc_buf(struct hevc_state_s *hevc)
hevc->m_BUF[i].size = buf_size;
hevc->m_BUF[i].used_flag = 0;
ret = 0;
-
if (get_dbg_flag(hevc) & H265_DEBUG_BUFMGR) {
hevc_print(hevc, 0,
"Buffer %d: start_adr %p size %x\n",
@@ -3234,9 +3234,9 @@ static void dealloc_unused_buf(struct hevc_state_s *hevc)
hevc->m_BUF[i].size);
}
if (!hevc->is_used_v4l)
- decoder_bmmu_box_free_idx(
- hevc->bmmu_box,
- VF_BUFFER_IDX(i));
+ decoder_bmmu_box_free_idx(
+ hevc->bmmu_box,
+ VF_BUFFER_IDX(i));
hevc->m_BUF[i].start_adr = 0;
hevc->m_BUF[i].size = 0;
}
@@ -3260,8 +3260,8 @@ static void dealloc_pic_buf(struct hevc_state_s *hevc,
if (!hevc->is_used_v4l)
decoder_bmmu_box_free_idx(
- hevc->bmmu_box,
- VF_BUFFER_IDX(i));
+ hevc->bmmu_box,
+ VF_BUFFER_IDX(i));
hevc->m_BUF[i].used_flag = 0;
hevc->m_BUF[i].start_adr = 0;
hevc->m_BUF[i].size = 0;
@@ -3286,6 +3286,7 @@ static int get_work_pic_num(struct hevc_state_s *hevc)
sps_pic_buf_diff = hevc->param.p.sps_max_dec_pic_buffering_minus1_0
- hevc->sps_num_reorder_pics_0;
+
#ifdef MULTI_INSTANCE_SUPPORT
/*
need one more for multi instance, as
@@ -3796,7 +3797,6 @@ static struct PIC_s *output_pic(struct hevc_state_s *hevc,
pic_display = NULL;
}
}
-
if (pic_display && (hevc->vf_pre_count == 1) && (hevc->first_pic_flag == 1)) {
pic_display = NULL;
hevc->first_pic_flag = 0;
@@ -7345,15 +7345,14 @@ static int H265_alloc_mmu(struct hevc_state_s *hevc, struct PIC_s *new_pic,
return -1;
}
ret = decoder_mmu_box_alloc_idx(
- hevc->mmu_box,
- cur_buf_idx,
- cur_mmu_4k_number,
- mmu_index_adr);
+ hevc->mmu_box,
+ cur_buf_idx,
+ cur_mmu_4k_number,
+ mmu_index_adr);
if (ret == 0)
new_pic->scatter_alloc = 1;
-
hevc_print(hevc, H265_DEBUG_BUFMGR_MORE,
- "%s pic index %d page count(%d) ret =%d\n",
+ "%s pic index %d page count(%d) ret =%d\n",
__func__, cur_buf_idx,
cur_mmu_4k_number, ret);
return ret;
@@ -7689,14 +7688,14 @@ static int parse_sei(struct hevc_state_s *hevc,
case SEI_PicTiming:
if ((parser_sei_enable & 0x4) &&
hevc->frame_field_info_present_flag) {
- p_sei = p;
- hevc->curr_pic_struct = (*p_sei >> 4)&0x0f;
- pic->pic_struct = hevc->curr_pic_struct;
- if (get_dbg_flag(hevc) &
- H265_DEBUG_PIC_STRUCT) {
- hevc_print(hevc, 0,
- "parse result pic_struct = %d\n",
- hevc->curr_pic_struct);
+ p_sei = p;
+ hevc->curr_pic_struct = (*p_sei >> 4)&0x0f;
+ pic->pic_struct = hevc->curr_pic_struct;
+ if (get_dbg_flag(hevc) &
+ H265_DEBUG_PIC_STRUCT) {
+ hevc_print(hevc, 0,
+ "parse result pic_struct = %d\n",
+ hevc->curr_pic_struct);
}
}
break;
@@ -8485,7 +8484,7 @@ static void fill_frame_info(struct hevc_state_s *hevc,
if (input_frame_based(hw_to_vdec(hevc)))
vframe_qos->size = pic->frame_size;
else
- vframe_qos->size = framesize;
+ vframe_qos->size = framesize;
vframe_qos->pts = pts;
#ifdef SHOW_QOS_INFO
hevc_print(hevc, 0, "slice:%d, poc:%d\n", pic->slice_type, pic->POC);
@@ -8711,7 +8710,6 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
if (pic->double_write_mode) {
vf->type = VIDTYPE_PROGRESSIVE | VIDTYPE_VIU_FIELD;
vf->type |= VIDTYPE_VIU_NV21;
-
if ((pic->double_write_mode == 3) &&
(!(IS_8K_SIZE(pic->width, pic->height)))) {
vf->type |= VIDTYPE_COMPRESS;
@@ -9475,11 +9473,9 @@ static irqreturn_t vh265_isr_thread_fn(int irq, void *data)
struct hevc_state_s *hevc = (struct hevc_state_s *) data;
unsigned int dec_status = hevc->dec_status;
int i, ret;
-
#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
struct vdec_s *vdec = hw_to_vdec(hevc);
#endif
-
if (hevc->eos)
return IRQ_HANDLED;
if (
@@ -10412,7 +10408,6 @@ static irqreturn_t vh265_isr(int irq, void *data)
struct hevc_state_s *hevc = (struct hevc_state_s *)data;
u32 debug_tag;
dec_status = READ_VREG(HEVC_DEC_STATUS_REG);
-
if (hevc->init_flag == 0)
return IRQ_HANDLED;
hevc->dec_status = dec_status;
@@ -10521,10 +10516,10 @@ static void vh265_set_clk(struct work_struct *work)
hevc->frame_height * fps;
}
-static void vh265_check_timer_func(unsigned long arg)
+static void vh265_check_timer_func(struct timer_list *timer)
{
- struct hevc_state_s *hevc = (struct hevc_state_s *)arg;
- struct timer_list *timer = &hevc->timer;
+ struct hevc_state_s *hevc = container_of(timer,
+ struct hevc_state_s, timer);
unsigned char empty_flag;
unsigned int buf_level;
@@ -11097,7 +11092,7 @@ static s32 vh265_init(struct hevc_state_s *hevc)
int fw_size = 0x1000 * 16;
struct firmware_s *fw = NULL;
- init_timer(&hevc->timer);
+ timer_setup(&hevc->timer, vh265_check_timer_func, 0);
hevc->stat |= STAT_TIMER_INIT;
@@ -11177,8 +11172,8 @@ static s32 vh265_init(struct hevc_state_s *hevc)
#ifdef MULTI_INSTANCE_SUPPORT
if (hevc->m_ins_flag) {
- hevc->timer.data = (ulong) hevc;
- hevc->timer.function = vh265_check_timer_func;
+ //hevc->timer.data = (ulong) hevc;
+ //hevc->timer.function = vh265_check_timer_func;
hevc->timer.expires = jiffies + PUT_INTERVAL;
hevc->fw = fw;
@@ -11275,8 +11270,8 @@ static s32 vh265_init(struct hevc_state_s *hevc)
#endif
hevc->stat |= STAT_VF_HOOK;
- hevc->timer.data = (ulong) hevc;
- hevc->timer.function = vh265_check_timer_func;
+ //hevc->timer.data = (ulong) hevc;
+ //hevc->timer.function = vh265_check_timer_func;
hevc->timer.expires = jiffies + PUT_INTERVAL;
add_timer(&hevc->timer);
@@ -12200,7 +12195,7 @@ static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask)
again_threshold) {
int r = vdec_sync_input(vdec);
hevc_print(hevc,
- PRINT_FLAG_VDEC_DETAIL, "%s buf lelvel:%x\n", __func__, r);
+ PRINT_FLAG_VDEC_DETAIL, "%s buf lelvel:%x\n", __func__, r);
return 0;
}
}
@@ -12391,6 +12386,7 @@ static void run(struct vdec_s *vdec, unsigned long mask,
else
loadr = amhevc_vdec_loadmc_ex(VFORMAT_HEVC, vdec,
NULL, hevc->fw->data);
+
if (loadr < 0) {
amhevc_disable();
hevc_print(hevc, 0, "H265: the %s fw loading failed, err: %x\n",
diff --git a/drivers/frame_provider/decoder/mjpeg/vmjpeg.c b/drivers/frame_provider/decoder/mjpeg/vmjpeg.c
index 6b87d4a..5535cd8 100644
--- a/drivers/frame_provider/decoder/mjpeg/vmjpeg.c
+++ b/drivers/frame_provider/decoder/mjpeg/vmjpeg.c
@@ -28,7 +28,6 @@
#include <linux/amlogic/media/vfm/vframe.h>
#include <linux/amlogic/media/vfm/vframe_provider.h>
#include <linux/amlogic/media/vfm/vframe_receiver.h>
-
#include <linux/amlogic/media/utils/vdec_reg.h>
#include "../../../stream_input/amports/amports_priv.h"
#include <linux/amlogic/media/registers/register.h>
@@ -36,9 +35,6 @@
#include "../utils/decoder_bmmu_box.h"
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include <linux/amlogic/media/codec_mm/configs.h>
-#include <linux/amlogic/tee.h>
-
-
#ifdef CONFIG_AM_VDEC_MJPEG_LOG
#define AMLOG
@@ -397,10 +393,8 @@ static void mjpeg_set_clk(struct work_struct *work)
}
}
-static void vmjpeg_put_timer_func(unsigned long arg)
+static void vmjpeg_put_timer_func(struct timer_list *timer)
{
- struct timer_list *timer = (struct timer_list *)arg;
-
while (!kfifo_is_empty(&recycle_q) &&
(READ_VREG(MREG_TO_AMRISC) == 0)) {
struct vframe_s *vf;
@@ -740,7 +734,7 @@ static s32 vmjpeg_init(void)
if (IS_ERR_OR_NULL(buf))
return -ENOMEM;
- init_timer(&recycle_timer);
+ timer_setup(&recycle_timer, vmjpeg_put_timer_func, 0);
stat |= STAT_TIMER_INIT;
@@ -805,10 +799,7 @@ static s32 vmjpeg_init(void)
stat |= STAT_VF_HOOK;
- recycle_timer.data = (ulong)&recycle_timer;
- recycle_timer.function = vmjpeg_put_timer_func;
recycle_timer.expires = jiffies + PUT_INTERVAL;
-
add_timer(&recycle_timer);
stat |= STAT_TIMER_ARM;
@@ -911,32 +902,16 @@ static int amvdec_mjpeg_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int mjpeg_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int mjpeg_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops mjpeg_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(mjpeg_suspend, mjpeg_resume)
-};
-#endif
static struct platform_driver amvdec_mjpeg_driver = {
.probe = amvdec_mjpeg_probe,
.remove = amvdec_mjpeg_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &mjpeg_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
diff --git a/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c b/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c
index aea1346..7f2007a 100644
--- a/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c
+++ b/drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c
@@ -29,12 +29,12 @@
#include <linux/amlogic/media/vfm/vframe.h>
#include <linux/amlogic/media/vfm/vframe_provider.h>
#include <linux/amlogic/media/vfm/vframe_receiver.h>
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
#include <linux/amlogic/media/utils/vdec_reg.h>
#include <linux/amlogic/media/registers/register.h>
#include "../../../stream_input/amports/amports_priv.h"
-
#include "../utils/vdec_input.h"
#include "../utils/vdec.h"
#include "../utils/amvdec.h"
@@ -122,14 +122,18 @@ int mmjpeg_debug_print(int index, int debug_flag, const char *fmt, ...)
if (((debug_enable & debug_flag) &&
((1 << index) & mmjpeg_debug_mask))
|| (debug_flag == PRINT_FLAG_ERROR)) {
- unsigned char buf[512];
+ unsigned char *buf = vzalloc(512);
int len = 0;
va_list args;
+
+ if (!buf)
+ return 0;
va_start(args, fmt);
len = sprintf(buf, "%d: ", index);
vsnprintf(buf + len, 512-len, fmt, args);
pr_info("%s", buf);
va_end(args);
+ vfree(buf);
}
return 0;
}
@@ -206,7 +210,7 @@ struct vdec_mjpeg_hw_s {
struct firmware_s *fw;
struct timer_list check_timer;
u32 decode_timeout_count;
- unsigned long int start_process_time;
+ u32 start_process_time;
u32 last_vld_level;
u8 eos;
u32 frame_num;
@@ -767,22 +771,23 @@ static void timeout_process(struct vdec_mjpeg_hw_s *hw)
vdec_schedule_work(&hw->work);
}
-static void check_timer_func(unsigned long arg)
+static void check_timer_func(struct timer_list *timer)
{
- struct vdec_mjpeg_hw_s *hw = (struct vdec_mjpeg_hw_s *)arg;
+ struct vdec_mjpeg_hw_s *hw = container_of(timer,
+ struct vdec_mjpeg_hw_s, check_timer);
struct vdec_s *vdec = hw_to_vdec(hw);
int timeout_val = decode_timeout_val;
mmjpeg_debug_print(DECODE_ID(hw), PRINT_FLAG_VLD_DETAIL,
- "%s: status:nstatus=%d:%d\n",
- __func__, vdec->status, vdec->next_status);
+ "%s: status:nstatus=%d:%d\n",
+ __func__, vdec->status, vdec->next_status);
mmjpeg_debug_print(DECODE_ID(hw), PRINT_FLAG_VLD_DETAIL,
- "%s: %d,buftl=%x:%x:%x:%x\n",
- __func__, __LINE__,
- READ_VREG(VLD_MEM_VIFIFO_BUF_CNTL),
- READ_PARSER_REG(PARSER_VIDEO_WP),
- READ_VREG(VLD_MEM_VIFIFO_LEVEL),
- READ_VREG(VLD_MEM_VIFIFO_WP));
+ "%s: %d,buftl=%x:%x:%x:%x\n",
+ __func__, __LINE__,
+ READ_VREG(VLD_MEM_VIFIFO_BUF_CNTL),
+ READ_PARSER_REG(PARSER_VIDEO_WP),
+ READ_VREG(VLD_MEM_VIFIFO_LEVEL),
+ READ_VREG(VLD_MEM_VIFIFO_WP));
if (radr != 0) {
if (rval != 0) {
@@ -1102,10 +1107,7 @@ static s32 vmjpeg_init(struct vdec_s *vdec)
CODEC_MM_FLAGS_CMA_CLEAR |
CODEC_MM_FLAGS_FOR_VDECODER);
- init_timer(&hw->check_timer);
-
- hw->check_timer.data = (unsigned long)hw;
- hw->check_timer.function = check_timer_func;
+ timer_setup(&hw->check_timer, check_timer_func, 0);
hw->check_timer.expires = jiffies + CHECK_INTERVAL;
/*add_timer(&hw->check_timer);*/
hw->stat |= STAT_TIMER_ARM;
@@ -1235,19 +1237,19 @@ static void run(struct vdec_s *vdec, unsigned long mask,
hw->init_flag = 1;
mmjpeg_debug_print(DECODE_ID(hw), PRINT_FLAG_RUN_FLOW,
- "%s (0x%x 0x%x 0x%x) vldcrl 0x%x bitcnt 0x%x powerctl 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
- __func__,
- READ_VREG(VLD_MEM_VIFIFO_LEVEL),
- READ_VREG(VLD_MEM_VIFIFO_WP),
- READ_VREG(VLD_MEM_VIFIFO_RP),
- READ_VREG(VLD_DECODE_CONTROL),
- READ_VREG(VIFF_BIT_CNT),
- READ_VREG(POWER_CTL_VLD),
- READ_VREG(VLD_MEM_VIFIFO_START_PTR),
- READ_VREG(VLD_MEM_VIFIFO_CURR_PTR),
- READ_VREG(VLD_MEM_VIFIFO_CONTROL),
- READ_VREG(VLD_MEM_VIFIFO_BUF_CNTL),
- READ_VREG(VLD_MEM_VIFIFO_END_PTR));
+ "%s (0x%x 0x%x 0x%x) vldcrl 0x%x bitcnt 0x%x powerctl 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+ __func__,
+ READ_VREG(VLD_MEM_VIFIFO_LEVEL),
+ READ_VREG(VLD_MEM_VIFIFO_WP),
+ READ_VREG(VLD_MEM_VIFIFO_RP),
+ READ_VREG(VLD_DECODE_CONTROL),
+ READ_VREG(VIFF_BIT_CNT),
+ READ_VREG(POWER_CTL_VLD),
+ READ_VREG(VLD_MEM_VIFIFO_START_PTR),
+ READ_VREG(VLD_MEM_VIFIFO_CURR_PTR),
+ READ_VREG(VLD_MEM_VIFIFO_CONTROL),
+ READ_VREG(VLD_MEM_VIFIFO_BUF_CNTL),
+ READ_VREG(VLD_MEM_VIFIFO_END_PTR));
}
static void wait_vmjpeg_search_done(struct vdec_mjpeg_hw_s *hw)
{
@@ -1302,7 +1304,6 @@ static int notify_v4l_eos(struct vdec_s *vdec)
return 0;
}
-
static void vmjpeg_work(struct work_struct *work)
{
struct vdec_mjpeg_hw_s *hw = container_of(work,
@@ -1532,32 +1533,16 @@ static int ammvdec_mjpeg_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int mmjpeg_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int mmjpeg_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops mmjpeg_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(mmjpeg_suspend, mmjpeg_resume)
-};
-#endif
static struct platform_driver ammvdec_mjpeg_driver = {
.probe = ammvdec_mjpeg_probe,
.remove = ammvdec_mjpeg_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &mmjpeg_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
diff --git a/drivers/frame_provider/decoder/mpeg12/vmpeg12.c b/drivers/frame_provider/decoder/mpeg12/vmpeg12.c
index 29757a0..f0d110d 100644
--- a/drivers/frame_provider/decoder/mpeg12/vmpeg12.c
+++ b/drivers/frame_provider/decoder/mpeg12/vmpeg12.c
@@ -41,7 +41,8 @@
#include "../utils/decoder_bmmu_box.h"
#include <linux/uaccess.h>
#include <linux/amlogic/media/codec_mm/configs.h>
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
@@ -1310,11 +1311,9 @@ static void vmpeg12_set_clk(struct work_struct *work)
}
-static void vmpeg_put_timer_func(unsigned long arg)
+static void vmpeg_put_timer_func(struct timer_list *timer)
{
- struct timer_list *timer = (struct timer_list *)arg;
int fatal_reset = 0;
-
enum receviver_start_e state = RECEIVER_INACTIVE;
if (vf_get_receiver(PROVIDER_NAME)) {
@@ -1366,7 +1365,7 @@ static void vmpeg_put_timer_func(unsigned long arg)
if (frame_dur > 0 && saved_resolution !=
frame_width * frame_height * (96000 / frame_dur))
- schedule_work(&set_clk_work);
+ schedule_work(&set_clk_work);
timer->expires = jiffies + PUT_INTERVAL;
@@ -1949,7 +1948,7 @@ static s32 vmpeg12_init(void)
if (IS_ERR_OR_NULL(buf))
return -ENOMEM;
- init_timer(&recycle_timer);
+ timer_setup(&recycle_timer, vmpeg_put_timer_func, 0);
stat |= STAT_TIMER_INIT;
@@ -2014,10 +2013,7 @@ static s32 vmpeg12_init(void)
stat |= STAT_VF_HOOK;
- recycle_timer.data = (ulong)&recycle_timer;
- recycle_timer.function = vmpeg_put_timer_func;
recycle_timer.expires = jiffies + PUT_INTERVAL;
-
add_timer(&recycle_timer);
stat |= STAT_TIMER_ARM;
@@ -2159,32 +2155,16 @@ static int amvdec_mpeg12_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int mpeg12_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int mpeg12_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops mpeg12_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(mpeg12_suspend, mpeg12_resume)
-};
-#endif
static struct platform_driver amvdec_mpeg12_driver = {
.probe = amvdec_mpeg12_probe,
.remove = amvdec_mpeg12_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &mpeg12_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
diff --git a/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c b/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c
index 356506d..8a04616 100644
--- a/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c
+++ b/drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c
@@ -26,19 +26,19 @@
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/delay.h>
-
+#include <linux/sched/clock.h>
#include <linux/amlogic/media/frame_sync/ptsserv.h>
#include <linux/amlogic/media/utils/amstream.h>
#include <linux/amlogic/media/canvas/canvas.h>
#include <linux/amlogic/media/vfm/vframe.h>
#include <linux/amlogic/media/vfm/vframe_provider.h>
#include <linux/amlogic/media/vfm/vframe_receiver.h>
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
#include <linux/amlogic/media/utils/vdec_reg.h>
#include <linux/amlogic/media/registers/register.h>
#include "../../../stream_input/amports/amports_priv.h"
-
#include "../utils/vdec_input.h"
#include "../utils/vdec.h"
#include "../utils/amvdec.h"
@@ -51,7 +51,6 @@
#include "../utils/vdec_v4l2_buffer_ops.h"
#include "../utils/config_parser.h"
-
#define MEM_NAME "codec_mmpeg12"
#define CHECK_INTERVAL (HZ/100)
@@ -84,7 +83,6 @@
#define PICINFO_RPT_FIRST 0x4000
#define PICINFO_TOP_FIRST 0x2000
#define PICINFO_FRAME 0x1000
-
#define TOP_FIELD 0x1000
#define BOTTOM_FIELD 0x2000
#define FRAME_PICTURE 0x3000
@@ -284,6 +282,7 @@ struct vdec_mpeg12_hw_s {
u32 pre_parser_wr_ptr;
u8 next_again_flag;
#endif
+
struct work_struct userdata_push_work;
struct mutex userdata_mutex;
struct mmpeg2_userdata_info_t userdata_info;
@@ -326,7 +325,7 @@ unsigned int mpeg12_debug_mask = 0xff;
#define PRINT_FLAG_ERROR 0x0
#define PRINT_FLAG_RUN_FLOW 0X0001
#define PRINT_FLAG_TIMEINFO 0x0002
-#define PRINT_FLAG_UCODE_DETAIL 0x0004
+#define PRINT_FLAG_UCODE_DETAIL 0x0004
#define PRINT_FLAG_VLD_DETAIL 0x0008
#define PRINT_FLAG_DEC_DETAIL 0x0010
#define PRINT_FLAG_BUFFER_DETAIL 0x0020
@@ -349,14 +348,18 @@ int debug_print(int index, int debug_flag, const char *fmt, ...)
if (((debug_enable & debug_flag) &&
((1 << index) & mpeg12_debug_mask))
|| (debug_flag == PRINT_FLAG_ERROR)) {
- unsigned char buf[512];
+ unsigned char *buf = vzalloc(512);
int len = 0;
va_list args;
+
+ if (!buf)
+ return 0;
va_start(args, fmt);
len = sprintf(buf, "%d: ", index);
vsnprintf(buf + len, 512-len, fmt, args);
pr_info("%s", buf);
va_end(args);
+ vfree(buf);
}
return 0;
}
@@ -1429,6 +1432,7 @@ static void userdata_push_do_work(struct work_struct *work)
if (pdata >= hw->userdata_info.data_buf_end)
pdata = hw->userdata_info.data_buf;
}
+
pcur_ud_rec = hw->ud_record + hw->cur_ud_idx;
pcur_ud_rec->meta_info = meta_info;
@@ -1455,7 +1459,6 @@ static void userdata_push_do_work(struct work_struct *work)
hw->cur_ud_idx++;
WRITE_VREG(AV_SCRATCH_J, 0);
-
}
@@ -1631,35 +1634,35 @@ static void force_interlace_check(struct vdec_mpeg12_hw_s *hw)
(hw->frame_width == 720) &&
(hw->frame_height == 576) &&
(hw->frame_dur == 3840)) {
- hw->frame_prog = 0;
- } else if ((hw->dec_control
- & DEC_CONTROL_FLAG_FORCE_3000_704_480_INTERLACE) &&
- (hw->frame_width == 704) &&
- (hw->frame_height == 480) &&
- (hw->frame_dur == 3200)) {
- hw->frame_prog = 0;
- } else if ((hw->dec_control
- & DEC_CONTROL_FLAG_FORCE_2500_704_576_INTERLACE) &&
- (hw->frame_width == 704) &&
- (hw->frame_height == 576) &&
- (hw->frame_dur == 3840)) {
- hw->frame_prog = 0;
- } else if ((hw->dec_control
- & DEC_CONTROL_FLAG_FORCE_2500_544_576_INTERLACE) &&
- (hw->frame_width == 544) &&
- (hw->frame_height == 576) &&
- (hw->frame_dur == 3840)) {
- hw->frame_prog = 0;
- } else if ((hw->dec_control
- & DEC_CONTROL_FLAG_FORCE_2500_480_576_INTERLACE) &&
- (hw->frame_width == 480) &&
- (hw->frame_height == 576) &&
- (hw->frame_dur == 3840)) {
- hw->frame_prog = 0;
- } else if (hw->dec_control
- & DEC_CONTROL_FLAG_FORCE_SEQ_INTERLACE) {
- hw->frame_prog = 0;
- }
+ hw->frame_prog = 0;
+ } else if ((hw->dec_control
+ & DEC_CONTROL_FLAG_FORCE_3000_704_480_INTERLACE) &&
+ (hw->frame_width == 704) &&
+ (hw->frame_height == 480) &&
+ (hw->frame_dur == 3200)) {
+ hw->frame_prog = 0;
+ } else if ((hw->dec_control
+ & DEC_CONTROL_FLAG_FORCE_2500_704_576_INTERLACE) &&
+ (hw->frame_width == 704) &&
+ (hw->frame_height == 576) &&
+ (hw->frame_dur == 3840)) {
+ hw->frame_prog = 0;
+ } else if ((hw->dec_control
+ & DEC_CONTROL_FLAG_FORCE_2500_544_576_INTERLACE) &&
+ (hw->frame_width == 544) &&
+ (hw->frame_height == 576) &&
+ (hw->frame_dur == 3840)) {
+ hw->frame_prog = 0;
+ } else if ((hw->dec_control
+ & DEC_CONTROL_FLAG_FORCE_2500_480_576_INTERLACE) &&
+ (hw->frame_width == 480) &&
+ (hw->frame_height == 576) &&
+ (hw->frame_dur == 3840)) {
+ hw->frame_prog = 0;
+ } else if (hw->dec_control
+ & DEC_CONTROL_FLAG_FORCE_SEQ_INTERLACE) {
+ hw->frame_prog = 0;
+ }
}
@@ -1907,7 +1910,7 @@ static irqreturn_t vmpeg12_isr(struct vdec_s *vdec, int irq)
{
u32 info, offset;
struct vdec_mpeg12_hw_s *hw =
- (struct vdec_mpeg12_hw_s *)(vdec->private);
+ (struct vdec_mpeg12_hw_s *)(vdec->private);
if (hw->eos)
return IRQ_HANDLED;
info = READ_VREG(MREG_PIC_INFO);
@@ -2147,7 +2150,7 @@ static struct vframe_s *vmpeg_vf_get(void *op_arg)
struct vframe_s *vf;
struct vdec_s *vdec = op_arg;
struct vdec_mpeg12_hw_s *hw =
- (struct vdec_mpeg12_hw_s *)vdec->private;
+ (struct vdec_mpeg12_hw_s *)vdec->private;
hw->get_num++;
if (kfifo_get(&hw->display_q, &vf))
@@ -2181,7 +2184,7 @@ static int vmpeg_vf_states(struct vframe_states *states, void *op_arg)
unsigned long flags;
struct vdec_s *vdec = op_arg;
struct vdec_mpeg12_hw_s *hw =
- (struct vdec_mpeg12_hw_s *)vdec->private;
+ (struct vdec_mpeg12_hw_s *)vdec->private;
spin_lock_irqsave(&hw->lock, flags);
@@ -2316,11 +2319,11 @@ static void vmpeg12_canvas_init(struct vdec_mpeg12_hw_s *hw)
}
hw->canvas_config[i][0].phy_addr =
- decbuf_start;
+ decbuf_start;
hw->canvas_config[i][0].width =
- canvas_width;
+ canvas_width;
hw->canvas_config[i][0].height =
- canvas_height;
+ canvas_height;
hw->canvas_config[i][0].block_mode =
hw->canvas_mode;
hw->canvas_config[i][0].endian =
@@ -2338,7 +2341,7 @@ static void vmpeg12_canvas_init(struct vdec_mpeg12_hw_s *hw)
(hw->canvas_mode == CANVAS_BLKMODE_LINEAR)?7:0;
canvas_config_config(canvas_u(canvas),
- &hw->canvas_config[i][1]);
+ &hw->canvas_config[i][1]);
}
}
return;
@@ -2496,9 +2499,10 @@ static void timeout_process(struct vdec_mpeg12_hw_s *hw)
vdec_schedule_work(&hw->timeout_work);
}
-static void check_timer_func(unsigned long arg)
+static void check_timer_func(struct timer_list *timer)
{
- struct vdec_mpeg12_hw_s *hw = (struct vdec_mpeg12_hw_s *)arg;
+ struct vdec_mpeg12_hw_s *hw = container_of(timer,
+ struct vdec_mpeg12_hw_s, check_timer);
struct vdec_s *vdec = hw_to_vdec(hw);
unsigned int timeout_val = decode_timeout_val;
@@ -2603,10 +2607,10 @@ static int vmpeg12_hw_ctx_restore(struct vdec_mpeg12_hw_s *hw)
WRITE_VREG(MREG_CMD, 0);
debug_print(DECODE_ID(hw), PRINT_FLAG_RESTORE,
- "0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
- hw->frame_width, hw->frame_height, hw->seqinfo,
- hw->reg_f_code_reg, hw->reg_slice_ver_pos_pic_type,
- hw->reg_mb_info);
+ "0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
+ hw->frame_width, hw->frame_height, hw->seqinfo,
+ hw->reg_f_code_reg, hw->reg_slice_ver_pos_pic_type,
+ hw->reg_mb_info);
WRITE_VREG(MREG_PIC_WIDTH, hw->reg_pic_width);
WRITE_VREG(MREG_PIC_HEIGHT, hw->reg_pic_height);
@@ -2651,6 +2655,7 @@ static int vmpeg12_hw_ctx_restore(struct vdec_mpeg12_hw_s *hw)
/*stream based input*/
WRITE_VREG(MREG_INPUT, (hw->ctx_valid<<6));
}
+
return 0;
}
@@ -2754,9 +2759,10 @@ static s32 vmpeg12_init(struct vdec_mpeg12_hw_s *hw)
USER_DATA_SIZE);
amvdec_enable();
- init_timer(&hw->check_timer);
- hw->check_timer.data = (unsigned long)hw;
- hw->check_timer.function = check_timer_func;
+ timer_setup(&hw->check_timer, check_timer_func, 0);
+ //init_timer(&hw->check_timer);
+ //hw->check_timer.data = (unsigned long)hw;
+ //hw->check_timer.function = check_timer_func;
hw->check_timer.expires = jiffies + CHECK_INTERVAL;
hw->stat |= STAT_TIMER_ARM;
@@ -2847,7 +2853,7 @@ void (*callback)(struct vdec_s *, void *),
void *arg)
{
struct vdec_mpeg12_hw_s *hw =
- (struct vdec_mpeg12_hw_s *)vdec->private;
+ (struct vdec_mpeg12_hw_s *)vdec->private;
int save_reg = READ_VREG(POWER_CTL_VLD);
int size, ret;
/* reset everything except DOS_TOP[1] and APB_CBUS[0]*/
@@ -3187,32 +3193,16 @@ static int ammvdec_mpeg12_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int mmpeg12_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int mmpeg12_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops mmpeg12_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(mmpeg12_suspend, mmpeg12_resume)
-};
-#endif
static struct platform_driver ammvdec_mpeg12_driver = {
.probe = ammvdec_mpeg12_probe,
.remove = ammvdec_mpeg12_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &mmpeg12_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
@@ -3294,7 +3284,6 @@ module_param_array(max_process_time, uint, &max_decode_instance_num, 0664);
module_param(udebug_flag, uint, 0664);
MODULE_PARM_DESC(udebug_flag, "\n ammvdec_mpeg12 udebug_flag\n");
-
#ifdef AGAIN_HAS_THRESHOLD
module_param(again_threshold, uint, 0664);
MODULE_PARM_DESC(again_threshold, "\n again_threshold\n");
@@ -3303,7 +3292,6 @@ MODULE_PARM_DESC(again_threshold, "\n again_threshold\n");
module_param(without_display_mode, uint, 0664);
MODULE_PARM_DESC(without_display_mode, "\n ammvdec_mpeg12 without_display_mode\n");
-
module_init(ammvdec_mpeg12_driver_init_module);
module_exit(ammvdec_mpeg12_driver_remove_module);
diff --git a/drivers/frame_provider/decoder/mpeg4/vmpeg4.c b/drivers/frame_provider/decoder/mpeg4/vmpeg4.c
index 7092ddb..444a87e 100644
--- a/drivers/frame_provider/decoder/mpeg4/vmpeg4.c
+++ b/drivers/frame_provider/decoder/mpeg4/vmpeg4.c
@@ -26,12 +26,10 @@
#include <linux/dma-mapping.h>
#include <linux/amlogic/media/utils/amstream.h>
#include <linux/amlogic/media/frame_sync/ptsserv.h>
-
#include <linux/amlogic/media/vfm/vframe.h>
#include <linux/amlogic/media/vfm/vframe_provider.h>
#include <linux/amlogic/media/vfm/vframe_receiver.h>
#include <linux/amlogic/media/canvas/canvas.h>
-
#include <linux/amlogic/media/utils/vdec_reg.h>
#include "vmpeg4.h"
#include <linux/amlogic/media/registers/register.h>
@@ -40,7 +38,8 @@
#include "../utils/decoder_bmmu_box.h"
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include <linux/amlogic/media/codec_mm/configs.h>
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
@@ -714,10 +713,8 @@ static void vmpeg4_set_clk(struct work_struct *work)
frame_width, frame_height, fps);
}
-static void vmpeg_put_timer_func(unsigned long arg)
+static void vmpeg_put_timer_func(struct timer_list *timer)
{
- struct timer_list *timer = (struct timer_list *)arg;
-
while (!kfifo_is_empty(&recycle_q) && (READ_VREG(MREG_BUFFERIN) == 0)) {
struct vframe_s *vf;
@@ -733,7 +730,7 @@ static void vmpeg_put_timer_func(unsigned long arg)
if (frame_dur > 0 && saved_resolution !=
frame_width * frame_height * (96000 / frame_dur))
- schedule_work(&set_clk_work);
+ schedule_work(&set_clk_work);
if (READ_VREG(AV_SCRATCH_L)) {
pr_info("mpeg4 fatal error happened,need reset !!\n");
@@ -1064,7 +1061,7 @@ static s32 vmpeg4_init(void)
stat |= STAT_MC_LOAD;
query_video_status(0, &trickmode_fffb);
- init_timer(&recycle_timer);
+ timer_setup(&recycle_timer, vmpeg_put_timer_func, 0);
stat |= STAT_TIMER_INIT;
if (vdec_request_irq(VDEC_IRQ_1, vmpeg4_isr,
@@ -1109,10 +1106,7 @@ static s32 vmpeg4_init(void)
stat |= STAT_VF_HOOK;
- recycle_timer.data = (ulong)&recycle_timer;
- recycle_timer.function = vmpeg_put_timer_func;
recycle_timer.expires = jiffies + PUT_INTERVAL;
-
add_timer(&recycle_timer);
stat |= STAT_TIMER_ARM;
@@ -1216,32 +1210,16 @@ static int amvdec_mpeg4_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int mpeg4_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int mpeg4_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops mpeg4_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(mpeg4_suspend, mpeg4_resume)
-};
-#endif
static struct platform_driver amvdec_mpeg4_driver = {
.probe = amvdec_mpeg4_probe,
.remove = amvdec_mpeg4_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &mpeg4_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
diff --git a/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c b/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c
index aff7852..d6f2845 100644
--- a/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c
+++ b/drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c
@@ -26,13 +26,14 @@
#include <linux/dma-mapping.h>
#include <linux/amlogic/media/utils/amstream.h>
#include <linux/amlogic/media/frame_sync/ptsserv.h>
-
#include <linux/amlogic/media/vfm/vframe.h>
#include <linux/amlogic/media/vfm/vframe_provider.h>
#include <linux/amlogic/media/vfm/vframe_receiver.h>
#include <linux/amlogic/media/canvas/canvas.h>
#include <linux/amlogic/media/codec_mm/codec_mm.h>
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
+#include <linux/sched/clock.h>
#include <linux/amlogic/media/utils/vdec_reg.h>
#include <linux/amlogic/media/registers/register.h>
#include "../../../stream_input/amports/amports_priv.h"
@@ -178,14 +179,18 @@ int mmpeg4_debug_print(int index, int debug_flag, const char *fmt, ...)
if (((debug_enable & debug_flag) &&
((1 << index) & mpeg4_debug_mask))
|| (debug_flag == PRINT_FLAG_ERROR)) {
- unsigned char buf[512];
+ unsigned char *buf = vzalloc(512);
int len = 0;
va_list args;
+
+ if (!buf)
+ return 0;
va_start(args, fmt);
len = sprintf(buf, "%d: ", index);
vsnprintf(buf + len, 512-len, fmt, args);
pr_info("%s", buf);
va_end(args);
+ vfree(buf);
}
return 0;
}
@@ -340,7 +345,6 @@ static unsigned char aspect_ratio_table[16] = {
static void reset_process_time(struct vdec_mpeg4_hw_s *hw);
-
static int vmpeg4_get_buf_num(struct vdec_mpeg4_hw_s *hw)
{
int buf_num = DECODE_BUFFER_NUM_DEF;
@@ -874,7 +878,6 @@ static irqreturn_t vmpeg4_isr_thread_fn(struct vdec_s *vdec, int irq)
u32 repeat_cnt, duration = 3200;
struct pic_info_t *dec_pic, *disp_pic;
struct vdec_mpeg4_hw_s *hw = (struct vdec_mpeg4_hw_s *)(vdec->private);
-
if (hw->eos)
return IRQ_HANDLED;
@@ -1760,9 +1763,10 @@ static void timeout_process(struct vdec_mpeg4_hw_s *hw)
}
-static void check_timer_func(unsigned long arg)
+static void check_timer_func(struct timer_list *timer)
{
- struct vdec_mpeg4_hw_s *hw = (struct vdec_mpeg4_hw_s *)arg;
+ struct vdec_mpeg4_hw_s *hw = container_of(timer,
+ struct vdec_mpeg4_hw_s, check_timer);
struct vdec_s *vdec = hw_to_vdec(hw);
unsigned int timeout_val = decode_timeout_val;
@@ -2031,9 +2035,10 @@ static s32 vmmpeg4_init(struct vdec_mpeg4_hw_s *hw)
amvdec_enable();
- init_timer(&hw->check_timer);
- hw->check_timer.data = (unsigned long)hw;
- hw->check_timer.function = check_timer_func;
+ timer_setup(&hw->check_timer, check_timer_func, 0);
+ //init_timer(&hw->check_timer);
+ //hw->check_timer.data = (unsigned long)hw;
+ //hw->check_timer.function = check_timer_func;
hw->check_timer.expires = jiffies + CHECK_INTERVAL;
hw->stat |= STAT_TIMER_ARM;
hw->eos = 0;
@@ -2048,7 +2053,6 @@ static s32 vmmpeg4_init(struct vdec_mpeg4_hw_s *hw)
static unsigned long run_ready(struct vdec_s *vdec, unsigned long mask)
{
struct vdec_mpeg4_hw_s *hw = (struct vdec_mpeg4_hw_s *)vdec->private;
-
if (hw->eos)
return 0;
if (vdec_stream_based(vdec) && (hw->init_flag == 0)
@@ -2415,32 +2419,16 @@ static int ammvdec_mpeg4_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int mmpeg4_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int mmpeg4_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops mmpeg4_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(mmpeg4_suspend, mmpeg4_resume)
-};
-#endif
static struct platform_driver ammvdec_mpeg4_driver = {
.probe = ammvdec_mpeg4_probe,
.remove = ammvdec_mpeg4_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &mmpeg4_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
diff --git a/drivers/frame_provider/decoder/real/vreal.c b/drivers/frame_provider/decoder/real/vreal.c
index a752f78..e342c96 100644
--- a/drivers/frame_provider/decoder/real/vreal.c
+++ b/drivers/frame_provider/decoder/real/vreal.c
@@ -23,9 +23,7 @@
#include <linux/fs.h>
#include <linux/kfifo.h>
#include <linux/platform_device.h>
-
#include <linux/amlogic/media/canvas/canvas.h>
-
#include <linux/dma-mapping.h>
#include <linux/amlogic/media/utils/amstream.h>
#include <linux/amlogic/media/utils/vformat.h>
@@ -40,11 +38,9 @@
#include "../utils/vdec.h"
#include <linux/amlogic/media/utils/vdec_reg.h>
#include "../utils/amvdec.h"
-
#include "../../../stream_input/parser/streambuf.h"
#include "../../../stream_input/parser/streambuf_reg.h"
#include "../../../stream_input/parser/rmparser.h"
-
#include "vreal.h"
#include <linux/amlogic/media/registers/register.h>
#include "../utils/decoder_mmu_box.h"
@@ -52,9 +48,8 @@
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include <linux/amlogic/media/codec_mm/configs.h>
#include "../utils/firmware.h"
-#include <linux/amlogic/tee.h>
-
-
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
#define DRIVER_NAME "amvdec_real"
#define MODULE_NAME "amvdec_real"
@@ -457,9 +452,8 @@ static void vreal_set_clk(struct work_struct *work)
}
}
-static void vreal_put_timer_func(unsigned long arg)
+static void vreal_put_timer_func(struct timer_list *timer)
{
- struct timer_list *timer = (struct timer_list *)arg;
/* unsigned int status; */
#if 0
@@ -808,7 +802,7 @@ s32 vreal_init(struct vdec_s *vdec)
pr_info("vreal_init\n");
- init_timer(&recycle_timer);
+ timer_setup(&recycle_timer, vreal_put_timer_func, 0);
stat |= STAT_TIMER_INIT;
@@ -907,10 +901,7 @@ s32 vreal_init(struct vdec_s *vdec)
stat |= STAT_VF_HOOK;
- recycle_timer.data = (ulong)&recycle_timer;
- recycle_timer.function = vreal_put_timer_func;
recycle_timer.expires = jiffies + PUT_INTERVAL;
-
add_timer(&recycle_timer);
stat |= STAT_TIMER_ARM;
@@ -1001,32 +992,16 @@ static int amvdec_real_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int real_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int real_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops real_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(real_suspend, real_resume)
-};
-#endif
static struct platform_driver amvdec_real_driver = {
.probe = amvdec_real_probe,
.remove = amvdec_real_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &real_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
diff --git a/drivers/frame_provider/decoder/utils/amstream_profile.c b/drivers/frame_provider/decoder/utils/amstream_profile.c
index c8033ce..0e2b9c8 100644
--- a/drivers/frame_provider/decoder/utils/amstream_profile.c
+++ b/drivers/frame_provider/decoder/utils/amstream_profile.c
@@ -66,5 +66,3 @@ bool is_support_profile(char *name)
return ret;
}
EXPORT_SYMBOL(is_support_profile);
-
-
diff --git a/drivers/frame_provider/decoder/utils/amvdec.c b/drivers/frame_provider/decoder/utils/amvdec.c
index bf8955e..6d8944b 100644
--- a/drivers/frame_provider/decoder/utils/amvdec.c
+++ b/drivers/frame_provider/decoder/utils/amvdec.c
@@ -43,7 +43,8 @@
#include "amvdec.h"
#include <linux/amlogic/media/utils/amports_config.h>
#include "firmware.h"
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
#include "../../../common/chips/decoder_cpu_ver_info.h"
#define MC_SIZE (4096 * 16)
diff --git a/drivers/frame_provider/decoder/utils/decoder_bmmu_box.c b/drivers/frame_provider/decoder/utils/decoder_bmmu_box.c
index 461621b..4181a6a 100644
--- a/drivers/frame_provider/decoder/utils/decoder_bmmu_box.c
+++ b/drivers/frame_provider/decoder/utils/decoder_bmmu_box.c
@@ -422,6 +422,7 @@ static int decoder_bmmu_box_dump(struct decoder_bmmu_box *box, void *buf,
int tsize = 0;
int s;
int i;
+
if (!buf) {
pbuf = sbuf;
size = 512;
@@ -466,6 +467,7 @@ static int decoder_bmmu_box_dump_all(void *buf, int size)
int s;
int i;
struct list_head *head, *list;
+
if (!buf) {
pbuf = sbuf;
size = 512;
@@ -523,7 +525,7 @@ static ssize_t box_dump_show(struct class *class, struct class_attribute *attr,
return ret;
}
-static ssize_t box_debug_show(struct class *class,
+static ssize_t debug_show(struct class *class,
struct class_attribute *attr,
char *buf)
{
@@ -537,8 +539,7 @@ static ssize_t box_debug_show(struct class *class,
return size;
}
-
-static ssize_t box_debug_store(struct class *class,
+static ssize_t debug_store(struct class *class,
struct class_attribute *attr,
const char *buf, size_t size)
{
@@ -559,19 +560,21 @@ static ssize_t box_debug_store(struct class *class,
}
+static CLASS_ATTR_RO(box_dump);
+static CLASS_ATTR_RW(debug);
-
-static struct class_attribute decoder_bmmu_box_class_attrs[] = {
- __ATTR_RO(box_dump),
- __ATTR(debug, S_IRUGO | S_IWUSR | S_IWGRP,
- box_debug_show, box_debug_store),
- __ATTR_NULL
+static struct attribute *decoder_bmmu_box_class_attrs[] = {
+ &class_attr_box_dump.attr,
+ &class_attr_debug.attr,
+ NULL
};
+ATTRIBUTE_GROUPS(decoder_bmmu_box_class);
+
static struct class decoder_bmmu_box_class = {
- .name = "decoder_bmmu_box",
- .class_attrs = decoder_bmmu_box_class_attrs,
- };
+ .name = "decoder_bmmu_box",
+ .class_groups = decoder_bmmu_box_class_groups,
+};
int decoder_bmmu_box_init(void)
{
diff --git a/drivers/frame_provider/decoder/utils/decoder_mmu_box.c b/drivers/frame_provider/decoder/utils/decoder_mmu_box.c
index 8389514..74a52a0 100644
--- a/drivers/frame_provider/decoder/utils/decoder_mmu_box.c
+++ b/drivers/frame_provider/decoder/utils/decoder_mmu_box.c
@@ -28,7 +28,6 @@
#include <linux/slab.h>
#include <linux/amlogic/media/codec_mm/codec_mm_scatter.h>
#include <linux/platform_device.h>
-
struct decoder_mmu_box {
int max_sc_num;
const char *name;
@@ -115,7 +114,7 @@ void decoder_mmu_try_to_release_box(void *handle)
if (!is_keep) {
decoder_mmu_box_mgr_del_box(box);
- codec_mm_scatter_mgt_delay_free_swith(0, 0, 0, box->tvp_mode);
+ codec_mm_scatter_mgt_delay_free_switch(0, 0, 0, box->tvp_mode);
kfree(box);
}
}
@@ -162,7 +161,7 @@ void *decoder_mmu_box_alloc_box(const char *name,
mutex_init(&box->mutex);
INIT_LIST_HEAD(&box->list);
decoder_mmu_box_mgr_add_box(box);
- codec_mm_scatter_mgt_delay_free_swith(1, 2000,
+ codec_mm_scatter_mgt_delay_free_switch(1, 2000,
min_size_M, box->tvp_mode);
return (void *)box;
}
@@ -261,7 +260,7 @@ int decoder_mmu_box_free_idx(void *handle, int idx)
mutex_unlock(&box->mutex);
if (sc && box->box_ref_cnt == 0)
- codec_mm_scatter_mgt_delay_free_swith(0, 0, 0, box->tvp_mode);
+ codec_mm_scatter_mgt_delay_free_switch(0, 0, 0, box->tvp_mode);
return 0;
}
@@ -287,7 +286,7 @@ int decoder_mmu_box_free(void *handle)
}
mutex_unlock(&box->mutex);
decoder_mmu_box_mgr_del_box(box);
- codec_mm_scatter_mgt_delay_free_swith(0, 0, 0, box->tvp_mode);
+ codec_mm_scatter_mgt_delay_free_switch(0, 0, 0, box->tvp_mode);
kfree(box);
return 0;
}
@@ -410,16 +409,18 @@ box_dump_show(struct class *class,
return ret;
}
+static CLASS_ATTR_RO(box_dump);
-
-static struct class_attribute decoder_mmu_box_class_attrs[] = {
- __ATTR_RO(box_dump),
- __ATTR_NULL
+static struct attribute *decoder_mmu_box_class_attrs[] = {
+ &class_attr_box_dump.attr,
+ NULL
};
+ATTRIBUTE_GROUPS(decoder_mmu_box_class);
+
static struct class decoder_mmu_box_class = {
.name = "decoder_mmu_box",
- .class_attrs = decoder_mmu_box_class_attrs,
+ .class_groups = decoder_mmu_box_class_groups,
};
int decoder_mmu_box_init(void)
diff --git a/drivers/frame_provider/decoder/utils/firmware.h b/drivers/frame_provider/decoder/utils/firmware.h
index c799fd0..78c90f7 100644
--- a/drivers/frame_provider/decoder/utils/firmware.h
+++ b/drivers/frame_provider/decoder/utils/firmware.h
@@ -22,6 +22,9 @@
#include "../../../common/firmware/firmware_type.h"
#include <linux/amlogic/media/utils/vformat.h>
+#ifdef CONFIG_AMLOGIC_TEE
+#include <linux/amlogic/tee.h>
+#endif
#define FW_LOAD_FORCE (0x1)
#define FW_LOAD_TRY (0X2)
@@ -38,4 +41,16 @@ extern int get_data_from_name(const char *name, char *buf);
extern int get_firmware_data(unsigned int foramt, char *buf);
extern int video_fw_reload(int mode);
+#ifndef CONFIG_AMLOGIC_TEE
+static inline bool tee_enabled(void) { return false; }
+static inline int tee_load_video_fw_swap(u32 index, u32 vdec, bool is_swap)
+{
+ return -1;
+}
+static inline int tee_load_video_fw(u32 index, u32 vdec)
+{
+ return -1;
+}
+#endif
+
#endif
diff --git a/drivers/frame_provider/decoder/utils/frame_check.c b/drivers/frame_provider/decoder/utils/frame_check.c
index e0100d1..14ee698 100644
--- a/drivers/frame_provider/decoder/utils/frame_check.c
+++ b/drivers/frame_provider/decoder/utils/frame_check.c
@@ -25,6 +25,7 @@
#include <linux/timer.h>
#include <linux/kfifo.h>
#include <linux/kthread.h>
+ #include <linux/vmalloc.h>
#include <linux/platform_device.h>
#include <linux/amlogic/media/canvas/canvas.h>
#include <linux/amlogic/media/canvas/canvas_mgr.h>
@@ -121,7 +122,7 @@ static int get_frame_size(struct pic_check_mgr_t *pic,
return -1;
}
- pic->size_y = vf->width * vf->height;
+ pic->size_y = vf->width* vf->height;
pic->size_uv = pic->size_y >> 1;
pic->size_pic = pic->size_y + pic->size_uv;
@@ -317,10 +318,14 @@ static int write_yuv_work(struct pic_check_mgr_t *mgr)
static int write_crc_work(struct pic_check_mgr_t *mgr)
{
unsigned int wr_size;
- char *crc_buf, crc_tmp[64*30];
+ char *crc_buf, *crc_tmp = NULL;
mm_segment_t old_fs;
struct pic_check_t *check = &mgr->pic_check;
+ crc_tmp = (char *)vzalloc(64 * 30);
+ if (!crc_tmp)
+ return -1;
+
if (mgr->enable & CRC_MASK) {
wr_size = 0;
while (kfifo_get(&check->wr_chk_q, &crc_buf) != 0) {
@@ -344,6 +349,8 @@ static int write_crc_work(struct pic_check_mgr_t *mgr)
set_fs(old_fs);
}
}
+
+ vfree(crc_tmp);
return 0;
}
@@ -442,19 +449,20 @@ static int do_yuv_dump(struct pic_check_mgr_t *mgr, struct vframe_s *vf)
return 0;
if (single_mode_vdec != NULL) {
- if (mgr->size_pic >
- (dump->buf_size - dump->dump_cnt * mgr->size_pic)) {
- if (dump->buf_size) {
- dbg_print(FC_ERROR,
- "not enough buf, force dump less\n");
- dump->num = dump->dump_cnt;
- check_schedule(mgr);
- } else
- set_disable(mgr, YUV_MASK);
- return -1;
- }
- tmp_addr = dump->buf_addr +
- mgr->size_pic * dump->dump_cnt;
+ if (mgr->size_pic >
+ (dump->buf_size - dump->dump_cnt * mgr->size_pic)) {
+ if (dump->buf_size) {
+ dbg_print(FC_ERROR,
+ "not enough buf, force dump less\n");
+ dump->num = dump->dump_cnt;
+ check_schedule(mgr);
+ } else
+ set_disable(mgr, YUV_MASK);
+ return -1;
+ }
+
+ tmp_addr = dump->buf_addr +
+ mgr->size_pic * dump->dump_cnt;
} else {
if (mgr->size_pic > dump->buf_size) {
dbg_print(FC_ERROR,
@@ -571,7 +579,7 @@ static int crc_store(struct pic_check_mgr_t *mgr, struct vframe_s *vf,
if ((comp_crc_y != crc_y) || (crc_uv != comp_crc_uv)) {
mgr->pic_dump.start = 0;
if (fc_debug || mgr->pic_dump.num < 3)
- mgr->pic_dump.num++;
+ mgr->pic_dump.num++;
dbg_print(0, "\n\nError: %08d: %08x %08x != %08x %08x\n\n",
mgr->frame_cnt, crc_y, crc_uv, comp_crc_y, comp_crc_uv);
do_yuv_dump(mgr, vf);
@@ -1075,7 +1083,7 @@ void frame_check_exit(struct pic_check_mgr_t *mgr)
atomic_set(&mgr->work_inited, 0);
}
if (single_mode_vdec != NULL)
- write_yuv_work(mgr);
+ write_yuv_work(mgr);
write_crc_work(mgr);
for (i = 0; i < ARRAY_SIZE(check->fbc_planes); i++) {
diff --git a/drivers/frame_provider/decoder/utils/secprot.c b/drivers/frame_provider/decoder/utils/secprot.c
index a1e7fa7..67b7e2f 100644
--- a/drivers/frame_provider/decoder/utils/secprot.c
+++ b/drivers/frame_provider/decoder/utils/secprot.c
@@ -16,7 +16,7 @@
*/
#include <linux/kernel.h>
-#include <asm/compiler.h>
+//#include <asm/compiler.h>
#include "secprot.h"
#ifndef CONFIG_ARM64
#include <asm/opcodes-sec.h>
@@ -26,6 +26,9 @@
int tee_config_device_secure(int dev_id, int secure)
{
+#if 1
+ return 0;
+#else
int ret = 0;
register unsigned x0 asm("x0");
register unsigned x1 asm("x1");
@@ -46,10 +49,14 @@ int tee_config_device_secure(int dev_id, int secure)
ret = x0;
return ret;
+#endif
}
#else
int tee_config_device_secure(int dev_id, int secure)
{
+#if 1
+ return 0;
+#else
int ret = 0;
register unsigned int r0 asm("r0");
register unsigned int r1 asm("r1");
@@ -70,6 +77,7 @@ int tee_config_device_secure(int dev_id, int secure)
ret = r0;
return ret;
+#endif
}
#endif
diff --git a/drivers/frame_provider/decoder/utils/vdec.c b/drivers/frame_provider/decoder/utils/vdec.c
index 07e039b..92e16e0 100644
--- a/drivers/frame_provider/decoder/utils/vdec.c
+++ b/drivers/frame_provider/decoder/utils/vdec.c
@@ -37,15 +37,18 @@
#include <linux/amlogic/media/video_sink/v4lvideo_ext.h>
#endif
#include <linux/amlogic/media/vfm/vfm_ext.h>
+#include <linux/sched/clock.h>
+#include <uapi/linux/sched/types.h>
+#include <linux/signal.h>
/*for VDEC_DEBUG_SUPPORT*/
#include <linux/time.h>
-
#include <linux/amlogic/media/utils/vdec_reg.h>
#include "vdec.h"
#include "vdec_trace.h"
#ifdef CONFIG_AMLOGIC_MEDIA_MULTI_DEC
#include "vdec_profile.h"
#endif
+#include <linux/sched/clock.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
#include <linux/libfdt_env.h>
@@ -77,6 +80,13 @@
#include <linux/amlogic/power_ctrl.h>
#endif
+#ifdef CONFIG_AMLOGIC_IONVIDEO
+#include <linux/amlogic/media/video_sink/ionvideo_ext.h>
+#endif
+
+/* wait other module to support this function */
+#define is_support_power_ctrl() 0
+
static DEFINE_MUTEX(vdec_mutex);
#define MC_SIZE (4096 * 4)
@@ -103,7 +113,6 @@ static int parallel_decode = 1;
static int fps_detection;
static int fps_clear;
-
static int force_nosecure_even_drm;
static int disable_switch_single_to_mult;
@@ -118,7 +127,6 @@ static DEFINE_SPINLOCK(vdec_spin_lock);
static int frameinfo_flag = 0;
static int v4lvideo_add_di = 1;
static int max_di_instance = 2;
-
//static int path_debug = 0;
static int enable_mvdec_info = 1;
@@ -193,23 +201,6 @@ static const char * const vdec_status_string[] = {
"VDEC_STATUS_CONNECTED",
"VDEC_STATUS_ACTIVE"
};
-/*
-bit [28] enable print
-bit [23:16] etc
-bit [15:12]
- none 0 and not 0x1: force single
- none 0 and 0x1: force multi
-bit [8]
- 1: force dual
-bit [3]
- 1: use mavs for single mode
-bit [2]
- 1: force vfm path for frame mode
-bit [1]
- 1: force esparser auto mode
-bit [0]
- 1: disable audo manual mode ??
-*/
static int debugflags;
@@ -333,14 +324,9 @@ static void vdec_up(struct vdec_s *vdec)
up(&core->sem);
}
-
static u64 vdec_get_us_time_system(void)
{
- struct timeval tv;
-
- do_gettimeofday(&tv);
-
- return div64_u64(timeval_to_ns(&tv), 1000);
+ return div64_u64(local_clock(), 1000);
}
static void vdec_fps_clear(int id)
@@ -533,13 +519,6 @@ static void free_canvas_ex(int index, int id)
static void vdec_dmc_pipeline_reset(void)
{
- /*
- * bit15: vdec_piple
- * bit14: hevc_dmc_piple
- * bit13: hevcf_dmc_pipl
- * bit12: wave420_dmc_pipl
- * bit11: hcodec_dmc_pipl
- */
WRITE_RESET_REG(RESET7_REGISTER,
(1 << 15) | (1 << 14) | (1 << 13) |
@@ -1024,7 +1003,6 @@ struct vdec_s *vdec_create(struct stream_port_s *port,
struct vdec_s *vdec;
int type = VDEC_TYPE_SINGLE;
int id;
-
if (is_mult_inc(port->type))
type = (port->type & PORT_TYPE_FRAME) ?
VDEC_TYPE_FRAME_BLOCK :
@@ -1084,6 +1062,7 @@ int vdec_set_format(struct vdec_s *vdec, int format)
vdec->slave->format = format;
vdec->slave->port_flag |= PORT_FLAG_VFORMAT;
}
+
//trace_vdec_set_format(vdec, format);/*DEBUG_TMP*/
return 0;
@@ -1905,6 +1884,8 @@ EXPORT_SYMBOL(vdec_sync_input);
const char *vdec_status_str(struct vdec_s *vdec)
{
+ if (vdec->status < 0)
+ return "INVALID";
return vdec->status < ARRAY_SIZE(vdec_status_string) ?
vdec_status_string[vdec->status] : "INVALID";
}
@@ -2074,7 +2055,6 @@ s32 vdec_init(struct vdec_s *vdec, int is_4k)
const char *dev_name;
int id = PLATFORM_DEVID_AUTO;/*if have used my self*/
- //pr_err("%s [pid=%d,tgid=%d]\n", __func__, current->pid, current->tgid);
dev_name = get_dev_name(vdec_single(vdec), vdec->format);
if (dev_name == NULL)
@@ -2538,7 +2518,6 @@ int vdec_v4l2_reset(struct vdec_s *vdec, int flag)
}
EXPORT_SYMBOL(vdec_v4l2_reset);
-
void vdec_free_cmabuf(void)
{
mutex_lock(&vdec_mutex);
@@ -2771,7 +2750,6 @@ unsigned long vdec_ready_to_run(struct vdec_s *vdec, unsigned long mask)
inc_profi_count(mask, vdec->check_count);
#endif
if (vdec_core_with_input(mask)) {
-
/* check frame based input underrun */
if (input && !input->eos && input_frame_based(input)
&& (!vdec_input_next_chunk(input))) {
@@ -2897,7 +2875,6 @@ void vdec_prepare_run(struct vdec_s *vdec, unsigned long mask)
vdec->need_more_data &= ~VDEC_NEED_MORE_DATA_DIRTY;
}
-
/* struct vdec_core_shread manages all decoder instance in active list. When
* a vdec is added into the active list, it can onlt be in two status:
* VDEC_STATUS_CONNECTED(the decoder does not own HW resource and ready to run)
@@ -3379,7 +3356,6 @@ void vdec_poweron(enum vdec_type_e core)
if (has_hdec()) {
sleep_val = is_power_ctrl_ver2 ? 0x1 : 0x3;
iso_val = is_power_ctrl_ver2 ? 0x1 : 0x30;
-
/* hcodec power on */
#ifdef CONFIG_AMLOGIC_POWER
if (is_support_power_ctrl()) {
@@ -3528,7 +3504,6 @@ void vdec_poweroff(enum vdec_type_e core)
{
int sleep_val, iso_val;
bool is_power_ctrl_ver2 = false;
-
if (core >= VDEC_MAX)
return;
@@ -3548,7 +3523,7 @@ void vdec_poweroff(enum vdec_type_e core)
sleep_val = is_power_ctrl_ver2 ? 0x2 : 0xc;
iso_val = is_power_ctrl_ver2 ? 0x2 : 0xc0;
- /* enable vdec1 isolation */
+ /* disable VDEC_1 DMC REQ*/
#ifdef CONFIG_AMLOGIC_POWER
if (is_support_power_ctrl()) {
if (power_ctrl_iso_mask(false, iso_val, 0)) {
@@ -3663,15 +3638,15 @@ void vdec_poweroff(enum vdec_type_e core)
WRITE_AOREG(AO_RTI_GEN_PWR_ISO0,
READ_AOREG(AO_RTI_GEN_PWR_ISO0) | iso_val);
#endif
- /* power off hevc memories */
- WRITE_VREG(DOS_MEM_PD_HEVC, 0xffffffffUL);
+ /* power off hevc memories */
+ WRITE_VREG(DOS_MEM_PD_HEVC, 0xffffffffUL);
- /* disable hevc clock */
- hevc_clock_off();
- if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A)
- hevc_back_clock_off();
+ /* disable hevc clock */
+ hevc_clock_off();
+ if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A)
+ hevc_back_clock_off();
- /* hevc power off */
+ /* hevc power off */
#ifdef CONFIG_AMLOGIC_POWER
if (is_support_power_ctrl()) {
if (power_ctrl_sleep_mask(false, sleep_val, 0)) {
@@ -3680,7 +3655,7 @@ void vdec_poweroff(enum vdec_type_e core)
return;
}
} else {
- WRITE_AOREG(AO_RTI_GEN_PWR_SLEEP0,
+ WRITE_AOREG(AO_RTI_GEN_PWR_SLEEP0,
READ_AOREG(AO_RTI_GEN_PWR_SLEEP0) | sleep_val);
}
#else
@@ -3871,8 +3846,8 @@ void vdec_reset_core(struct vdec_s *vdec)
(get_cpu_major_id() != AM_MESON_CPU_MAJOR_ID_TL1)) {
WRITE_VREG(DOS_SW_RESET0, (1<<3)|(1<<4)|(1<<5)|(1<<7)|(1<<8)|(1<<9));
} else {
- WRITE_VREG(DOS_SW_RESET0,
- (1<<3)|(1<<4)|(1<<5));
+ WRITE_VREG(DOS_SW_RESET0,
+ (1<<3)|(1<<4)|(1<<5));
}
WRITE_VREG(DOS_SW_RESET0, 0);
@@ -3916,16 +3891,13 @@ void hevc_mmu_dma_check(struct vdec_s *vdec)
}
}
EXPORT_SYMBOL(hevc_mmu_dma_check);
-
void hevc_reset_core(struct vdec_s *vdec)
{
unsigned long flags;
unsigned int mask = 0;
-
mask = 1 << 4; /*bit4: hevc*/
if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A)
mask |= 1 << 8; /*bit8: hevcb*/
-
WRITE_VREG(HEVC_STREAM_CONTROL, 0);
spin_lock_irqsave(&vdec_spin_lock, flags);
codec_dmcbus_write(DMC_REQ_CTRL,
@@ -4225,9 +4197,7 @@ static ssize_t enable_mvdec_info_store(struct class *cla,
return count;
}
-
-
-static ssize_t store_poweron_clock_level(struct class *class,
+static ssize_t poweron_clock_level_store(struct class *class,
struct class_attribute *attr,
const char *buf, size_t size)
{
@@ -4243,7 +4213,7 @@ static ssize_t store_poweron_clock_level(struct class *class,
return size;
}
-static ssize_t show_poweron_clock_level(struct class *class,
+static ssize_t poweron_clock_level_show(struct class *class,
struct class_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", poweron_clock_level);
@@ -4254,7 +4224,7 @@ static ssize_t show_poweron_clock_level(struct class *class,
*always don't release
*vdec 64 memory for fast play.
*/
-static ssize_t store_keep_vdec_mem(struct class *class,
+static ssize_t keep_vdec_mem_store(struct class *class,
struct class_attribute *attr,
const char *buf, size_t size)
{
@@ -4269,15 +4239,14 @@ static ssize_t store_keep_vdec_mem(struct class *class,
return size;
}
-static ssize_t show_keep_vdec_mem(struct class *class,
+static ssize_t keep_vdec_mem_show(struct class *class,
struct class_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", keep_vdec_mem);
}
-
#ifdef VDEC_DEBUG_SUPPORT
-static ssize_t store_debug(struct class *class,
+static ssize_t debug_store(struct class *class,
struct class_attribute *attr,
const char *buf, size_t size)
{
@@ -4334,7 +4303,7 @@ static ssize_t store_debug(struct class *class,
return size;
}
-static ssize_t show_debug(struct class *class,
+static ssize_t debug_show(struct class *class,
struct class_attribute *attr, char *buf)
{
char *pbuf = buf;
@@ -4875,43 +4844,57 @@ static ssize_t dump_fps_show(struct class *class,
return pbuf - buf;
}
-
-
-static struct class_attribute vdec_class_attrs[] = {
- __ATTR_RO(amrisc_regs),
- __ATTR_RO(dump_trace),
- __ATTR_RO(clock_level),
- __ATTR(enable_mvdec_info, S_IRUGO | S_IWUSR | S_IWGRP,
- enable_mvdec_info_show, enable_mvdec_info_store),
- __ATTR(poweron_clock_level, S_IRUGO | S_IWUSR | S_IWGRP,
- show_poweron_clock_level, store_poweron_clock_level),
- __ATTR(dump_risc_mem, S_IRUGO | S_IWUSR | S_IWGRP,
- dump_risc_mem_show, dump_risc_mem_store),
- __ATTR(keep_vdec_mem, S_IRUGO | S_IWUSR | S_IWGRP,
- show_keep_vdec_mem, store_keep_vdec_mem),
- __ATTR_RO(core),
- __ATTR_RO(vdec_status),
- __ATTR_RO(dump_vdec_blocks),
- __ATTR_RO(dump_vdec_chunks),
- __ATTR_RO(dump_decoder_state),
+static CLASS_ATTR_RO(amrisc_regs);
+static CLASS_ATTR_RO(dump_trace);
+static CLASS_ATTR_RO(clock_level);
+static CLASS_ATTR_RW(poweron_clock_level);
+static CLASS_ATTR_RW(dump_risc_mem);
+static CLASS_ATTR_RW(keep_vdec_mem);
+static CLASS_ATTR_RW(enable_mvdec_info);
+static CLASS_ATTR_RO(core);
+static CLASS_ATTR_RO(vdec_status);
+static CLASS_ATTR_RO(dump_vdec_blocks);
+static CLASS_ATTR_RO(dump_vdec_chunks);
+static CLASS_ATTR_RO(dump_decoder_state);
+#ifdef VDEC_DEBUG_SUPPORT
+static CLASS_ATTR_RW(debug);
+#endif
+#ifdef FRAME_CHECK
+static CLASS_ATTR_RW(dump_yuv);
+static CLASS_ATTR_RW(frame_check);
+#endif
+static CLASS_ATTR_RO(dump_fps);
+
+static struct attribute *vdec_class_attrs[] = {
+ &class_attr_amrisc_regs.attr,
+ &class_attr_dump_trace.attr,
+ &class_attr_clock_level.attr,
+ &class_attr_poweron_clock_level.attr,
+ &class_attr_dump_risc_mem.attr,
+ &class_attr_keep_vdec_mem.attr,
+ &class_attr_enable_mvdec_info.attr,
+ &class_attr_core.attr,
+ &class_attr_vdec_status.attr,
+ &class_attr_dump_vdec_blocks.attr,
+ &class_attr_dump_vdec_chunks.attr,
+ &class_attr_dump_decoder_state.attr,
#ifdef VDEC_DEBUG_SUPPORT
- __ATTR(debug, S_IRUGO | S_IWUSR | S_IWGRP,
- show_debug, store_debug),
+ &class_attr_debug.attr,
#endif
#ifdef FRAME_CHECK
- __ATTR(dump_yuv, S_IRUGO | S_IWUSR | S_IWGRP,
- dump_yuv_show, dump_yuv_store),
- __ATTR(frame_check, S_IRUGO | S_IWUSR | S_IWGRP,
- frame_check_show, frame_check_store),
+ &class_attr_dump_yuv.attr,
+ &class_attr_frame_check.attr,
#endif
- __ATTR_RO(dump_fps),
- __ATTR_NULL
+ &class_attr_dump_fps.attr,
+ NULL
};
+ATTRIBUTE_GROUPS(vdec_class);
+
static struct class vdec_class = {
- .name = "vdec",
- .class_attrs = vdec_class_attrs,
- };
+ .name = "vdec",
+ .class_groups = vdec_class_groups,
+};
struct device *get_vdec_device(void)
{
@@ -5214,6 +5197,7 @@ u32 vdec_get_frame_vdec(struct vdec_s *vdec, struct vframe_counter_s *tmpbuf)
}
EXPORT_SYMBOL(vdec_get_frame_vdec);
+
RESERVEDMEM_OF_DECLARE(vdec, "amlogic, vdec-memory", vdec_mem_setup);
/*
uint force_hevc_clock_cntl;
diff --git a/drivers/frame_provider/decoder/utils/vdec.h b/drivers/frame_provider/decoder/utils/vdec.h
index 06b565d..8b0aaf2 100644
--- a/drivers/frame_provider/decoder/utils/vdec.h
+++ b/drivers/frame_provider/decoder/utils/vdec.h
@@ -128,7 +128,6 @@ extern void vdec_fill_vdec_frame(struct vdec_s *vdec,
struct vframe_s *vf, u32 hw_dec_time);
extern void vdec_set_vframe_comm(struct vdec_s *vdec, char *n);
-
struct vdec_s;
enum vformat_t;
@@ -369,7 +368,6 @@ extern int vdec_destroy(struct vdec_s *vdec);
extern int vdec_reset(struct vdec_s *vdec);
extern int vdec_v4l2_reset(struct vdec_s *vdec, int flag);
-
extern void vdec_set_status(struct vdec_s *vdec, int status);
extern void vdec_set_next_status(struct vdec_s *vdec, int status);
@@ -431,7 +429,9 @@ extern void vdec_core_finish_run(struct vdec_s *vdec, unsigned long mask);
#ifdef VDEC_DEBUG_SUPPORT
extern void vdec_set_step_mode(void);
#endif
+
extern void hevc_mmu_dma_check(struct vdec_s *vdec);
+
int vdec_read_user_data(struct vdec_s *vdec,
struct userdata_param_t *p_userdata_param);
@@ -448,7 +448,6 @@ int vdec_get_debug_flags(void);
void VDEC_PRINT_FUN_LINENO(const char *fun, int line);
-
unsigned char is_mult_inc(unsigned int);
int vdec_get_status(struct vdec_s *vdec);
diff --git a/drivers/frame_provider/decoder/utils/vdec_input.c b/drivers/frame_provider/decoder/utils/vdec_input.c
index 1a39cbd..4965cff 100644
--- a/drivers/frame_provider/decoder/utils/vdec_input.c
+++ b/drivers/frame_provider/decoder/utils/vdec_input.c
@@ -20,15 +20,12 @@
#include <linux/slab.h>
#include <linux/dma-mapping.h>
#include <linux/amlogic/media/codec_mm/codec_mm.h>
-
#include "../../../stream_input/amports/amports_priv.h"
#include "vdec.h"
#include "vdec_input.h"
-
#include <asm/cacheflush.h>
#include <linux/crc32.h>
-
#define VFRAME_BLOCK_SIZE (512 * SZ_1K)/*512 for 1080p default init.*/
#define VFRAME_BLOCK_SIZE_4K (2 * SZ_1M) /*2M for 4K default.*/
#define VFRAME_BLOCK_SIZE_MAX (4 * SZ_1M)
@@ -62,7 +59,7 @@ static int aml_copy_from_user(void *to, const void *from, ulong n)
{
int ret =0;
- if (likely(access_ok(VERIFY_READ, from, n)))
+ if (likely(access_ok(from, n)))
ret = copy_from_user(to, from, n);
else
memcpy(to, from, n);
@@ -326,6 +323,7 @@ static int vdec_input_dump_block_locked(
char sbuf[512];
int tsize = 0;
int s;
+
if (!pbuf) {
pbuf = sbuf;
size = 512;
@@ -412,6 +410,7 @@ int vdec_input_dump_blocks(struct vdec_input_s *input,
s += vdec_input_dump_block_locked(block, lbuf, size - s);
}
vdec_input_unlock(input, flags);
+
return s;
}
@@ -424,6 +423,7 @@ static int vdec_input_dump_chunk_locked(
char sbuf[512];
int tsize = 0;
int s;
+
if (!pbuf) {
pbuf = sbuf;
size = 512;
@@ -470,6 +470,7 @@ int vdec_input_dump_chunks(int id, struct vdec_input_s *input,
if (size <= 0)
return 0;
+
if (!bufs)
lbuf = sbuf;
s = snprintf(lbuf + s, size - s,
@@ -500,6 +501,7 @@ int vdec_input_dump_chunks(int id, struct vdec_input_s *input,
break;
}
vdec_input_unlock(input, flags);
+
return s;
}
@@ -765,6 +767,7 @@ int vdec_input_add_chunk(struct vdec_input_s *input, const char *buf,
struct vframe_chunk_s *chunk;
struct vdec_s *vdec = input->vdec;
struct vframe_block_list_s *block;
+
int need_pading_size = MIN_FRAME_PADDING_SIZE;
if (vdec_secure(vdec)) {
@@ -966,7 +969,6 @@ int vdec_input_add_frame(struct vdec_input_s *input, const char *buf,
} else {
ret = vdec_input_add_chunk(input, buf, count, 0);
}
-
return ret;
}
EXPORT_SYMBOL(vdec_input_add_frame);
@@ -1141,5 +1143,3 @@ u32 vdec_input_get_freed_handle(struct vdec_s *vdec)
return handle;
}
EXPORT_SYMBOL(vdec_input_get_freed_handle);
-
-
diff --git a/drivers/frame_provider/decoder/utils/vdec_profile.c b/drivers/frame_provider/decoder/utils/vdec_profile.c
index d00987a..95be88f 100644
--- a/drivers/frame_provider/decoder/utils/vdec_profile.c
+++ b/drivers/frame_provider/decoder/utils/vdec_profile.c
@@ -20,14 +20,12 @@
#include <linux/types.h>
#include <linux/debugfs.h>
#include <linux/moduleparam.h>
-
-
+#include <linux/sched/clock.h>
#include <linux/amlogic/media/utils/vdec_reg.h>
#include <trace/events/meson_atrace.h>
#include "vdec_profile.h"
#include "vdec.h"
-
#define ISA_TIMERE 0x2662
#define ISA_TIMERE_HI 0x2663
@@ -112,11 +110,7 @@ static u64 get_us_time_hw(void)
static u64 get_us_time_system(void)
{
- struct timeval tv;
-
- do_gettimeofday(&tv);
-
- return div64_u64(timeval_to_ns(&tv), 1000);
+ return div64_u64(local_clock(), 1000);
}
static void vdec_profile_update_alloc_time(
diff --git a/drivers/frame_provider/decoder/vc1/vvc1.c b/drivers/frame_provider/decoder/vc1/vvc1.c
index 3904fd5..1e3e264 100644
--- a/drivers/frame_provider/decoder/vc1/vvc1.c
+++ b/drivers/frame_provider/decoder/vc1/vvc1.c
@@ -30,7 +30,6 @@
#include <linux/amlogic/media/vfm/vframe.h>
#include <linux/amlogic/media/vfm/vframe_provider.h>
#include <linux/amlogic/media/vfm/vframe_receiver.h>
-
#include <linux/amlogic/media/utils/vdec_reg.h>
#include "../utils/amvdec.h"
#include "../utils/vdec.h"
@@ -41,11 +40,10 @@
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include <linux/amlogic/media/codec_mm/configs.h>
#include "../utils/firmware.h"
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
#include <linux/delay.h>
-
-
#define DRIVER_NAME "amvdec_vc1"
#define MODULE_NAME "amvdec_vc1"
@@ -496,6 +494,7 @@ static irqreturn_t vvc1_isr(int irq, void *dev_id)
decoder_bmmu_box_get_mem_handle(
mm_blk_handle,
buffer_index);
+
kfifo_put(&display_q, (const struct vframe_s *)vf);
ATRACE_COUNTER(MODULE_NAME, vf->pts);
@@ -555,6 +554,7 @@ static irqreturn_t vvc1_isr(int irq, void *dev_id)
decoder_bmmu_box_get_mem_handle(
mm_blk_handle,
buffer_index);
+
kfifo_put(&display_q, (const struct vframe_s *)vf);
ATRACE_COUNTER(MODULE_NAME, vf->pts);
@@ -640,7 +640,6 @@ static irqreturn_t vvc1_isr(int irq, void *dev_id)
decoder_bmmu_box_get_mem_handle(
mm_blk_handle,
buffer_index);
-
kfifo_put(&display_q, (const struct vframe_s *)vf);
ATRACE_COUNTER(MODULE_NAME, vf->pts);
@@ -1017,11 +1016,8 @@ static void error_do_work(struct work_struct *work)
amvdec_start();
}
-
-static void vvc1_put_timer_func(unsigned long arg)
+static void vvc1_put_timer_func(struct timer_list *timer)
{
- struct timer_list *timer = (struct timer_list *)arg;
-
if (READ_VREG(VC1_SOS_COUNT) > 10)
schedule_work(&error_wd_work);
@@ -1057,7 +1053,7 @@ static s32 vvc1_init(void)
return -ENOMEM;
pr_info("vvc1_init, format %d\n", vvc1_amstream_dec_info.format);
- init_timer(&recycle_timer);
+ timer_setup(&recycle_timer, vvc1_put_timer_func, 0);
stat |= STAT_TIMER_INIT;
@@ -1131,10 +1127,7 @@ static s32 vvc1_init(void)
stat |= STAT_VF_HOOK;
- recycle_timer.data = (ulong)&recycle_timer;
- recycle_timer.function = vvc1_put_timer_func;
recycle_timer.expires = jiffies + PUT_INTERVAL;
-
add_timer(&recycle_timer);
stat |= STAT_TIMER_ARM;
@@ -1236,32 +1229,16 @@ static int amvdec_vc1_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int vc1_suspend(struct device *dev)
-{
- amvdec_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int vc1_resume(struct device *dev)
-{
- amvdec_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops vc1_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(vc1_suspend, vc1_resume)
-};
-#endif
static struct platform_driver amvdec_vc1_driver = {
.probe = amvdec_vc1_probe,
.remove = amvdec_vc1_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &vc1_pm_ops,
+ .suspend = amvdec_suspend,
+ .resume = amvdec_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
diff --git a/drivers/frame_provider/decoder/vp9/vvp9.c b/drivers/frame_provider/decoder/vp9/vvp9.c
index 83efc23..43f1376 100644
--- a/drivers/frame_provider/decoder/vp9/vvp9.c
+++ b/drivers/frame_provider/decoder/vp9/vvp9.c
@@ -37,14 +37,15 @@
#include <linux/dma-mapping.h>
#include <linux/dma-contiguous.h>
#include <linux/slab.h>
-#include <linux/amlogic/tee.h>
+//#include <linux/amlogic/tee.h>
+#include <uapi/linux/tee.h>
+#include <linux/sched/clock.h>
#include "../../../stream_input/amports/amports_priv.h"
#include <linux/amlogic/media/codec_mm/codec_mm.h>
#include "../utils/decoder_mmu_box.h"
#include "../utils/decoder_bmmu_box.h"
#define MEM_NAME "codec_vp9"
-/* #include <mach/am_regs.h> */
#include <linux/amlogic/media/utils/vdec_reg.h>
#include "../utils/vdec.h"
#include "../utils/amvdec.h"
@@ -64,11 +65,9 @@
#include "vvp9.h"
-
/*#define SUPPORT_FB_DECODING*/
/*#define FB_DECODING_TEST_SCHEDULE*/
-
#define HW_MASK_FRONT 0x1
#define HW_MASK_BACK 0x2
@@ -148,6 +147,7 @@
#ifdef MULTI_INSTANCE_SUPPORT
#define MAX_DECODE_INSTANCE_NUM 9
#define MULTI_DRIVER_NAME "ammvdec_vp9"
+
static unsigned int max_decode_instance_num
= MAX_DECODE_INSTANCE_NUM;
static unsigned int decode_frame_count[MAX_DECODE_INSTANCE_NUM];
@@ -208,7 +208,7 @@ static s32 vvp9_init(struct VP9Decoder_s *pbi);
#endif
static void vvp9_prot_init(struct VP9Decoder_s *pbi, u32 mask);
static int vvp9_local_init(struct VP9Decoder_s *pbi);
-static void vvp9_put_timer_func(unsigned long arg);
+static void vvp9_put_timer_func(struct timer_list *timer);
static void dump_data(struct VP9Decoder_s *pbi, int size);
static unsigned char get_data_check_sum
(struct VP9Decoder_s *pbi, int size);
@@ -936,6 +936,7 @@ struct BuffInfo_s {
struct buff_s rpm;
struct buff_s lmem;
} BuffInfo_t;
+
#ifdef MULTI_INSTANCE_SUPPORT
#define DEC_RESULT_NONE 0
#define DEC_RESULT_DONE 1
@@ -2837,7 +2838,6 @@ int vp9_bufmgr_postproc(struct VP9Decoder_s *pbi)
return 0;
}
-/*struct VP9Decoder_s vp9_decoder;*/
union param_u vp9_param;
/**************************************************
@@ -4930,6 +4930,7 @@ static int config_pic(struct VP9Decoder_s *pbi,
if ((!pbi->mmu_enable) && ((dw_mode & 0x10) == 0))
buf_size += (mc_buffer_size_h << 16);
+
if (pbi->mmu_enable) {
pic_config->header_adr = decoder_bmmu_box_get_phy_addr(
pbi->bmmu_box, HEADER_BUFFER_IDX(pic_config->index));
@@ -4947,6 +4948,7 @@ static int config_pic(struct VP9Decoder_s *pbi,
<= mpred_mv_end
) {
#endif
+
if (buf_size > 0) {
ret = decoder_bmmu_box_alloc_buf_phy(pbi->bmmu_box,
VF_BUFFER_IDX(i),
@@ -5053,7 +5055,6 @@ static void init_pic_list(struct VP9Decoder_s *pbi)
struct PIC_BUFFER_CONFIG_s *pic_config;
u32 header_size;
struct vdec_s *vdec = hw_to_vdec(pbi);
-
if (pbi->mmu_enable && ((pbi->double_write_mode & 0x10) == 0)) {
header_size = vvp9_mmu_compress_header_size(pbi);
/*alloc VP9 compress header first*/
@@ -8556,15 +8557,14 @@ static void vp9_set_clk(struct work_struct *work)
frame_height * fps;
}
-static void vvp9_put_timer_func(unsigned long arg)
+static void vvp9_put_timer_func(struct timer_list *timer)
{
- struct VP9Decoder_s *pbi = (struct VP9Decoder_s *)arg;
- struct timer_list *timer = &pbi->timer;
+ struct VP9Decoder_s *pbi = container_of(timer,
+ struct VP9Decoder_s, timer);
+ enum receviver_start_e state = RECEIVER_INACTIVE;
uint8_t empty_flag;
unsigned int buf_level;
- enum receviver_start_e state = RECEIVER_INACTIVE;
-
if (pbi->m_ins_flag) {
if (hw_to_vdec(pbi)->next_status
== VDEC_STATUS_DISCONNECTED) {
@@ -9049,12 +9049,10 @@ static s32 vvp9_init(struct VP9Decoder_s *pbi)
fw->len = fw_size;
INIT_WORK(&pbi->set_clk_work, vp9_set_clk);
- init_timer(&pbi->timer);
+ timer_setup(&pbi->timer, vvp9_put_timer_func, 0);
#ifdef MULTI_INSTANCE_SUPPORT
if (pbi->m_ins_flag) {
- pbi->timer.data = (ulong) pbi;
- pbi->timer.function = vvp9_put_timer_func;
pbi->timer.expires = jiffies + PUT_INTERVAL;
/*add_timer(&pbi->timer);
@@ -9133,14 +9131,11 @@ static s32 vvp9_init(struct VP9Decoder_s *pbi)
#endif
pbi->stat |= STAT_VF_HOOK;
- pbi->timer.data = (ulong)pbi;
- pbi->timer.function = vvp9_put_timer_func;
pbi->timer.expires = jiffies + PUT_INTERVAL;
+ add_timer(&pbi->timer);
pbi->stat |= STAT_VDEC_RUN;
- add_timer(&pbi->timer);
-
pbi->stat |= STAT_TIMER_ARM;
amhevc_start();
@@ -9295,7 +9290,7 @@ static struct VP9Decoder_s *gHevc;
static int amvdec_vp9_probe(struct platform_device *pdev)
{
struct vdec_s *pdata = *(struct vdec_s **)pdev->dev.platform_data;
- struct BUF_s BUF[MAX_BUF_NUM];
+ //struct BUF_s BUF[MAX_BUF_NUM];
struct VP9Decoder_s *pbi;
int ret;
#ifndef MULTI_INSTANCE_SUPPORT
@@ -9304,7 +9299,7 @@ static int amvdec_vp9_probe(struct platform_device *pdev)
pr_debug("%s\n", __func__);
mutex_lock(&vvp9_mutex);
- pbi = vmalloc(sizeof(struct VP9Decoder_s));
+ pbi = vzalloc(sizeof(struct VP9Decoder_s));
if (pbi == NULL) {
pr_info("\namvdec_vp9 device data allocation failed\n");
mutex_unlock(&vvp9_mutex);
@@ -9312,9 +9307,11 @@ static int amvdec_vp9_probe(struct platform_device *pdev)
}
gHevc = pbi;
+#if 0
memcpy(&BUF[0], &pbi->m_BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
memset(pbi, 0, sizeof(struct VP9Decoder_s));
memcpy(&pbi->m_BUF[0], &BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
+#endif
pbi->init_flag = 0;
pbi->first_sc_checked= 0;
@@ -9454,32 +9451,16 @@ static int amvdec_vp9_remove(struct platform_device *pdev)
}
/****************************************/
-#ifdef CONFIG_PM
-static int vp9_suspend(struct device *dev)
-{
- amhevc_suspend(to_platform_device(dev), dev->power.power_state);
- return 0;
-}
-
-static int vp9_resume(struct device *dev)
-{
- amhevc_resume(to_platform_device(dev));
- return 0;
-}
-
-static const struct dev_pm_ops vp9_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(vp9_suspend, vp9_resume)
-};
-#endif
static struct platform_driver amvdec_vp9_driver = {
.probe = amvdec_vp9_probe,
.remove = amvdec_vp9_remove,
- .driver = {
- .name = DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &vp9_pm_ops,
+ .suspend = amhevc_suspend,
+ .resume = amhevc_resume,
#endif
+ .driver = {
+ .name = DRIVER_NAME,
}
};
@@ -9918,7 +9899,6 @@ static void run_front(struct vdec_s *vdec)
vdec_schedule_work(&pbi->work);
return;
}
-
input_empty[pbi->index] = 0;
pbi->dec_result = DEC_RESULT_NONE;
pbi->start_shift_bytes = READ_VREG(HEVC_SHIFT_BYTE_COUNT);
@@ -10404,7 +10384,7 @@ static int ammvdec_vp9_probe(struct platform_device *pdev)
struct vframe_content_light_level_s content_light_level;
struct vframe_master_display_colour_s vf_dp;
- struct BUF_s BUF[MAX_BUF_NUM];
+ //struct BUF_s BUF[MAX_BUF_NUM];
struct VP9Decoder_s *pbi = NULL;
pr_debug("%s\n", __func__);
@@ -10435,8 +10415,10 @@ static int ammvdec_vp9_probe(struct platform_device *pdev)
pdata->threaded_irq_handler = vp9_threaded_irq_cb;
pdata->dump_state = vp9_dump_state;
+#if 0
memcpy(&BUF[0], &pbi->m_BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
memcpy(&pbi->m_BUF[0], &BUF[0], sizeof(struct BUF_s) * MAX_BUF_NUM);
+#endif
pbi->index = pdev->id;
@@ -10721,11 +10703,12 @@ static int ammvdec_vp9_remove(struct platform_device *pdev)
static struct platform_driver ammvdec_vp9_driver = {
.probe = ammvdec_vp9_probe,
.remove = ammvdec_vp9_remove,
- .driver = {
- .name = MULTI_DRIVER_NAME,
#ifdef CONFIG_PM
- .pm = &vp9_pm_ops,
+ .suspend = amhevc_suspend,
+ .resume = amhevc_resume,
#endif
+ .driver = {
+ .name = MULTI_DRIVER_NAME,
}
};
#endif
diff --git a/drivers/stream_input/Makefile b/drivers/stream_input/Makefile
index a6cedab..73dfd13 100644
--- a/drivers/stream_input/Makefile
+++ b/drivers/stream_input/Makefile
@@ -8,16 +8,9 @@ stream_input-objs += parser/esparser.o
stream_input-objs += parser/tsdemux.o
stream_input-objs += parser/psparser.o
stream_input-objs += parser/rmparser.o
-stream_input-objs += parser/dvb_common.o
stream_input-objs += subtitle/subtitle.o
obj-$(CONFIG_AMLOGIC_DVB) += parser/hw_demux/
-obj-$(CONFIG_AMLOGIC_DVB) += parser/demux/
-obj-$(CONFIG_AMLOGIC_DVB) += parser/dvb_ci/
-
-ccflags-y += -I.
-ccflags-y += -I$(srctree)/drivers/media/dvb-core
-
#obj-y += tv_frontend/
# obj-y += box-frontend/avl6211/
# obj-y += box-frontend/atbm8881/
diff --git a/drivers/stream_input/amports/adec.c b/drivers/stream_input/amports/adec.c
index 5bca205..0102912 100644
--- a/drivers/stream_input/amports/adec.c
+++ b/drivers/stream_input/amports/adec.c
@@ -140,20 +140,29 @@ static ssize_t addr_offset_show(struct class *class,
return sprintf(buf, "%d\n", astream_dev->offset);
}
-static struct class_attribute astream_class_attrs[] = {
- __ATTR_RO(format),
- __ATTR_RO(samplerate),
- __ATTR_RO(channum),
- __ATTR_RO(datawidth),
- __ATTR_RO(pts),
- __ATTR_RO(addr_offset),
- __ATTR_NULL
+static CLASS_ATTR_RO(format);
+static CLASS_ATTR_RO(samplerate);
+static CLASS_ATTR_RO(channum);
+static CLASS_ATTR_RO(datawidth);
+static CLASS_ATTR_RO(pts);
+static CLASS_ATTR_RO(addr_offset);
+
+static struct attribute *astream_class_attrs[] = {
+ &class_attr_format.attr,
+ &class_attr_samplerate.attr,
+ &class_attr_channum.attr,
+ &class_attr_datawidth.attr,
+ &class_attr_pts.attr,
+ &class_attr_addr_offset.attr,
+ NULL
};
+ATTRIBUTE_GROUPS(astream_class);
+
static struct class astream_class = {
- .name = "astream",
- .class_attrs = astream_class_attrs,
- };
+ .name = "astream",
+ .class_groups = astream_class_groups,
+};
#if 1
#define IO_CBUS_PHY_BASE 0xc1100000ULL
@@ -412,3 +421,4 @@ void astream_dev_unregister(void)
class_unregister(&astream_class);
}
}
+
diff --git a/drivers/stream_input/amports/amports_priv.h b/drivers/stream_input/amports/amports_priv.h
index b09118d..084c9ed 100644
--- a/drivers/stream_input/amports/amports_priv.h
+++ b/drivers/stream_input/amports/amports_priv.h
@@ -42,7 +42,6 @@ int ext_put_video_frame(struct vframe_s *vf);
int ext_register_end_frame_callback(struct amvideocap_req *req);
int amstream_request_firmware_from_sys(const char *file_name,
char *buf, int size);
-void set_vsync_pts_inc_mode(int inc);
void set_real_audio_info(void *arg);
void amstream_wakeup_userdata_poll(struct vdec_s *vdec);
diff --git a/drivers/stream_input/amports/amstream.c b/drivers/stream_input/amports/amstream.c
index 6cf5736..9322290 100644
--- a/drivers/stream_input/amports/amstream.c
+++ b/drivers/stream_input/amports/amstream.c
@@ -24,25 +24,20 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
-#include <linux/amlogic/major.h>
+#include <uapi/linux/major.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/kthread.h>
-
#include <linux/amlogic/media/utils/amstream.h>
#include <linux/amlogic/media/utils/vformat.h>
#include <linux/amlogic/media/utils/aformat.h>
-
#include <linux/amlogic/media/frame_sync/tsync.h>
#include <linux/amlogic/media/frame_sync/ptsserv.h>
#include <linux/amlogic/media/frame_sync/timestamp.h>
-
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/io.h>
-/* #include <mach/am_regs.h> */
-
#include <linux/platform_device.h>
#include <linux/mutex.h>
#include <linux/poll.h>
@@ -50,10 +45,6 @@
#include <linux/dma-contiguous.h>
#include <linux/uaccess.h>
#include <linux/clk.h>
-#if 1 /* MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6 */
-/* #include <mach/mod_gate.h> */
-/* #include <mach/power_gate.h> */
-#endif
#include "../parser/streambuf.h"
#include "../parser/streambuf_reg.h"
#include "../parser/tsdemux.h"
@@ -320,7 +311,7 @@ atomic_t userdata_ready = ATOMIC_INIT(0);
static int userdata_length;
static wait_queue_head_t amstream_userdata_wait;
#define USERDATA_FIFO_NUM 1024
-static struct userdata_poc_info_t userdata_poc_info[USERDATA_FIFO_NUM];
+static struct userdata_poc_info_t *userdata_poc_info;
static int userdata_poc_ri, userdata_poc_wi;
static int last_read_wi;
static u32 ud_ready_vdec_flag;
@@ -555,9 +546,6 @@ static void port_set_inited(struct port_priv_s *priv)
struct vdec_s *vdec = priv->vdec;
vdec->port_flag |= PORT_FLAG_INITED;
- port->flag |= PORT_FLAG_INITED;
- pr_info("vdec->port_flag=0x%x, port_flag=0x%x\n",
- vdec->port_flag, port->flag);
} else
port->flag |= PORT_FLAG_INITED;
}
@@ -719,35 +707,23 @@ static int audio_port_reset(struct stream_port_s *port,
struct stream_buf_s *pbuf)
{
int r;
- mutex_lock(&amstream_mutex);
+
if ((port->flag & PORT_FLAG_AFORMAT) == 0) {
pr_err("aformat not set\n");
- mutex_unlock(&amstream_mutex);
return 0;
}
- pr_info("audio port reset, flag:0x%x\n", port->flag);
- if ((port->flag & PORT_FLAG_INITED) == 0) {
- pr_info("audio port not inited,return\n");
- mutex_unlock(&amstream_mutex);
- return 0;
- }
-
- pr_info("audio_port_reset begin\n");
pts_stop(PTS_TYPE_AUDIO);
stbuf_release(pbuf, false);
r = stbuf_init(pbuf, NULL, false);
- if (r < 0) {
- mutex_unlock(&amstream_mutex);
+ if (r < 0)
return r;
- }
r = adec_init(port);
if (r < 0) {
audio_port_release(port, pbuf, 2);
- mutex_unlock(&amstream_mutex);
return r;
}
@@ -770,8 +746,6 @@ static int audio_port_reset(struct stream_port_s *port,
r = pts_start(PTS_TYPE_AUDIO);
- pr_info("audio_port_reset done\n");
- mutex_unlock(&amstream_mutex);
return r;
}
@@ -882,16 +856,6 @@ static void amstream_user_buffer_init(void)
pubuf->buf_rp = 0;
}
-#if 1
-/*DDD*/
-struct stream_buf_s *get_vbuf(void)
-{
- return &bufs[BUF_TYPE_VIDEO];
-}
-
-EXPORT_SYMBOL(get_vbuf);
-#endif
-
static int amstream_port_init(struct port_priv_s *priv)
{
int r = 0;
@@ -1598,7 +1562,6 @@ static int amstream_open(struct inode *inode, struct file *file)
struct stream_port_s *s;
struct stream_port_s *port = &ports[iminor(inode)];
struct port_priv_s *priv;
- VDEC_PRINT_FUN_LINENO(__func__, __LINE__);
#ifdef G12A_BRINGUP_DEBUG
if (vdec_get_debug_flags() & 0xff0000) {
pr_info("%s force open port %d\n",
@@ -1611,8 +1574,6 @@ static int amstream_open(struct inode *inode, struct file *file)
if (iminor(inode) >= amstream_port_num)
return -ENODEV;
- //pr_err("%s, port name %s\n", __func__, port->name);
- //pr_err("%s [pid=%d,tgid=%d]\n", __func__, current->pid, current->tgid);
mutex_lock(&amstream_mutex);
if (port->type & PORT_TYPE_VIDEO) {
@@ -1727,6 +1688,7 @@ static int amstream_open(struct inode *inode, struct file *file)
}
}
}
+
return 0;
}
@@ -1794,10 +1756,8 @@ static int amstream_release(struct inode *inode, struct file *file)
#else
if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_TXLX
&& port->vformat == VFORMAT_H264
- && bufs[BUF_TYPE_VIDEO].for_4k) {
+ && bufs[BUF_TYPE_VIDEO].for_4k)
vdec_poweroff(VDEC_HEVC);
- bufs[BUF_TYPE_VIDEO].for_4k = 0;
- }
if ((port->vformat == VFORMAT_HEVC
|| port->vformat == VFORMAT_AVS2
@@ -2654,7 +2614,6 @@ static long amstream_do_ioctl_new(struct port_priv_s *priv,
tmpbuf,
slots*sizeof(struct vframe_counter_s))) {
r = -EFAULT;
- kfree(tmpbuf);
break;
}
}else { //For compatibility, only copy the qos
@@ -3157,19 +3116,19 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
struct vdec_s *vdec;
p_userdata_param = &param;
+
if (copy_from_user(p_userdata_param,
(void __user *)arg,
sizeof(struct userdata_param_t))) {
r = -EFAULT;
break;
}
- mutex_lock(&amstream_mutex);
+
vdec = vdec_get_vdec_by_id(p_userdata_param->instance_id);
if (vdec) {
if (vdec_read_user_data(vdec,
p_userdata_param) == 0) {
r = -EFAULT;
- mutex_unlock(&amstream_mutex);
break;
}
@@ -3179,7 +3138,6 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
r = -EFAULT;
} else
r = -EINVAL;
- mutex_unlock(&amstream_mutex);
}
}
break;
@@ -3210,14 +3168,12 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
struct vdec_s *vdec;
int vdec_id;
- mutex_lock(&amstream_mutex);
get_user(vdec_id, (int __user *)arg);
vdec = vdec_get_vdec_by_id(vdec_id);
if (vdec) {
vdec_reset_userdata_fifo(vdec, 0);
pr_info("reset_userdata_fifo for vdec: %d\n", vdec_id);
}
- mutex_unlock(&amstream_mutex);
} else
r = -EINVAL;
break;
@@ -3287,10 +3243,17 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
case AMSTREAM_IOC_SUB_INFO:
if (arg > 0) {
- struct subtitle_info msub_info[MAX_SUB_NUM];
- struct subtitle_info *psub_info[MAX_SUB_NUM];
+ struct subtitle_info *msub_info =
+ vzalloc(sizeof(struct subtitle_info) * MAX_SUB_NUM);
+ struct subtitle_info **psub_info =
+ vzalloc(sizeof(struct subtitle_info) * MAX_SUB_NUM);
int i;
+ if (!msub_info || !psub_info) {
+ r = -ENOMEM;
+ break;
+ }
+
for (i = 0; i < MAX_SUB_NUM; i++)
psub_info[i] = &msub_info[i];
@@ -3301,6 +3264,8 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
sizeof(struct subtitle_info) * MAX_SUB_NUM))
r = -EFAULT;
}
+ vfree(msub_info);
+ vfree(psub_info);
}
break;
case AMSTREAM_IOC_SET_DEMUX:
@@ -3369,18 +3334,11 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
}
case AMSTREAM_IOC_SET_DRMMODE:
if ((u32) arg == 1) {
- pr_err("set drmmode, input must be secure buffer\n");
+ pr_err("set drmmode\n");
this->flag |= PORT_FLAG_DRM;
if ((this->type & PORT_TYPE_VIDEO) &&
(priv->vdec))
priv->vdec->port_flag |= PORT_FLAG_DRM;
- } else if ((u32)arg == 2) {
- pr_err("set drmmode, input must be normal buffer\n");
- if ((this->type & PORT_TYPE_VIDEO) &&
- (priv->vdec)) {
- pr_err("vdec port_flag with drmmode\n");
- priv->vdec->port_flag |= PORT_FLAG_DRM;
- }
} else {
this->flag &= (~PORT_FLAG_DRM);
pr_err("no drmmode\n");
@@ -3400,59 +3358,6 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
tsync_set_apts(pts);
break;
}
- case AMSTREAM_IOC_SET_CRC: {
- struct usr_crc_info_t crc_info;
- struct vdec_s *vdec;
-
- if (copy_from_user(&crc_info, (void __user *)arg,
- sizeof(struct usr_crc_info_t))) {
- return -EFAULT;
- }
- /*
- pr_info("id %d, frame %d, y_crc: %08x, uv_crc: %08x\n", crc_info.id,
- crc_info.pic_num, crc_info.y_crc, crc_info.uv_crc);
- */
- vdec = vdec_get_vdec_by_id(crc_info.id);
- if (vdec == NULL)
- return -ENODEV;
- if (vdec->vfc.cmp_pool == NULL) {
- vdec->vfc.cmp_pool =
- vmalloc(USER_CMP_POOL_MAX_SIZE *
- sizeof(struct usr_crc_info_t));
- if (vdec->vfc.cmp_pool == NULL)
- return -ENOMEM;
- }
- if (vdec->vfc.usr_cmp_num >= USER_CMP_POOL_MAX_SIZE) {
- pr_info("warn: could not write any more, max %d",
- USER_CMP_POOL_MAX_SIZE);
- return -EFAULT;
- }
- memcpy(&vdec->vfc.cmp_pool[vdec->vfc.usr_cmp_num], &crc_info,
- sizeof(struct usr_crc_info_t));
- vdec->vfc.usr_cmp_num++;
- break;
- }
- case AMSTREAM_IOC_GET_CRC_CMP_RESULT: {
- int val, vdec_id;
- struct vdec_s *vdec;
-
- if (get_user(val, (int __user *)arg)) {
- return -EFAULT;
- }
- vdec_id = val & 0x00ff;
- vdec = vdec_get_vdec_by_id(vdec_id);
- if (vdec == NULL)
- return -ENODEV;
- if (val & 0xff00)
- put_user(vdec->vfc.usr_cmp_num, (int *)arg);
- else
- put_user(vdec->vfc.usr_cmp_result, (int *)arg);
- /*
- pr_info("amstream get crc32 cmpare num %d result: %d\n",
- vdec->vfc.usr_cmp_num, vdec->vfc.usr_cmp_result);
- */
- break;
- }
default:
r = -ENOIOCTLCMD;
break;
@@ -3545,7 +3450,7 @@ static long amstream_ioc_setget_ptr(struct port_priv_s *priv,
return -EFAULT;
data = compat_alloc_user_space(sizeof(*data));
- if (!access_ok(VERIFY_WRITE, data, sizeof(*data)))
+ if (!access_ok(data, sizeof(*data)))
return -EFAULT;
if (put_user(param.cmd, &data->cmd) ||
@@ -3574,7 +3479,7 @@ static long amstream_set_sysinfo(struct port_priv_s *priv,
return -EFAULT;
data = compat_alloc_user_space(sizeof(*data));
- if (!access_ok(VERIFY_WRITE, data, sizeof(*data)))
+ if (!access_ok(data, sizeof(*data)))
return -EFAULT;
if (copy_in_user(data, data32, 7 * sizeof(u32)))
return -EFAULT;
@@ -3623,7 +3528,7 @@ static long amstream_ioc_get_userdata(struct port_priv_s *priv,
return -EFAULT;
data = compat_alloc_user_space(sizeof(*data));
- if (!access_ok(VERIFY_WRITE, data, sizeof(*data)))
+ if (!access_ok(data, sizeof(*data)))
return -EFAULT;
if (copy_in_user(data, data32, 4 * sizeof(u32)))
@@ -3936,7 +3841,7 @@ static int reset_canuse_buferlevel(int levelx10000)
return 0;
}
-static ssize_t show_canuse_buferlevel(struct class *class,
+static ssize_t canuse_buferlevel_show(struct class *class,
struct class_attribute *attr, char *buf)
{
ssize_t size = sprintf(buf,
@@ -3945,7 +3850,7 @@ static ssize_t show_canuse_buferlevel(struct class *class,
return size;
}
-static ssize_t store_canuse_buferlevel(struct class *class,
+static ssize_t canuse_buferlevel_store(struct class *class,
struct class_attribute *attr,
const char *buf, size_t size)
{
@@ -3962,7 +3867,7 @@ static ssize_t store_canuse_buferlevel(struct class *class,
return size;
}
-static ssize_t store_maxdelay(struct class *class,
+static ssize_t max_buffer_delay_ms_store(struct class *class,
struct class_attribute *attr,
const char *buf, size_t size)
{
@@ -3979,7 +3884,7 @@ static ssize_t store_maxdelay(struct class *class,
return size;
}
-static ssize_t show_maxdelay(struct class *class,
+static ssize_t max_buffer_delay_ms_show(struct class *class,
struct class_attribute *attr,
char *buf)
{
@@ -3992,163 +3897,28 @@ static ssize_t show_maxdelay(struct class *class,
return size;
}
-static ssize_t audio_path_store(struct class *class,
- struct class_attribute *attr,
- const char *buf, size_t size)
-{
- unsigned int val = 0;
- int i;
- ssize_t ret;
- struct stream_buf_s *pabuf = &bufs[BUF_TYPE_AUDIO];
- struct stream_port_s *this;
- ret = kstrtoint(buf, 0, &val);
- if (ret != 0)
- return -EINVAL;
- if (val != 1)
- return -EINVAL;
- for (i = 0; i < MAX_AMSTREAM_PORT_NUM; i++) {
- if (strcmp(ports[i].name, "amstream_mpts") == 0 ||
- strcmp(ports[i].name, "amstream_mpts_sched") == 0) {
- this = &ports[i];
- if ((this->flag & PORT_FLAG_AFORMAT) != 0) {
- pr_info("audio_port_reset %s\n", ports[i].name);
- audio_port_reset(this, pabuf);
- }
- }
- }
- return size;
-}
-
-ssize_t dump_stream_show(struct class *class,
- struct class_attribute *attr, char *buf)
-{
- char *p_buf = buf;
-
- p_buf += sprintf(p_buf, "\nmdkir -p /data/tmp -m 777;setenforce 0;\n\n");
- p_buf += sprintf(p_buf, "video:\n\t echo 0 > /sys/class/amstream/dump_stream;\n");
- p_buf += sprintf(p_buf, "hevc :\n\t echo 4 > /sys/class/amstream/dump_stream;\n");
-
- return p_buf - buf;
-}
-
-#define DUMP_STREAM_FILE "/data/tmp/dump_stream.h264"
-ssize_t dump_stream_store(struct class *class,
- struct class_attribute *attr,
- const char *buf, size_t size)
-{
- struct stream_buf_s *p_buf;
- int ret = 0, id = 0;
- unsigned int stride, remain, level, vmap_size;
- int write_size;
- void *stbuf_vaddr;
- unsigned long offset;
- struct file *fp;
- mm_segment_t old_fs;
- loff_t fpos;
-
- ret = sscanf(buf, "%d", &id);
- if (ret < 0) {
- pr_info("paser buf id fail, default id = 0\n");
- id = 0;
- }
- if (id != BUF_TYPE_VIDEO && id != BUF_TYPE_HEVC) {
- pr_info("buf id out of range, max %d, id %d, set default id 0\n", BUF_MAX_NUM - 1, id);
- id = 0;
- }
- p_buf = get_stream_buffer(id);
- if (!p_buf) {
- pr_info("get buf fail, id %d\n", id);
- return size;
- }
- if ((!p_buf->buf_size) || (p_buf->is_secure) || (!(p_buf->flag & BUF_FLAG_IN_USE))) {
- pr_info("buf size %d, is_secure %d, in_use %d, it can not dump\n",
- p_buf->buf_size, p_buf->is_secure, (p_buf->flag & BUF_FLAG_IN_USE));
- return size;
- }
-
- level = stbuf_level(p_buf);
- if (!level || level > p_buf->buf_size) {
- pr_info("stream buf level %d, buf size %d, error return\n", level, p_buf->buf_size);
- return size;
- }
-
- fp = filp_open(DUMP_STREAM_FILE, O_CREAT | O_RDWR, 0666);
- if (IS_ERR(fp)) {
- fp = NULL;
- pr_info("create dump stream file failed\n");
- return size;
- }
-
- offset = p_buf->buf_start;
- remain = level;
- stride = SZ_1M;
- vmap_size = 0;
- fpos = 0;
- pr_info("create file success, it will dump from addr 0x%lx, size 0x%x\n", offset, remain);
- while (remain > 0) {
- if (remain > stride)
- vmap_size = stride;
- else {
- stride = remain;
- vmap_size = stride;
- }
-
- stbuf_vaddr = codec_mm_vmap(offset, vmap_size);
- if (stbuf_vaddr == NULL) {
- stride >>= 1;
- pr_info("vmap fail change vmap stide size 0x%x\n", stride);
- continue;
- }
- codec_mm_dma_flush(stbuf_vaddr, vmap_size, DMA_FROM_DEVICE);
-
- old_fs = get_fs();
- set_fs(KERNEL_DS);
- write_size = vfs_write(fp, stbuf_vaddr, vmap_size, &fpos);
- if (write_size < vmap_size) {
- write_size += vfs_write(fp, stbuf_vaddr + write_size, vmap_size - write_size, &fpos);
- pr_info("fail write retry, total %d, write %d\n", vmap_size, write_size);
- if (write_size < vmap_size) {
- pr_info("retry fail, interrupt dump stream, break\n");
- break;
- }
- }
- set_fs(old_fs);
- vfs_fsync(fp, 0);
- pr_info("vmap_size 0x%x dump size 0x%x\n", vmap_size, write_size);
-
- offset += vmap_size;
- remain -= vmap_size;
- codec_mm_unmap_phyaddr(stbuf_vaddr);
- }
-
- filp_close(fp, current->files);
- pr_info("dump stream buf end\n");
-
- return size;
-}
-
-
-
-
-static struct class_attribute amstream_class_attrs[] = {
- __ATTR_RO(ports),
- __ATTR_RO(bufs),
- __ATTR_RO(vcodec_profile),
- __ATTR_RO(videobufused),
- __ATTR(canuse_buferlevel, S_IRUGO | S_IWUSR | S_IWGRP,
- show_canuse_buferlevel, store_canuse_buferlevel),
- __ATTR(max_buffer_delay_ms, S_IRUGO | S_IWUSR | S_IWGRP, show_maxdelay,
- store_maxdelay),
- __ATTR(reset_audio_port, S_IRUGO | S_IWUSR | S_IWGRP,
- NULL, audio_path_store),
- __ATTR(dump_stream, S_IRUGO | S_IWUSR | S_IWGRP,
- dump_stream_show, dump_stream_store),
- __ATTR_NULL
+static CLASS_ATTR_RO(ports);
+static CLASS_ATTR_RO(bufs);
+static CLASS_ATTR_RO(vcodec_profile);
+static CLASS_ATTR_RO(videobufused);
+static CLASS_ATTR_RW(canuse_buferlevel);
+static CLASS_ATTR_RW(max_buffer_delay_ms);
+
+static struct attribute *amstream_class_attrs[] = {
+ &class_attr_ports.attr,
+ &class_attr_bufs.attr,
+ &class_attr_vcodec_profile.attr,
+ &class_attr_videobufused.attr,
+ &class_attr_canuse_buferlevel.attr,
+ &class_attr_max_buffer_delay_ms.attr,
+ NULL
};
+ATTRIBUTE_GROUPS(amstream_class);
+
static struct class amstream_class = {
- .name = "amstream",
- .class_attrs = amstream_class_attrs,
+ .name = "amstream",
+ .class_groups = amstream_class_groups,
};
int amstream_request_firmware_from_sys(const char *file_name,
@@ -4292,6 +4062,12 @@ static int amstream_probe(struct platform_device *pdev)
if (get_cpu_major_id() == AM_MESON_CPU_MAJOR_ID_G12A)
vdec_power_reset();
+ userdata_poc_info =
+ vzalloc(sizeof(struct userdata_poc_info_t) *
+ USERDATA_FIFO_NUM);
+ if (!userdata_poc_info)
+ return -ENOMEM;
+
return 0;
/*
@@ -4333,6 +4109,11 @@ static int amstream_remove(struct platform_device *pdev)
amstream_adec_status = NULL;
+ if (userdata_poc_info) {
+ vfree(userdata_poc_info);
+ userdata_poc_info = NULL;
+ }
+
pr_err("Amlogic A/V streaming port release\n");
return 0;
diff --git a/drivers/stream_input/parser/esparser.c b/drivers/stream_input/parser/esparser.c
index f81ba0c..1cf8f02 100644
--- a/drivers/stream_input/parser/esparser.c
+++ b/drivers/stream_input/parser/esparser.c
@@ -166,7 +166,6 @@ static ssize_t _esparser_write(const char __user *buf,
dma_addr_t dma_addr = 0;
u32 type = stbuf->type;
- VDEC_PRINT_FUN_LINENO(__func__, __LINE__);
if (type == BUF_TYPE_HEVC)
parser_type = PARSER_VIDEO;
else if (type == BUF_TYPE_VIDEO)
@@ -251,8 +250,6 @@ static ssize_t _esparser_write(const char __user *buf,
audio_data_parsed += len;
threadrw_update_buffer_level(stbuf, len);
- VDEC_PRINT_FUN_LINENO(__func__, __LINE__);
-
return len;
}
@@ -264,8 +261,8 @@ static ssize_t _esparser_write_s(const char __user *buf,
u32 len = 0;
int ret;
u32 wp, buf_start, buf_end;
+ dma_addr_t buf_wp_map;
u32 type = stbuf->type;
- void *vaddr = NULL;
if (type != BUF_TYPE_AUDIO)
BUG();
@@ -275,25 +272,24 @@ static ssize_t _esparser_write_s(const char __user *buf,
/*pr_info("write wp 0x%x, count %d, start 0x%x, end 0x%x\n",
* wp, (u32)count, buf_start, buf_end);*/
if (wp + count > buf_end) {
- if (wp == buf_end) {
- wp = buf_start;
- set_buf_wp(type, wp);
- return -EAGAIN;
- }
- vaddr = codec_mm_phys_to_virt(wp);
- ret = copy_from_user(vaddr, p, buf_end - wp);
+ ret = copy_from_user(codec_mm_phys_to_virt(wp),
+ p, buf_end - wp);
if (ret > 0) {
len += buf_end - wp - ret;
- codec_mm_dma_flush(vaddr, len, DMA_TO_DEVICE);
+ buf_wp_map = dma_map_single(amports_get_dma_device(),
+ codec_mm_phys_to_virt(wp), len, DMA_TO_DEVICE);
wp += len;
pr_info("copy from user not finished\n");
+ dma_unmap_single(NULL, buf_wp_map, len, DMA_TO_DEVICE);
set_buf_wp(type, wp);
goto end_write;
} else if (ret == 0) {
len += buf_end - wp;
- codec_mm_dma_flush(vaddr, len, DMA_TO_DEVICE);
+ buf_wp_map = dma_map_single(amports_get_dma_device(),
+ codec_mm_phys_to_virt(wp), len, DMA_TO_DEVICE);
wp = buf_start;
r = count - len;
+ dma_unmap_single(NULL, buf_wp_map, len, DMA_TO_DEVICE);
set_buf_wp(type, wp);
} else {
pr_info("copy from user failed 1\n");
@@ -302,15 +298,16 @@ static ssize_t _esparser_write_s(const char __user *buf,
return -EAGAIN;
}
}
-
- vaddr = codec_mm_phys_to_virt(wp);
- ret = copy_from_user(vaddr, p + len, r);
+ ret = copy_from_user(codec_mm_phys_to_virt(wp), p + len, r);
if (ret >= 0) {
len += r - ret;
- codec_mm_dma_flush(vaddr, r - ret, DMA_TO_DEVICE);
+ buf_wp_map = dma_map_single(amports_get_dma_device(),
+ codec_mm_phys_to_virt(wp), r - ret, DMA_TO_DEVICE);
+
if (ret > 0)
pr_info("copy from user not finished 2\n");
wp += r - ret;
+ dma_unmap_single(NULL, buf_wp_map, r - ret, DMA_TO_DEVICE);
set_buf_wp(type, wp);
} else {
pr_info("copy from user failed 2\n");
@@ -396,8 +393,6 @@ s32 esparser_init(struct stream_buf_s *buf, struct vdec_s *vdec)
u32 parser_sub_rp;
bool first_use = false;
/* #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */
- VDEC_PRINT_FUN_LINENO(__func__, __LINE__);
-
if (has_hevc_vdec() && (buf->type == BUF_TYPE_HEVC))
pts_type = PTS_TYPE_HEVC;
else
@@ -452,15 +447,13 @@ s32 esparser_init(struct stream_buf_s *buf, struct vdec_s *vdec)
/* reset PARSER with first esparser_init() call */
WRITE_RESET_REG(RESET1_REGISTER, RESET_PARSER);
-/* for recorded file and local play, this can't change the input source*/
-/* TS data path */
-/*
+
+ /* TS data path */
#ifndef CONFIG_AM_DVB
WRITE_DEMUX_REG(FEC_INPUT_CONTROL, 0);
#else
tsdemux_set_reset_flag();
-#endif */
-
+#endif
CLEAR_DEMUX_REG_MASK(TS_HIU_CTL, 1 << USE_HI_BSF_INTERFACE);
CLEAR_DEMUX_REG_MASK(TS_HIU_CTL_2, 1 << USE_HI_BSF_INTERFACE);
CLEAR_DEMUX_REG_MASK(TS_HIU_CTL_3, 1 << USE_HI_BSF_INTERFACE);
@@ -523,9 +516,7 @@ s32 esparser_init(struct stream_buf_s *buf, struct vdec_s *vdec)
vdec->input.start);
WRITE_PARSER_REG(PARSER_VIDEO_END_PTR,
vdec->input.start + vdec->input.size - 8);
- if (vdec_single(vdec) || (vdec_get_debug_flags() & 0x2)) {
- if (vdec_get_debug_flags() & 0x2)
- pr_info("%s %d\n", __func__, __LINE__);
+ if (vdec_single(vdec)) {
CLEAR_PARSER_REG_MASK(PARSER_ES_CONTROL,
ES_VID_MAN_RD_PTR);
@@ -603,7 +594,6 @@ s32 esparser_init(struct stream_buf_s *buf, struct vdec_s *vdec)
pr_info("esparser_init: irq register failed.\n");
goto Err_2;
}
- VDEC_PRINT_FUN_LINENO(__func__, __LINE__);
WRITE_PARSER_REG(PARSER_INT_STATUS, 0xffff);
WRITE_PARSER_REG(PARSER_INT_ENABLE,
@@ -749,6 +739,7 @@ ssize_t drm_write(struct file *file, struct stream_buf_s *stbuf,
s32 r;
u32 len;
u32 realcount, totalcount;
+ u32 re_count = count;
u32 havewritebytes = 0;
u32 leftcount = 0;
@@ -857,12 +848,7 @@ ssize_t drm_write(struct file *file, struct stream_buf_s *stbuf,
mutex_unlock(&esparser_mutex);
}
- if ((drm->drm_flag & TYPE_DRMINFO) && (drm->drm_hasesdata == 0)) {
- havewritebytes = sizeof(struct drm_info);
- } else if (drm->drm_hasesdata == 1) {
- havewritebytes += sizeof(struct drm_info);
- }
- return havewritebytes;
+ return re_count;
}
EXPORT_SYMBOL(drm_write);
diff --git a/drivers/stream_input/parser/psparser.c b/drivers/stream_input/parser/psparser.c
index 771314a..3197976 100644
--- a/drivers/stream_input/parser/psparser.c
+++ b/drivers/stream_input/parser/psparser.c
@@ -893,15 +893,12 @@ s32 psparser_init(u32 vid, u32 aid, u32 sid, struct vdec_s *vdec)
WRITE_RESET_REG(RESET1_REGISTER, RESET_PARSER);
-/* for recorded file and local play, this can't change the input source*/
/* TS data path */
-/*
#ifndef CONFIG_AM_DVB
WRITE_DEMUX_REG(FEC_INPUT_CONTROL, 0);
#else
tsdemux_set_reset_flag();
-#endif */
-
+#endif
CLEAR_DEMUX_REG_MASK(TS_HIU_CTL, 1 << USE_HI_BSF_INTERFACE);
CLEAR_DEMUX_REG_MASK(TS_HIU_CTL_2, 1 << USE_HI_BSF_INTERFACE);
CLEAR_DEMUX_REG_MASK(TS_HIU_CTL_3, 1 << USE_HI_BSF_INTERFACE);
diff --git a/drivers/stream_input/parser/rmparser.c b/drivers/stream_input/parser/rmparser.c
index 9f7a1b0..1c4aa78 100644
--- a/drivers/stream_input/parser/rmparser.c
+++ b/drivers/stream_input/parser/rmparser.c
@@ -69,15 +69,12 @@ s32 rmparser_init(struct vdec_s *vdec)
WRITE_RESET_REG(RESET1_REGISTER, RESET_PARSER);
-/* for recorded file and local play, this can't change the input source*/
/* TS data path */
-/*
#ifndef CONFIG_AM_DVB
WRITE_DEMUX_REG(FEC_INPUT_CONTROL, 0);
#else
tsdemux_set_reset_flag();
-#endif */
-
+#endif
CLEAR_DEMUX_REG_MASK(TS_HIU_CTL, 1 << USE_HI_BSF_INTERFACE);
CLEAR_DEMUX_REG_MASK(TS_HIU_CTL_2, 1 << USE_HI_BSF_INTERFACE);
CLEAR_DEMUX_REG_MASK(TS_HIU_CTL_3, 1 << USE_HI_BSF_INTERFACE);
diff --git a/drivers/stream_input/parser/streambuf.c b/drivers/stream_input/parser/streambuf.c
index 1060770..49a7762 100644
--- a/drivers/stream_input/parser/streambuf.c
+++ b/drivers/stream_input/parser/streambuf.c
@@ -23,12 +23,9 @@
#include <linux/io.h>
#include <linux/amlogic/media/frame_sync/ptsserv.h>
#include <linux/amlogic/media/utils/vformat.h>
-#include <linux/amlogic/iomap.h>
#include <asm/cacheflush.h>
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
-/* #include <mach/am_regs.h> */
-
#include <linux/amlogic/media/utils/vdec_reg.h>
#include "../../frame_provider/decoder/utils/vdec.h"
#include "streambuf_reg.h"
@@ -194,9 +191,10 @@ void stbuf_fetch_release(void)
}
}
-static void _stbuf_timer_func(unsigned long arg)
+static void _stbuf_timer_func(struct timer_list *timer)
{
- struct stream_buf_s *p = (struct stream_buf_s *)arg;
+ struct stream_buf_s *p = container_of(timer,
+ struct stream_buf_s, timer);
if (stbuf_space(p) < p->wcnt) {
p->timer.expires = jiffies + STBUF_WAIT_INTERVAL;
@@ -277,8 +275,6 @@ s32 stbuf_init(struct stream_buf_s *buf, struct vdec_s *vdec, bool is_multi)
u32 dummy;
u32 addr32;
- VDEC_PRINT_FUN_LINENO(__func__, __LINE__);
-
if (!buf->buf_start) {
r = _stbuf_alloc(buf, (vdec) ?
vdec->port_flag & PORT_FLAG_DRM : 0);
@@ -304,9 +300,10 @@ s32 stbuf_init(struct stream_buf_s *buf, struct vdec_s *vdec, bool is_multi)
}
buf->write_thread = 0;
- if (((vdec && !vdec_single(vdec)) || (is_multi)) &&
- (vdec_get_debug_flags() & 0x2) == 0)
+
+ if ((vdec && !vdec_single(vdec)) || (is_multi))
return 0;
+
if (has_hevc_vdec() && buf->type == BUF_TYPE_HEVC) {
CLEAR_VREG_MASK(HEVC_STREAM_CONTROL, 1);
WRITE_VREG(HEVC_STREAM_START_ADDR, addr32);
@@ -318,8 +315,6 @@ s32 stbuf_init(struct stream_buf_s *buf, struct vdec_s *vdec, bool is_multi)
}
if (buf->type == BUF_TYPE_VIDEO) {
- VDEC_PRINT_FUN_LINENO(__func__, __LINE__);
-
_WRITE_ST_REG(CONTROL, 0);
/* reset VLD before setting all pointers */
WRITE_VREG(VLD_MEM_VIFIFO_WRAP_COUNT, 0);
@@ -395,7 +390,7 @@ s32 stbuf_wait_space(struct stream_buf_s *stream_buf, size_t count)
p->wcnt = count;
- setup_timer(&p->timer, _stbuf_timer_func, (ulong) p);
+ timer_setup(&p->timer, _stbuf_timer_func, 0);
mod_timer(&p->timer, jiffies + STBUF_WAIT_INTERVAL);
diff --git a/drivers/stream_input/parser/streambuf_reg.h b/drivers/stream_input/parser/streambuf_reg.h
index 5f0c8ca..cb3acb1 100644
--- a/drivers/stream_input/parser/streambuf_reg.h
+++ b/drivers/stream_input/parser/streambuf_reg.h
@@ -103,12 +103,6 @@
(VDEC2_VLD_MEM_VIFIFO_START_PTR+(r))))
#define _WRITE_VDEC2_ST_REG(r, val) codec_dosbus_write(\
(VDEC2_VLD_MEM_VIFIFO_START_PTR+r), val)
-#define MEM_BUFCTRL_MANUAL (1<<1)
-#define MEM_BUFCTRL_INIT (1<<0)
#define MEM_LEVEL_CNT_BIT 18
#define MEM_FIFO_CNT_BIT 16
-#define MEM_FILL_ON_LEVEL (1<<10)
-#define MEM_CTRL_EMPTY_EN (1<<2)
-#define MEM_CTRL_FILL_EN (1<<1)
-#define MEM_CTRL_INIT (1<<0)
#endif /* STREAMBUF_REG_H */
diff --git a/drivers/stream_input/parser/thread_rw.c b/drivers/stream_input/parser/thread_rw.c
index 4e4864f..6fe6cd8 100644
--- a/drivers/stream_input/parser/thread_rw.c
+++ b/drivers/stream_input/parser/thread_rw.c
@@ -151,8 +151,7 @@ static ssize_t threadrw_write_in(
{
int ret = 0;
int off = 0;
- /* int change to size_t for buffer overflow on OTT-5057 */
- size_t left = count;
+ int left = count;
int wait_num = 0;
unsigned long flags;
@@ -160,11 +159,14 @@ static ssize_t threadrw_write_in(
ret = threadrw_write_onece(task,
task->file,
stbuf, buf + off, left);
+ if (ret >= left) {
+ off = count;
+ left = 0;
+ } else if (ret > 0) {
+ off += ret;
+ left -= ret;
- /* firstly check ret < 0, avoid the risk of -EAGAIN in ret
- * implicit convert to size_t when compare with "size_t left".
- */
- if (ret < 0) {
+ } else if (ret < 0) {
if (off > 0) {
break; /*have write ok some data. */
} else if (ret == -EAGAIN) {
@@ -181,12 +183,6 @@ static ssize_t threadrw_write_in(
break;
}
break; /*to end */
- } else if (ret >= left) {
- off = count;
- left = 0;
- } else if (ret > 0) {
- off += ret;
- left -= ret;
}
}
diff --git a/drivers/stream_input/parser/tsdemux.c b/drivers/stream_input/parser/tsdemux.c
index ac34cf7..3ddde4e 100644
--- a/drivers/stream_input/parser/tsdemux.c
+++ b/drivers/stream_input/parser/tsdemux.c
@@ -967,21 +967,25 @@ ssize_t tsdemux_write(struct file *file,
return -EAGAIN;
}
-static ssize_t show_discontinue_counter(struct class *class,
+static ssize_t discontinue_counter_show(struct class *class,
struct class_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", discontinued_counter);
}
-static struct class_attribute tsdemux_class_attrs[] = {
- __ATTR(discontinue_counter, S_IRUGO, show_discontinue_counter, NULL),
- __ATTR_NULL
+static CLASS_ATTR_RO(discontinue_counter);
+
+static struct attribute *tsdemux_class_attrs[] = {
+ &class_attr_discontinue_counter.attr,
+ NULL
};
+ATTRIBUTE_GROUPS(tsdemux_class);
+
static struct class tsdemux_class = {
- .name = "tsdemux",
- .class_attrs = tsdemux_class_attrs,
- };
+ .name = "tsdemux",
+ .class_groups = tsdemux_class_groups,
+};
int tsdemux_class_register(void)
{