Commit 754081a7 authored by 吴智聪(John Wu)'s avatar 吴智聪(John Wu)

cleanup ir blaster driver code

parent d0be9aad
......@@ -72,7 +72,8 @@ static struct timer_list learning_key_timer;
static struct blaster_data_type *BlsKey;
static struct blaster_data_pack *bls_data_pack;
struct irrtc_device {
struct irrtc_device
{
int key;
};
static struct irrtc_device device;
......@@ -119,24 +120,27 @@ static void set_timer1_div(struct blaster_data_pack *blsdat)
else
{
count=blsdat->bitstimes&BITS_COUNT_MASK;
if (count==bls_wave_count)
if(count==bls_wave_count)
sbit=0;
if (keybit_get(blsdat->mbits, (count-bls_wave_count)))
if(keybit_get(blsdat->mbits, (count-bls_wave_count)))
{
if (keybit_get(blsdat->dbits, (count-bls_wave_count)))
if(keybit_get(blsdat->dbits, (count-bls_wave_count)))
{
div=blsdat->specbits[sbit];
sbit++;
} else
}
else
{
div=blsdat->bit2;
}
} else
}
else
{
if (keybit_get(blsdat->dbits, (count-bls_wave_count)))
if(keybit_get(blsdat->dbits, (count-bls_wave_count)))
{
div=blsdat->bit1;
} else
}
else
{
div=blsdat->bit0;
}
......@@ -177,12 +181,12 @@ static void blaster_key(struct blaster_data_pack* blsdat)
GPIO23_DIR &= ~GIO_BLS; //gio 47 direction output
/*check if the io port status correct if not correct set it's logic to reverse of start level and hold for a momemt*/
bitset2=GPIO23_OUT_DATA;
if (((bitset2 & GIO_BLS)!=0)&&((bls_data_pack->bitstimes&BITS_COUNT_MASK)!=0))
if(((bitset2 & GIO_BLS)!=0)&&((bls_data_pack->bitstimes&BITS_COUNT_MASK)!=0))
{
GPIO23_CLR_DATA |= GIO_BLS;
msleep(WAIT_HARDWARE_RESET);
}
else if (((bitset2 & GIO_BLS)==0)&&((bls_data_pack->bitstimes&BITS_COUNT_MASK)==0))
else if(((bitset2 & GIO_BLS)==0)&&((bls_data_pack->bitstimes&BITS_COUNT_MASK)==0))
{
GPIO23_SET_DATA |= GIO_BLS;
msleep(WAIT_HARDWARE_RESET);
......@@ -200,12 +204,12 @@ void timer_handle(unsigned long data)
{
int osd_key;
dbg("bitstimes=%d\n", BlsKey->bitstimes);
if (learning_status & WAIT_LEARN_COMPLETE)
if(learning_status & WAIT_LEARN_COMPLETE)
{
lock_data_protect();
osd_key=get_osd_key();
unlock_data_protect();
if (!osd_key )
if(!osd_key )
{
disable_irq(IRQ_TINT1_TINT34);
TIMER1_TCR &= ~(3<<22); //disable timer1 34
......@@ -218,9 +222,9 @@ void timer_handle(unsigned long data)
learning_key_timer.function = timer_handle;
add_timer(&learning_key_timer);
}
else if (learning_status & WAIT_RELEASE_REMOTE)
else if(learning_status & WAIT_RELEASE_REMOTE)
{
if (learning_status & KEY_WAVE_PRESENT)
if(learning_status & KEY_WAVE_PRESENT)
{
learning_status &= ~KEY_WAVE_PRESENT;
learning_key_timer.expires = jiffies + POLL_RELEASE_DELAY;
......@@ -233,7 +237,7 @@ void timer_handle(unsigned long data)
lock_data_protect();
osd_key=get_osd_key();
unlock_data_protect();
if (!osd_key )
if(!osd_key )
{
report_key(RELEASE_REMOTE_KEY);
//report_key(UP_KEY);
......@@ -250,16 +254,16 @@ static int capture_key(struct blaster_data_type* blsdat)
int counter;
int td;
if (!(learning_status & WAIT_RELEASE_REMOTE))
if(!(learning_status & WAIT_RELEASE_REMOTE))
{
counter=TIMER1_TIM34;
if (old_int_counter==timer_int_counter)
if(old_int_counter==timer_int_counter)
td=counter - old_counter;
else
td=MAX_COUNTER - old_counter - INT_CAPTURE_TIME_WASTE + counter ;
old_counter=counter;
old_int_counter=timer_int_counter;
if (!(learning_status & WAIT_LEARN_COMPLETE))
if(!(learning_status & WAIT_LEARN_COMPLETE))
{
times = 0;
learning_key_timer.function = timer_handle;
......@@ -267,14 +271,14 @@ static int capture_key(struct blaster_data_type* blsdat)
learning_status |= WAIT_LEARN_COMPLETE;
}
if (0 == times++)
if(0 == times++)
{
blsdat->bitstimes |= ((SET_GPIO01_IN_DATA & GIO_CAP) << 8);
return 0;
}
blsdat->bits[times-2]=td;
blsdat->bitstimes++;
if (times == BLASTER_MAX_CHANGE+1)
if(times == BLASTER_MAX_CHANGE+1)
{
report_key(LEARNING_COMPLETE_KEY);
learning_key_timer.function = timer_handle;
......@@ -299,10 +303,10 @@ static irqreturn_t handle_bls_timer1_irqs(int irq, void * dev_id, struct pt_regs
}
if(bls_wave_count==0)
return IRQ_HANDLED;
if (!wave_len)
if(!wave_len)
{
bitset2=GPIO23_OUT_DATA;
if (bitset2 & GIO_BLS)
if(bitset2 & GIO_BLS)
GPIO23_CLR_DATA |= GIO_BLS;
else
GPIO23_SET_DATA |= GIO_BLS;
......@@ -339,7 +343,7 @@ static irqreturn_t handle_capture_irqs(int irq, void * dev_id, struct pt_regs *
static int irrtc_open(struct inode * inode, struct file * file)
{
#ifdef ONLYOPENONE
if (opened)
if(opened)
return -EBUSY;
opened = 1;
#endif
......@@ -350,7 +354,7 @@ static int irrtc_open(struct inode * inode, struct file * file)
static int irrtc_release(struct inode * inode, struct file * file)
{
#ifdef ONLYOPENONE
if (!opened)
if(!opened)
return -ERESTARTSYS;
opened = 0;
......@@ -364,27 +368,27 @@ static int irrtc_ioctl(struct inode * inode, struct file * file,
{
int ret = 0;
int arg_size;
if (_IOC_TYPE(cmd) != NEUROS_IR_BLASTER_IOC_MAGIC)
if(_IOC_TYPE(cmd) != NEUROS_IR_BLASTER_IOC_MAGIC)
{
ret = -EINVAL;
goto bail;
}
arg_size = _IOC_SIZE(cmd);
if (_IOC_DIR(cmd) & _IOC_READ)
if(_IOC_DIR(cmd) & _IOC_READ)
ret = !access_ok(VERIFY_WRITE, (void *)arg, arg_size);
else if (_IOC_DIR(cmd) & _IOC_WRITE)
else if(_IOC_DIR(cmd) & _IOC_WRITE)
ret = !access_ok(VERIFY_READ, (void *)arg, arg_size);
if (ret) goto bail;
switch (cmd)
if(ret) goto bail;
switch(cmd)
{
case RRB_BLASTER_KEY:
{
if (bls_status!=BLS_START)
if(bls_status!=BLS_START)
{
int_type=BLASTER;
bls_data_pack=kmalloc(sizeof(struct blaster_data_pack), GFP_KERNEL);
if (bls_data_pack==NULL)
if(bls_data_pack==NULL)
{
ret = -EINVAL;
break;
......@@ -442,7 +446,7 @@ static int irrtc_ioctl(struct inode * inode, struct file * file,
break;
}
bail:
bail:
return ret;
}
......@@ -483,10 +487,10 @@ static int __init irrtc_init(void)
printk(KERN_INFO "\t" MOD_DESC "\n");
status = register_chrdev(NEUROS_IR_BLASTER_MAJOR, "ir_blaster", &irrtc_fops);
if (status != 0)
if(status != 0)
{
if (status == -EINVAL) printk(KERN_ERR "%s Couldn't register device: invalid major number %d.\n", pname, NEUROS_IR_BLASTER_MAJOR);
else if (status == -EBUSY) printk(KERN_ERR "%s Couldn't register device: major number %d already busy.\n", pname, NEUROS_IR_BLASTER_MAJOR);
if(status == -EINVAL) printk(KERN_ERR "%s Couldn't register device: invalid major number %d.\n", pname, NEUROS_IR_BLASTER_MAJOR);
else if(status == -EBUSY) printk(KERN_ERR "%s Couldn't register device: major number %d already busy.\n", pname, NEUROS_IR_BLASTER_MAJOR);
else printk(KERN_ERR "%s Couldn't register device: error %d.\n", pname, status);
status = -1;
goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment