radeon/vce: add config task and put task info into encoder v2
authorLeo Liu <leo.liu@amd.com>
Mon, 1 Jun 2015 17:48:24 +0000 (13:48 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 14 Aug 2015 13:02:30 +0000 (15:02 +0200)
The config task has own task ID, extract the configuration functions
into config task.

v2 (chk): calculate offset automatically

Signed-off-by: Leo Liu <leo.liu@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/drivers/radeon/radeon_vce.c
src/gallium/drivers/radeon/radeon_vce.h
src/gallium/drivers/radeon/radeon_vce_40_2_2.c
src/gallium/drivers/radeon/radeon_vce_50.c

index 644958a05e80174a33e2beb966d22d15a04369cc..e53ef3f8486e90b126731e7d49bbc3940df58b3e 100644 (file)
@@ -56,6 +56,7 @@
 static void flush(struct rvce_encoder *enc)
 {
        enc->ws->cs_flush(enc->cs, RADEON_FLUSH_ASYNC, NULL, 0);
+       enc->task_info_idx = 0;
 }
 
 #if 0
@@ -280,24 +281,19 @@ static void rvce_begin_frame(struct pipe_video_codec *encoder,
                enc->fb = &fb;
                enc->session(enc);
                enc->create(enc);
-               enc->rate_control(enc);
-               need_rate_control = false;
-               enc->config_extension(enc);
-               enc->motion_estimation(enc);
-               enc->rdo(enc);
-               if (enc->use_vui)
-                       enc->vui(enc);
-               enc->pic_control(enc);
+               enc->config(enc);
                enc->feedback(enc);
                flush(enc);
                //dump_feedback(enc, &fb);
                rvid_destroy_buffer(&fb);
+               need_rate_control = false;
        }
 
-       enc->session(enc);
-
-       if (need_rate_control)
-               enc->rate_control(enc);
+       if (need_rate_control) {
+               enc->session(enc);
+               enc->config(enc);
+               flush(enc);
+       }
 }
 
 static void rvce_encode_bitstream(struct pipe_video_codec *encoder,
@@ -314,6 +310,7 @@ static void rvce_encode_bitstream(struct pipe_video_codec *encoder,
                RVID_ERR("Can't create feedback buffer.\n");
                return;
        }
+       enc->session(enc);
        enc->encode(enc);
        enc->feedback(enc);
 }
index ae7b2b431be4a4ba0abb0a3f021f296ecacc22e3..28629043bc3496ed03217a72b3d61360770a874c 100644 (file)
@@ -77,8 +77,12 @@ struct rvce_encoder {
        void (*motion_estimation)(struct rvce_encoder *enc);
        void (*rdo)(struct rvce_encoder *enc);
        void (*vui)(struct rvce_encoder *enc);
+       void (*config)(struct rvce_encoder *enc);
        void (*encode)(struct rvce_encoder *enc);
        void (*destroy)(struct rvce_encoder *enc);
+       void (*task_info)(struct rvce_encoder *enc, uint32_t op,
+                         uint32_t dep, uint32_t fb_idx,
+                         uint32_t ring_idx);
 
        unsigned                        stream_handle;
 
@@ -102,6 +106,8 @@ struct rvce_encoder {
        struct rvid_buffer              *fb;
        struct rvid_buffer              cpb;
        struct pipe_h264_enc_picture_desc pic;
+       unsigned                        task_info_idx;
+
        bool                            use_vm;
        bool                            use_vui;
        bool                            dual_pipe;
index 71b5e89fd5906892e839272174ba85977a5335b1..ede540d7ac842521bd2888f8ec16443f83bdc1f2 100644 (file)
@@ -53,15 +53,24 @@ static void session(struct rvce_encoder *enc)
        RVCE_END();
 }
 
-static void task_info(struct rvce_encoder *enc, uint32_t taskOperation)
+static void task_info(struct rvce_encoder *enc, uint32_t op,
+                     uint32_t dep, uint32_t fb_idx, uint32_t ring_idx)
 {
        RVCE_BEGIN(0x00000002); // task info
+       if (op == 0x3) {
+               if (enc->task_info_idx) {
+                       uint32_t offs = enc->cs->cdw - enc->task_info_idx + 3;
+                       // Update offsetOfNextTaskInfo
+                       enc->cs->buf[enc->task_info_idx] = offs;
+               }
+               enc->task_info_idx = enc->cs->cdw;
+       }
        RVCE_CS(0xffffffff); // offsetOfNextTaskInfo
-       RVCE_CS(taskOperation); // taskOperation
-       RVCE_CS(0x00000000); // referencePictureDependency
+       RVCE_CS(op); // taskOperation
+       RVCE_CS(dep); // referencePictureDependency
        RVCE_CS(0x00000000); // collocateFlagDependency
-       RVCE_CS(0x00000000); // feedbackIndex
-       RVCE_CS(0x00000000); // videoBitstreamRingIndex
+       RVCE_CS(fb_idx); // feedbackIndex
+       RVCE_CS(ring_idx); // videoBitstreamRingIndex
        RVCE_END();
 }
 
@@ -75,7 +84,7 @@ static void feedback(struct rvce_encoder *enc)
 
 static void create(struct rvce_encoder *enc)
 {
-       task_info(enc, 0x00000000);
+       enc->task_info(enc, 0x00000000, 0, 0, 0);
 
        RVCE_BEGIN(0x01000001); // create cmd
        RVCE_CS(0x00000000); // encUseCircularBuffer
@@ -271,12 +280,24 @@ static void vui(struct rvce_encoder *enc)
        RVCE_END();
 }
 
+static void config(struct rvce_encoder *enc)
+{
+       enc->task_info(enc, 0x00000002, 0, 0xffffffff, 0);
+       enc->rate_control(enc);
+       enc->config_extension(enc);
+       enc->motion_estimation(enc);
+       enc->rdo(enc);
+       if (enc->use_vui)
+               enc->vui(enc);
+       enc->pic_control(enc);
+}
+
 static void encode(struct rvce_encoder *enc)
 {
        int i;
        unsigned luma_offset, chroma_offset;
 
-       task_info(enc, 0x00000003);
+       enc->task_info(enc, 0x00000003, 0, 0, 0);
 
        RVCE_BEGIN(0x05000001); // context buffer
        RVCE_READWRITE(enc->cpb.res->cs_buf, enc->cpb.res->domains, 0x0); // encodeContextAddressHi/Lo
@@ -401,7 +422,7 @@ static void encode(struct rvce_encoder *enc)
 
 static void destroy(struct rvce_encoder *enc)
 {
-       task_info(enc, 0x00000001);
+       enc->task_info(enc, 0x00000001, 0, 0, 0);
 
        RVCE_BEGIN(0x02000001); // destroy
        RVCE_END();
@@ -410,6 +431,7 @@ static void destroy(struct rvce_encoder *enc)
 void radeon_vce_40_2_2_init(struct rvce_encoder *enc)
 {
        enc->session = session;
+       enc->task_info = task_info;
        enc->create = create;
        enc->feedback = feedback;
        enc->rate_control = rate_control;
@@ -418,6 +440,7 @@ void radeon_vce_40_2_2_init(struct rvce_encoder *enc)
        enc->motion_estimation = motion_estimation;
        enc->rdo = rdo;
        enc->vui = vui;
+       enc->config = config;
        enc->encode = encode;
        enc->destroy = destroy;
 }
index a11cc6a2860c4aa261fbebc5f806fdf901665074..377e15431862af350c51dac62360584e1f5a5bb8 100644 (file)
 #include "radeon_video.h"
 #include "radeon_vce.h"
 
-static void task_info(struct rvce_encoder *enc, uint32_t taskOperation)
-{
-       RVCE_BEGIN(0x00000002); // task info
-       RVCE_CS(0xffffffff); // offsetOfNextTaskInfo
-       RVCE_CS(taskOperation); // taskOperation
-       RVCE_CS(0x00000000); // referencePictureDependency
-       RVCE_CS(0x00000000); // collocateFlagDependency
-       RVCE_CS(0x00000000); // feedbackIndex
-       RVCE_CS(0x00000000); // videoBitstreamRingIndex
-       RVCE_END();
-}
-
 static void rate_control(struct rvce_encoder *enc)
 {
        RVCE_BEGIN(0x04000005); // rate control
@@ -93,7 +81,7 @@ static void encode(struct rvce_encoder *enc)
        int i;
        unsigned luma_offset, chroma_offset;
 
-       task_info(enc, 0x00000003);
+       enc->task_info(enc, 0x00000003, 0, 0, 0);
 
        RVCE_BEGIN(0x05000001); // context buffer
        RVCE_READWRITE(enc->cpb.res->cs_buf, enc->cpb.res->domains, 0); // encodeContextAddressHi/Lo