Now that we support two cores with different PP operations we need to make the condition to enable PP a bit smarter based on what is actually supported by each core. While doing this also move the needs_postproc() test inside the postproc .c file instead of cluttering the header. Signed-off-by: Adrian Ratiu <adrian.ratiu@xxxxxxxxxxxxx> --- drivers/staging/media/hantro/hantro.h | 10 ++----- .../staging/media/hantro/hantro_postproc.c | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/hantro/hantro.h b/drivers/staging/media/hantro/hantro.h index 2d507f8d3a1d..05e59bc83b71 100644 --- a/drivers/staging/media/hantro/hantro.h +++ b/drivers/staging/media/hantro/hantro.h @@ -393,6 +393,9 @@ static inline void hantro_reg_write_s(struct hantro_dev *vpu, vdpu_write(vpu, vdpu_read_mask(vpu, reg, val), reg->base); } +bool hantro_needs_postproc(const struct hantro_ctx *ctx, + const struct hantro_fmt *fmt); + void *hantro_get_ctrl(struct hantro_ctx *ctx, u32 id); dma_addr_t hantro_get_ref(struct hantro_ctx *ctx, u64 ts); @@ -408,13 +411,6 @@ hantro_get_dst_buf(struct hantro_ctx *ctx) return v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); } -static inline bool -hantro_needs_postproc(const struct hantro_ctx *ctx, - const struct hantro_fmt *fmt) -{ - return !ctx->is_encoder && fmt->fourcc != V4L2_PIX_FMT_NV12; -} - static inline dma_addr_t hantro_get_dec_buf_addr(struct hantro_ctx *ctx, struct vb2_buffer *vb) { diff --git a/drivers/staging/media/hantro/hantro_postproc.c b/drivers/staging/media/hantro/hantro_postproc.c index a6b3e243dc39..653bae37eed9 100644 --- a/drivers/staging/media/hantro/hantro_postproc.c +++ b/drivers/staging/media/hantro/hantro_postproc.c @@ -22,6 +22,35 @@ #define VC8000D_PP_OUT_NV12 0x0 +bool hantro_needs_postproc(const struct hantro_ctx *ctx, + const struct hantro_fmt *fmt) +{ + bool ret = false; + + /* postproc is only available for decoders */ + if (ctx->is_encoder) + return false; + + switch (ctx->dev->core_hw_dec_rev) { + case HANTRO_G1_REV: + /* + * for now the G1 PP is only used for NV12 -> YUYV conversion + * so if the dst format is already NV12 we don't need it + */ + ret = fmt->fourcc != V4L2_PIX_FMT_NV12; + break; + case HANTRO_VC8000_REV: + /* + * for now the VC8000D PP is only used to de-tile 4x4 NV12, so + * enabling it for something else doesn't make sense. + */ + ret = fmt->fourcc == V4L2_PIX_FMT_NV12; + break; + } + + return ret; +} + void hantro_postproc_enable(struct hantro_ctx *ctx) { struct hantro_regmap_fields_dec *fields = ctx->dev->reg_fields_dec; -- 2.28.0