From 6ca170cdef98bdfddcd5b362ab8ecd8729606bbf Mon Sep 17 00:00:00 2001 From: Jeonghee Kim Date: Fri, 25 May 2018 15:57:55 +0900 Subject: [PATCH] [COMMON] media: mfc: parse supported version of each feature Added to check the supported F/W version of each feature. It is possible to check whether each feature is supported by using the command below. echo 1 > d/mfc/mfc_info Change-Id: I7b28ac5136951c8bac0c4ae5856bb9e9c37a0b3f Signed-off-by: Jeonghee Kim --- drivers/media/platform/exynos/mfc/s5p_mfc.c | 31 +++++++++++++------ .../platform/exynos/mfc/s5p_mfc_common.h | 2 ++ .../platform/exynos/mfc/s5p_mfc_data_struct.h | 25 ++++++++++----- .../platform/exynos/mfc/s5p_mfc_debugfs.c | 11 +++++++ .../media/platform/exynos/mfc/s5p_mfc_dec.c | 2 +- .../media/platform/exynos/mfc/s5p_mfc_enc.c | 6 ++-- .../platform/exynos/mfc/s5p_mfc_enc_param.c | 9 +++--- .../media/platform/exynos/mfc/s5p_mfc_inst.c | 2 +- .../media/platform/exynos/mfc/s5p_mfc_irq.c | 8 ++--- .../media/platform/exynos/mfc/s5p_mfc_nal_q.c | 6 ++-- .../media/platform/exynos/mfc/s5p_mfc_reg.c | 2 +- 11 files changed, 70 insertions(+), 34 deletions(-) diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc.c b/drivers/media/platform/exynos/mfc/s5p_mfc.c index 2b1fd66771d9..a5956c130c49 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc.c @@ -393,7 +393,7 @@ static int mfc_init_instance(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx) s5p_mfc_release_hwlock_dev(dev); - if (dev->pdata->nal_q) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->nal_q)) { dev->nal_q_handle = s5p_mfc_nal_q_create(dev); if (dev->nal_q_handle == NULL) mfc_err_dev("NAL Q: Can't create nal q\n"); @@ -951,26 +951,37 @@ static void mfc_parse_dt(struct device_node *np, struct s5p_mfc_dev *mfc) if (!np) return; + /* MFC version */ of_property_read_u32(np, "ip_ver", &pdata->ip_ver); + + /* Debug mode */ of_property_read_u32(np, "debug_mode", &pdata->debug_mode); + + /* Sysmmu check */ of_property_read_u32(np, "share_sysmmu", &pdata->share_sysmmu); of_property_read_u32(np, "axid_mask", &pdata->axid_mask); of_property_read_u32(np, "mfc_fault_num", &pdata->mfc_fault_num); - of_property_read_u32(np, "nal_q", &pdata->nal_q); - of_property_read_u32(np, "skype", &pdata->skype); - of_property_read_u32(np, "black_bar", &pdata->black_bar); - of_property_read_u32(np, "color_aspect_dec", &pdata->color_aspect_dec); - of_property_read_u32(np, "static_info_dec", &pdata->static_info_dec); - of_property_read_u32(np, "color_aspect_enc", &pdata->color_aspect_enc); - of_property_read_u32(np, "static_info_enc", &pdata->static_info_enc); + + /* Features */ + of_property_read_u32_array(np, "nal_q", &pdata->nal_q.support, 2); + of_property_read_u32_array(np, "skype", &pdata->skype.support, 2); + of_property_read_u32_array(np, "black_bar", &pdata->black_bar.support, 2); + of_property_read_u32_array(np, "color_aspect_dec", &pdata->color_aspect_dec.support, 2); + of_property_read_u32_array(np, "static_info_dec", &pdata->static_info_dec.support, 2); + of_property_read_u32_array(np, "color_aspect_enc", &pdata->color_aspect_enc.support, 2); + of_property_read_u32_array(np, "static_info_enc", &pdata->static_info_enc.support, 2); + + /* Encoder default parameter */ of_property_read_u32(np, "enc_param_num", &pdata->enc_param_num); if (pdata->enc_param_num) { of_property_read_u32_array(np, "enc_param_addr", - &pdata->enc_param_addr[0], pdata->enc_param_num); + pdata->enc_param_addr, pdata->enc_param_num); of_property_read_u32_array(np, "enc_param_val", - &pdata->enc_param_val[0], pdata->enc_param_num); + pdata->enc_param_val, pdata->enc_param_num); } + #ifdef CONFIG_MFC_USE_BUS_DEVFREQ + /* QoS */ of_property_read_u32(np, "num_qos_steps", &pdata->num_qos_steps); of_property_read_u32(np, "max_qos_steps", &pdata->max_qos_steps); of_property_read_u32(np, "max_mb", &pdata->max_mb); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h index 42208d97aa10..ae107bf7bf7a 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_common.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_common.h @@ -180,4 +180,6 @@ #define MFC_VER_MAJOR(dev) ((dev->pdata->ip_ver >> 8) & 0xFF) #define MFC_VER_MINOR(dev) (dev->pdata->ip_ver & 0xFF) +#define MFC_FEATURE_SUPPORT(dev, f) ((f).support && ((dev)->fw.date >= (f).version)) + #endif /* __S5P_MFC_COMMON_H */ diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h index 6e6b14f5bc82..297dca3ddabf 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_data_struct.h @@ -370,23 +370,34 @@ struct s5p_mfc_qos { }; #endif +struct s5p_mfc_feature { + unsigned int support; + unsigned int version; +}; + struct s5p_mfc_platdata { + /* MFC version */ unsigned int ip_ver; + /* Debug mode */ unsigned int debug_mode; + /* Sysmmu check */ unsigned int share_sysmmu; unsigned int axid_mask; unsigned int mfc_fault_num; - unsigned int nal_q; - unsigned int skype; - unsigned int black_bar; - unsigned int color_aspect_dec; - unsigned int static_info_dec; - unsigned int color_aspect_enc; - unsigned int static_info_enc; + /* Features */ + struct s5p_mfc_feature nal_q; + struct s5p_mfc_feature skype; + struct s5p_mfc_feature black_bar; + struct s5p_mfc_feature color_aspect_dec; + struct s5p_mfc_feature static_info_dec; + struct s5p_mfc_feature color_aspect_enc; + struct s5p_mfc_feature static_info_enc; + /* Encoder default parameter */ unsigned int enc_param_num; unsigned int enc_param_addr[MFC_MAX_DEFAULT_PARAM]; unsigned int enc_param_val[MFC_MAX_DEFAULT_PARAM]; #ifdef CONFIG_MFC_USE_BUS_DEVFREQ + /* QoS */ unsigned int num_qos_steps; unsigned int max_qos_steps; unsigned int max_mb; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c b/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c index dba5337e52f9..5341b4995130 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_debugfs.c @@ -50,9 +50,20 @@ static int mfc_info_show(struct seq_file *s, void *unused) seq_printf(s, "[HWLOCK] bits: %#lx, dev: %#lx, owned_by_irq = %d, wl_count = %d\n", dev->hwlock.bits, dev->hwlock.dev, dev->hwlock.owned_by_irq, dev->hwlock.wl_count); + seq_printf(s, "[DEBUG MODE] %s\n", dev->pdata->debug_mode ? "enabled" : "disabled"); seq_printf(s, "[MMCACHE] %s(%s)\n", dev->has_mmcache ? "supported" : "not supported", dev->mmcache.is_on_status ? "enabled" : "disabled"); + seq_printf(s, "[FEATURES] nal_q: %d(0x%x), skype: %d(0x%x), black_bar: %d(0x%x)\n", + dev->pdata->nal_q.support, dev->pdata->nal_q.version, + dev->pdata->skype.support, dev->pdata->skype.version, + dev->pdata->black_bar.support, dev->pdata->black_bar.version); + seq_printf(s, " color_aspect_dec: %d(0x%x), enc: %d(0x%x)\n", + dev->pdata->color_aspect_dec.support, dev->pdata->color_aspect_dec.version, + dev->pdata->color_aspect_enc.support, dev->pdata->color_aspect_enc.version); + seq_printf(s, " static_info_dec: %d(0x%x), enc: %d(0x%x)\n", + dev->pdata->static_info_dec.support, dev->pdata->static_info_dec.version, + dev->pdata->static_info_enc.support, dev->pdata->static_info_enc.version); if (dev->nal_q_handle) seq_printf(s, "[NAL-Q] state: %d\n", dev->nal_q_handle->nal_q_state); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c b/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c index 93ee73436264..8de947ab5470 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_dec.c @@ -880,7 +880,7 @@ static int mfc_dec_ext_info(struct s5p_mfc_ctx *ctx) int val = 0; val |= DEC_SET_DYNAMIC_DPB; - if (dev->pdata->skype) + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->skype)) val |= DEC_SET_SKYPE_FLAG; return val; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c index 66805a334598..dc6687270164 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc.c @@ -805,7 +805,7 @@ static int mfc_enc_ext_info(struct s5p_mfc_ctx *ctx) val |= ENC_SET_SPARE_SIZE; val |= ENC_SET_TEMP_SVC_CH; - if (dev->pdata->skype) + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->skype)) val |= ENC_SET_SKYPE_FLAG; val |= ENC_SET_ROI_CONTROL; @@ -814,12 +814,12 @@ static int mfc_enc_ext_info(struct s5p_mfc_ctx *ctx) val |= ENC_SET_PVC_MODE; val |= ENC_SET_RATIO_OF_INTRA; - if (dev->pdata->color_aspect_enc) + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->color_aspect_enc)) val |= ENC_SET_COLOR_ASPECT; val |= ENC_SET_HP_BITRATE_CONTROL; - if (dev->pdata->static_info_enc) + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->static_info_enc)) val |= ENC_SET_STATIC_INFO; return val; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c index 5305bd460d38..618bbc26d1a9 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_enc_param.c @@ -581,7 +581,7 @@ void s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx) MFC_WRITEL(reg, S5P_FIMV_E_H264_FRAME_PACKING_SEI_INFO); } - if (dev->pdata->color_aspect_enc && p->check_color_range) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->color_aspect_enc) && p->check_color_range) { reg = MFC_READL(S5P_FIMV_E_VIDEO_SIGNAL_TYPE); /* VIDEO_SIGNAL_TYPE_FLAG */ reg |= 0x1 << 31; @@ -1048,7 +1048,7 @@ void s5p_mfc_set_enc_params_vp9(struct s5p_mfc_ctx *ctx) reg |= p_vp9->rc_min_qp_p & 0xFF; MFC_WRITEL(reg, S5P_FIMV_E_RC_QP_BOUND_PB); - if (dev->pdata->color_aspect_enc && p->check_color_range) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->color_aspect_enc) && p->check_color_range) { reg = MFC_READL(S5P_FIMV_E_VIDEO_SIGNAL_TYPE); /* VIDEO_SIGNAL_TYPE_FLAG */ reg |= 0x1 << 31; @@ -1294,7 +1294,7 @@ void s5p_mfc_set_enc_params_hevc(struct s5p_mfc_ctx *ctx) MFC_WRITEL(reg, S5P_FIMV_E_RC_ROI_CTRL); mfc_debug(3, "ROI: HEVC ROI enable\n"); - if (dev->pdata->color_aspect_enc && p->check_color_range) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->color_aspect_enc) && p->check_color_range) { reg = MFC_READL(S5P_FIMV_E_VIDEO_SIGNAL_TYPE); /* VIDEO_SIGNAL_TYPE_FLAG */ reg |= 0x1 << 31; @@ -1325,7 +1325,8 @@ void s5p_mfc_set_enc_params_hevc(struct s5p_mfc_ctx *ctx) MFC_WRITEL(0, S5P_FIMV_E_VIDEO_SIGNAL_TYPE); } - if (dev->pdata->static_info_enc && p->static_info_enable && ctx->is_10bit) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->static_info_enc) && + p->static_info_enable && ctx->is_10bit) { reg = MFC_READL(S5P_FIMV_E_HEVC_OPTIONS_2); /* HDR_STATIC_INFO_ENABLE */ reg |= p->static_info_enable; diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_inst.c b/drivers/media/platform/exynos/mfc/s5p_mfc_inst.c index 2542044835b4..b1c675c30385 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_inst.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_inst.c @@ -177,7 +177,7 @@ int s5p_mfc_init_decode(struct s5p_mfc_ctx *ctx) /* Enable realloc interface if SEI is enabled */ if (dec->sei_parse) reg |= (0x1 << S5P_FIMV_D_SEI_ENABLE_NEED_INIT_BUFFER_SHIFT); - if (dev->pdata->static_info_dec) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->static_info_dec)) { reg |= (0x1 << S5P_FIMV_D_SEI_ENABLE_CONTENT_LIGHT_SHIFT); reg |= (0x1 << S5P_FIMV_D_SEI_ENABLE_MASTERING_DISPLAY_SHIFT); } diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c index f900a9280e19..38811af55fb1 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_irq.c @@ -224,17 +224,17 @@ static void mfc_handle_frame_output_del(struct s5p_mfc_ctx *ctx, unsigned int is_content_light = 0, is_display_colour = 0; unsigned int i, index; - if (dev->pdata->color_aspect_dec) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->color_aspect_dec)) { is_video_signal_type = s5p_mfc_get_video_signal_type(); is_colour_description = s5p_mfc_get_colour_description(); } - if (dev->pdata->static_info_dec) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->static_info_dec)) { is_content_light = s5p_mfc_get_sei_avail_content_light(); is_display_colour = s5p_mfc_get_sei_avail_mastering_display(); } - if (dev->pdata->black_bar && dec->detect_black_bar) + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->black_bar) && dec->detect_black_bar) mfc_handle_black_bar_info(dev, ctx); else dec->black_bar_updated = 0; @@ -284,7 +284,7 @@ static void mfc_handle_frame_output_del(struct s5p_mfc_ctx *ctx, } } - if (IS_VP9_DEC(ctx) && dev->pdata->color_aspect_dec) { + if (IS_VP9_DEC(ctx) && MFC_FEATURE_SUPPORT(dev, dev->pdata->color_aspect_dec)) { if (dec->color_space != S5P_FIMV_D_COLOR_UNKNOWN) { ref_mb->vb.reserved2 |= (1 << 3); mfc_debug(2, "color space parsed\n"); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c b/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c index a88e2ae227e8..af2a9a9f06be 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_nal_q.c @@ -1231,7 +1231,7 @@ static void mfc_nal_q_handle_frame_output_del(struct s5p_mfc_ctx *ctx, unsigned int disp_err; int i, index; - if (dev->pdata->color_aspect_dec) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->color_aspect_dec)) { is_video_signal_type = ((pOutStr->VideoSignalType >> S5P_FIMV_D_VIDEO_SIGNAL_TYPE_FLAG_SHIFT) & S5P_FIMV_D_VIDEO_SIGNAL_TYPE_FLAG_MASK); @@ -1240,7 +1240,7 @@ static void mfc_nal_q_handle_frame_output_del(struct s5p_mfc_ctx *ctx, & S5P_FIMV_D_COLOUR_DESCRIPTION_FLAG_MASK); } - if (dev->pdata->static_info_dec) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->static_info_dec)) { is_content_light = ((pOutStr->SeiAvail >> S5P_FIMV_D_SEI_AVAIL_CONTENT_LIGHT_SHIFT) & S5P_FIMV_D_SEI_AVAIL_CONTENT_LIGHT_MASK); is_display_colour = ((pOutStr->SeiAvail >> S5P_FIMV_D_SEI_AVAIL_MASTERING_DISPLAY_SHIFT) @@ -1288,7 +1288,7 @@ static void mfc_nal_q_handle_frame_output_del(struct s5p_mfc_ctx *ctx, } } - if (IS_VP9_DEC(ctx) && dev->pdata->color_aspect_dec) { + if (IS_VP9_DEC(ctx) && MFC_FEATURE_SUPPORT(dev, dev->pdata->color_aspect_dec)) { if (dec->color_space != S5P_FIMV_D_COLOR_UNKNOWN) { ref_mb->vb.reserved2 |= (1 << 3); mfc_debug(2, "NAL Q: color space parsed\n"); diff --git a/drivers/media/platform/exynos/mfc/s5p_mfc_reg.c b/drivers/media/platform/exynos/mfc/s5p_mfc_reg.c index 8b21e3271f4b..e4af9d98922a 100644 --- a/drivers/media/platform/exynos/mfc/s5p_mfc_reg.c +++ b/drivers/media/platform/exynos/mfc/s5p_mfc_reg.c @@ -459,7 +459,7 @@ int s5p_mfc_set_dynamic_dpb(struct s5p_mfc_ctx *ctx, struct s5p_mfc_buf *dst_mb) mfc_debug(2, "Dst addr [%d] = 0x%08llx\n", dst_index, dst_mb->addr[0][0]); /* for debugging about black bar detection */ - if (dev->pdata->black_bar && dec->detect_black_bar) { + if (MFC_FEATURE_SUPPORT(dev, dev->pdata->black_bar) && dec->detect_black_bar) { for (i = 0; i < raw->num_planes; i++) { dec->frame_vaddr[i][dec->frame_cnt] = vb2_plane_vaddr(&dst_mb->vb.vb2_buf, i); dec->frame_daddr[i][dec->frame_cnt] = dst_mb->addr[0][i]; -- 2.20.1