Lines Matching refs:ceudev
316 static int ceu_soft_reset(struct ceu_device *ceudev) in ceu_soft_reset() argument
320 ceu_write(ceudev, CEU_CAPSR, CEU_CAPSR_CPKIL); in ceu_soft_reset()
323 if (!(ceu_read(ceudev, CEU_CSTSR) & CEU_CSTRST_CPTON)) in ceu_soft_reset()
329 dev_err(ceudev->dev, "soft reset time out\n"); in ceu_soft_reset()
334 if (!(ceu_read(ceudev, CEU_CAPSR) & CEU_CAPSR_CPKIL)) in ceu_soft_reset()
348 static int ceu_hw_config(struct ceu_device *ceudev) in ceu_hw_config() argument
351 struct v4l2_pix_format_mplane *pix = &ceudev->v4l2_pix; in ceu_hw_config()
352 struct ceu_subdev *ceu_sd = ceudev->sd; in ceu_hw_config()
357 ceu_write(ceudev, CEU_CAIFR, 0); in ceu_hw_config()
358 ceu_write(ceudev, CEU_CFWCR, 0); in ceu_hw_config()
359 ceu_write(ceudev, CEU_CRCNTR, 0); in ceu_hw_config()
360 ceu_write(ceudev, CEU_CRCMPR, 0); in ceu_hw_config()
440 ceu_write(ceudev, CEU_CAMCR, camcr); in ceu_hw_config()
441 ceu_write(ceudev, CEU_CDOCR, cdocr); in ceu_hw_config()
442 ceu_write(ceudev, CEU_CAPCR, CEU_CAPCR_BUS_WIDTH256); in ceu_hw_config()
449 ceu_write(ceudev, CEU_CAMOR, 0); in ceu_hw_config()
452 ceu_write(ceudev, CEU_CAPWR, capwr); in ceu_hw_config()
453 ceu_write(ceudev, CEU_CFSZR, cfzsr); in ceu_hw_config()
454 ceu_write(ceudev, CEU_CDWDR, cdwdr); in ceu_hw_config()
464 static int ceu_capture(struct ceu_device *ceudev) in ceu_capture() argument
466 struct v4l2_pix_format_mplane *pix = &ceudev->v4l2_pix; in ceu_capture()
470 vb2_dma_contig_plane_dma_addr(&ceudev->active->vb2_buf, 0); in ceu_capture()
471 ceu_write(ceudev, CEU_CDAYR, phys_addr_top); in ceu_capture()
476 vb2_dma_contig_plane_dma_addr(&ceudev->active->vb2_buf, in ceu_capture()
478 ceu_write(ceudev, CEU_CDACR, phys_addr_top); in ceu_capture()
485 ceu_write(ceudev, CEU_CAPSR, CEU_CAPSR_CE); in ceu_capture()
492 struct ceu_device *ceudev = data; in ceu_irq() local
498 status = ceu_read(ceudev, CEU_CETCR); in ceu_irq()
499 ceu_write(ceudev, CEU_CETCR, ~ceudev->irq_mask); in ceu_irq()
505 spin_lock(&ceudev->lock); in ceu_irq()
508 vbuf = ceudev->active; in ceu_irq()
510 spin_unlock(&ceudev->lock); in ceu_irq()
519 dev_err(ceudev->dev, "VBP interrupt: abort capture\n"); in ceu_irq()
525 vbuf->sequence = ceudev->sequence++; in ceu_irq()
526 vbuf->field = ceudev->field; in ceu_irq()
529 if (!list_empty(&ceudev->capture)) { in ceu_irq()
530 buf = list_first_entry(&ceudev->capture, struct ceu_buffer, in ceu_irq()
533 ceudev->active = &buf->vb; in ceu_irq()
535 ceu_capture(ceudev); in ceu_irq()
541 spin_unlock(&ceudev->lock); in ceu_irq()
549 list_for_each_entry(buf, &ceudev->capture, queue) in ceu_irq()
552 spin_unlock(&ceudev->lock); in ceu_irq()
577 static void ceu_calc_plane_sizes(struct ceu_device *ceudev, in ceu_calc_plane_sizes() argument
624 struct ceu_device *ceudev = vb2_get_drv_priv(vq); in ceu_vb2_setup() local
625 struct v4l2_pix_format_mplane *pix = &ceudev->v4l2_pix; in ceu_vb2_setup()
647 struct ceu_device *ceudev = vb2_get_drv_priv(vb->vb2_queue); in ceu_vb2_queue() local
652 spin_lock_irqsave(&ceudev->lock, irqflags); in ceu_vb2_queue()
653 list_add_tail(&buf->queue, &ceudev->capture); in ceu_vb2_queue()
654 spin_unlock_irqrestore(&ceudev->lock, irqflags); in ceu_vb2_queue()
659 struct ceu_device *ceudev = vb2_get_drv_priv(vb->vb2_queue); in ceu_vb2_prepare() local
660 struct v4l2_pix_format_mplane *pix = &ceudev->v4l2_pix; in ceu_vb2_prepare()
665 dev_err(ceudev->dev, in ceu_vb2_prepare()
680 struct ceu_device *ceudev = vb2_get_drv_priv(vq); in ceu_start_streaming() local
681 struct v4l2_subdev *v4l2_sd = ceudev->sd->v4l2_sd; in ceu_start_streaming()
687 ret = ceu_hw_config(ceudev); in ceu_start_streaming()
693 dev_dbg(ceudev->dev, in ceu_start_streaming()
698 spin_lock_irqsave(&ceudev->lock, irqflags); in ceu_start_streaming()
699 ceudev->sequence = 0; in ceu_start_streaming()
702 buf = list_first_entry(&ceudev->capture, struct ceu_buffer, in ceu_start_streaming()
706 ceudev->active = &buf->vb; in ceu_start_streaming()
709 ceu_write(ceudev, CEU_CETCR, ~ceudev->irq_mask); in ceu_start_streaming()
710 ceu_write(ceudev, CEU_CEIER, CEU_CEIER_MASK); in ceu_start_streaming()
712 ceu_capture(ceudev); in ceu_start_streaming()
714 spin_unlock_irqrestore(&ceudev->lock, irqflags); in ceu_start_streaming()
719 spin_lock_irqsave(&ceudev->lock, irqflags); in ceu_start_streaming()
720 list_for_each_entry(buf, &ceudev->capture, queue) in ceu_start_streaming()
721 vb2_buffer_done(&ceudev->active->vb2_buf, in ceu_start_streaming()
723 ceudev->active = NULL; in ceu_start_streaming()
724 spin_unlock_irqrestore(&ceudev->lock, irqflags); in ceu_start_streaming()
731 struct ceu_device *ceudev = vb2_get_drv_priv(vq); in ceu_stop_streaming() local
732 struct v4l2_subdev *v4l2_sd = ceudev->sd->v4l2_sd; in ceu_stop_streaming()
737 ceu_write(ceudev, CEU_CETCR, in ceu_stop_streaming()
738 ceu_read(ceudev, CEU_CETCR) & ceudev->irq_mask); in ceu_stop_streaming()
739 ceu_write(ceudev, CEU_CEIER, CEU_CEIER_MASK); in ceu_stop_streaming()
743 spin_lock_irqsave(&ceudev->lock, irqflags); in ceu_stop_streaming()
744 if (ceudev->active) { in ceu_stop_streaming()
745 vb2_buffer_done(&ceudev->active->vb2_buf, in ceu_stop_streaming()
747 ceudev->active = NULL; in ceu_stop_streaming()
751 list_for_each_entry(buf, &ceudev->capture, queue) in ceu_stop_streaming()
753 INIT_LIST_HEAD(&ceudev->capture); in ceu_stop_streaming()
755 spin_unlock_irqrestore(&ceudev->lock, irqflags); in ceu_stop_streaming()
757 ceu_soft_reset(ceudev); in ceu_stop_streaming()
780 static int __ceu_try_fmt(struct ceu_device *ceudev, struct v4l2_format *v4l2_fmt, in __ceu_try_fmt() argument
783 struct ceu_subdev *ceu_sd = ceudev->sd; in __ceu_try_fmt()
863 ceu_calc_plane_sizes(ceudev, ceu_fmt, pix); in __ceu_try_fmt()
874 static int ceu_try_fmt(struct ceu_device *ceudev, struct v4l2_format *v4l2_fmt) in ceu_try_fmt() argument
878 return __ceu_try_fmt(ceudev, v4l2_fmt, &mbus_code); in ceu_try_fmt()
884 static int ceu_set_fmt(struct ceu_device *ceudev, struct v4l2_format *v4l2_fmt) in ceu_set_fmt() argument
886 struct ceu_subdev *ceu_sd = ceudev->sd; in ceu_set_fmt()
899 ret = __ceu_try_fmt(ceudev, v4l2_fmt, &mbus_code); in ceu_set_fmt()
909 ceudev->v4l2_pix = v4l2_fmt->fmt.pix_mp; in ceu_set_fmt()
910 ceudev->field = V4L2_FIELD_NONE; in ceu_set_fmt()
919 static int ceu_set_default_fmt(struct ceu_device *ceudev) in ceu_set_default_fmt() argument
944 ret = ceu_try_fmt(ceudev, &v4l2_fmt); in ceu_set_default_fmt()
948 ceudev->v4l2_pix = v4l2_fmt.fmt.pix_mp; in ceu_set_default_fmt()
949 ceudev->field = V4L2_FIELD_NONE; in ceu_set_default_fmt()
967 static int ceu_init_mbus_fmt(struct ceu_device *ceudev) in ceu_init_mbus_fmt() argument
969 struct ceu_subdev *ceu_sd = ceudev->sd; in ceu_init_mbus_fmt()
1055 struct ceu_device *ceudev = dev_get_drvdata(dev); in ceu_runtime_resume() local
1056 struct v4l2_subdev *v4l2_sd = ceudev->sd->v4l2_sd; in ceu_runtime_resume()
1060 ceu_soft_reset(ceudev); in ceu_runtime_resume()
1071 struct ceu_device *ceudev = dev_get_drvdata(dev); in ceu_runtime_suspend() local
1072 struct v4l2_subdev *v4l2_sd = ceudev->sd->v4l2_sd; in ceu_runtime_suspend()
1076 ceu_write(ceudev, CEU_CEIER, 0); in ceu_runtime_suspend()
1077 ceu_soft_reset(ceudev); in ceu_runtime_suspend()
1086 struct ceu_device *ceudev = video_drvdata(file); in ceu_open() local
1093 mutex_lock(&ceudev->mlock); in ceu_open()
1095 ret = pm_runtime_resume_and_get(ceudev->dev); in ceu_open()
1096 mutex_unlock(&ceudev->mlock); in ceu_open()
1103 struct ceu_device *ceudev = video_drvdata(file); in ceu_release() local
1107 mutex_lock(&ceudev->mlock); in ceu_release()
1109 pm_runtime_put(ceudev->dev); in ceu_release()
1110 mutex_unlock(&ceudev->mlock); in ceu_release()
1129 struct ceu_device *ceudev = video_drvdata(file); in ceu_querycap() local
1134 "platform:renesas-ceu-%s", dev_name(ceudev->dev)); in ceu_querycap()
1156 struct ceu_device *ceudev = video_drvdata(file); in ceu_try_fmt_vid_cap() local
1158 return ceu_try_fmt(ceudev, f); in ceu_try_fmt_vid_cap()
1164 struct ceu_device *ceudev = video_drvdata(file); in ceu_s_fmt_vid_cap() local
1166 if (vb2_is_streaming(&ceudev->vb2_vq)) in ceu_s_fmt_vid_cap()
1169 return ceu_set_fmt(ceudev, f); in ceu_s_fmt_vid_cap()
1175 struct ceu_device *ceudev = video_drvdata(file); in ceu_g_fmt_vid_cap() local
1177 f->fmt.pix_mp = ceudev->v4l2_pix; in ceu_g_fmt_vid_cap()
1185 struct ceu_device *ceudev = video_drvdata(file); in ceu_enum_input() local
1187 if (inp->index >= ceudev->num_sd) in ceu_enum_input()
1199 struct ceu_device *ceudev = video_drvdata(file); in ceu_g_input() local
1201 *i = ceudev->sd_index; in ceu_g_input()
1208 struct ceu_device *ceudev = video_drvdata(file); in ceu_s_input() local
1212 if (i >= ceudev->num_sd) in ceu_s_input()
1215 if (vb2_is_streaming(&ceudev->vb2_vq)) in ceu_s_input()
1218 if (i == ceudev->sd_index) in ceu_s_input()
1221 ceu_sd_old = ceudev->sd; in ceu_s_input()
1222 ceudev->sd = ceudev->subdevs[i]; in ceu_s_input()
1228 ret = ceu_init_mbus_fmt(ceudev); in ceu_s_input()
1230 ceudev->sd = ceu_sd_old; in ceu_s_input()
1234 ret = ceu_set_default_fmt(ceudev); in ceu_s_input()
1236 ceudev->sd = ceu_sd_old; in ceu_s_input()
1242 v4l2_subdev_call(ceudev->sd->v4l2_sd, core, s_power, 1); in ceu_s_input()
1244 ceudev->sd_index = i; in ceu_s_input()
1251 struct ceu_device *ceudev = video_drvdata(file); in ceu_g_parm() local
1253 return v4l2_g_parm_cap(video_devdata(file), ceudev->sd->v4l2_sd, a); in ceu_g_parm()
1258 struct ceu_device *ceudev = video_drvdata(file); in ceu_s_parm() local
1260 return v4l2_s_parm_cap(video_devdata(file), ceudev->sd->v4l2_sd, a); in ceu_s_parm()
1266 struct ceu_device *ceudev = video_drvdata(file); in ceu_enum_framesizes() local
1267 struct ceu_subdev *ceu_sd = ceudev->sd; in ceu_enum_framesizes()
1298 struct ceu_device *ceudev = video_drvdata(file); in ceu_enum_frameintervals() local
1299 struct ceu_subdev *ceu_sd = ceudev->sd; in ceu_enum_frameintervals()
1366 struct ceu_device *ceudev = video_get_drvdata(vdev); in ceu_vdev_release() local
1368 kfree(ceudev); in ceu_vdev_release()
1376 struct ceu_device *ceudev = v4l2_to_ceu(v4l2_dev); in ceu_notify_bound() local
1380 ceudev->num_sd++; in ceu_notify_bound()
1388 struct ceu_device *ceudev = v4l2_to_ceu(v4l2_dev); in ceu_notify_complete() local
1389 struct video_device *vdev = &ceudev->vdev; in ceu_notify_complete()
1390 struct vb2_queue *q = &ceudev->vb2_vq; in ceu_notify_complete()
1397 q->drv_priv = ceudev; in ceu_notify_complete()
1403 q->lock = &ceudev->mlock; in ceu_notify_complete()
1404 q->dev = ceudev->v4l2_dev.dev; in ceu_notify_complete()
1414 if (!ceudev->sd) { in ceu_notify_complete()
1415 ceudev->sd = ceudev->subdevs[0]; in ceu_notify_complete()
1416 ceudev->sd_index = 0; in ceu_notify_complete()
1419 v4l2_sd = ceudev->sd->v4l2_sd; in ceu_notify_complete()
1421 ret = ceu_init_mbus_fmt(ceudev); in ceu_notify_complete()
1425 ret = ceu_set_default_fmt(ceudev); in ceu_notify_complete()
1432 vdev->lock = &ceudev->mlock; in ceu_notify_complete()
1433 vdev->queue = &ceudev->vb2_vq; in ceu_notify_complete()
1440 video_set_drvdata(vdev, ceudev); in ceu_notify_complete()
1464 static int ceu_init_async_subdevs(struct ceu_device *ceudev, unsigned int n_sd) in ceu_init_async_subdevs() argument
1467 ceudev->subdevs = devm_kcalloc(ceudev->dev, n_sd, in ceu_init_async_subdevs()
1468 sizeof(*ceudev->subdevs), GFP_KERNEL); in ceu_init_async_subdevs()
1469 if (!ceudev->subdevs) in ceu_init_async_subdevs()
1472 ceudev->sd = NULL; in ceu_init_async_subdevs()
1473 ceudev->sd_index = 0; in ceu_init_async_subdevs()
1474 ceudev->num_sd = 0; in ceu_init_async_subdevs()
1483 static int ceu_parse_platform_data(struct ceu_device *ceudev, in ceu_parse_platform_data() argument
1494 ret = ceu_init_async_subdevs(ceudev, pdata->num_subdevs); in ceu_parse_platform_data()
1502 ceu_sd = v4l2_async_nf_add_i2c(&ceudev->notifier, in ceu_parse_platform_data()
1507 v4l2_async_nf_cleanup(&ceudev->notifier); in ceu_parse_platform_data()
1511 ceudev->subdevs[i] = ceu_sd; in ceu_parse_platform_data()
1520 static int ceu_parse_dt(struct ceu_device *ceudev) in ceu_parse_dt() argument
1522 struct device_node *of = ceudev->dev->of_node; in ceu_parse_dt()
1533 ret = ceu_init_async_subdevs(ceudev, num_ep); in ceu_parse_dt()
1551 dev_err(ceudev->dev, in ceu_parse_dt()
1559 dev_err(ceudev->dev, in ceu_parse_dt()
1565 ceu_sd = v4l2_async_nf_add_fwnode_remote(&ceudev->notifier, in ceu_parse_dt()
1573 ceudev->subdevs[i] = ceu_sd; in ceu_parse_dt()
1581 v4l2_async_nf_cleanup(&ceudev->notifier); in ceu_parse_dt()
1616 struct ceu_device *ceudev; in ceu_probe() local
1621 ceudev = kzalloc(sizeof(*ceudev), GFP_KERNEL); in ceu_probe()
1622 if (!ceudev) in ceu_probe()
1625 platform_set_drvdata(pdev, ceudev); in ceu_probe()
1626 ceudev->dev = dev; in ceu_probe()
1628 INIT_LIST_HEAD(&ceudev->capture); in ceu_probe()
1629 spin_lock_init(&ceudev->lock); in ceu_probe()
1630 mutex_init(&ceudev->mlock); in ceu_probe()
1632 ceudev->base = devm_platform_ioremap_resource(pdev, 0); in ceu_probe()
1633 if (IS_ERR(ceudev->base)) { in ceu_probe()
1634 ret = PTR_ERR(ceudev->base); in ceu_probe()
1644 0, dev_name(dev), ceudev); in ceu_probe()
1652 ret = v4l2_device_register(dev, &ceudev->v4l2_dev); in ceu_probe()
1656 v4l2_async_nf_init(&ceudev->notifier, &ceudev->v4l2_dev); in ceu_probe()
1660 num_subdevs = ceu_parse_dt(ceudev); in ceu_probe()
1664 num_subdevs = ceu_parse_platform_data(ceudev, in ceu_probe()
1674 ceudev->irq_mask = ceu_data->irq_mask; in ceu_probe()
1676 ceudev->notifier.v4l2_dev = &ceudev->v4l2_dev; in ceu_probe()
1677 ceudev->notifier.ops = &ceu_notify_ops; in ceu_probe()
1678 ret = v4l2_async_nf_register(&ceudev->notifier); in ceu_probe()
1687 v4l2_async_nf_cleanup(&ceudev->notifier); in ceu_probe()
1689 v4l2_device_unregister(&ceudev->v4l2_dev); in ceu_probe()
1693 kfree(ceudev); in ceu_probe()
1700 struct ceu_device *ceudev = platform_get_drvdata(pdev); in ceu_remove() local
1702 pm_runtime_disable(ceudev->dev); in ceu_remove()
1704 v4l2_async_nf_unregister(&ceudev->notifier); in ceu_remove()
1706 v4l2_async_nf_cleanup(&ceudev->notifier); in ceu_remove()
1708 v4l2_device_unregister(&ceudev->v4l2_dev); in ceu_remove()
1710 video_unregister_device(&ceudev->vdev); in ceu_remove()