From 25498fe10c3ad500834cfd2868e2db0dc0ff4b4e Mon Sep 17 00:00:00 2001 From: Sunyoung Kang Date: Mon, 2 Jul 2018 17:22:28 +0900 Subject: [PATCH] [COMMON] media: mfc: DRV4.0: refactoring flag info The vb.reserved2 field of struct vb2_v4l2_buffer stores the flags used to exchange information between driver and HAL. This provides APIs for using flags. - mfc_clear_vb_flag() - mfc_set_vb_flag() - mfc_check_vb_flag() Change-Id: I403e8543983b488895214fef483ad3d47e049408 Signed-off-by: Sunyoung Kang --- .../platform/exynos/mfc/mfc_data_struct.h | 12 +++++ .../media/platform/exynos/mfc/mfc_dec_vb2.c | 2 +- drivers/media/platform/exynos/mfc/mfc_isr.c | 20 +++---- drivers/media/platform/exynos/mfc/mfc_nal_q.c | 18 +++---- drivers/media/platform/exynos/mfc/mfc_queue.c | 52 +++---------------- drivers/media/platform/exynos/mfc/mfc_queue.h | 5 +- drivers/media/platform/exynos/mfc/mfc_run.c | 4 +- drivers/media/platform/exynos/mfc/mfc_utils.h | 18 +++++++ 8 files changed, 60 insertions(+), 71 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/mfc_data_struct.h b/drivers/media/platform/exynos/mfc/mfc_data_struct.h index 155b83553a88..5129566a248a 100644 --- a/drivers/media/platform/exynos/mfc/mfc_data_struct.h +++ b/drivers/media/platform/exynos/mfc/mfc_data_struct.h @@ -170,6 +170,18 @@ enum mfc_ctrl_mode { MFC_CTRL_MODE_CST = 0x2, }; +enum mfc_vb_flag { + MFC_FLAG_HDR_CONTENT_LIGHT = 0, + MFC_FLAG_HDR_DISPLAY_COLOUR = 1, + MFC_FLAG_HDR_MAXTIX_COEFF = 2, + MFC_FLAG_HDR_COLOUR_DESC = 3, + MFC_FLAG_HDR_VIDEO_SIGNAL_TYPE = 4, + MFC_FLAG_BLACKBAR_DETECT = 5, + MFC_FLAG_CSD = 29, + MFC_FLAG_EMPTY_DATA = 30, + MFC_FLAG_LAST_FRAME = 31, +}; + struct mfc_ctx; enum mfc_debug_cause { diff --git a/drivers/media/platform/exynos/mfc/mfc_dec_vb2.c b/drivers/media/platform/exynos/mfc/mfc_dec_vb2.c index 2730527a0609..bc5bfcdbe8f5 100644 --- a/drivers/media/platform/exynos/mfc/mfc_dec_vb2.c +++ b/drivers/media/platform/exynos/mfc/mfc_dec_vb2.c @@ -380,7 +380,7 @@ static void __mfc_dec_src_stop_streaming(struct mfc_ctx *ctx) } while (1) { - csd = mfc_peek_buf_csd(&ctx->buf_queue_lock, &ctx->src_buf_queue); + csd = mfc_check_buf_vb_flag(ctx, MFC_FLAG_CSD); if (csd == 1) { mfc_clean_ctx_int_flags(ctx); diff --git a/drivers/media/platform/exynos/mfc/mfc_isr.c b/drivers/media/platform/exynos/mfc/mfc_isr.c index 53c4059a5d8c..22ba05c4aa9d 100644 --- a/drivers/media/platform/exynos/mfc/mfc_isr.c +++ b/drivers/media/platform/exynos/mfc/mfc_isr.c @@ -125,7 +125,7 @@ static void __mfc_handle_frame_all_extracted(struct mfc_ctx *ctx) dst_mb->vb.sequence = (ctx->sequence++); dst_mb->vb.field = __mfc_handle_frame_field(ctx); - dst_mb->vb.reserved2 = 0; + mfc_clear_vb_flag(dst_mb); clear_bit(dst_mb->vb.vb2_buf.index, &dec->available_dpb); @@ -262,40 +262,40 @@ static void __mfc_handle_frame_output_del(struct mfc_ctx *ctx, ref_mb->vb.field = __mfc_handle_frame_field(ctx); /* Set reserved2 bits in order to inform SEI information */ - ref_mb->vb.reserved2 = 0; + mfc_clear_vb_flag(ref_mb); if (is_content_light) { - ref_mb->vb.reserved2 |= (1 << 0); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_CONTENT_LIGHT); mfc_debug(2, "[HDR] content light level parsed\n"); } if (is_display_colour) { - ref_mb->vb.reserved2 |= (1 << 1); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_DISPLAY_COLOUR); mfc_debug(2, "[HDR] mastering display colour parsed\n"); } if (is_video_signal_type) { - ref_mb->vb.reserved2 |= (1 << 4); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_VIDEO_SIGNAL_TYPE); mfc_debug(2, "[HDR] video signal type parsed\n"); if (is_colour_description) { - ref_mb->vb.reserved2 |= (1 << 2); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_MAXTIX_COEFF); mfc_debug(2, "[HDR] matrix coefficients parsed\n"); - ref_mb->vb.reserved2 |= (1 << 3); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_COLOUR_DESC); mfc_debug(2, "[HDR] colour description parsed\n"); } } if (IS_VP9_DEC(ctx) && MFC_FEATURE_SUPPORT(dev, dev->pdata->color_aspect_dec)) { if (dec->color_space != MFC_REG_D_COLOR_UNKNOWN) { - ref_mb->vb.reserved2 |= (1 << 3); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_COLOUR_DESC); mfc_debug(2, "[HDR] color space parsed\n"); } - ref_mb->vb.reserved2 |= (1 << 4); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_VIDEO_SIGNAL_TYPE); mfc_debug(2, "[HDR] color range parsed\n"); } if (dec->black_bar_updated) { - ref_mb->vb.reserved2 |= (1 << 5); + mfc_set_vb_flag(ref_mb, MFC_FLAG_BLACKBAR_DETECT); mfc_debug(3, "[BLACKBAR] black bar detected\n"); } diff --git a/drivers/media/platform/exynos/mfc/mfc_nal_q.c b/drivers/media/platform/exynos/mfc/mfc_nal_q.c index 411f206ee72d..a4ed5fec3d8a 100644 --- a/drivers/media/platform/exynos/mfc/mfc_nal_q.c +++ b/drivers/media/platform/exynos/mfc/mfc_nal_q.c @@ -58,7 +58,7 @@ int mfc_nal_q_check_enable(struct mfc_dev *dev) return 0; } /* NAL-Q can't use the command about last frame */ - if (mfc_is_last_frame(temp_ctx) == 1) { + if (mfc_check_buf_vb_flag(temp_ctx, MFC_FLAG_LAST_FRAME) == 1) { mfc_debug(2, "There is a last frame. index: %d\n", i); return 0; } @@ -1279,33 +1279,33 @@ static void __mfc_nal_q_handle_frame_output_del(struct mfc_ctx *ctx, ref_mb->vb.sequence = ctx->sequence; /* Set reserved2 bits in order to inform SEI information */ - ref_mb->vb.reserved2 = 0; + mfc_clear_vb_flag(ref_mb); if (is_content_light) { - ref_mb->vb.reserved2 |= (1 << 0); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_CONTENT_LIGHT); mfc_debug(2, "[NALQ][HDR] content light level parsed\n"); } if (is_display_colour) { - ref_mb->vb.reserved2 |= (1 << 1); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_DISPLAY_COLOUR); mfc_debug(2, "[NALQ][HDR] mastering display colour parsed\n"); } if (is_video_signal_type) { - ref_mb->vb.reserved2 |= (1 << 4); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_VIDEO_SIGNAL_TYPE); mfc_debug(2, "[NALQ][HDR] video signal type parsed\n"); if (is_colour_description) { - ref_mb->vb.reserved2 |= (1 << 2); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_MAXTIX_COEFF); mfc_debug(2, "[NALQ][HDR] matrix coefficients parsed\n"); - ref_mb->vb.reserved2 |= (1 << 3); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_COLOUR_DESC); mfc_debug(2, "[NALQ][HDR] colour description parsed\n"); } } if (IS_VP9_DEC(ctx) && MFC_FEATURE_SUPPORT(dev, dev->pdata->color_aspect_dec)) { if (dec->color_space != MFC_REG_D_COLOR_UNKNOWN) { - ref_mb->vb.reserved2 |= (1 << 3); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_COLOUR_DESC); mfc_debug(2, "[NALQ][HDR] color space parsed\n"); } - ref_mb->vb.reserved2 |= (1 << 4); + mfc_set_vb_flag(ref_mb, MFC_FLAG_HDR_VIDEO_SIGNAL_TYPE); mfc_debug(2, "[NALQ][HDR] color range parsed\n"); } diff --git a/drivers/media/platform/exynos/mfc/mfc_queue.c b/drivers/media/platform/exynos/mfc/mfc_queue.c index a28a1069496b..e4ee0dad230d 100644 --- a/drivers/media/platform/exynos/mfc/mfc_queue.c +++ b/drivers/media/platform/exynos/mfc/mfc_queue.c @@ -34,30 +34,6 @@ void mfc_add_tail_buf(spinlock_t *plock, struct mfc_buf_queue *queue, spin_unlock_irqrestore(plock, flags); } -int mfc_peek_buf_csd(spinlock_t *plock, struct mfc_buf_queue *queue) -{ - unsigned long flags; - int csd = -1; - struct mfc_buf *mfc_buf = NULL; - - spin_lock_irqsave(plock, flags); - - if (list_empty(&queue->head)) { - mfc_debug(2, "queue is empty\n"); - spin_unlock_irqrestore(plock, flags); - return csd; - } - - mfc_buf = list_entry(queue->head.next, struct mfc_buf, list); - - csd = mfc_buf->vb.reserved2 & FLAG_CSD ? 1 : 0; - - mfc_debug(2, "addr[0]: 0x%08llx\n", mfc_buf->addr[0][0]); - - spin_unlock_irqrestore(plock, flags); - return csd; -} - struct mfc_buf *mfc_get_buf(spinlock_t *plock, struct mfc_buf_queue *queue, enum mfc_queue_used_type used) { @@ -1020,24 +996,10 @@ void mfc_cleanup_nal_queue(struct mfc_ctx *ctx) spin_unlock_irqrestore(&ctx->buf_queue_lock, flags); } -int mfc_is_last_frame(struct mfc_ctx *ctx) +int mfc_check_buf_vb_flag(struct mfc_ctx *ctx, enum mfc_vb_flag f) { - struct mfc_buf *src_mb; - struct mfc_dev *dev; unsigned long flags; - - mfc_debug_enter(); - - if (!ctx) { - mfc_err_dev("no mfc context to run\n"); - return -EINVAL; - } - - dev = ctx->dev; - if (!dev) { - mfc_err_dev("no mfc device to run\n"); - return -EINVAL; - } + struct mfc_buf *mfc_buf = NULL; spin_lock_irqsave(&ctx->buf_queue_lock, flags); @@ -1047,20 +1009,18 @@ int mfc_is_last_frame(struct mfc_ctx *ctx) return -EINVAL; } - src_mb = list_entry(ctx->src_buf_queue.head.next, struct mfc_buf, list); + mfc_buf = list_entry(ctx->src_buf_queue.head.next, struct mfc_buf, list); mfc_debug(2, "[BUFINFO] addr[0]: 0x%08llx\n", mfc_buf->addr[0][0]); - if (src_mb->vb.reserved2 & FLAG_LAST_FRAME) { - mfc_debug(2, "last frame!\n"); + if (mfc_check_vb_flag(mfc_buf, f)) { + mfc_debug(2, "find flag %ld\n", f); spin_unlock_irqrestore(&ctx->buf_queue_lock, flags); return 1; } - mfc_debug(4, "not last frame!\n"); + mfc_debug(4, "no flag %ld\n", f); spin_unlock_irqrestore(&ctx->buf_queue_lock, flags); - mfc_debug_leave(); - return 0; } diff --git a/drivers/media/platform/exynos/mfc/mfc_queue.h b/drivers/media/platform/exynos/mfc/mfc_queue.h index 2c9345531392..392d0b38185e 100644 --- a/drivers/media/platform/exynos/mfc/mfc_queue.h +++ b/drivers/media/platform/exynos/mfc/mfc_queue.h @@ -105,8 +105,6 @@ static inline void mfc_delete_queue(struct mfc_buf_queue *queue) void mfc_add_tail_buf(spinlock_t *plock, struct mfc_buf_queue *queue, struct mfc_buf *mfc_buf); -int mfc_peek_buf_csd(spinlock_t *plock, struct mfc_buf_queue *queue); - struct mfc_buf *mfc_get_buf(spinlock_t *plock, struct mfc_buf_queue *queue, enum mfc_queue_used_type used); struct mfc_buf *mfc_get_del_buf(spinlock_t *plock, struct mfc_buf_queue *queue, @@ -155,6 +153,7 @@ struct mfc_buf *mfc_search_move_dpb_nal_q(struct mfc_ctx *ctx, unsigned int dyna void mfc_store_dpb(struct mfc_ctx *ctx, struct vb2_buffer *vb); void mfc_cleanup_nal_queue(struct mfc_ctx *ctx); -int mfc_is_last_frame(struct mfc_ctx *ctx); + +int mfc_check_buf_vb_flag(struct mfc_ctx *ctx, enum mfc_vb_flag f); #endif /* __MFC_QUEUE_H */ diff --git a/drivers/media/platform/exynos/mfc/mfc_run.c b/drivers/media/platform/exynos/mfc/mfc_run.c index d27743d2249a..a882999473a5 100644 --- a/drivers/media/platform/exynos/mfc/mfc_run.c +++ b/drivers/media/platform/exynos/mfc/mfc_run.c @@ -356,7 +356,7 @@ int mfc_run_dec_init(struct mfc_ctx *ctx) static int __mfc_check_last_frame(struct mfc_ctx *ctx, struct mfc_buf *mfc_buf) { - if (mfc_buf->vb.reserved2 & FLAG_LAST_FRAME) { + if (mfc_check_vb_flag(mfc_buf, FLAG_LAST_FRAME)) { mfc_debug(2, "Setting ctx->state to FINISHING\n"); mfc_change_state(ctx, MFCINST_FINISHING); return 1; @@ -394,7 +394,7 @@ int mfc_run_dec_frame(struct mfc_ctx *ctx) } } - if (src_mb->vb.reserved2 & FLAG_EMPTY_DATA) + if (mfc_check_vb_flag(src_mb, MFC_FLAG_EMPTY_DATA)) src_mb->vb.vb2_buf.planes[0].bytesused = 0; if (dec->consumed) diff --git a/drivers/media/platform/exynos/mfc/mfc_utils.h b/drivers/media/platform/exynos/mfc/mfc_utils.h index f9d3266ad3a7..4a6c939335b2 100644 --- a/drivers/media/platform/exynos/mfc/mfc_utils.h +++ b/drivers/media/platform/exynos/mfc/mfc_utils.h @@ -101,6 +101,24 @@ static inline int mfc_is_encoder_otf_node(enum mfc_node_type node) return 0; } +static inline void mfc_clear_vb_flag(struct mfc_buf *mfc_buf) +{ + mfc_buf->vb.reserved2 = 0; +} + +static inline void mfc_set_vb_flag(struct mfc_buf *mfc_buf, enum mfc_vb_flag f) +{ + mfc_buf->vb.reserved2 |= (1 << f); +} + +static inline int mfc_check_vb_flag(struct mfc_buf *mfc_buf, enum mfc_vb_flag f) +{ + if (mfc_buf->vb.reserved2 & f) + return 1; + + return 0; +} + int mfc_check_vb_with_fmt(struct mfc_fmt *fmt, struct vb2_buffer *vb); void mfc_raw_protect(struct mfc_ctx *ctx, struct mfc_buf *mfc_buf, -- 2.20.1