Lines Matching defs:camif

40 #include "camif-core.h"
41 #include "camif-regs.h"
46 /* Locking: called with vp->camif->slock spinlock held */
67 /* Locking: called with camif->slock spinlock held */
68 static int s3c_camif_hw_init(struct camif_dev *camif, struct camif_vp *vp)
70 const struct s3c_camif_variant *variant = camif->variant;
72 if (camif->sensor.sd == NULL || vp->out_fmt == NULL)
77 camif_hw_set_camera_bus(camif);
78 camif_hw_set_source_format(camif);
79 camif_hw_set_camera_crop(camif);
80 camif_hw_set_test_pattern(camif, camif->test_pattern);
82 camif_hw_set_effect(camif, camif->colorfx,
83 camif->colorfx_cb, camif->colorfx_cr);
96 * Locking: called with camif->slock spinlock held.
98 static int s3c_camif_hw_vp_init(struct camif_dev *camif, struct camif_vp *vp)
100 unsigned int ip_rev = camif->variant->ip_revision;
113 static int sensor_set_power(struct camif_dev *camif, int on)
115 struct cam_sensor *sensor = &camif->sensor;
118 if (!on == camif->sensor.power_count)
129 static int sensor_set_streaming(struct camif_dev *camif, int on)
131 struct cam_sensor *sensor = &camif->sensor;
134 if (!on == camif->sensor.stream_count)
152 struct camif_dev *camif = vp->camif;
157 spin_lock_irqsave(&camif->slock, flags);
175 spin_unlock_irqrestore(&camif->slock, flags);
180 return sensor_set_streaming(camif, 0);
185 struct camif_dev *camif = vp->camif;
189 spin_lock_irqsave(&camif->slock, flags);
191 spin_unlock_irqrestore(&camif->slock, flags);
196 static bool camif_is_streaming(struct camif_dev *camif)
201 spin_lock_irqsave(&camif->slock, flags);
202 status = camif->stream_count > 0;
203 spin_unlock_irqrestore(&camif->slock, flags);
210 struct camif_dev *camif = vp->camif;
217 spin_lock_irqsave(&camif->slock, flags);
220 spin_unlock_irqrestore(&camif->slock, flags);
226 spin_lock_irqsave(&camif->slock, flags);
237 spin_unlock_irqrestore(&camif->slock, flags);
292 struct camif_dev *camif = vp->camif;
293 unsigned int ip_rev = camif->variant->ip_revision;
296 spin_lock(&camif->slock);
367 camif_hw_set_camera_crop(camif);
370 camif_hw_set_test_pattern(camif, camif->test_pattern);
371 if (camif->variant->has_img_effect)
372 camif_hw_set_effect(camif, camif->colorfx,
373 camif->colorfx_cb, camif->colorfx_cr);
377 spin_unlock(&camif->slock);
384 struct camif_dev *camif = vp->camif;
394 spin_lock_irqsave(&camif->slock, flags);
396 if (camif->stream_count == 0) {
397 camif_hw_reset(camif);
398 ret = s3c_camif_hw_init(camif, vp);
400 ret = s3c_camif_hw_vp_init(camif, vp);
402 spin_unlock_irqrestore(&camif->slock, flags);
409 spin_lock_irqsave(&camif->slock, flags);
423 spin_unlock_irqrestore(&camif->slock, flags);
424 ret = sensor_set_streaming(camif, 1);
428 camif_hw_dump_regs(camif, __func__);
434 spin_unlock_irqrestore(&camif->slock, flags);
450 struct camif_dev *camif = vp->camif;
471 allocators[0] = camif->alloc_ctx;
498 struct camif_dev *camif = vp->camif;
501 spin_lock_irqsave(&camif->slock, flags);
523 spin_unlock_irqrestore(&camif->slock, flags);
526 if (sensor_set_streaming(camif, 1) == 0)
532 camif_hw_dump_regs(camif, __func__);
536 spin_unlock_irqrestore(&camif->slock, flags);
542 mutex_lock(&vp->camif->lock);
548 mutex_unlock(&vp->camif->lock);
564 struct camif_dev *camif = vp->camif;
570 if (mutex_lock_interruptible(&camif->lock))
577 ret = pm_runtime_get_sync(camif->dev);
581 ret = sensor_set_power(camif, 1);
585 pm_runtime_put(camif->dev);
589 mutex_unlock(&camif->lock);
596 struct camif_dev *camif = vp->camif;
602 mutex_lock(&camif->lock);
610 sensor_set_power(camif, 0);
612 pm_runtime_put(camif->dev);
615 mutex_unlock(&camif->lock);
623 struct camif_dev *camif = vp->camif;
626 mutex_lock(&camif->lock);
632 mutex_unlock(&camif->lock);
670 dev_name(vp->camif->dev), vp->id);
682 struct v4l2_subdev *sensor = vp->camif->sensor.sd;
746 struct camif_dev *camif = vp->camif;
747 struct v4l2_rect *crop = &camif->camif_crop;
760 pix_lim = &camif->variant->vp_pix_limits[vp->id];
840 /* Only check pixel formats at the sensor and the camif subdev pads */
841 static int camif_pipeline_validate(struct camif_dev *camif)
848 pad = media_entity_remote_pad(&camif->pads[0]);
854 ret = v4l2_subdev_call(camif->sensor.sd, pad, get_fmt, NULL, &src_fmt);
858 if (src_fmt.format.width != camif->mbus_fmt.width ||
859 src_fmt.format.height != camif->mbus_fmt.height ||
860 src_fmt.format.code != camif->mbus_fmt.code)
870 struct camif_dev *camif = vp->camif;
871 struct media_entity *sensor = &camif->sensor.sd->entity;
885 ret = media_entity_pipeline_start(sensor, camif->m_pipeline);
889 ret = camif_pipeline_validate(camif);
902 struct camif_dev *camif = vp->camif;
915 media_entity_pipeline_stop(&camif->sensor.sd->entity);
1036 static void __camif_try_compose(struct camif_dev *camif, struct camif_vp *vp,
1040 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV) {
1052 struct camif_dev *camif = vp->camif;
1060 __camif_try_compose(camif, vp, &rect);
1063 spin_lock_irqsave(&camif->slock, flags);
1066 spin_unlock_irqrestore(&camif->slock, flags);
1105 struct camif_dev *camif = vp->camif;
1111 spin_lock_irqsave(&camif->slock, flags);
1124 spin_unlock_irqrestore(&camif->slock, flags);
1133 int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
1135 struct camif_vp *vp = &camif->vp[idx];
1142 snprintf(vfd->name, sizeof(vfd->name), "camif-%s",
1147 vfd->v4l2_dev = &camif->v4l2_dev;
1150 vfd->lock = &camif->lock;
1196 v4l2_info(&camif->v4l2_dev, "registered %s as /dev/%s\n",
1209 void s3c_camif_unregister_video_node(struct camif_dev *camif, int idx)
1211 struct video_device *vfd = &camif->vp[idx].vdev;
1220 /* Media bus pixel formats supported at the camif input */
1247 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1256 mutex_lock(&camif->lock);
1261 *mf = camif->mbus_fmt;
1266 mf->width = camif->camif_crop.width;
1267 mf->height = camif->camif_crop.height;
1268 mf->code = camif->mbus_fmt.code;
1272 mutex_unlock(&camif->lock);
1278 static void __camif_subdev_try_format(struct camif_dev *camif,
1281 const struct s3c_camif_variant *variant = camif->variant;
1300 struct v4l2_rect *crop = &camif->camif_crop;
1307 v4l2_dbg(1, debug, &camif->subdev, "%ux%u\n", mf->width, mf->height);
1314 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1316 struct v4l2_rect *crop = &camif->camif_crop;
1324 mutex_lock(&camif->lock);
1330 if (vb2_is_busy(&camif->vp[VP_CODEC].vb_queue) ||
1331 vb2_is_busy(&camif->vp[VP_PREVIEW].vb_queue)) {
1332 mutex_unlock(&camif->lock);
1336 __camif_subdev_try_format(camif, mf, fmt->pad);
1341 mutex_unlock(&camif->lock);
1347 camif->mbus_fmt = *mf;
1354 * Reset source format (the camif's crop rectangle)
1358 struct camif_frame *frame = &camif->vp[i].out_frame;
1367 mf->code = camif->mbus_fmt.code;
1373 mutex_unlock(&camif->lock);
1381 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1382 struct v4l2_rect *crop = &camif->camif_crop;
1383 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
1395 mutex_lock(&camif->lock);
1406 mutex_unlock(&camif->lock);
1415 static void __camif_try_crop(struct camif_dev *camif, struct v4l2_rect *r)
1417 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
1418 const struct camif_pix_limits *pix_lim = &camif->variant->pix_limits;
1446 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV &&
1447 camif_is_streaming(camif)) {
1451 struct v4l2_rect *or = &camif->vp[i].out_frame.rect;
1454 *r = camif->camif_crop;
1460 v4l2_dbg(1, debug, &camif->v4l2_dev, "crop: (%d,%d)/%dx%d, fmt: %ux%u\n",
1468 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1469 struct v4l2_rect *crop = &camif->camif_crop;
1475 mutex_lock(&camif->lock);
1476 __camif_try_crop(camif, &sel->r);
1484 spin_lock_irqsave(&camif->slock, flags);
1488 struct camif_vp *vp = &camif->vp[i];
1496 spin_unlock_irqrestore(&camif->slock, flags);
1498 mutex_unlock(&camif->lock);
1502 camif->mbus_fmt.width, camif->mbus_fmt.height);
1521 struct camif_dev *camif = container_of(ctrl->handler, struct camif_dev,
1525 spin_lock_irqsave(&camif->slock, flags);
1529 camif->colorfx = camif->ctrl_colorfx->val;
1533 camif->colorfx_cb = 115;
1534 camif->colorfx_cr = 145;
1537 camif->colorfx_cb = camif->ctrl_colorfx_cbcr->val >> 8;
1538 camif->colorfx_cr = camif->ctrl_colorfx_cbcr->val & 0xff;
1542 camif->colorfx_cb = 128;
1543 camif->colorfx_cr = 128;
1547 camif->test_pattern = camif->ctrl_test_pattern->val;
1553 camif->vp[VP_CODEC].state |= ST_VP_CONFIG;
1554 camif->vp[VP_PREVIEW].state |= ST_VP_CONFIG;
1555 spin_unlock_irqrestore(&camif->slock, flags);
1571 int s3c_camif_create_subdev(struct camif_dev *camif)
1573 struct v4l2_ctrl_handler *handler = &camif->ctrl_handler;
1574 struct v4l2_subdev *sd = &camif->subdev;
1581 camif->pads[CAMIF_SD_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
1582 camif->pads[CAMIF_SD_PAD_SOURCE_C].flags = MEDIA_PAD_FL_SOURCE;
1583 camif->pads[CAMIF_SD_PAD_SOURCE_P].flags = MEDIA_PAD_FL_SOURCE;
1586 camif->pads, 0);
1591 camif->ctrl_test_pattern = v4l2_ctrl_new_std_menu_items(handler,
1596 if (camif->variant->has_img_effect) {
1597 camif->ctrl_colorfx = v4l2_ctrl_new_std_menu(handler,
1602 camif->ctrl_colorfx_cbcr = v4l2_ctrl_new_std(handler,
1613 if (camif->variant->has_img_effect)
1614 v4l2_ctrl_auto_cluster(2, &camif->ctrl_colorfx,
1618 v4l2_set_subdevdata(sd, camif);
1623 void s3c_camif_unregister_subdev(struct camif_dev *camif)
1625 struct v4l2_subdev *sd = &camif->subdev;
1633 v4l2_ctrl_handler_free(&camif->ctrl_handler);
1637 int s3c_camif_set_defaults(struct camif_dev *camif)
1639 unsigned int ip_rev = camif->variant->ip_revision;
1643 struct camif_vp *vp = &camif->vp[i];
1646 vp->camif = camif;
1648 vp->offset = camif->variant->vp_offset;
1672 memset(&camif->mbus_fmt, 0, sizeof(camif->mbus_fmt));
1673 camif->mbus_fmt.width = CAMIF_DEF_WIDTH;
1674 camif->mbus_fmt.height = CAMIF_DEF_HEIGHT;
1675 camif->mbus_fmt.code = camif_mbus_formats[0];
1677 memset(&camif->camif_crop, 0, sizeof(camif->camif_crop));
1678 camif->camif_crop.width = CAMIF_DEF_WIDTH;
1679 camif->camif_crop.height = CAMIF_DEF_HEIGHT;