media: The H264 and H265 formats support DV in Frame mode [2/2]
authorGan Zhang <gan.zhang@amlogic.com>
Tue, 16 Jun 2020 03:25:08 +0000 (11:25 +0800)
committerHui Zhang <hui.zhang@amlogic.com>
Wed, 8 Jul 2020 06:49:52 +0000 (23:49 -0700)
PD#SWPL-25611

Problem:
support dv frame mode.

Solution:
add DOLBY_META_SUPPORT in ucode and
set aux data in frame mode.

ucode gerrit id: 115646
ucode commit id: da74861
ucode change id: I4c6e0e

Verify:
ac214

Change-Id: I29647903fdb185965ee228d82e9dc7106f94e883
Signed-off-by: Gan Zhang <gan.zhang@amlogic.com>
drivers/frame_provider/decoder/h264_multi/vmh264.c
drivers/frame_provider/decoder/h265/vh265.c
drivers/frame_provider/decoder/vav1/vav1.c
drivers/stream_input/amports/amstream.c
firmware/video_ucode.bin

index d92722b355287c0c3d6b48dd7c41a8b0fe40dea3..87b5bdead9f1c6b6bd2c0eb61cb7907a05ed7346 100644 (file)
 
 #define DETECT_WRONG_MULTI_SLICE
 
+/*
+to enable DV of frame mode
+#define DOLBY_META_SUPPORT in ucode
+*/
 
 #undef pr_info
 #define pr_info printk
@@ -148,7 +152,6 @@ static unsigned int error_recovery_mode_in;
 static int start_decode_buf_level = 0x4000;
 static int pre_decode_buf_level = 0x1000;
 static int stream_mode_start_num = 4;
-
 #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
 /*to make reorder size difference of bl and el not too big*/
 static unsigned int reorder_dpb_size_margin_dv = 16;
@@ -3113,10 +3116,10 @@ static void set_aux_data(struct vdec_h264_hw_s *hw,
                        hw_buf->prefix_aux_size;
        }
        if (dpb_is_debug(DECODE_ID(hw),
-                PRINT_FLAG_DPB_DETAIL)) {
+                PRINT_FLAG_DEC_DETAIL)) {
                dpb_print(DECODE_ID(hw), 0,
-                       "%s:old size %d count %d,suf %d dv_flag %d\r\n",
-                       __func__, AUX_DATA_SIZE(pic),
+                       "%s:poc %d old size %d count %d,suf %d dv_flag %d\r\n",
+                       __func__, pic->poc, AUX_DATA_SIZE(pic),
                        aux_count, suffix_flag, dv_meta_flag);
        }
        if (aux_size > 0 && aux_count > 0) {
@@ -3212,7 +3215,7 @@ static void set_aux_data(struct vdec_h264_hw_s *hw,
                                h[7] = (padding_len) & 0xff;
                        }
                        if (dpb_is_debug(DECODE_ID(hw),
-                               PRINT_FLAG_DPB_DETAIL)) {
+                               PRINT_FLAG_DEC_DETAIL)) {
                                dpb_print(DECODE_ID(hw), 0,
                                        "aux: (size %d) suffix_flag %d\n",
                                        AUX_DATA_SIZE(pic), suffix_flag);
@@ -6402,7 +6405,11 @@ pic_done_proc:
                                PRINT_FLAG_DPB_DETAIL))
                                dump_aux_buf(hw);
 #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
-                       if (vdec->dolby_meta_with_el || vdec->slave) {
+                       if (vdec_frame_based(vdec)) {
+                               if (hw->last_dec_picture)
+                                       set_aux_data(hw,
+                                               hw->last_dec_picture, 0, 0, NULL);
+                       } else if (vdec->dolby_meta_with_el || vdec->slave) {
                                if (hw->last_dec_picture)
                                        set_aux_data(hw, hw->last_dec_picture,
                                                0, 0, NULL);
@@ -8248,7 +8255,9 @@ static int vmh264_get_ps_info(struct vdec_h264_hw_s *hw,
        u32 param1, u32 param2, u32 param3, u32 param4,
        struct aml_vdec_ps_infos *ps)
 {
+#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
        struct vdec_s *vdec = hw_to_vdec(hw);
+#endif
        int mb_width, mb_total;
        int mb_height = 0;
        int active_buffer_spec_num;
@@ -9880,9 +9889,9 @@ static int __init ammvdec_h264_driver_init_module(void)
        if (vdec_is_support_4k()) {
                if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_TXLX) {
                        ammvdec_h264_profile.profile =
-                                       "4k, dwrite, compressed";
+                                       "4k, dwrite, compressed, frame_dv";
                } else if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_GXTVBB) {
-                       ammvdec_h264_profile.profile = "4k";
+                       ammvdec_h264_profile.profile = "4k, frame_dv";
                }
        }
 
index e1a2429e894bda37e7482a75a3142bba99ab1762..122e8bcb62d1eb2ebdcc641ecb9ccb2f0fd5b1b7 100644 (file)
 #include "../utils/vdec_v4l2_buffer_ops.h"
 #include <media/v4l2-mem2mem.h>
 
+/*
+to enable DV of frame mode
+#define DOLBY_META_SUPPORT in ucode
+*/
+
 #define HEVC_8K_LFTOFFSET_FIX
 
 #define CONSTRAIN_MAX_BUF_NUM
@@ -422,8 +427,12 @@ use_cma: 1, use both reserver memory and cma for buffers
 static u32 use_cma = 2;
 
 #define AUX_BUF_ALIGN(adr) ((adr + 0xf) & (~0xf))
+/*
 static u32 prefix_aux_buf_size = (16 * 1024);
 static u32 suffix_aux_buf_size;
+*/
+static u32 prefix_aux_buf_size = (12 * 1024);
+static u32 suffix_aux_buf_size = (12 * 1024);
 
 static u32 max_decoding_time;
 /*
@@ -464,8 +473,8 @@ static u32 fr_hint_status;
         *  bit 8, debug flag
         */
 static u32 parser_sei_enable;
-#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
 static u32 parser_dolby_vision_enable = 1;
+#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
 static u32 dolby_meta_with_el;
 static u32 dolby_el_flush_th = 2;
 #endif
@@ -3907,6 +3916,7 @@ static struct PIC_s *output_pic(struct hevc_state_s *hevc,
 
                        }
                }
+#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
                /* dv wait cur_pic all data get,
                some data may get after picture output */
                if ((vdec->master || vdec->slave)
@@ -3915,7 +3925,7 @@ static struct PIC_s *output_pic(struct hevc_state_s *hevc,
                        (hevc->bypass_dvenl && !dolby_meta_with_el)
                        && (!fisrt_pic_flag))
                        pic_display = NULL;
-
+#endif
                if (pic_display) {
                        if ((num_pic_not_yet_display >
                                pic_display->num_reorder_pic)
@@ -6860,9 +6870,7 @@ static int hevc_slice_segment_header_process(struct hevc_state_s *hevc,
                union param_u *rpm_param,
                int decode_pic_begin)
 {
-#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
        struct vdec_s *vdec = hw_to_vdec(hevc);
-#endif
        int i;
        int lcu_x_num_div;
        int lcu_y_num_div;
@@ -9572,11 +9580,11 @@ static int hevc_recover(struct hevc_state_s *hevc)
        WRITE_VREG(NAL_SEARCH_CTL,
                READ_VREG(NAL_SEARCH_CTL)
                | ((parser_sei_enable & 0x7) << 17));
-#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
+/*#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION*/
        WRITE_VREG(NAL_SEARCH_CTL,
                READ_VREG(NAL_SEARCH_CTL) |
                ((parser_dolby_vision_enable & 0x1) << 20));
-#endif
+/*#endif*/
        config_decode_mode(hevc);
        WRITE_VREG(DECODE_STOP_POS, udebug_flag);
 
@@ -9784,9 +9792,7 @@ static irqreturn_t vh265_isr_thread_fn(int irq, void *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;
@@ -9829,11 +9835,11 @@ static irqreturn_t vh265_isr_thread_fn(int irq, void *data)
                WRITE_VREG(NAL_SEARCH_CTL,
                        READ_VREG(NAL_SEARCH_CTL)
                        | ((parser_sei_enable & 0x7) << 17));
-#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
+/*#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION*/
                WRITE_VREG(NAL_SEARCH_CTL,
                        READ_VREG(NAL_SEARCH_CTL) |
                        ((parser_dolby_vision_enable & 0x1) << 20));
-#endif
+/*#endif*/
                config_decode_mode(hevc);
                /* search new nal */
                WRITE_VREG(HEVC_DEC_STATUS_REG, HEVC_ACTION_DONE);
@@ -9912,6 +9918,8 @@ static irqreturn_t vh265_isr_thread_fn(int irq, void *data)
                        read_decode_info(hevc);
                        if (vdec_frame_based(hw_to_vdec(hevc))) {
                                hevc->empty_flag = 1;
+                               /*suffix sei or dv meta*/
+                               set_aux_data(hevc, hevc->cur_pic, 1, 0);
                                goto pic_done;
                        } else {
                                if (
@@ -9938,6 +9946,8 @@ static irqreturn_t vh265_isr_thread_fn(int irq, void *data)
                        if (vdec_frame_based(hw_to_vdec(hevc))) {
                                /*hevc->dec_result = DEC_RESULT_GET_DATA;*/
                                hevc->empty_flag = 1;
+                               /*suffix sei or dv meta*/
+                               set_aux_data(hevc, hevc->cur_pic, 1, 0);
                                goto pic_done;
                        } else {
                                hevc->dec_result = DEC_RESULT_AGAIN;
@@ -10076,7 +10086,9 @@ pic_done:
                                        (READ_VREG(HEVC_PARSER_LCU_START) & 0xffffff) == 0
                                        && (hevc->lcu_x_num * hevc->lcu_y_num != 1))
                                        hevc->cur_pic->error_mark = 1;
+#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
 force_output:
+#endif
                                pic_display = output_pic(hevc, 1);
                                if (pic_display) {
                                        if ((pic_display->error_mark &&
@@ -10391,11 +10403,11 @@ force_output:
                        WRITE_VREG(NAL_SEARCH_CTL,
                                READ_VREG(NAL_SEARCH_CTL)
                                | ((parser_sei_enable & 0x7) << 17));
-#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
+/*#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION*/
                        WRITE_VREG(NAL_SEARCH_CTL,
                                READ_VREG(NAL_SEARCH_CTL) |
                                ((parser_dolby_vision_enable & 0x1) << 20));
-#endif
+/*#endif*/
                        config_decode_mode(hevc);
                }
 
@@ -11380,11 +11392,11 @@ static void vh265_prot_init(struct hevc_state_s *hevc)
        WRITE_VREG(NAL_SEARCH_CTL,
                READ_VREG(NAL_SEARCH_CTL)
                | ((parser_sei_enable & 0x7) << 17));
-#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
+/*#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION*/
        WRITE_VREG(NAL_SEARCH_CTL,
                READ_VREG(NAL_SEARCH_CTL) |
                ((parser_dolby_vision_enable & 0x1) << 20));
-#endif
+/*#endif*/
        WRITE_VREG(DECODE_STOP_POS, udebug_flag);
 
        config_decode_mode(hevc);
@@ -13694,8 +13706,8 @@ static struct mconfig h265_configs[] = {
        MC_PU32("parser_sei_enable", &parser_sei_enable),
        MC_PU32("start_decode_buf_level", &start_decode_buf_level),
        MC_PU32("decode_timeout_val", &decode_timeout_val),
-#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
        MC_PU32("parser_dolby_vision_enable", &parser_dolby_vision_enable),
+#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
        MC_PU32("dv_toggle_prov_name", &dv_toggle_prov_name),
        MC_PU32("dv_debug", &dv_debug),
 #endif
@@ -13752,10 +13764,10 @@ static int __init amvdec_h265_driver_init_module(void)
                        amvdec_h265_profile.profile = "4k";
                } else if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_SM1) {
                        amvdec_h265_profile.profile =
-                               "8k, 8bit, 10bit, dwrite, compressed";
+                               "8k, 8bit, 10bit, dwrite, compressed, frame_dv";
                }else if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_GXBB) {
                        amvdec_h265_profile.profile =
-                               "4k, 8bit, 10bit, dwrite, compressed";
+                               "4k, 8bit, 10bit, dwrite, compressed, frame_dv";
                } else if (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_MG9TV)
                        amvdec_h265_profile.profile = "4k";
        }
@@ -13947,11 +13959,11 @@ MODULE_PARM_DESC(pts_unstable, "\n amvdec_h265 pts_unstable\n");
 module_param(parser_sei_enable, uint, 0664);
 MODULE_PARM_DESC(parser_sei_enable, "\n parser_sei_enable\n");
 
-#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
 module_param(parser_dolby_vision_enable, uint, 0664);
 MODULE_PARM_DESC(parser_dolby_vision_enable,
        "\n parser_dolby_vision_enable\n");
 
+#ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
 module_param(dolby_meta_with_el, uint, 0664);
 MODULE_PARM_DESC(dolby_meta_with_el,
        "\n dolby_meta_with_el\n");
index f8b03a306fc8c8b9336a563f992b648c49e28051..faeaa9bd91dafff2c4edde4826a8bb432fa5e7c3 100644 (file)
@@ -9750,7 +9750,7 @@ static int __init amvdec_av1_driver_init_module(void)
 
        if ((get_cpu_major_id() > AM_MESON_CPU_MAJOR_ID_TM2) || is_cpu_tm2_revb()) {
                amvdec_av1_profile.profile =
-                               "8k, 10bit, dwrite, compressed, no_head";
+                               "8k, 10bit, dwrite, compressed, no_head, frame_dv";
        } else {
                amvdec_av1_profile.name = "av1_unsupport";
        }
index 75a72a5111a7a78344631da2b823ed8857e8a1f6..bfb44b412d967530fa8eff9a8df884bd78a77427 100644 (file)
@@ -325,7 +325,10 @@ static int userdata_poc_ri, userdata_poc_wi;
 static int last_read_wi;
 static u32 ud_ready_vdec_flag;
 
-
+/*bit 1 force dual layer
+ *bit 2 force frame mode
+ */
+static u32 force_dv_mode;
 
 static DEFINE_MUTEX(userdata_mutex);
 
@@ -430,6 +433,19 @@ static struct stream_port_s ports[] = {
                .fops = &vbuf_fops,
                .vformat = VFORMAT_HEVC,
        },
+       {
+               .name = "amstream_dves_avc_frame",
+               .type = PORT_TYPE_ES | PORT_TYPE_VIDEO | PORT_TYPE_FRAME |
+                       PORT_TYPE_DECODER_SCHED | PORT_TYPE_DUALDEC,
+               .fops = &vframe_fops,
+       },
+       {
+               .name = "amstream_dves_hevc_frame",
+               .type = PORT_TYPE_ES | PORT_TYPE_VIDEO | PORT_TYPE_HEVC | PORT_TYPE_FRAME |
+                       PORT_TYPE_DECODER_SCHED | PORT_TYPE_DUALDEC,
+               .fops = &vframe_fops,
+               .vformat = VFORMAT_HEVC,
+       },
        {
                .name = "amstream_dves_av1",
                .type = PORT_TYPE_ES | PORT_TYPE_VIDEO | PORT_TYPE_HEVC | PORT_TYPE_FRAME |
@@ -631,7 +647,7 @@ static int video_port_init(struct port_priv_s *priv,
                                __LINE__);
                        return r;
                }
-
+#if 0
                if (vdec_dual(vdec)) {
                        if (port->vformat == VFORMAT_AV1)       /* av1 dv only single layer */
                                return 0;
@@ -645,6 +661,7 @@ static int video_port_init(struct port_priv_s *priv,
                                return r;
                        }
                }
+#endif
                return 0;
        }
 
@@ -1620,6 +1637,17 @@ static int amstream_open(struct inode *inode, struct file *file)
                        return -EBUSY;
                }
        }
+       /* force dv frame mode */
+       if ((force_dv_mode & 0x2) &&
+               (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_SC2)) {
+               port->type |= PORT_TYPE_FRAME;
+               port->fops = &vframe_fops;
+               pr_debug("%s, dobly vision force frame mode.\n", __func__);
+       }
+
+       /* esplayer stream mode force dv */
+       if (force_dv_mode & 0x1)
+               port->type |= PORT_TYPE_DUALDEC;
 
        /* check other ports conflicts for audio */
        for (s = &ports[0], i = 0; i < amstream_port_num; i++, s++) {
@@ -1702,17 +1730,18 @@ static int amstream_open(struct inode *inode, struct file *file)
                        pr_err("amstream: vdec creation failed\n");
                        return -ENOMEM;
                }
-
-               if ((port->type & PORT_TYPE_DUALDEC) ||
-                       (vdec_get_debug_flags() & 0x100)) {
-                       priv->vdec->slave = vdec_create(port, priv->vdec);
-
-                       if (priv->vdec->slave == NULL) {
-                               vdec_release(priv->vdec);
-                               port->flag = 0;
-                               kfree(priv);
-                               pr_err("amstream: sub vdec creation failed\n");
-                               return -ENOMEM;
+               if (!(port->type & PORT_TYPE_FRAME)) {
+                       if ((port->type & PORT_TYPE_DUALDEC) ||
+                               (vdec_get_debug_flags() & 0x100)) {
+                               priv->vdec->slave = vdec_create(port, priv->vdec);
+
+                               if (priv->vdec->slave == NULL) {
+                                       vdec_release(priv->vdec);
+                                       port->flag = 0;
+                                       kfree(priv);
+                                       pr_err("amstream: sub vdec creation failed\n");
+                                       return -ENOMEM;
+                               }
                        }
                }
        }
@@ -4475,6 +4504,10 @@ static void __exit amstream_module_exit(void)
 module_init(amstream_module_init);
 module_exit(amstream_module_exit);
 
+module_param(force_dv_mode, uint, 0664);
+MODULE_PARM_DESC(force_dv_mode,
+       "\n force_dv_mode \n");
+
 module_param(def_4k_vstreambuf_sizeM, uint, 0664);
 MODULE_PARM_DESC(def_4k_vstreambuf_sizeM,
        "\nDefault video Stream buf size for 4K MByptes\n");
index 51d2caf7934b1f4c9ea58b3564037bc5ced0e3cd..cfc5d61262e76139985016dc1203859d5fc9461b 100644 (file)
Binary files a/firmware/video_ucode.bin and b/firmware/video_ucode.bin differ