Lines Matching refs:inst
68 find_format(struct venus_inst *inst, u32 pixfmt, u32 type) in find_format() argument
83 !venus_helper_check_codec(inst, fmt[i].pixfmt)) in find_format()
90 find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type) in find_format_by_index() argument
105 venus_helper_check_codec(inst, fmt[i].pixfmt); in find_format_by_index()
156 struct venus_inst *inst = to_inst(file); in venc_enum_fmt() local
159 fmt = find_format_by_index(inst, f->index, f->type); in venc_enum_fmt()
172 venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f) in venc_try_fmt_common() argument
182 fmt = find_format(inst, pixmp->pixelformat, f->type); in venc_try_fmt_common()
190 fmt = find_format(inst, pixmp->pixelformat, f->type); in venc_try_fmt_common()
195 pixmp->width = clamp(pixmp->width, frame_width_min(inst), in venc_try_fmt_common()
196 frame_width_max(inst)); in venc_try_fmt_common()
197 pixmp->height = clamp(pixmp->height, frame_height_min(inst), in venc_try_fmt_common()
198 frame_height_max(inst)); in venc_try_fmt_common()
226 struct venus_inst *inst = to_inst(file); in venc_try_fmt() local
228 venc_try_fmt_common(inst, f); in venc_try_fmt()
235 struct venus_inst *inst = to_inst(file); in venc_s_fmt() local
243 q = v4l2_m2m_get_vq(inst->m2m_ctx, f->type); in venc_s_fmt()
252 fmt = venc_try_fmt_common(inst, f); in venc_s_fmt()
258 pixfmt_cap = inst->fmt_cap->pixfmt; in venc_s_fmt()
261 pixfmt_out = inst->fmt_out->pixfmt; in venc_s_fmt()
270 venc_try_fmt_common(inst, &format); in venc_s_fmt()
273 inst->out_width = format.fmt.pix_mp.width; in venc_s_fmt()
274 inst->out_height = format.fmt.pix_mp.height; in venc_s_fmt()
275 inst->colorspace = pixmp->colorspace; in venc_s_fmt()
276 inst->ycbcr_enc = pixmp->ycbcr_enc; in venc_s_fmt()
277 inst->quantization = pixmp->quantization; in venc_s_fmt()
278 inst->xfer_func = pixmp->xfer_func; in venc_s_fmt()
287 venc_try_fmt_common(inst, &format); in venc_s_fmt()
289 inst->width = format.fmt.pix_mp.width; in venc_s_fmt()
290 inst->height = format.fmt.pix_mp.height; in venc_s_fmt()
293 inst->fmt_out = fmt; in venc_s_fmt()
295 inst->fmt_cap = fmt; in venc_s_fmt()
296 inst->output_buf_size = pixmp->plane_fmt[0].sizeimage; in venc_s_fmt()
305 struct venus_inst *inst = to_inst(file); in venc_g_fmt() local
309 fmt = inst->fmt_cap; in venc_g_fmt()
311 fmt = inst->fmt_out; in venc_g_fmt()
318 pixmp->width = inst->width; in venc_g_fmt()
319 pixmp->height = inst->height; in venc_g_fmt()
320 pixmp->colorspace = inst->colorspace; in venc_g_fmt()
321 pixmp->ycbcr_enc = inst->ycbcr_enc; in venc_g_fmt()
322 pixmp->quantization = inst->quantization; in venc_g_fmt()
323 pixmp->xfer_func = inst->xfer_func; in venc_g_fmt()
325 pixmp->width = inst->out_width; in venc_g_fmt()
326 pixmp->height = inst->out_height; in venc_g_fmt()
329 venc_try_fmt_common(inst, f); in venc_g_fmt()
337 struct venus_inst *inst = to_inst(file); in venc_g_selection() local
345 s->r.width = inst->out_width; in venc_g_selection()
346 s->r.height = inst->out_height; in venc_g_selection()
349 s->r.width = inst->width; in venc_g_selection()
350 s->r.height = inst->height; in venc_g_selection()
365 struct venus_inst *inst = to_inst(file); in venc_s_selection() local
370 if (s->r.width > inst->out_width || in venc_s_selection()
371 s->r.height > inst->out_height) in venc_s_selection()
381 inst->width = s->r.width; in venc_s_selection()
382 inst->height = s->r.height; in venc_s_selection()
393 struct venus_inst *inst = to_inst(file); in venc_s_parm() local
405 timeperframe->denominator = inst->timeperframe.denominator; in venc_s_parm()
407 timeperframe->numerator = inst->timeperframe.numerator; in venc_s_parm()
420 inst->timeperframe = *timeperframe; in venc_s_parm()
421 inst->fps = fps; in venc_s_parm()
428 struct venus_inst *inst = to_inst(file); in venc_g_parm() local
435 a->parm.output.timeperframe = inst->timeperframe; in venc_g_parm()
443 struct venus_inst *inst = to_inst(file); in venc_enum_framesizes() local
448 fmt = find_format(inst, fsize->pixel_format, in venc_enum_framesizes()
451 fmt = find_format(inst, fsize->pixel_format, in venc_enum_framesizes()
460 fsize->stepwise.min_width = frame_width_min(inst); in venc_enum_framesizes()
461 fsize->stepwise.max_width = frame_width_max(inst); in venc_enum_framesizes()
462 fsize->stepwise.step_width = frame_width_step(inst); in venc_enum_framesizes()
463 fsize->stepwise.min_height = frame_height_min(inst); in venc_enum_framesizes()
464 fsize->stepwise.max_height = frame_height_max(inst); in venc_enum_framesizes()
465 fsize->stepwise.step_height = frame_height_step(inst); in venc_enum_framesizes()
473 struct venus_inst *inst = to_inst(file); in venc_enum_frameintervals() local
479 fmt = find_format(inst, fival->pixel_format, in venc_enum_frameintervals()
482 fmt = find_format(inst, fival->pixel_format, in venc_enum_frameintervals()
494 if (fival->width > frame_width_max(inst) || in venc_enum_frameintervals()
495 fival->width < frame_width_min(inst) || in venc_enum_frameintervals()
496 fival->height > frame_height_max(inst) || in venc_enum_frameintervals()
497 fival->height < frame_height_min(inst)) in venc_enum_frameintervals()
500 if (IS_V1(inst->core)) { in venc_enum_frameintervals()
506 fival->stepwise.min.denominator = frate_max(inst) / framerate_factor; in venc_enum_frameintervals()
508 fival->stepwise.max.denominator = frate_min(inst) / framerate_factor; in venc_enum_frameintervals()
510 fival->stepwise.step.denominator = frate_max(inst) / framerate_factor; in venc_enum_frameintervals()
531 struct venus_inst *inst = to_inst(file); in venc_encoder_cmd() local
539 mutex_lock(&inst->lock); in venc_encoder_cmd()
542 inst->enc_state == VENUS_ENC_STATE_ENCODING) { in venc_encoder_cmd()
547 if (!(inst->streamon_out && inst->streamon_cap)) in venc_encoder_cmd()
554 ret = hfi_session_process_buf(inst, &fdata); in venc_encoder_cmd()
556 inst->enc_state = VENUS_ENC_STATE_DRAIN; in venc_encoder_cmd()
558 if (inst->enc_state == VENUS_ENC_STATE_DRAIN) { in venc_encoder_cmd()
562 if (inst->enc_state == VENUS_ENC_STATE_STOPPED) { in venc_encoder_cmd()
563 vb2_clear_last_buffer_dequeued(&inst->fh.m2m_ctx->cap_q_ctx.q); in venc_encoder_cmd()
564 inst->enc_state = VENUS_ENC_STATE_ENCODING; in venc_encoder_cmd()
569 mutex_unlock(&inst->lock); in venc_encoder_cmd()
604 static int venc_pm_get(struct venus_inst *inst) in venc_pm_get() argument
606 struct venus_core *core = inst->core; in venc_pm_get()
617 static int venc_pm_put(struct venus_inst *inst, bool autosuspend) in venc_pm_put() argument
619 struct venus_core *core = inst->core; in venc_pm_put()
635 static int venc_pm_get_put(struct venus_inst *inst) in venc_pm_get_put() argument
637 struct venus_core *core = inst->core; in venc_pm_get_put()
657 static void venc_pm_touch(struct venus_inst *inst) in venc_pm_touch() argument
659 pm_runtime_mark_last_busy(inst->core->dev_enc); in venc_pm_touch()
662 static int venc_set_properties(struct venus_inst *inst) in venc_set_properties() argument
664 struct venc_controls *ctr = &inst->controls.enc; in venc_set_properties()
679 ret = venus_helper_set_work_mode(inst); in venc_set_properties()
685 frate.framerate = inst->fps * (1 << 16); in venc_set_properties()
687 ret = hfi_session_set_property(inst, ptype, &frate); in venc_set_properties()
691 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { in venc_set_properties()
702 ret = hfi_session_set_property(inst, ptype, &info); in venc_set_properties()
712 ret = hfi_session_set_property(inst, ptype, &entropy); in venc_set_properties()
723 ret = hfi_session_set_property(inst, ptype, &deblock); in venc_set_properties()
733 ret = hfi_session_set_property(inst, ptype, &h264_transform); in venc_set_properties()
739 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || in venc_set_properties()
740 inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
748 ret = hfi_session_set_property(inst, ptype, &idrp); in venc_set_properties()
753 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC && in venc_set_properties()
778 ret = hfi_session_set_property(inst, ptype, &hdr10); in venc_set_properties()
787 ret = hfi_session_set_property(inst, ptype, &max_num_b_frames); in venc_set_properties()
796 ret = hfi_session_set_property(inst, ptype, &intra_period); in venc_set_properties()
812 ret = hfi_session_set_property(inst, ptype, &rate_control); in venc_set_properties()
821 ret = hfi_session_set_property(inst, ptype, &quality); in venc_set_properties()
835 ret = hfi_session_set_property(inst, ptype, &brate); in venc_set_properties()
839 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || in venc_set_properties()
840 inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
847 ret = hfi_session_set_property(inst, ptype, &en); in venc_set_properties()
861 ret = hfi_session_set_property(inst, ptype, &brate); in venc_set_properties()
866 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
876 ret = hfi_session_set_property(inst, ptype, &quant); in venc_set_properties()
880 if (inst->core->res->hfi_version == HFI_VERSION_4XX || in venc_set_properties()
881 inst->core->res->hfi_version == HFI_VERSION_6XX) { in venc_set_properties()
884 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
887 } else if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_VP8) { in venc_set_properties()
895 ret = hfi_session_set_property(inst, ptype, &quant_range_v2); in venc_set_properties()
899 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
902 } else if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_VP8) { in venc_set_properties()
911 ret = hfi_session_set_property(inst, ptype, &quant_range); in venc_set_properties()
921 ret = hfi_session_set_property(inst, ptype, <r_mode); in venc_set_properties()
925 switch (inst->hfi_codec) { in venc_set_properties()
953 ret = venus_helper_set_profile_level(inst, profile, level); in venc_set_properties()
957 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || in venc_set_properties()
958 inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
966 ret = hfi_session_set_property(inst, ptype, &en); in venc_set_properties()
969 if ((inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || in venc_set_properties()
970 inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) && in venc_set_properties()
979 mbs = ALIGN(inst->width, 16) * ALIGN(inst->height, 16); in venc_set_properties()
995 ret = hfi_session_set_property(inst, ptype, &intra_refresh); in venc_set_properties()
1003 static int venc_init_session(struct venus_inst *inst) in venc_init_session() argument
1007 ret = venus_helper_session_init(inst); in venc_init_session()
1013 ret = venus_helper_set_stride(inst, inst->out_width, in venc_init_session()
1014 inst->out_height); in venc_init_session()
1018 ret = venus_helper_set_input_resolution(inst, inst->width, in venc_init_session()
1019 inst->height); in venc_init_session()
1023 ret = venus_helper_set_output_resolution(inst, inst->width, in venc_init_session()
1024 inst->height, in venc_init_session()
1029 ret = venus_helper_set_color_format(inst, inst->fmt_out->pixfmt); in venc_init_session()
1033 ret = venc_set_properties(inst); in venc_init_session()
1039 hfi_session_deinit(inst); in venc_init_session()
1043 static int venc_out_num_buffers(struct venus_inst *inst, unsigned int *num) in venc_out_num_buffers() argument
1048 ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); in venc_out_num_buffers()
1061 struct venus_inst *inst = vb2_get_drv_priv(q); in venc_queue_setup() local
1062 struct venus_core *core = inst->core; in venc_queue_setup()
1068 *num_planes != inst->fmt_out->num_planes) in venc_queue_setup()
1072 *num_planes != inst->fmt_cap->num_planes) in venc_queue_setup()
1076 sizes[0] < inst->input_buf_size) in venc_queue_setup()
1080 sizes[0] < inst->output_buf_size) in venc_queue_setup()
1087 if (inst->nonblock) in venc_queue_setup()
1096 ret = venc_pm_get(inst); in venc_queue_setup()
1100 mutex_lock(&inst->lock); in venc_queue_setup()
1101 ret = venc_init_session(inst); in venc_queue_setup()
1102 mutex_unlock(&inst->lock); in venc_queue_setup()
1107 ret = venc_pm_put(inst, false); in venc_queue_setup()
1113 *num_planes = inst->fmt_out->num_planes; in venc_queue_setup()
1115 ret = venc_out_num_buffers(inst, &num); in venc_queue_setup()
1121 inst->num_input_bufs = *num_buffers; in venc_queue_setup()
1123 sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt, in venc_queue_setup()
1124 inst->out_width, in venc_queue_setup()
1125 inst->out_height); in venc_queue_setup()
1126 inst->input_buf_size = sizes[0]; in venc_queue_setup()
1129 *num_planes = inst->fmt_cap->num_planes; in venc_queue_setup()
1131 inst->num_output_bufs = *num_buffers; in venc_queue_setup()
1132 sizes[0] = venus_helper_get_framesz(inst->fmt_cap->pixfmt, in venc_queue_setup()
1133 inst->width, in venc_queue_setup()
1134 inst->height); in venc_queue_setup()
1135 sizes[0] = max(sizes[0], inst->output_buf_size); in venc_queue_setup()
1136 inst->output_buf_size = sizes[0]; in venc_queue_setup()
1145 venc_pm_put(inst, false); in venc_queue_setup()
1151 struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); in venc_buf_init() local
1153 inst->buf_count++; in venc_buf_init()
1158 static void venc_release_session(struct venus_inst *inst) in venc_release_session() argument
1162 venc_pm_get(inst); in venc_release_session()
1164 mutex_lock(&inst->lock); in venc_release_session()
1166 ret = hfi_session_deinit(inst); in venc_release_session()
1167 if (ret || inst->session_error) in venc_release_session()
1168 hfi_session_abort(inst); in venc_release_session()
1170 mutex_unlock(&inst->lock); in venc_release_session()
1172 venus_pm_load_scale(inst); in venc_release_session()
1173 INIT_LIST_HEAD(&inst->registeredbufs); in venc_release_session()
1174 venus_pm_release_core(inst); in venc_release_session()
1176 venc_pm_put(inst, false); in venc_release_session()
1181 struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); in venc_buf_cleanup() local
1185 mutex_lock(&inst->lock); in venc_buf_cleanup()
1187 if (!list_empty(&inst->registeredbufs)) in venc_buf_cleanup()
1189 mutex_unlock(&inst->lock); in venc_buf_cleanup()
1191 inst->buf_count--; in venc_buf_cleanup()
1192 if (!inst->buf_count) in venc_buf_cleanup()
1193 venc_release_session(inst); in venc_buf_cleanup()
1196 static int venc_verify_conf(struct venus_inst *inst) in venc_verify_conf() argument
1198 enum hfi_version ver = inst->core->res->hfi_version; in venc_verify_conf()
1202 if (!inst->num_input_bufs || !inst->num_output_bufs) in venc_verify_conf()
1205 ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); in venc_verify_conf()
1209 if (inst->num_output_bufs < bufreq.count_actual || in venc_verify_conf()
1210 inst->num_output_bufs < hfi_bufreq_get_count_min(&bufreq, ver)) in venc_verify_conf()
1213 ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); in venc_verify_conf()
1217 if (inst->num_input_bufs < bufreq.count_actual || in venc_verify_conf()
1218 inst->num_input_bufs < hfi_bufreq_get_count_min(&bufreq, ver)) in venc_verify_conf()
1226 struct venus_inst *inst = vb2_get_drv_priv(q); in venc_start_streaming() local
1229 mutex_lock(&inst->lock); in venc_start_streaming()
1232 inst->streamon_out = 1; in venc_start_streaming()
1234 inst->streamon_cap = 1; in venc_start_streaming()
1236 if (!(inst->streamon_out & inst->streamon_cap)) { in venc_start_streaming()
1237 mutex_unlock(&inst->lock); in venc_start_streaming()
1241 venus_helper_init_instance(inst); in venc_start_streaming()
1243 inst->sequence_cap = 0; in venc_start_streaming()
1244 inst->sequence_out = 0; in venc_start_streaming()
1246 ret = venc_pm_get(inst); in venc_start_streaming()
1250 ret = venus_pm_acquire_core(inst); in venc_start_streaming()
1254 ret = venc_pm_put(inst, true); in venc_start_streaming()
1258 ret = venc_set_properties(inst); in venc_start_streaming()
1262 ret = venc_verify_conf(inst); in venc_start_streaming()
1266 ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, in venc_start_streaming()
1267 inst->num_output_bufs, 0); in venc_start_streaming()
1271 ret = venus_helper_vb2_start_streaming(inst); in venc_start_streaming()
1275 inst->enc_state = VENUS_ENC_STATE_ENCODING; in venc_start_streaming()
1277 mutex_unlock(&inst->lock); in venc_start_streaming()
1282 venc_pm_put(inst, false); in venc_start_streaming()
1284 venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED); in venc_start_streaming()
1286 inst->streamon_out = 0; in venc_start_streaming()
1288 inst->streamon_cap = 0; in venc_start_streaming()
1289 mutex_unlock(&inst->lock); in venc_start_streaming()
1295 struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); in venc_vb2_buf_queue() local
1298 venc_pm_get_put(inst); in venc_vb2_buf_queue()
1300 mutex_lock(&inst->lock); in venc_vb2_buf_queue()
1302 if (inst->enc_state == VENUS_ENC_STATE_STOPPED) { in venc_vb2_buf_queue()
1303 vbuf->sequence = inst->sequence_cap++; in venc_vb2_buf_queue()
1307 mutex_unlock(&inst->lock); in venc_vb2_buf_queue()
1312 mutex_unlock(&inst->lock); in venc_vb2_buf_queue()
1325 static void venc_buf_done(struct venus_inst *inst, unsigned int buf_type, in venc_buf_done() argument
1333 venc_pm_touch(inst); in venc_buf_done()
1340 vbuf = venus_helper_find_buf(inst, type, tag); in venc_buf_done()
1351 vbuf->sequence = inst->sequence_cap++; in venc_buf_done()
1353 inst->enc_state == VENUS_ENC_STATE_DRAIN) { in venc_buf_done()
1354 inst->enc_state = VENUS_ENC_STATE_STOPPED; in venc_buf_done()
1357 vbuf->sequence = inst->sequence_out++; in venc_buf_done()
1363 static void venc_event_notify(struct venus_inst *inst, u32 event, in venc_event_notify() argument
1366 struct device *dev = inst->core->dev_enc; in venc_event_notify()
1368 venc_pm_touch(inst); in venc_event_notify()
1371 inst->session_error = true; in venc_event_notify()
1372 venus_helper_vb2_queue_error(inst); in venc_event_notify()
1373 dev_err(dev, "enc: event session error %x\n", inst->error); in venc_event_notify()
1390 struct venus_inst *inst = priv; in m2m_queue_init() local
1398 src_vq->drv_priv = inst; in m2m_queue_init()
1402 src_vq->dev = inst->core->dev; in m2m_queue_init()
1403 src_vq->lock = &inst->ctx_q_lock; in m2m_queue_init()
1404 if (inst->core->res->hfi_version == HFI_VERSION_1XX) in m2m_queue_init()
1415 dst_vq->drv_priv = inst; in m2m_queue_init()
1419 dst_vq->dev = inst->core->dev; in m2m_queue_init()
1420 dst_vq->lock = &inst->ctx_q_lock; in m2m_queue_init()
1424 static void venc_inst_init(struct venus_inst *inst) in venc_inst_init() argument
1426 inst->fmt_cap = &venc_formats[VENUS_FMT_H264]; in venc_inst_init()
1427 inst->fmt_out = &venc_formats[VENUS_FMT_NV12]; in venc_inst_init()
1428 inst->width = 1280; in venc_inst_init()
1429 inst->height = ALIGN(720, 32); in venc_inst_init()
1430 inst->out_width = 1280; in venc_inst_init()
1431 inst->out_height = 720; in venc_inst_init()
1432 inst->fps = 15; in venc_inst_init()
1433 inst->timeperframe.numerator = 1; in venc_inst_init()
1434 inst->timeperframe.denominator = 15; in venc_inst_init()
1435 inst->hfi_codec = HFI_VIDEO_CODEC_H264; in venc_inst_init()
1441 struct venus_inst *inst; in venc_open() local
1444 inst = kzalloc(sizeof(*inst), GFP_KERNEL); in venc_open()
1445 if (!inst) in venc_open()
1448 INIT_LIST_HEAD(&inst->dpbbufs); in venc_open()
1449 INIT_LIST_HEAD(&inst->registeredbufs); in venc_open()
1450 INIT_LIST_HEAD(&inst->internalbufs); in venc_open()
1451 INIT_LIST_HEAD(&inst->list); in venc_open()
1452 mutex_init(&inst->lock); in venc_open()
1453 mutex_init(&inst->ctx_q_lock); in venc_open()
1455 inst->core = core; in venc_open()
1456 inst->session_type = VIDC_SESSION_TYPE_ENC; in venc_open()
1457 inst->clk_data.core_id = VIDC_CORE_ID_DEFAULT; in venc_open()
1458 inst->core_acquired = false; in venc_open()
1459 inst->nonblock = file->f_flags & O_NONBLOCK; in venc_open()
1461 if (inst->enc_state == VENUS_ENC_STATE_DEINIT) in venc_open()
1462 inst->enc_state = VENUS_ENC_STATE_INIT; in venc_open()
1464 venus_helper_init_instance(inst); in venc_open()
1466 ret = venc_ctrl_init(inst); in venc_open()
1470 ret = hfi_session_create(inst, &venc_hfi_ops); in venc_open()
1474 venc_inst_init(inst); in venc_open()
1480 inst->m2m_dev = v4l2_m2m_init(&venc_m2m_ops); in venc_open()
1481 if (IS_ERR(inst->m2m_dev)) { in venc_open()
1482 ret = PTR_ERR(inst->m2m_dev); in venc_open()
1486 inst->m2m_ctx = v4l2_m2m_ctx_init(inst->m2m_dev, inst, m2m_queue_init); in venc_open()
1487 if (IS_ERR(inst->m2m_ctx)) { in venc_open()
1488 ret = PTR_ERR(inst->m2m_ctx); in venc_open()
1492 v4l2_fh_init(&inst->fh, core->vdev_enc); in venc_open()
1494 inst->fh.ctrl_handler = &inst->ctrl_handler; in venc_open()
1495 v4l2_fh_add(&inst->fh); in venc_open()
1496 inst->fh.m2m_ctx = inst->m2m_ctx; in venc_open()
1497 file->private_data = &inst->fh; in venc_open()
1502 v4l2_m2m_release(inst->m2m_dev); in venc_open()
1504 hfi_session_destroy(inst); in venc_open()
1506 venc_ctrl_deinit(inst); in venc_open()
1508 kfree(inst); in venc_open()
1514 struct venus_inst *inst = to_inst(file); in venc_close() local
1516 venc_pm_get(inst); in venc_close()
1518 v4l2_m2m_ctx_release(inst->m2m_ctx); in venc_close()
1519 v4l2_m2m_release(inst->m2m_dev); in venc_close()
1520 venc_ctrl_deinit(inst); in venc_close()
1521 hfi_session_destroy(inst); in venc_close()
1522 mutex_destroy(&inst->lock); in venc_close()
1523 mutex_destroy(&inst->ctx_q_lock); in venc_close()
1524 v4l2_fh_del(&inst->fh); in venc_close()
1525 v4l2_fh_exit(&inst->fh); in venc_close()
1527 inst->enc_state = VENUS_ENC_STATE_DEINIT; in venc_close()
1529 venc_pm_put(inst, false); in venc_close()
1531 kfree(inst); in venc_close()