Exemple #1
0
static int dsps_register_otg_device(struct dsps_glue *glue)
{
	int ret;

	strcpy(glue->otg_dev.name, "otg");
	glue->otg_dev.id = DEVICE_ID_DYNAMIC,
	glue->otg_dev.parent = glue->dev;

	ret = register_device(&glue->otg_dev);
	if (ret)
		return ret;

	dev_add_param_enum(&glue->otg_dev, "mode",
			dsps_set_mode, NULL, &glue->otgmode,
			dsps_mode_names, ARRAY_SIZE(dsps_mode_names), glue);
	return 0;
}
static int ci_register_otg_device(struct imx_chipidea *ci)
{
	int ret;

	if (imx_otg_device.parent)
		return -EBUSY;

	imx_otg_device.parent = ci->dev;

	ret = register_device(&imx_otg_device);
	if (ret)
		return ret;

	ci->param_mode = dev_add_param_enum(&imx_otg_device, "mode",
			ci_set_mode, NULL, &ci->mode,
			ci_mode_names, ARRAY_SIZE(ci_mode_names), ci);
	return 0;
}
Exemple #3
0
int register_framebuffer(struct fb_info *info)
{
	int id = get_free_deviceid("fb");
	struct device_d *dev;
	int ret, num_modes, i;
	const char **names;

	dev = &info->dev;

	/*
	 * If info->mode is set at this point it's the only mode
	 * the fb supports. move it over to the modes list.
	 */
	if (info->mode) {
		info->modes.modes = info->mode;
		info->modes.num_modes = 1;
	}

	if (!info->line_length)
		info->line_length = info->xres * (info->bits_per_pixel >> 3);

	info->cdev.ops = &fb_ops;
	info->cdev.name = basprintf("fb%d", id);
	info->cdev.size = info->line_length * info->yres;
	info->cdev.dev = dev;
	info->cdev.priv = info;
	dev->resource = xzalloc(sizeof(struct resource));
	dev->resource[0].start = (resource_size_t)info->screen_base;
	dev->resource[0].end = dev->resource[0].start + info->cdev.size - 1;
	dev->resource[0].flags = IORESOURCE_MEM;
	dev->num_resources = 1;

	dev->priv = info;
	dev->id = id;
	dev->info = fb_info;

	dev_set_name(dev, "fb");

	ret = register_device(&info->dev);
	if (ret)
		goto err_free;

	dev_add_param_bool(dev, "enable", fb_enable_set, NULL,
			&info->p_enable, info);

	if (IS_ENABLED(CONFIG_DRIVER_VIDEO_EDID))
		fb_edid_add_modes(info);

	num_modes = info->modes.num_modes + info->edid_modes.num_modes;

	names = xzalloc(sizeof(char *) * num_modes);

	for (i = 0; i < info->modes.num_modes; i++)
		names[i] = info->modes.modes[i].name;
	for (i = 0; i < info->edid_modes.num_modes; i++)
		names[i + info->modes.num_modes] = info->edid_modes.modes[i].name;
	dev_add_param_enum(dev, "mode_name", fb_set_modename, NULL, &info->current_mode, names, num_modes, info);
	info->shadowfb = 1;
	dev_add_param_bool(dev, "shadowfb", fb_set_shadowfb, NULL, &info->shadowfb, info);

	info->mode = fb_num_to_mode(info, 0);

	fb_setup_mode(info);

	ret = devfs_create(&info->cdev);
	if (ret)
		goto err_unregister;

	if (IS_ENABLED(CONFIG_DRIVER_VIDEO_SIMPLEFB)) {
		ret = fb_register_simplefb(info);
		if (ret)
			dev_err(&info->dev, "failed to register simplefb: %s\n",
					strerror(-ret));
	}

	if (IS_ENABLED(CONFIG_FRAMEBUFFER_CONSOLE))
		register_fbconsole(info);

	return 0;

err_unregister:
	unregister_device(&info->dev);
err_free:
	free(dev->resource);

	return ret;
}