modules: the firmware loading the way was optimized.

PD#171042:
1. removed the way which used cpu type to choice fw.
2. removed redundant code.

ucode gitid
45b7330fd00f96d2e9859ac1ec91d1e46f70a1b2

Change-Id: Ie737701e682244223e437b2d6c5eb02420e10fbb
Signed-off-by: Nanxin Qin <nanxin.qin@amlogic.com>
This commit is contained in:
Nanxin Qin
2018-07-31 15:56:18 +08:00
committed by Dongjin Kim
parent 9e1e8402e0
commit 3381e66954
21 changed files with 254 additions and 247 deletions

View File

@@ -79,15 +79,12 @@ int get_firmware_data(unsigned int format, char *buf)
struct fw_mgr_s *mgr = g_mgr;
struct fw_info_s *info;
if (tee_enabled()) {
pr_info ("tee load firmware fomat = %d\n",(u32)format);
ret = tee_load_video_fw((u32)format, 0);
if (ret == 0)
ret = 1;
else
ret = -1;
return ret;
}
pr_info("[%s], the fw (%s) will be loaded.\n",
tee_enabled() ? "TEE" : "LOCAL",
get_fw_format_name(format));
if (tee_enabled())
return 0;
mutex_lock(&mutex);

View File

@@ -69,7 +69,7 @@ struct cpu_type_s {
const char *name;
};
const char *get_firmware_type_name(unsigned int format);
const char *get_fw_format_name(unsigned int format);
unsigned int get_fw_format(const char *name);
int fw_get_cpu(const char *name);

View File

@@ -42,6 +42,7 @@
#include "../utils/decoder_bmmu_box.h"
#include "../utils/firmware.h"
#include "../../../common/chips/decoder_cpu_ver_info.h"
#include <linux/amlogic/tee.h>
#define DRIVER_NAME "amvdec_avs"
#define MODULE_NAME "amvdec_avs"
@@ -1489,7 +1490,7 @@ static void init_avsp_long_cabac_buf(void)
static s32 vavs_init(void)
{
int r, size = -1;
int ret, size = -1;
char *buf = vmalloc(0x1000 * 16);
if (IS_ERR_OR_NULL(buf))
@@ -1524,19 +1525,18 @@ static s32 vavs_init(void)
return -1;
}
if (size == 1)
pr_info("tee load ok\n");
if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_GXM)
size = amvdec_loadmc_ex(VFORMAT_AVS, NULL, buf);
ret = amvdec_loadmc_ex(VFORMAT_AVS, NULL, buf);
else if (firmware_sel == 1)
size = amvdec_loadmc_ex(VFORMAT_AVS, "avs_no_cabac", buf);
ret = amvdec_loadmc_ex(VFORMAT_AVS, "avs_no_cabac", buf);
else
size = amvdec_loadmc_ex(VFORMAT_AVS, NULL, buf);
ret = amvdec_loadmc_ex(VFORMAT_AVS, NULL, buf);
if (size < 0) {
if (ret < 0) {
amvdec_disable();
vfree(buf);
pr_err("AVS: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}
@@ -1545,9 +1545,9 @@ static s32 vavs_init(void)
stat |= STAT_MC_LOAD;
/* enable AMRISC side protocol */
r = vavs_prot_init();
if (r < 0)
return r;
ret = vavs_prot_init();
if (ret < 0)
return ret;
#ifdef HANDLE_AVS_IRQ
if (vdec_request_irq(VDEC_IRQ_1, vavs_isr,

View File

@@ -54,6 +54,7 @@
#include "../utils/config_parser.h"
#include "../utils/firmware.h"
#include "../../../common/chips/decoder_cpu_ver_info.h"
#include <linux/amlogic/tee.h>
#define MIX_STREAM_SUPPORT
#define SUPPORT_4K2K
@@ -4771,7 +4772,7 @@ TODO:FOR VERSION
static s32 vavs2_init(struct vdec_s *vdec)
{
int size = -1;
int ret = -1, size = -1;
int fw_size = 0x1000 * 16;
struct firmware_s *fw = NULL;
struct AVS2Decoder_s *dec = (struct AVS2Decoder_s *)vdec->private;
@@ -4784,20 +4785,14 @@ static s32 vavs2_init(struct vdec_s *vdec)
fw = vmalloc(sizeof(struct firmware_s) + fw_size);
if (IS_ERR_OR_NULL(fw))
return -ENOMEM;
#ifdef MULTI_INSTANCE_SUPPORT
if (tee_enabled()) {
size = 1;
pr_debug ("laod\n");
} else
#endif
size = get_firmware_data(VIDEO_DEC_AVS2_MMU, fw->data);
if (size < 0) {
pr_err("get firmware fail.\n");
vfree(fw);
return -1;
}
avs2_print(dec, AVS2_DBG_BUFMGR,
"firmware size %d\n", size);
fw->len = fw_size;
if (dec->m_ins_flag) {
@@ -4817,18 +4812,18 @@ static s32 vavs2_init(struct vdec_s *vdec)
}
amhevc_enable();
if (size == 1)
pr_info ("tee load ok\n");
if (amhevc_loadmc_ex(VFORMAT_AVS2, NULL, fw->data) < 0) {
ret = amhevc_loadmc_ex(VFORMAT_AVS2, NULL, fw->data);
if (ret < 0) {
amhevc_disable();
vfree(fw);
pr_err("AVS2: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}
avs2_print(dec, AVS2_DBG_BUFMGR,
"firmware size %d\n", size);
vfree(fw);
dec->stat |= STAT_MC_LOAD;
/* enable AMRISC side protocol */

View File

@@ -2575,9 +2575,12 @@ static s32 vh264_init(void)
amvdec_enable();
if (!firmwareloaded && tee_enabled()) {
if (tee_load_video_fw((u32)VIDEO_DEC_H264, 0) != 0) {
ret = amvdec_loadmc_ex(VFORMAT_H264, NULL, NULL);
if (ret < 0) {
amvdec_disable();
return -1;
pr_err("H264: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return ret;
}
} else {
/* -- ucode loading (amrisc and swap code) */
@@ -2651,14 +2654,13 @@ static s32 vh264_init(void)
}
firmwareloaded = 1;
} else {
int ret = -1, size = -1;
int ret = -1;
char *buf = vmalloc(0x1000 * 16);
if (IS_ERR_OR_NULL(buf))
return -ENOMEM;
size = get_firmware_data(VIDEO_DEC_H264, buf);
if (size < 0) {
if (get_firmware_data(VIDEO_DEC_H264, buf) < 0) {
pr_err("get firmware fail.");
vfree(buf);
return -1;
@@ -2679,7 +2681,6 @@ static s32 vh264_init(void)
vfree(buf);
if (ret < 0) {
pr_err("h264 load orignal firmware error %d.\n", ret);
amvdec_disable();
if (mc_cpu_addr) {
dma_free_coherent(amports_get_dma_device(),
@@ -2687,6 +2688,8 @@ static s32 vh264_init(void)
mc_dma_handle);
mc_cpu_addr = NULL;
}
pr_err("H264: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}
}

View File

@@ -1438,7 +1438,6 @@ static s32 vh264_4k2k_init(void)
if (H264_4K2K_SINGLE_CORE)
size = get_firmware_data(VIDEO_DEC_H264_4k2K_SINGLE, buf);
else
size = get_firmware_data(VIDEO_DEC_H264_4k2K, buf);
@@ -1448,11 +1447,18 @@ static s32 vh264_4k2k_init(void)
return -1;
}
if (amvdec_loadmc_ex(VFORMAT_H264_4K2K, NULL, buf) < 0) {
if (H264_4K2K_SINGLE_CORE)
ret = amvdec_loadmc_ex(VFORMAT_H264_4K2K, "single_core", buf);
else
ret = amvdec_loadmc_ex(VFORMAT_H264_4K2K, NULL, buf);
if (ret < 0) {
amvdec_disable();
dma_free_coherent(amports_get_dma_device(),
MC_TOTAL_SIZE, mc_cpu_addr, mc_dma_handle);
mc_cpu_addr = NULL;
pr_err("H264_4K2K: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}

View File

@@ -1401,7 +1401,7 @@ static int vh264mvc_local_init(void)
static s32 vh264mvc_init(void)
{
int ret = -1, size = -1;
int ret = -1;
char *buf = vmalloc(0x1000 * 16);
if (buf == NULL)
@@ -1427,11 +1427,12 @@ static s32 vh264mvc_init(void)
amvdec_enable();
if (tee_enabled()) {
pr_info("the video fw from the teeload.\n");
ret = tee_load_video_fw((u32)VIDEO_DEC_H264_MVC, 0);
ret = amvdec_loadmc_ex(VFORMAT_H264MVC, NULL, buf);
if (ret != 0) {
amvdec_disable();
vfree(buf);
pr_err("H264_MVC: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -1;
}
} else {
@@ -1447,8 +1448,7 @@ static s32 vh264mvc_init(void)
WRITE_VREG(UCODE_START_ADDR, mc_dma_handle);
size = get_firmware_data(VIDEO_DEC_H264_MVC, buf);
if (size < 0) {
if (get_firmware_data(VIDEO_DEC_H264_MVC, buf) < 0) {
pr_err("get firmware fail.");
vfree(buf);
return -1;

View File

@@ -5321,6 +5321,11 @@ static void vh264_local_init(struct vdec_h264_hw_s *hw)
static s32 vh264_init(struct vdec_h264_hw_s *hw)
{
int ret = 0, size = -1;
int fw_size = 0x1000 * 16;
int fw_mmu_size = 0x1000 * 16;
struct firmware_s *fw = NULL, *fw_mmu = NULL;
/* int trickmode_fffb = 0; */
/* pr_info("\nvh264_init\n"); */
@@ -5362,11 +5367,38 @@ static s32 vh264_init(struct vdec_h264_hw_s *hw)
return -ENOMEM;
}
}
if (!tee_enabled()) {
int ret = 0, size = -1;
int fw_size = 0x1000 * 16;
struct firmware_s *fw = NULL;
fw = vmalloc(sizeof(struct firmware_s) + fw_size);
if (IS_ERR_OR_NULL(fw))
return -ENOMEM;
size = get_firmware_data(VIDEO_DEC_H264_MULTI, fw->data);
if (size < 0) {
pr_err("get firmware fail.\n");
vfree(fw);
return -1;
}
fw->len = size;
hw->fw = fw;
if (hw->mmu_enable) {
fw_mmu = vmalloc(sizeof(struct firmware_s) + fw_mmu_size);
if (IS_ERR_OR_NULL(fw_mmu))
return -ENOMEM;
size = get_firmware_data(VIDEO_DEC_H264_MULTI_MMU, fw_mmu->data);
if (size < 0) {
pr_err("get mmu fw fail.\n");
vfree(fw_mmu);
return -1;
}
fw_mmu->len = size;
hw->fw_mmu = fw_mmu;
}
if (!tee_enabled()) {
/* -- ucode loading (amrisc and swap code) */
hw->mc_cpu_addr =
dma_alloc_coherent(amports_get_dma_device(), MC_TOTAL_SIZE,
@@ -5384,23 +5416,6 @@ static s32 vh264_init(struct vdec_h264_hw_s *hw)
(void *)hw->mc_dma_handle, hw->mc_cpu_addr);
*/
pr_debug("start load orignal firmware ...\n");
fw = vmalloc(sizeof(struct firmware_s) + fw_size);
if (IS_ERR_OR_NULL(fw))
return -ENOMEM;
size = get_firmware_data(VIDEO_DEC_H264_MULTI, fw->data);
if (size < 0) {
pr_err("get firmware fail.\n");
vfree(fw);
return -1;
}
fw->len = size;
hw->fw = fw;
/*ret = amvdec_loadmc_ex(VFORMAT_H264, NULL, buf);*/
/*header*/
@@ -5428,34 +5443,11 @@ static s32 vh264_init(struct vdec_h264_hw_s *hw)
memcpy((u8 *) hw->mc_cpu_addr + MC_OFFSET_MAIN + 0x3000,
fw->data + 0x5000, 0x1000);
if (hw->mmu_enable) {
int fw_mmu_size = 0x1000 * 16;
struct firmware_s *fw_mmu = NULL;
pr_debug("start load mmu fw ...\n");
fw_mmu = vmalloc(sizeof(struct firmware_s) + fw_mmu_size);
if (IS_ERR_OR_NULL(fw_mmu))
return -ENOMEM;
size = get_firmware_data(VIDEO_DEC_H264_MULTI_MMU,
fw_mmu->data);
if (size < 0) {
pr_err("get mmu fw fail.\n");
vfree(fw_mmu);
return -1;
}
if (hw->mmu_enable)
ret = amhevc_loadmc_ex(VFORMAT_HEVC,
NULL, fw_mmu->data);
fw_mmu->len = size;
hw->fw_mmu = fw_mmu;
}
if (ret < 0) {
dpb_print(DECODE_ID(hw), PRINT_FLAG_ERROR,
"264 load orignal firmware error.\n");
amvdec_disable();
if (hw->mmu_enable)
amhevc_disable();
@@ -5465,10 +5457,15 @@ static s32 vh264_init(struct vdec_h264_hw_s *hw)
hw->mc_dma_handle);
hw->mc_cpu_addr = NULL;
}
dpb_print(DECODE_ID(hw), PRINT_FLAG_ERROR,
"MH264: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}
}
#if 1 /* #ifdef BUFFER_MGR_IN_C */
hw->lmem_addr = __get_free_page(GFP_KERNEL);
if (!hw->lmem_addr) {
@@ -6597,7 +6594,7 @@ static void run(struct vdec_s *vdec, unsigned long mask,
struct vdec_h264_hw_s *hw =
(struct vdec_h264_hw_s *)vdec->private;
struct h264_dpb_stru *p_H264_Dpb = &hw->dpb;
int size;
int size, ret = -1;
run_count[DECODE_ID(hw)]++;
if (hw->mmu_enable)
@@ -6707,39 +6704,29 @@ static void run(struct vdec_s *vdec, unsigned long mask,
start_process_time(hw);
if (tee_enabled()) {
if (tee_load_video_fw(VIDEO_DEC_H264_MULTI, 0) != 0) {
amvdec_enable_flag = false;
amvdec_disable();
dpb_print(DECODE_ID(hw), 0, "%s: Error amvdec_vdec_loadmc fail\n", __func__);
return;
}
if (hw->mmu_enable) {
if (tee_load_video_fw(VIDEO_DEC_H264_MULTI_MMU,
OPTEE_VDEC_HEVC) < 0) {
amvdec_enable_flag = false;
amhevc_disable();
dpb_print(DECODE_ID(hw), 0, "tee mmu fw load fail\n");
return;
}
}
ret = amvdec_vdec_loadmc_ex(VFORMAT_H264, "mh264", vdec, hw->fw->data);
if (ret < 0) {
amvdec_enable_flag = false;
amvdec_disable();
} else {
if (amvdec_vdec_loadmc_ex(vdec, NULL, hw->fw->data) < 0) {
dpb_print(DECODE_ID(hw), PRINT_FLAG_ERROR,
"MH264 the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return;
}
if (hw->mmu_enable) {
ret = amhevc_loadmc_ex(VFORMAT_H264, "mh264_mmu",
hw->fw_mmu->data);
if (ret < 0) {
amvdec_enable_flag = false;
amvdec_disable();
dpb_print(DECODE_ID(hw), 0, "%s: Error amvdec_vdec_loadmc fail\n", __func__);
amhevc_disable();
dpb_print(DECODE_ID(hw), PRINT_FLAG_ERROR,
"MH264_MMU the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return;
}
if (hw->mmu_enable) {
if (amhevc_loadmc_ex(VFORMAT_HEVC,
NULL, hw->fw_mmu->data) < 0) {
amvdec_enable_flag = false;
amhevc_disable();
dpb_print(DECODE_ID(hw), 0, "mmu fw load fail\n");
return;
}
}
}
vmh264_reset_udr_mgr(hw);

View File

@@ -9083,22 +9083,15 @@ static s32 vh265_init(struct hevc_state_s *hevc)
INIT_WORK(&hevc->notify_work, vh265_notify_work);
INIT_WORK(&hevc->set_clk_work, vh265_set_clk);
fw = vmalloc(sizeof(struct firmware_s) + fw_size);
if (IS_ERR_OR_NULL(fw))
return -ENOMEM;
#ifdef MULTI_INSTANCE_SUPPORT
if (tee_enabled())
size = 1;
else
#endif
if (hevc->mmu_enable) {
if (hevc->mmu_enable)
size = get_firmware_data(VIDEO_DEC_HEVC_MMU, fw->data);
hevc_print(hevc, 0, "vh265 mmu ucode loaded!\n");
} else {
else
size = get_firmware_data(VIDEO_DEC_HEVC, fw->data);
hevc_print(hevc, 0, "vh265 ucode loaded!\n");
}
if (size < 0) {
pr_err("get firmware fail.\n");
@@ -9131,19 +9124,16 @@ static s32 vh265_init(struct hevc_state_s *hevc)
#endif
amhevc_enable();
if (size == 1) {
pr_info ("tee load ok");
if (hevc->mmu_enable) {
ret = tee_load_video_fw((u32)VIDEO_DEC_HEVC_MMU, 0);
} else
ret = tee_load_video_fw((u32)VIDEO_DEC_HEVC, 0);
} else
if (hevc->mmu_enable)
ret = amhevc_loadmc_ex(VFORMAT_HEVC, "h265_mmu", fw->data);
else
ret = amhevc_loadmc_ex(VFORMAT_HEVC, NULL, fw->data);
if (ret < 0) {
amhevc_disable();
vfree(fw);
pr_err("H265: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}
@@ -10006,18 +9996,17 @@ static void run(struct vdec_s *vdec, unsigned long mask,
}
}
if (hevc->mmu_enable) {
loadr = amhevc_vdec_loadmc_ex(vdec,
"vh265_mc_mmu", hevc->fw->data);
} else
loadr = amhevc_vdec_loadmc_ex(vdec,
"vh265_mc", hevc->fw->data);
if (hevc->mmu_enable)
loadr = amhevc_vdec_loadmc_ex(VFORMAT_HEVC, vdec,
"h265_mmu", hevc->fw->data);
else
loadr = amhevc_vdec_loadmc_ex(VFORMAT_HEVC, vdec,
NULL, hevc->fw->data);
if (loadr < 0) {
amhevc_disable();
hevc_print(hevc, 0,
"%s: Error amvdec_loadmc fail\n",
__func__);
hevc_print(hevc, 0, "H265: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", loadr);
return;
}

View File

@@ -36,6 +36,7 @@
#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
@@ -745,11 +746,12 @@ static s32 vmjpeg_init(void)
return -1;
}
if (size == 1)
pr_info ("tee load ok");
else if (amvdec_loadmc_ex(VFORMAT_MJPEG, NULL, buf) < 0) {
ret = amvdec_loadmc_ex(VFORMAT_MJPEG, NULL, buf);
if (ret < 0) {
amvdec_disable();
vfree(buf);
pr_err("MJPEG: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}

View File

@@ -601,10 +601,7 @@ static s32 vmjpeg_init(struct vdec_s *vdec)
fw = vmalloc(sizeof(struct firmware_s) + fw_size);
if (IS_ERR_OR_NULL(fw))
return -ENOMEM;
if (tee_enabled()) {
size = 1;
pr_debug (" tee load\n");
} else
size = get_firmware_data(VIDEO_DEC_MJPEG_MULTI, fw->data);
if (size < 0) {
pr_err("get firmware fail.");
@@ -722,8 +719,10 @@ static void run(struct vdec_s *vdec, unsigned long mask,
hw->dec_result = DEC_RESULT_NONE;
if (amvdec_vdec_loadmc_ex(vdec, "vmmjpeg_mc",hw->fw->data) < 0) {
pr_err("%s: Error amvdec_loadmc fail\n", __func__);
ret = amvdec_vdec_loadmc_ex(VFORMAT_MJPEG, "mmjpeg", vdec, hw->fw->data);
if (ret < 0) {
pr_err("[%d] MMJPEG: the %s fw loading failed, err: %x\n",
vdec->id, tee_enabled() ? "TEE" : "local", ret);
return;
}
/* if (amvdec_vdec_loadmc_buf_ex(vdec, hw->fw->data, hw->fw->len) < 0) {

View File

@@ -41,6 +41,7 @@
#include "../utils/decoder_bmmu_box.h"
#include <linux/uaccess.h>
#include <linux/amlogic/media/codec_mm/configs.h>
#include <linux/amlogic/tee.h>
#ifdef CONFIG_AM_VDEC_MPEG12_LOG
#define AMLOG
@@ -1928,11 +1929,12 @@ static s32 vmpeg12_init(void)
return -1;
}
if (size == 1)
pr_info ("tee load ok");
else if (amvdec_loadmc_ex(VFORMAT_MPEG12, NULL, buf) < 0) {
ret = amvdec_loadmc_ex(VFORMAT_MPEG12, NULL, buf);
if (ret < 0) {
amvdec_disable();
vfree(buf);
pr_err("MPEG12: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}

View File

@@ -40,6 +40,7 @@
#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>
/* #define CONFIG_AM_VDEC_MPEG4_LOG */
#ifdef CONFIG_AM_VDEC_MPEG4_LOG
@@ -1011,21 +1012,24 @@ static void vmpeg4_local_init(void)
static s32 vmpeg4_init(void)
{
int r;
int trickmode_fffb = 0;
int size = -1;
int size = -1, ret = -1;
char fw_name[32] = {0};
char *buf = vmalloc(0x1000 * 16);
if (IS_ERR_OR_NULL(buf))
return -ENOMEM;
amlog_level(LOG_LEVEL_INFO, "vmpeg4_init\n");
if (vmpeg4_amstream_dec_info.format ==
if (vmpeg4_amstream_dec_info.format ==
VIDEO_DEC_FORMAT_MPEG4_5) {
size = get_firmware_data(VIDEO_DEC_MPEG4_5, buf);
pr_info("load VIDEO_DEC_FORMAT_MPEG4_5\n");
strncpy(fw_name, "vmpeg4_mc_5", sizeof(fw_name));
amlog_level(LOG_LEVEL_INFO, "load VIDEO_DEC_FORMAT_MPEG4_5\n");
} else if (vmpeg4_amstream_dec_info.format == VIDEO_DEC_FORMAT_H263) {
size = get_firmware_data(VIDEO_DEC_H263, buf);
strncpy(fw_name, "h263_mc", sizeof(fw_name));
pr_info("load VIDEO_DEC_FORMAT_H263\n");
} else
@@ -1038,10 +1042,12 @@ static s32 vmpeg4_init(void)
return -1;
}
if (size == 1)
pr_info ("tee load ok");
else if (amvdec_loadmc_ex(VFORMAT_MPEG4, NULL, buf) < 0) {
ret = amvdec_loadmc_ex(VFORMAT_MPEG4, fw_name, buf);
if (ret < 0) {
amvdec_disable();
vfree(buf);
pr_err("%s: the %s fw loading failed, err: %x\n",
fw_name, tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}
@@ -1060,13 +1066,13 @@ static s32 vmpeg4_init(void)
stat |= STAT_ISR_REG;
vmpeg4_local_init();
/* enable AMRISC side protocol */
r = vmpeg4_prot_init();
if (r < 0) {
ret = vmpeg4_prot_init();
if (ret < 0) {
if (mm_blk_handle) {
decoder_bmmu_box_free(mm_blk_handle);
mm_blk_handle = NULL;
}
return r;
return ret;
}
amvdec_enable();
fr_hint_status = VDEC_NO_NEED_HINT;

View File

@@ -42,6 +42,7 @@
#include "../utils/vdec_input.h"
#include "../utils/vdec.h"
#include "../utils/firmware.h"
#include <linux/amlogic/tee.h>
#define DRIVER_NAME "ammvdec_mpeg4"
#define MODULE_NAME "ammvdec_mpeg4"
@@ -1055,14 +1056,17 @@ static s32 vmmpeg4_init(struct vdec_mpeg4_hw_s *hw)
if (IS_ERR_OR_NULL(fw))
return -ENOMEM;
if (hw->vmpeg4_amstream_dec_info.format ==
if (hw->vmpeg4_amstream_dec_info.format ==
VIDEO_DEC_FORMAT_MPEG4_5) {
size = get_firmware_data(VIDEO_DEC_MPEG4_5, fw->data);
strncpy(fw->name, "vmpeg4_mc_5", sizeof(fw->name));
pr_info("load VIDEO_DEC_FORMAT_MPEG4_5\n");
} else if (hw->vmpeg4_amstream_dec_info.format ==
VIDEO_DEC_FORMAT_H263) {
size = get_firmware_data(VIDEO_DEC_H263, fw->data);
strncpy(fw->name, "h263_mc", sizeof(fw->name));
pr_info("load VIDEO_DEC_FORMAT_H263\n");
} else
pr_info("not supported MPEG4 format %d\n",
@@ -1129,10 +1133,14 @@ static void run(struct vdec_s *vdec, unsigned long mask,
hw->dec_result = DEC_RESULT_NONE;
if (amvdec_vdec_loadmc_buf_ex(vdec, hw->fw->data, hw->fw->len) < 0) {
pr_err("VIDEO_DEC_FORMAT_MPEG4 ucode loading failed\n");
ret = amvdec_vdec_loadmc_buf_ex(VFORMAT_MPEG4,hw->fw->name, vdec,
hw->fw->data, hw->fw->len);
if (ret < 0) {
hw->dec_result = DEC_RESULT_ERROR;
schedule_work(&hw->work);
pr_err("[%d] %s: the %s fw loading failed, err: %x\n", vdec->id,
hw->fw->name, tee_enabled() ? "TEE" : "local", ret);
return;
}

View File

@@ -52,6 +52,7 @@
#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>
#define DRIVER_NAME "amvdec_real"
#define MODULE_NAME "amvdec_real"
@@ -793,6 +794,7 @@ static void load_block_data(void *dest, unsigned int count)
s32 vreal_init(struct vdec_s *vdec)
{
int ret = -1, size = -1;
char fw_name[32] = {0};
char *buf = vmalloc(0x1000 * 16);
if (IS_ERR_OR_NULL(buf))
@@ -832,10 +834,12 @@ s32 vreal_init(struct vdec_s *vdec)
while (READ_VREG(LMEM_DMA_CTRL) & 0x8000)
;
size = get_firmware_data(VIDEO_DEC_REAL_V8, buf);
strncpy(fw_name, "vreal_mc_8", sizeof(fw_name));
pr_info("load VIDEO_DEC_FORMAT_REAL_8\n");
} else if (vreal_amstream_dec_info.format == VIDEO_DEC_FORMAT_REAL_9) {
size = get_firmware_data(VIDEO_DEC_REAL_V9, buf);
strncpy(fw_name, "vreal_mc_9", sizeof(fw_name));
pr_info("load VIDEO_DEC_FORMAT_REAL_9\n");
} else
@@ -848,12 +852,14 @@ s32 vreal_init(struct vdec_s *vdec)
vfree(buf);
return -1;
}
if (size == 1)
pr_info ("tee load ok");
else if (amvdec_loadmc_ex(VFORMAT_REAL, NULL, buf) < 0) {
ret = amvdec_loadmc_ex(VFORMAT_REAL, fw_name, buf);
if (ret < 0) {
rmparser_release();
amvdec_disable();
vfree(buf);
pr_err("%s: the %s fw loading failed, err: %x\n",
fw_name, tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}

View File

@@ -14,7 +14,7 @@
* more details.
*
*/
#define DEBUG
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/errno.h>
@@ -267,7 +267,7 @@ static s32 am_vdec_loadmc_ex(struct vdec_s *vdec,
pr_err("loading firmware %s to vdec ram failed!\n", name);
return err;
}
pr_debug("loading firmware %s to vdec ram ok!\n", name);
return err;
}
@@ -286,7 +286,7 @@ static s32 am_vdec_loadmc_buf_ex(struct vdec_s *vdec,
pr_err("loading firmware to vdec ram failed!\n");
return err;
}
pr_debug("loading firmware to vdec ram ok!\n");
return err;
}
@@ -316,7 +316,7 @@ static s32 am_loadmc_ex(enum vformat_e type,
return err;
}
vfree(mc_addr);
pr_debug("loading firmware %s to vdec ram ok!\n", name);
return err;
}
@@ -401,7 +401,10 @@ s32 optee_load_fw(enum vformat_e type, const char *fw_name)
break;
case VFORMAT_MJPEG:
format = VIDEO_DEC_MJPEG;
if (!strcmp(name, "mmjpeg"))
format = VIDEO_DEC_MJPEG_MULTI;
else
format = VIDEO_DEC_MJPEG;
break;
case VFORMAT_VP9:
@@ -417,10 +420,10 @@ s32 optee_load_fw(enum vformat_e type, const char *fw_name)
break;
case VFORMAT_HEVC:
if (!strcmp(name, "vh265_mc"))
format = VIDEO_DEC_HEVC;
else
if (!strcmp(name, "h265_mmu"))
format = VIDEO_DEC_HEVC_MMU;
else
format = VIDEO_DEC_HEVC;
break;
case VFORMAT_REAL:
@@ -441,15 +444,29 @@ s32 optee_load_fw(enum vformat_e type, const char *fw_name)
format = VIDEO_DEC_FORMAT_H263;
break;
default:
if (!strcmp(name, "vh265_mc"))
format = VIDEO_DEC_HEVC;
else if (!strcmp(name, "vh265_mc_mmu"))
format = VIDEO_DEC_HEVC_MMU;
else if (!strcmp(name, "vmmjpeg_mc"))
format = VIDEO_DEC_MJPEG_MULTI;
case VFORMAT_H264_4K2K:
if (!strcmp(name, "single_core"))
format = VIDEO_DEC_H264_4k2K_SINGLE;
else
pr_info("unknow dec format\n");
format = VIDEO_DEC_H264_4k2K;
break;
case VFORMAT_H264MVC:
format = VIDEO_DEC_H264_MVC;
break;
case VFORMAT_H264:
if (!strcmp(name, "mh264"))
format = VIDEO_DEC_H264_MULTI;
else if (!strcmp(name, "mh264_mmu")) {
format = VIDEO_DEC_H264_MULTI_MMU;
vdec = OPTEE_VDEC_HEVC;
} else
format = VIDEO_DEC_H264;
break;
default:
pr_info("Unknow vdec format!\n");
break;
}
@@ -471,18 +488,23 @@ s32 amvdec_loadmc_ex(enum vformat_e type, const char *name, char *def)
}
EXPORT_SYMBOL(amvdec_loadmc_ex);
s32 amvdec_vdec_loadmc_ex(struct vdec_s *vdec, const char *name, char *def)
s32 amvdec_vdec_loadmc_ex(enum vformat_e type, const char *name,
struct vdec_s *vdec, char *def)
{
if (tee_enabled())
return optee_load_fw(FIRMWARE_MAX, name);
return optee_load_fw(type, name);
else
return am_vdec_loadmc_ex(vdec, name, def, &amvdec_loadmc);
return am_vdec_loadmc_ex(vdec, name, def, &amvdec_loadmc);
}
EXPORT_SYMBOL(amvdec_vdec_loadmc_ex);
s32 amvdec_vdec_loadmc_buf_ex(struct vdec_s *vdec, char *buf, int size)
s32 amvdec_vdec_loadmc_buf_ex(enum vformat_e type, const char *name,
struct vdec_s *vdec, char *buf, int size)
{
return am_vdec_loadmc_buf_ex(vdec, buf, size, &amvdec_loadmc);
if (tee_enabled())
return optee_load_fw(type, name);
else
return am_vdec_loadmc_buf_ex(vdec, buf, size, &amvdec_loadmc);
}
EXPORT_SYMBOL(amvdec_vdec_loadmc_buf_ex);
@@ -661,19 +683,20 @@ s32 amhevc_loadmc_ex(enum vformat_e type, const char *name, char *def)
else
return am_loadmc_ex(type, name, def, &amhevc_loadmc);
else
return 0;
return -1;
}
EXPORT_SYMBOL(amhevc_loadmc_ex);
s32 amhevc_vdec_loadmc_ex(struct vdec_s *vdec, const char *name, char *def)
s32 amhevc_vdec_loadmc_ex(enum vformat_e type, struct vdec_s *vdec,
const char *name, char *def)
{
if (has_hevc_vdec())
if (tee_enabled())
return optee_load_fw(FIRMWARE_MAX, name);
return optee_load_fw(type, name);
else
return am_vdec_loadmc_ex(vdec, name, def, &amhevc_loadmc);
return am_vdec_loadmc_ex(vdec, name, def, &amhevc_loadmc);
else
return 0;
return -1;
}
EXPORT_SYMBOL(amhevc_vdec_loadmc_ex);

View File

@@ -38,7 +38,8 @@ extern void amvdec_stop(void);
extern void amvdec_enable(void);
extern void amvdec_disable(void);
s32 amvdec_loadmc_ex(enum vformat_e type, const char *name, char *def);
s32 amvdec_vdec_loadmc_ex(struct vdec_s *vdec, const char *name, char *def);
s32 amvdec_vdec_loadmc_ex(enum vformat_e type, const char *name,
struct vdec_s *vdec, char *def);
extern void amvdec2_start(void);
extern void amvdec2_stop(void);
@@ -51,8 +52,10 @@ extern void amhevc_stop(void);
extern void amhevc_enable(void);
extern void amhevc_disable(void);
s32 amhevc_loadmc_ex(enum vformat_e type, const char *name, char *def);
s32 amhevc_vdec_loadmc_ex(struct vdec_s *vdec, const char *name, char *def);
s32 amvdec_vdec_loadmc_buf_ex(struct vdec_s *vdec, char *buf, int size);
s32 amhevc_vdec_loadmc_ex(enum vformat_e type, struct vdec_s *vdec,
const char *name, char *def);
s32 amvdec_vdec_loadmc_buf_ex(enum vformat_e type, const char *name,
struct vdec_s *vdec, char *buf, int size);
extern void amhcodec_start(void);
extern void amhcodec_stop(void);

View File

@@ -8,6 +8,7 @@
#define FW_LOAD_TRY (0X2)
struct firmware_s {
char name[32];
unsigned int len;
char data[0];
};

View File

@@ -1028,7 +1028,7 @@ static void vvc1_put_timer_func(unsigned long arg)
static s32 vvc1_init(void)
{
int ret = -1, size = -1;
int ret = -1;
char *buf = vmalloc(0x1000 * 16);
int fw_type = VIDEO_DEC_VC1;
@@ -1056,19 +1056,19 @@ static s32 vvc1_init(void)
} else
pr_info("not supported VC1 format\n");
size = get_firmware_data(fw_type, buf);
if (size < 0) {
if (get_firmware_data(fw_type, buf) < 0) {
amvdec_disable();
pr_err("get firmware fail.");
vfree(buf);
return -1;
}
if (size == 1)
pr_info("tee load ok\n");
else if (amvdec_loadmc_ex(VFORMAT_VC1, NULL, buf) < 0) {
ret = amvdec_loadmc_ex(VFORMAT_VC1, NULL, buf);
if (ret < 0) {
amvdec_disable();
vfree(buf);
pr_err("VC1: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}

View File

@@ -7856,34 +7856,20 @@ static s32 vvp9_init(struct vdec_s *vdec)
static s32 vvp9_init(struct VP9Decoder_s *pbi)
{
#endif
int ret, size = -1;
int ret;
int fw_size = 0x1000 * 16;
struct firmware_s *fw = NULL;
INIT_WORK(&pbi->set_clk_work, vp9_set_clk);
init_timer(&pbi->timer);
pbi->stat |= STAT_TIMER_INIT;
if (vvp9_local_init(pbi) < 0)
return -EBUSY;
fw = vmalloc(sizeof(struct firmware_s) + fw_size);
if (IS_ERR_OR_NULL(fw))
return -ENOMEM;
#ifdef MULTI_INSTANCE_SUPPORT
if (tee_enabled()) {
size = 1;
pr_debug ("laod\n");
} else
#endif
if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A)
size = get_firmware_data(VIDEO_DEC_VP9, fw->data);
else
size = get_firmware_data(VIDEO_DEC_VP9_MMU, fw->data);
if (size < 0) {
if (get_firmware_data(VIDEO_DEC_VP9_MMU, fw->data) < 0) {
pr_err("get firmware fail.\n");
vfree(fw);
return -1;
@@ -7891,6 +7877,9 @@ 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);
#ifdef MULTI_INSTANCE_SUPPORT
if (pbi->m_ins_flag) {
pbi->timer.data = (ulong) pbi;
@@ -7915,18 +7904,12 @@ static s32 vvp9_init(struct VP9Decoder_s *pbi)
amhevc_enable();
if (size == 1) {
pr_info ("tee load ok\n");
if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A)
ret = tee_load_video_fw((u32)VIDEO_DEC_VP9, 0);
else
ret = tee_load_video_fw((u32)VIDEO_DEC_VP9_MMU, 0);
} else
ret = amhevc_loadmc_ex(VFORMAT_VP9, NULL, fw->data);
ret = amhevc_loadmc_ex(VFORMAT_VP9, NULL, fw->data);
if (ret < 0) {
amhevc_disable();
vfree(fw);
pr_err("VP9: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return -EBUSY;
}
@@ -8674,15 +8657,12 @@ static void run_front(struct vdec_s *vdec)
vp9_print_cont(pbi, 0, "\r\n");
}
if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_G12A)
ret = amhevc_loadmc_ex(VFORMAT_VP9, "vp9_mc", pbi->fw->data);
else
ret = amhevc_loadmc_ex(VFORMAT_VP9, NULL, pbi->fw->data);
ret = amhevc_loadmc_ex(VFORMAT_VP9, NULL, pbi->fw->data);
if (ret < 0) {
amhevc_disable();
vp9_print(pbi, 0,
"%s: Error amvdec_loadmc fail\n", __func__);
vp9_print(pbi, PRINT_FLAG_ERROR,
"VP9: the %s fw loading failed, err: %x\n",
tee_enabled() ? "TEE" : "local", ret);
return;
}

BIN
firmware/video/video_ucode.bin Normal file → Executable file

Binary file not shown.