History

media: allegro: add control to disable encoder buffer

The encoder buffer can have a negative impact on the quality of the encoded video. Add a control to allow user space to disable the encoder buffer per channel if the VCU supports the encoder buffer but the quality is not sufficient.

Michael Tretter committed 5 years ago

Commit 7aea2c01 parent 98f1cbf2 files · +35 −2Browse files

Unified · Split

2 files
  1. drivers/media/platform/allegro-dvt/allegro-core.c +30 −2
  2. include/uapi/linux/v4l2-controls.h +5 −0
drivers/media/platform/allegro-dvt/allegro-core.c+30−2
@@ -105,6 +105,12 @@ · 104 unmodified lines
105#define BETA_OFFSET_DIV_2 -1105#define BETA_OFFSET_DIV_2 -1
106#define TC_OFFSET_DIV_2 -1106#define TC_OFFSET_DIV_2 -1
107 107
108/*
109 * This control allows applications to explicitly disable the encoder buffer.
110 * This value is Allegro specific.
111 */
112#define V4L2_CID_USER_ALLEGRO_ENCODER_BUFFER (V4L2_CID_USER_ALLEGRO_BASE + 0)
113
108static int debug;114static int debug;
109module_param(debug, int, 0644);115module_param(debug, int, 0644);
110MODULE_PARM_DESC(debug, "Debug level (0-2)");116MODULE_PARM_DESC(debug, "Debug level (0-2)");
@@ -275,6 +281,8 @@ struct allegro_channel { · 164 unmodified lines
275 struct v4l2_ctrl *mpeg_video_cpb_size;281 struct v4l2_ctrl *mpeg_video_cpb_size;
276 struct v4l2_ctrl *mpeg_video_gop_size;282 struct v4l2_ctrl *mpeg_video_gop_size;
277 283
284 struct v4l2_ctrl *encoder_buffer;
285
278 /* user_id is used to identify the channel during CREATE_CHANNEL */286 /* user_id is used to identify the channel during CREATE_CHANNEL */
279 /* not sure, what to set here and if this is actually required */287 /* not sure, what to set here and if this is actually required */
280 int user_id;288 int user_id;
@@ -1255,7 +1263,7 @@ static int fill_create_channel_param(struct allegro_channel *channel, · 974 unmodified lines
1255 param->max_transfo_depth_intra = channel->max_transfo_depth_intra;1263 param->max_transfo_depth_intra = channel->max_transfo_depth_intra;
1256 param->max_transfo_depth_inter = channel->max_transfo_depth_inter;1264 param->max_transfo_depth_inter = channel->max_transfo_depth_inter;
1257 1265
1258 param->encoder_buffer_enabled = channel->dev->has_encoder_buffer;1266 param->encoder_buffer_enabled = v4l2_ctrl_g_ctrl(channel->encoder_buffer);
1259 param->encoder_buffer_offset = 0;1267 param->encoder_buffer_offset = 0;
1260 1268
1261 param->rate_control_mode = channel->frame_rc_enable ?1269 param->rate_control_mode = channel->frame_rc_enable ?
@@ -1381,7 +1389,7 @@ static int allegro_mcu_send_encode_frame(struct allegro_dev *dev, · 119 unmodified lines
1381 u64 src_handle)1389 u64 src_handle)
1382{1390{
1383 struct mcu_msg_encode_frame msg;1391 struct mcu_msg_encode_frame msg;
1384 bool use_encoder_buffer = channel->dev->has_encoder_buffer;1392 bool use_encoder_buffer = v4l2_ctrl_g_ctrl(channel->encoder_buffer);
1385 1393
1386 memset(&msg, 0, sizeof(msg));1394 memset(&msg, 0, sizeof(msg));
1387 1395
@@ -2466,6 +2474,8 @@ static void allegro_destroy_channel(struct allegro_channel *channel) · 1078 unmodified lines
2466 v4l2_ctrl_grab(channel->mpeg_video_cpb_size, false);2474 v4l2_ctrl_grab(channel->mpeg_video_cpb_size, false);
2467 v4l2_ctrl_grab(channel->mpeg_video_gop_size, false);2475 v4l2_ctrl_grab(channel->mpeg_video_gop_size, false);
2468 2476
2477 v4l2_ctrl_grab(channel->encoder_buffer, false);
2478
2469 if (channel->user_id != -1) {2479 if (channel->user_id != -1) {
2470 clear_bit(channel->user_id, &dev->channel_user_ids);2480 clear_bit(channel->user_id, &dev->channel_user_ids);
2471 channel->user_id = -1;2481 channel->user_id = -1;
@@ -2532,6 +2542,8 @@ static int allegro_create_channel(struct allegro_channel *channel) · 60 unmodified lines
2532 v4l2_ctrl_grab(channel->mpeg_video_cpb_size, true);2542 v4l2_ctrl_grab(channel->mpeg_video_cpb_size, true);
2533 v4l2_ctrl_grab(channel->mpeg_video_gop_size, true);2543 v4l2_ctrl_grab(channel->mpeg_video_gop_size, true);
2534 2544
2545 v4l2_ctrl_grab(channel->encoder_buffer, true);
2546
2535 reinit_completion(&channel->completion);2547 reinit_completion(&channel->completion);
2536 allegro_mcu_send_create_channel(dev, channel);2548 allegro_mcu_send_create_channel(dev, channel);
2537 timeout = wait_for_completion_timeout(&channel->completion,2549 timeout = wait_for_completion_timeout(&channel->completion,
@@ -2915,6 +2927,10 @@ static int allegro_try_ctrl(struct v4l2_ctrl *ctrl) · 377 unmodified lines
2915 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:2927 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
2916 allegro_clamp_bitrate(channel, ctrl);2928 allegro_clamp_bitrate(channel, ctrl);
2917 break;2929 break;
2930 case V4L2_CID_USER_ALLEGRO_ENCODER_BUFFER:
2931 if (!channel->dev->has_encoder_buffer)
2932 ctrl->val = 0;
2933 break;
2918 }2934 }
2919 2935
2920 return 0;2936 return 0;
@@ -2955,6 +2971,16 @@ static const struct v4l2_ctrl_ops allegro_ctrl_ops = { · 34 unmodified lines
2955 .s_ctrl = allegro_s_ctrl,2971 .s_ctrl = allegro_s_ctrl,
2956};2972};
2957 2973
2974static const struct v4l2_ctrl_config allegro_encoder_buffer_ctrl_config = {
2975 .id = V4L2_CID_USER_ALLEGRO_ENCODER_BUFFER,
2976 .name = "Encoder Buffer Enable",
2977 .type = V4L2_CTRL_TYPE_BOOLEAN,
2978 .min = 0,
2979 .max = 1,
2980 .step = 1,
2981 .def = 1,
2982};
2983
2958static int allegro_open(struct file *file)2984static int allegro_open(struct file *file)
2959{2985{
2960 struct video_device *vdev = video_devdata(file);2986 struct video_device *vdev = video_devdata(file);
@@ -3106,6 +3132,8 @@ static int allegro_open(struct file *file) · 145 unmodified lines
3106 V4L2_CID_MPEG_VIDEO_GOP_SIZE,3132 V4L2_CID_MPEG_VIDEO_GOP_SIZE,
3107 0, ALLEGRO_GOP_SIZE_MAX,3133 0, ALLEGRO_GOP_SIZE_MAX,
3108 1, ALLEGRO_GOP_SIZE_DEFAULT);3134 1, ALLEGRO_GOP_SIZE_DEFAULT);
3135 channel->encoder_buffer = v4l2_ctrl_new_custom(handler,
3136 &allegro_encoder_buffer_ctrl_config, NULL);
3109 v4l2_ctrl_new_std(handler,3137 v4l2_ctrl_new_std(handler,
3110 &allegro_ctrl_ops,3138 &allegro_ctrl_ops,
3111 V4L2_CID_MIN_BUFFERS_FOR_OUTPUT,3139 V4L2_CID_MIN_BUFFERS_FOR_OUTPUT,
include/uapi/linux/v4l2-controls.h+5−0
@@ -211,6 +211,11 @@ enum v4l2_colorfx { · 210 unmodified lines
211 * We reserve 128 controls for this driver.211 * We reserve 128 controls for this driver.
212 */212 */
213#define V4L2_CID_USER_CCS_BASE (V4L2_CID_USER_BASE + 0x10f0)213#define V4L2_CID_USER_CCS_BASE (V4L2_CID_USER_BASE + 0x10f0)
214/*
215 * The base for Allegro driver controls.
216 * We reserve 16 controls for this driver.
217 */
218#define V4L2_CID_USER_ALLEGRO_BASE (V4L2_CID_USER_BASE + 0x1170)
214 219
215/* MPEG-class control IDs */220/* MPEG-class control IDs */
216/* The MPEG controls are applicable to all codec controls221/* The MPEG controls are applicable to all codec controls

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t