Lines Matching refs:camif

65 static int s3c_camif_hw_init(struct camif_dev *camif, struct camif_vp *vp)  in s3c_camif_hw_init()  argument
67 const struct s3c_camif_variant *variant = camif->variant; in s3c_camif_hw_init()
69 if (camif->sensor.sd == NULL || vp->out_fmt == NULL) in s3c_camif_hw_init()
74 camif_hw_set_camera_bus(camif); in s3c_camif_hw_init()
75 camif_hw_set_source_format(camif); in s3c_camif_hw_init()
76 camif_hw_set_camera_crop(camif); in s3c_camif_hw_init()
77 camif_hw_set_test_pattern(camif, camif->test_pattern); in s3c_camif_hw_init()
79 camif_hw_set_effect(camif, camif->colorfx, in s3c_camif_hw_init()
80 camif->colorfx_cr, camif->colorfx_cb); in s3c_camif_hw_init()
95 static int s3c_camif_hw_vp_init(struct camif_dev *camif, struct camif_vp *vp) in s3c_camif_hw_vp_init() argument
97 unsigned int ip_rev = camif->variant->ip_revision; in s3c_camif_hw_vp_init()
110 static int sensor_set_power(struct camif_dev *camif, int on) in sensor_set_power() argument
112 struct cam_sensor *sensor = &camif->sensor; in sensor_set_power()
115 if (camif->sensor.power_count == !on) in sensor_set_power()
128 static int sensor_set_streaming(struct camif_dev *camif, int on) in sensor_set_streaming() argument
130 struct cam_sensor *sensor = &camif->sensor; in sensor_set_streaming()
133 if (camif->sensor.stream_count == !on) in sensor_set_streaming()
151 struct camif_dev *camif = vp->camif; in camif_reinitialize() local
156 spin_lock_irqsave(&camif->slock, flags); in camif_reinitialize()
174 spin_unlock_irqrestore(&camif->slock, flags); in camif_reinitialize()
179 return sensor_set_streaming(camif, 0); in camif_reinitialize()
184 struct camif_dev *camif = vp->camif; in s3c_vp_active() local
188 spin_lock_irqsave(&camif->slock, flags); in s3c_vp_active()
190 spin_unlock_irqrestore(&camif->slock, flags); in s3c_vp_active()
195 static bool camif_is_streaming(struct camif_dev *camif) in camif_is_streaming() argument
200 spin_lock_irqsave(&camif->slock, flags); in camif_is_streaming()
201 status = camif->stream_count > 0; in camif_is_streaming()
202 spin_unlock_irqrestore(&camif->slock, flags); in camif_is_streaming()
209 struct camif_dev *camif = vp->camif; in camif_stop_capture() local
216 spin_lock_irqsave(&camif->slock, flags); in camif_stop_capture()
219 spin_unlock_irqrestore(&camif->slock, flags); in camif_stop_capture()
225 spin_lock_irqsave(&camif->slock, flags); in camif_stop_capture()
236 spin_unlock_irqrestore(&camif->slock, flags); in camif_stop_capture()
291 struct camif_dev *camif = vp->camif; in s3c_camif_irq_handler() local
292 unsigned int ip_rev = camif->variant->ip_revision; in s3c_camif_irq_handler()
295 spin_lock(&camif->slock); in s3c_camif_irq_handler()
360 camif_hw_set_camera_crop(camif); in s3c_camif_irq_handler()
363 camif_hw_set_test_pattern(camif, camif->test_pattern); in s3c_camif_irq_handler()
364 if (camif->variant->has_img_effect) in s3c_camif_irq_handler()
365 camif_hw_set_effect(camif, camif->colorfx, in s3c_camif_irq_handler()
366 camif->colorfx_cr, camif->colorfx_cb); in s3c_camif_irq_handler()
370 spin_unlock(&camif->slock); in s3c_camif_irq_handler()
377 struct camif_dev *camif = vp->camif; in start_streaming() local
387 spin_lock_irqsave(&camif->slock, flags); in start_streaming()
389 if (camif->stream_count == 0) { in start_streaming()
390 camif_hw_reset(camif); in start_streaming()
391 ret = s3c_camif_hw_init(camif, vp); in start_streaming()
393 ret = s3c_camif_hw_vp_init(camif, vp); in start_streaming()
395 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
402 spin_lock_irqsave(&camif->slock, flags); in start_streaming()
416 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
417 ret = sensor_set_streaming(camif, 1); in start_streaming()
421 camif_hw_dump_regs(camif, __func__); in start_streaming()
427 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
483 struct camif_dev *camif = vp->camif; in buffer_queue() local
486 spin_lock_irqsave(&camif->slock, flags); in buffer_queue()
508 spin_unlock_irqrestore(&camif->slock, flags); in buffer_queue()
511 if (sensor_set_streaming(camif, 1) == 0) in buffer_queue()
517 camif_hw_dump_regs(camif, __func__); in buffer_queue()
521 spin_unlock_irqrestore(&camif->slock, flags); in buffer_queue()
537 struct camif_dev *camif = vp->camif; in s3c_camif_open() local
543 if (mutex_lock_interruptible(&camif->lock)) in s3c_camif_open()
550 ret = pm_runtime_resume_and_get(camif->dev); in s3c_camif_open()
554 ret = sensor_set_power(camif, 1); in s3c_camif_open()
558 pm_runtime_put(camif->dev); in s3c_camif_open()
562 mutex_unlock(&camif->lock); in s3c_camif_open()
569 struct camif_dev *camif = vp->camif; in s3c_camif_close() local
575 mutex_lock(&camif->lock); in s3c_camif_close()
583 sensor_set_power(camif, 0); in s3c_camif_close()
585 pm_runtime_put(camif->dev); in s3c_camif_close()
588 mutex_unlock(&camif->lock); in s3c_camif_close()
596 struct camif_dev *camif = vp->camif; in s3c_camif_poll() local
599 mutex_lock(&camif->lock); in s3c_camif_poll()
605 mutex_unlock(&camif->lock); in s3c_camif_poll()
643 dev_name(vp->camif->dev), vp->id); in s3c_camif_vidioc_querycap()
651 struct v4l2_subdev *sensor = vp->camif->sensor.sd; in s3c_camif_vidioc_enum_input()
712 struct camif_dev *camif = vp->camif; in __camif_video_try_format() local
713 struct v4l2_rect *crop = &camif->camif_crop; in __camif_video_try_format()
726 pix_lim = &camif->variant->vp_pix_limits[vp->id]; in __camif_video_try_format()
807 static int camif_pipeline_validate(struct camif_dev *camif) in camif_pipeline_validate() argument
816 pad = media_pad_remote_pad_first(&camif->pads[0]); in camif_pipeline_validate()
821 ret = v4l2_subdev_call(camif->sensor.sd, pad, get_fmt, NULL, &src_fmt); in camif_pipeline_validate()
825 if (src_fmt.format.width != camif->mbus_fmt.width || in camif_pipeline_validate()
826 src_fmt.format.height != camif->mbus_fmt.height || in camif_pipeline_validate()
827 src_fmt.format.code != camif->mbus_fmt.code) in camif_pipeline_validate()
837 struct camif_dev *camif = vp->camif; in s3c_camif_streamon() local
838 struct media_entity *sensor = &camif->sensor.sd->entity; in s3c_camif_streamon()
852 ret = media_pipeline_start(sensor->pads, camif->m_pipeline); in s3c_camif_streamon()
856 ret = camif_pipeline_validate(camif); in s3c_camif_streamon()
869 struct camif_dev *camif = vp->camif; in s3c_camif_streamoff() local
882 media_pipeline_stop(camif->sensor.sd->entity.pads); in s3c_camif_streamoff()
1003 static void __camif_try_compose(struct camif_dev *camif, struct camif_vp *vp, in __camif_try_compose() argument
1007 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV) { in __camif_try_compose()
1019 struct camif_dev *camif = vp->camif; in s3c_camif_s_selection() local
1027 __camif_try_compose(camif, vp, &rect); in s3c_camif_s_selection()
1030 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_s_selection()
1033 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_s_selection()
1072 struct camif_dev *camif = vp->camif; in s3c_camif_video_s_ctrl() local
1078 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_video_s_ctrl()
1091 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_video_s_ctrl()
1100 int s3c_camif_register_video_node(struct camif_dev *camif, int idx) in s3c_camif_register_video_node() argument
1102 struct camif_vp *vp = &camif->vp[idx]; in s3c_camif_register_video_node()
1114 vfd->v4l2_dev = &camif->v4l2_dev; in s3c_camif_register_video_node()
1117 vfd->lock = &camif->lock; in s3c_camif_register_video_node()
1131 q->lock = &vp->camif->lock; in s3c_camif_register_video_node()
1132 q->dev = camif->v4l2_dev.dev; in s3c_camif_register_video_node()
1166 v4l2_info(&camif->v4l2_dev, "registered %s as /dev/%s\n", in s3c_camif_register_video_node()
1177 void s3c_camif_unregister_video_node(struct camif_dev *camif, int idx) in s3c_camif_unregister_video_node() argument
1179 struct video_device *vfd = &camif->vp[idx].vdev; in s3c_camif_unregister_video_node()
1215 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_get_fmt() local
1224 mutex_lock(&camif->lock); in s3c_camif_subdev_get_fmt()
1229 *mf = camif->mbus_fmt; in s3c_camif_subdev_get_fmt()
1234 mf->width = camif->camif_crop.width; in s3c_camif_subdev_get_fmt()
1235 mf->height = camif->camif_crop.height; in s3c_camif_subdev_get_fmt()
1236 mf->code = camif->mbus_fmt.code; in s3c_camif_subdev_get_fmt()
1240 mutex_unlock(&camif->lock); in s3c_camif_subdev_get_fmt()
1246 static void __camif_subdev_try_format(struct camif_dev *camif, in __camif_subdev_try_format() argument
1249 const struct s3c_camif_variant *variant = camif->variant; in __camif_subdev_try_format()
1269 struct v4l2_rect *crop = &camif->camif_crop; in __camif_subdev_try_format()
1276 v4l2_dbg(1, debug, &camif->subdev, "%ux%u\n", mf->width, mf->height); in __camif_subdev_try_format()
1283 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_set_fmt() local
1285 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_set_fmt()
1293 mutex_lock(&camif->lock); in s3c_camif_subdev_set_fmt()
1299 if (vb2_is_busy(&camif->vp[VP_CODEC].vb_queue) || in s3c_camif_subdev_set_fmt()
1300 vb2_is_busy(&camif->vp[VP_PREVIEW].vb_queue)) { in s3c_camif_subdev_set_fmt()
1301 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1305 __camif_subdev_try_format(camif, mf, fmt->pad); in s3c_camif_subdev_set_fmt()
1310 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1316 camif->mbus_fmt = *mf; in s3c_camif_subdev_set_fmt()
1327 struct camif_frame *frame = &camif->vp[i].out_frame; in s3c_camif_subdev_set_fmt()
1336 mf->code = camif->mbus_fmt.code; in s3c_camif_subdev_set_fmt()
1342 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1350 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_get_selection() local
1351 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_get_selection()
1352 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt; in s3c_camif_subdev_get_selection()
1364 mutex_lock(&camif->lock); in s3c_camif_subdev_get_selection()
1375 mutex_unlock(&camif->lock); in s3c_camif_subdev_get_selection()
1384 static void __camif_try_crop(struct camif_dev *camif, struct v4l2_rect *r) in __camif_try_crop() argument
1386 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt; in __camif_try_crop()
1387 const struct camif_pix_limits *pix_lim = &camif->variant->pix_limits; in __camif_try_crop()
1415 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV && in __camif_try_crop()
1416 camif_is_streaming(camif)) { in __camif_try_crop()
1420 struct v4l2_rect *or = &camif->vp[i].out_frame.rect; in __camif_try_crop()
1423 *r = camif->camif_crop; in __camif_try_crop()
1429 v4l2_dbg(1, debug, &camif->v4l2_dev, "crop: (%d,%d)/%dx%d, fmt: %ux%u\n", in __camif_try_crop()
1437 struct camif_dev *camif = v4l2_get_subdevdata(sd); in s3c_camif_subdev_set_selection() local
1438 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_set_selection()
1444 mutex_lock(&camif->lock); in s3c_camif_subdev_set_selection()
1445 __camif_try_crop(camif, &sel->r); in s3c_camif_subdev_set_selection()
1453 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_subdev_set_selection()
1457 struct camif_vp *vp = &camif->vp[i]; in s3c_camif_subdev_set_selection()
1465 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_subdev_set_selection()
1467 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_selection()
1471 camif->mbus_fmt.width, camif->mbus_fmt.height); in s3c_camif_subdev_set_selection()
1490 struct camif_dev *camif = container_of(ctrl->handler, struct camif_dev, in s3c_camif_subdev_s_ctrl() local
1494 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_subdev_s_ctrl()
1498 camif->colorfx = camif->ctrl_colorfx->val; in s3c_camif_subdev_s_ctrl()
1502 camif->colorfx_cb = 115; in s3c_camif_subdev_s_ctrl()
1503 camif->colorfx_cr = 145; in s3c_camif_subdev_s_ctrl()
1506 camif->colorfx_cb = camif->ctrl_colorfx_cbcr->val >> 8; in s3c_camif_subdev_s_ctrl()
1507 camif->colorfx_cr = camif->ctrl_colorfx_cbcr->val & 0xff; in s3c_camif_subdev_s_ctrl()
1511 camif->colorfx_cb = 128; in s3c_camif_subdev_s_ctrl()
1512 camif->colorfx_cr = 128; in s3c_camif_subdev_s_ctrl()
1516 camif->test_pattern = camif->ctrl_test_pattern->val; in s3c_camif_subdev_s_ctrl()
1522 camif->vp[VP_CODEC].state |= ST_VP_CONFIG; in s3c_camif_subdev_s_ctrl()
1523 camif->vp[VP_PREVIEW].state |= ST_VP_CONFIG; in s3c_camif_subdev_s_ctrl()
1524 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_subdev_s_ctrl()
1540 int s3c_camif_create_subdev(struct camif_dev *camif) in s3c_camif_create_subdev() argument
1542 struct v4l2_ctrl_handler *handler = &camif->ctrl_handler; in s3c_camif_create_subdev()
1543 struct v4l2_subdev *sd = &camif->subdev; in s3c_camif_create_subdev()
1550 camif->pads[CAMIF_SD_PAD_SINK].flags = MEDIA_PAD_FL_SINK; in s3c_camif_create_subdev()
1551 camif->pads[CAMIF_SD_PAD_SOURCE_C].flags = MEDIA_PAD_FL_SOURCE; in s3c_camif_create_subdev()
1552 camif->pads[CAMIF_SD_PAD_SOURCE_P].flags = MEDIA_PAD_FL_SOURCE; in s3c_camif_create_subdev()
1555 camif->pads); in s3c_camif_create_subdev()
1560 camif->ctrl_test_pattern = v4l2_ctrl_new_std_menu_items(handler, in s3c_camif_create_subdev()
1565 if (camif->variant->has_img_effect) { in s3c_camif_create_subdev()
1566 camif->ctrl_colorfx = v4l2_ctrl_new_std_menu(handler, in s3c_camif_create_subdev()
1571 camif->ctrl_colorfx_cbcr = v4l2_ctrl_new_std(handler, in s3c_camif_create_subdev()
1582 if (camif->variant->has_img_effect) in s3c_camif_create_subdev()
1583 v4l2_ctrl_auto_cluster(2, &camif->ctrl_colorfx, in s3c_camif_create_subdev()
1587 v4l2_set_subdevdata(sd, camif); in s3c_camif_create_subdev()
1592 void s3c_camif_unregister_subdev(struct camif_dev *camif) in s3c_camif_unregister_subdev() argument
1594 struct v4l2_subdev *sd = &camif->subdev; in s3c_camif_unregister_subdev()
1602 v4l2_ctrl_handler_free(&camif->ctrl_handler); in s3c_camif_unregister_subdev()
1606 int s3c_camif_set_defaults(struct camif_dev *camif) in s3c_camif_set_defaults() argument
1608 unsigned int ip_rev = camif->variant->ip_revision; in s3c_camif_set_defaults()
1612 struct camif_vp *vp = &camif->vp[i]; in s3c_camif_set_defaults()
1615 vp->camif = camif; in s3c_camif_set_defaults()
1617 vp->offset = camif->variant->vp_offset; in s3c_camif_set_defaults()
1641 memset(&camif->mbus_fmt, 0, sizeof(camif->mbus_fmt)); in s3c_camif_set_defaults()
1642 camif->mbus_fmt.width = CAMIF_DEF_WIDTH; in s3c_camif_set_defaults()
1643 camif->mbus_fmt.height = CAMIF_DEF_HEIGHT; in s3c_camif_set_defaults()
1644 camif->mbus_fmt.code = camif_mbus_formats[0]; in s3c_camif_set_defaults()
1646 memset(&camif->camif_crop, 0, sizeof(camif->camif_crop)); in s3c_camif_set_defaults()
1647 camif->camif_crop.width = CAMIF_DEF_WIDTH; in s3c_camif_set_defaults()
1648 camif->camif_crop.height = CAMIF_DEF_HEIGHT; in s3c_camif_set_defaults()