Lines Matching defs:camif

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