コード例 #1
0
static long mtkfb_vsync_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
    int ret = 0;
	MTKFB_VSYNC_FUNC();
    switch (cmd)
    {
        case MTKFB_VSYNC_IOCTL:
        {
			MTKFB_VSYNC_LOG("[MTKFB_VSYNC]: enter MTKFB_VSYNC_IOCTL %d\n", arg);			

			if(arg == MTKFB_VSYNC_SOURCE_HDMI)
			{
#if defined(MTK_HDMI_SUPPORT)
                if (down_interruptible(&mtkfb_vsync_sem)) {
         			printk("[mtkfb_vsync_ioctl] can't get semaphore,%d\n", __LINE__);
    				msleep(20);
         			return ret;
        		}
                hdmi_waitVsync();
    			up(&mtkfb_vsync_sem);
    			MTKFB_VSYNC_LOG("[MTKFB_VSYNC]: leave MTKFB_VSYNC_IOCTL, %d\n", __LINE__);
#else
                MTKFB_VSYNC_LOG("[MTKFB_VSYNC]: NS leave MTKFB_VSYNC_IOCTL, %d\n", __LINE__);
                ret = -EFAULT;
#endif                
                return ret;
			}
			
			if (down_interruptible(&mtkfb_vsync_sem)) {
     			printk("[mtkfb_vsync_ioctl] can't get semaphore,%d\n", __LINE__);
				msleep(20);
     			return ret;
    		}
            mtkfb_waitVsync();
			up(&mtkfb_vsync_sem);
			MTKFB_VSYNC_LOG("[MTKFB_VSYNC]: leave MTKFB_VSYNC_IOCTL\n");
        }
        break;
    }
    return ret;
}
コード例 #2
0
static long mtkfb_vsync_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
    int ret = 0;
	MTKFB_VSYNC_FUNC();
    switch (cmd)
    {
        case MTKFB_VSYNC_IOCTL:
        {
			MTKFB_VSYNC_LOG("[MTKFB_VSYNC]: enter MTKFB_VSYNC_IOCTL\n");
			if (down_interruptible(&mtkfb_vsync_sem)) {
     			printk("[mtkfb_vsync_ioctl] can't get semaphore,%d\n", __LINE__);
				msleep(20);
     			return ret;
    		}
            mtkfb_waitVsync();
			up(&mtkfb_vsync_sem);
			MTKFB_VSYNC_LOG("[MTKFB_VSYNC]: leave MTKFB_VSYNC_IOCTL\n");
        }
        break;
    }
    return ret;
}
コード例 #3
0
static long mtkfb_vsync_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	int ret = 0;
	MTKFB_VSYNC_FUNC();
	switch (cmd) {
	case MTKFB_VSYNC_IOCTL:
		{
			MTKFB_VSYNC_LOG("[MTKFB_VSYNC]: enter MTKFB_VSYNC_IOCTL %ld\n", arg);

#if defined(CONFIG_SINGLE_PANEL_OUTPUT)
			if (is_hdmi_active()) {
#else
			if (arg == MTKFB_VSYNC_SOURCE_HDMI) {
#endif
#if defined(CONFIG_MTK_HDMI_SUPPORT)
				if (down_interruptible(&mtkfb_vsync_sem)) {
					MTKFB_MSG("[mtkfb_vsync_ioctl] can't get semaphore,%d\n",
						  __LINE__);
					msleep(20);
					return ret;
				}
				hdmi_waitVsync();
				up(&mtkfb_vsync_sem);
				MTKFB_VSYNC_LOG("[MTKFB_VSYNC]: leave MTKFB_VSYNC_IOCTL, %d\n",
						__LINE__);
#else
				MTKFB_VSYNC_LOG("[MTKFB_VSYNC]: NS leave MTKFB_VSYNC_IOCTL, %d\n",
						__LINE__);
				ret = -EFAULT;
#endif
				return ret;
			}

			if (down_interruptible(&mtkfb_vsync_sem)) {
				MTKFB_MSG("[mtkfb_vsync_ioctl] can't get semaphore,%d\n", __LINE__);
				msleep(20);
				return ret;
			}
			mtkfb_waitVsync();
			up(&mtkfb_vsync_sem);
			MTKFB_VSYNC_LOG("[MTKFB_VSYNC]: leave MTKFB_VSYNC_IOCTL\n");
		}
		break;
	}
	return ret;
}


static const struct file_operations mtkfb_vsync_fops = {
	.owner = THIS_MODULE,
	.unlocked_ioctl = mtkfb_vsync_unlocked_ioctl,
	.open = mtkfb_vsync_open,
	.release = mtkfb_vsync_release,
	.flush = mtkfb_vsync_flush,
	.read = mtkfb_vsync_read,
};

static int mtkfb_vsync_probe(struct platform_device *pdev)
{
	struct class_device;
	struct class_device *class_dev = NULL;

	MTKFB_MSG("\n=== MTKFB_VSYNC probe ===\n");

	if (alloc_chrdev_region(&mtkfb_vsync_devno, 0, 1, MTKFB_VSYNC_DEVNAME)) {
		VSYNC_ERR("can't get device major number...\n");
		return -EFAULT;
	}

	MTKFB_MSG("get device major number (%d)\n", mtkfb_vsync_devno);

	mtkfb_vsync_cdev = cdev_alloc();
	mtkfb_vsync_cdev->owner = THIS_MODULE;
	mtkfb_vsync_cdev->ops = &mtkfb_vsync_fops;

	cdev_add(mtkfb_vsync_cdev, mtkfb_vsync_devno, 1);

	mtkfb_vsync_class = class_create(THIS_MODULE, MTKFB_VSYNC_DEVNAME);
	class_dev =
	    (struct class_device *)device_create(mtkfb_vsync_class, NULL, mtkfb_vsync_devno, NULL,
						 MTKFB_VSYNC_DEVNAME);

	VSYNC_INF("probe is done\n");
	return 0;
}

static int mtkfb_vsync_remove(struct platform_device *pdev)
{
	VSYNC_INF("device remove\n");
	return 0;
}