Lines Matching +full:rk3399 +full:- +full:vdec

1 // SPDX-License-Identifier: GPL-2.0
9 * Based on s5p-mfc driver by Samsung Electronics Co., Ltd.
22 #include <media/v4l2-event.h>
23 #include <media/v4l2-mem2mem.h>
24 #include <media/videobuf2-core.h>
25 #include <media/videobuf2-vmalloc.h>
31 #define DRIVER_NAME "hantro-vpu"
36 "Debug level - higher value produces more verbose messages");
42 ctrl = v4l2_ctrl_find(&ctx->ctrl_handler, id); in hantro_get_ctrl()
43 return ctrl ? ctrl->p_cur.p : NULL; in hantro_get_ctrl()
48 struct vb2_queue *q = v4l2_m2m_get_dst_vq(ctx->fh.m2m_ctx); in hantro_get_ref()
67 src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); in hantro_job_finish_no_pm()
68 dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); in hantro_job_finish_no_pm()
75 src->sequence = ctx->sequence_out++; in hantro_job_finish_no_pm()
76 dst->sequence = ctx->sequence_cap++; in hantro_job_finish_no_pm()
78 if (v4l2_m2m_is_last_draining_src_buf(ctx->fh.m2m_ctx, src)) { in hantro_job_finish_no_pm()
79 dst->flags |= V4L2_BUF_FLAG_LAST; in hantro_job_finish_no_pm()
80 v4l2_event_queue_fh(&ctx->fh, &hantro_eos_event); in hantro_job_finish_no_pm()
81 v4l2_m2m_mark_stopped(ctx->fh.m2m_ctx); in hantro_job_finish_no_pm()
84 v4l2_m2m_buf_done_and_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx, in hantro_job_finish_no_pm()
92 pm_runtime_mark_last_busy(vpu->dev); in hantro_job_finish()
93 pm_runtime_put_autosuspend(vpu->dev); in hantro_job_finish()
95 clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks); in hantro_job_finish()
104 v4l2_m2m_get_curr_priv(vpu->m2m_dev); in hantro_irq_done()
111 if (cancel_delayed_work(&vpu->watchdog_work)) { in hantro_irq_done()
112 if (result == VB2_BUF_STATE_DONE && ctx->codec_ops->done) in hantro_irq_done()
113 ctx->codec_ops->done(ctx); in hantro_irq_done()
125 ctx = v4l2_m2m_get_curr_priv(vpu->m2m_dev); in hantro_watchdog()
128 ctx->codec_ops->reset(ctx); in hantro_watchdog()
138 v4l2_ctrl_request_setup(src_buf->vb2_buf.req_obj.req, in hantro_start_prepare_run()
139 &ctx->ctrl_handler); in hantro_start_prepare_run()
141 if (!ctx->is_encoder && !ctx->dev->variant->late_postproc) { in hantro_start_prepare_run()
142 if (hantro_needs_postproc(ctx, ctx->vpu_dst_fmt)) in hantro_start_prepare_run()
153 if (!ctx->is_encoder && ctx->dev->variant->late_postproc) { in hantro_end_prepare_run()
154 if (hantro_needs_postproc(ctx, ctx->vpu_dst_fmt)) in hantro_end_prepare_run()
161 v4l2_ctrl_request_complete(src_buf->vb2_buf.req_obj.req, in hantro_end_prepare_run()
162 &ctx->ctrl_handler); in hantro_end_prepare_run()
165 schedule_delayed_work(&ctx->dev->watchdog_work, in hantro_end_prepare_run()
178 ret = pm_runtime_resume_and_get(ctx->dev->dev); in device_run()
182 ret = clk_bulk_enable(ctx->dev->variant->num_clocks, ctx->dev->clocks); in device_run()
188 if (ctx->codec_ops->run(ctx)) in device_run()
194 hantro_job_finish_no_pm(ctx->dev, ctx, VB2_BUF_STATE_ERROR); in device_run()
207 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; in queue_init()
208 src_vq->io_modes = VB2_MMAP | VB2_DMABUF; in queue_init()
209 src_vq->drv_priv = ctx; in queue_init()
210 src_vq->ops = &hantro_queue_ops; in queue_init()
211 src_vq->mem_ops = &vb2_dma_contig_memops; in queue_init()
218 src_vq->dma_attrs = DMA_ATTR_ALLOC_SINGLE_PAGES | in queue_init()
220 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); in queue_init()
221 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; in queue_init()
222 src_vq->lock = &ctx->dev->vpu_mutex; in queue_init()
223 src_vq->dev = ctx->dev->v4l2_dev.dev; in queue_init()
224 src_vq->supports_requests = true; in queue_init()
230 dst_vq->bidirectional = true; in queue_init()
231 dst_vq->mem_ops = &vb2_dma_contig_memops; in queue_init()
232 dst_vq->dma_attrs = DMA_ATTR_ALLOC_SINGLE_PAGES; in queue_init()
237 if (!ctx->is_encoder) in queue_init()
238 dst_vq->dma_attrs |= DMA_ATTR_NO_KERNEL_MAPPING; in queue_init()
240 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; in queue_init()
241 dst_vq->io_modes = VB2_MMAP | VB2_DMABUF; in queue_init()
242 dst_vq->drv_priv = ctx; in queue_init()
243 dst_vq->ops = &hantro_queue_ops; in queue_init()
244 dst_vq->buf_struct_size = sizeof(struct hantro_decoded_buffer); in queue_init()
245 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; in queue_init()
246 dst_vq->lock = &ctx->dev->vpu_mutex; in queue_init()
247 dst_vq->dev = ctx->dev->v4l2_dev.dev; in queue_init()
256 ctx = container_of(ctrl->handler, in hantro_try_ctrl()
259 if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) { in hantro_try_ctrl()
260 const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps; in hantro_try_ctrl()
262 if (sps->chroma_format_idc > 1) in hantro_try_ctrl()
264 return -EINVAL; in hantro_try_ctrl()
265 if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8) in hantro_try_ctrl()
267 return -EINVAL; in hantro_try_ctrl()
268 if (sps->bit_depth_luma_minus8 != 0) in hantro_try_ctrl()
269 /* Only 8-bit is supported */ in hantro_try_ctrl()
270 return -EINVAL; in hantro_try_ctrl()
271 } else if (ctrl->id == V4L2_CID_STATELESS_HEVC_SPS) { in hantro_try_ctrl()
272 const struct v4l2_ctrl_hevc_sps *sps = ctrl->p_new.p_hevc_sps; in hantro_try_ctrl()
274 if (sps->bit_depth_luma_minus8 != 0 && sps->bit_depth_luma_minus8 != 2) in hantro_try_ctrl()
275 /* Only 8-bit and 10-bit are supported */ in hantro_try_ctrl()
276 return -EINVAL; in hantro_try_ctrl()
278 ctx->bit_depth = sps->bit_depth_luma_minus8 + 8; in hantro_try_ctrl()
279 } else if (ctrl->id == V4L2_CID_STATELESS_VP9_FRAME) { in hantro_try_ctrl()
280 const struct v4l2_ctrl_vp9_frame *dec_params = ctrl->p_new.p_vp9_frame; in hantro_try_ctrl()
283 if (dec_params->profile != 0) in hantro_try_ctrl()
284 return -EINVAL; in hantro_try_ctrl()
293 ctx = container_of(ctrl->handler, in hantro_jpeg_s_ctrl()
296 vpu_debug(1, "s_ctrl: id = %d, val = %d\n", ctrl->id, ctrl->val); in hantro_jpeg_s_ctrl()
298 switch (ctrl->id) { in hantro_jpeg_s_ctrl()
300 ctx->jpeg_quality = ctrl->val; in hantro_jpeg_s_ctrl()
303 return -EINVAL; in hantro_jpeg_s_ctrl()
313 ctx = container_of(ctrl->handler, in hantro_vp9_s_ctrl()
316 switch (ctrl->id) { in hantro_vp9_s_ctrl()
318 ctx->bit_depth = ctrl->p_new.p_vp9_frame->bit_depth; in hantro_vp9_s_ctrl()
321 return -EINVAL; in hantro_vp9_s_ctrl()
510 v4l2_ctrl_handler_init(&ctx->ctrl_handler, num_ctrls); in hantro_ctrls_setup()
516 v4l2_ctrl_new_custom(&ctx->ctrl_handler, in hantro_ctrls_setup()
518 if (ctx->ctrl_handler.error) { in hantro_ctrls_setup()
521 ctx->ctrl_handler.error); in hantro_ctrls_setup()
522 v4l2_ctrl_handler_free(&ctx->ctrl_handler); in hantro_ctrls_setup()
523 return ctx->ctrl_handler.error; in hantro_ctrls_setup()
526 return v4l2_ctrl_handler_setup(&ctx->ctrl_handler); in hantro_ctrls_setup()
546 * as vdev and ctx->fh), which have proper locking done in respective in hantro_open()
552 return -ENOMEM; in hantro_open()
554 ctx->dev = vpu; in hantro_open()
555 if (func->id == MEDIA_ENT_F_PROC_VIDEO_ENCODER) { in hantro_open()
556 allowed_codecs = vpu->variant->codec & HANTRO_ENCODERS; in hantro_open()
557 ctx->is_encoder = true; in hantro_open()
558 } else if (func->id == MEDIA_ENT_F_PROC_VIDEO_DECODER) { in hantro_open()
559 allowed_codecs = vpu->variant->codec & HANTRO_DECODERS; in hantro_open()
560 ctx->is_encoder = false; in hantro_open()
562 ret = -ENODEV; in hantro_open()
566 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(vpu->m2m_dev, ctx, queue_init); in hantro_open()
567 if (IS_ERR(ctx->fh.m2m_ctx)) { in hantro_open()
568 ret = PTR_ERR(ctx->fh.m2m_ctx); in hantro_open()
572 v4l2_fh_init(&ctx->fh, vdev); in hantro_open()
573 filp->private_data = &ctx->fh; in hantro_open()
574 v4l2_fh_add(&ctx->fh); in hantro_open()
583 ctx->fh.ctrl_handler = &ctx->ctrl_handler; in hantro_open()
588 v4l2_fh_del(&ctx->fh); in hantro_open()
589 v4l2_fh_exit(&ctx->fh); in hantro_open()
598 container_of(filp->private_data, struct hantro_ctx, fh); in hantro_release()
604 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); in hantro_release()
605 v4l2_fh_del(&ctx->fh); in hantro_release()
606 v4l2_fh_exit(&ctx->fh); in hantro_release()
607 v4l2_ctrl_handler_free(&ctx->ctrl_handler); in hantro_release()
624 { .compatible = "rockchip,px30-vpu", .data = &px30_vpu_variant, },
625 { .compatible = "rockchip,rk3036-vpu", .data = &rk3036_vpu_variant, },
626 { .compatible = "rockchip,rk3066-vpu", .data = &rk3066_vpu_variant, },
627 { .compatible = "rockchip,rk3288-vpu", .data = &rk3288_vpu_variant, },
628 { .compatible = "rockchip,rk3328-vpu", .data = &rk3328_vpu_variant, },
629 { .compatible = "rockchip,rk3399-vpu", .data = &rk3399_vpu_variant, },
630 { .compatible = "rockchip,rk3568-vepu", .data = &rk3568_vepu_variant, },
631 { .compatible = "rockchip,rk3568-vpu", .data = &rk3568_vpu_variant, },
634 { .compatible = "nxp,imx8mm-vpu-g1", .data = &imx8mm_vpu_g1_variant, },
635 { .compatible = "nxp,imx8mq-vpu", .data = &imx8mq_vpu_variant, },
636 { .compatible = "nxp,imx8mq-vpu-g1", .data = &imx8mq_vpu_g1_variant },
637 { .compatible = "nxp,imx8mq-vpu-g2", .data = &imx8mq_vpu_g2_variant },
640 { .compatible = "microchip,sama5d4-vdec", .data = &sama5d4_vdec_variant, },
643 { .compatible = "allwinner,sun50i-h6-vpu-g2", .data = &sunxi_vpu_variant, },
658 entity->obj_type = MEDIA_ENTITY_TYPE_BASE; in hantro_register_entity()
660 entity->info.dev.major = VIDEO_MAJOR; in hantro_register_entity()
661 entity->info.dev.minor = vdev->minor; in hantro_register_entity()
664 name = devm_kasprintf(mdev->dev, GFP_KERNEL, "%s-%s", vdev->name, in hantro_register_entity()
667 return -ENOMEM; in hantro_register_entity()
669 entity->name = name; in hantro_register_entity()
670 entity->function = function; in hantro_register_entity()
686 struct media_device *mdev = &vpu->mdev; in hantro_attach_func()
691 func->source_pad.flags = MEDIA_PAD_FL_SOURCE; in hantro_attach_func()
692 ret = hantro_register_entity(mdev, &func->vdev.entity, "source", in hantro_attach_func()
693 &func->source_pad, 1, MEDIA_ENT_F_IO_V4L, in hantro_attach_func()
694 &func->vdev); in hantro_attach_func()
698 func->proc_pads[0].flags = MEDIA_PAD_FL_SINK; in hantro_attach_func()
699 func->proc_pads[1].flags = MEDIA_PAD_FL_SOURCE; in hantro_attach_func()
700 ret = hantro_register_entity(mdev, &func->proc, "proc", in hantro_attach_func()
701 func->proc_pads, 2, func->id, in hantro_attach_func()
702 &func->vdev); in hantro_attach_func()
706 func->sink_pad.flags = MEDIA_PAD_FL_SINK; in hantro_attach_func()
707 ret = hantro_register_entity(mdev, &func->sink, "sink", in hantro_attach_func()
708 &func->sink_pad, 1, MEDIA_ENT_F_IO_V4L, in hantro_attach_func()
709 &func->vdev); in hantro_attach_func()
714 ret = media_create_pad_link(&func->vdev.entity, 0, &func->proc, 0, in hantro_attach_func()
720 ret = media_create_pad_link(&func->proc, 1, &func->sink, 0, in hantro_attach_func()
727 func->intf_devnode = media_devnode_create(mdev, MEDIA_INTF_T_V4L_VIDEO, in hantro_attach_func()
729 func->vdev.minor); in hantro_attach_func()
730 if (!func->intf_devnode) { in hantro_attach_func()
731 ret = -ENOMEM; in hantro_attach_func()
736 link = media_create_intf_link(&func->vdev.entity, in hantro_attach_func()
737 &func->intf_devnode->intf, in hantro_attach_func()
741 ret = -ENOMEM; in hantro_attach_func()
745 link = media_create_intf_link(&func->sink, &func->intf_devnode->intf, in hantro_attach_func()
749 ret = -ENOMEM; in hantro_attach_func()
755 media_devnode_remove(func->intf_devnode); in hantro_attach_func()
758 media_entity_remove_links(&func->sink); in hantro_attach_func()
761 media_entity_remove_links(&func->proc); in hantro_attach_func()
762 media_entity_remove_links(&func->vdev.entity); in hantro_attach_func()
765 media_device_unregister_entity(&func->sink); in hantro_attach_func()
768 media_device_unregister_entity(&func->proc); in hantro_attach_func()
771 media_device_unregister_entity(&func->vdev.entity); in hantro_attach_func()
777 media_devnode_remove(func->intf_devnode); in hantro_detach_func()
778 media_entity_remove_links(&func->sink); in hantro_detach_func()
779 media_entity_remove_links(&func->proc); in hantro_detach_func()
780 media_entity_remove_links(&func->vdev.entity); in hantro_detach_func()
781 media_device_unregister_entity(&func->sink); in hantro_detach_func()
782 media_device_unregister_entity(&func->proc); in hantro_detach_func()
783 media_device_unregister_entity(&func->vdev.entity); in hantro_detach_func()
793 match = of_match_node(of_hantro_match, vpu->dev->of_node); in hantro_add_func()
794 func = devm_kzalloc(vpu->dev, sizeof(*func), GFP_KERNEL); in hantro_add_func()
796 v4l2_err(&vpu->v4l2_dev, "Failed to allocate video device\n"); in hantro_add_func()
797 return -ENOMEM; in hantro_add_func()
800 func->id = funcid; in hantro_add_func()
802 vfd = &func->vdev; in hantro_add_func()
803 vfd->fops = &hantro_fops; in hantro_add_func()
804 vfd->release = video_device_release_empty; in hantro_add_func()
805 vfd->lock = &vpu->vpu_mutex; in hantro_add_func()
806 vfd->v4l2_dev = &vpu->v4l2_dev; in hantro_add_func()
807 vfd->vfl_dir = VFL_DIR_M2M; in hantro_add_func()
808 vfd->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE; in hantro_add_func()
809 vfd->ioctl_ops = &hantro_ioctl_ops; in hantro_add_func()
810 snprintf(vfd->name, sizeof(vfd->name), "%s-%s", match->compatible, in hantro_add_func()
814 vpu->encoder = func; in hantro_add_func()
816 vpu->decoder = func; in hantro_add_func()
823 ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1); in hantro_add_func()
825 v4l2_err(&vpu->v4l2_dev, "Failed to register video device\n"); in hantro_add_func()
831 v4l2_err(&vpu->v4l2_dev, in hantro_add_func()
836 v4l2_info(&vpu->v4l2_dev, "registered %s as /dev/video%d\n", vfd->name, in hantro_add_func()
837 vfd->num); in hantro_add_func()
848 if (!vpu->variant->enc_fmts) in hantro_add_enc_func()
856 if (!vpu->variant->dec_fmts) in hantro_add_dec_func()
868 func = vpu->encoder; in hantro_remove_func()
870 func = vpu->decoder; in hantro_remove_func()
876 video_unregister_device(&func->vdev); in hantro_remove_func()
902 vpu = devm_kzalloc(&pdev->dev, sizeof(*vpu), GFP_KERNEL); in hantro_probe()
904 return -ENOMEM; in hantro_probe()
906 vpu->dev = &pdev->dev; in hantro_probe()
907 vpu->pdev = pdev; in hantro_probe()
908 mutex_init(&vpu->vpu_mutex); in hantro_probe()
909 spin_lock_init(&vpu->irqlock); in hantro_probe()
911 match = of_match_node(of_hantro_match, pdev->dev.of_node); in hantro_probe()
912 vpu->variant = match->data; in hantro_probe()
915 * Support for nxp,imx8mq-vpu is kept for backwards compatibility in hantro_probe()
917 * nxp,imx8mq-vpu-g1 or nxp,imx8mq-vpu-g2 instead. in hantro_probe()
919 if (of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu")) in hantro_probe()
920 dev_warn(&pdev->dev, "%s compatible is deprecated\n", in hantro_probe()
921 match->compatible); in hantro_probe()
923 INIT_DELAYED_WORK(&vpu->watchdog_work, hantro_watchdog); in hantro_probe()
925 vpu->clocks = devm_kcalloc(&pdev->dev, vpu->variant->num_clocks, in hantro_probe()
926 sizeof(*vpu->clocks), GFP_KERNEL); in hantro_probe()
927 if (!vpu->clocks) in hantro_probe()
928 return -ENOMEM; in hantro_probe()
930 if (vpu->variant->num_clocks > 1) { in hantro_probe()
931 for (i = 0; i < vpu->variant->num_clocks; i++) in hantro_probe()
932 vpu->clocks[i].id = vpu->variant->clk_names[i]; in hantro_probe()
934 ret = devm_clk_bulk_get(&pdev->dev, vpu->variant->num_clocks, in hantro_probe()
935 vpu->clocks); in hantro_probe()
943 vpu->clocks[0].clk = devm_clk_get(&pdev->dev, NULL); in hantro_probe()
944 if (IS_ERR(vpu->clocks[0].clk)) in hantro_probe()
945 return PTR_ERR(vpu->clocks[0].clk); in hantro_probe()
948 vpu->resets = devm_reset_control_array_get(&pdev->dev, false, true); in hantro_probe()
949 if (IS_ERR(vpu->resets)) in hantro_probe()
950 return PTR_ERR(vpu->resets); in hantro_probe()
952 num_bases = vpu->variant->num_regs ?: 1; in hantro_probe()
953 vpu->reg_bases = devm_kcalloc(&pdev->dev, num_bases, in hantro_probe()
954 sizeof(*vpu->reg_bases), GFP_KERNEL); in hantro_probe()
955 if (!vpu->reg_bases) in hantro_probe()
956 return -ENOMEM; in hantro_probe()
959 res = vpu->variant->reg_names ? in hantro_probe()
960 platform_get_resource_byname(vpu->pdev, IORESOURCE_MEM, in hantro_probe()
961 vpu->variant->reg_names[i]) : in hantro_probe()
962 platform_get_resource(vpu->pdev, IORESOURCE_MEM, 0); in hantro_probe()
963 vpu->reg_bases[i] = devm_ioremap_resource(vpu->dev, res); in hantro_probe()
964 if (IS_ERR(vpu->reg_bases[i])) in hantro_probe()
965 return PTR_ERR(vpu->reg_bases[i]); in hantro_probe()
967 vpu->enc_base = vpu->reg_bases[0] + vpu->variant->enc_offset; in hantro_probe()
968 vpu->dec_base = vpu->reg_bases[0] + vpu->variant->dec_offset; in hantro_probe()
971 * TODO: Eventually allow taking advantage of full 64-bit address space. in hantro_probe()
975 ret = dma_set_coherent_mask(vpu->dev, DMA_BIT_MASK(32)); in hantro_probe()
977 dev_err(vpu->dev, "Could not set DMA coherent mask.\n"); in hantro_probe()
980 vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); in hantro_probe()
982 for (i = 0; i < vpu->variant->num_irqs; i++) { in hantro_probe()
986 if (!vpu->variant->irqs[i].handler) in hantro_probe()
989 if (vpu->variant->num_irqs > 1) { in hantro_probe()
990 irq_name = vpu->variant->irqs[i].name; in hantro_probe()
991 irq = platform_get_irq_byname(vpu->pdev, irq_name); in hantro_probe()
998 irq = platform_get_irq(vpu->pdev, 0); in hantro_probe()
1001 return -ENXIO; in hantro_probe()
1003 ret = devm_request_irq(vpu->dev, irq, in hantro_probe()
1004 vpu->variant->irqs[i].handler, 0, in hantro_probe()
1005 dev_name(vpu->dev), vpu); in hantro_probe()
1007 dev_err(vpu->dev, "Could not request %s IRQ.\n", in hantro_probe()
1013 if (vpu->variant->init) { in hantro_probe()
1014 ret = vpu->variant->init(vpu); in hantro_probe()
1016 dev_err(&pdev->dev, "Failed to init VPU hardware\n"); in hantro_probe()
1021 pm_runtime_set_autosuspend_delay(vpu->dev, 100); in hantro_probe()
1022 pm_runtime_use_autosuspend(vpu->dev); in hantro_probe()
1023 pm_runtime_enable(vpu->dev); in hantro_probe()
1025 ret = reset_control_deassert(vpu->resets); in hantro_probe()
1027 dev_err(&pdev->dev, "Failed to deassert resets\n"); in hantro_probe()
1031 ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks); in hantro_probe()
1033 dev_err(&pdev->dev, "Failed to prepare clocks\n"); in hantro_probe()
1037 ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev); in hantro_probe()
1039 dev_err(&pdev->dev, "Failed to register v4l2 device\n"); in hantro_probe()
1044 vpu->m2m_dev = v4l2_m2m_init(&vpu_m2m_ops); in hantro_probe()
1045 if (IS_ERR(vpu->m2m_dev)) { in hantro_probe()
1046 v4l2_err(&vpu->v4l2_dev, "Failed to init mem2mem device\n"); in hantro_probe()
1047 ret = PTR_ERR(vpu->m2m_dev); in hantro_probe()
1051 vpu->mdev.dev = vpu->dev; in hantro_probe()
1052 strscpy(vpu->mdev.model, DRIVER_NAME, sizeof(vpu->mdev.model)); in hantro_probe()
1053 strscpy(vpu->mdev.bus_info, "platform: " DRIVER_NAME, in hantro_probe()
1054 sizeof(vpu->mdev.bus_info)); in hantro_probe()
1055 media_device_init(&vpu->mdev); in hantro_probe()
1056 vpu->mdev.ops = &hantro_m2m_media_ops; in hantro_probe()
1057 vpu->v4l2_dev.mdev = &vpu->mdev; in hantro_probe()
1061 dev_err(&pdev->dev, "Failed to register encoder\n"); in hantro_probe()
1067 dev_err(&pdev->dev, "Failed to register decoder\n"); in hantro_probe()
1071 ret = media_device_register(&vpu->mdev); in hantro_probe()
1073 v4l2_err(&vpu->v4l2_dev, "Failed to register mem2mem media device\n"); in hantro_probe()
1084 media_device_cleanup(&vpu->mdev); in hantro_probe()
1085 v4l2_m2m_release(vpu->m2m_dev); in hantro_probe()
1087 v4l2_device_unregister(&vpu->v4l2_dev); in hantro_probe()
1089 clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks); in hantro_probe()
1091 reset_control_assert(vpu->resets); in hantro_probe()
1093 pm_runtime_dont_use_autosuspend(vpu->dev); in hantro_probe()
1094 pm_runtime_disable(vpu->dev); in hantro_probe()
1102 v4l2_info(&vpu->v4l2_dev, "Removing %s\n", pdev->name); in hantro_remove()
1104 media_device_unregister(&vpu->mdev); in hantro_remove()
1107 media_device_cleanup(&vpu->mdev); in hantro_remove()
1108 v4l2_m2m_release(vpu->m2m_dev); in hantro_remove()
1109 v4l2_device_unregister(&vpu->v4l2_dev); in hantro_remove()
1110 clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks); in hantro_remove()
1111 reset_control_assert(vpu->resets); in hantro_remove()
1112 pm_runtime_dont_use_autosuspend(vpu->dev); in hantro_remove()
1113 pm_runtime_disable(vpu->dev); in hantro_remove()
1122 if (vpu->variant->runtime_resume) in hantro_runtime_resume()
1123 return vpu->variant->runtime_resume(vpu); in hantro_runtime_resume()
1147 MODULE_AUTHOR("Alpha Lin <Alpha.Lin@Rock-Chips.com>");