Lines Matching refs:icd

47 #define is_streaming(ici, icd)				\  argument
49 (icd)->vb_vidq.streaming : \
50 vb2_is_streaming(&(icd)->vb2_vidq))
69 static int soc_camera_video_start(struct soc_camera_device *icd);
70 static int video_dev_create(struct soc_camera_device *icd);
156 static int __soc_camera_power_on(struct soc_camera_device *icd) in __soc_camera_power_on() argument
158 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in __soc_camera_power_on()
168 static int __soc_camera_power_off(struct soc_camera_device *icd) in __soc_camera_power_off() argument
170 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in __soc_camera_power_off()
205 struct soc_camera_device *icd, unsigned int fourcc) in soc_camera_xlate_by_fourcc() argument
209 for (i = 0; i < icd->num_user_formats; i++) in soc_camera_xlate_by_fourcc()
210 if (icd->user_formats[i].host_fmt->fourcc == fourcc) in soc_camera_xlate_by_fourcc()
211 return icd->user_formats + i; in soc_camera_xlate_by_fourcc()
253 static int soc_camera_try_fmt(struct soc_camera_device *icd, in soc_camera_try_fmt() argument
256 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_try_fmt()
261 dev_dbg(icd->pdev, "TRY_FMT(%c%c%c%c, %ux%u)\n", in soc_camera_try_fmt()
270 ret = ici->ops->try_fmt(icd, f); in soc_camera_try_fmt()
274 xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); in soc_camera_try_fmt()
297 struct soc_camera_device *icd = file->private_data; in soc_camera_try_fmt_vid_cap() local
306 return soc_camera_try_fmt(icd, f); in soc_camera_try_fmt_vid_cap()
312 struct soc_camera_device *icd = file->private_data; in soc_camera_enum_input() local
319 inp->std = icd->vdev->tvnorms; in soc_camera_enum_input()
342 struct soc_camera_device *icd = file->private_data; in soc_camera_s_std() local
343 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_s_std()
350 struct soc_camera_device *icd = file->private_data; in soc_camera_g_std() local
351 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_g_std()
359 struct soc_camera_device *icd = file->private_data; in soc_camera_enum_framesizes() local
360 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_enum_framesizes()
362 return ici->ops->enum_framesizes(icd, fsize); in soc_camera_enum_framesizes()
369 struct soc_camera_device *icd = file->private_data; in soc_camera_reqbufs() local
370 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_reqbufs()
374 if (icd->streamer && icd->streamer != file) in soc_camera_reqbufs()
378 ret = videobuf_reqbufs(&icd->vb_vidq, p); in soc_camera_reqbufs()
382 ret = ici->ops->reqbufs(icd, p); in soc_camera_reqbufs()
384 ret = vb2_reqbufs(&icd->vb2_vidq, p); in soc_camera_reqbufs()
388 icd->streamer = p->count ? file : NULL; in soc_camera_reqbufs()
395 struct soc_camera_device *icd = file->private_data; in soc_camera_querybuf() local
396 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_querybuf()
401 return videobuf_querybuf(&icd->vb_vidq, p); in soc_camera_querybuf()
403 return vb2_querybuf(&icd->vb2_vidq, p); in soc_camera_querybuf()
409 struct soc_camera_device *icd = file->private_data; in soc_camera_qbuf() local
410 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_qbuf()
414 if (icd->streamer != file) in soc_camera_qbuf()
418 return videobuf_qbuf(&icd->vb_vidq, p); in soc_camera_qbuf()
420 return vb2_qbuf(&icd->vb2_vidq, p); in soc_camera_qbuf()
426 struct soc_camera_device *icd = file->private_data; in soc_camera_dqbuf() local
427 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_dqbuf()
431 if (icd->streamer != file) in soc_camera_dqbuf()
435 return videobuf_dqbuf(&icd->vb_vidq, p, file->f_flags & O_NONBLOCK); in soc_camera_dqbuf()
437 return vb2_dqbuf(&icd->vb2_vidq, p, file->f_flags & O_NONBLOCK); in soc_camera_dqbuf()
443 struct soc_camera_device *icd = file->private_data; in soc_camera_create_bufs() local
444 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_create_bufs()
451 if (icd->streamer && icd->streamer != file) in soc_camera_create_bufs()
454 ret = vb2_create_bufs(&icd->vb2_vidq, create); in soc_camera_create_bufs()
456 icd->streamer = file; in soc_camera_create_bufs()
463 struct soc_camera_device *icd = file->private_data; in soc_camera_prepare_buf() local
464 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_prepare_buf()
470 return vb2_prepare_buf(&icd->vb2_vidq, b); in soc_camera_prepare_buf()
476 struct soc_camera_device *icd = file->private_data; in soc_camera_expbuf() local
477 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_expbuf()
483 if (icd->streamer && icd->streamer != file) in soc_camera_expbuf()
485 return vb2_expbuf(&icd->vb2_vidq, p); in soc_camera_expbuf()
489 static int soc_camera_init_user_formats(struct soc_camera_device *icd) in soc_camera_init_user_formats() argument
491 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_init_user_formats()
492 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_init_user_formats()
516 ret = ici->ops->get_formats(icd, i, NULL); in soc_camera_init_user_formats()
525 icd->user_formats = in soc_camera_init_user_formats()
527 if (!icd->user_formats) in soc_camera_init_user_formats()
530 dev_dbg(icd->pdev, "Found %d supported formats.\n", fmts); in soc_camera_init_user_formats()
538 icd->user_formats[fmts].host_fmt = in soc_camera_init_user_formats()
540 if (icd->user_formats[fmts].host_fmt) in soc_camera_init_user_formats()
541 icd->user_formats[fmts++].code = code.code; in soc_camera_init_user_formats()
543 ret = ici->ops->get_formats(icd, i, in soc_camera_init_user_formats()
544 &icd->user_formats[fmts]); in soc_camera_init_user_formats()
550 icd->num_user_formats = fmts; in soc_camera_init_user_formats()
551 icd->current_fmt = &icd->user_formats[0]; in soc_camera_init_user_formats()
556 vfree(icd->user_formats); in soc_camera_init_user_formats()
561 static void soc_camera_free_user_formats(struct soc_camera_device *icd) in soc_camera_free_user_formats() argument
563 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_free_user_formats()
566 ici->ops->put_formats(icd); in soc_camera_free_user_formats()
567 icd->current_fmt = NULL; in soc_camera_free_user_formats()
568 icd->num_user_formats = 0; in soc_camera_free_user_formats()
569 vfree(icd->user_formats); in soc_camera_free_user_formats()
570 icd->user_formats = NULL; in soc_camera_free_user_formats()
574 static int soc_camera_set_fmt(struct soc_camera_device *icd, in soc_camera_set_fmt() argument
577 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_set_fmt()
581 dev_dbg(icd->pdev, "S_FMT(%c%c%c%c, %ux%u)\n", in soc_camera_set_fmt()
585 ret = soc_camera_try_fmt(icd, f); in soc_camera_set_fmt()
589 ret = ici->ops->set_fmt(icd, f); in soc_camera_set_fmt()
592 } else if (!icd->current_fmt || in soc_camera_set_fmt()
593 icd->current_fmt->host_fmt->fourcc != pix->pixelformat) { in soc_camera_set_fmt()
594 dev_err(icd->pdev, in soc_camera_set_fmt()
599 icd->user_width = pix->width; in soc_camera_set_fmt()
600 icd->user_height = pix->height; in soc_camera_set_fmt()
601 icd->bytesperline = pix->bytesperline; in soc_camera_set_fmt()
602 icd->sizeimage = pix->sizeimage; in soc_camera_set_fmt()
603 icd->colorspace = pix->colorspace; in soc_camera_set_fmt()
604 icd->field = pix->field; in soc_camera_set_fmt()
606 icd->vb_vidq.field = pix->field; in soc_camera_set_fmt()
608 dev_dbg(icd->pdev, "set width: %d height: %d\n", in soc_camera_set_fmt()
609 icd->user_width, icd->user_height); in soc_camera_set_fmt()
612 return ici->ops->set_bus_param(icd); in soc_camera_set_fmt()
615 static int soc_camera_add_device(struct soc_camera_device *icd) in soc_camera_add_device() argument
617 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_add_device()
620 if (ici->icd) in soc_camera_add_device()
623 if (!icd->clk) { in soc_camera_add_device()
630 ret = ici->ops->add(icd); in soc_camera_add_device()
635 ici->icd = icd; in soc_camera_add_device()
640 if (!icd->clk) in soc_camera_add_device()
645 static void soc_camera_remove_device(struct soc_camera_device *icd) in soc_camera_remove_device() argument
647 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_remove_device()
649 if (WARN_ON(icd != ici->icd)) in soc_camera_remove_device()
653 ici->ops->remove(icd); in soc_camera_remove_device()
654 if (!icd->clk) in soc_camera_remove_device()
656 ici->icd = NULL; in soc_camera_remove_device()
662 struct soc_camera_device *icd; in soc_camera_open() local
679 icd = video_get_drvdata(vdev); in soc_camera_open()
680 ici = to_soc_camera_host(icd->parent); in soc_camera_open()
686 dev_err(icd->pdev, "Couldn't lock capture bus driver.\n"); in soc_camera_open()
690 if (!to_soc_camera_control(icd)) { in soc_camera_open()
700 icd->use_count++; in soc_camera_open()
703 if (icd->use_count == 1) { in soc_camera_open()
704 struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); in soc_camera_open()
709 .width = icd->user_width, in soc_camera_open()
710 .height = icd->user_height, in soc_camera_open()
711 .field = icd->field, in soc_camera_open()
712 .colorspace = icd->colorspace, in soc_camera_open()
714 icd->current_fmt->host_fmt->fourcc, in soc_camera_open()
720 if (icd->control) in soc_camera_open()
721 sdesc->subdev_desc.reset(icd->control); in soc_camera_open()
723 ret = soc_camera_add_device(icd); in soc_camera_open()
725 dev_err(icd->pdev, "Couldn't activate the camera: %d\n", ret); in soc_camera_open()
729 ret = __soc_camera_power_on(icd); in soc_camera_open()
733 pm_runtime_enable(&icd->vdev->dev); in soc_camera_open()
734 ret = pm_runtime_resume(&icd->vdev->dev); in soc_camera_open()
744 ret = soc_camera_set_fmt(icd, &f); in soc_camera_open()
749 ici->ops->init_videobuf(&icd->vb_vidq, icd); in soc_camera_open()
751 ret = ici->ops->init_videobuf2(&icd->vb2_vidq, icd); in soc_camera_open()
755 v4l2_ctrl_handler_setup(&icd->ctrl_handler); in soc_camera_open()
759 file->private_data = icd; in soc_camera_open()
760 dev_dbg(icd->pdev, "camera device open\n"); in soc_camera_open()
770 pm_runtime_disable(&icd->vdev->dev); in soc_camera_open()
772 __soc_camera_power_off(icd); in soc_camera_open()
774 soc_camera_remove_device(icd); in soc_camera_open()
776 icd->use_count--; in soc_camera_open()
787 struct soc_camera_device *icd = file->private_data; in soc_camera_close() local
788 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_close()
791 if (icd->streamer == file) { in soc_camera_close()
793 vb2_queue_release(&icd->vb2_vidq); in soc_camera_close()
794 icd->streamer = NULL; in soc_camera_close()
796 icd->use_count--; in soc_camera_close()
797 if (!icd->use_count) { in soc_camera_close()
798 pm_runtime_suspend(&icd->vdev->dev); in soc_camera_close()
799 pm_runtime_disable(&icd->vdev->dev); in soc_camera_close()
801 __soc_camera_power_off(icd); in soc_camera_close()
803 soc_camera_remove_device(icd); in soc_camera_close()
810 dev_dbg(icd->pdev, "camera device close\n"); in soc_camera_close()
818 struct soc_camera_device *icd = file->private_data; in soc_camera_read() local
819 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_read()
821 dev_dbg(icd->pdev, "read called, buf %p\n", buf); in soc_camera_read()
823 if (ici->ops->init_videobuf2 && icd->vb2_vidq.io_modes & VB2_READ) in soc_camera_read()
824 return vb2_read(&icd->vb2_vidq, buf, count, ppos, in soc_camera_read()
827 dev_err(icd->pdev, "camera device read not implemented\n"); in soc_camera_read()
834 struct soc_camera_device *icd = file->private_data; in soc_camera_mmap() local
835 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_mmap()
838 dev_dbg(icd->pdev, "mmap called, vma=0x%08lx\n", (unsigned long)vma); in soc_camera_mmap()
840 if (icd->streamer != file) in soc_camera_mmap()
846 err = videobuf_mmap_mapper(&icd->vb_vidq, vma); in soc_camera_mmap()
848 err = vb2_mmap(&icd->vb2_vidq, vma); in soc_camera_mmap()
851 dev_dbg(icd->pdev, "vma start=0x%08lx, size=%ld, ret=%d\n", in soc_camera_mmap()
861 struct soc_camera_device *icd = file->private_data; in soc_camera_poll() local
862 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_poll()
865 if (icd->streamer != file) in soc_camera_poll()
869 if (ici->ops->init_videobuf && list_empty(&icd->vb_vidq.stream)) in soc_camera_poll()
870 dev_err(icd->pdev, "Trying to poll with no queued buffers!\n"); in soc_camera_poll()
890 struct soc_camera_device *icd = file->private_data; in soc_camera_s_fmt_vid_cap() local
896 dev_warn(icd->pdev, "Wrong buf-type %d\n", f->type); in soc_camera_s_fmt_vid_cap()
900 if (icd->streamer && icd->streamer != file) in soc_camera_s_fmt_vid_cap()
903 if (is_streaming(to_soc_camera_host(icd->parent), icd)) { in soc_camera_s_fmt_vid_cap()
904 dev_err(icd->pdev, "S_FMT denied: queue initialised\n"); in soc_camera_s_fmt_vid_cap()
908 ret = soc_camera_set_fmt(icd, f); in soc_camera_s_fmt_vid_cap()
910 if (!ret && !icd->streamer) in soc_camera_s_fmt_vid_cap()
911 icd->streamer = file; in soc_camera_s_fmt_vid_cap()
919 struct soc_camera_device *icd = file->private_data; in soc_camera_enum_fmt_vid_cap() local
924 if (f->index >= icd->num_user_formats) in soc_camera_enum_fmt_vid_cap()
927 format = icd->user_formats[f->index].host_fmt; in soc_camera_enum_fmt_vid_cap()
938 struct soc_camera_device *icd = file->private_data; in soc_camera_g_fmt_vid_cap() local
946 pix->width = icd->user_width; in soc_camera_g_fmt_vid_cap()
947 pix->height = icd->user_height; in soc_camera_g_fmt_vid_cap()
948 pix->bytesperline = icd->bytesperline; in soc_camera_g_fmt_vid_cap()
949 pix->sizeimage = icd->sizeimage; in soc_camera_g_fmt_vid_cap()
950 pix->field = icd->field; in soc_camera_g_fmt_vid_cap()
951 pix->pixelformat = icd->current_fmt->host_fmt->fourcc; in soc_camera_g_fmt_vid_cap()
952 pix->colorspace = icd->colorspace; in soc_camera_g_fmt_vid_cap()
953 dev_dbg(icd->pdev, "current_fmt->fourcc: 0x%08x\n", in soc_camera_g_fmt_vid_cap()
954 icd->current_fmt->host_fmt->fourcc); in soc_camera_g_fmt_vid_cap()
961 struct soc_camera_device *icd = file->private_data; in soc_camera_querycap() local
962 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_querycap()
973 struct soc_camera_device *icd = file->private_data; in soc_camera_streamon() local
974 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_streamon()
975 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_streamon()
983 if (icd->streamer != file) in soc_camera_streamon()
988 ret = videobuf_streamon(&icd->vb_vidq); in soc_camera_streamon()
990 ret = vb2_streamon(&icd->vb2_vidq, i); in soc_camera_streamon()
1001 struct soc_camera_device *icd = file->private_data; in soc_camera_streamoff() local
1002 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_streamoff()
1003 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_streamoff()
1011 if (icd->streamer != file) in soc_camera_streamoff()
1019 ret = videobuf_streamoff(&icd->vb_vidq); in soc_camera_streamoff()
1021 ret = vb2_streamoff(&icd->vb2_vidq, i); in soc_camera_streamoff()
1031 struct soc_camera_device *icd = file->private_data; in soc_camera_cropcap() local
1032 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_cropcap()
1034 return ici->ops->cropcap(icd, a); in soc_camera_cropcap()
1040 struct soc_camera_device *icd = file->private_data; in soc_camera_g_crop() local
1041 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_g_crop()
1044 ret = ici->ops->get_crop(icd, a); in soc_camera_g_crop()
1057 struct soc_camera_device *icd = file->private_data; in soc_camera_s_crop() local
1058 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_s_crop()
1066 dev_dbg(icd->pdev, "S_CROP(%ux%u@%u:%u)\n", in soc_camera_s_crop()
1072 ret = ici->ops->get_crop(icd, &current_crop); in soc_camera_s_crop()
1076 dev_err(icd->pdev, in soc_camera_s_crop()
1080 !is_streaming(ici, icd)) { in soc_camera_s_crop()
1082 ret = ici->ops->set_crop(icd, a); in soc_camera_s_crop()
1084 ret = ici->ops->set_livecrop(icd, a); in soc_camera_s_crop()
1086 dev_err(icd->pdev, in soc_camera_s_crop()
1097 struct soc_camera_device *icd = file->private_data; in soc_camera_g_selection() local
1098 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_g_selection()
1107 return ici->ops->get_selection(icd, s); in soc_camera_g_selection()
1113 struct soc_camera_device *icd = file->private_data; in soc_camera_s_selection() local
1114 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_s_selection()
1125 if (is_streaming(ici, icd) && in soc_camera_s_selection()
1126 (icd->user_width != s->r.width || in soc_camera_s_selection()
1127 icd->user_height != s->r.height)) in soc_camera_s_selection()
1134 if (icd->streamer && icd->streamer != file) in soc_camera_s_selection()
1141 ret = ici->ops->set_selection(icd, s); in soc_camera_s_selection()
1144 icd->user_width = s->r.width; in soc_camera_s_selection()
1145 icd->user_height = s->r.height; in soc_camera_s_selection()
1146 if (!icd->streamer) in soc_camera_s_selection()
1147 icd->streamer = file; in soc_camera_s_selection()
1156 struct soc_camera_device *icd = file->private_data; in soc_camera_g_parm() local
1157 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_g_parm()
1160 return ici->ops->get_parm(icd, a); in soc_camera_g_parm()
1168 struct soc_camera_device *icd = file->private_data; in soc_camera_s_parm() local
1169 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_s_parm()
1172 return ici->ops->set_parm(icd, a); in soc_camera_s_parm()
1178 struct soc_camera_device *icd);
1183 struct soc_camera_device *icd; in scan_add_host() local
1187 list_for_each_entry(icd, &devices, list) in scan_add_host()
1188 if (icd->iface == ici->nr) { in scan_add_host()
1189 struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); in scan_add_host()
1194 if (icd->control) in scan_add_host()
1195 ssdd->reset(icd->control); in scan_add_host()
1197 icd->parent = ici->v4l2_dev.dev; in scan_add_host()
1200 soc_camera_probe(ici, icd); in scan_add_host()
1212 struct soc_camera_device *icd = clk->priv; in soc_camera_clk_enable() local
1215 if (!icd || !icd->parent) in soc_camera_clk_enable()
1218 ici = to_soc_camera_host(icd->parent); in soc_camera_clk_enable()
1232 struct soc_camera_device *icd = clk->priv; in soc_camera_clk_disable() local
1235 if (!icd || !icd->parent) in soc_camera_clk_disable()
1238 ici = to_soc_camera_host(icd->parent); in soc_camera_clk_disable()
1299 static int soc_camera_probe_finish(struct soc_camera_device *icd) in soc_camera_probe_finish() argument
1301 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_probe_finish()
1308 sd->grp_id = soc_camera_grp_id(icd); in soc_camera_probe_finish()
1309 v4l2_set_subdev_hostdata(sd, icd); in soc_camera_probe_finish()
1311 v4l2_subdev_call(sd, video, g_tvnorms, &icd->vdev->tvnorms); in soc_camera_probe_finish()
1313 ret = v4l2_ctrl_add_handler(&icd->ctrl_handler, sd->ctrl_handler, NULL); in soc_camera_probe_finish()
1317 ret = soc_camera_add_device(icd); in soc_camera_probe_finish()
1319 dev_err(icd->pdev, "Couldn't activate the camera: %d\n", ret); in soc_camera_probe_finish()
1324 ret = soc_camera_init_user_formats(icd); in soc_camera_probe_finish()
1328 icd->field = V4L2_FIELD_ANY; in soc_camera_probe_finish()
1330 ret = soc_camera_video_start(icd); in soc_camera_probe_finish()
1336 icd->user_width = mf->width; in soc_camera_probe_finish()
1337 icd->user_height = mf->height; in soc_camera_probe_finish()
1338 icd->colorspace = mf->colorspace; in soc_camera_probe_finish()
1339 icd->field = mf->field; in soc_camera_probe_finish()
1341 soc_camera_remove_device(icd); in soc_camera_probe_finish()
1346 soc_camera_free_user_formats(icd); in soc_camera_probe_finish()
1348 soc_camera_remove_device(icd); in soc_camera_probe_finish()
1354 static int soc_camera_i2c_init(struct soc_camera_device *icd, in soc_camera_i2c_init() argument
1367 if (icd->sasc) { in soc_camera_i2c_init()
1372 ici = to_soc_camera_host(icd->parent); in soc_camera_i2c_init()
1375 dev_err(icd->pdev, "Cannot get I2C adapter #%d. No driver?\n", in soc_camera_i2c_init()
1397 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); in soc_camera_i2c_init()
1398 if (IS_ERR(icd->clk)) { in soc_camera_i2c_init()
1399 ret = PTR_ERR(icd->clk); in soc_camera_i2c_init()
1413 icd->control = &client->dev; in soc_camera_i2c_init()
1417 v4l2_clk_unregister(icd->clk); in soc_camera_i2c_init()
1418 icd->clk = NULL; in soc_camera_i2c_init()
1426 static void soc_camera_i2c_free(struct soc_camera_device *icd) in soc_camera_i2c_free() argument
1429 to_i2c_client(to_soc_camera_control(icd)); in soc_camera_i2c_free()
1433 icd->control = NULL; in soc_camera_i2c_free()
1434 if (icd->sasc) in soc_camera_i2c_free()
1443 v4l2_clk_unregister(icd->clk); in soc_camera_i2c_free()
1444 icd->clk = NULL; in soc_camera_i2c_free()
1461 struct soc_camera_device *icd = platform_get_drvdata(sasc->pdev); in soc_camera_async_bound() local
1463 if (asd == sasc->sensor && !WARN_ON(icd->control)) { in soc_camera_async_bound()
1471 struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); in soc_camera_async_bound()
1481 icd->control = &client->dev; in soc_camera_async_bound()
1494 struct soc_camera_device *icd = platform_get_drvdata(sasc->pdev); in soc_camera_async_unbind() local
1496 if (icd->clk) { in soc_camera_async_unbind()
1497 v4l2_clk_unregister(icd->clk); in soc_camera_async_unbind()
1498 icd->clk = NULL; in soc_camera_async_unbind()
1506 struct soc_camera_device *icd = platform_get_drvdata(sasc->pdev); in soc_camera_async_complete() local
1508 if (to_soc_camera_control(icd)) { in soc_camera_async_complete()
1509 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_async_complete()
1513 ret = soc_camera_probe(ici, icd); in soc_camera_async_complete()
1527 struct soc_camera_device *icd; in scan_async_group() local
1560 icd = soc_camera_add_pdev(sasc); in scan_async_group()
1561 if (!icd) { in scan_async_group()
1572 icd->sasc = sasc; in scan_async_group()
1573 icd->parent = ici->v4l2_dev.dev; in scan_async_group()
1578 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); in scan_async_group()
1579 if (IS_ERR(icd->clk)) { in scan_async_group()
1580 ret = PTR_ERR(icd->clk); in scan_async_group()
1588 v4l2_clk_unregister(icd->clk); in scan_async_group()
1590 icd->clk = NULL; in scan_async_group()
1612 #define soc_camera_i2c_init(icd, sdesc) (-ENODEV) argument
1613 #define soc_camera_i2c_free(icd) do {} while (0) argument
1629 struct soc_camera_device *icd; in soc_of_bind() local
1659 icd = soc_camera_add_pdev(sasc); in soc_of_bind()
1660 if (!icd) { in soc_of_bind()
1671 icd->sasc = sasc; in soc_of_bind()
1672 icd->parent = ici->v4l2_dev.dev; in soc_of_bind()
1683 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); in soc_of_bind()
1684 if (IS_ERR(icd->clk)) { in soc_of_bind()
1685 ret = PTR_ERR(icd->clk); in soc_of_bind()
1693 v4l2_clk_unregister(icd->clk); in soc_of_bind()
1695 icd->clk = NULL; in soc_of_bind()
1746 struct soc_camera_device *icd) in soc_camera_probe() argument
1748 struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); in soc_camera_probe()
1753 dev_info(icd->pdev, "Probing %s\n", dev_name(icd->pdev)); in soc_camera_probe()
1762 ret = v4l2_ctrl_handler_init(&icd->ctrl_handler, 16); in soc_camera_probe()
1767 ret = video_dev_create(icd); in soc_camera_probe()
1779 ret = soc_camera_i2c_init(icd, sdesc); in soc_camera_probe()
1793 ret = shd->add_device(icd); in soc_camera_probe()
1801 control = to_soc_camera_control(icd); in soc_camera_probe()
1804 shd->del_device(icd); in soc_camera_probe()
1811 ret = soc_camera_probe_finish(icd); in soc_camera_probe()
1820 soc_camera_i2c_free(icd); in soc_camera_probe()
1822 shd->del_device(icd); in soc_camera_probe()
1829 if (icd->vdev) { in soc_camera_probe()
1830 video_device_release(icd->vdev); in soc_camera_probe()
1831 icd->vdev = NULL; in soc_camera_probe()
1834 v4l2_ctrl_handler_free(&icd->ctrl_handler); in soc_camera_probe()
1844 static int soc_camera_remove(struct soc_camera_device *icd) in soc_camera_remove() argument
1846 struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); in soc_camera_remove()
1847 struct video_device *vdev = icd->vdev; in soc_camera_remove()
1849 v4l2_ctrl_handler_free(&icd->ctrl_handler); in soc_camera_remove()
1852 icd->vdev = NULL; in soc_camera_remove()
1856 soc_camera_i2c_free(icd); in soc_camera_remove()
1858 struct device *dev = to_soc_camera_control(icd); in soc_camera_remove()
1861 sdesc->host_desc.del_device(icd); in soc_camera_remove()
1866 if (icd->num_user_formats) in soc_camera_remove()
1867 soc_camera_free_user_formats(icd); in soc_camera_remove()
1869 if (icd->clk) { in soc_camera_remove()
1871 v4l2_clk_unregister(icd->clk); in soc_camera_remove()
1872 icd->clk = NULL; in soc_camera_remove()
1875 if (icd->sasc) in soc_camera_remove()
1876 platform_device_unregister(icd->sasc->pdev); in soc_camera_remove()
1881 static int default_cropcap(struct soc_camera_device *icd, in default_cropcap() argument
1884 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_cropcap()
1888 static int default_g_crop(struct soc_camera_device *icd, struct v4l2_crop *a) in default_g_crop() argument
1890 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_g_crop()
1894 static int default_s_crop(struct soc_camera_device *icd, const struct v4l2_crop *a) in default_s_crop() argument
1896 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_s_crop()
1900 static int default_g_parm(struct soc_camera_device *icd, in default_g_parm() argument
1903 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_g_parm()
1907 static int default_s_parm(struct soc_camera_device *icd, in default_s_parm() argument
1910 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_s_parm()
1914 static int default_enum_framesizes(struct soc_camera_device *icd, in default_enum_framesizes() argument
1918 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_enum_framesizes()
1925 xlate = soc_camera_xlate_by_fourcc(icd, fsize->pixel_format); in default_enum_framesizes()
2023 struct soc_camera_device *icd, *tmp; in soc_camera_host_unregister() local
2029 list_for_each_entry(icd, &devices, list) in soc_camera_host_unregister()
2030 if (icd->iface == ici->nr && icd->sasc) { in soc_camera_host_unregister()
2032 get_device(icd->pdev); in soc_camera_host_unregister()
2033 list_add(&icd->sasc->list, &notifiers); in soc_camera_host_unregister()
2045 list_for_each_entry_safe(icd, tmp, &devices, list) in soc_camera_host_unregister()
2046 if (icd->iface == ici->nr) in soc_camera_host_unregister()
2047 soc_camera_remove(icd); in soc_camera_host_unregister()
2056 static int soc_camera_device_register(struct soc_camera_device *icd) in soc_camera_device_register() argument
2066 if (ix->iface == icd->iface && ix->devnum == i) { in soc_camera_device_register()
2082 icd->devnum = num; in soc_camera_device_register()
2083 icd->use_count = 0; in soc_camera_device_register()
2084 icd->host_priv = NULL; in soc_camera_device_register()
2090 i = to_platform_device(icd->pdev)->id; in soc_camera_device_register()
2099 list_add_tail(&icd->list, &devices); in soc_camera_device_register()
2135 static int video_dev_create(struct soc_camera_device *icd) in video_dev_create() argument
2137 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in video_dev_create()
2149 vdev->ctrl_handler = &icd->ctrl_handler; in video_dev_create()
2152 icd->vdev = vdev; in video_dev_create()
2160 static int soc_camera_video_start(struct soc_camera_device *icd) in soc_camera_video_start() argument
2162 const struct device_type *type = icd->vdev->dev.type; in soc_camera_video_start()
2165 if (!icd->parent) in soc_camera_video_start()
2168 video_set_drvdata(icd->vdev, icd); in soc_camera_video_start()
2169 if (icd->vdev->tvnorms == 0) { in soc_camera_video_start()
2171 v4l2_disable_ioctl(icd->vdev, VIDIOC_G_STD); in soc_camera_video_start()
2172 v4l2_disable_ioctl(icd->vdev, VIDIOC_S_STD); in soc_camera_video_start()
2173 v4l2_disable_ioctl(icd->vdev, VIDIOC_ENUMSTD); in soc_camera_video_start()
2175 ret = video_register_device(icd->vdev, VFL_TYPE_GRABBER, -1); in soc_camera_video_start()
2177 dev_err(icd->pdev, "video_register_device failed: %d\n", ret); in soc_camera_video_start()
2182 icd->vdev->dev.type = type; in soc_camera_video_start()
2191 struct soc_camera_device *icd; in soc_camera_pdrv_probe() local
2197 icd = devm_kzalloc(&pdev->dev, sizeof(*icd), GFP_KERNEL); in soc_camera_pdrv_probe()
2198 if (!icd) in soc_camera_pdrv_probe()
2213 icd->iface = sdesc->host_desc.bus_id; in soc_camera_pdrv_probe()
2214 icd->sdesc = sdesc; in soc_camera_pdrv_probe()
2215 icd->pdev = &pdev->dev; in soc_camera_pdrv_probe()
2216 platform_set_drvdata(pdev, icd); in soc_camera_pdrv_probe()
2218 icd->user_width = DEFAULT_WIDTH; in soc_camera_pdrv_probe()
2219 icd->user_height = DEFAULT_HEIGHT; in soc_camera_pdrv_probe()
2221 return soc_camera_device_register(icd); in soc_camera_pdrv_probe()
2231 struct soc_camera_device *icd = platform_get_drvdata(pdev); in soc_camera_pdrv_remove() local
2234 if (!icd) in soc_camera_pdrv_remove()
2249 list_del(&icd->list); in soc_camera_pdrv_remove()