struct xilinx_drm_plane_manager *
xilinx_drm_plane_probe_manager(struct drm_device *drm)
{
	struct xilinx_drm_plane_manager *manager;
	struct device *dev = drm->dev;
	struct device_node *sub_node;
	const char *format;
	int ret;

	manager = devm_kzalloc(dev, sizeof(*manager), GFP_KERNEL);
	if (!manager)
		return ERR_PTR(-ENOMEM);

	/* this node is used to create a plane */
	manager->node = of_get_child_by_name(dev->of_node, "planes");
	if (!manager->node) {
		DRM_ERROR("failed to get a planes node\n");
		return ERR_PTR(-EINVAL);
	}

	/* check the base pixel format of plane manager */
	ret = of_property_read_string(manager->node, "xlnx,pixel-format",
				      &format);
	if (ret < 0) {
		DRM_ERROR("failed to get a plane manager format\n");
		return ERR_PTR(ret);
	}

	ret = xilinx_drm_format_by_name(format, &manager->format);
	if (ret < 0) {
		DRM_ERROR("invalid plane manager format\n");
		return ERR_PTR(ret);
	}

	manager->drm = drm;

	/* probe an OSD. proceed even if there's no OSD */
	sub_node = of_parse_phandle(dev->of_node, "xlnx,osd", 0);
	if (sub_node) {
		manager->osd = xilinx_osd_probe(dev, sub_node);
		of_node_put(sub_node);
		if (IS_ERR(manager->osd)) {
			of_node_put(manager->node);
			DRM_ERROR("failed to probe an osd\n");
			return ERR_CAST(manager->osd);
		}
	}

	ret = xilinx_drm_plane_init_manager(manager);
	if (ret) {
		DRM_ERROR("failed to init a plane manager\n");
		return ERR_PTR(ret);
	}

	manager->default_alpha = OSD_MAX_ALPHA;

	return manager;
}
Beispiel #2
0
struct xilinx_drm_plane_manager *
xilinx_drm_plane_probe_manager(struct drm_device *drm)
{
	struct xilinx_drm_plane_manager *manager;
	struct device *dev = drm->dev;
	struct device_node *sub_node;
	int ret;

	manager = devm_kzalloc(dev, sizeof(*manager), GFP_KERNEL);
	if (!manager)
		return ERR_PTR(-ENOMEM);

	/* this node is used to create a plane */
	manager->node = of_get_child_by_name(dev->of_node, "planes");
	if (!manager->node) {
		DRM_ERROR("failed to get a planes node\n");
		return ERR_PTR(-EINVAL);
	}

	manager->drm = drm;

	/* probe an OSD. proceed even if there's no OSD */
	sub_node = of_parse_phandle(dev->of_node, "osd", 0);
	if (sub_node) {
		manager->osd = xilinx_osd_probe(dev, sub_node);
		of_node_put(sub_node);
		if (IS_ERR(manager->osd)) {
			of_node_put(manager->node);
			DRM_ERROR("failed to probe an osd\n");
			return ERR_CAST(manager->osd);
		}
	}

	ret = xilinx_drm_plane_init_manager(manager);
	if (ret) {
		DRM_ERROR("failed to init a plane manager\n");
		return ERR_PTR(ret);
	}

	manager->default_alpha = OSD_MAX_ALPHA;

	return manager;
}