Lines Matching refs: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
284 timeperframe->numerator = venc->params.frame_rate.numerator; in venc_g_parm()
285 timeperframe->denominator = venc->params.frame_rate.denominator; in venc_g_parm()
293 struct venc_t *venc = inst->priv; in venc_s_parm() local
307 timeperframe->numerator = venc->params.frame_rate.numerator; in venc_s_parm()
309 timeperframe->denominator = venc->params.frame_rate.denominator; in venc_s_parm()
311 venc->params.frame_rate.numerator = timeperframe->numerator; in venc_s_parm()
312 venc->params.frame_rate.denominator = timeperframe->denominator; in venc_s_parm()
314 rational_best_approximation(venc->params.frame_rate.numerator, in venc_s_parm()
315 venc->params.frame_rate.denominator, in venc_s_parm()
316 venc->params.frame_rate.numerator, in venc_s_parm()
317 venc->params.frame_rate.denominator, in venc_s_parm()
319 venc->params.frame_rate.numerator = n; in venc_s_parm()
320 venc->params.frame_rate.denominator = d; in venc_s_parm()
331 struct venc_t *venc = inst->priv; in venc_g_selection() local
345 s->r = venc->params.crop; in venc_g_selection()
354 static int venc_valid_crop(struct venc_t *venc, const struct vpu_core_resources *res) in venc_valid_crop() argument
362 rect = &venc->params.crop; in venc_valid_crop()
365 src_width = venc->params.src_width; in venc_valid_crop()
366 src_height = venc->params.src_height; in venc_valid_crop()
386 struct venc_t *venc = inst->priv; in venc_s_selection() local
397 venc->params.crop.left = ALIGN(s->r.left, res->step_width); in venc_s_selection()
398 venc->params.crop.top = ALIGN(s->r.top, res->step_height); in venc_s_selection()
399 venc->params.crop.width = ALIGN(s->r.width, res->step_width); in venc_s_selection()
400 venc->params.crop.height = ALIGN(s->r.height, res->step_height); in venc_s_selection()
401 if (venc_valid_crop(venc, res)) { in venc_s_selection()
402 venc->params.crop.left = 0; in venc_s_selection()
403 venc->params.crop.top = 0; in venc_s_selection()
404 venc->params.crop.width = venc->params.src_width; in venc_s_selection()
405 venc->params.crop.height = venc->params.src_height; in venc_s_selection()
408 inst->crop = venc->params.crop; in venc_s_selection()
415 struct venc_t *venc = inst->priv; in venc_drain() local
427 if (!venc->input_ready) in venc_drain()
430 venc->input_ready = false; in venc_drain()
436 wake_up_all(&venc->wq); in venc_drain()
516 struct venc_t *venc = inst->priv; in venc_op_s_ctrl() local
522 venc->params.profile = ctrl->val; in venc_op_s_ctrl()
525 venc->params.level = ctrl->val; in venc_op_s_ctrl()
528 venc->params.rc_enable = ctrl->val; in venc_op_s_ctrl()
531 venc->params.rc_mode = ctrl->val; in venc_op_s_ctrl()
534 if (ctrl->val != venc->params.bitrate) in venc_op_s_ctrl()
535 venc->bitrate_change = true; in venc_op_s_ctrl()
536 venc->params.bitrate = ctrl->val; in venc_op_s_ctrl()
539 venc->params.bitrate_max = ctrl->val; in venc_op_s_ctrl()
542 venc->params.gop_length = ctrl->val; in venc_op_s_ctrl()
545 venc->params.bframes = ctrl->val; in venc_op_s_ctrl()
548 venc->params.i_frame_qp = ctrl->val; in venc_op_s_ctrl()
551 venc->params.p_frame_qp = ctrl->val; in venc_op_s_ctrl()
554 venc->params.b_frame_qp = ctrl->val; in venc_op_s_ctrl()
557 venc->request_key_frame = 1; in venc_op_s_ctrl()
560 venc->cpb_size = ctrl->val * 1024; in venc_op_s_ctrl()
563 venc->params.sar.enable = ctrl->val; in venc_op_s_ctrl()
566 venc->params.sar.idc = ctrl->val; in venc_op_s_ctrl()
569 venc->params.sar.width = ctrl->val; in venc_op_s_ctrl()
572 venc->params.sar.height = ctrl->val; in venc_op_s_ctrl()
699 struct venc_t *venc = inst->priv; in venc_check_ready() local
702 if (vpu_helper_get_free_space(inst) < venc->cpb_size) in venc_check_ready()
704 return venc->input_ready; in venc_check_ready()
707 if (list_empty(&venc->frames)) in venc_check_ready()
720 static void venc_set_enable(struct venc_t *venc, u32 type, int enable) in venc_set_enable() argument
725 venc->enable |= mask; in venc_set_enable()
727 venc->enable &= ~mask; in venc_set_enable()
730 static u32 venc_get_enable(struct venc_t *venc, u32 type) in venc_get_enable() argument
732 return venc->enable & venc_get_enable_mask(type); in venc_get_enable()
737 struct venc_t *venc = inst->priv; in venc_input_done() local
740 venc->input_ready = true; in venc_input_done()
755 struct venc_t *venc; in venc_precheck_encoded_frame() local
761 venc = inst->priv; in venc_precheck_encoded_frame()
770 venc->skipped_bytes += skipped; in venc_precheck_encoded_frame()
771 venc->skipped_count++; in venc_precheck_encoded_frame()
781 struct venc_t *venc = inst->priv; in venc_get_one_encoded_frame() local
822 venc->ready_count++; in venc_get_one_encoded_frame()
832 struct venc_t *venc; in venc_get_encoded_frames() local
838 venc = inst->priv; in venc_get_encoded_frames()
839 list_for_each_entry_safe(frame, tmp, &venc->frames, list) { in venc_get_encoded_frames()
854 struct venc_t *venc; in venc_frame_encoded() local
859 venc = inst->priv; in venc_frame_encoded()
868 list_add_tail(&frame->list, &venc->frames); in venc_frame_encoded()
869 venc->encode_count++; in venc_frame_encoded()
878 struct venc_t *venc = inst->priv; in venc_set_last_buffer_dequeued() local
880 if (venc->stopped && list_empty(&venc->frames)) in venc_set_last_buffer_dequeued()
886 struct venc_t *venc = inst->priv; in venc_stop_done() local
889 venc->stopped = true; in venc_stop_done()
893 wake_up_all(&venc->wq); in venc_stop_done()
906 struct venc_t *venc; in venc_cleanup() local
911 venc = inst->priv; in venc_cleanup()
912 vfree(venc); in venc_cleanup()
919 struct venc_t *venc = inst->priv; in venc_start_session() local
923 venc_set_enable(venc, type, 1); in venc_start_session()
924 if ((venc->enable & VENC_ENABLE_MASK) != VENC_ENABLE_MASK) in venc_start_session()
930 inst->stream_buffer.length = max_t(u32, stream_buffer_size, venc->cpb_size * 3); in venc_start_session()
939 ret = vpu_iface_set_encode_params(inst, &venc->params, 0); in venc_start_session()
950 ret = vpu_iface_set_encode_params(inst, &venc->params, 1); in venc_start_session()
959 venc->bitrate_change = false; in venc_start_session()
960 venc->input_ready = true; in venc_start_session()
961 venc->frame_count = 0; in venc_start_session()
962 venc->encode_count = 0; in venc_start_session()
963 venc->ready_count = 0; in venc_start_session()
964 venc->stopped = false; in venc_start_session()
966 if (venc->frame_count == 0) in venc_start_session()
971 venc_set_enable(venc, type, 0); in venc_start_session()
980 struct venc_t *venc; in venc_cleanup_mem_resource() local
983 venc = inst->priv; in venc_cleanup_mem_resource()
985 for (i = 0; i < ARRAY_SIZE(venc->enc); i++) in venc_cleanup_mem_resource()
986 vpu_free_dma(&venc->enc[i]); in venc_cleanup_mem_resource()
987 for (i = 0; i < ARRAY_SIZE(venc->ref); i++) in venc_cleanup_mem_resource()
988 vpu_free_dma(&venc->ref[i]); in venc_cleanup_mem_resource()
999 struct venc_t *venc; in venc_request_mem_resource() local
1003 venc = inst->priv; in venc_request_mem_resource()
1004 if (enc_frame_num > ARRAY_SIZE(venc->enc)) { in venc_request_mem_resource()
1008 if (ref_frame_num > ARRAY_SIZE(venc->ref)) { in venc_request_mem_resource()
1012 if (act_frame_num > ARRAY_SIZE(venc->act)) { in venc_request_mem_resource()
1018 venc->enc[i].length = enc_frame_size; in venc_request_mem_resource()
1019 ret = vpu_alloc_dma(inst->core, &venc->enc[i]); in venc_request_mem_resource()
1026 venc->ref[i].length = ref_frame_size; in venc_request_mem_resource()
1027 ret = vpu_alloc_dma(inst->core, &venc->ref[i]); in venc_request_mem_resource()
1037 venc->act[0].length = act_frame_size; in venc_request_mem_resource()
1038 venc->act[0].phys = inst->act.phys; in venc_request_mem_resource()
1039 venc->act[0].virt = inst->act.virt; in venc_request_mem_resource()
1042 vpu_iface_config_memory_resource(inst, MEM_RES_ENC, i, &venc->enc[i]); in venc_request_mem_resource()
1044 vpu_iface_config_memory_resource(inst, MEM_RES_REF, i, &venc->ref[i]); in venc_request_mem_resource()
1046 vpu_iface_config_memory_resource(inst, MEM_RES_ACT, i, &venc->act[i]); in venc_request_mem_resource()
1049 static void venc_cleanup_frames(struct venc_t *venc) in venc_cleanup_frames() argument
1054 list_for_each_entry_safe(frame, tmp, &venc->frames, list) { in venc_cleanup_frames()
1062 struct venc_t *venc = inst->priv; in venc_stop_session() local
1064 venc_set_enable(venc, type, 0); in venc_stop_session()
1065 if (venc->enable & VENC_ENABLE_MASK) in venc_stop_session()
1075 if (!wait_event_timeout(venc->wq, venc->stopped, VPU_TIMEOUT)) { in venc_stop_session()
1091 struct venc_t *venc = inst->priv; in venc_process_output() local
1103 if (venc->request_key_frame) { in venc_process_output()
1105 venc->request_key_frame = 0; in venc_process_output()
1107 if (venc->bitrate_change) { in venc_process_output()
1108 vpu_session_update_parameters(inst, &venc->params); in venc_process_output()
1109 venc->bitrate_change = false; in venc_process_output()
1114 venc->input_ready = false; in venc_process_output()
1115 venc->frame_count++; in venc_process_output()
1123 struct venc_t *venc; in venc_process_capture() local
1128 venc = inst->priv; in venc_process_capture()
1129 if (list_empty(&venc->frames)) in venc_process_capture()
1132 frame = list_first_entry(&venc->frames, struct venc_frame_t, list); in venc_process_capture()
1146 struct venc_t *venc = inst->priv; in venc_on_queue_empty() local
1151 if (venc->stopped) in venc_on_queue_empty()
1157 struct venc_t *venc = inst->priv; in venc_get_debug_info() local
1162 num = scnprintf(str, size, "profile = %d\n", venc->params.profile); in venc_get_debug_info()
1165 num = scnprintf(str, size, "level = %d\n", venc->params.level); in venc_get_debug_info()
1169 venc->params.frame_rate.numerator, in venc_get_debug_info()
1170 venc->params.frame_rate.denominator); in venc_get_debug_info()
1174 venc->params.src_width, in venc_get_debug_info()
1175 venc->params.src_height, in venc_get_debug_info()
1176 venc->params.out_width, in venc_get_debug_info()
1177 venc->params.out_height); in venc_get_debug_info()
1181 venc->params.crop.left, in venc_get_debug_info()
1182 venc->params.crop.top, in venc_get_debug_info()
1183 venc->params.crop.width, in venc_get_debug_info()
1184 venc->params.crop.height); in venc_get_debug_info()
1189 venc->enable, in venc_get_debug_info()
1190 venc->frame_count, venc->encode_count, in venc_get_debug_info()
1191 venc->ready_count, in venc_get_debug_info()
1192 venc->stopped); in venc_get_debug_info()
1195 num = scnprintf(str, size, "gop = %d\n", venc->params.gop_length); in venc_get_debug_info()
1198 num = scnprintf(str, size, "bframes = %d\n", venc->params.bframes); in venc_get_debug_info()
1202 venc->params.rc_enable ? "enable" : "disable", in venc_get_debug_info()
1203 venc->params.rc_mode, in venc_get_debug_info()
1204 venc->params.bitrate, in venc_get_debug_info()
1205 venc->params.bitrate_max, in venc_get_debug_info()
1206 venc->params.i_frame_qp); in venc_get_debug_info()
1210 venc->params.sar.enable, in venc_get_debug_info()
1211 venc->params.sar.idc, in venc_get_debug_info()
1212 venc->params.sar.width, in venc_get_debug_info()
1213 venc->params.sar.height); in venc_get_debug_info()
1219 venc->params.color.primaries, in venc_get_debug_info()
1220 venc->params.color.transfer, in venc_get_debug_info()
1221 venc->params.color.matrix, in venc_get_debug_info()
1222 venc->params.color.full_range); in venc_get_debug_info()
1226 venc->skipped_count, venc->skipped_bytes); in venc_get_debug_info()
1258 struct venc_t *venc; in venc_init() local
1262 venc = inst->priv; in venc_init()
1263 venc->params.qp_min = 1; in venc_init()
1264 venc->params.qp_max = 51; in venc_init()
1265 venc->params.qp_min_i = 1; in venc_init()
1266 venc->params.qp_max_i = 51; in venc_init()
1267 venc->params.bitrate_min = BITRATE_MIN; in venc_init()
1295 struct venc_t *venc; in venc_open() local
1302 venc = vzalloc(sizeof(*venc)); in venc_open()
1303 if (!venc) { in venc_open()
1311 inst->priv = venc; in venc_open()
1312 INIT_LIST_HEAD(&venc->frames); in venc_open()
1313 init_waitqueue_head(&venc->wq); in venc_open()