struct vsp1_uds *vsp1_uds_create(struct vsp1_device *vsp1, unsigned int index) { struct v4l2_subdev *subdev; struct vsp1_uds *uds; int ret; uds = devm_kzalloc(vsp1->dev, sizeof(*uds), GFP_KERNEL); if (uds == NULL) return ERR_PTR(-ENOMEM); uds->entity.type = VSP1_ENTITY_UDS; uds->entity.index = index; ret = vsp1_entity_init(vsp1, &uds->entity, 2); if (ret < 0) return ERR_PTR(ret); /* Initialize the V4L2 subdev. */ subdev = &uds->entity.subdev; v4l2_subdev_init(subdev, &uds_ops); subdev->entity.ops = &vsp1_media_ops; subdev->internal_ops = &vsp1_subdev_internal_ops; snprintf(subdev->name, sizeof(subdev->name), "%s uds.%u", dev_name(vsp1->dev), index); v4l2_set_subdevdata(subdev, uds); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; vsp1_entity_init_formats(subdev, NULL); return uds; }
struct vsp1_lut *vsp1_lut_create(struct vsp1_device *vsp1) { struct v4l2_subdev *subdev; struct vsp1_lut *lut; int ret; lut = devm_kzalloc(vsp1->dev, sizeof(*lut), GFP_KERNEL); if (lut == NULL) return ERR_PTR(-ENOMEM); lut->entity.type = VSP1_ENTITY_LUT; ret = vsp1_entity_init(vsp1, &lut->entity, 2); if (ret < 0) return ERR_PTR(ret); /* Initialize the V4L2 subdev. */ subdev = &lut->entity.subdev; v4l2_subdev_init(subdev, &lut_ops); subdev->entity.ops = &vsp1_media_ops; subdev->internal_ops = &vsp1_subdev_internal_ops; snprintf(subdev->name, sizeof(subdev->name), "%s lut", dev_name(vsp1->dev)); v4l2_set_subdevdata(subdev, lut); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; vsp1_entity_init_formats(subdev, NULL); return lut; }
static int vsp1_entity_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh) { vsp1_entity_init_formats(subdev, fh->pad); return 0; }
struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) { struct v4l2_subdev *subdev; struct vsp1_rwpf *rpf; int ret; rpf = devm_kzalloc(vsp1->dev, sizeof(*rpf), GFP_KERNEL); if (rpf == NULL) return ERR_PTR(-ENOMEM); rpf->ops = &rpf_vdev_ops; rpf->max_width = RPF_MAX_WIDTH; rpf->max_height = RPF_MAX_HEIGHT; rpf->entity.type = VSP1_ENTITY_RPF; rpf->entity.index = index; ret = vsp1_entity_init(vsp1, &rpf->entity, 2); if (ret < 0) return ERR_PTR(ret); /* Initialize the V4L2 subdev. */ subdev = &rpf->entity.subdev; v4l2_subdev_init(subdev, &rpf_ops); subdev->entity.ops = &vsp1->media_ops; subdev->internal_ops = &vsp1_subdev_internal_ops; snprintf(subdev->name, sizeof(subdev->name), "%s rpf.%u", dev_name(vsp1->dev), index); v4l2_set_subdevdata(subdev, rpf); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; vsp1_entity_init_formats(subdev, NULL); /* Initialize the control handler. */ v4l2_ctrl_handler_init(&rpf->ctrls, 1); rpf->alpha = v4l2_ctrl_new_std(&rpf->ctrls, &rpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT, 0, 255, 1, 255); rpf->entity.subdev.ctrl_handler = &rpf->ctrls; if (rpf->ctrls.error) { dev_err(vsp1->dev, "rpf%u: failed to initialize controls\n", index); ret = rpf->ctrls.error; goto error; } return rpf; error: vsp1_entity_destroy(&rpf->entity); return ERR_PTR(ret); }
struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1) { struct v4l2_subdev *subdev; struct vsp1_bru *bru; int ret; bru = devm_kzalloc(vsp1->dev, sizeof(*bru), GFP_KERNEL); if (bru == NULL) return ERR_PTR(-ENOMEM); bru->entity.type = VSP1_ENTITY_BRU; ret = vsp1_entity_init(vsp1, &bru->entity, vsp1->info->num_bru_inputs + 1); if (ret < 0) return ERR_PTR(ret); /* Initialize the V4L2 subdev. */ subdev = &bru->entity.subdev; v4l2_subdev_init(subdev, &bru_ops); subdev->entity.ops = &vsp1->media_ops; subdev->internal_ops = &vsp1_subdev_internal_ops; snprintf(subdev->name, sizeof(subdev->name), "%s bru", dev_name(vsp1->dev)); v4l2_set_subdevdata(subdev, bru); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; vsp1_entity_init_formats(subdev, NULL); /* Initialize the control handler. */ v4l2_ctrl_handler_init(&bru->ctrls, 1); v4l2_ctrl_new_std(&bru->ctrls, &bru_ctrl_ops, V4L2_CID_BG_COLOR, 0, 0xffffff, 1, 0); bru->entity.subdev.ctrl_handler = &bru->ctrls; if (bru->ctrls.error) { dev_err(vsp1->dev, "bru: failed to initialize controls\n"); ret = bru->ctrls.error; vsp1_entity_destroy(&bru->entity); return ERR_PTR(ret); } return bru; }
struct vsp1_hsit *vsp1_hsit_create(struct vsp1_device *vsp1, bool inverse) { struct v4l2_subdev *subdev; struct vsp1_hsit *hsit; int ret; hsit = devm_kzalloc(vsp1->dev, sizeof(*hsit), GFP_KERNEL); if (hsit == NULL) return ERR_PTR(-ENOMEM); hsit->inverse = inverse; if (inverse) hsit->entity.type = VSP1_ENTITY_HSI; else hsit->entity.type = VSP1_ENTITY_HST; ret = vsp1_entity_init(vsp1, &hsit->entity, 2); if (ret < 0) return ERR_PTR(ret); /* Initialize the V4L2 subdev. */ subdev = &hsit->entity.subdev; v4l2_subdev_init(subdev, &hsit_ops); subdev->entity.ops = &vsp1_media_ops; subdev->internal_ops = &vsp1_subdev_internal_ops; snprintf(subdev->name, sizeof(subdev->name), "%s %s", dev_name(vsp1->dev), inverse ? "hsi" : "hst"); v4l2_set_subdevdata(subdev, hsit); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; vsp1_entity_init_formats(subdev, NULL); return hsit; }
struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) { struct v4l2_subdev *subdev; struct vsp1_video *video; struct vsp1_rwpf *rpf; int ret; rpf = devm_kzalloc(vsp1->dev, sizeof(*rpf), GFP_KERNEL); if (rpf == NULL) return ERR_PTR(-ENOMEM); rpf->max_width = RPF_MAX_WIDTH; rpf->max_height = RPF_MAX_HEIGHT; rpf->entity.type = VSP1_ENTITY_RPF; rpf->entity.index = index; ret = vsp1_entity_init(vsp1, &rpf->entity, 2); if (ret < 0) return ERR_PTR(ret); /* Initialize the V4L2 subdev. */ subdev = &rpf->entity.subdev; v4l2_subdev_init(subdev, &rpf_ops); subdev->entity.ops = &vsp1_media_ops; subdev->internal_ops = &vsp1_subdev_internal_ops; snprintf(subdev->name, sizeof(subdev->name), "%s rpf.%u", dev_name(vsp1->dev), index); v4l2_set_subdevdata(subdev, rpf); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; vsp1_entity_init_formats(subdev, NULL); /* Initialize the video device. */ video = &rpf->video; video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; video->vsp1 = vsp1; video->ops = &rpf_vdev_ops; ret = vsp1_video_init(video, &rpf->entity); if (ret < 0) goto error_video; /* Connect the video device to the RPF. */ ret = media_entity_create_link(&rpf->video.video.entity, 0, &rpf->entity.subdev.entity, RWPF_PAD_SINK, MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); if (ret < 0) goto error_link; return rpf; error_link: vsp1_video_cleanup(video); error_video: media_entity_cleanup(&rpf->entity.subdev.entity); return ERR_PTR(ret); }
struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) { struct v4l2_subdev *subdev; struct vsp1_video *video; struct vsp1_rwpf *wpf; unsigned int flags; int ret; wpf = devm_kzalloc(vsp1->dev, sizeof(*wpf), GFP_KERNEL); if (wpf == NULL) return ERR_PTR(-ENOMEM); wpf->max_width = WPF_MAX_WIDTH; wpf->max_height = WPF_MAX_HEIGHT; wpf->entity.type = VSP1_ENTITY_WPF; wpf->entity.index = index; ret = vsp1_entity_init(vsp1, &wpf->entity, 2); if (ret < 0) return ERR_PTR(ret); /* Initialize the V4L2 subdev. */ subdev = &wpf->entity.subdev; v4l2_subdev_init(subdev, &wpf_ops); subdev->entity.ops = &vsp1_media_ops; subdev->internal_ops = &vsp1_subdev_internal_ops; snprintf(subdev->name, sizeof(subdev->name), "%s wpf.%u", dev_name(vsp1->dev), index); v4l2_set_subdevdata(subdev, wpf); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; vsp1_entity_init_formats(subdev, NULL); /* Initialize the control handler. */ v4l2_ctrl_handler_init(&wpf->ctrls, 1); v4l2_ctrl_new_std(&wpf->ctrls, &wpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT, 0, 255, 1, 255); wpf->entity.subdev.ctrl_handler = &wpf->ctrls; if (wpf->ctrls.error) { dev_err(vsp1->dev, "wpf%u: failed to initialize controls\n", index); ret = wpf->ctrls.error; goto error; } /* Initialize the video device. */ video = &wpf->video; video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; video->vsp1 = vsp1; video->ops = &wpf_vdev_ops; ret = vsp1_video_init(video, &wpf->entity); if (ret < 0) goto error; wpf->entity.video = video; /* Connect the video device to the WPF. All connections are immutable * except for the WPF0 source link if a LIF is present. */ flags = MEDIA_LNK_FL_ENABLED; if (!(vsp1->pdata.features & VSP1_HAS_LIF) || index != 0) flags |= MEDIA_LNK_FL_IMMUTABLE; ret = media_entity_create_link(&wpf->entity.subdev.entity, RWPF_PAD_SOURCE, &wpf->video.video.entity, 0, flags); if (ret < 0) goto error; wpf->entity.sink = &wpf->video.video.entity; return wpf; error: vsp1_entity_destroy(&wpf->entity); return ERR_PTR(ret); }
struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) { struct v4l2_subdev *subdev; struct vsp1_video *video; struct vsp1_rwpf *wpf; unsigned int flags; int ret; wpf = devm_kzalloc(vsp1->dev, sizeof(*wpf), GFP_KERNEL); if (wpf == NULL) return ERR_PTR(-ENOMEM); wpf->max_width = WPF_MAX_WIDTH; wpf->max_height = WPF_MAX_HEIGHT; wpf->entity.type = VSP1_ENTITY_WPF; wpf->entity.index = index; wpf->entity.id = VI6_DPR_NODE_WPF(index); ret = vsp1_entity_init(vsp1, &wpf->entity, 2); if (ret < 0) return ERR_PTR(ret); /* Initialize the V4L2 subdev. */ subdev = &wpf->entity.subdev; v4l2_subdev_init(subdev, &wpf_ops); subdev->entity.ops = &vsp1_media_ops; subdev->internal_ops = &vsp1_subdev_internal_ops; snprintf(subdev->name, sizeof(subdev->name), "%s wpf.%u", dev_name(vsp1->dev), index); v4l2_set_subdevdata(subdev, wpf); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; vsp1_entity_init_formats(subdev, NULL); /* Initialize the video device. */ video = &wpf->video; video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; video->vsp1 = vsp1; video->ops = &wpf_vdev_ops; ret = vsp1_video_init(video, &wpf->entity); if (ret < 0) goto error_video; /* Connect the video device to the WPF. All connections are immutable * except for the WPF0 source link if a LIF is present. */ flags = MEDIA_LNK_FL_ENABLED; if (!(vsp1->pdata->features & VSP1_HAS_LIF) || index != 0) flags |= MEDIA_LNK_FL_IMMUTABLE; ret = media_entity_create_link(&wpf->entity.subdev.entity, RWPF_PAD_SOURCE, &wpf->video.video.entity, 0, flags); if (ret < 0) goto error_link; wpf->entity.sink = &wpf->video.video.entity; return wpf; error_link: vsp1_video_cleanup(video); error_video: media_entity_cleanup(&wpf->entity.subdev.entity); return ERR_PTR(ret); }