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()
339 struct soc_camera_device *icd = file->private_data; in soc_camera_s_std() local
340 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_s_std()
347 struct soc_camera_device *icd = file->private_data; in soc_camera_g_std() local
348 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_g_std()
356 struct soc_camera_device *icd = file->private_data; in soc_camera_enum_framesizes() local
357 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_enum_framesizes()
359 return ici->ops->enum_framesizes(icd, fsize); in soc_camera_enum_framesizes()
366 struct soc_camera_device *icd = file->private_data; in soc_camera_reqbufs() local
367 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_reqbufs()
371 if (icd->streamer && icd->streamer != file) in soc_camera_reqbufs()
375 ret = videobuf_reqbufs(&icd->vb_vidq, p); in soc_camera_reqbufs()
379 ret = ici->ops->reqbufs(icd, p); in soc_camera_reqbufs()
381 ret = vb2_reqbufs(&icd->vb2_vidq, p); in soc_camera_reqbufs()
384 if (!ret && !icd->streamer) in soc_camera_reqbufs()
385 icd->streamer = file; in soc_camera_reqbufs()
393 struct soc_camera_device *icd = file->private_data; in soc_camera_querybuf() local
394 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_querybuf()
399 return videobuf_querybuf(&icd->vb_vidq, p); in soc_camera_querybuf()
401 return vb2_querybuf(&icd->vb2_vidq, p); in soc_camera_querybuf()
407 struct soc_camera_device *icd = file->private_data; in soc_camera_qbuf() local
408 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_qbuf()
412 if (icd->streamer != file) in soc_camera_qbuf()
416 return videobuf_qbuf(&icd->vb_vidq, p); in soc_camera_qbuf()
418 return vb2_qbuf(&icd->vb2_vidq, p); in soc_camera_qbuf()
424 struct soc_camera_device *icd = file->private_data; in soc_camera_dqbuf() local
425 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_dqbuf()
429 if (icd->streamer != file) in soc_camera_dqbuf()
433 return videobuf_dqbuf(&icd->vb_vidq, p, file->f_flags & O_NONBLOCK); in soc_camera_dqbuf()
435 return vb2_dqbuf(&icd->vb2_vidq, p, file->f_flags & O_NONBLOCK); in soc_camera_dqbuf()
441 struct soc_camera_device *icd = file->private_data; in soc_camera_create_bufs() local
442 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_create_bufs()
448 return vb2_create_bufs(&icd->vb2_vidq, create); in soc_camera_create_bufs()
454 struct soc_camera_device *icd = file->private_data; in soc_camera_prepare_buf() local
455 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_prepare_buf()
461 return vb2_prepare_buf(&icd->vb2_vidq, b); in soc_camera_prepare_buf()
467 struct soc_camera_device *icd = file->private_data; in soc_camera_expbuf() local
468 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_expbuf()
470 if (icd->streamer != file) in soc_camera_expbuf()
477 return vb2_expbuf(&icd->vb2_vidq, p); in soc_camera_expbuf()
481 static int soc_camera_init_user_formats(struct soc_camera_device *icd) in soc_camera_init_user_formats() argument
483 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_init_user_formats()
484 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_init_user_formats()
504 ret = ici->ops->get_formats(icd, i, NULL); in soc_camera_init_user_formats()
513 icd->user_formats = in soc_camera_init_user_formats()
515 if (!icd->user_formats) in soc_camera_init_user_formats()
518 dev_dbg(icd->pdev, "Found %d supported formats.\n", fmts); in soc_camera_init_user_formats()
525 icd->user_formats[fmts].host_fmt = in soc_camera_init_user_formats()
527 if (icd->user_formats[fmts].host_fmt) in soc_camera_init_user_formats()
528 icd->user_formats[fmts++].code = code; in soc_camera_init_user_formats()
530 ret = ici->ops->get_formats(icd, i, in soc_camera_init_user_formats()
531 &icd->user_formats[fmts]); in soc_camera_init_user_formats()
537 icd->num_user_formats = fmts; in soc_camera_init_user_formats()
538 icd->current_fmt = &icd->user_formats[0]; in soc_camera_init_user_formats()
543 vfree(icd->user_formats); in soc_camera_init_user_formats()
548 static void soc_camera_free_user_formats(struct soc_camera_device *icd) in soc_camera_free_user_formats() argument
550 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_free_user_formats()
553 ici->ops->put_formats(icd); in soc_camera_free_user_formats()
554 icd->current_fmt = NULL; in soc_camera_free_user_formats()
555 icd->num_user_formats = 0; in soc_camera_free_user_formats()
556 vfree(icd->user_formats); in soc_camera_free_user_formats()
557 icd->user_formats = NULL; in soc_camera_free_user_formats()
561 static int soc_camera_set_fmt(struct soc_camera_device *icd, in soc_camera_set_fmt() argument
564 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_set_fmt()
568 dev_dbg(icd->pdev, "S_FMT(%c%c%c%c, %ux%u)\n", in soc_camera_set_fmt()
572 ret = soc_camera_try_fmt(icd, f); in soc_camera_set_fmt()
576 ret = ici->ops->set_fmt(icd, f); in soc_camera_set_fmt()
579 } else if (!icd->current_fmt || in soc_camera_set_fmt()
580 icd->current_fmt->host_fmt->fourcc != pix->pixelformat) { in soc_camera_set_fmt()
581 dev_err(icd->pdev, in soc_camera_set_fmt()
586 icd->user_width = pix->width; in soc_camera_set_fmt()
587 icd->user_height = pix->height; in soc_camera_set_fmt()
588 icd->bytesperline = pix->bytesperline; in soc_camera_set_fmt()
589 icd->sizeimage = pix->sizeimage; in soc_camera_set_fmt()
590 icd->colorspace = pix->colorspace; in soc_camera_set_fmt()
591 icd->field = pix->field; in soc_camera_set_fmt()
593 icd->vb_vidq.field = pix->field; in soc_camera_set_fmt()
595 dev_dbg(icd->pdev, "set width: %d height: %d\n", in soc_camera_set_fmt()
596 icd->user_width, icd->user_height); in soc_camera_set_fmt()
599 return ici->ops->set_bus_param(icd); in soc_camera_set_fmt()
602 static int soc_camera_add_device(struct soc_camera_device *icd) in soc_camera_add_device() argument
604 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_add_device()
607 if (ici->icd) in soc_camera_add_device()
610 if (!icd->clk) { in soc_camera_add_device()
617 ret = ici->ops->add(icd); in soc_camera_add_device()
622 ici->icd = icd; in soc_camera_add_device()
627 if (!icd->clk) in soc_camera_add_device()
632 static void soc_camera_remove_device(struct soc_camera_device *icd) in soc_camera_remove_device() argument
634 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_remove_device()
636 if (WARN_ON(icd != ici->icd)) in soc_camera_remove_device()
640 ici->ops->remove(icd); in soc_camera_remove_device()
641 if (!icd->clk) in soc_camera_remove_device()
643 ici->icd = NULL; in soc_camera_remove_device()
649 struct soc_camera_device *icd; in soc_camera_open() local
666 icd = video_get_drvdata(vdev); in soc_camera_open()
667 ici = to_soc_camera_host(icd->parent); in soc_camera_open()
673 dev_err(icd->pdev, "Couldn't lock capture bus driver.\n"); in soc_camera_open()
677 if (!to_soc_camera_control(icd)) { in soc_camera_open()
687 icd->use_count++; in soc_camera_open()
690 if (icd->use_count == 1) { in soc_camera_open()
691 struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); in soc_camera_open()
696 .width = icd->user_width, in soc_camera_open()
697 .height = icd->user_height, in soc_camera_open()
698 .field = icd->field, in soc_camera_open()
699 .colorspace = icd->colorspace, in soc_camera_open()
701 icd->current_fmt->host_fmt->fourcc, in soc_camera_open()
707 if (icd->control) in soc_camera_open()
708 sdesc->subdev_desc.reset(icd->control); in soc_camera_open()
710 ret = soc_camera_add_device(icd); in soc_camera_open()
712 dev_err(icd->pdev, "Couldn't activate the camera: %d\n", ret); in soc_camera_open()
716 ret = __soc_camera_power_on(icd); in soc_camera_open()
720 pm_runtime_enable(&icd->vdev->dev); in soc_camera_open()
721 ret = pm_runtime_resume(&icd->vdev->dev); in soc_camera_open()
731 ret = soc_camera_set_fmt(icd, &f); in soc_camera_open()
736 ici->ops->init_videobuf(&icd->vb_vidq, icd); in soc_camera_open()
738 ret = ici->ops->init_videobuf2(&icd->vb2_vidq, icd); in soc_camera_open()
742 v4l2_ctrl_handler_setup(&icd->ctrl_handler); in soc_camera_open()
746 file->private_data = icd; in soc_camera_open()
747 dev_dbg(icd->pdev, "camera device open\n"); in soc_camera_open()
757 pm_runtime_disable(&icd->vdev->dev); in soc_camera_open()
759 __soc_camera_power_off(icd); in soc_camera_open()
761 soc_camera_remove_device(icd); in soc_camera_open()
763 icd->use_count--; in soc_camera_open()
774 struct soc_camera_device *icd = file->private_data; in soc_camera_close() local
775 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_close()
778 icd->use_count--; in soc_camera_close()
779 if (!icd->use_count) { in soc_camera_close()
780 pm_runtime_suspend(&icd->vdev->dev); in soc_camera_close()
781 pm_runtime_disable(&icd->vdev->dev); in soc_camera_close()
784 vb2_queue_release(&icd->vb2_vidq); in soc_camera_close()
785 __soc_camera_power_off(icd); in soc_camera_close()
787 soc_camera_remove_device(icd); in soc_camera_close()
790 if (icd->streamer == file) in soc_camera_close()
791 icd->streamer = NULL; in soc_camera_close()
796 dev_dbg(icd->pdev, "camera device close\n"); in soc_camera_close()
804 struct soc_camera_device *icd = file->private_data; in soc_camera_read() local
805 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_read()
807 dev_dbg(icd->pdev, "read called, buf %p\n", buf); in soc_camera_read()
809 if (ici->ops->init_videobuf2 && icd->vb2_vidq.io_modes & VB2_READ) in soc_camera_read()
810 return vb2_read(&icd->vb2_vidq, buf, count, ppos, in soc_camera_read()
813 dev_err(icd->pdev, "camera device read not implemented\n"); in soc_camera_read()
820 struct soc_camera_device *icd = file->private_data; in soc_camera_mmap() local
821 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_mmap()
824 dev_dbg(icd->pdev, "mmap called, vma=0x%08lx\n", (unsigned long)vma); in soc_camera_mmap()
826 if (icd->streamer != file) in soc_camera_mmap()
832 err = videobuf_mmap_mapper(&icd->vb_vidq, vma); in soc_camera_mmap()
834 err = vb2_mmap(&icd->vb2_vidq, vma); in soc_camera_mmap()
837 dev_dbg(icd->pdev, "vma start=0x%08lx, size=%ld, ret=%d\n", in soc_camera_mmap()
847 struct soc_camera_device *icd = file->private_data; in soc_camera_poll() local
848 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_poll()
851 if (icd->streamer != file) in soc_camera_poll()
855 if (ici->ops->init_videobuf && list_empty(&icd->vb_vidq.stream)) in soc_camera_poll()
856 dev_err(icd->pdev, "Trying to poll with no queued buffers!\n"); in soc_camera_poll()
876 struct soc_camera_device *icd = file->private_data; in soc_camera_s_fmt_vid_cap() local
882 dev_warn(icd->pdev, "Wrong buf-type %d\n", f->type); in soc_camera_s_fmt_vid_cap()
886 if (icd->streamer && icd->streamer != file) in soc_camera_s_fmt_vid_cap()
889 if (is_streaming(to_soc_camera_host(icd->parent), icd)) { in soc_camera_s_fmt_vid_cap()
890 dev_err(icd->pdev, "S_FMT denied: queue initialised\n"); in soc_camera_s_fmt_vid_cap()
894 ret = soc_camera_set_fmt(icd, f); in soc_camera_s_fmt_vid_cap()
896 if (!ret && !icd->streamer) in soc_camera_s_fmt_vid_cap()
897 icd->streamer = file; in soc_camera_s_fmt_vid_cap()
905 struct soc_camera_device *icd = file->private_data; in soc_camera_enum_fmt_vid_cap() local
910 if (f->index >= icd->num_user_formats) in soc_camera_enum_fmt_vid_cap()
913 format = icd->user_formats[f->index].host_fmt; in soc_camera_enum_fmt_vid_cap()
924 struct soc_camera_device *icd = file->private_data; in soc_camera_g_fmt_vid_cap() local
932 pix->width = icd->user_width; in soc_camera_g_fmt_vid_cap()
933 pix->height = icd->user_height; in soc_camera_g_fmt_vid_cap()
934 pix->bytesperline = icd->bytesperline; in soc_camera_g_fmt_vid_cap()
935 pix->sizeimage = icd->sizeimage; in soc_camera_g_fmt_vid_cap()
936 pix->field = icd->field; in soc_camera_g_fmt_vid_cap()
937 pix->pixelformat = icd->current_fmt->host_fmt->fourcc; in soc_camera_g_fmt_vid_cap()
938 pix->colorspace = icd->colorspace; in soc_camera_g_fmt_vid_cap()
939 dev_dbg(icd->pdev, "current_fmt->fourcc: 0x%08x\n", in soc_camera_g_fmt_vid_cap()
940 icd->current_fmt->host_fmt->fourcc); in soc_camera_g_fmt_vid_cap()
947 struct soc_camera_device *icd = file->private_data; in soc_camera_querycap() local
948 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_querycap()
959 struct soc_camera_device *icd = file->private_data; in soc_camera_streamon() local
960 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_streamon()
961 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_streamon()
969 if (icd->streamer != file) in soc_camera_streamon()
974 ret = videobuf_streamon(&icd->vb_vidq); in soc_camera_streamon()
976 ret = vb2_streamon(&icd->vb2_vidq, i); in soc_camera_streamon()
987 struct soc_camera_device *icd = file->private_data; in soc_camera_streamoff() local
988 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_streamoff()
989 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_streamoff()
996 if (icd->streamer != file) in soc_camera_streamoff()
1004 videobuf_streamoff(&icd->vb_vidq); in soc_camera_streamoff()
1006 vb2_streamoff(&icd->vb2_vidq, i); in soc_camera_streamoff()
1016 struct soc_camera_device *icd = file->private_data; in soc_camera_cropcap() local
1017 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_cropcap()
1019 return ici->ops->cropcap(icd, a); in soc_camera_cropcap()
1025 struct soc_camera_device *icd = file->private_data; in soc_camera_g_crop() local
1026 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_g_crop()
1029 ret = ici->ops->get_crop(icd, a); in soc_camera_g_crop()
1042 struct soc_camera_device *icd = file->private_data; in soc_camera_s_crop() local
1043 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_s_crop()
1051 dev_dbg(icd->pdev, "S_CROP(%ux%u@%u:%u)\n", in soc_camera_s_crop()
1057 ret = ici->ops->get_crop(icd, ¤t_crop); in soc_camera_s_crop()
1061 dev_err(icd->pdev, in soc_camera_s_crop()
1065 !is_streaming(ici, icd)) { in soc_camera_s_crop()
1067 ret = ici->ops->set_crop(icd, a); in soc_camera_s_crop()
1069 ret = ici->ops->set_livecrop(icd, a); in soc_camera_s_crop()
1071 dev_err(icd->pdev, in soc_camera_s_crop()
1082 struct soc_camera_device *icd = file->private_data; in soc_camera_g_selection() local
1083 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_g_selection()
1092 return ici->ops->get_selection(icd, s); in soc_camera_g_selection()
1098 struct soc_camera_device *icd = file->private_data; in soc_camera_s_selection() local
1099 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_s_selection()
1110 if (is_streaming(ici, icd) && in soc_camera_s_selection()
1111 (icd->user_width != s->r.width || in soc_camera_s_selection()
1112 icd->user_height != s->r.height)) in soc_camera_s_selection()
1119 if (icd->streamer && icd->streamer != file) in soc_camera_s_selection()
1126 ret = ici->ops->set_selection(icd, s); in soc_camera_s_selection()
1129 icd->user_width = s->r.width; in soc_camera_s_selection()
1130 icd->user_height = s->r.height; in soc_camera_s_selection()
1131 if (!icd->streamer) in soc_camera_s_selection()
1132 icd->streamer = file; in soc_camera_s_selection()
1141 struct soc_camera_device *icd = file->private_data; in soc_camera_g_parm() local
1142 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_g_parm()
1145 return ici->ops->get_parm(icd, a); in soc_camera_g_parm()
1153 struct soc_camera_device *icd = file->private_data; in soc_camera_s_parm() local
1154 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_s_parm()
1157 return ici->ops->set_parm(icd, a); in soc_camera_s_parm()
1163 struct soc_camera_device *icd);
1168 struct soc_camera_device *icd; in scan_add_host() local
1172 list_for_each_entry(icd, &devices, list) in scan_add_host()
1173 if (icd->iface == ici->nr) { in scan_add_host()
1174 struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); in scan_add_host()
1179 if (icd->control) in scan_add_host()
1180 ssdd->reset(icd->control); in scan_add_host()
1182 icd->parent = ici->v4l2_dev.dev; in scan_add_host()
1185 soc_camera_probe(ici, icd); in scan_add_host()
1197 struct soc_camera_device *icd = clk->priv; in soc_camera_clk_enable() local
1200 if (!icd || !icd->parent) in soc_camera_clk_enable()
1203 ici = to_soc_camera_host(icd->parent); in soc_camera_clk_enable()
1217 struct soc_camera_device *icd = clk->priv; in soc_camera_clk_disable() local
1220 if (!icd || !icd->parent) in soc_camera_clk_disable()
1223 ici = to_soc_camera_host(icd->parent); in soc_camera_clk_disable()
1284 static int soc_camera_probe_finish(struct soc_camera_device *icd) in soc_camera_probe_finish() argument
1286 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in soc_camera_probe_finish()
1290 sd->grp_id = soc_camera_grp_id(icd); in soc_camera_probe_finish()
1291 v4l2_set_subdev_hostdata(sd, icd); in soc_camera_probe_finish()
1293 v4l2_subdev_call(sd, video, g_tvnorms, &icd->vdev->tvnorms); in soc_camera_probe_finish()
1295 ret = v4l2_ctrl_add_handler(&icd->ctrl_handler, sd->ctrl_handler, NULL); in soc_camera_probe_finish()
1299 ret = soc_camera_add_device(icd); in soc_camera_probe_finish()
1301 dev_err(icd->pdev, "Couldn't activate the camera: %d\n", ret); in soc_camera_probe_finish()
1306 ret = soc_camera_init_user_formats(icd); in soc_camera_probe_finish()
1310 icd->field = V4L2_FIELD_ANY; in soc_camera_probe_finish()
1312 ret = soc_camera_video_start(icd); in soc_camera_probe_finish()
1318 icd->user_width = mf.width; in soc_camera_probe_finish()
1319 icd->user_height = mf.height; in soc_camera_probe_finish()
1320 icd->colorspace = mf.colorspace; in soc_camera_probe_finish()
1321 icd->field = mf.field; in soc_camera_probe_finish()
1323 soc_camera_remove_device(icd); in soc_camera_probe_finish()
1328 soc_camera_free_user_formats(icd); in soc_camera_probe_finish()
1330 soc_camera_remove_device(icd); in soc_camera_probe_finish()
1336 static int soc_camera_i2c_init(struct soc_camera_device *icd, in soc_camera_i2c_init() argument
1349 if (icd->sasc) { in soc_camera_i2c_init()
1354 ici = to_soc_camera_host(icd->parent); in soc_camera_i2c_init()
1357 dev_err(icd->pdev, "Cannot get I2C adapter #%d. No driver?\n", in soc_camera_i2c_init()
1379 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); in soc_camera_i2c_init()
1380 if (IS_ERR(icd->clk)) { in soc_camera_i2c_init()
1381 ret = PTR_ERR(icd->clk); in soc_camera_i2c_init()
1395 icd->control = &client->dev; in soc_camera_i2c_init()
1399 v4l2_clk_unregister(icd->clk); in soc_camera_i2c_init()
1400 icd->clk = NULL; in soc_camera_i2c_init()
1408 static void soc_camera_i2c_free(struct soc_camera_device *icd) in soc_camera_i2c_free() argument
1411 to_i2c_client(to_soc_camera_control(icd)); in soc_camera_i2c_free()
1415 icd->control = NULL; in soc_camera_i2c_free()
1416 if (icd->sasc) in soc_camera_i2c_free()
1425 v4l2_clk_unregister(icd->clk); in soc_camera_i2c_free()
1426 icd->clk = NULL; in soc_camera_i2c_free()
1443 struct soc_camera_device *icd = platform_get_drvdata(sasc->pdev); in soc_camera_async_bound() local
1445 if (asd == sasc->sensor && !WARN_ON(icd->control)) { in soc_camera_async_bound()
1453 struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); in soc_camera_async_bound()
1463 icd->control = &client->dev; in soc_camera_async_bound()
1476 struct soc_camera_device *icd = platform_get_drvdata(sasc->pdev); in soc_camera_async_unbind() local
1478 if (icd->clk) { in soc_camera_async_unbind()
1479 v4l2_clk_unregister(icd->clk); in soc_camera_async_unbind()
1480 icd->clk = NULL; in soc_camera_async_unbind()
1488 struct soc_camera_device *icd = platform_get_drvdata(sasc->pdev); in soc_camera_async_complete() local
1490 if (to_soc_camera_control(icd)) { in soc_camera_async_complete()
1491 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in soc_camera_async_complete()
1495 ret = soc_camera_probe(ici, icd); in soc_camera_async_complete()
1509 struct soc_camera_device *icd; in scan_async_group() local
1542 icd = soc_camera_add_pdev(sasc); in scan_async_group()
1543 if (!icd) { in scan_async_group()
1554 icd->sasc = sasc; in scan_async_group()
1555 icd->parent = ici->v4l2_dev.dev; in scan_async_group()
1560 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); in scan_async_group()
1561 if (IS_ERR(icd->clk)) { in scan_async_group()
1562 ret = PTR_ERR(icd->clk); in scan_async_group()
1570 v4l2_clk_unregister(icd->clk); in scan_async_group()
1572 icd->clk = NULL; in scan_async_group()
1594 #define soc_camera_i2c_init(icd, sdesc) (-ENODEV) argument
1595 #define soc_camera_i2c_free(icd) do {} while (0) argument
1611 struct soc_camera_device *icd; in soc_of_bind() local
1641 icd = soc_camera_add_pdev(sasc); in soc_of_bind()
1642 if (!icd) { in soc_of_bind()
1653 icd->sasc = sasc; in soc_of_bind()
1654 icd->parent = ici->v4l2_dev.dev; in soc_of_bind()
1665 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); in soc_of_bind()
1666 if (IS_ERR(icd->clk)) { in soc_of_bind()
1667 ret = PTR_ERR(icd->clk); in soc_of_bind()
1675 v4l2_clk_unregister(icd->clk); in soc_of_bind()
1677 icd->clk = NULL; in soc_of_bind()
1728 struct soc_camera_device *icd) in soc_camera_probe() argument
1730 struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); in soc_camera_probe()
1735 dev_info(icd->pdev, "Probing %s\n", dev_name(icd->pdev)); in soc_camera_probe()
1744 ret = v4l2_ctrl_handler_init(&icd->ctrl_handler, 16); in soc_camera_probe()
1749 ret = video_dev_create(icd); in soc_camera_probe()
1761 ret = soc_camera_i2c_init(icd, sdesc); in soc_camera_probe()
1775 ret = shd->add_device(icd); in soc_camera_probe()
1783 control = to_soc_camera_control(icd); in soc_camera_probe()
1786 shd->del_device(icd); in soc_camera_probe()
1793 ret = soc_camera_probe_finish(icd); in soc_camera_probe()
1802 soc_camera_i2c_free(icd); in soc_camera_probe()
1804 shd->del_device(icd); in soc_camera_probe()
1811 if (icd->vdev) { in soc_camera_probe()
1812 video_device_release(icd->vdev); in soc_camera_probe()
1813 icd->vdev = NULL; in soc_camera_probe()
1816 v4l2_ctrl_handler_free(&icd->ctrl_handler); in soc_camera_probe()
1826 static int soc_camera_remove(struct soc_camera_device *icd) in soc_camera_remove() argument
1828 struct soc_camera_desc *sdesc = to_soc_camera_desc(icd); in soc_camera_remove()
1829 struct video_device *vdev = icd->vdev; in soc_camera_remove()
1831 v4l2_ctrl_handler_free(&icd->ctrl_handler); in soc_camera_remove()
1834 icd->vdev = NULL; in soc_camera_remove()
1838 soc_camera_i2c_free(icd); in soc_camera_remove()
1840 struct device *dev = to_soc_camera_control(icd); in soc_camera_remove()
1843 sdesc->host_desc.del_device(icd); in soc_camera_remove()
1848 if (icd->num_user_formats) in soc_camera_remove()
1849 soc_camera_free_user_formats(icd); in soc_camera_remove()
1851 if (icd->clk) { in soc_camera_remove()
1853 v4l2_clk_unregister(icd->clk); in soc_camera_remove()
1854 icd->clk = NULL; in soc_camera_remove()
1857 if (icd->sasc) in soc_camera_remove()
1858 platform_device_unregister(icd->sasc->pdev); in soc_camera_remove()
1863 static int default_cropcap(struct soc_camera_device *icd, in default_cropcap() argument
1866 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_cropcap()
1870 static int default_g_crop(struct soc_camera_device *icd, struct v4l2_crop *a) in default_g_crop() argument
1872 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_g_crop()
1876 static int default_s_crop(struct soc_camera_device *icd, const struct v4l2_crop *a) in default_s_crop() argument
1878 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_s_crop()
1882 static int default_g_parm(struct soc_camera_device *icd, in default_g_parm() argument
1885 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_g_parm()
1889 static int default_s_parm(struct soc_camera_device *icd, in default_s_parm() argument
1892 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_s_parm()
1896 static int default_enum_framesizes(struct soc_camera_device *icd, in default_enum_framesizes() argument
1900 struct v4l2_subdev *sd = soc_camera_to_subdev(icd); in default_enum_framesizes()
1907 xlate = soc_camera_xlate_by_fourcc(icd, fsize->pixel_format); in default_enum_framesizes()
2005 struct soc_camera_device *icd, *tmp; in soc_camera_host_unregister() local
2011 list_for_each_entry(icd, &devices, list) in soc_camera_host_unregister()
2012 if (icd->iface == ici->nr && icd->sasc) { in soc_camera_host_unregister()
2014 get_device(icd->pdev); in soc_camera_host_unregister()
2015 list_add(&icd->sasc->list, ¬ifiers); in soc_camera_host_unregister()
2027 list_for_each_entry_safe(icd, tmp, &devices, list) in soc_camera_host_unregister()
2028 if (icd->iface == ici->nr) in soc_camera_host_unregister()
2029 soc_camera_remove(icd); in soc_camera_host_unregister()
2038 static int soc_camera_device_register(struct soc_camera_device *icd) in soc_camera_device_register() argument
2048 if (ix->iface == icd->iface && ix->devnum == i) { in soc_camera_device_register()
2064 icd->devnum = num; in soc_camera_device_register()
2065 icd->use_count = 0; in soc_camera_device_register()
2066 icd->host_priv = NULL; in soc_camera_device_register()
2072 i = to_platform_device(icd->pdev)->id; in soc_camera_device_register()
2081 list_add_tail(&icd->list, &devices); in soc_camera_device_register()
2117 static int video_dev_create(struct soc_camera_device *icd) in video_dev_create() argument
2119 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); in video_dev_create()
2131 vdev->ctrl_handler = &icd->ctrl_handler; in video_dev_create()
2134 icd->vdev = vdev; in video_dev_create()
2142 static int soc_camera_video_start(struct soc_camera_device *icd) in soc_camera_video_start() argument
2144 const struct device_type *type = icd->vdev->dev.type; in soc_camera_video_start()
2147 if (!icd->parent) in soc_camera_video_start()
2150 video_set_drvdata(icd->vdev, icd); in soc_camera_video_start()
2151 if (icd->vdev->tvnorms == 0) { in soc_camera_video_start()
2153 v4l2_disable_ioctl(icd->vdev, VIDIOC_G_STD); in soc_camera_video_start()
2154 v4l2_disable_ioctl(icd->vdev, VIDIOC_S_STD); in soc_camera_video_start()
2155 v4l2_disable_ioctl(icd->vdev, VIDIOC_ENUMSTD); in soc_camera_video_start()
2157 ret = video_register_device(icd->vdev, VFL_TYPE_GRABBER, -1); in soc_camera_video_start()
2159 dev_err(icd->pdev, "video_register_device failed: %d\n", ret); in soc_camera_video_start()
2164 icd->vdev->dev.type = type; in soc_camera_video_start()
2173 struct soc_camera_device *icd; in soc_camera_pdrv_probe() local
2179 icd = devm_kzalloc(&pdev->dev, sizeof(*icd), GFP_KERNEL); in soc_camera_pdrv_probe()
2180 if (!icd) in soc_camera_pdrv_probe()
2195 icd->iface = sdesc->host_desc.bus_id; in soc_camera_pdrv_probe()
2196 icd->sdesc = sdesc; in soc_camera_pdrv_probe()
2197 icd->pdev = &pdev->dev; in soc_camera_pdrv_probe()
2198 platform_set_drvdata(pdev, icd); in soc_camera_pdrv_probe()
2200 icd->user_width = DEFAULT_WIDTH; in soc_camera_pdrv_probe()
2201 icd->user_height = DEFAULT_HEIGHT; in soc_camera_pdrv_probe()
2203 return soc_camera_device_register(icd); in soc_camera_pdrv_probe()
2213 struct soc_camera_device *icd = platform_get_drvdata(pdev); in soc_camera_pdrv_remove() local
2216 if (!icd) in soc_camera_pdrv_remove()
2231 list_del(&icd->list); in soc_camera_pdrv_remove()