Commit 7f046e4b authored by Michael Tretter's avatar Michael Tretter Committed by Mauro Carvalho Chehab

media: allegro: remove cpb_size and gop_size from channel

The cpb_size and the gop_size are straight copies of the values in the
v4l2-ctrls. To avoid this duplication, directly get the values from the
v4l2-ctrls and remove the copies.
Signed-off-by: default avatarMichael Tretter <m.tretter@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent d4a881c1
...@@ -203,8 +203,6 @@ struct allegro_channel { ...@@ -203,8 +203,6 @@ struct allegro_channel {
bool frame_rc_enable; bool frame_rc_enable;
unsigned int bitrate; unsigned int bitrate;
unsigned int bitrate_peak; unsigned int bitrate_peak;
unsigned int cpb_size;
unsigned int gop_size;
struct allegro_buffer config_blob; struct allegro_buffer config_blob;
...@@ -925,6 +923,7 @@ static int fill_create_channel_param(struct allegro_channel *channel, ...@@ -925,6 +923,7 @@ static int fill_create_channel_param(struct allegro_channel *channel,
int p_frame_qp = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_p_frame_qp); int p_frame_qp = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_p_frame_qp);
int b_frame_qp = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_b_frame_qp); int b_frame_qp = v4l2_ctrl_g_ctrl(channel->mpeg_video_h264_b_frame_qp);
int bitrate_mode = v4l2_ctrl_g_ctrl(channel->mpeg_video_bitrate_mode); int bitrate_mode = v4l2_ctrl_g_ctrl(channel->mpeg_video_bitrate_mode);
unsigned int cpb_size = v4l2_ctrl_g_ctrl(channel->mpeg_video_cpb_size);
param->width = channel->width; param->width = channel->width;
param->height = channel->height; param->height = channel->height;
...@@ -972,8 +971,7 @@ static int fill_create_channel_param(struct allegro_channel *channel, ...@@ -972,8 +971,7 @@ static int fill_create_channel_param(struct allegro_channel *channel,
param->rate_control_mode = channel->frame_rc_enable ? param->rate_control_mode = channel->frame_rc_enable ?
v4l2_bitrate_mode_to_mcu_mode(bitrate_mode) : 0; v4l2_bitrate_mode_to_mcu_mode(bitrate_mode) : 0;
param->cpb_size = v4l2_cpb_size_to_mcu(channel->cpb_size, param->cpb_size = v4l2_cpb_size_to_mcu(cpb_size, channel->bitrate_peak);
channel->bitrate_peak);
/* Shall be ]0;cpb_size in 90 kHz units]. Use maximum value. */ /* Shall be ]0;cpb_size in 90 kHz units]. Use maximum value. */
param->initial_rem_delay = param->cpb_size; param->initial_rem_delay = param->cpb_size;
param->framerate = DIV_ROUND_UP(channel->framerate.numerator, param->framerate = DIV_ROUND_UP(channel->framerate.numerator,
...@@ -996,10 +994,10 @@ static int fill_create_channel_param(struct allegro_channel *channel, ...@@ -996,10 +994,10 @@ static int fill_create_channel_param(struct allegro_channel *channel,
param->max_pixel_value = 255; param->max_pixel_value = 255;
param->gop_ctrl_mode = 0x00000002; param->gop_ctrl_mode = 0x00000002;
param->freq_idr = channel->gop_size; param->freq_idr = v4l2_ctrl_g_ctrl(channel->mpeg_video_gop_size);
param->freq_lt = 0; param->freq_lt = 0;
param->gdr_mode = 0x00000000; param->gdr_mode = 0x00000000;
param->gop_length = channel->gop_size; param->gop_length = v4l2_ctrl_g_ctrl(channel->mpeg_video_gop_size);
param->subframe_latency = 0x00000000; param->subframe_latency = 0x00000000;
param->lda_factors[0] = 51; param->lda_factors[0] = 51;
...@@ -1342,7 +1340,7 @@ static ssize_t allegro_h264_write_sps(struct allegro_channel *channel, ...@@ -1342,7 +1340,7 @@ static ssize_t allegro_h264_write_sps(struct allegro_channel *channel,
sps->vui.vcl_hrd_parameters.bit_rate_value_minus1[0] = sps->vui.vcl_hrd_parameters.bit_rate_value_minus1[0] =
channel->bitrate_peak / (1 << (6 + sps->vui.vcl_hrd_parameters.bit_rate_scale)) - 1; channel->bitrate_peak / (1 << (6 + sps->vui.vcl_hrd_parameters.bit_rate_scale)) - 1;
/* See Rec. ITU-T H.264 (04/2017) p. 410 E-54 */ /* See Rec. ITU-T H.264 (04/2017) p. 410 E-54 */
cpb_size = channel->cpb_size; cpb_size = v4l2_ctrl_g_ctrl(channel->mpeg_video_cpb_size);
cpb_size_scale = ffs(cpb_size) - 4; cpb_size_scale = ffs(cpb_size) - 4;
sps->vui.vcl_hrd_parameters.cpb_size_scale = cpb_size_scale; sps->vui.vcl_hrd_parameters.cpb_size_scale = cpb_size_scale;
sps->vui.vcl_hrd_parameters.cpb_size_value_minus1[0] = sps->vui.vcl_hrd_parameters.cpb_size_value_minus1[0] =
...@@ -2135,9 +2133,6 @@ static void allegro_set_default_params(struct allegro_channel *channel) ...@@ -2135,9 +2133,6 @@ static void allegro_set_default_params(struct allegro_channel *channel)
channel->profile = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE; channel->profile = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE;
channel->level = channel->level =
select_minimum_h264_level(channel->width, channel->height); select_minimum_h264_level(channel->width, channel->height);
channel->cpb_size = maximum_cpb_size(channel->level);
channel->gop_size = ALLEGRO_GOP_SIZE_DEFAULT;
} }
static int allegro_queue_setup(struct vb2_queue *vq, static int allegro_queue_setup(struct vb2_queue *vq,
...@@ -2394,12 +2389,6 @@ static int allegro_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -2394,12 +2389,6 @@ static int allegro_s_ctrl(struct v4l2_ctrl *ctrl)
v4l2_ctrl_activate(channel->mpeg_video_bitrate_peak, v4l2_ctrl_activate(channel->mpeg_video_bitrate_peak,
ctrl->val == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); ctrl->val == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR);
break; break;
case V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE:
channel->cpb_size = ctrl->val;
break;
case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
channel->gop_size = ctrl->val;
break;
case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP: case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP:
case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP: case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP:
case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP: case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP:
...@@ -2425,6 +2414,8 @@ static int allegro_open(struct file *file) ...@@ -2425,6 +2414,8 @@ static int allegro_open(struct file *file)
int ret; int ret;
unsigned int bitrate_max; unsigned int bitrate_max;
unsigned int bitrate_def; unsigned int bitrate_def;
unsigned int cpb_size_max;
unsigned int cpb_size_def;
channel = kzalloc(sizeof(*channel), GFP_KERNEL); channel = kzalloc(sizeof(*channel), GFP_KERNEL);
if (!channel) if (!channel)
...@@ -2493,6 +2484,8 @@ static int allegro_open(struct file *file) ...@@ -2493,6 +2484,8 @@ static int allegro_open(struct file *file)
bitrate_max = maximum_bitrate(V4L2_MPEG_VIDEO_H264_LEVEL_5_1); bitrate_max = maximum_bitrate(V4L2_MPEG_VIDEO_H264_LEVEL_5_1);
bitrate_def = maximum_bitrate(V4L2_MPEG_VIDEO_H264_LEVEL_5_1); bitrate_def = maximum_bitrate(V4L2_MPEG_VIDEO_H264_LEVEL_5_1);
cpb_size_max = maximum_cpb_size(V4L2_MPEG_VIDEO_H264_LEVEL_5_1);
cpb_size_def = maximum_cpb_size(V4L2_MPEG_VIDEO_H264_LEVEL_5_1);
channel->mpeg_video_bitrate = v4l2_ctrl_new_std(handler, channel->mpeg_video_bitrate = v4l2_ctrl_new_std(handler,
&allegro_ctrl_ops, &allegro_ctrl_ops,
V4L2_CID_MPEG_VIDEO_BITRATE, V4L2_CID_MPEG_VIDEO_BITRATE,
...@@ -2504,13 +2497,12 @@ static int allegro_open(struct file *file) ...@@ -2504,13 +2497,12 @@ static int allegro_open(struct file *file)
channel->mpeg_video_cpb_size = v4l2_ctrl_new_std(handler, channel->mpeg_video_cpb_size = v4l2_ctrl_new_std(handler,
&allegro_ctrl_ops, &allegro_ctrl_ops,
V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE, V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE,
0, maximum_cpb_size(V4L2_MPEG_VIDEO_H264_LEVEL_5_1), 0, cpb_size_max, 1, cpb_size_def);
1, channel->cpb_size);
channel->mpeg_video_gop_size = v4l2_ctrl_new_std(handler, channel->mpeg_video_gop_size = v4l2_ctrl_new_std(handler,
&allegro_ctrl_ops, &allegro_ctrl_ops,
V4L2_CID_MPEG_VIDEO_GOP_SIZE, V4L2_CID_MPEG_VIDEO_GOP_SIZE,
0, ALLEGRO_GOP_SIZE_MAX, 0, ALLEGRO_GOP_SIZE_MAX,
1, channel->gop_size); 1, ALLEGRO_GOP_SIZE_DEFAULT);
v4l2_ctrl_new_std(handler, v4l2_ctrl_new_std(handler,
&allegro_ctrl_ops, &allegro_ctrl_ops,
V4L2_CID_MIN_BUFFERS_FOR_OUTPUT, V4L2_CID_MIN_BUFFERS_FOR_OUTPUT,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment