Lines Matching full:venc

179 	struct venc_t *venc = inst->priv;  in venc_g_fmt()  local
197 f->fmt.pix_mp.colorspace = venc->params.color.primaries; in venc_g_fmt()
198 f->fmt.pix_mp.xfer_func = venc->params.color.transfer; in venc_g_fmt()
199 f->fmt.pix_mp.ycbcr_enc = venc->params.color.matrix; in venc_g_fmt()
200 f->fmt.pix_mp.quantization = venc->params.color.full_range; in venc_g_fmt()
221 struct venc_t *venc = inst->priv; in venc_s_fmt() local
238 venc->params.input_format = cur_fmt->pixfmt; in venc_s_fmt()
239 venc->params.src_stride = cur_fmt->bytesperline[0]; in venc_s_fmt()
240 venc->params.src_width = cur_fmt->width; in venc_s_fmt()
241 venc->params.src_height = cur_fmt->height; in venc_s_fmt()
242 venc->params.crop.left = 0; in venc_s_fmt()
243 venc->params.crop.top = 0; in venc_s_fmt()
244 venc->params.crop.width = cur_fmt->width; in venc_s_fmt()
245 venc->params.crop.height = cur_fmt->height; in venc_s_fmt()
247 venc->params.codec_format = cur_fmt->pixfmt; in venc_s_fmt()
248 venc->params.out_width = cur_fmt->width; in venc_s_fmt()
249 venc->params.out_height = cur_fmt->height; in venc_s_fmt()
253 venc->params.color.primaries = pix_mp->colorspace; in venc_s_fmt()
254 venc->params.color.transfer = pix_mp->xfer_func; in venc_s_fmt()
255 venc->params.color.matrix = pix_mp->ycbcr_enc; in venc_s_fmt()
256 venc->params.color.full_range = pix_mp->quantization; in venc_s_fmt()
259 pix_mp->colorspace = venc->params.color.primaries; in venc_s_fmt()
260 pix_mp->xfer_func = venc->params.color.transfer; in venc_s_fmt()
261 pix_mp->ycbcr_enc = venc->params.color.matrix; in venc_s_fmt()
262 pix_mp->quantization = venc->params.color.full_range; in venc_s_fmt()
270 struct venc_t *venc = inst->priv; in venc_g_parm() local
285 timeperframe->numerator = venc->params.frame_rate.numerator; in venc_g_parm()
286 timeperframe->denominator = venc->params.frame_rate.denominator; in venc_g_parm()
294 struct venc_t *venc = inst->priv; in venc_s_parm() local
309 timeperframe->numerator = venc->params.frame_rate.numerator; in venc_s_parm()
311 timeperframe->denominator = venc->params.frame_rate.denominator; in venc_s_parm()
313 venc->params.frame_rate.numerator = timeperframe->numerator; in venc_s_parm()
314 venc->params.frame_rate.denominator = timeperframe->denominator; in venc_s_parm()
316 rational_best_approximation(venc->params.frame_rate.numerator, in venc_s_parm()
317 venc->params.frame_rate.denominator, in venc_s_parm()
318 venc->params.frame_rate.numerator, in venc_s_parm()
319 venc->params.frame_rate.denominator, in venc_s_parm()
321 venc->params.frame_rate.numerator = n; in venc_s_parm()
322 venc->params.frame_rate.denominator = d; in venc_s_parm()
333 struct venc_t *venc = inst->priv; in venc_g_selection() local
347 s->r = venc->params.crop; in venc_g_selection()
356 static int venc_valid_crop(struct venc_t *venc, const struct vpu_core_resources *res) in venc_valid_crop() argument
364 rect = &venc->params.crop; in venc_valid_crop()
367 src_width = venc->params.src_width; in venc_valid_crop()
368 src_height = venc->params.src_height; in venc_valid_crop()
388 struct venc_t *venc = inst->priv; in venc_s_selection() local
399 venc->params.crop.left = ALIGN(s->r.left, res->step_width); in venc_s_selection()
400 venc->params.crop.top = ALIGN(s->r.top, res->step_height); in venc_s_selection()
401 venc->params.crop.width = ALIGN(s->r.width, res->step_width); in venc_s_selection()
402 venc->params.crop.height = ALIGN(s->r.height, res->step_height); in venc_s_selection()
403 if (venc_valid_crop(venc, res)) { in venc_s_selection()
404 venc->params.crop.left = 0; in venc_s_selection()
405 venc->params.crop.top = 0; in venc_s_selection()
406 venc->params.crop.width = venc->params.src_width; in venc_s_selection()
407 venc->params.crop.height = venc->params.src_height; in venc_s_selection()
410 inst->crop = venc->params.crop; in venc_s_selection()
417 struct venc_t *venc = inst->priv; in venc_drain() local
429 if (!venc->input_ready) in venc_drain()
432 venc->input_ready = false; in venc_drain()
438 wake_up_all(&venc->wq); in venc_drain()
518 struct venc_t *venc = inst->priv; in venc_op_s_ctrl() local
523 venc->params.profile = ctrl->val; in venc_op_s_ctrl()
526 venc->params.level = ctrl->val; in venc_op_s_ctrl()
529 venc->params.rc_enable = ctrl->val; in venc_op_s_ctrl()
532 venc->params.rc_mode = ctrl->val; in venc_op_s_ctrl()
535 if (ctrl->val != venc->params.bitrate) in venc_op_s_ctrl()
536 venc->bitrate_change = true; in venc_op_s_ctrl()
537 venc->params.bitrate = ctrl->val; in venc_op_s_ctrl()
540 venc->params.bitrate_max = ctrl->val; in venc_op_s_ctrl()
543 venc->params.gop_length = ctrl->val; in venc_op_s_ctrl()
546 venc->params.bframes = ctrl->val; in venc_op_s_ctrl()
549 venc->params.i_frame_qp = ctrl->val; in venc_op_s_ctrl()
552 venc->params.p_frame_qp = ctrl->val; in venc_op_s_ctrl()
555 venc->params.b_frame_qp = ctrl->val; in venc_op_s_ctrl()
558 venc->request_key_frame = 1; in venc_op_s_ctrl()
561 venc->cpb_size = ctrl->val * 1024; in venc_op_s_ctrl()
564 venc->params.sar.enable = ctrl->val; in venc_op_s_ctrl()
567 venc->params.sar.idc = ctrl->val; in venc_op_s_ctrl()
570 venc->params.sar.width = ctrl->val; in venc_op_s_ctrl()
573 venc->params.sar.height = ctrl->val; in venc_op_s_ctrl()
702 struct venc_t *venc = inst->priv; in venc_check_ready() local
705 if (vpu_helper_get_free_space(inst) < venc->cpb_size) in venc_check_ready()
707 return venc->input_ready; in venc_check_ready()
710 if (list_empty(&venc->frames)) in venc_check_ready()
723 static void venc_set_enable(struct venc_t *venc, u32 type, int enable) in venc_set_enable() argument
728 venc->enable |= mask; in venc_set_enable()
730 venc->enable &= ~mask; in venc_set_enable()
733 static u32 venc_get_enable(struct venc_t *venc, u32 type) in venc_get_enable() argument
735 return venc->enable & venc_get_enable_mask(type); in venc_get_enable()
740 struct venc_t *venc = inst->priv; in venc_input_done() local
743 venc->input_ready = true; in venc_input_done()
758 struct venc_t *venc; in venc_precheck_encoded_frame() local
764 venc = inst->priv; in venc_precheck_encoded_frame()
773 venc->skipped_bytes += skipped; in venc_precheck_encoded_frame()
774 venc->skipped_count++; in venc_precheck_encoded_frame()
784 struct venc_t *venc = inst->priv; in venc_get_one_encoded_frame() local
826 venc->ready_count++; in venc_get_one_encoded_frame()
836 struct venc_t *venc; in venc_get_encoded_frames() local
842 venc = inst->priv; in venc_get_encoded_frames()
843 list_for_each_entry_safe(frame, tmp, &venc->frames, list) { in venc_get_encoded_frames()
858 struct venc_t *venc; in venc_frame_encoded() local
863 venc = inst->priv; in venc_frame_encoded()
872 list_add_tail(&frame->list, &venc->frames); in venc_frame_encoded()
873 venc->encode_count++; in venc_frame_encoded()
882 struct venc_t *venc = inst->priv; in venc_set_last_buffer_dequeued() local
884 if (venc->stopped && list_empty(&venc->frames)) in venc_set_last_buffer_dequeued()
890 struct venc_t *venc = inst->priv; in venc_stop_done() local
893 venc->stopped = true; in venc_stop_done()
897 wake_up_all(&venc->wq); in venc_stop_done()
910 struct venc_t *venc; in venc_cleanup() local
915 venc = inst->priv; in venc_cleanup()
916 vfree(venc); in venc_cleanup()
923 struct venc_t *venc = inst->priv; in venc_start_session() local
927 venc_set_enable(venc, type, 1); in venc_start_session()
928 if ((venc->enable & VENC_ENABLE_MASK) != VENC_ENABLE_MASK) in venc_start_session()
934 inst->stream_buffer.length = max_t(u32, stream_buffer_size, venc->cpb_size * 3); in venc_start_session()
943 ret = vpu_iface_set_encode_params(inst, &venc->params, 0); in venc_start_session()
954 ret = vpu_iface_set_encode_params(inst, &venc->params, 1); in venc_start_session()
963 venc->bitrate_change = false; in venc_start_session()
964 venc->input_ready = true; in venc_start_session()
965 venc->frame_count = 0; in venc_start_session()
966 venc->encode_count = 0; in venc_start_session()
967 venc->ready_count = 0; in venc_start_session()
968 venc->stopped = false; in venc_start_session()
970 if (venc->frame_count == 0) in venc_start_session()
975 venc_set_enable(venc, type, 0); in venc_start_session()
984 struct venc_t *venc; in venc_cleanup_mem_resource() local
987 venc = inst->priv; in venc_cleanup_mem_resource()
989 for (i = 0; i < ARRAY_SIZE(venc->enc); i++) in venc_cleanup_mem_resource()
990 vpu_free_dma(&venc->enc[i]); in venc_cleanup_mem_resource()
991 for (i = 0; i < ARRAY_SIZE(venc->ref); i++) in venc_cleanup_mem_resource()
992 vpu_free_dma(&venc->ref[i]); in venc_cleanup_mem_resource()
1003 struct venc_t *venc; in venc_request_mem_resource() local
1007 venc = inst->priv; in venc_request_mem_resource()
1008 if (enc_frame_num > ARRAY_SIZE(venc->enc)) { in venc_request_mem_resource()
1012 if (ref_frame_num > ARRAY_SIZE(venc->ref)) { in venc_request_mem_resource()
1016 if (act_frame_num > ARRAY_SIZE(venc->act)) { in venc_request_mem_resource()
1022 venc->enc[i].length = enc_frame_size; in venc_request_mem_resource()
1023 ret = vpu_alloc_dma(inst->core, &venc->enc[i]); in venc_request_mem_resource()
1030 venc->ref[i].length = ref_frame_size; in venc_request_mem_resource()
1031 ret = vpu_alloc_dma(inst->core, &venc->ref[i]); in venc_request_mem_resource()
1041 venc->act[0].length = act_frame_size; in venc_request_mem_resource()
1042 venc->act[0].phys = inst->act.phys; in venc_request_mem_resource()
1043 venc->act[0].virt = inst->act.virt; in venc_request_mem_resource()
1046 vpu_iface_config_memory_resource(inst, MEM_RES_ENC, i, &venc->enc[i]); in venc_request_mem_resource()
1048 vpu_iface_config_memory_resource(inst, MEM_RES_REF, i, &venc->ref[i]); in venc_request_mem_resource()
1050 vpu_iface_config_memory_resource(inst, MEM_RES_ACT, i, &venc->act[i]); in venc_request_mem_resource()
1053 static void venc_cleanup_frames(struct venc_t *venc) in venc_cleanup_frames() argument
1058 list_for_each_entry_safe(frame, tmp, &venc->frames, list) { in venc_cleanup_frames()
1066 struct venc_t *venc = inst->priv; in venc_stop_session() local
1068 venc_set_enable(venc, type, 0); in venc_stop_session()
1069 if (venc->enable & VENC_ENABLE_MASK) in venc_stop_session()
1079 if (!wait_event_timeout(venc->wq, venc->stopped, VPU_TIMEOUT)) { in venc_stop_session()
1095 struct venc_t *venc = inst->priv; in venc_process_output() local
1107 if (venc->request_key_frame) { in venc_process_output()
1109 venc->request_key_frame = 0; in venc_process_output()
1111 if (venc->bitrate_change) { in venc_process_output()
1112 vpu_session_update_parameters(inst, &venc->params); in venc_process_output()
1113 venc->bitrate_change = false; in venc_process_output()
1118 venc->input_ready = false; in venc_process_output()
1119 venc->frame_count++; in venc_process_output()
1127 struct venc_t *venc; in venc_process_capture() local
1132 venc = inst->priv; in venc_process_capture()
1133 if (list_empty(&venc->frames)) in venc_process_capture()
1136 frame = list_first_entry(&venc->frames, struct venc_frame_t, list); in venc_process_capture()
1150 struct venc_t *venc = inst->priv; in venc_on_queue_empty() local
1155 if (venc->stopped) in venc_on_queue_empty()
1161 struct venc_t *venc = inst->priv; in venc_get_debug_info() local
1166 num = scnprintf(str, size, "profile = %d\n", venc->params.profile); in venc_get_debug_info()
1169 num = scnprintf(str, size, "level = %d\n", venc->params.level); in venc_get_debug_info()
1173 venc->params.frame_rate.numerator, in venc_get_debug_info()
1174 venc->params.frame_rate.denominator); in venc_get_debug_info()
1178 venc->params.src_width, in venc_get_debug_info()
1179 venc->params.src_height, in venc_get_debug_info()
1180 venc->params.out_width, in venc_get_debug_info()
1181 venc->params.out_height); in venc_get_debug_info()
1185 venc->params.crop.left, in venc_get_debug_info()
1186 venc->params.crop.top, in venc_get_debug_info()
1187 venc->params.crop.width, in venc_get_debug_info()
1188 venc->params.crop.height); in venc_get_debug_info()
1193 venc->enable, in venc_get_debug_info()
1194 venc->frame_count, venc->encode_count, in venc_get_debug_info()
1195 venc->ready_count, in venc_get_debug_info()
1196 venc->stopped); in venc_get_debug_info()
1199 num = scnprintf(str, size, "gop = %d\n", venc->params.gop_length); in venc_get_debug_info()
1202 num = scnprintf(str, size, "bframes = %d\n", venc->params.bframes); in venc_get_debug_info()
1206 venc->params.rc_enable ? "enable" : "disable", in venc_get_debug_info()
1207 venc->params.rc_mode, in venc_get_debug_info()
1208 venc->params.bitrate, in venc_get_debug_info()
1209 venc->params.bitrate_max, in venc_get_debug_info()
1210 venc->params.i_frame_qp); in venc_get_debug_info()
1214 venc->params.sar.enable, in venc_get_debug_info()
1215 venc->params.sar.idc, in venc_get_debug_info()
1216 venc->params.sar.width, in venc_get_debug_info()
1217 venc->params.sar.height); in venc_get_debug_info()
1223 venc->params.color.primaries, in venc_get_debug_info()
1224 venc->params.color.transfer, in venc_get_debug_info()
1225 venc->params.color.matrix, in venc_get_debug_info()
1226 venc->params.color.full_range); in venc_get_debug_info()
1230 venc->skipped_count, venc->skipped_bytes); in venc_get_debug_info()
1262 struct venc_t *venc; in venc_init() local
1266 venc = inst->priv; in venc_init()
1267 venc->params.qp_min = 1; in venc_init()
1268 venc->params.qp_max = 51; in venc_init()
1269 venc->params.qp_min_i = 1; in venc_init()
1270 venc->params.qp_max_i = 51; in venc_init()
1271 venc->params.bitrate_min = BITRATE_MIN; in venc_init()
1299 struct venc_t *venc; in venc_open() local
1306 venc = vzalloc(sizeof(*venc)); in venc_open()
1307 if (!venc) { in venc_open()
1315 inst->priv = venc; in venc_open()
1316 INIT_LIST_HEAD(&venc->frames); in venc_open()
1317 init_waitqueue_head(&venc->wq); in venc_open()