Lines Matching full:cam
73 struct camera_data *cam = video_drvdata(file); in cpia2_open() local
76 if (mutex_lock_interruptible(&cam->v4l2_lock)) in cpia2_open()
83 if (cpia2_allocate_buffers(cam)) { in cpia2_open()
90 if (cpia2_reset_camera(cam) < 0) { in cpia2_open()
96 cam->APP_len = 0; in cpia2_open()
97 cam->COM_len = 0; in cpia2_open()
100 cpia2_dbg_dump_registers(cam); in cpia2_open()
102 mutex_unlock(&cam->v4l2_lock); in cpia2_open()
114 struct camera_data *cam = video_get_drvdata(dev); in cpia2_close() local
116 mutex_lock(&cam->v4l2_lock); in cpia2_close()
117 if (video_is_registered(&cam->vdev) && v4l2_fh_is_singular_file(file)) { in cpia2_close()
118 cpia2_usb_stream_stop(cam); in cpia2_close()
121 cpia2_save_camera_state(cam); in cpia2_close()
123 cpia2_set_low_power(cam); in cpia2_close()
124 cpia2_free_buffers(cam); in cpia2_close()
127 if (cam->stream_fh == file->private_data) { in cpia2_close()
128 cam->stream_fh = NULL; in cpia2_close()
129 cam->mmapped = 0; in cpia2_close()
131 mutex_unlock(&cam->v4l2_lock); in cpia2_close()
143 struct camera_data *cam = video_drvdata(file); in cpia2_v4l_read() local
147 if(!cam) in cpia2_v4l_read()
150 if (mutex_lock_interruptible(&cam->v4l2_lock)) in cpia2_v4l_read()
152 ret = cpia2_read(cam, buf, count, noblock); in cpia2_v4l_read()
153 mutex_unlock(&cam->v4l2_lock); in cpia2_v4l_read()
165 struct camera_data *cam = video_drvdata(filp); in cpia2_v4l_poll() local
168 mutex_lock(&cam->v4l2_lock); in cpia2_v4l_poll()
169 res = cpia2_poll(cam, filp, wait); in cpia2_v4l_poll()
170 mutex_unlock(&cam->v4l2_lock); in cpia2_v4l_poll()
175 static int sync(struct camera_data *cam, int frame_nr) in sync() argument
177 struct framebuf *frame = &cam->buffers[frame_nr]; in sync()
183 if (!cam->streaming) { in sync()
189 mutex_unlock(&cam->v4l2_lock); in sync()
190 wait_event_interruptible(cam->wq_stream, in sync()
191 !cam->streaming || in sync()
193 mutex_lock(&cam->v4l2_lock); in sync()
196 if (!video_is_registered(&cam->vdev)) in sync()
211 struct camera_data *cam = video_drvdata(file); in cpia2_querycap() local
215 if (cam->params.pnp_id.product == 0x151) in cpia2_querycap()
219 switch (cam->params.pnp_id.device_type) { in cpia2_querycap()
230 switch (cam->params.version.sensor_flags) { in cpia2_querycap()
251 if (usb_make_path(cam->dev, vc->bus_info, sizeof(vc->bus_info)) <0) in cpia2_querycap()
316 struct camera_data *cam = video_drvdata(file); in cpia2_try_fmt_vid_cap() local
324 f->fmt.pix.sizeimage = cam->frame_size; in cpia2_try_fmt_vid_cap()
377 struct camera_data *cam = video_drvdata(file); in cpia2_s_fmt_vid_cap() local
384 cam->pixelformat = f->fmt.pix.pixelformat; in cpia2_s_fmt_vid_cap()
388 cam->params.compression.inhibit_htables = 0; in cpia2_s_fmt_vid_cap()
396 if (f->fmt.pix.width != cam->width || in cpia2_s_fmt_vid_cap()
397 f->fmt.pix.height != cam->height) { in cpia2_s_fmt_vid_cap()
398 cam->width = f->fmt.pix.width; in cpia2_s_fmt_vid_cap()
399 cam->height = f->fmt.pix.height; in cpia2_s_fmt_vid_cap()
400 cam->params.roi.width = f->fmt.pix.width; in cpia2_s_fmt_vid_cap()
401 cam->params.roi.height = f->fmt.pix.height; in cpia2_s_fmt_vid_cap()
402 cpia2_set_format(cam); in cpia2_s_fmt_vid_cap()
405 for (frame = 0; frame < cam->num_frames; ++frame) { in cpia2_s_fmt_vid_cap()
406 if (cam->buffers[frame].status == FRAME_READING) in cpia2_s_fmt_vid_cap()
407 if ((err = sync(cam, frame)) < 0) in cpia2_s_fmt_vid_cap()
410 cam->buffers[frame].status = FRAME_EMPTY; in cpia2_s_fmt_vid_cap()
427 struct camera_data *cam = video_drvdata(file); in cpia2_g_fmt_vid_cap() local
429 f->fmt.pix.width = cam->width; in cpia2_g_fmt_vid_cap()
430 f->fmt.pix.height = cam->height; in cpia2_g_fmt_vid_cap()
431 f->fmt.pix.pixelformat = cam->pixelformat; in cpia2_g_fmt_vid_cap()
434 f->fmt.pix.sizeimage = cam->frame_size; in cpia2_g_fmt_vid_cap()
452 struct camera_data *cam = video_drvdata(file); in cpia2_g_selection() local
462 s->r.width = cam->width; in cpia2_g_selection()
463 s->r.height = cam->height; in cpia2_g_selection()
487 struct camera_data *cam = video_drvdata(file); in cpia2_g_parm() local
495 cap->readbuffers = cam->num_frames; in cpia2_g_parm()
497 if (cam->params.vp_params.frame_rate == framerate_controls[i].value) { in cpia2_g_parm()
506 struct camera_data *cam = video_drvdata(file); in cpia2_s_parm() local
518 if (cam->params.pnp_id.device_type == DEVICE_STV_672 && in cpia2_s_parm()
519 cam->params.version.sensor_flags == CPIA2_VP_SENSOR_FLAGS_500) in cpia2_s_parm()
533 return cpia2_set_fps(cam, framerate_controls[i].value); in cpia2_s_parm()
569 struct camera_data *cam = video_drvdata(file); in cpia2_enum_frameintervals() local
578 if (cam->params.pnp_id.device_type == DEVICE_STV_672 && in cpia2_enum_frameintervals()
579 cam->params.version.sensor_flags == CPIA2_VP_SENSOR_FLAGS_500) in cpia2_enum_frameintervals()
604 struct camera_data *cam = in cpia2_s_ctrl() local
616 cpia2_set_brightness(cam, ctrl->val); in cpia2_s_ctrl()
619 cpia2_set_contrast(cam, ctrl->val); in cpia2_s_ctrl()
622 cpia2_set_saturation(cam, ctrl->val); in cpia2_s_ctrl()
625 cpia2_set_property_mirror(cam, ctrl->val); in cpia2_s_ctrl()
628 cpia2_set_property_flip(cam, ctrl->val); in cpia2_s_ctrl()
631 return cpia2_set_flicker_mode(cam, flicker_table[ctrl->val]); in cpia2_s_ctrl()
633 return cpia2_set_gpio(cam, (cam->top_light->val << 6) | in cpia2_s_ctrl()
634 (cam->bottom_light->val << 7)); in cpia2_s_ctrl()
636 cam->params.compression.inhibit_htables = in cpia2_s_ctrl()
640 cam->params.vc_params.quality = ctrl->val; in cpia2_s_ctrl()
643 cam->params.camera_state.stream_mode = ctrl->val; in cpia2_s_ctrl()
662 struct camera_data *cam = video_drvdata(file); in cpia2_g_jpegcomp() local
669 if(!cam->params.compression.inhibit_htables) { in cpia2_g_jpegcomp()
673 parms->APPn = cam->APPn; in cpia2_g_jpegcomp()
674 parms->APP_len = cam->APP_len; in cpia2_g_jpegcomp()
675 if(cam->APP_len > 0) { in cpia2_g_jpegcomp()
676 memcpy(parms->APP_data, cam->APP_data, cam->APP_len); in cpia2_g_jpegcomp()
680 parms->COM_len = cam->COM_len; in cpia2_g_jpegcomp()
681 if(cam->COM_len > 0) { in cpia2_g_jpegcomp()
682 memcpy(parms->COM_data, cam->COM_data, cam->COM_len); in cpia2_g_jpegcomp()
704 struct camera_data *cam = video_drvdata(file); in cpia2_s_jpegcomp() local
709 cam->params.compression.inhibit_htables = in cpia2_s_jpegcomp()
714 parms->APP_len <= sizeof(cam->APP_data) && in cpia2_s_jpegcomp()
716 cam->APPn = parms->APPn; in cpia2_s_jpegcomp()
717 cam->APP_len = parms->APP_len; in cpia2_s_jpegcomp()
718 memcpy(cam->APP_data, parms->APP_data, parms->APP_len); in cpia2_s_jpegcomp()
725 cam->APP_len = 0; in cpia2_s_jpegcomp()
730 parms->COM_len <= sizeof(cam->COM_data)) { in cpia2_s_jpegcomp()
731 cam->COM_len = parms->COM_len; in cpia2_s_jpegcomp()
732 memcpy(cam->COM_data, parms->COM_data, parms->COM_len); in cpia2_s_jpegcomp()
753 struct camera_data *cam = video_drvdata(file); in cpia2_reqbufs() local
759 DBG("REQBUFS requested:%d returning:%d\n", req->count, cam->num_frames); in cpia2_reqbufs()
760 req->count = cam->num_frames; in cpia2_reqbufs()
776 struct camera_data *cam = video_drvdata(file); in cpia2_querybuf() local
779 buf->index >= cam->num_frames) in cpia2_querybuf()
782 buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer; in cpia2_querybuf()
783 buf->length = cam->frame_size; in cpia2_querybuf()
787 if(cam->mmapped) in cpia2_querybuf()
794 switch (cam->buffers[buf->index].status) { in cpia2_querybuf()
802 buf->bytesused = cam->buffers[buf->index].length; in cpia2_querybuf()
803 v4l2_buffer_set_timestamp(buf, cam->buffers[buf->index].ts); in cpia2_querybuf()
804 buf->sequence = cam->buffers[buf->index].seq; in cpia2_querybuf()
826 struct camera_data *cam = video_drvdata(file); in cpia2_qbuf() local
830 buf->index >= cam->num_frames) in cpia2_qbuf()
835 if(cam->buffers[buf->index].status == FRAME_READY) in cpia2_qbuf()
836 cam->buffers[buf->index].status = FRAME_EMPTY; in cpia2_qbuf()
849 static int find_earliest_filled_buffer(struct camera_data *cam) in find_earliest_filled_buffer() argument
853 for (i=0; i<cam->num_frames; i++) { in find_earliest_filled_buffer()
854 if(cam->buffers[i].status == FRAME_READY) { in find_earliest_filled_buffer()
859 if (cam->buffers[i].ts < cam->buffers[found].ts) in find_earliest_filled_buffer()
877 struct camera_data *cam = video_drvdata(file); in cpia2_dqbuf() local
884 frame = find_earliest_filled_buffer(cam); in cpia2_dqbuf()
891 struct framebuf *cb=cam->curbuff; in cpia2_dqbuf()
892 mutex_unlock(&cam->v4l2_lock); in cpia2_dqbuf()
893 wait_event_interruptible(cam->wq_stream, in cpia2_dqbuf()
894 !video_is_registered(&cam->vdev) || in cpia2_dqbuf()
895 (cb=cam->curbuff)->status == FRAME_READY); in cpia2_dqbuf()
896 mutex_lock(&cam->v4l2_lock); in cpia2_dqbuf()
899 if (!video_is_registered(&cam->vdev)) in cpia2_dqbuf()
906 buf->bytesused = cam->buffers[buf->index].length; in cpia2_dqbuf()
910 v4l2_buffer_set_timestamp(buf, cam->buffers[buf->index].ts); in cpia2_dqbuf()
911 buf->sequence = cam->buffers[buf->index].seq; in cpia2_dqbuf()
912 buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer; in cpia2_dqbuf()
913 buf->length = cam->frame_size; in cpia2_dqbuf()
919 cam->buffers[buf->index].status, buf->sequence, buf->bytesused); in cpia2_dqbuf()
926 struct camera_data *cam = video_drvdata(file); in cpia2_streamon() local
929 DBG("VIDIOC_STREAMON, streaming=%d\n", cam->streaming); in cpia2_streamon()
930 if (!cam->mmapped || type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in cpia2_streamon()
933 if (!cam->streaming) { in cpia2_streamon()
934 ret = cpia2_usb_stream_start(cam, in cpia2_streamon()
935 cam->params.camera_state.stream_mode); in cpia2_streamon()
937 v4l2_ctrl_grab(cam->usb_alt, true); in cpia2_streamon()
944 struct camera_data *cam = video_drvdata(file); in cpia2_streamoff() local
947 DBG("VIDIOC_STREAMOFF, streaming=%d\n", cam->streaming); in cpia2_streamoff()
948 if (!cam->mmapped || type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in cpia2_streamoff()
951 if (cam->streaming) { in cpia2_streamoff()
952 ret = cpia2_usb_stream_stop(cam); in cpia2_streamoff()
954 v4l2_ctrl_grab(cam->usb_alt, false); in cpia2_streamoff()
966 struct camera_data *cam = video_drvdata(file); in cpia2_mmap() local
969 if (mutex_lock_interruptible(&cam->v4l2_lock)) in cpia2_mmap()
971 retval = cpia2_remap_buffer(cam, area); in cpia2_mmap()
974 cam->stream_fh = file->private_data; in cpia2_mmap()
975 mutex_unlock(&cam->v4l2_lock); in cpia2_mmap()
985 static void reset_camera_struct_v4l(struct camera_data *cam) in reset_camera_struct_v4l() argument
987 cam->width = cam->params.roi.width; in reset_camera_struct_v4l()
988 cam->height = cam->params.roi.height; in reset_camera_struct_v4l()
990 cam->frame_size = buffer_size; in reset_camera_struct_v4l()
991 cam->num_frames = num_buffers; in reset_camera_struct_v4l()
994 cam->params.flicker_control.flicker_mode_req = flicker_mode; in reset_camera_struct_v4l()
997 cam->params.camera_state.stream_mode = alternate; in reset_camera_struct_v4l()
999 cam->pixelformat = V4L2_PIX_FMT_JPEG; in reset_camera_struct_v4l()
1051 struct camera_data *cam = in cpia2_camera_release() local
1054 v4l2_ctrl_handler_free(&cam->hdl); in cpia2_camera_release()
1055 v4l2_device_unregister(&cam->v4l2_dev); in cpia2_camera_release()
1056 kfree(cam); in cpia2_camera_release()
1068 int cpia2_register_camera(struct camera_data *cam) in cpia2_register_camera() argument
1070 struct v4l2_ctrl_handler *hdl = &cam->hdl; in cpia2_register_camera()
1085 cam->params.pnp_id.device_type == DEVICE_STV_672 ? 1 : 0, in cpia2_register_camera()
1101 cam->usb_alt = v4l2_ctrl_new_custom(hdl, &cpia2_usb_alt, NULL); in cpia2_register_camera()
1103 if (cam->params.pnp_id.device_type != DEVICE_STV_672) in cpia2_register_camera()
1107 if (cam->params.pnp_id.device_type == DEVICE_STV_672) in cpia2_register_camera()
1112 if (cam->params.pnp_id.product == 0x151) { in cpia2_register_camera()
1113 cam->top_light = v4l2_ctrl_new_std(hdl, &cpia2_ctrl_ops, in cpia2_register_camera()
1115 cam->bottom_light = v4l2_ctrl_new_std(hdl, &cpia2_ctrl_ops, in cpia2_register_camera()
1117 v4l2_ctrl_cluster(2, &cam->top_light); in cpia2_register_camera()
1126 cam->vdev = cpia2_template; in cpia2_register_camera()
1127 video_set_drvdata(&cam->vdev, cam); in cpia2_register_camera()
1128 cam->vdev.lock = &cam->v4l2_lock; in cpia2_register_camera()
1129 cam->vdev.ctrl_handler = hdl; in cpia2_register_camera()
1130 cam->vdev.v4l2_dev = &cam->v4l2_dev; in cpia2_register_camera()
1131 cam->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | in cpia2_register_camera()
1134 reset_camera_struct_v4l(cam); in cpia2_register_camera()
1137 if (video_register_device(&cam->vdev, VFL_TYPE_VIDEO, video_nr) < 0) { in cpia2_register_camera()
1150 void cpia2_unregister_camera(struct camera_data *cam) in cpia2_unregister_camera() argument
1152 video_unregister_device(&cam->vdev); in cpia2_unregister_camera()