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 {
}
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);
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);
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");
}
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;
}
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");
}
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)
{
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);
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;
}
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,
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 */
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;
}
}
- 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)
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,