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_get_sync(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)
814 pad = media_entity_remote_pad(&camif->pads[0]);
820 ret = v4l2_subdev_call(camif->sensor.sd, pad, get_fmt, NULL, &src_fmt);
824 if (src_fmt.format.width != camif->mbus_fmt.width ||
825 src_fmt.format.height != camif->mbus_fmt.height ||
826 src_fmt.format.code != camif->mbus_fmt.code)
836 struct camif_dev *camif = vp->camif;
837 struct media_entity *sensor = &camif->sensor.sd->entity;
851 ret = media_pipeline_start(sensor, camif->m_pipeline);
855 ret = camif_pipeline_validate(camif);
868 struct camif_dev *camif = vp->camif;
881 media_pipeline_stop(&camif->sensor.sd->entity);
1002 static void __camif_try_compose(struct camif_dev *camif, struct camif_vp *vp,
1006 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV) {
1018 struct camif_dev *camif = vp->camif;
1026 __camif_try_compose(camif, vp, &rect);
1029 spin_lock_irqsave(&camif->slock, flags);
1032 spin_unlock_irqrestore(&camif->slock, flags);
1071 struct camif_dev *camif = vp->camif;
1077 spin_lock_irqsave(&camif->slock, flags);
1090 spin_unlock_irqrestore(&camif->slock, flags);
1099 int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
1101 struct camif_vp *vp = &camif->vp[idx];
1108 snprintf(vfd->name, sizeof(vfd->name), "camif-%s",
1113 vfd->v4l2_dev = &camif->v4l2_dev;
1116 vfd->lock = &camif->lock;
1130 q->lock = &vp->camif->lock;
1131 q->dev = camif->v4l2_dev.dev;
1165 v4l2_info(&camif->v4l2_dev, "registered %s as /dev/%s\n",
1176 void s3c_camif_unregister_video_node(struct camif_dev *camif, int idx)
1178 struct video_device *vfd = &camif->vp[idx].vdev;
1187 /* Media bus pixel formats supported at the camif input */
1214 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1223 mutex_lock(&camif->lock);
1228 *mf = camif->mbus_fmt;
1233 mf->width = camif->camif_crop.width;
1234 mf->height = camif->camif_crop.height;
1235 mf->code = camif->mbus_fmt.code;
1239 mutex_unlock(&camif->lock);
1245 static void __camif_subdev_try_format(struct camif_dev *camif,
1248 const struct s3c_camif_variant *variant = camif->variant;
1268 struct v4l2_rect *crop = &camif->camif_crop;
1275 v4l2_dbg(1, debug, &camif->subdev, "%ux%u\n", mf->width, mf->height);
1282 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1284 struct v4l2_rect *crop = &camif->camif_crop;
1292 mutex_lock(&camif->lock);
1298 if (vb2_is_busy(&camif->vp[VP_CODEC].vb_queue) ||
1299 vb2_is_busy(&camif->vp[VP_PREVIEW].vb_queue)) {
1300 mutex_unlock(&camif->lock);
1304 __camif_subdev_try_format(camif, mf, fmt->pad);
1309 mutex_unlock(&camif->lock);
1315 camif->mbus_fmt = *mf;
1322 * Reset source format (the camif's crop rectangle)
1326 struct camif_frame *frame = &camif->vp[i].out_frame;
1335 mf->code = camif->mbus_fmt.code;
1341 mutex_unlock(&camif->lock);
1349 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1350 struct v4l2_rect *crop = &camif->camif_crop;
1351 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
1363 mutex_lock(&camif->lock);
1374 mutex_unlock(&camif->lock);
1383 static void __camif_try_crop(struct camif_dev *camif, struct v4l2_rect *r)
1385 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt;
1386 const struct camif_pix_limits *pix_lim = &camif->variant->pix_limits;
1414 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV &&
1415 camif_is_streaming(camif)) {
1419 struct v4l2_rect *or = &camif->vp[i].out_frame.rect;
1422 *r = camif->camif_crop;
1428 v4l2_dbg(1, debug, &camif->v4l2_dev, "crop: (%d,%d)/%dx%d, fmt: %ux%u\n",
1436 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1437 struct v4l2_rect *crop = &camif->camif_crop;
1443 mutex_lock(&camif->lock);
1444 __camif_try_crop(camif, &sel->r);
1452 spin_lock_irqsave(&camif->slock, flags);
1456 struct camif_vp *vp = &camif->vp[i];
1464 spin_unlock_irqrestore(&camif->slock, flags);
1466 mutex_unlock(&camif->lock);
1470 camif->mbus_fmt.width, camif->mbus_fmt.height);
1489 struct camif_dev *camif = container_of(ctrl->handler, struct camif_dev,
1493 spin_lock_irqsave(&camif->slock, flags);
1497 camif->colorfx = camif->ctrl_colorfx->val;
1501 camif->colorfx_cb = 115;
1502 camif->colorfx_cr = 145;
1505 camif->colorfx_cb = camif->ctrl_colorfx_cbcr->val >> 8;
1506 camif->colorfx_cr = camif->ctrl_colorfx_cbcr->val & 0xff;
1510 camif->colorfx_cb = 128;
1511 camif->colorfx_cr = 128;
1515 camif->test_pattern = camif->ctrl_test_pattern->val;
1521 camif->vp[VP_CODEC].state |= ST_VP_CONFIG;
1522 camif->vp[VP_PREVIEW].state |= ST_VP_CONFIG;
1523 spin_unlock_irqrestore(&camif->slock, flags);
1539 int s3c_camif_create_subdev(struct camif_dev *camif)
1541 struct v4l2_ctrl_handler *handler = &camif->ctrl_handler;
1542 struct v4l2_subdev *sd = &camif->subdev;
1549 camif->pads[CAMIF_SD_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
1550 camif->pads[CAMIF_SD_PAD_SOURCE_C].flags = MEDIA_PAD_FL_SOURCE;
1551 camif->pads[CAMIF_SD_PAD_SOURCE_P].flags = MEDIA_PAD_FL_SOURCE;
1554 camif->pads);
1559 camif->ctrl_test_pattern = v4l2_ctrl_new_std_menu_items(handler,
1564 if (camif->variant->has_img_effect) {
1565 camif->ctrl_colorfx = v4l2_ctrl_new_std_menu(handler,
1570 camif->ctrl_colorfx_cbcr = v4l2_ctrl_new_std(handler,
1581 if (camif->variant->has_img_effect)
1582 v4l2_ctrl_auto_cluster(2, &camif->ctrl_colorfx,
1586 v4l2_set_subdevdata(sd, camif);
1591 void s3c_camif_unregister_subdev(struct camif_dev *camif)
1593 struct v4l2_subdev *sd = &camif->subdev;
1601 v4l2_ctrl_handler_free(&camif->ctrl_handler);
1605 int s3c_camif_set_defaults(struct camif_dev *camif)
1607 unsigned int ip_rev = camif->variant->ip_revision;
1611 struct camif_vp *vp = &camif->vp[i];
1614 vp->camif = camif;
1616 vp->offset = camif->variant->vp_offset;
1640 memset(&camif->mbus_fmt, 0, sizeof(camif->mbus_fmt));
1641 camif->mbus_fmt.width = CAMIF_DEF_WIDTH;
1642 camif->mbus_fmt.height = CAMIF_DEF_HEIGHT;
1643 camif->mbus_fmt.code = camif_mbus_formats[0];
1645 memset(&camif->camif_crop, 0, sizeof(camif->camif_crop));
1646 camif->camif_crop.width = CAMIF_DEF_WIDTH;
1647 camif->camif_crop.height = CAMIF_DEF_HEIGHT;