Lines Matching refs:venc
168 struct venc_t *venc = inst->priv; in venc_g_fmt() local
186 f->fmt.pix_mp.colorspace = venc->params.color.primaries; in venc_g_fmt()
187 f->fmt.pix_mp.xfer_func = venc->params.color.transfer; in venc_g_fmt()
188 f->fmt.pix_mp.ycbcr_enc = venc->params.color.matrix; in venc_g_fmt()
189 f->fmt.pix_mp.quantization = venc->params.color.full_range; in venc_g_fmt()
209 struct venc_t *venc = inst->priv; in venc_s_fmt() local
239 venc->params.input_format = cur_fmt->pixfmt; in venc_s_fmt()
240 venc->params.src_stride = cur_fmt->bytesperline[0]; in venc_s_fmt()
241 venc->params.src_width = cur_fmt->width; in venc_s_fmt()
242 venc->params.src_height = cur_fmt->height; in venc_s_fmt()
243 venc->params.crop.left = 0; in venc_s_fmt()
244 venc->params.crop.top = 0; in venc_s_fmt()
245 venc->params.crop.width = cur_fmt->width; in venc_s_fmt()
246 venc->params.crop.height = cur_fmt->height; in venc_s_fmt()
248 venc->params.codec_format = cur_fmt->pixfmt; in venc_s_fmt()
249 venc->params.out_width = cur_fmt->width; in venc_s_fmt()
250 venc->params.out_height = cur_fmt->height; in venc_s_fmt()
255 venc->params.color.primaries = pix_mp->colorspace; in venc_s_fmt()
256 vpu_color_get_default(venc->params.color.primaries, in venc_s_fmt()
257 &venc->params.color.transfer, in venc_s_fmt()
258 &venc->params.color.matrix, in venc_s_fmt()
259 &venc->params.color.full_range); in venc_s_fmt()
262 venc->params.color.transfer = pix_mp->xfer_func; in venc_s_fmt()
264 venc->params.color.matrix = pix_mp->ycbcr_enc; in venc_s_fmt()
266 venc->params.color.full_range = pix_mp->quantization; in venc_s_fmt()
269 pix_mp->colorspace = venc->params.color.primaries; in venc_s_fmt()
270 pix_mp->xfer_func = venc->params.color.transfer; in venc_s_fmt()
271 pix_mp->ycbcr_enc = venc->params.color.matrix; in venc_s_fmt()
272 pix_mp->quantization = venc->params.color.full_range; in venc_s_fmt()
280 struct venc_t *venc = inst->priv; in venc_g_parm() local
294 timeperframe->numerator = venc->params.frame_rate.numerator; in venc_g_parm()
295 timeperframe->denominator = venc->params.frame_rate.denominator; in venc_g_parm()
303 struct venc_t *venc = inst->priv; in venc_s_parm() local
317 timeperframe->numerator = venc->params.frame_rate.numerator; in venc_s_parm()
319 timeperframe->denominator = venc->params.frame_rate.denominator; in venc_s_parm()
321 venc->params.frame_rate.numerator = timeperframe->numerator; in venc_s_parm()
322 venc->params.frame_rate.denominator = timeperframe->denominator; in venc_s_parm()
324 rational_best_approximation(venc->params.frame_rate.numerator, in venc_s_parm()
325 venc->params.frame_rate.denominator, in venc_s_parm()
326 venc->params.frame_rate.numerator, in venc_s_parm()
327 venc->params.frame_rate.denominator, in venc_s_parm()
329 venc->params.frame_rate.numerator = n; in venc_s_parm()
330 venc->params.frame_rate.denominator = d; in venc_s_parm()
341 struct venc_t *venc = inst->priv; in venc_g_selection() local
355 s->r = venc->params.crop; in venc_g_selection()
364 static int venc_valid_crop(struct venc_t *venc, const struct vpu_core_resources *res) in venc_valid_crop() argument
372 rect = &venc->params.crop; in venc_valid_crop()
375 src_width = venc->params.src_width; in venc_valid_crop()
376 src_height = venc->params.src_height; in venc_valid_crop()
396 struct venc_t *venc = inst->priv; in venc_s_selection() local
407 venc->params.crop.left = ALIGN(s->r.left, res->step_width); in venc_s_selection()
408 venc->params.crop.top = ALIGN(s->r.top, res->step_height); in venc_s_selection()
409 venc->params.crop.width = ALIGN(s->r.width, res->step_width); in venc_s_selection()
410 venc->params.crop.height = ALIGN(s->r.height, res->step_height); in venc_s_selection()
411 if (venc_valid_crop(venc, res)) { in venc_s_selection()
412 venc->params.crop.left = 0; in venc_s_selection()
413 venc->params.crop.top = 0; in venc_s_selection()
414 venc->params.crop.width = venc->params.src_width; in venc_s_selection()
415 venc->params.crop.height = venc->params.src_height; in venc_s_selection()
418 inst->crop = venc->params.crop; in venc_s_selection()
425 struct venc_t *venc = inst->priv; in venc_drain() local
437 if (!venc->input_ready) in venc_drain()
440 venc->input_ready = false; in venc_drain()
446 wake_up_all(&venc->wq); in venc_drain()
526 struct venc_t *venc = inst->priv; in venc_op_s_ctrl() local
532 venc->params.profile = ctrl->val; in venc_op_s_ctrl()
535 venc->params.level = ctrl->val; in venc_op_s_ctrl()
538 venc->params.rc_enable = ctrl->val; in venc_op_s_ctrl()
541 venc->params.rc_mode = ctrl->val; in venc_op_s_ctrl()
544 if (ctrl->val != venc->params.bitrate) in venc_op_s_ctrl()
545 venc->bitrate_change = true; in venc_op_s_ctrl()
546 venc->params.bitrate = ctrl->val; in venc_op_s_ctrl()
549 venc->params.bitrate_max = ctrl->val; in venc_op_s_ctrl()
552 venc->params.gop_length = ctrl->val; in venc_op_s_ctrl()
555 venc->params.bframes = ctrl->val; in venc_op_s_ctrl()
558 venc->params.i_frame_qp = ctrl->val; in venc_op_s_ctrl()
561 venc->params.p_frame_qp = ctrl->val; in venc_op_s_ctrl()
564 venc->params.b_frame_qp = ctrl->val; in venc_op_s_ctrl()
567 venc->request_key_frame = 1; in venc_op_s_ctrl()
570 venc->cpb_size = ctrl->val * 1024; in venc_op_s_ctrl()
573 venc->params.sar.enable = ctrl->val; in venc_op_s_ctrl()
576 venc->params.sar.idc = ctrl->val; in venc_op_s_ctrl()
579 venc->params.sar.width = ctrl->val; in venc_op_s_ctrl()
582 venc->params.sar.height = ctrl->val; in venc_op_s_ctrl()
709 struct venc_t *venc = inst->priv; in venc_check_ready() local
712 if (vpu_helper_get_free_space(inst) < venc->cpb_size) in venc_check_ready()
714 return venc->input_ready; in venc_check_ready()
717 if (list_empty(&venc->frames)) in venc_check_ready()
730 static void venc_set_enable(struct venc_t *venc, u32 type, int enable) in venc_set_enable() argument
735 venc->enable |= mask; in venc_set_enable()
737 venc->enable &= ~mask; in venc_set_enable()
740 static u32 venc_get_enable(struct venc_t *venc, u32 type) in venc_get_enable() argument
742 return venc->enable & venc_get_enable_mask(type); in venc_get_enable()
747 struct venc_t *venc = inst->priv; in venc_input_done() local
750 venc->input_ready = true; in venc_input_done()
765 struct venc_t *venc; in venc_precheck_encoded_frame() local
771 venc = inst->priv; in venc_precheck_encoded_frame()
780 venc->skipped_bytes += skipped; in venc_precheck_encoded_frame()
781 venc->skipped_count++; in venc_precheck_encoded_frame()
791 struct venc_t *venc = inst->priv; in venc_get_one_encoded_frame() local
832 venc->ready_count++; in venc_get_one_encoded_frame()
842 struct venc_t *venc; in venc_get_encoded_frames() local
848 venc = inst->priv; in venc_get_encoded_frames()
849 list_for_each_entry_safe(frame, tmp, &venc->frames, list) { in venc_get_encoded_frames()
864 struct venc_t *venc; in venc_frame_encoded() local
869 venc = inst->priv; in venc_frame_encoded()
878 list_add_tail(&frame->list, &venc->frames); in venc_frame_encoded()
879 venc->encode_count++; in venc_frame_encoded()
888 struct venc_t *venc = inst->priv; in venc_set_last_buffer_dequeued() local
890 if (venc->stopped && list_empty(&venc->frames)) in venc_set_last_buffer_dequeued()
896 struct venc_t *venc = inst->priv; in venc_stop_done() local
899 venc->stopped = true; in venc_stop_done()
903 wake_up_all(&venc->wq); in venc_stop_done()
916 struct venc_t *venc; in venc_cleanup() local
921 venc = inst->priv; in venc_cleanup()
922 vfree(venc); in venc_cleanup()
929 struct venc_t *venc = inst->priv; in venc_start_session() local
933 venc_set_enable(venc, type, 1); in venc_start_session()
934 if ((venc->enable & VENC_ENABLE_MASK) != VENC_ENABLE_MASK) in venc_start_session()
940 inst->stream_buffer.length = max_t(u32, stream_buffer_size, venc->cpb_size * 3); in venc_start_session()
949 ret = vpu_iface_set_encode_params(inst, &venc->params, 0); in venc_start_session()
960 ret = vpu_iface_set_encode_params(inst, &venc->params, 1); in venc_start_session()
969 venc->bitrate_change = false; in venc_start_session()
970 venc->input_ready = true; in venc_start_session()
971 venc->frame_count = 0; in venc_start_session()
972 venc->encode_count = 0; in venc_start_session()
973 venc->ready_count = 0; in venc_start_session()
974 venc->stopped = false; in venc_start_session()
976 if (venc->frame_count == 0) in venc_start_session()
981 venc_set_enable(venc, type, 0); in venc_start_session()
990 struct venc_t *venc; in venc_cleanup_mem_resource() local
993 venc = inst->priv; in venc_cleanup_mem_resource()
995 for (i = 0; i < ARRAY_SIZE(venc->enc); i++) in venc_cleanup_mem_resource()
996 vpu_free_dma(&venc->enc[i]); in venc_cleanup_mem_resource()
997 for (i = 0; i < ARRAY_SIZE(venc->ref); i++) in venc_cleanup_mem_resource()
998 vpu_free_dma(&venc->ref[i]); in venc_cleanup_mem_resource()
1009 struct venc_t *venc; in venc_request_mem_resource() local
1013 venc = inst->priv; in venc_request_mem_resource()
1014 if (enc_frame_num > ARRAY_SIZE(venc->enc)) { in venc_request_mem_resource()
1018 if (ref_frame_num > ARRAY_SIZE(venc->ref)) { in venc_request_mem_resource()
1022 if (act_frame_num > ARRAY_SIZE(venc->act)) { in venc_request_mem_resource()
1028 venc->enc[i].length = enc_frame_size; in venc_request_mem_resource()
1029 ret = vpu_alloc_dma(inst->core, &venc->enc[i]); in venc_request_mem_resource()
1036 venc->ref[i].length = ref_frame_size; in venc_request_mem_resource()
1037 ret = vpu_alloc_dma(inst->core, &venc->ref[i]); in venc_request_mem_resource()
1047 venc->act[0].length = act_frame_size; in venc_request_mem_resource()
1048 venc->act[0].phys = inst->act.phys; in venc_request_mem_resource()
1049 venc->act[0].virt = inst->act.virt; in venc_request_mem_resource()
1052 vpu_iface_config_memory_resource(inst, MEM_RES_ENC, i, &venc->enc[i]); in venc_request_mem_resource()
1054 vpu_iface_config_memory_resource(inst, MEM_RES_REF, i, &venc->ref[i]); in venc_request_mem_resource()
1056 vpu_iface_config_memory_resource(inst, MEM_RES_ACT, i, &venc->act[i]); in venc_request_mem_resource()
1059 static void venc_cleanup_frames(struct venc_t *venc) in venc_cleanup_frames() argument
1064 list_for_each_entry_safe(frame, tmp, &venc->frames, list) { in venc_cleanup_frames()
1072 struct venc_t *venc = inst->priv; in venc_stop_session() local
1074 venc_set_enable(venc, type, 0); in venc_stop_session()
1075 if (venc->enable & VENC_ENABLE_MASK) in venc_stop_session()
1085 if (!wait_event_timeout(venc->wq, venc->stopped, VPU_TIMEOUT)) { in venc_stop_session()
1101 struct venc_t *venc = inst->priv; in venc_process_output() local
1113 if (venc->request_key_frame) { in venc_process_output()
1115 venc->request_key_frame = 0; in venc_process_output()
1117 if (venc->bitrate_change) { in venc_process_output()
1118 vpu_session_update_parameters(inst, &venc->params); in venc_process_output()
1119 venc->bitrate_change = false; in venc_process_output()
1124 venc->input_ready = false; in venc_process_output()
1125 venc->frame_count++; in venc_process_output()
1133 struct venc_t *venc; in venc_process_capture() local
1138 venc = inst->priv; in venc_process_capture()
1139 if (list_empty(&venc->frames)) in venc_process_capture()
1142 frame = list_first_entry(&venc->frames, struct venc_frame_t, list); in venc_process_capture()
1156 struct venc_t *venc = inst->priv; in venc_on_queue_empty() local
1161 if (venc->stopped) in venc_on_queue_empty()
1167 struct venc_t *venc = inst->priv; in venc_get_debug_info() local
1172 num = scnprintf(str, size, "profile = %d\n", venc->params.profile); in venc_get_debug_info()
1175 num = scnprintf(str, size, "level = %d\n", venc->params.level); in venc_get_debug_info()
1179 venc->params.frame_rate.numerator, in venc_get_debug_info()
1180 venc->params.frame_rate.denominator); in venc_get_debug_info()
1184 venc->params.src_width, in venc_get_debug_info()
1185 venc->params.src_height, in venc_get_debug_info()
1186 venc->params.out_width, in venc_get_debug_info()
1187 venc->params.out_height); in venc_get_debug_info()
1191 venc->params.crop.left, in venc_get_debug_info()
1192 venc->params.crop.top, in venc_get_debug_info()
1193 venc->params.crop.width, in venc_get_debug_info()
1194 venc->params.crop.height); in venc_get_debug_info()
1199 venc->enable, in venc_get_debug_info()
1200 venc->frame_count, venc->encode_count, in venc_get_debug_info()
1201 venc->ready_count, in venc_get_debug_info()
1202 venc->stopped); in venc_get_debug_info()
1205 num = scnprintf(str, size, "gop = %d\n", venc->params.gop_length); in venc_get_debug_info()
1208 num = scnprintf(str, size, "bframes = %d\n", venc->params.bframes); in venc_get_debug_info()
1212 venc->params.rc_enable ? "enable" : "disable", in venc_get_debug_info()
1213 venc->params.rc_mode, in venc_get_debug_info()
1214 venc->params.bitrate, in venc_get_debug_info()
1215 venc->params.bitrate_max, in venc_get_debug_info()
1216 venc->params.i_frame_qp); in venc_get_debug_info()
1220 venc->params.sar.enable, in venc_get_debug_info()
1221 venc->params.sar.idc, in venc_get_debug_info()
1222 venc->params.sar.width, in venc_get_debug_info()
1223 venc->params.sar.height); in venc_get_debug_info()
1229 venc->params.color.primaries, in venc_get_debug_info()
1230 venc->params.color.transfer, in venc_get_debug_info()
1231 venc->params.color.matrix, in venc_get_debug_info()
1232 venc->params.color.full_range); in venc_get_debug_info()
1236 venc->skipped_count, venc->skipped_bytes); in venc_get_debug_info()
1268 struct venc_t *venc; in venc_init() local
1272 venc = inst->priv; in venc_init()
1273 venc->params.qp_min = 1; in venc_init()
1274 venc->params.qp_max = 51; in venc_init()
1275 venc->params.qp_min_i = 1; in venc_init()
1276 venc->params.qp_max_i = 51; in venc_init()
1277 venc->params.bitrate_min = BITRATE_MIN; in venc_init()
1306 struct venc_t *venc; in venc_open() local
1313 venc = vzalloc(sizeof(*venc)); in venc_open()
1314 if (!venc) { in venc_open()
1322 inst->priv = venc; in venc_open()
1323 INIT_LIST_HEAD(&venc->frames); in venc_open()
1324 init_waitqueue_head(&venc->wq); in venc_open()