static ssize_t vibr_vtg_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)
{
	unsigned int val;
    struct vibrator_hw* hw = mt_get_cust_vibrator_hw();
	sscanf(buf, "%u", &val);
	if(val>=MIN_VIBR && val <=MAX_VIBR) {
       pmic_set_register_value(PMIC_RG_VIBR_VOSEL,val);
       hw->vib_vol=val;
    }
    
	return count;
}
Ejemplo n.º 2
0
static void vibrator_enable(struct timed_output_dev *dev, int value)
{
		unsigned long flags;
		
		
#if 1
		//struct vibrator_hw* hw = get_cust_vibrator_hw(); 
		struct vibrator_hw* hw = mt_get_cust_vibrator_hw();

#endif
		printk("[vibrator]vibrator_enable: vibrator first in value = %d\n", value);

		spin_lock_irqsave(&vibe_lock, flags);
		while(hrtimer_cancel(&vibe_timer))
                {
                      printk("[vibrator]vibrator_enable: try to cancel hrtimer \n");
                }

		if (value == 0 || shutdown_flag == 1) {
			printk("[vibrator]vibrator_enable: shutdown_flag = %d\n", shutdown_flag);
			vibe_state = 0;
		}
		else 
		{
#if 1
			printk("[vibrator]vibrator_enable: vibrator cust timer: %d \n", hw->vib_timer);
#ifdef CUST_VIBR_LIMIT
			if(value > hw->vib_limit && value < hw->vib_timer)
				
#else
			if(value >= 10 && value < hw->vib_timer)
#endif
				value = hw->vib_timer;
#endif

			value = (value > 15000 ? 15000 : value);
			vibe_state = 1;
			hrtimer_start(&vibe_timer, 
							ktime_set(value / 1000, (value % 1000) * 1000000),
							HRTIMER_MODE_REL);
		}
		spin_unlock_irqrestore(&vibe_lock, flags);
        printk("[vibrator]vibrator_enable: vibrator start: %d \n", value); 
		queue_work(vibrator_queue, &vibrator_work);
}
static ssize_t vibr_vtg_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
	struct vibrator_hw* hw = mt_get_cust_vibrator_hw();

	return sprintf(buf, "%d\n", hw->vib_vol);
}