Add encoder features
Subsystems (2)
Jackson.lee
maintainercover Add encoder features
From: Jackson Lee <[email protected]>
This series adds several encoder-side enhancements for the Wave5 driver.
The following features are introduced:
- Background detection support via V4L2 controls
- CBP profile support
- Support for packed YUV422 formats
Background detection allows the encoder to differentiate between foreground and background regions, potentially improving compression efficiency depending on the use case.
CBP profile support extends compatibility with additional encoding profiles.
Support for packed YUV422 formats enables handling of commonly used input formats such as YUYV and YVYU.
The changes include updates to control definitions, documentation, and driver implementation.
Tested on Wave5 encoder pipeline with GStreamer.
Change since v0:
* For [PATCH v1 1/4] media: v4l2-controls: Add control for background detection
- Added spaces around '+' in CID macro definition per CI suggestion
* For [PATCH v1 2/4] media: chips-media: wave5: Add support for background detection
- Split into two patches: API addition and driver implementation
* For [PATCH v1 3/4] media: chips-media: wave5: Support CBP profile
- Added Fixed tag
- Added braces to all branches in the else-if/else block
* For [PATCH v1 4/4] media: chips-media: wave5: Add Support for Packed YUV422 Formats
- Added Reviewed-by tag
Jackson Lee (4):
media: v4l2-controls: Add control for background detection
media: chips-media: wave5: Add support for background detection
media: chips-media: wave5: Support CBP profile
media: chips-media: wave5: Add Support for Packed YUV422 Formats
.../media/v4l/ext-ctrls-codec.rst | 6 +++ .../platform/chips-media/wave5/wave5-helper.h | 2 +- .../platform/chips-media/wave5/wave5-hw.c | 7 ++- .../chips-media/wave5/wave5-vpu-enc.c | 45 ++++++++++++++++++- .../platform/chips-media/wave5/wave5-vpuapi.h | 2 + drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 + include/uapi/linux/v4l2-controls.h | 2 + 7 files changed, 63 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0
Jackson.lee
maintainerPATCH 1/4 media: v4l2-controls: Add control for background detection
From: Jackson Lee <[email protected]>
Add a generic V4L2 boolean control V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION that allows encoders to detect background regions in a frame and use fewer bits or skip mode to encode them, potentially reducing bitrate for streams with stationary scenes.
--- Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 6 ++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 ++ include/uapi/linux/v4l2-controls.h | 2 ++ 3 files changed, 10 insertions(+)
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +6 -0
@@ -737,6 +737,12 @@ enum v4l2_mpeg_video_frame_skip_mode - Enable writing sample aspect ratio in the Video Usability Information. Applicable to the H264 encoder. +``V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION (boolean)`` + If enabled, the encoder detect a background region in frame and + use low bits or skip mode to encode the background region. + If a lot of scenes are stationary or background, It may help to + reduce the video bitrate. Applicable to the encoder. + .. _v4l2-mpeg-video-h264-vui-sar-idc: ``V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC``
drivers/media/v4l2-core/v4l2-ctrls-defs.c +2 -0
@@ -889,6 +889,7 @@ const char *v4l2_ctrl_get_name(u32 id)case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY :return "Display Delay" ;case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE :return "Display Delay Enable" ;case V4L2_CID_MPEG_VIDEO_AU_DELIMITER :return "Generate Access Unit Delimiters" ; +case V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION :return "Background Detection" ;case V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP :return "H263 I-Frame QP Value" ;case V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP :return "H263 P-Frame QP Value" ;case V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP :return "H263 B-Frame QP Value" ;
@@ -1296,6 +1297,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case V4L2_CID_MPEG_VIDEO_MPEG4_QPEL :case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER :case V4L2_CID_MPEG_VIDEO_AU_DELIMITER : +case V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION :case V4L2_CID_WIDE_DYNAMIC_RANGE :case V4L2_CID_IMAGE_STABILIZATION :case V4L2_CID_RDS_RECEPTION :
include/uapi/linux/v4l2-controls.h +2 -0
@@ -464,6 +464,8 @@ enum v4l2_mpeg_video_intra_refresh_period_type { V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_CYCLIC = 1, }; +#define V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION (V4L2_CID_CODEC_BASE + 238) +/* CIDs for the MPEG-2 Part 2 (H.262) codec */ #define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270)enum v4l2_mpeg_video_mpeg2_level {
Signature · 1 line
2.43.0
Re: [PATCH v1 1/4] media: v4l2-controls: Add control for background detection
Le mardi 24 mars 2026 à 14:03 +0900, Jackson.lee a écrit :
Quoted 9 lines
From: Jackson Lee <[email protected]>
Add a generic V4L2 boolean control
V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTIONthat allows encoders to detect background regions in a frame and use fewer bits or skip mode to encode them, potentially reducing bitrate for streams with stationary scenes.Signed-off-by Jackson Lee <[email protected]>Signed-off-by Nas Chung <[email protected]>
Quoted 69 lines
---
Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst | 6 ++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 ++ include/uapi/linux/v4l2-controls.h | 2 ++3 files changed, 10 insertions(+)Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +0
-0@@ -737,6 +737,12 @@ enum v4l2_mpeg_video_frame_skip_mode -Enable writing sample aspect ratio in the Video Usability Information. Applicable to the H264 encoder.
+``V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION (boolean)``
+ If enabled, the encoder detect a background region in frame and + use low bits or skip mode to encode the background region. + If a lot of scenes are stationary or background, It may help to + reduce the video bitrate. Applicable to the encoder. +
.. _v4l2-mpeg-video-h264-vui-sar-idc:
``V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC``drivers/media/v4l2- renamed from drivers/media/v4l2-core/v4l2-ctrls-defs.c +0
-0
core/v4l2-ctrls-defs.c
index551426c4cd01..e062f2088490100644drivers/media/v4l2-core/v4l2-ctrls-defs.c +0
-0@@ -889,6 +889,7 @@ const char *v4l2_ctrl_get_name(u32 id)case
V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY: return
"Display Delay";
caseV4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE: return
"Display Delay Enable";
caseV4L2_CID_MPEG_VIDEO_AU_DELIMITER: return
"Generate Access Unit Delimiters";drivers/media/v4l2-core/v4l2-ctrls-defs.c +1
-0+case V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION :return "Background Detection";
caseV4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP: return "H263
I-Frame QP Value";
caseV4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP: return "H263
P-Frame QP Value";
caseV4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP: return "H263
B-Frame QP Value";drivers/media/v4l2-core/v4l2-ctrls-defs.c +0
-0@@ -1296,6 +1297,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,case
V4L2_CID_MPEG_VIDEO_MPEG4_QPEL:
caseV4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER:
caseV4L2_CID_MPEG_VIDEO_AU_DELIMITER:drivers/media/v4l2-core/v4l2-ctrls-defs.c +1
-0+case V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION :case
V4L2_CID_WIDE_DYNAMIC_RANGE:
caseV4L2_CID_IMAGE_STABILIZATION:
caseV4L2_CID_RDS_RECEPTION:include/uapi/linux/v4l2- renamed from include/uapi/linux/v4l2-controls.h +0
-0
controls.h
index68dd0c4e47b2..affec0ab4781100644include/uapi/linux/v4l2-controls.h +0
-0@@ -464,6 +464,8 @@ enum v4l2_mpeg_video_intra_refresh_period_type { V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_CYCLIC = 1, };include/uapi/linux/v4l2-controls.h +3
-0+#define V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION (V4L2_CID_CODEC_BASE + 238) +/* CIDs for the MPEG-2 Part 2 (H.262) codec */
#defineV4L2_CID_MPEG_VIDEO_MPEG2_LEVEL(V4L2_CID_CODEC_BASE+270)
enumv4l2_mpeg_video_mpeg2_level{
Jackson.lee
maintainerPATCH 2/4 media: chips-media: wave5: Add support for background detection
In reply to Jackson.leeFrom: Jackson Lee <[email protected]>
Implement V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION in the Wave5 encoder driver. When enabled, the hardware detects background regions in a frame and uses fewer bits or skip mode to encode them, reducing bitrate for streams with stationary scenes.
--- drivers/media/platform/chips-media/wave5/wave5-hw.c | 4 +++- drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 7 +++++++ drivers/media/platform/chips-media/wave5/wave5-vpuapi.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-hw.c +3 -1
@@ -49,6 +49,7 @@#define FASTIO_ADDRESS_MASK GENMASK(15, 0)#define SEQ_PARAM_PROFILE_MASK GENMASK(30, 24) +#define SEQ_BG_PARAM_REG_DATA 0x3800410static void _wave5_print_reg_err (struct vpu_device *vpu_dev,u32 reg_fail_reason,const char *func);
@@ -1838,7 +1839,8 @@ int wave5_vpu_enc_init_seq(struct vpu_instance *inst)vpu_write_reg (inst->dev,W5_CMD_ENC_SEQ_RC_BIT_RATIO_LAYER_4_7 ,0 );vpu_write_reg (inst->dev,W5_CMD_ENC_SEQ_ROT_PARAM , rot_mir_mode); -vpu_write_reg (inst->dev,W5_CMD_ENC_SEQ_BG_PARAM ,0 ); +vpu_write_reg (inst->dev,W5_CMD_ENC_SEQ_BG_PARAM , +SEQ_BG_PARAM_REG_DATA | p_param->bg_detection);vpu_write_reg (inst->dev,W5_CMD_ENC_SEQ_CUSTOM_LAMBDA_ADDR ,0 );vpu_write_reg (inst->dev,W5_CMD_ENC_SEQ_CONF_WIN_TOP_BOT , p_param->conf_win_bot <<16 | p_param->conf_win_top);
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +7 -0
@@ -780,6 +780,9 @@ static int wave5_vpu_enc_s_ctrl(struct v4l2_ctrl *ctrl)case V4L2_CID_MPEG_VIDEO_BITRATE : inst->bit_rate = ctrl->val;break ; +case V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION : + inst->enc_param.bg_detection = ctrl->val; +break ;case V4L2_CID_MPEG_VIDEO_GOP_SIZE : inst->enc_param.avc_idr_period = ctrl->val;break ;
@@ -1205,6 +1208,7 @@ static int wave5_set_enc_openparam(struct enc_open_param *open_param, open_param->wave_param.beta_offset_div2 = input.beta_offset_div2; open_param->wave_param.decoding_refresh_type = input.decoding_refresh_type; open_param->wave_param.intra_period = input.intra_period; + open_param->wave_param.bg_detection = input.bg_detection;if (inst->std ==W_HEVC_ENC ) {if (input.intra_period ==0 ) { open_param->wave_param.decoding_refresh_type =DEC_REFRESH_TYPE_IDR ;
@@ -1700,6 +1704,9 @@ static int wave5_vpu_open_enc(struct file *filp)v4l2_ctrl_new_std (v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops,V4L2_CID_MPEG_VIDEO_AU_DELIMITER ,0 ,1 ,1 ,1 ); +v4l2_ctrl_new_std (v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops, +V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION , +0 ,1 ,1 ,0 );v4l2_ctrl_new_std (v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops,V4L2_CID_HFLIP ,0 ,1 ,1 ,0 );
drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +1 -0
@@ -570,6 +570,7 @@ struct enc_wave_param { u32 transform8x8_enable: 1; /* enable 8x8 intra prediction and 8x8 transform */ u32 mb_level_rc_enable: 1; /* enable MB-level rate control */ u32 forced_idr_header_enable: 1; /* enable header encoding before IDR frame */ + u32 bg_detection: 1; /* enable background detection */ };struct enc_open_param {
Signature · 1 line
2.43.0
Re: [PATCH v1 2/4] media: chips-media: wave5: Add support for background detection
Le mardi 24 mars 2026 à 14:03 +0900, Jackson.lee a écrit :
Quoted 9 lines
From: Jackson Lee <[email protected]>
Implement
V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTIONin the Wave5 encoder driver. When enabled, the hardware detects background regions in a frame and uses fewer bits or skip mode to encode them, reducing bitrate for streams with stationary scenes.Signed-off-by Jackson Lee <[email protected]>Signed-off-by Nas Chung <[email protected]>
Quoted 81 lines
---
drivers/media/platform/chips-media/wave5/wave5-hw.c | 4 +++-drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c| 7 +++++++ drivers/media/platform/chips-media/wave5/wave5-vpuapi.h | 1 +3 files changed, 11 insertions(+), 1 deletion(-)drivers/media/platform/chips-media/wave5/wave5-hw.c +0
-0@@ -49,6 +49,7 @@
#defineFASTIO_ADDRESS_MASKGENMASK(15, 0)
#defineSEQ_PARAM_PROFILE_MASKGENMASK(30, 24)
+#defineSEQ_BG_PARAM_REG_DATA0x3800410
static void _wave5_print_reg_err(structvpu_device*vpu_dev, u32reg_fail_reason,
const char *func);drivers/media/platform/chips-media/wave5/wave5-hw.c +0
-0@@ -1838,7 +1839,8 @@ int wave5_vpu_enc_init_seq(struct vpu_instance *inst) vpu_write_reg(inst->dev, W5_CMD_ENC_SEQ_RC_BIT_RATIO_LAYER_4_7, 0); vpu_write_reg(inst->dev, W5_CMD_ENC_SEQ_ROT_PARAM, rot_mir_mode);drivers/media/platform/chips-media/wave5/wave5-hw.c +2
-1-vpu_write_reg (inst->dev,W5_CMD_ENC_SEQ_BG_PARAM ,0 ); +vpu_write_reg (inst->dev,W5_CMD_ENC_SEQ_BG_PARAM , + SEQ_BG_PARAM_REG_DATA | p_param->bg_detection);
vpu_write_reg(inst->dev, W5_CMD_ENC_SEQ_CUSTOM_LAMBDA_ADDR, 0);vpu_write_reg(inst->dev, W5_CMD_ENC_SEQ_CONF_WIN_TOP_BOT, p_param->conf_win_bot << 16 | p_param->conf_win_top);drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +0
-0@@ -780,6 +780,9 @@ static int wave5_vpu_enc_s_ctrl(struct v4l2_ctrl *ctrl)case
V4L2_CID_MPEG_VIDEO_BITRATE:
inst->bit_rate=ctrl->val;
break;drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +3
-0+case V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION : + inst->enc_param.bg_detection = ctrl->val; +break ;case
V4L2_CID_MPEG_VIDEO_GOP_SIZE:
inst->enc_param.avc_idr_period=ctrl->val; break;drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +0
-0@@ -1205,6 +1208,7 @@ static int wave5_set_enc_openparam(struct enc_open_param *open_param, open_param->wave_param.beta_offset_div2 = input.beta_offset_div2;
open_param->wave_param.decoding_refresh_type= input.decoding_refresh_type;open_param->wave_param.intra_period= input.intra_period;drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +1
-0+ open_param->wave_param.bg_detection = input.bg_detection;if (
inst->std==W_HEVC_ENC) {
if (input.intra_period == 0) {open_param->wave_param.decoding_refresh_type=DEC_REFRESH_TYPE_IDR;drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +3
-0@@ -1700,6 +1704,9 @@ static int wave5_vpu_open_enc(struct file *filp) v4l2_ctrl_new_std(v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops, V4L2_CID_MPEG_VIDEO_AU_DELIMITER, 0, 1, 1, 1); +v4l2_ctrl_new_std (v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_BACKGROUND_DETECTION, + 0, 1, 1, 0); v4l2_ctrl_new_std(v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0);drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +0
-0@@ -570,6 +570,7 @@ struct enc_wave_param {u32
transform8x8_enable: 1; /* enable 8x8 intra prediction and 8x8 transform */
u32mb_level_rc_enable: 1; /* enable MB-level rate control */ u32forced_idr_header_enable: 1; /* enable header encoding before IDR frame */drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +1
-0+ u32 bg_detection: 1; /* enable background detection */};
structenc_open_param{
Jackson.lee
maintainerPATCH 3/4 media: chips-media: wave5: Support CBP profile
In reply to Jackson.leeFrom: Jackson Lee <[email protected]>
Constrained Baseline Profile (CBP) and Baseline Profile (BP) have been treated as the same.
Introduce the ability to differentiate between the two.
--- drivers/media/platform/chips-media/wave5/wave5-hw.c | 3 +++ drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 5 ++++- drivers/media/platform/chips-media/wave5/wave5-vpuapi.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-hw.c +3 -0
@@ -1763,6 +1763,9 @@ int wave5_vpu_enc_init_seq(struct vpu_instance *inst) (p_param->skip_intra_trans <<25 ) | (p_param->strong_intra_smooth_enable <<27 ) | (p_param->en_still_picture <<30 ); + else if (inst->std == W_AVC_ENC) + reg_val |= (p_param->constraint_set1_flag << 29); +vpu_write_reg (inst->dev,W5_CMD_ENC_SEQ_SPS_PARAM , reg_val); reg_val = (p_param->lossless_enable) |
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +4 -1
@@ -939,6 +939,8 @@ static int wave5_vpu_enc_s_ctrl(struct v4l2_ctrl *ctrl)case V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE : inst->enc_param.profile =H264_PROFILE_BP ; inst->bit_depth =8 ; +if (ctrl->val ==V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE ) + inst->enc_param.constraint_set1_flag =1 ;break ;case V4L2_MPEG_VIDEO_H264_PROFILE_MAIN : inst->enc_param.profile =H264_PROFILE_MP ;
@@ -1215,6 +1217,7 @@ static int wave5_set_enc_openparam(struct enc_open_param *open_param, open_param->wave_param.intra_period = input.avc_idr_period; } }else { + open_param->wave_param.constraint_set1_flag = input.constraint_set1_flag; open_param->wave_param.avc_idr_period = input.avc_idr_period; } open_param->wave_param.entropy_coding_mode = input.entropy_coding_mode;
@@ -1687,7 +1690,7 @@ static int wave5_vpu_open_enc(struct file *filp) -6, 6, 1, 0);v4l2_ctrl_new_std (v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops,V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM , -0 ,1 ,1 ,1 ); +0 ,1 ,1 ,0 );v4l2_ctrl_new_std (v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops,V4L2_CID_MPEG_VIDEO_H264_CONSTRAINED_INTRA_PREDICTION ,0 ,1 ,1 ,0 );
drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +1 -0
@@ -570,6 +570,7 @@ struct enc_wave_param { u32 transform8x8_enable: 1; /* enable 8x8 intra prediction and 8x8 transform */ u32 mb_level_rc_enable: 1; /* enable MB-level rate control */ u32 forced_idr_header_enable: 1; /* enable header encoding before IDR frame */ + u32 constraint_set1_flag: 1; /* enable CBP */ u32 bg_detection: 1; /* enable background detection */ };
Signature · 1 line
2.43.0
Re: [PATCH v1 3/4] media: chips-media: wave5: Support CBP profile
Hi Jackson,
Quoted 43 lines · Jackson.lee
From: Jackson Lee <[email protected]>
Constrained Baseline Profile (CBP) and Baseline Profile (BP) have been treated as the same.
Introduce the ability to differentiate between the two.Fixes 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")Signed-off-by Jackson Lee <[email protected]>Signed-off-by Nas Chung <[email protected]>--- drivers/media/platform/chips-media/wave5/wave5-hw.c | 3 +++ drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 5 ++++- drivers/media/platform/chips-media/wave5/wave5-vpuapi.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-)drivers/media/platform/chips-media/wave5/wave5-hw.c +3
-0@@ -1763,6 +1763,9 @@ int wave5_vpu_enc_init_seq(struct vpu_instance *inst) (p_param->skip_intra_trans <<25 ) | (p_param->strong_intra_smooth_enable <<27 ) | (p_param->en_still_picture <<30 ); + else if (inst->std == W_AVC_ENC) + reg_val |= (p_param->constraint_set1_flag << 29); +vpu_write_reg (inst->dev,W5_CMD_ENC_SEQ_SPS_PARAM , reg_val); reg_val = (p_param->lossless_enable) |drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +2
-0@@ -939,6 +939,8 @@ static int wave5_vpu_enc_s_ctrl(struct v4l2_ctrl *ctrl)case V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE : inst->enc_param.profile =H264_PROFILE_BP ; inst->bit_depth =8 ; +if (ctrl->val ==V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE ) + inst->enc_param.constraint_set1_flag =1 ;break ;case V4L2_MPEG_VIDEO_H264_PROFILE_MAIN : inst->enc_param.profile =H264_PROFILE_MP ;
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c static int wave5_set_enc_openparam(struct enc_open_param *open_param, · line 1222
Quoted 6 lines
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +1
-0@@ -1215,6 +1217,7 @@ static int wave5_set_enc_openparam(struct enc_open_param *open_param, open_param->wave_param.intra_period = input.avc_idr_period; } }else { + open_param->wave_param.constraint_set1_flag = input.constraint_set1_flag; open_param->wave_param.avc_idr_period = input.avc_idr_period; }
Thank you for fixing. Setting GOP and CBP work for me now.
Quoted 22 lines
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +1
-1open_param->wave_param.entropy_coding_mode = input.entropy_coding_mode;@@ -1687,7 +1690,7 @@ static int wave5_vpu_open_enc(struct file *filp) -6, 6, 1, 0);v4l2_ctrl_new_std (v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops,V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM , -0 ,1 ,1 ,1 ); +0 ,1 ,1 ,0 );v4l2_ctrl_new_std (v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops,V4L2_CID_MPEG_VIDEO_H264_CONSTRAINED_INTRA_PREDICTION ,0 ,1 ,1 ,0 );drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +1
-0@@ -570,6 +570,7 @@ struct enc_wave_param { u32 transform8x8_enable: 1; /* enable 8x8 intra prediction and 8x8 transform */ u32 mb_level_rc_enable: 1; /* enable MB-level rate control */ u32 forced_idr_header_enable: 1; /* enable header encoding before IDR frame */ + u32 constraint_set1_flag: 1; /* enable CBP */ u32 bg_detection: 1; /* enable background detection */ };
Re: [PATCH v1 3/4] media: chips-media: wave5: Support CBP profile
In reply to Jackson.leeLe mardi 24 mars 2026 à 14:03 +0900, Jackson.lee a écrit :
Quoted 9 lines
From: Jackson Lee <[email protected]>
Constrained Baseline Profile (CBP) and Baseline Profile (BP) have been treated as the same.
Introduce the ability to differentiate between the two.Fixes 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")Signed-off-by Jackson Lee <[email protected]>Signed-off-by Nas Chung <[email protected]>
Quoted 62 lines
---
drivers/media/platform/chips-media/wave5/wave5-hw.c | 3 +++drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c| 5 ++++- drivers/media/platform/chips-media/wave5/wave5-vpuapi.h | 1 +3 files changed, 8 insertions(+), 1 deletion(-)drivers/media/platform/chips-media/wave5/wave5-hw.c +0
-0@@ -1763,6 +1763,9 @@ int wave5_vpu_enc_init_seq(struct vpu_instance *inst)(
p_param->skip_intra_trans<< 25) | (p_param->strong_intra_smooth_enable<< 27) | (p_param->en_still_picture<< 30);drivers/media/platform/chips-media/wave5/wave5-hw.c +3
-0+else if (inst->std ==W_AVC_ENC ) + reg_val |= (p_param->constraint_set1_flag <<29 ); +
vpu_write_reg(inst->dev, W5_CMD_ENC_SEQ_SPS_PARAM, reg_val);
reg_val= (p_param->lossless_enable) |drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +0
-0@@ -939,6 +939,8 @@ static int wave5_vpu_enc_s_ctrl(struct v4l2_ctrl *ctrl)case
V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE:
inst->enc_param.profile=H264_PROFILE_BP;inst->bit_depth= 8;drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +2
-0+if (ctrl->val ==V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE ) + inst->enc_param.constraint_set1_flag =1 ;break;
caseV4L2_MPEG_VIDEO_H264_PROFILE_MAIN:
inst->enc_param.profile=H264_PROFILE_MP;drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +2
-1@@ -1215,6 +1217,7 @@ static int wave5_set_enc_openparam(struct enc_open_param *open_param, open_param->wave_param.intra_period = input.avc_idr_period; } } else { + open_param->wave_param.constraint_set1_flag = input.constraint_set1_flag; open_param->wave_param.avc_idr_period = input.avc_idr_period; } open_param->wave_param.entropy_coding_mode = input.entropy_coding_mode;@@ -1687,7 +1690,7 @@ static int wave5_vpu_open_enc(struct file *filp) -6, 6, 1, 0); v4l2_ctrl_new_std(v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops, V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM, - 0, 1, 1, 1); + 0, 1, 1, 0); v4l2_ctrl_new_std(v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops, V4L2_CID_MPEG_VIDEO_H264_CONSTRAINED_INTRA_PREDICTION, 0, 1, 1, 0);drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +0
-0@@ -570,6 +570,7 @@ struct enc_wave_param {u32
transform8x8_enable: 1; /* enable 8x8 intra prediction and 8x8 transform */ u32mb_level_rc_enable: 1; /* enable MB-level rate control */
u32forced_idr_header_enable: 1; /* enable header encoding before IDR frame */drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +1
-0+ u32 constraint_set1_flag: 1; /* enable CBP */u32
bg_detection: 1; /* enable background detection */ };
Jackson.lee
maintainerPATCH 4/4 media: chips-media: wave5: Add Support for Packed YUV422 Formats
In reply to Jackson.leeFrom: Jackson Lee <[email protected]>
Wave5 encoder is capable of reading in numerous raw pixel formats. Expose these formats and properly configure encoder if selected.
--- .../platform/chips-media/wave5/wave5-helper.h | 2 +- .../chips-media/wave5/wave5-vpu-enc.c | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-helper.h +1 -1
@@ -11,7 +11,7 @@#include "wave5-vpu.h" #define FMT_TYPES 2 -#define MAX_FMTS 12 +#define MAX_FMTS 16const char *state_to_str (enum vpu_instance_state state);void wave5_cleanup_instance (struct vpu_instance *inst,struct file *filp);
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +32 -0
@@ -90,6 +90,22 @@ static const struct vpu_format enc_fmt_list[FMT_TYPES][MAX_FMTS] = { .v4l2_pix_fmt = V4L2_PIX_FMT_NV61M, .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_YUYV, + .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_YVYU, + .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_UYVY, + .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_VYUY, + .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], + }, } };
@@ -1161,6 +1177,22 @@ static int wave5_set_enc_openparam(struct enc_open_param *open_param,else open_param->src_format =FORMAT_420 ; +switch (info->format) { +case V4L2_PIX_FMT_YUYV : + open_param->packed_format =PACKED_YUYV ; +break ; +case V4L2_PIX_FMT_YVYU : + open_param->packed_format =PACKED_YVYU ; +break ; +case V4L2_PIX_FMT_UYVY : + open_param->packed_format =PACKED_UYVY ; +break ; +case V4L2_PIX_FMT_VYUY : + open_param->packed_format =PACKED_VYUY ; +break ; +default : +break ; + } open_param->wave_param.gop_preset_idx =PRESET_IDX_IPP_SINGLE ; open_param->wave_param.hvs_qp_scale =2 ; open_param->wave_param.hvs_max_delta_qp =10 ;
Signature · 1 line
2.43.0
Re: [PATCH v1 4/4] media: chips-media: wave5: Add Support for Packed YUV422 Formats
Hi Jackson
Quoted 8 lines · Jackson.lee
From: Jackson Lee <[email protected]>
Wave5 encoder is capable of reading in numerous raw pixel formats. Expose these formats and properly configure encoder if selected.
Signed-off-by Jackson Lee <[email protected]>Signed-off-by Nas Chung <[email protected]>Reviewed-by Nicolas Dufresne <[email protected]>
Even though this already has Nicolas's review, wanted to add my tested by as I have validated this with latest kernel and gstreamer version 1.26.9. Encoder is properly reading these raw formats!
Quoted 68 lines
--- .../platform/chips-media/wave5/wave5-helper.h | 2 +- .../chips-media/wave5/wave5-vpu-enc.c | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-)drivers/media/platform/chips-media/wave5/wave5-helper.h +1
-1@@ -11,7 +11,7 @@#include "wave5-vpu.h" #define FMT_TYPES 2 -#define MAX_FMTS 12 +#define MAX_FMTS 16const char *state_to_str (enum vpu_instance_state state);void wave5_cleanup_instance (struct vpu_instance *inst,struct file *filp);drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +32
-0@@ -90,6 +90,22 @@ static const struct vpu_format enc_fmt_list[FMT_TYPES][MAX_FMTS] = { .v4l2_pix_fmt = V4L2_PIX_FMT_NV61M, .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_YUYV, + .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_YVYU, + .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_UYVY, + .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_VYUY, + .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], + }, } };@@ -1161,6 +1177,22 @@ static int wave5_set_enc_openparam(struct enc_open_param *open_param,else open_param->src_format =FORMAT_420 ; +switch (info->format) { +case V4L2_PIX_FMT_YUYV : + open_param->packed_format =PACKED_YUYV ; +break ; +case V4L2_PIX_FMT_YVYU : + open_param->packed_format =PACKED_YVYU ; +break ; +case V4L2_PIX_FMT_UYVY : + open_param->packed_format =PACKED_UYVY ; +break ; +case V4L2_PIX_FMT_VYUY : + open_param->packed_format =PACKED_VYUY ; +break ; +default : +break ; + } open_param->wave_param.gop_preset_idx =PRESET_IDX_IPP_SINGLE ; open_param->wave_param.hvs_qp_scale =2 ; open_param->wave_param.hvs_max_delta_qp =10 ;