Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci-2.6.23
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci-2.6.23
Commits
765db0a3
Commit
765db0a3
authored
Jul 11, 2008
by
吴智聪(John Wu)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up neuros_ir and neuros_ir_blaster code
parent
67fc7be9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
155 additions
and
151 deletions
+155
-151
drivers/input/misc/neuros_ir.c
drivers/input/misc/neuros_ir.c
+73
-69
drivers/misc/neuros_ir_blaster.c
drivers/misc/neuros_ir_blaster.c
+82
-82
No files found.
drivers/input/misc/neuros_ir.c
View file @
765db0a3
...
...
@@ -61,7 +61,8 @@
#define IR_RETRY_COUNT 3
#define FACTORY_TEST_DELAY 6
struct
irrtc_device
{
struct
irrtc_device
{
int
key
;
};
static
struct
irrtc_device
device
;
...
...
@@ -71,18 +72,18 @@ static wait_queue_head_t poll_queue;
static
char
*
devname
=
"neuros_ir"
;
static
struct
input_dev
*
ir_input_dev
;
static
int
factory_test
=
0
;
static
int
osd_key
=
0
;
static
int
is_learning
=
0
;
static
int
factory_test
=
0
;
static
int
osd_key
=
0
;
static
int
is_learning
=
0
;
#if USE_WORKQUEUE
#define KEYBUF_SIZE 2
static
int
keybuf
[
KEYBUF_SIZE
];
static
int
roffset
=
0
;
static
int
woffset
=
0
;
static
int
numOfKeys
=
0
;
static
int
roffset
=
0
;
static
int
woffset
=
0
;
static
int
numOfKeys
=
0
;
#else
static
int
keyin
=
0
;
static
int
keyin
=
0
;
#endif
static
void
irrtc_report_key
(
int
ir_key
);
...
...
@@ -93,37 +94,37 @@ static spinlock_t data_protect = SPIN_LOCK_UNLOCKED;
static
void
lock_data_protect
(
void
)
{
spin_lock
(
&
data_protect
);
spin_lock
(
&
data_protect
);
}
EXPORT_SYMBOL
(
lock_data_protect
);
static
void
unlock_data_protect
(
void
)
{
spin_unlock
(
&
data_protect
);
spin_unlock
(
&
data_protect
);
}
EXPORT_SYMBOL
(
unlock_data_protect
);
static
void
set_factory_test
(
int
value
)
{
factory_test
=
value
;
factory_test
=
value
;
}
EXPORT_SYMBOL
(
set_factory_test
);
static
int
get_osd_key
(
void
)
{
return
osd_key
;
return
osd_key
;
}
EXPORT_SYMBOL
(
get_osd_key
);
static
void
set_osd_key
(
int
value
)
{
osd_key
=
value
;
osd_key
=
value
;
}
EXPORT_SYMBOL
(
set_osd_key
);
static
void
set_is_learning
(
int
value
)
{
is_learning
=
value
;
is_learning
=
value
;
}
EXPORT_SYMBOL
(
set_is_learning
);
...
...
@@ -140,7 +141,7 @@ static int read_keybuf(void)
{
numOfKeys
--
;
key
=
keybuf
[
roffset
];
if
(
++
roffset
>=
KEYBUF_SIZE
)
roffset
=
0
;
if
(
++
roffset
>=
KEYBUF_SIZE
)
roffset
=
0
;
}
up
(
&
keybuf_sem
);
...
...
@@ -153,19 +154,19 @@ static int read_keybuf(void)
static
void
write_keybuf
(
int
key
)
{
if
(
-
EINTR
==
down_interruptible
(
&
keybuf_sem
))
return
;
return
;
// Display some more sober debug message on key presses but don't bother with key releases.
if
(
key
!=
0x00
)
printk
(
"{IR:key:%02x}
\n
"
,
key
);
// Display some more sober debug message on key presses but don't bother with key releases.
if
(
key
!=
0x00
)
printk
(
"{IR:key:%02x}
\n
"
,
key
);
if
(
++
numOfKeys
>
KEYBUF_SIZE
)
{
numOfKeys
=
KEYBUF_SIZE
;
if
(
++
roffset
>=
KEYBUF_SIZE
)
roffset
=
0
;
}
if
(
++
numOfKeys
>
KEYBUF_SIZE
)
{
numOfKeys
=
KEYBUF_SIZE
;
if
(
++
roffset
>=
KEYBUF_SIZE
)
roffset
=
0
;
}
keybuf
[
woffset
]
=
key
;
if
(
++
woffset
>=
KEYBUF_SIZE
)
woffset
=
0
;
keybuf
[
woffset
]
=
key
;
if
(
++
woffset
>=
KEYBUF_SIZE
)
woffset
=
0
;
up
(
&
keybuf_sem
);
}
...
...
@@ -173,9 +174,9 @@ static void write_keybuf(int key)
static
void
report_key
(
int
key
)
{
irrtc_report_key
(
key
);
//before adding to keybuf we report this key to the input system
write_keybuf
(
key
);
wake_up_interruptible
(
&
poll_queue
);
irrtc_report_key
(
key
);
//before adding to keybuf we report this key to the input system
write_keybuf
(
key
);
wake_up_interruptible
(
&
poll_queue
);
}
EXPORT_SYMBOL
(
report_key
);
//----------------------------------------------------------- INTERRUPTS -------------------------------------------------------
...
...
@@ -183,30 +184,30 @@ EXPORT_SYMBOL(report_key);
#if USE_WORKQUEUE
static
void
irrtc_do_wq
(
struct
work_struct
*
work
)
{
int
key
;
int
retry
=
IR_RETRY_COUNT
;
int
key
;
int
retry
=
IR_RETRY_COUNT
;
if
(
is_learning
==
1
)
{
disable_irq
(
IRQ_TINT1_TINT34
);
if
(
is_learning
==
1
)
{
disable_irq
(
IRQ_TINT1_TINT34
);
TIMER1_TCR
&=
~
(
3
<<
22
);
//disable timer1 34
disable_irq
(
IRQ_GPIO7
);
lock_data_protect
();
set_osd_key
(
1
);
lock_data_protect
();
set_osd_key
(
1
);
set_is_learning
(
0
);
unlock_data_protect
();
}
//HACK: we KNOW that key should never become 0xFF!!
do
{
key
=
KEY_MASK
&
i2c_read
(
regIR
);
}
while
((
key
==
NULL_KEY
)
&&
(
retry
--
));
dbg
(
"do tasklet: key = [%x]
\n
"
,
key
);
if
(
key
<=
TEST_KEY
&&
key
>=
UP_KEY
)
{
report_key
(
key
);
}
unlock_data_protect
();
}
//HACK: we KNOW that key should never become 0xFF!!
do
{
key
=
KEY_MASK
&
i2c_read
(
regIR
);
}
while
((
key
==
NULL_KEY
)
&&
(
retry
--
));
dbg
(
"do tasklet: key = [%x]
\n
"
,
key
);
if
(
key
<=
TEST_KEY
&&
key
>=
UP_KEY
)
{
report_key
(
key
);
}
}
DECLARE_WORK
(
irrtc_wq
,
irrtc_do_wq
);
...
...
@@ -216,17 +217,17 @@ DECLARE_DELAYED_WORK(irrtc_delay_wq, irrtc_do_wq);
static
irqreturn_t
handle_irrtc_irqs
(
int
irq
,
void
*
dev_id
)
{
#if USE_WORKQUEUE
if
(
!
factory_test
)
schedule_work
(
&
irrtc_wq
);
else
{
schedule_delayed_work
(
&
irrtc_delay_wq
,
FACTORY_TEST_DELAY
);
set_factory_test
(
0
);
}
if
(
!
factory_test
)
schedule_work
(
&
irrtc_wq
);
else
{
schedule_delayed_work
(
&
irrtc_delay_wq
,
FACTORY_TEST_DELAY
);
set_factory_test
(
0
);
}
#else
keyin
=
1
;
keyin
=
1
;
#endif
return
IRQ_HANDLED
;
return
IRQ_HANDLED
;
}
static
void
irqs_irrtc_init
(
void
)
...
...
@@ -273,31 +274,34 @@ static ssize_t irrtc_read(struct file *filp, char __user *buff, size_t count, lo
key
=
read_keybuf
();
dbg
(
"key=%d
\n
"
,
key
);
if
(
key
!=
-
1
)
//none key
r
=
copy_to_user
(
buff
,
&
key
,
sizeof
(
int
));
if
(
key
!=
-
1
)
//none key
r
=
copy_to_user
(
buff
,
&
key
,
sizeof
(
int
));
else
count
=
0
;
count
=
0
;
#else
if
(
-
EINTR
==
down_interruptible
(
&
keybuf_sem
))
return
0
;
return
0
;
if
(
count
>
KEYBUF_SIZE
*
sizeof
(
int
))
{
if
(
count
>
KEYBUF_SIZE
*
sizeof
(
int
))
{
if
(
roffset
<=
woffset
)
count
=
(
woffset
-
roffset
)
*
sizeof
(
int
);
else
count
=
(
KEYBUF_SIZE
-
(
roffset
-
woffset
+
1
))
*
sizeof
(
int
);
}
if
(
count
==
0
)
{
if
(
count
==
0
)
{
printk
(
"buffer empty
\n
"
);
goto
out
;
}
if
(
roffset
<
woffset
)
r
=
copy_to_user
(
buff
,
keybuf
+
roffset
,
count
);
else
{
r
=
copy_to_user
(
buff
,
&
keybuf
[
roffset
],
(
KEYBUF_SIZE
-
roffset
+
1
)
*
sizeof
(
int
));
r
=
copy_to_user
(
buff
+
(
KEYBUF_SIZE
-
roffset
+
1
)
*
sizeof
(
int
),
keybuf
,
woffset
*
sizeof
(
int
));
r
=
copy_to_user
(
buff
,
keybuf
+
roffset
,
count
);
else
{
r
=
copy_to_user
(
buff
,
&
keybuf
[
roffset
],
(
KEYBUF_SIZE
-
roffset
+
1
)
*
sizeof
(
int
));
r
=
copy_to_user
(
buff
+
(
KEYBUF_SIZE
-
roffset
+
1
)
*
sizeof
(
int
),
keybuf
,
woffset
*
sizeof
(
int
));
}
out:
...
...
@@ -313,7 +317,7 @@ static ssize_t irrtc_write(struct file * file, const char __user * buf, size_t c
return
-
1
;
//printk("-----------------%x\n",key);
report_key
(
key
);
report_key
(
key
);
return
count
;
}
...
...
@@ -346,7 +350,7 @@ static void irrtc_inputdev_init(void)
// set a bit in the input device structure for each key that we are able to generate.
for
(
i
=
0
;
i
<
NUM_KEYS
;
i
++
)
if
(
keymap
[
i
]
!=
0
)
if
(
keymap
[
i
]
!=
0
)
set_bit
(
keymap
[
i
],
ir_input_dev
->
keybit
);
input_register_device
(
ir_input_dev
);
//done. we can now send events into the system.
...
...
drivers/misc/neuros_ir_blaster.c
View file @
765db0a3
...
...
@@ -64,9 +64,9 @@
#define GIO_CAP (1<<7)
static
int
learning_status
=
0
;
static
int
bls_wave_count
;
static
int
bls_status
=
BLS_COMPLETE
;
static
int
timer_int_counter
=
0
;
static
int
wave_len
=
0
;
static
int
bls_status
=
BLS_COMPLETE
;
static
int
timer_int_counter
=
0
;
static
int
wave_len
=
0
;
static
int
int_type
;
static
struct
timer_list
learning_key_timer
;
static
struct
blaster_data_type
*
BlsKey
;
...
...
@@ -108,50 +108,50 @@ static void set_timer1_div(struct blaster_data_pack *blsdat)
unsigned
int
div
;
int
count
;
static
int
sbit
;
if
(
wave_len
)
if
(
wave_len
)
{
div
=
wave_len
;
if
(
div
>
MAX_COUNTER
)
div
=
MAX_COUNTER
;
wave_len
-=
div
;
div
=
wave_len
;
if
(
div
>
MAX_COUNTER
)
div
=
MAX_COUNTER
;
wave_len
-=
div
;
}
else
{
count
=
blsdat
->
bitstimes
&
BITS_COUNT_MASK
;
if
(
count
==
bls_wave_count
)
sbit
=
0
;
if
(
keybit_get
(
blsdat
->
mbits
,
(
count
-
bls_wave_count
)))
count
=
blsdat
->
bitstimes
&
BITS_COUNT_MASK
;
if
(
count
==
bls_wave_count
)
sbit
=
0
;
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
];
div
=
blsdat
->
specbits
[
sbit
];
sbit
++
;
}
else
{
div
=
blsdat
->
bit2
;
div
=
blsdat
->
bit2
;
}
}
else
{
if
(
keybit_get
(
blsdat
->
dbits
,
(
count
-
bls_wave_count
)))
if
(
keybit_get
(
blsdat
->
dbits
,
(
count
-
bls_wave_count
)))
{
div
=
blsdat
->
bit1
;
div
=
blsdat
->
bit1
;
}
else
{
div
=
blsdat
->
bit0
;
div
=
blsdat
->
bit0
;
}
}
}
//div-=div>>5; // The ideal situation is that set the timer prescale to let the timer cycle is 1us
// but the nearest setting make the cycle 1.032us so do this adjustment with
// divider value
div
-=
INT_TIMER1_TIME_WASTE
;
if
(
div
>
MAX_COUNTER
)
div
-=
INT_TIMER1_TIME_WASTE
;
if
(
div
>
MAX_COUNTER
)
{
wave_len
=
div
-
MAX_COUNTER
;
div
=
MAX_COUNTER
;
wave_len
=
div
-
MAX_COUNTER
;
div
=
MAX_COUNTER
;
}
div
--
;
TIMER1_TCR
&=
~
(
3
<<
22
);
//disable timer1 34
...
...
@@ -169,34 +169,34 @@ static void set_timer1_div(struct blaster_data_pack *blsdat)
static
void
blaster_key
(
struct
blaster_data_pack
*
blsdat
)
{
uint16_t
bitset2
;
wave_len
=
0
;
bls_status
=
BLS_START
;
bls_wave_count
=
blsdat
->
bitstimes
&
BITS_COUNT_MASK
;
if
(
bls_wave_count
>
BLASTER_MAX_CHANGE
||
bls_wave_count
<=
0
)
wave_len
=
0
;
bls_status
=
BLS_START
;
bls_wave_count
=
blsdat
->
bitstimes
&
BITS_COUNT_MASK
;
if
(
bls_wave_count
>
BLASTER_MAX_CHANGE
||
bls_wave_count
<=
0
)
{
bls_status
=
BLS_ERROR
;
if
(
bls_data_pack
)
bls_status
=
BLS_ERROR
;
if
(
bls_data_pack
)
{
kfree
(
bls_data_pack
);
bls_data_pack
=
NULL
;
bls_data_pack
=
NULL
;
}
return
;
}
GPIO23_DIR
&=
~
GIO_BLS
;
//gio 47 direction output
GPIO23_CLR_DATA
|=
GIO_BLS
;
/*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
))
bitset2
=
GPIO23_OUT_DATA
;
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
);
}
if
(
blsdat
->
bitstimes
&
FIRST_LEVEL_BIT_MASK
)
if
(
blsdat
->
bitstimes
&
FIRST_LEVEL_BIT_MASK
)
GPIO23_SET_DATA
|=
GIO_BLS
;
else
GPIO23_CLR_DATA
|=
GIO_BLS
;
...
...
@@ -208,12 +208,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
...
...
@@ -226,9 +226,9 @@ void timer_handle(unsigned long data)
learning_key_timer
.
function
=
timer_handle
;
mod_timer
(
&
learning_key_timer
,
jiffies
+
POLL_RELEASE_DELAY
);
}
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
.
function
=
timer_handle
;
...
...
@@ -238,9 +238,9 @@ void timer_handle(unsigned long data)
{
disable_learning
();
lock_data_protect
();
osd_key
=
get_osd_key
();
osd_key
=
get_osd_key
();
unlock_data_protect
();
if
(
!
osd_key
)
if
(
!
osd_key
)
{
report_key
(
RELEASE_REMOTE_KEY
);
//report_key(UP_KEY);
...
...
@@ -251,22 +251,22 @@ void timer_handle(unsigned long data)
static
int
capture_key
(
struct
blaster_data_type
*
blsdat
)
{
static
int
times
=
0
;
static
int
times
=
0
;
static
int
old_counter
;
static
int
old_int_counter
;
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
)
td
=
counter
-
old_counter
;
counter
=
TIMER1_TIM34
;
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
==
0
)
td
=
MAX_COUNTER
-
old_counter
-
INT_CAPTURE_TIME_WASTE
+
counter
;
old_counter
=
counter
;
old_int_counter
=
timer_int_counter
;
if
(
learning_status
==
0
)
{
times
=
0
;
learning_key_timer
.
function
=
timer_handle
;
...
...
@@ -274,14 +274,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
->
bits
[
times
-
2
]
=
td
;
blsdat
->
bitstimes
++
;
if
(
times
==
BLASTER_MAX_CHANGE
+
1
)
if
(
times
==
BLASTER_MAX_CHANGE
+
1
)
{
disable_irq
(
IRQ_TINT1_TINT34
);
TIMER1_TCR
&=
~
(
3
<<
22
);
//disable timer1 34
...
...
@@ -301,32 +301,32 @@ static int capture_key(struct blaster_data_type* blsdat)
static
irqreturn_t
handle_bls_timer1_irqs
(
int
irq
,
void
*
dev_id
)
{
uint32_t
bitset2
;
if
(
int_type
==
CAPTURE
)
{
if
(
int_type
==
CAPTURE
)
{
timer_int_counter
++
;
return
IRQ_HANDLED
;
}
if
(
bls_wave_count
==
0
)
if
(
bls_wave_count
==
0
)
return
IRQ_HANDLED
;
if
(
!
wave_len
)
if
(
!
wave_len
)
{
bitset2
=
GPIO23_OUT_DATA
;
if
(
bitset2
&
GIO_BLS
)
bitset2
=
GPIO23_OUT_DATA
;
if
(
bitset2
&
GIO_BLS
)
GPIO23_CLR_DATA
|=
GIO_BLS
;
else
GPIO23_SET_DATA
|=
GIO_BLS
;
bls_wave_count
--
;
}
if
(
bls_wave_count
==
0
)
if
(
bls_wave_count
==
0
)
{
disable_irq
(
IRQ_TINT1_TINT34
);
TIMER1_TCR
&=
~
(
3
<<
22
);
//disable timer1 34
GPIO23_DIR
|=
GIO_BLS
;
//gio 47 direction input
bls_status
=
BLS_COMPLETE
;
if
(
bls_data_pack
)
bls_status
=
BLS_COMPLETE
;
if
(
bls_data_pack
)
{
kfree
(
bls_data_pack
);
bls_data_pack
=
NULL
;
bls_data_pack
=
NULL
;
}
return
IRQ_HANDLED
;
}
...
...
@@ -348,7 +348,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
...
...
@@ -359,7 +359,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
;
...
...
@@ -373,27 +373,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
)
int_type
=
BLASTER
;
bls_data_pack
=
kmalloc
(
sizeof
(
struct
blaster_data_pack
),
GFP_KERNEL
);
if
(
bls_data_pack
==
NULL
)
{
ret
=
-
EINVAL
;
break
;
...
...
@@ -405,17 +405,17 @@ static int irrtc_ioctl(struct inode * inode, struct file * file,
break
;
case
RRB_CAPTURE_KEY
:
{
BlsKey
=
kmalloc
(
sizeof
(
struct
blaster_data_type
),
GFP_KERNEL
);
if
(
BlsKey
==
NULL
)
BlsKey
=
kmalloc
(
sizeof
(
struct
blaster_data_type
),
GFP_KERNEL
);
if
(
BlsKey
==
NULL
)
{
ret
=
-
EINVAL
;
break
;
}
memset
(
BlsKey
,
0
,
sizeof
(
struct
blaster_data_type
));
set_osd_key
(
0
);
int_type
=
CAPTURE
;
timer_int_counter
=
0
;
learning_status
=
0
;
int_type
=
CAPTURE
;
timer_int_counter
=
0
;
learning_status
=
0
;
TIMER1_TGCR
&=
~
(
3
<<
2
);
//clear timer1 mode
TIMER1_TGCR
|=
(
1
<<
2
);
//set timer1 unchained mode
TIMER1_TGCR
&=
~
(
1
<<
1
);
//reset timer1 34
...
...
@@ -431,11 +431,11 @@ static int irrtc_ioctl(struct inode * inode, struct file * file,
break
;
case
RRB_READ_LEARNING_DATA
:
{
if
(
BlsKey
)
if
(
BlsKey
)
{
ret
|=
copy_to_user
((
void
*
)
arg
,
BlsKey
,
sizeof
(
struct
blaster_data_type
));
kfree
(
BlsKey
);
BlsKey
=
NULL
;
BlsKey
=
NULL
;
}
}
break
;
...
...
@@ -502,10 +502,10 @@ static int __init irrtc_init(void)
printk
(
KERN_INFO
"
\t
"
MOD_DESC
"
\n
"
);
status
=
register_chrdev
(
NEUROS_IR_BLASTER_MAJOR
,
"neuros_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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment