[05/13] radeon/vcn: separate send cmd call from end frame

Submitted by Zhang, Boyuan on Aug. 16, 2018, 4:06 p.m.

Details

Message ID 1534435591-22542-5-git-send-email-boyuan.zhang@amd.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Zhang, Boyuan Aug. 16, 2018, 4:06 p.m.
From: Boyuan Zhang <boyuan.zhang@amd.com>

Use function pointer for sending cmd in end_frame call. By doing this, we can
assign different cmd sending logics for Jpeg decode later.

Signed-off-by: Boyuan Zhang <boyuan.zhang@amd.com>
---
 src/gallium/drivers/radeon/radeon_vcn_dec.c | 30 ++++++++++++++++++++---------
 src/gallium/drivers/radeon/radeon_vcn_dec.h |  7 +++++++
 2 files changed, 28 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/radeon/radeon_vcn_dec.c b/src/gallium/drivers/radeon/radeon_vcn_dec.c
index e6c1b67..30a8952 100644
--- a/src/gallium/drivers/radeon/radeon_vcn_dec.c
+++ b/src/gallium/drivers/radeon/radeon_vcn_dec.c
@@ -1111,24 +1111,17 @@  static void radeon_dec_decode_bitstream(struct pipe_video_codec *decoder,
 }
 
 /**
- * end decoding of the current frame
+ * send cmd for vcn dec
  */
-static void radeon_dec_end_frame(struct pipe_video_codec *decoder,
+void send_cmd_dec(struct radeon_decoder *dec,
 			   struct pipe_video_buffer *target,
 			   struct pipe_picture_desc *picture)
 {
-	struct radeon_decoder *dec = (struct radeon_decoder*)decoder;
 	struct pb_buffer *dt;
 	struct rvid_buffer *msg_fb_it_buf, *bs_buf;
 
-	assert(decoder);
-
-	if (!dec->bs_ptr)
-		return;
-
 	msg_fb_it_buf = &dec->msg_fb_it_buffers[dec->cur_buffer];
 	bs_buf = &dec->bs_buffers[dec->cur_buffer];
-
 	memset(dec->bs_ptr, 0, align(dec->bs_size, 128) - dec->bs_size);
 	dec->ws->buffer_unmap(bs_buf->res->buf);
 
@@ -1152,6 +1145,23 @@  static void radeon_dec_end_frame(struct pipe_video_codec *decoder,
 		send_cmd(dec, RDECODE_CMD_IT_SCALING_TABLE_BUFFER, msg_fb_it_buf->res->buf,
 			 FB_BUFFER_OFFSET + FB_BUFFER_SIZE, RADEON_USAGE_READ, RADEON_DOMAIN_GTT);
 	set_reg(dec, RDECODE_ENGINE_CNTL, 1);
+}
+
+/**
+ * end decoding of the current frame
+ */
+static void radeon_dec_end_frame(struct pipe_video_codec *decoder,
+			   struct pipe_video_buffer *target,
+			   struct pipe_picture_desc *picture)
+{
+	struct radeon_decoder *dec = (struct radeon_decoder*)decoder;
+
+	assert(decoder);
+
+	if (!dec->bs_ptr)
+		return;
+
+	dec->send_cmd(dec, target, picture);
 
 	flush(dec, PIPE_FLUSH_ASYNC);
 	next_buffer(dec);
@@ -1294,6 +1304,8 @@  struct pipe_video_codec *radeon_create_decoder(struct pipe_context *context,
 
 	next_buffer(dec);
 
+	dec->send_cmd = send_cmd_dec;
+
 	return &dec->base;
 
 error:
diff --git a/src/gallium/drivers/radeon/radeon_vcn_dec.h b/src/gallium/drivers/radeon/radeon_vcn_dec.h
index 399d75c..05e4847 100644
--- a/src/gallium/drivers/radeon/radeon_vcn_dec.h
+++ b/src/gallium/drivers/radeon/radeon_vcn_dec.h
@@ -618,8 +618,15 @@  struct radeon_decoder {
 	void				*render_pic_list[16];
 
 	struct jpeg_params		jpg;
+	void (*send_cmd)(struct radeon_decoder *dec,
+			 struct pipe_video_buffer *target,
+			 struct pipe_picture_desc *picture);
 };
 
+void send_cmd_dec(struct radeon_decoder *dec,
+		  struct pipe_video_buffer *target,
+		  struct pipe_picture_desc *picture);
+
 struct pipe_video_codec *radeon_create_decoder(struct pipe_context *context,
 		const struct pipe_video_codec *templat);
 

Comments

Patch 1-5:

Reviewed-by: Leo Liu <leo.liu@amd.com>


On 08/16/2018 12:06 PM, boyuan.zhang@amd.com wrote:
> From: Boyuan Zhang <boyuan.zhang@amd.com>
>
> Use function pointer for sending cmd in end_frame call. By doing this, we can
> assign different cmd sending logics for Jpeg decode later.
>
> Signed-off-by: Boyuan Zhang <boyuan.zhang@amd.com>
> ---
>   src/gallium/drivers/radeon/radeon_vcn_dec.c | 30 ++++++++++++++++++++---------
>   src/gallium/drivers/radeon/radeon_vcn_dec.h |  7 +++++++
>   2 files changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/src/gallium/drivers/radeon/radeon_vcn_dec.c b/src/gallium/drivers/radeon/radeon_vcn_dec.c
> index e6c1b67..30a8952 100644
> --- a/src/gallium/drivers/radeon/radeon_vcn_dec.c
> +++ b/src/gallium/drivers/radeon/radeon_vcn_dec.c
> @@ -1111,24 +1111,17 @@ static void radeon_dec_decode_bitstream(struct pipe_video_codec *decoder,
>   }
>   
>   /**
> - * end decoding of the current frame
> + * send cmd for vcn dec
>    */
> -static void radeon_dec_end_frame(struct pipe_video_codec *decoder,
> +void send_cmd_dec(struct radeon_decoder *dec,
>   			   struct pipe_video_buffer *target,
>   			   struct pipe_picture_desc *picture)
>   {
> -	struct radeon_decoder *dec = (struct radeon_decoder*)decoder;
>   	struct pb_buffer *dt;
>   	struct rvid_buffer *msg_fb_it_buf, *bs_buf;
>   
> -	assert(decoder);
> -
> -	if (!dec->bs_ptr)
> -		return;
> -
>   	msg_fb_it_buf = &dec->msg_fb_it_buffers[dec->cur_buffer];
>   	bs_buf = &dec->bs_buffers[dec->cur_buffer];
> -
>   	memset(dec->bs_ptr, 0, align(dec->bs_size, 128) - dec->bs_size);
>   	dec->ws->buffer_unmap(bs_buf->res->buf);
>   
> @@ -1152,6 +1145,23 @@ static void radeon_dec_end_frame(struct pipe_video_codec *decoder,
>   		send_cmd(dec, RDECODE_CMD_IT_SCALING_TABLE_BUFFER, msg_fb_it_buf->res->buf,
>   			 FB_BUFFER_OFFSET + FB_BUFFER_SIZE, RADEON_USAGE_READ, RADEON_DOMAIN_GTT);
>   	set_reg(dec, RDECODE_ENGINE_CNTL, 1);
> +}
> +
> +/**
> + * end decoding of the current frame
> + */
> +static void radeon_dec_end_frame(struct pipe_video_codec *decoder,
> +			   struct pipe_video_buffer *target,
> +			   struct pipe_picture_desc *picture)
> +{
> +	struct radeon_decoder *dec = (struct radeon_decoder*)decoder;
> +
> +	assert(decoder);
> +
> +	if (!dec->bs_ptr)
> +		return;
> +
> +	dec->send_cmd(dec, target, picture);
>   
>   	flush(dec, PIPE_FLUSH_ASYNC);
>   	next_buffer(dec);
> @@ -1294,6 +1304,8 @@ struct pipe_video_codec *radeon_create_decoder(struct pipe_context *context,
>   
>   	next_buffer(dec);
>   
> +	dec->send_cmd = send_cmd_dec;
> +
>   	return &dec->base;
>   
>   error:
> diff --git a/src/gallium/drivers/radeon/radeon_vcn_dec.h b/src/gallium/drivers/radeon/radeon_vcn_dec.h
> index 399d75c..05e4847 100644
> --- a/src/gallium/drivers/radeon/radeon_vcn_dec.h
> +++ b/src/gallium/drivers/radeon/radeon_vcn_dec.h
> @@ -618,8 +618,15 @@ struct radeon_decoder {
>   	void				*render_pic_list[16];
>   
>   	struct jpeg_params		jpg;
> +	void (*send_cmd)(struct radeon_decoder *dec,
> +			 struct pipe_video_buffer *target,
> +			 struct pipe_picture_desc *picture);
>   };
>   
> +void send_cmd_dec(struct radeon_decoder *dec,
> +		  struct pipe_video_buffer *target,
> +		  struct pipe_picture_desc *picture);
> +
>   struct pipe_video_codec *radeon_create_decoder(struct pipe_context *context,
>   		const struct pipe_video_codec *templat);
>