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()
418 inst->timeperframe = *timeperframe; in venc_s_parm()
419 inst->fps = fps; in venc_s_parm()
426 struct venus_inst *inst = to_inst(file); in venc_g_parm() local
433 a->parm.output.timeperframe = inst->timeperframe; in venc_g_parm()
441 struct venus_inst *inst = to_inst(file); in venc_enum_framesizes() local
446 fmt = find_format(inst, fsize->pixel_format, in venc_enum_framesizes()
449 fmt = find_format(inst, fsize->pixel_format, in venc_enum_framesizes()
458 fsize->stepwise.min_width = frame_width_min(inst); in venc_enum_framesizes()
459 fsize->stepwise.max_width = frame_width_max(inst); in venc_enum_framesizes()
460 fsize->stepwise.step_width = frame_width_step(inst); in venc_enum_framesizes()
461 fsize->stepwise.min_height = frame_height_min(inst); in venc_enum_framesizes()
462 fsize->stepwise.max_height = frame_height_max(inst); in venc_enum_framesizes()
463 fsize->stepwise.step_height = frame_height_step(inst); in venc_enum_framesizes()
471 struct venus_inst *inst = to_inst(file); in venc_enum_frameintervals() local
477 fmt = find_format(inst, fival->pixel_format, in venc_enum_frameintervals()
480 fmt = find_format(inst, fival->pixel_format, in venc_enum_frameintervals()
492 if (fival->width > frame_width_max(inst) || in venc_enum_frameintervals()
493 fival->width < frame_width_min(inst) || in venc_enum_frameintervals()
494 fival->height > frame_height_max(inst) || in venc_enum_frameintervals()
495 fival->height < frame_height_min(inst)) in venc_enum_frameintervals()
498 if (IS_V1(inst->core)) { in venc_enum_frameintervals()
504 fival->stepwise.min.denominator = frate_max(inst) / framerate_factor; in venc_enum_frameintervals()
506 fival->stepwise.max.denominator = frate_min(inst) / framerate_factor; in venc_enum_frameintervals()
508 fival->stepwise.step.denominator = frate_max(inst) / framerate_factor; in venc_enum_frameintervals()
529 struct venus_inst *inst = to_inst(file); in venc_encoder_cmd() local
537 mutex_lock(&inst->lock); in venc_encoder_cmd()
540 inst->enc_state == VENUS_ENC_STATE_ENCODING) { in venc_encoder_cmd()
545 if (!(inst->streamon_out && inst->streamon_cap)) in venc_encoder_cmd()
552 ret = hfi_session_process_buf(inst, &fdata); in venc_encoder_cmd()
554 inst->enc_state = VENUS_ENC_STATE_DRAIN; in venc_encoder_cmd()
556 if (inst->enc_state == VENUS_ENC_STATE_DRAIN) { in venc_encoder_cmd()
560 if (inst->enc_state == VENUS_ENC_STATE_STOPPED) { in venc_encoder_cmd()
561 vb2_clear_last_buffer_dequeued(&inst->fh.m2m_ctx->cap_q_ctx.q); in venc_encoder_cmd()
562 inst->enc_state = VENUS_ENC_STATE_ENCODING; in venc_encoder_cmd()
567 mutex_unlock(&inst->lock); in venc_encoder_cmd()
602 static int venc_pm_get(struct venus_inst *inst) in venc_pm_get() argument
604 struct venus_core *core = inst->core; in venc_pm_get()
615 static int venc_pm_put(struct venus_inst *inst, bool autosuspend) in venc_pm_put() argument
617 struct venus_core *core = inst->core; in venc_pm_put()
633 static int venc_pm_get_put(struct venus_inst *inst) in venc_pm_get_put() argument
635 struct venus_core *core = inst->core; in venc_pm_get_put()
655 static void venc_pm_touch(struct venus_inst *inst) in venc_pm_touch() argument
657 pm_runtime_mark_last_busy(inst->core->dev_enc); in venc_pm_touch()
660 static int venc_set_properties(struct venus_inst *inst) in venc_set_properties() argument
662 struct venc_controls *ctr = &inst->controls.enc; in venc_set_properties()
677 ret = venus_helper_set_work_mode(inst); in venc_set_properties()
683 frate.framerate = inst->fps * (1 << 16); in venc_set_properties()
685 ret = hfi_session_set_property(inst, ptype, &frate); in venc_set_properties()
689 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264) { in venc_set_properties()
700 ret = hfi_session_set_property(inst, ptype, &info); in venc_set_properties()
710 ret = hfi_session_set_property(inst, ptype, &entropy); in venc_set_properties()
721 ret = hfi_session_set_property(inst, ptype, &deblock); in venc_set_properties()
731 ret = hfi_session_set_property(inst, ptype, &h264_transform); in venc_set_properties()
739 ret = hfi_session_set_property(inst, ptype, &ctr->h264_hier_layers); in venc_set_properties()
744 ret = hfi_session_set_property(inst, ptype, &ctr->layer_bitrate); in venc_set_properties()
753 ret = hfi_session_set_property(inst, ptype, &brate); in venc_set_properties()
760 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || in venc_set_properties()
761 inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
769 ret = hfi_session_set_property(inst, ptype, &idrp); in venc_set_properties()
774 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC && in venc_set_properties()
799 ret = hfi_session_set_property(inst, ptype, &hdr10); in venc_set_properties()
808 ret = hfi_session_set_property(inst, ptype, &max_num_b_frames); in venc_set_properties()
817 ret = hfi_session_set_property(inst, ptype, &intra_period); in venc_set_properties()
833 ret = hfi_session_set_property(inst, ptype, &rate_control); in venc_set_properties()
842 ret = hfi_session_set_property(inst, ptype, &quality); in venc_set_properties()
857 ret = hfi_session_set_property(inst, ptype, &brate); in venc_set_properties()
870 ret = hfi_session_set_property(inst, ptype, &brate); in venc_set_properties()
875 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || in venc_set_properties()
876 inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
883 ret = hfi_session_set_property(inst, ptype, &en); in venc_set_properties()
889 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
899 ret = hfi_session_set_property(inst, ptype, &quant); in venc_set_properties()
903 if (inst->core->res->hfi_version == HFI_VERSION_4XX || in venc_set_properties()
904 inst->core->res->hfi_version == HFI_VERSION_6XX) { in venc_set_properties()
907 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
910 } else if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_VP8) { in venc_set_properties()
918 ret = hfi_session_set_property(inst, ptype, &quant_range_v2); in venc_set_properties()
922 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
925 } else if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_VP8) { in venc_set_properties()
934 ret = hfi_session_set_property(inst, ptype, &quant_range); in venc_set_properties()
944 ret = hfi_session_set_property(inst, ptype, &ltr_mode); in venc_set_properties()
948 switch (inst->hfi_codec) { in venc_set_properties()
976 ret = venus_helper_set_profile_level(inst, profile, level); in venc_set_properties()
980 if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || in venc_set_properties()
981 inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { in venc_set_properties()
989 ret = hfi_session_set_property(inst, ptype, &en); in venc_set_properties()
992 if ((inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || in venc_set_properties()
993 inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) && in venc_set_properties()
1002 mbs = ALIGN(inst->width, 16) * ALIGN(inst->height, 16); in venc_set_properties()
1018 ret = hfi_session_set_property(inst, ptype, &intra_refresh); in venc_set_properties()
1026 static int venc_init_session(struct venus_inst *inst) in venc_init_session() argument
1030 ret = venus_helper_session_init(inst); in venc_init_session()
1036 ret = venus_helper_set_stride(inst, inst->out_width, in venc_init_session()
1037 inst->out_height); in venc_init_session()
1041 ret = venus_helper_set_input_resolution(inst, inst->width, in venc_init_session()
1042 inst->height); in venc_init_session()
1046 ret = venus_helper_set_output_resolution(inst, inst->width, in venc_init_session()
1047 inst->height, in venc_init_session()
1052 ret = venus_helper_set_color_format(inst, inst->fmt_out->pixfmt); in venc_init_session()
1056 ret = venc_set_properties(inst); in venc_init_session()
1062 hfi_session_deinit(inst); in venc_init_session()
1066 static int venc_out_num_buffers(struct venus_inst *inst, unsigned int *num) in venc_out_num_buffers() argument
1071 ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); in venc_out_num_buffers()
1084 struct venus_inst *inst = vb2_get_drv_priv(q); in venc_queue_setup() local
1085 struct venus_core *core = inst->core; in venc_queue_setup()
1091 *num_planes != inst->fmt_out->num_planes) in venc_queue_setup()
1095 *num_planes != inst->fmt_cap->num_planes) in venc_queue_setup()
1099 sizes[0] < inst->input_buf_size) in venc_queue_setup()
1103 sizes[0] < inst->output_buf_size) in venc_queue_setup()
1110 if (inst->nonblock) in venc_queue_setup()
1119 ret = venc_pm_get(inst); in venc_queue_setup()
1123 mutex_lock(&inst->lock); in venc_queue_setup()
1124 ret = venc_init_session(inst); in venc_queue_setup()
1125 mutex_unlock(&inst->lock); in venc_queue_setup()
1130 ret = venc_pm_put(inst, false); in venc_queue_setup()
1136 *num_planes = inst->fmt_out->num_planes; in venc_queue_setup()
1138 ret = venc_out_num_buffers(inst, &num); in venc_queue_setup()
1144 inst->num_input_bufs = *num_buffers; in venc_queue_setup()
1146 sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt, in venc_queue_setup()
1147 inst->out_width, in venc_queue_setup()
1148 inst->out_height); in venc_queue_setup()
1149 inst->input_buf_size = sizes[0]; in venc_queue_setup()
1152 *num_planes = inst->fmt_cap->num_planes; in venc_queue_setup()
1154 inst->num_output_bufs = *num_buffers; in venc_queue_setup()
1155 sizes[0] = venus_helper_get_framesz(inst->fmt_cap->pixfmt, in venc_queue_setup()
1156 inst->width, in venc_queue_setup()
1157 inst->height); in venc_queue_setup()
1158 sizes[0] = max(sizes[0], inst->output_buf_size); in venc_queue_setup()
1159 inst->output_buf_size = sizes[0]; in venc_queue_setup()
1168 venc_pm_put(inst, false); in venc_queue_setup()
1174 struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); in venc_buf_init() local
1176 inst->buf_count++; in venc_buf_init()
1181 static void venc_release_session(struct venus_inst *inst) in venc_release_session() argument
1185 venc_pm_get(inst); in venc_release_session()
1187 mutex_lock(&inst->lock); in venc_release_session()
1189 ret = hfi_session_deinit(inst); in venc_release_session()
1190 if (ret || inst->session_error) in venc_release_session()
1191 hfi_session_abort(inst); in venc_release_session()
1193 mutex_unlock(&inst->lock); in venc_release_session()
1195 venus_pm_load_scale(inst); in venc_release_session()
1196 INIT_LIST_HEAD(&inst->registeredbufs); in venc_release_session()
1197 venus_pm_release_core(inst); in venc_release_session()
1199 venc_pm_put(inst, false); in venc_release_session()
1204 struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); in venc_buf_cleanup() local
1208 mutex_lock(&inst->lock); in venc_buf_cleanup()
1210 if (!list_empty(&inst->registeredbufs)) in venc_buf_cleanup()
1212 mutex_unlock(&inst->lock); in venc_buf_cleanup()
1214 inst->buf_count--; in venc_buf_cleanup()
1215 if (!inst->buf_count) in venc_buf_cleanup()
1216 venc_release_session(inst); in venc_buf_cleanup()
1219 static int venc_verify_conf(struct venus_inst *inst) in venc_verify_conf() argument
1221 enum hfi_version ver = inst->core->res->hfi_version; in venc_verify_conf()
1225 if (!inst->num_input_bufs || !inst->num_output_bufs) in venc_verify_conf()
1228 ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); in venc_verify_conf()
1232 if (inst->num_output_bufs < bufreq.count_actual || in venc_verify_conf()
1233 inst->num_output_bufs < hfi_bufreq_get_count_min(&bufreq, ver)) in venc_verify_conf()
1236 ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); in venc_verify_conf()
1240 if (inst->num_input_bufs < bufreq.count_actual || in venc_verify_conf()
1241 inst->num_input_bufs < hfi_bufreq_get_count_min(&bufreq, ver)) in venc_verify_conf()
1249 struct venus_inst *inst = vb2_get_drv_priv(q); in venc_start_streaming() local
1252 mutex_lock(&inst->lock); in venc_start_streaming()
1255 inst->streamon_out = 1; in venc_start_streaming()
1257 inst->streamon_cap = 1; in venc_start_streaming()
1259 if (!(inst->streamon_out & inst->streamon_cap)) { in venc_start_streaming()
1260 mutex_unlock(&inst->lock); in venc_start_streaming()
1264 venus_helper_init_instance(inst); in venc_start_streaming()
1266 inst->sequence_cap = 0; in venc_start_streaming()
1267 inst->sequence_out = 0; in venc_start_streaming()
1269 ret = venc_pm_get(inst); in venc_start_streaming()
1273 ret = venus_pm_acquire_core(inst); in venc_start_streaming()
1277 ret = venc_pm_put(inst, true); in venc_start_streaming()
1281 ret = venc_set_properties(inst); in venc_start_streaming()
1285 ret = venc_verify_conf(inst); in venc_start_streaming()
1289 ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, in venc_start_streaming()
1290 inst->num_output_bufs, 0); in venc_start_streaming()
1294 ret = venus_helper_vb2_start_streaming(inst); in venc_start_streaming()
1298 inst->enc_state = VENUS_ENC_STATE_ENCODING; in venc_start_streaming()
1300 mutex_unlock(&inst->lock); in venc_start_streaming()
1305 venc_pm_put(inst, false); in venc_start_streaming()
1307 venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED); in venc_start_streaming()
1309 inst->streamon_out = 0; in venc_start_streaming()
1311 inst->streamon_cap = 0; in venc_start_streaming()
1312 mutex_unlock(&inst->lock); in venc_start_streaming()
1318 struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); in venc_vb2_buf_queue() local
1321 venc_pm_get_put(inst); in venc_vb2_buf_queue()
1323 mutex_lock(&inst->lock); in venc_vb2_buf_queue()
1325 if (inst->enc_state == VENUS_ENC_STATE_STOPPED) { in venc_vb2_buf_queue()
1326 vbuf->sequence = inst->sequence_cap++; in venc_vb2_buf_queue()
1330 mutex_unlock(&inst->lock); in venc_vb2_buf_queue()
1335 mutex_unlock(&inst->lock); in venc_vb2_buf_queue()
1348 static void venc_buf_done(struct venus_inst *inst, unsigned int buf_type, in venc_buf_done() argument
1356 venc_pm_touch(inst); in venc_buf_done()
1363 vbuf = venus_helper_find_buf(inst, type, tag); in venc_buf_done()
1374 vbuf->sequence = inst->sequence_cap++; in venc_buf_done()
1376 inst->enc_state == VENUS_ENC_STATE_DRAIN) { in venc_buf_done()
1377 inst->enc_state = VENUS_ENC_STATE_STOPPED; in venc_buf_done()
1380 vbuf->sequence = inst->sequence_out++; in venc_buf_done()
1386 static void venc_event_notify(struct venus_inst *inst, u32 event, in venc_event_notify() argument
1389 struct device *dev = inst->core->dev_enc; in venc_event_notify()
1391 venc_pm_touch(inst); in venc_event_notify()
1394 inst->session_error = true; in venc_event_notify()
1395 venus_helper_vb2_queue_error(inst); in venc_event_notify()
1396 dev_err(dev, "enc: event session error %x\n", inst->error); in venc_event_notify()
1413 struct venus_inst *inst = priv; in m2m_queue_init() local
1421 src_vq->drv_priv = inst; in m2m_queue_init()
1425 src_vq->dev = inst->core->dev; in m2m_queue_init()
1426 src_vq->lock = &inst->ctx_q_lock; in m2m_queue_init()
1427 if (inst->core->res->hfi_version == HFI_VERSION_1XX) in m2m_queue_init()
1438 dst_vq->drv_priv = inst; in m2m_queue_init()
1442 dst_vq->dev = inst->core->dev; in m2m_queue_init()
1443 dst_vq->lock = &inst->ctx_q_lock; in m2m_queue_init()
1447 static void venc_inst_init(struct venus_inst *inst) in venc_inst_init() argument
1449 inst->fmt_cap = &venc_formats[VENUS_FMT_H264]; in venc_inst_init()
1450 inst->fmt_out = &venc_formats[VENUS_FMT_NV12]; in venc_inst_init()
1451 inst->width = 1280; in venc_inst_init()
1452 inst->height = ALIGN(720, 32); in venc_inst_init()
1453 inst->out_width = 1280; in venc_inst_init()
1454 inst->out_height = 720; in venc_inst_init()
1455 inst->fps = 15; in venc_inst_init()
1456 inst->timeperframe.numerator = 1; in venc_inst_init()
1457 inst->timeperframe.denominator = 15; in venc_inst_init()
1458 inst->hfi_codec = HFI_VIDEO_CODEC_H264; in venc_inst_init()
1464 struct venus_inst *inst; in venc_open() local
1467 inst = kzalloc(sizeof(*inst), GFP_KERNEL); in venc_open()
1468 if (!inst) in venc_open()
1471 INIT_LIST_HEAD(&inst->dpbbufs); in venc_open()
1472 INIT_LIST_HEAD(&inst->registeredbufs); in venc_open()
1473 INIT_LIST_HEAD(&inst->internalbufs); in venc_open()
1474 INIT_LIST_HEAD(&inst->list); in venc_open()
1475 mutex_init(&inst->lock); in venc_open()
1476 mutex_init(&inst->ctx_q_lock); in venc_open()
1478 inst->core = core; in venc_open()
1479 inst->session_type = VIDC_SESSION_TYPE_ENC; in venc_open()
1480 inst->clk_data.core_id = VIDC_CORE_ID_DEFAULT; in venc_open()
1481 inst->core_acquired = false; in venc_open()
1482 inst->nonblock = file->f_flags & O_NONBLOCK; in venc_open()
1484 if (inst->enc_state == VENUS_ENC_STATE_DEINIT) in venc_open()
1485 inst->enc_state = VENUS_ENC_STATE_INIT; in venc_open()
1487 venus_helper_init_instance(inst); in venc_open()
1489 ret = venc_ctrl_init(inst); in venc_open()
1493 venc_inst_init(inst); in venc_open()
1499 inst->m2m_dev = v4l2_m2m_init(&venc_m2m_ops); in venc_open()
1500 if (IS_ERR(inst->m2m_dev)) { in venc_open()
1501 ret = PTR_ERR(inst->m2m_dev); in venc_open()
1505 inst->m2m_ctx = v4l2_m2m_ctx_init(inst->m2m_dev, inst, m2m_queue_init); in venc_open()
1506 if (IS_ERR(inst->m2m_ctx)) { in venc_open()
1507 ret = PTR_ERR(inst->m2m_ctx); in venc_open()
1511 ret = hfi_session_create(inst, &venc_hfi_ops); in venc_open()
1515 v4l2_fh_init(&inst->fh, core->vdev_enc); in venc_open()
1517 inst->fh.ctrl_handler = &inst->ctrl_handler; in venc_open()
1518 v4l2_fh_add(&inst->fh); in venc_open()
1519 inst->fh.m2m_ctx = inst->m2m_ctx; in venc_open()
1520 file->private_data = &inst->fh; in venc_open()
1525 v4l2_m2m_ctx_release(inst->m2m_ctx); in venc_open()
1527 v4l2_m2m_release(inst->m2m_dev); in venc_open()
1529 v4l2_ctrl_handler_free(&inst->ctrl_handler); in venc_open()
1531 kfree(inst); in venc_open()
1537 struct venus_inst *inst = to_inst(file); in venc_close() local
1539 venc_pm_get(inst); in venc_close()
1540 venus_close_common(inst); in venc_close()
1541 inst->enc_state = VENUS_ENC_STATE_DEINIT; in venc_close()
1542 venc_pm_put(inst, false); in venc_close()
1544 kfree(inst); in venc_close()