예제 #1
0
static ssize_t spfcw043_power(struct device *dev,
			struct device_attribute *attr, const char *buf,
			size_t count)
{
	int brightness = 0;

	if (buf[0] < 0x30 || buf[0] > 0x39) {
		LED_ERROR("data is wrong!");
		return count;
	} else if (buf[1] < 0x30 || buf[1] > 0x39)
		brightness = (int) (buf[0] - 0x30);
	else {
		brightness = brightness + (int) (buf[0] - 0x30) * 10;
		brightness = brightness + (int) (buf[1] - 0x30);
	}

	if (brightness < 0 || brightness >= TORCH_BRIGHTNESS_INVALID) {
		LED_ERROR("brightness data is wrong! %d", brightness);
		return count;
	}

	if (brightness == 0) {
		spfcw043_setPower(0, 0);
	} else {
		if (spfcw043_setGpio()) {
			LED_ERROR("spfcw043_setGpio failed!\n");
			return count;
		}
		spfcw043_setPower(1, brightness);
	}

	return count;
}
static long aat1290a_ioctl(struct file *file,
				unsigned int cmd, unsigned long arg)
{
	int *ctrl = (int *)file->private_data;

	if (!ctrl) {
		LED_ERROR("invalid input data\n");
		return -1;
	}

	switch (cmd) {
	case IOCTL_AAT1290A_SET_BRIGHTNESS:
		if (*ctrl < 0 || *ctrl > TORCH_BRIGHTNESS_0)
			return -EINVAL;
		led_pdata->brightness = *ctrl;
		break;
	case IOCTL_AAT1290A_GET_STATUS:
		*ctrl = led_pdata->status;
		break;
	case IOCTL_AAT1290A_SET_POWER:
		aat1290a_setPower(*ctrl, led_pdata->brightness);
		break;
	default:
		LED_ERROR("invalid input data\n");
		return -EINVAL;
	}

	return 0;
}
예제 #3
0
static int aat1290a_led_probe(struct platform_device *pdev)
{
	LED_ERROR("Probe\n");
	led_pdata =
		(struct aat1290a_led_platform_data *) pdev->dev.platform_data;

	if (misc_register(&aat1290a_miscdev)) {
		LED_ERROR("Failed to register misc driver\n");
		return -ENODEV;
	}

	aat1290a_dev = device_create(camera_class, NULL, 0, NULL, "flash");
	if (IS_ERR(aat1290a_dev))
		LED_ERROR("Failed to create device(flash)!\n");

	if (device_create_file(aat1290a_dev, &dev_attr_rear_flash) < 0) {
		LED_ERROR("failed to create device file, %s\n",
				dev_attr_rear_flash.attr.name);
	}

	if (led_pdata)
		led_pdata->initGpio();
	aat1290a_setGpio();
	return 0;
}
예제 #4
0
static int aat1290a_setGpio(void)
{
	if (led_pdata->status != STATUS_AVAILABLE) {
		if (led_pdata->setGpio()) {
			LED_ERROR("Can't set GPIO for led\n");
			return -ENODEV;
		}
		led_pdata->status = STATUS_AVAILABLE;
	} else {
		LED_ERROR("GPIO already set!");
	}

	return 0;
}
예제 #5
0
static int aat1290a_freeGpio(void)
{
	if (led_pdata->status == STATUS_AVAILABLE) {
		if (led_pdata->freeGpio()) {
			LED_ERROR("Can't free GPIO for led\n");
			return -ENODEV;
		}
		led_pdata->status = STATUS_UNAVAILABLE;
	} else {
		LED_ERROR("GPIO already free!");
	}

	return 0;
}
예제 #6
0
static int aat1290a_setPower(int onoff, int level)
{
	int i;
	if (led_pdata->status == STATUS_AVAILABLE) {
		led_pdata->torch_en(0);
		led_pdata->torch_set(0);
		led_pdata->switch_sel(!onoff);
		/* onoff = 0 - select aat1290a, onoff = 1 - select ISP*/
		udelay(10);
		if (onoff) {
			led_pdata->torch_set(1);
			for (i = 1; i < level; i++) {
				udelay(1);
				led_pdata->torch_set(0);
				udelay(1);
				led_pdata->torch_set(1);
			}
		}
	} else {
		LED_ERROR("GPIO is not available!");
		return -ENODEV;
	}

	return 0;
}
static int aat1290a_release(struct inode *inode, struct file *file)
{
	if (aat1290a_freeGpio()) {
		LED_ERROR("aat1290a_freeGpio failed!\n");
		return -ENODEV;
	}

	return 0;
}
int aat1290a_flash_power(int onoff)
{
	if (onoff == 0) {
		aat1290a_setPower(0, 0);
		if (aat1290a_freeGpio()) {
			LED_ERROR("aat1290a_freeGpio failed!\n");
			return -EIO;
		}
	} else {
		if (aat1290a_setGpio()) {
			LED_ERROR("aat1290a_setGpio failed!\n");
			return -EIO;
		}
		aat1290a_setPower(1, TORCH_BRIGHTNESS_100);
	}

	return 0;
}
예제 #9
0
static int spfcw043_release(struct inode *inode, struct file *file)
{
	if (spfcw043_freeGpio()) {
		LED_ERROR("spfcw043_freeGpio failed!\n");
		return -ENODEV;
	}

	return 0;
}
예제 #10
0
static int spfcw043_led_probe(struct platform_device *pdev)
{
	LED_ERROR("Probe\n");
	led_pdata =
		(struct spfcw043_led_platform_data *) pdev->dev.platform_data;

	if (misc_register(&spfcw043_miscdev)) {
		LED_ERROR("Failed to register misc driver\n");
		return -ENODEV;
	}

	if (IS_ERR(camera_rear))
		LED_ERROR("Failed to create device(flash)!\n");

	if (device_create_file(camera_rear, &dev_attr_rear_flash) < 0) {
		LED_ERROR("failed to create device file, %s\n",
				dev_attr_rear_flash.attr.name);
	}
	spfcw043_setGpio();
	return 0;
}
static ssize_t aat1290a_power(struct device *dev,
			struct device_attribute *attr, const char *buf,
			size_t count)
{
	int brightness = 0;

	LED_ERROR("[%s] buf[0] %d, count %d", __func__, buf[0], count);

	if (count == 1)
		brightness = (int) (buf[0] - 0x30);
	else if (count == 2) {
		brightness = brightness + (int) (buf[0] - 0x30) * 10;
		brightness = brightness + (int) (buf[1] - 0x30);
	} else {
		LED_ERROR("data is too long!");
		return count;
	}

	if (brightness < 0 || brightness >= TORCH_BRIGHTNESS_INVALID) {
		LED_ERROR("brightness data is wrong! %d", brightness);
		return count;
	}

	if (brightness == 0) {
		aat1290a_setPower(0, 0);
		if (aat1290a_freeGpio()) {
			LED_ERROR("aat1290a_freeGpio failed!\n");
			return count;
		}
	} else {
		if (aat1290a_setGpio()) {
			LED_ERROR("aat1290a_setGpio failed!\n");
			return count;
		}
		aat1290a_setPower(1, brightness);
	}

	return count;
}
static int aat1290a_led_probe(struct platform_device *pdev)
{
	LED_ERROR("Probe\n");
	led_pdata =
		(struct aat1290a_led_platform_data *) pdev->dev.platform_data;

	if (misc_register(&aat1290a_miscdev)) {
		LED_ERROR("Failed to register misc driver\n");
		return -ENODEV;
	}

	flash_class = class_create(THIS_MODULE, "flash");
	if (IS_ERR(flash_class))
		LED_ERROR("Failed to create class(flash)!\n");
	aat1290a_dev = device_create(flash_class, NULL, 0, NULL, "flash");
	if (IS_ERR(aat1290a_dev))
		LED_ERROR("Failed to create device(flash)!\n");

	if (device_create_file(aat1290a_dev, &dev_attr_flash_power) < 0) {
		LED_ERROR("failed to create device file, %s\n",
				dev_attr_flash_power.attr.name);
	}
	return 0;
}
예제 #13
0
static inline void i2c_error(struct i2c_periph *periph)
{
  uint8_t err_nr = 0;
  periph->errors->er_irq_cnt;
  if (I2C_GetITStatus(periph->reg_addr, I2C_IT_AF)) {       /* Acknowledge failure */
    periph->errors->ack_fail_cnt++;
    I2C_ClearITPendingBit(periph->reg_addr, I2C_IT_AF);
    err_nr = 1;
  }
  if (I2C_GetITStatus(periph->reg_addr, I2C_IT_BERR)) {     /* Misplaced Start or Stop condition */
    periph->errors->miss_start_stop_cnt++;
    I2C_ClearITPendingBit(periph->reg_addr, I2C_IT_BERR);
    err_nr = 2;
  }
  if (I2C_GetITStatus(periph->reg_addr, I2C_IT_ARLO)) {     /* Arbitration lost */
    periph->errors->arb_lost_cnt++;
    I2C_ClearITPendingBit(periph->reg_addr, I2C_IT_ARLO);
    err_nr = 3;
  }
  if (I2C_GetITStatus(periph->reg_addr, I2C_IT_OVR)) {      /* Overrun/Underrun */
    periph->errors->over_under_cnt++;
    I2C_ClearITPendingBit(periph->reg_addr, I2C_IT_OVR);
    err_nr = 4;
  }
  if (I2C_GetITStatus(periph->reg_addr, I2C_IT_PECERR)) {   /* PEC Error in reception */
    periph->errors->pec_recep_cnt++;
    I2C_ClearITPendingBit(periph->reg_addr, I2C_IT_PECERR);
    err_nr = 5;
  }
  if (I2C_GetITStatus(periph->reg_addr, I2C_IT_TIMEOUT)) {  /* Timeout or Tlow error */
    periph->errors->timeout_tlow_cnt++;
    I2C_ClearITPendingBit(periph->reg_addr, I2C_IT_TIMEOUT);
    err_nr = 6;
  }
  if (I2C_GetITStatus(periph->reg_addr, I2C_IT_SMBALERT)) { /* SMBus alert */
    periph->errors->smbus_alert_cnt++;
    I2C_ClearITPendingBit(periph->reg_addr, I2C_IT_SMBALERT);
    err_nr = 7;
  }

#ifdef I2C_DEBUG_LED
  LED_ERROR(20, err_nr);
#endif

  return;

}
예제 #14
0
static inline void i2c_error(struct i2c_periph *periph)
{
#ifdef I2C_DEBUG_LED
  uint8_t err_nr = 0;
#endif
  periph->errors->er_irq_cnt;
  if ((I2C_SR1((uint32_t)periph->reg_addr) & I2C_SR1_AF) != 0) { /* Acknowledge failure */
    periph->errors->ack_fail_cnt++;
    I2C_SR1((uint32_t)periph->reg_addr) &= ~I2C_SR1_AF;
#ifdef I2C_DEBUG_LED
    err_nr = 1;
#endif
  }
  if ((I2C_SR1((uint32_t)periph->reg_addr) & I2C_SR1_BERR) != 0) {     /* Misplaced Start or Stop condition */
    periph->errors->miss_start_stop_cnt++;
    I2C_SR1((uint32_t)periph->reg_addr) &= ~I2C_SR1_BERR;
#ifdef I2C_DEBUG_LED
    err_nr = 2;
#endif
  }
  if ((I2C_SR1((uint32_t)periph->reg_addr) & I2C_SR1_ARLO) != 0) {     /* Arbitration lost */
    periph->errors->arb_lost_cnt++;
    I2C_SR1((uint32_t)periph->reg_addr) &= ~I2C_SR1_ARLO;
#ifdef I2C_DEBUG_LED
    err_nr = 3;
#endif
  }
  if ((I2C_SR1((uint32_t)periph->reg_addr) & I2C_SR1_OVR) != 0) {      /* Overrun/Underrun */
    periph->errors->over_under_cnt++;
    I2C_SR1((uint32_t)periph->reg_addr) &= ~I2C_SR1_OVR;
#ifdef I2C_DEBUG_LED
    err_nr = 4;
#endif
  }
  if ((I2C_SR1((uint32_t)periph->reg_addr) & I2C_SR1_PECERR) != 0) {   /* PEC Error in reception */
    periph->errors->pec_recep_cnt++;
    I2C_SR1((uint32_t)periph->reg_addr) &= ~I2C_SR1_PECERR;
#ifdef I2C_DEBUG_LED
    err_nr = 5;
#endif
  }
  if ((I2C_SR1((uint32_t)periph->reg_addr) & I2C_SR1_TIMEOUT) != 0) {  /* Timeout or Tlow error */
    periph->errors->timeout_tlow_cnt++;
    I2C_SR1((uint32_t)periph->reg_addr) &= ~I2C_SR1_TIMEOUT;
#ifdef I2C_DEBUG_LED
    err_nr = 6;
#endif
  }
  if ((I2C_SR1((uint32_t)periph->reg_addr) & I2C_SR1_SMBALERT) != 0) { /* SMBus alert */
    periph->errors->smbus_alert_cnt++;
    I2C_SR1((uint32_t)periph->reg_addr) &= ~I2C_SR1_SMBALERT;
#ifdef I2C_DEBUG_LED
    err_nr = 7;
#endif
  }

#ifdef I2C_DEBUG_LED
  LED_ERROR(20, err_nr);
#endif

  return;
}
예제 #15
0
	{NEVER, 0, STARTBUTTON_BIT, &STARTBUTTON(PORT), startbutton_event},
	{NEVER, 0, SETUPBUTTON_BIT, &SETUPBUTTON(PORT), setupbutton_event}
};

struct pacer {
	struct timer	timer;
	unsigned char	pattern;
	unsigned	pattern_bit	: 3;
	unsigned	repeat		: 1;
	unsigned	port_bit	: 3;
	volatile char	*port;
};
static struct pacer	pacers[PACER_MAX] = {
	{EXPIRED, 0x00, 0x1, 0, KEY_BEEP_BIT,      &beep_bits},
	{EXPIRED, 0x00, 0x1, 0, ERR_BEEP_BIT,      &beep_bits},
	{EXPIRED, 0x00, 0x1, 0, LED_ERROR_BIT,     &LED_ERROR(LAT)},
	{EXPIRED, 0x00, 0x1, 0, LED_LOCKED_BIT,    &LED_LOCKED(LAT)},
	{EXPIRED, 0x00, 0x1, 0, LED_CARTRIDGE_BIT, &LED_CARTRIDGE(LAT)},
	{EXPIRED, 0x00, 0x1, 0, LED_CAT_BIT,       &LED_CAT(LAT)}
};


/******************************************************************************/
/* Local Prototypes							      */
/******************************************************************************/

static void set_pacer (unsigned char pacer, unsigned char pattern, unsigned char repeat);


/******************************************************************************/
/* Global Implementations						      */