int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz,
		      struct platform_device *pdev)
{
	struct v4l2_subdev *resizer = &vpfe_rsz->subdev;
	struct media_pad *pads = &vpfe_rsz->pads[0];
	struct media_entity *me = &resizer->entity;
	struct imp_logical_channel *channel = &vpfe_rsz->channel;

	int ret;

	if (cpu_is_davinci_dm365() || cpu_is_davinci_dm355()) {
		vpfe_rsz->imp_hw_if = imp_get_hw_if();

		if (ISNULL(vpfe_rsz->imp_hw_if))
			return -1;
	} else
		return -1;

	vpfe_rsz->video_in.ops = &video_in_ops;
	vpfe_rsz->video_out.ops = &video_out1_ops;
	/*TODO:enable with rsz-b*/

	v4l2_subdev_init(resizer, &resizer_v4l2_ops);
	strlcpy(resizer->name, "DAVINCI RESIZER", sizeof(resizer->name));
	resizer->grp_id = 1 << 16;	/* group ID for davinci subdevs */
	v4l2_set_subdevdata(resizer, vpfe_rsz);
	resizer->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;

	pads[RESIZER_PAD_SINK].flags = MEDIA_PAD_FL_INPUT;
	pads[RESIZER_PAD_SOURCE].flags = MEDIA_PAD_FL_OUTPUT;

	vpfe_rsz->input = RESIZER_INPUT_NONE;
	vpfe_rsz->output = RESIZER_OUTPUT_NONE;

	channel->type = IMP_RESIZER;
	channel->config_state = STATE_NOT_CONFIGURED;

	me->ops = &resizer_media_ops;

	ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0);
	if (ret)
		return ret;

	vpfe_rsz->video_in.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
	ret = vpfe_video_init(&vpfe_rsz->video_in, "RSZ");
	if (ret) {
		printk(KERN_ERR "failed to init RSZ video-in device\n");
		return ret;
	}

	vpfe_rsz->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	ret = vpfe_video_init(&vpfe_rsz->video_out, "RSZ");
	if (ret) {
		printk(KERN_ERR "failed to init RSZ video-out device\n");
		return ret;
	}

	return 0;
}
Example #2
0
int imp_init_serializer(void)
{
	if (!serializer_initialized) {
		memset((void *)&imp_serializer_info, (char)0,
		       sizeof(struct imp_serializer));
		init_completion(&imp_serializer_info.sem_isr);
		imp_serializer_info.sem_isr.done = 0;
		imp_serializer_info.array_count = 0;
		mutex_init(&imp_serializer_info.array_sem);
		printk(KERN_NOTICE "imp serializer initialized\n");
		serializer_initialized = 1;
		imp_hw_if = imp_get_hw_if();
	}
	return 0;
}
Example #3
0
/*
=====================rsz_init===========================
function to	register resizer character driver
*/
static __init int rsz_init(void)
{

	int result;

	/* Register     the     driver in the kernel */

	result = alloc_chrdev_region(&dev, 0, 1, DRIVER_NAME);
	if (result < 0) {
		printk(KERN_ERR
		       "DaVinciresizer: could not register character device");
		return -ENODEV;
	}
	/* Initialize of character device */
	cdev_init(&c_dev, &rsz_fops);
	c_dev.owner = THIS_MODULE;
	c_dev.ops = &rsz_fops;

	/* addding character device */
	result = cdev_add(&c_dev, dev, 1);

	if (result) {
		printk(KERN_ERR
		       "DaVinciresizer:Error %d adding"
			" Davinciresizer ..error no:",
		       result);
		unregister_chrdev_region(dev, 1);
		return result;
	}

	/* registeration of     character device */
	register_chrdev(MAJOR(dev), DRIVER_NAME, &rsz_fops);

	/* register driver as a platform driver */
	if (driver_register(&resizer_driver) != 0) {
		unregister_chrdev_region(dev, 1);
		cdev_del(&c_dev);
		return -EINVAL;
	}

	/* Register the drive as a platform device */
	if (platform_device_register(&resizer_device) != 0) {
		driver_unregister(&resizer_driver);
		unregister_chrdev_region(dev, 1);
		unregister_chrdev(MAJOR(dev), DRIVER_NAME);
		cdev_del(&c_dev);
		return -EINVAL;
	}

	rsz_class = class_create(THIS_MODULE, "davinci_resizer");

	if (!rsz_class) {

		platform_device_unregister(&resizer_device);
		cdev_del(&c_dev);
		unregister_chrdev(MAJOR(dev), DRIVER_NAME);

		return -EIO;
	}

	device_create(rsz_class, NULL, dev, NULL, "davinci_resizer");

	rsz_dev.users = 0;

	mutex_init(&rsz_dev.lock);
	/* Initialize the serializer */
	imp_init_serializer();
	imp_hw_if = imp_get_hw_if();
	printk(KERN_NOTICE "davinci_resizer initialized\n");
	return 0;
}				/* End   of function  resizer_init */