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 (camif->sensor.power_count == !on) 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 (camif->sensor.stream_count == !on) 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()
361 camif_hw_set_camera_crop(camif); in s3c_camif_irq_handler()
364 camif_hw_set_test_pattern(camif, camif->test_pattern); in s3c_camif_irq_handler()
365 if (camif->variant->has_img_effect) in s3c_camif_irq_handler()
366 camif_hw_set_effect(camif, camif->colorfx, in s3c_camif_irq_handler()
367 camif->colorfx_cb, camif->colorfx_cr); in s3c_camif_irq_handler()
371 spin_unlock(&camif->slock); in s3c_camif_irq_handler()
378 struct camif_dev *camif = vp->camif; in start_streaming() local
388 spin_lock_irqsave(&camif->slock, flags); in start_streaming()
390 if (camif->stream_count == 0) { in start_streaming()
391 camif_hw_reset(camif); in start_streaming()
392 ret = s3c_camif_hw_init(camif, vp); in start_streaming()
394 ret = s3c_camif_hw_vp_init(camif, vp); in start_streaming()
396 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
403 spin_lock_irqsave(&camif->slock, flags); in start_streaming()
417 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
418 ret = sensor_set_streaming(camif, 1); in start_streaming()
422 camif_hw_dump_regs(camif, __func__); in start_streaming()
428 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
445 struct camif_dev *camif = vp->camif; in queue_setup() local
469 allocators[0] = camif->alloc_ctx; in queue_setup()
497 struct camif_dev *camif = vp->camif; in buffer_queue() local
500 spin_lock_irqsave(&camif->slock, flags); in buffer_queue()
522 spin_unlock_irqrestore(&camif->slock, flags); in buffer_queue()
525 if (sensor_set_streaming(camif, 1) == 0) in buffer_queue()
531 camif_hw_dump_regs(camif, __func__); in buffer_queue()
535 spin_unlock_irqrestore(&camif->slock, flags); in buffer_queue()
551 struct camif_dev *camif = vp->camif; in s3c_camif_open() local
557 if (mutex_lock_interruptible(&camif->lock)) in s3c_camif_open()
564 ret = pm_runtime_get_sync(camif->dev); in s3c_camif_open()
568 ret = sensor_set_power(camif, 1); in s3c_camif_open()
572 pm_runtime_put(camif->dev); in s3c_camif_open()
576 mutex_unlock(&camif->lock); in s3c_camif_open()
583 struct camif_dev *camif = vp->camif; in s3c_camif_close() local
589 mutex_lock(&camif->lock); in s3c_camif_close()
597 sensor_set_power(camif, 0); in s3c_camif_close()
599 pm_runtime_put(camif->dev); in s3c_camif_close()
602 mutex_unlock(&camif->lock); in s3c_camif_close()
610 struct camif_dev *camif = vp->camif; in s3c_camif_poll() local
613 mutex_lock(&camif->lock); in s3c_camif_poll()
619 mutex_unlock(&camif->lock); in s3c_camif_poll()
657 dev_name(vp->camif->dev), vp->id); in s3c_camif_vidioc_querycap()
669 struct v4l2_subdev *sensor = vp->camif->sensor.sd; in s3c_camif_vidioc_enum_input()
733 struct camif_dev *camif = vp->camif; in __camif_video_try_format() local
734 struct v4l2_rect *crop = &camif->camif_crop; in __camif_video_try_format()
747 pix_lim = &camif->variant->vp_pix_limits[vp->id]; in __camif_video_try_format()
828 static int camif_pipeline_validate(struct camif_dev *camif) in camif_pipeline_validate() argument
835 pad = media_entity_remote_pad(&camif->pads[0]); in camif_pipeline_validate()
841 ret = v4l2_subdev_call(camif->sensor.sd, pad, get_fmt, NULL, &src_fmt); in camif_pipeline_validate()
845 if (src_fmt.format.width != camif->mbus_fmt.width || in camif_pipeline_validate()
846 src_fmt.format.height != camif->mbus_fmt.height || in camif_pipeline_validate()
847 src_fmt.format.code != camif->mbus_fmt.code) in camif_pipeline_validate()
857 struct camif_dev *camif = vp->camif; in s3c_camif_streamon() local
858 struct media_entity *sensor = &camif->sensor.sd->entity; in s3c_camif_streamon()
872 ret = media_entity_pipeline_start(sensor, camif->m_pipeline); in s3c_camif_streamon()
876 ret = camif_pipeline_validate(camif); in s3c_camif_streamon()
889 struct camif_dev *camif = vp->camif; in s3c_camif_streamoff() local
902 media_entity_pipeline_stop(&camif->sensor.sd->entity); in s3c_camif_streamoff()
1023 static void __camif_try_compose(struct camif_dev *camif, struct camif_vp *vp, in __camif_try_compose() argument
1027 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV) { in __camif_try_compose()
1039 struct camif_dev *camif = vp->camif; in s3c_camif_s_selection() local
1047 __camif_try_compose(camif, vp, &rect); in s3c_camif_s_selection()
1050 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_s_selection()
1053 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_s_selection()
1092 struct camif_dev *camif = vp->camif; in s3c_camif_video_s_ctrl() local
1098 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_video_s_ctrl()
1111 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_video_s_ctrl()
1120 int s3c_camif_register_video_node(struct camif_dev *camif, int idx) in s3c_camif_register_video_node() argument
1122 struct camif_vp *vp = &camif->vp[idx]; in s3c_camif_register_video_node()
1134 vfd->v4l2_dev = &camif->v4l2_dev; in s3c_camif_register_video_node()
1137 vfd->lock = &camif->lock; in s3c_camif_register_video_node()
1151 q->lock = &vp->camif->lock; in s3c_camif_register_video_node()
1184 v4l2_info(&camif->v4l2_dev, "registered %s as /dev/%s\n", in s3c_camif_register_video_node()
1197 void s3c_camif_unregister_video_node(struct camif_dev *camif, int idx) in s3c_camif_unregister_video_node() argument
1199 struct video_device *vfd = &camif->vp[idx].vdev; in s3c_camif_unregister_video_node()
1235 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_get_fmt() local
1244 mutex_lock(&camif->lock); in s3c_camif_subdev_get_fmt()
1249 *mf = camif->mbus_fmt; in s3c_camif_subdev_get_fmt()
1254 mf->width = camif->camif_crop.width; in s3c_camif_subdev_get_fmt()
1255 mf->height = camif->camif_crop.height; in s3c_camif_subdev_get_fmt()
1256 mf->code = camif->mbus_fmt.code; in s3c_camif_subdev_get_fmt()
1260 mutex_unlock(&camif->lock); in s3c_camif_subdev_get_fmt()
1266 static void __camif_subdev_try_format(struct camif_dev *camif, in __camif_subdev_try_format() argument
1269 const struct s3c_camif_variant *variant = camif->variant; in __camif_subdev_try_format()
1288 struct v4l2_rect *crop = &camif->camif_crop; in __camif_subdev_try_format()
1295 v4l2_dbg(1, debug, &camif->subdev, "%ux%u\n", mf->width, mf->height); in __camif_subdev_try_format()
1302 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_set_fmt() local
1304 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_set_fmt()
1312 mutex_lock(&camif->lock); in s3c_camif_subdev_set_fmt()
1318 if (vb2_is_busy(&camif->vp[VP_CODEC].vb_queue) || in s3c_camif_subdev_set_fmt()
1319 vb2_is_busy(&camif->vp[VP_PREVIEW].vb_queue)) { in s3c_camif_subdev_set_fmt()
1320 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1324 __camif_subdev_try_format(camif, mf, fmt->pad); in s3c_camif_subdev_set_fmt()
1329 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1335 camif->mbus_fmt = *mf; in s3c_camif_subdev_set_fmt()
1346 struct camif_frame *frame = &camif->vp[i].out_frame; in s3c_camif_subdev_set_fmt()
1355 mf->code = camif->mbus_fmt.code; in s3c_camif_subdev_set_fmt()
1361 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1369 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_get_selection() local
1370 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_get_selection()
1371 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt; in s3c_camif_subdev_get_selection()
1383 mutex_lock(&camif->lock); in s3c_camif_subdev_get_selection()
1394 mutex_unlock(&camif->lock); in s3c_camif_subdev_get_selection()
1403 static void __camif_try_crop(struct camif_dev *camif, struct v4l2_rect *r) in __camif_try_crop() argument
1405 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt; in __camif_try_crop()
1406 const struct camif_pix_limits *pix_lim = &camif->variant->pix_limits; in __camif_try_crop()
1434 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV && in __camif_try_crop()
1435 camif_is_streaming(camif)) { in __camif_try_crop()
1439 struct v4l2_rect *or = &camif->vp[i].out_frame.rect; in __camif_try_crop()
1442 *r = camif->camif_crop; in __camif_try_crop()
1448 v4l2_dbg(1, debug, &camif->v4l2_dev, "crop: (%d,%d)/%dx%d, fmt: %ux%u\n", in __camif_try_crop()
1456 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_set_selection() local
1457 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_set_selection()
1463 mutex_lock(&camif->lock); in s3c_camif_subdev_set_selection()
1464 __camif_try_crop(camif, &sel->r); in s3c_camif_subdev_set_selection()
1472 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_subdev_set_selection()
1476 struct camif_vp *vp = &camif->vp[i]; in s3c_camif_subdev_set_selection()
1484 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_subdev_set_selection()
1486 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_selection()
1490 camif->mbus_fmt.width, camif->mbus_fmt.height); in s3c_camif_subdev_set_selection()
1509 struct camif_dev *camif = container_of(ctrl->handler, struct camif_dev, in s3c_camif_subdev_s_ctrl() local
1513 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_subdev_s_ctrl()
1517 camif->colorfx = camif->ctrl_colorfx->val; in s3c_camif_subdev_s_ctrl()
1521 camif->colorfx_cb = 115; in s3c_camif_subdev_s_ctrl()
1522 camif->colorfx_cr = 145; in s3c_camif_subdev_s_ctrl()
1525 camif->colorfx_cb = camif->ctrl_colorfx_cbcr->val >> 8; in s3c_camif_subdev_s_ctrl()
1526 camif->colorfx_cr = camif->ctrl_colorfx_cbcr->val & 0xff; in s3c_camif_subdev_s_ctrl()
1530 camif->colorfx_cb = 128; in s3c_camif_subdev_s_ctrl()
1531 camif->colorfx_cr = 128; in s3c_camif_subdev_s_ctrl()
1535 camif->test_pattern = camif->ctrl_test_pattern->val; in s3c_camif_subdev_s_ctrl()
1541 camif->vp[VP_CODEC].state |= ST_VP_CONFIG; in s3c_camif_subdev_s_ctrl()
1542 camif->vp[VP_PREVIEW].state |= ST_VP_CONFIG; in s3c_camif_subdev_s_ctrl()
1543 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_subdev_s_ctrl()
1559 int s3c_camif_create_subdev(struct camif_dev *camif) in s3c_camif_create_subdev() argument
1561 struct v4l2_ctrl_handler *handler = &camif->ctrl_handler; in s3c_camif_create_subdev()
1562 struct v4l2_subdev *sd = &camif->subdev; in s3c_camif_create_subdev()
1569 camif->pads[CAMIF_SD_PAD_SINK].flags = MEDIA_PAD_FL_SINK; in s3c_camif_create_subdev()
1570 camif->pads[CAMIF_SD_PAD_SOURCE_C].flags = MEDIA_PAD_FL_SOURCE; in s3c_camif_create_subdev()
1571 camif->pads[CAMIF_SD_PAD_SOURCE_P].flags = MEDIA_PAD_FL_SOURCE; in s3c_camif_create_subdev()
1574 camif->pads, 0); in s3c_camif_create_subdev()
1579 camif->ctrl_test_pattern = v4l2_ctrl_new_std_menu_items(handler, in s3c_camif_create_subdev()
1584 if (camif->variant->has_img_effect) { in s3c_camif_create_subdev()
1585 camif->ctrl_colorfx = v4l2_ctrl_new_std_menu(handler, in s3c_camif_create_subdev()
1590 camif->ctrl_colorfx_cbcr = v4l2_ctrl_new_std(handler, in s3c_camif_create_subdev()
1601 if (camif->variant->has_img_effect) in s3c_camif_create_subdev()
1602 v4l2_ctrl_auto_cluster(2, &camif->ctrl_colorfx, in s3c_camif_create_subdev()
1606 v4l2_set_subdevdata(sd, camif); in s3c_camif_create_subdev()
1611 void s3c_camif_unregister_subdev(struct camif_dev *camif) in s3c_camif_unregister_subdev() argument
1613 struct v4l2_subdev *sd = &camif->subdev; in s3c_camif_unregister_subdev()
1621 v4l2_ctrl_handler_free(&camif->ctrl_handler); in s3c_camif_unregister_subdev()
1625 int s3c_camif_set_defaults(struct camif_dev *camif) in s3c_camif_set_defaults() argument
1627 unsigned int ip_rev = camif->variant->ip_revision; in s3c_camif_set_defaults()
1631 struct camif_vp *vp = &camif->vp[i]; in s3c_camif_set_defaults()
1634 vp->camif = camif; in s3c_camif_set_defaults()
1636 vp->offset = camif->variant->vp_offset; in s3c_camif_set_defaults()
1660 memset(&camif->mbus_fmt, 0, sizeof(camif->mbus_fmt)); in s3c_camif_set_defaults()
1661 camif->mbus_fmt.width = CAMIF_DEF_WIDTH; in s3c_camif_set_defaults()
1662 camif->mbus_fmt.height = CAMIF_DEF_HEIGHT; in s3c_camif_set_defaults()
1663 camif->mbus_fmt.code = camif_mbus_formats[0]; in s3c_camif_set_defaults()
1665 memset(&camif->camif_crop, 0, sizeof(camif->camif_crop)); in s3c_camif_set_defaults()
1666 camif->camif_crop.width = CAMIF_DEF_WIDTH; in s3c_camif_set_defaults()
1667 camif->camif_crop.height = CAMIF_DEF_HEIGHT; in s3c_camif_set_defaults()