Lines Matching refs:camif

68 static int s3c_camif_hw_init(struct camif_dev *camif, struct camif_vp *vp)  in s3c_camif_hw_init()  argument
70 const struct s3c_camif_variant *variant = camif->variant; in s3c_camif_hw_init()
72 if (camif->sensor.sd == NULL || vp->out_fmt == NULL) in s3c_camif_hw_init()
77 camif_hw_set_camera_bus(camif); in s3c_camif_hw_init()
78 camif_hw_set_source_format(camif); in s3c_camif_hw_init()
79 camif_hw_set_camera_crop(camif); in s3c_camif_hw_init()
80 camif_hw_set_test_pattern(camif, camif->test_pattern); in s3c_camif_hw_init()
82 camif_hw_set_effect(camif, camif->colorfx, in s3c_camif_hw_init()
83 camif->colorfx_cb, camif->colorfx_cr); in s3c_camif_hw_init()
98 static int s3c_camif_hw_vp_init(struct camif_dev *camif, struct camif_vp *vp) in s3c_camif_hw_vp_init() argument
100 unsigned int ip_rev = camif->variant->ip_revision; in s3c_camif_hw_vp_init()
113 static int sensor_set_power(struct camif_dev *camif, int on) in sensor_set_power() argument
115 struct cam_sensor *sensor = &camif->sensor; in sensor_set_power()
118 if (!on == camif->sensor.power_count) in sensor_set_power()
129 static int sensor_set_streaming(struct camif_dev *camif, int on) in sensor_set_streaming() argument
131 struct cam_sensor *sensor = &camif->sensor; in sensor_set_streaming()
134 if (!on == camif->sensor.stream_count) in sensor_set_streaming()
152 struct camif_dev *camif = vp->camif; in camif_reinitialize() local
157 spin_lock_irqsave(&camif->slock, flags); in camif_reinitialize()
175 spin_unlock_irqrestore(&camif->slock, flags); in camif_reinitialize()
180 return sensor_set_streaming(camif, 0); in camif_reinitialize()
185 struct camif_dev *camif = vp->camif; in s3c_vp_active() local
189 spin_lock_irqsave(&camif->slock, flags); in s3c_vp_active()
191 spin_unlock_irqrestore(&camif->slock, flags); in s3c_vp_active()
196 static bool camif_is_streaming(struct camif_dev *camif) in camif_is_streaming() argument
201 spin_lock_irqsave(&camif->slock, flags); in camif_is_streaming()
202 status = camif->stream_count > 0; in camif_is_streaming()
203 spin_unlock_irqrestore(&camif->slock, flags); in camif_is_streaming()
210 struct camif_dev *camif = vp->camif; in camif_stop_capture() local
217 spin_lock_irqsave(&camif->slock, flags); in camif_stop_capture()
220 spin_unlock_irqrestore(&camif->slock, flags); in camif_stop_capture()
226 spin_lock_irqsave(&camif->slock, flags); in camif_stop_capture()
237 spin_unlock_irqrestore(&camif->slock, flags); in camif_stop_capture()
292 struct camif_dev *camif = vp->camif; in s3c_camif_irq_handler() local
293 unsigned int ip_rev = camif->variant->ip_revision; in s3c_camif_irq_handler()
296 spin_lock(&camif->slock); in s3c_camif_irq_handler()
367 camif_hw_set_camera_crop(camif); in s3c_camif_irq_handler()
370 camif_hw_set_test_pattern(camif, camif->test_pattern); in s3c_camif_irq_handler()
371 if (camif->variant->has_img_effect) in s3c_camif_irq_handler()
372 camif_hw_set_effect(camif, camif->colorfx, in s3c_camif_irq_handler()
373 camif->colorfx_cb, camif->colorfx_cr); in s3c_camif_irq_handler()
377 spin_unlock(&camif->slock); in s3c_camif_irq_handler()
384 struct camif_dev *camif = vp->camif; in start_streaming() local
394 spin_lock_irqsave(&camif->slock, flags); in start_streaming()
396 if (camif->stream_count == 0) { in start_streaming()
397 camif_hw_reset(camif); in start_streaming()
398 ret = s3c_camif_hw_init(camif, vp); in start_streaming()
400 ret = s3c_camif_hw_vp_init(camif, vp); in start_streaming()
402 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
409 spin_lock_irqsave(&camif->slock, flags); in start_streaming()
423 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
424 ret = sensor_set_streaming(camif, 1); in start_streaming()
428 camif_hw_dump_regs(camif, __func__); in start_streaming()
434 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
450 struct camif_dev *camif = vp->camif; in queue_setup() local
471 allocators[0] = camif->alloc_ctx; in queue_setup()
498 struct camif_dev *camif = vp->camif; in buffer_queue() local
501 spin_lock_irqsave(&camif->slock, flags); in buffer_queue()
523 spin_unlock_irqrestore(&camif->slock, flags); in buffer_queue()
526 if (sensor_set_streaming(camif, 1) == 0) in buffer_queue()
532 camif_hw_dump_regs(camif, __func__); in buffer_queue()
536 spin_unlock_irqrestore(&camif->slock, flags); in buffer_queue()
552 struct camif_dev *camif = vp->camif; in s3c_camif_open() local
558 if (mutex_lock_interruptible(&camif->lock)) in s3c_camif_open()
565 ret = pm_runtime_get_sync(camif->dev); in s3c_camif_open()
569 ret = sensor_set_power(camif, 1); in s3c_camif_open()
573 pm_runtime_put(camif->dev); in s3c_camif_open()
577 mutex_unlock(&camif->lock); in s3c_camif_open()
584 struct camif_dev *camif = vp->camif; in s3c_camif_close() local
590 mutex_lock(&camif->lock); in s3c_camif_close()
598 sensor_set_power(camif, 0); in s3c_camif_close()
600 pm_runtime_put(camif->dev); in s3c_camif_close()
603 mutex_unlock(&camif->lock); in s3c_camif_close()
611 struct camif_dev *camif = vp->camif; in s3c_camif_poll() local
614 mutex_lock(&camif->lock); in s3c_camif_poll()
620 mutex_unlock(&camif->lock); in s3c_camif_poll()
658 dev_name(vp->camif->dev), vp->id); in s3c_camif_vidioc_querycap()
670 struct v4l2_subdev *sensor = vp->camif->sensor.sd; in s3c_camif_vidioc_enum_input()
734 struct camif_dev *camif = vp->camif; in __camif_video_try_format() local
735 struct v4l2_rect *crop = &camif->camif_crop; in __camif_video_try_format()
748 pix_lim = &camif->variant->vp_pix_limits[vp->id]; in __camif_video_try_format()
829 static int camif_pipeline_validate(struct camif_dev *camif) in camif_pipeline_validate() argument
836 pad = media_entity_remote_pad(&camif->pads[0]); in camif_pipeline_validate()
842 ret = v4l2_subdev_call(camif->sensor.sd, pad, get_fmt, NULL, &src_fmt); in camif_pipeline_validate()
846 if (src_fmt.format.width != camif->mbus_fmt.width || in camif_pipeline_validate()
847 src_fmt.format.height != camif->mbus_fmt.height || in camif_pipeline_validate()
848 src_fmt.format.code != camif->mbus_fmt.code) in camif_pipeline_validate()
858 struct camif_dev *camif = vp->camif; in s3c_camif_streamon() local
859 struct media_entity *sensor = &camif->sensor.sd->entity; in s3c_camif_streamon()
873 ret = media_entity_pipeline_start(sensor, camif->m_pipeline); in s3c_camif_streamon()
877 ret = camif_pipeline_validate(camif); in s3c_camif_streamon()
890 struct camif_dev *camif = vp->camif; in s3c_camif_streamoff() local
903 media_entity_pipeline_stop(&camif->sensor.sd->entity); in s3c_camif_streamoff()
1024 static void __camif_try_compose(struct camif_dev *camif, struct camif_vp *vp, in __camif_try_compose() argument
1028 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV) { in __camif_try_compose()
1040 struct camif_dev *camif = vp->camif; in s3c_camif_s_selection() local
1048 __camif_try_compose(camif, vp, &rect); in s3c_camif_s_selection()
1051 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_s_selection()
1054 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_s_selection()
1093 struct camif_dev *camif = vp->camif; in s3c_camif_video_s_ctrl() local
1099 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_video_s_ctrl()
1112 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_video_s_ctrl()
1121 int s3c_camif_register_video_node(struct camif_dev *camif, int idx) in s3c_camif_register_video_node() argument
1123 struct camif_vp *vp = &camif->vp[idx]; in s3c_camif_register_video_node()
1135 vfd->v4l2_dev = &camif->v4l2_dev; in s3c_camif_register_video_node()
1138 vfd->lock = &camif->lock; in s3c_camif_register_video_node()
1152 q->lock = &vp->camif->lock; in s3c_camif_register_video_node()
1185 v4l2_info(&camif->v4l2_dev, "registered %s as /dev/%s\n", in s3c_camif_register_video_node()
1198 void s3c_camif_unregister_video_node(struct camif_dev *camif, int idx) in s3c_camif_unregister_video_node() argument
1200 struct video_device *vfd = &camif->vp[idx].vdev; in s3c_camif_unregister_video_node()
1236 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_get_fmt() local
1245 mutex_lock(&camif->lock); in s3c_camif_subdev_get_fmt()
1250 *mf = camif->mbus_fmt; in s3c_camif_subdev_get_fmt()
1255 mf->width = camif->camif_crop.width; in s3c_camif_subdev_get_fmt()
1256 mf->height = camif->camif_crop.height; in s3c_camif_subdev_get_fmt()
1257 mf->code = camif->mbus_fmt.code; in s3c_camif_subdev_get_fmt()
1261 mutex_unlock(&camif->lock); in s3c_camif_subdev_get_fmt()
1267 static void __camif_subdev_try_format(struct camif_dev *camif, in __camif_subdev_try_format() argument
1270 const struct s3c_camif_variant *variant = camif->variant; in __camif_subdev_try_format()
1289 struct v4l2_rect *crop = &camif->camif_crop; in __camif_subdev_try_format()
1296 v4l2_dbg(1, debug, &camif->subdev, "%ux%u\n", mf->width, mf->height); in __camif_subdev_try_format()
1303 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_set_fmt() local
1305 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_set_fmt()
1313 mutex_lock(&camif->lock); in s3c_camif_subdev_set_fmt()
1319 if (vb2_is_busy(&camif->vp[VP_CODEC].vb_queue) || in s3c_camif_subdev_set_fmt()
1320 vb2_is_busy(&camif->vp[VP_PREVIEW].vb_queue)) { in s3c_camif_subdev_set_fmt()
1321 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1325 __camif_subdev_try_format(camif, mf, fmt->pad); in s3c_camif_subdev_set_fmt()
1330 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1336 camif->mbus_fmt = *mf; in s3c_camif_subdev_set_fmt()
1347 struct camif_frame *frame = &camif->vp[i].out_frame; in s3c_camif_subdev_set_fmt()
1356 mf->code = camif->mbus_fmt.code; in s3c_camif_subdev_set_fmt()
1362 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1370 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_get_selection() local
1371 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_get_selection()
1372 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt; in s3c_camif_subdev_get_selection()
1384 mutex_lock(&camif->lock); in s3c_camif_subdev_get_selection()
1395 mutex_unlock(&camif->lock); in s3c_camif_subdev_get_selection()
1404 static void __camif_try_crop(struct camif_dev *camif, struct v4l2_rect *r) in __camif_try_crop() argument
1406 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt; in __camif_try_crop()
1407 const struct camif_pix_limits *pix_lim = &camif->variant->pix_limits; in __camif_try_crop()
1435 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV && in __camif_try_crop()
1436 camif_is_streaming(camif)) { in __camif_try_crop()
1440 struct v4l2_rect *or = &camif->vp[i].out_frame.rect; in __camif_try_crop()
1443 *r = camif->camif_crop; in __camif_try_crop()
1449 v4l2_dbg(1, debug, &camif->v4l2_dev, "crop: (%d,%d)/%dx%d, fmt: %ux%u\n", in __camif_try_crop()
1457 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_set_selection() local
1458 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_set_selection()
1464 mutex_lock(&camif->lock); in s3c_camif_subdev_set_selection()
1465 __camif_try_crop(camif, &sel->r); in s3c_camif_subdev_set_selection()
1473 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_subdev_set_selection()
1477 struct camif_vp *vp = &camif->vp[i]; in s3c_camif_subdev_set_selection()
1485 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_subdev_set_selection()
1487 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_selection()
1491 camif->mbus_fmt.width, camif->mbus_fmt.height); in s3c_camif_subdev_set_selection()
1510 struct camif_dev *camif = container_of(ctrl->handler, struct camif_dev, in s3c_camif_subdev_s_ctrl() local
1514 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_subdev_s_ctrl()
1518 camif->colorfx = camif->ctrl_colorfx->val; in s3c_camif_subdev_s_ctrl()
1522 camif->colorfx_cb = 115; in s3c_camif_subdev_s_ctrl()
1523 camif->colorfx_cr = 145; in s3c_camif_subdev_s_ctrl()
1526 camif->colorfx_cb = camif->ctrl_colorfx_cbcr->val >> 8; in s3c_camif_subdev_s_ctrl()
1527 camif->colorfx_cr = camif->ctrl_colorfx_cbcr->val & 0xff; in s3c_camif_subdev_s_ctrl()
1531 camif->colorfx_cb = 128; in s3c_camif_subdev_s_ctrl()
1532 camif->colorfx_cr = 128; in s3c_camif_subdev_s_ctrl()
1536 camif->test_pattern = camif->ctrl_test_pattern->val; in s3c_camif_subdev_s_ctrl()
1542 camif->vp[VP_CODEC].state |= ST_VP_CONFIG; in s3c_camif_subdev_s_ctrl()
1543 camif->vp[VP_PREVIEW].state |= ST_VP_CONFIG; in s3c_camif_subdev_s_ctrl()
1544 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_subdev_s_ctrl()
1560 int s3c_camif_create_subdev(struct camif_dev *camif) in s3c_camif_create_subdev() argument
1562 struct v4l2_ctrl_handler *handler = &camif->ctrl_handler; in s3c_camif_create_subdev()
1563 struct v4l2_subdev *sd = &camif->subdev; in s3c_camif_create_subdev()
1570 camif->pads[CAMIF_SD_PAD_SINK].flags = MEDIA_PAD_FL_SINK; in s3c_camif_create_subdev()
1571 camif->pads[CAMIF_SD_PAD_SOURCE_C].flags = MEDIA_PAD_FL_SOURCE; in s3c_camif_create_subdev()
1572 camif->pads[CAMIF_SD_PAD_SOURCE_P].flags = MEDIA_PAD_FL_SOURCE; in s3c_camif_create_subdev()
1575 camif->pads, 0); in s3c_camif_create_subdev()
1580 camif->ctrl_test_pattern = v4l2_ctrl_new_std_menu_items(handler, in s3c_camif_create_subdev()
1585 if (camif->variant->has_img_effect) { in s3c_camif_create_subdev()
1586 camif->ctrl_colorfx = v4l2_ctrl_new_std_menu(handler, in s3c_camif_create_subdev()
1591 camif->ctrl_colorfx_cbcr = v4l2_ctrl_new_std(handler, in s3c_camif_create_subdev()
1602 if (camif->variant->has_img_effect) in s3c_camif_create_subdev()
1603 v4l2_ctrl_auto_cluster(2, &camif->ctrl_colorfx, in s3c_camif_create_subdev()
1607 v4l2_set_subdevdata(sd, camif); in s3c_camif_create_subdev()
1612 void s3c_camif_unregister_subdev(struct camif_dev *camif) in s3c_camif_unregister_subdev() argument
1614 struct v4l2_subdev *sd = &camif->subdev; in s3c_camif_unregister_subdev()
1622 v4l2_ctrl_handler_free(&camif->ctrl_handler); in s3c_camif_unregister_subdev()
1626 int s3c_camif_set_defaults(struct camif_dev *camif) in s3c_camif_set_defaults() argument
1628 unsigned int ip_rev = camif->variant->ip_revision; in s3c_camif_set_defaults()
1632 struct camif_vp *vp = &camif->vp[i]; in s3c_camif_set_defaults()
1635 vp->camif = camif; in s3c_camif_set_defaults()
1637 vp->offset = camif->variant->vp_offset; in s3c_camif_set_defaults()
1661 memset(&camif->mbus_fmt, 0, sizeof(camif->mbus_fmt)); in s3c_camif_set_defaults()
1662 camif->mbus_fmt.width = CAMIF_DEF_WIDTH; in s3c_camif_set_defaults()
1663 camif->mbus_fmt.height = CAMIF_DEF_HEIGHT; in s3c_camif_set_defaults()
1664 camif->mbus_fmt.code = camif_mbus_formats[0]; in s3c_camif_set_defaults()
1666 memset(&camif->camif_crop, 0, sizeof(camif->camif_crop)); in s3c_camif_set_defaults()
1667 camif->camif_crop.width = CAMIF_DEF_WIDTH; in s3c_camif_set_defaults()
1668 camif->camif_crop.height = CAMIF_DEF_HEIGHT; in s3c_camif_set_defaults()