コード例 #1
0
static int camera_dev_ioctl(struct inode *inode, struct file *file,
	unsigned int cmd, unsigned long arg)
{
	int rc = 0;

	if (!bHaveResetGpio) {
		ddbg_print("Requesting reset gpio\n");
		rc = gpio_request(gpio_reset, "camera reset");
		if (!rc)
			bHaveResetGpio = 1;
	}
	if (!bHavePowerDownGpio) {
		ddbg_print("Requesting powerdown gpio\n");
		rc = gpio_request(gpio_powerdown, "camera powerdown");
		if (!rc)
			bHavePowerDownGpio = 1;
	}
	ddbg_print("camera ioctl cmd = %u, arg = %lu\n", cmd, arg);

	switch (cmd) {
	case CAMERA_RESET_WRITE:
		if (bHaveResetGpio) {
			gpio_direction_output(gpio_reset, 0);
			gpio_set_value(gpio_reset, (arg ? 1 : 0));
			dbg_print("CAMERA_MISC set RESET line to %u\n",
				(arg ? 1 : 0));
		}

		if (!bHaveResetGpio) {
			err_print ("CAMERA_MISC: gpio_request () failed. \
				rc = %d; cmd = %d; arg = %lu", rc, cmd, arg);
			return -EIO;
		}
		break;

	case CAMERA_POWERDOWN_WRITE:
		if (bHavePowerDownGpio) {
			gpio_direction_output(gpio_powerdown, 0);
			if (0 == arg)
				gpio_set_value(gpio_powerdown, 0);
			else
				gpio_set_value(gpio_powerdown, 1);
			dbg_print("CAMERA_MISC set POWERDOWN line to %u\n",
				(arg ? 1 : 0));
		}
		if (!bHavePowerDownGpio) {
			err_print ("CAMERA_MISC: gpio_request () failed. \
				rc = %d; cmd = %u; arg = %lu", rc, cmd, arg);
			return -EIO;
		}
コード例 #2
0
static int camera_dev_release(struct inode *inode, struct file *file)
{
// TO DO REMOVE
    ddbg_print( "camera0 closed\n");
// TO DO REMOVE
    return 0;
}
コード例 #3
0
static int camera_dev_open(struct inode *inode, struct file *file)
{
// TO DO REMOVE
    ddbg_print( "camera0 opened\n");
// TO DO REMOVE
    return 0;
}
コード例 #4
0
static int __init camera_misc_init(void)
{
    ddbg_print("camera misc init\n" );

    if(misc_register( &cam_misc_device0 ))
    {
        err_print( "error in register camera misc device!\n" );
        return -EIO;
    }
    return 0;
}
コード例 #5
0
static int camera_dev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)

{
    int rc;

    ddbg_print( "camera ioctl cmd = %u, arg = %lu\n", cmd, arg);

    switch(cmd)
    {
        case CAMERA_RESET_WRITE:
            rc = gpio_request (GPIO_RESET, GPIO_SENSOR_NAME);
            if (!rc)
            {
                gpio_direction_output (GPIO_RESET, (arg ? 1 : 0));
                dbg_print( "CAMERA_MISC set RESET line to %u\n", (arg ? 1 : 0));
            }
            gpio_free (GPIO_RESET);
            if (rc)
            {
              err_print ("CAMERA_MISC: gpio_request () failed. rc = %d; cmd = %d; arg = %lu", rc, cmd, arg); 
              return -EIO;
            }
            break;


        case CAMERA_POWERDOWN_WRITE:
            rc = gpio_request (GPIO_POWERDOWN, GPIO_SENSOR_NAME);
            if (!rc)
            {
                if (0 == arg)
                {
#if 0 // TODO: NEED TO HANDLE MCLK
                  msm_camio_camif_pad_reg_reset();
                  mdelay (50);
#endif // TODO: NEED TO HANDLE MCLK
                  rc = gpio_direction_output (GPIO_POWERDOWN, 0);
                }
                else
                {
                  rc = gpio_direction_output (GPIO_POWERDOWN, 1);
                }
                dbg_print( "CAMERA_MISC set POWERDOWN line to %u\n", (arg ? 1 : 0));
            }
            gpio_free (GPIO_POWERDOWN);
            if (rc)
            {
              err_print ("CAMERA_MISC: gpio_request () failed. rc = %d; cmd = %u; arg = %lu", rc, cmd, arg); 
              return -EIO;
            }
            break;

        case CAMERA_CLOCK_DISABLE:
            msm_camio_camif_pad_reg_reset();
            dbg_print( "CAMERA_MISC turned off MCLK done\n");
            break;

        case CAMERA_CLOCK_ENABLE:
            /* enable mclk */
            msm_camio_clk_rate_set ((int)arg);
            dbg_print( "CAMERA_MISC set MCLK to %d\n", (int) arg);
            break;

        default:
            err_print( "CAMERA_MISC received unsupported cmd; cmd = %u\n", cmd);
            return -EIO;
            break;
    }

    return 0;
}
コード例 #6
0
static void __exit camera_misc_exit(void)
{
    ddbg_print("camera misc exit\n" );
    misc_deregister( &cam_misc_device0 );
}