#define ENC_SET_FIXED_SLICE (1 << 6)
#define ENC_SET_PVC_MODE (1 << 7)
#define ENC_SET_RATIO_OF_INTRA (1 << 8)
+#define ENC_SET_COLOR_ASPECT (1 << 9)
#define MFC_VER_MAJOR(dev) ((s5p_mfc_version(dev) >> 8) & 0xFF)
#define MFC_VER_MINOR(dev) (s5p_mfc_version(dev) & 0xFF)
(dev->fw.date >= 0x171023))
#define FW_HAS_RATIO_INTRA_CTRL(dev) (FROM_MFCV11X(dev) && \
(dev->fw.date >= 0x171113))
+#define FW_HAS_ENC_COLOR_ASPECT(dev) (FROM_MFCV11X(dev) && \
+ (dev->fw.date >= 0x171023))
static inline unsigned int s5p_mfc_version(struct s5p_mfc_dev *dev)
{
u32 i_frm_ctrl_mode;
u32 i_frm_ctrl;
+ u32 color_range;
+ u32 colour_primaries;
+ u32 transfer_characteristics;
+ u32 matrix_coefficients;
+
union {
struct s5p_mfc_h264_enc_params h264;
struct s5p_mfc_mpeg4_enc_params mpeg4;
unsigned char frame_cnt;
unsigned int num_of_tile_over_4;
+
+ unsigned int color_range;
+ unsigned int color_space;
};
struct s5p_mfc_enc {
int ts_count;
int ts_is_full;
- unsigned int color_range;
- unsigned int color_space;
-
int buf_process_type;
unsigned long raw_protect_flag;
{
struct s5p_mfc_buf_ctrl *buf_ctrl;
struct s5p_mfc_dev *dev = ctx->dev;
+ struct s5p_mfc_dec *dec = ctx->dec_priv;
unsigned int value = 0;
list_for_each_entry(buf_ctrl, head, list) {
if (IS_VP9_DEC(ctx)) {
if (buf_ctrl->id == V4L2_CID_MPEG_VIDEO_FULL_RANGE_FLAG)
- buf_ctrl->val = ctx->color_range;
+ buf_ctrl->val = dec->color_range;
else if (buf_ctrl->id == V4L2_CID_MPEG_VIDEO_COLOUR_PRIMARIES)
- buf_ctrl->val = ctx->color_space;
+ buf_ctrl->val = dec->color_space;
}
mfc_debug(8, "Get buffer control "\
"id: 0x%08x val: %d\n",
static int s5p_mfc_dec_get_buf_ctrls_val_nal_q_dec(struct s5p_mfc_ctx *ctx,
struct list_head *head, DecoderOutputStr *pOutStr)
{
+ struct s5p_mfc_dec *dec = ctx->dec_priv;
struct s5p_mfc_buf_ctrl *buf_ctrl;
unsigned int value = 0;
break;
case V4L2_CID_MPEG_VIDEO_FULL_RANGE_FLAG:
if (IS_VP9_DEC(ctx)) {
- buf_ctrl->val = ctx->color_range;
+ buf_ctrl->val = dec->color_range;
buf_ctrl->has_new = 1;
continue;
}
case V4L2_CID_MPEG_VIDEO_COLOUR_PRIMARIES:
if (IS_VP9_DEC(ctx)) {
- buf_ctrl->val = ctx->color_space;
+ buf_ctrl->val = dec->color_space;
buf_ctrl->has_new = 1;
continue;
}
if (FW_HAS_RATIO_INTRA_CTRL(dev))
val |= ENC_SET_RATIO_OF_INTRA;
+ if (FW_HAS_ENC_COLOR_ASPECT(dev))
+ val |= ENC_SET_COLOR_ASPECT;
+
return val;
}
case V4L2_CID_MPEG_VIDEO_RATIO_OF_INTRA:
p->ratio_intra = ctrl->value;
break;
+ case V4L2_CID_MPEG_VIDEO_FULL_RANGE_FLAG:
+ p->color_range = ctrl->value;
+ break;
+ case V4L2_CID_MPEG_VIDEO_COLOUR_PRIMARIES:
+ p->colour_primaries = ctrl->value;
+ break;
+ case V4L2_CID_MPEG_VIDEO_TRANSFER_CHARACTERISTICS:
+ p->transfer_characteristics = ctrl->value;
+ break;
+ case V4L2_CID_MPEG_VIDEO_MATRIX_COEFFICIENTS:
+ p->matrix_coefficients = ctrl->value;
+ break;
default:
mfc_err_ctx("Invalid control: 0x%08x\n", ctrl->id);
ret = -EINVAL;
.step = 1,
.default_value = 0,
},
+ {
+ .id = V4L2_CID_MPEG_VIDEO_FULL_RANGE_FLAG,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Color range",
+ .minimum = 0,
+ .maximum = 1,
+ .step = 1,
+ .default_value = 0,
+ },
+ {
+ .id = V4L2_CID_MPEG_VIDEO_COLOUR_PRIMARIES,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Colour primaries",
+ .minimum = 0,
+ .maximum = 10,
+ .step = 1,
+ .default_value = 0,
+ },
+ {
+ .id = V4L2_CID_MPEG_VIDEO_TRANSFER_CHARACTERISTICS,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Transfer characteristics",
+ .minimum = 0,
+ .maximum = 17,
+ .step = 1,
+ .default_value = 0,
+ },
+ {
+ .id = V4L2_CID_MPEG_VIDEO_MATRIX_COEFFICIENTS,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Matrix coefficients",
+ .minimum = 0,
+ .maximum = 10,
+ .step = 1,
+ .default_value = 0,
+ },
};
#define NUM_CTRLS ARRAY_SIZE(controls)
MFC_WRITEL(reg, S5P_FIMV_E_H264_FRAME_PACKING_SEI_INFO);
}
+ if (FW_HAS_ENC_COLOR_ASPECT(dev)) {
+ reg = MFC_READL(S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
+ /* VIDEO_SIGNAL_TYPE_FLAG */
+ reg |= 0x1 << 31;
+ /* COLOR_RANGE */
+ reg &= ~(0x1 << 25);
+ reg |= p->color_range << 25;
+ /* COLOUR_DESCRIPTION_PRESENT_FLAG */
+ reg |= 0x1 << 24;
+ /* COLOUR_PRIMARIES */
+ reg &= ~(0xFF << 16);
+ reg |= p->colour_primaries << 16;
+ /* TRANSFER_CHARACTERISTICS */
+ reg &= ~(0xFF << 8);
+ reg |= p->transfer_characteristics << 8;
+ /* MATRIX_COEFFICIENTS */
+ reg &= ~(0xFF);
+ reg |= p->matrix_coefficients;
+ MFC_WRITEL(reg, S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
+ mfc_debug(2, "H264 ENC Color aspect: range:%s, pri:%d, trans:%d, mat:%d\n",
+ p->color_range ? "Full" : "Limited", p->colour_primaries,
+ p->transfer_characteristics, p->matrix_coefficients);
+ }
+
mfc_set_fmo_slice_map_h264(ctx, p_264);
mfc_debug_leave();
reg |= p_vp9->rc_min_qp_p & 0xFF;
MFC_WRITEL(reg, S5P_FIMV_E_RC_QP_BOUND_PB);
+ if (FW_HAS_ENC_COLOR_ASPECT(dev)) {
+ reg = MFC_READL(S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
+ /* VIDEO_SIGNAL_TYPE_FLAG */
+ reg |= 0x1 << 31;
+ /* COLOR_SPACE: VP9 uses colour_primaries interface for color space */
+ reg &= ~(0x1F << 26);
+ reg |= p->colour_primaries << 26;
+ /* COLOR_RANGE */
+ reg &= ~(0x1 << 25);
+ reg |= p->color_range << 25;
+ MFC_WRITEL(reg, S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
+ mfc_debug(2, "VP9 ENC Color aspect: range:%s, space: %d\n",
+ p->color_range ? "Full" : "Limited", p->colour_primaries);
+ }
+
mfc_debug_leave();
}
MFC_WRITEL(reg, S5P_FIMV_E_RC_ROI_CTRL);
mfc_debug(3, "ROI: HEVC ROI enable\n");
+ if (FW_HAS_ENC_COLOR_ASPECT(dev)) {
+ reg = MFC_READL(S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
+ /* VIDEO_SIGNAL_TYPE_FLAG */
+ reg |= 0x1 << 31;
+ /* COLOR_RANGE */
+ reg &= ~(0x1 << 25);
+ reg |= p->color_range << 25;
+ /* COLOUR_DESCRIPTION_PRESENT_FLAG */
+ reg |= 0x1 << 24;
+ /* COLOUR_PRIMARIES */
+ reg &= ~(0xFF << 16);
+ reg |= p->colour_primaries << 16;
+ /* TRANSFER_CHARACTERISTICS */
+ reg &= ~(0xFF << 8);
+ reg |= p->transfer_characteristics << 8;
+ /* MATRIX_COEFFICIENTS */
+ reg &= ~(0xFF);
+ reg |= p->matrix_coefficients;
+ MFC_WRITEL(reg, S5P_FIMV_E_VIDEO_SIGNAL_TYPE);
+ mfc_debug(2, "HEVC ENC Color aspect: range:%s, pri:%d, trans:%d, mat:%d\n",
+ p->color_range ? "Full" : "Limited", p->colour_primaries,
+ p->transfer_characteristics, p->matrix_coefficients);
+ }
+
mfc_debug_leave();
}
}
if (IS_VP9_DEC(ctx) && FW_HAS_VP9_HDR(dev)) {
- if (ctx->color_space != S5P_FIMV_D_COLOR_UNKNOWN) {
+ if (dec->color_space != S5P_FIMV_D_COLOR_UNKNOWN) {
ref_mb->vb.reserved2 |= (1 << 3);
mfc_debug(2, "color space parsed\n");
}
}
if (IS_VP9_DEC(ctx)) {
- ctx->color_range = s5p_mfc_get_color_range();
- ctx->color_space = s5p_mfc_get_color_space();
+ dec->color_range = s5p_mfc_get_color_range();
+ dec->color_space = s5p_mfc_get_color_space();
mfc_debug(2, "color range: %d, color space: %d, It's valid for VP9\n",
- ctx->color_range, ctx->color_space);
+ dec->color_range, dec->color_space);
}
return 0;
}
if (IS_VP9_DEC(ctx) && FW_HAS_VP9_HDR(dev)) {
- if (ctx->color_space != S5P_FIMV_D_COLOR_UNKNOWN) {
+ if (dec->color_space != S5P_FIMV_D_COLOR_UNKNOWN) {
ref_mb->vb.reserved2 |= (1 << 3);
mfc_debug(2, "NAL Q: color space parsed\n");
}
#define S5P_FIMV_E_MV_VER_RANGE 0xF7B8
#define S5P_FIMV_E_HIGH_QUALITY_MODE 0xF7C0
+#define S5P_FIMV_E_VIDEO_SIGNAL_TYPE 0xF7C4
#define S5P_FIMV_E_SAO_WEIGHT0 0xF7C8
#define S5P_FIMV_E_SAO_WEIGHT1 0xF7CC