Difference between revisions of "Rock/ir"
(Created page with "{{Languages|rock/ir}} __TOC__ The Radxa Rock comes with IR sensor(between the uSD card and USB otg port). This page describe how to use and configure the remote to work prop...") |
PeiYao Wang (Talk | contribs) (→Android) |
||
Line 6: | Line 6: | ||
== Android == | == Android == | ||
+ | The SDK just supports IR with NEC Encode format | ||
+ | There is just one file related "kernel/drivers/input/remotectl/rkxx_remotectl.c" | ||
+ | Do as follows | ||
+ | |||
+ | 1、Add a array as follows | ||
+ | |||
+ | static struct rkxx_remote_key_table remote_key_table_41C8[] = { | ||
+ | {0x38, KEY_VOLUMEUP}, | ||
+ | {0xb8, KEY_VOLUMEDOWN}, | ||
+ | {0x58, KEY_MENU}, | ||
+ | {0xd0, KEY_REPLY}, | ||
+ | {0x48, KEY_BACK}, | ||
+ | {0x98, KEY_BACK}, | ||
+ | {0x50, KEY_UP}, | ||
+ | {0x30, KEY_DOWN}, | ||
+ | {0xc8, KEY_LEFT}, | ||
+ | {0xc0, KEY_RIGHT}, | ||
+ | {0x40, KEY_REPLY}, | ||
+ | {0x80, KEY_SEARCH}, | ||
+ | }; | ||
+ | |||
+ | |||
+ | The first column is the IR key value,the second column is the corresponding key value. | ||
+ | |||
+ | 2、Add one item in | ||
+ | "static struct rkxx_remotectl_button remotectl_button[]" | ||
+ | For example: | ||
+ | { | ||
+ | .usercode = 0x41c8, | ||
+ | .nbuttons = 12, | ||
+ | .key_table = &remote_key_table_41C8[0], | ||
+ | }, | ||
+ | |||
+ | The first is usercode, every IR has a usercode; the second is the buttons number | ||
+ | the third is the first address of the array added in the 1st step. | ||
+ | |||
+ | How to get the usercode and IR key value | ||
+ | In the remotectl_do_something func | ||
+ | case RMC_USERCODE: | ||
+ | { | ||
+ | ddata->scanData <<= 1; | ||
+ | ddata->count ++; | ||
+ | if ((TIME_BIT1_MIN < ddata->period) && (ddata->period < TIME_BIT1_MAX)){ | ||
+ | ddata->scanData |= 0x01; | ||
+ | } | ||
+ | if (ddata->count == 0x10){//16 bit user code | ||
+ | // printk("u=0x%x\n",((ddata->scanData)&0xFFFF)); | ||
+ | if (remotectl_keybdNum_lookup(ddata)){ | ||
+ | ddata->state = RMC_GETDATA; | ||
+ | ddata->scanData = 0; | ||
+ | ddata->count = 0; | ||
+ | }else{ | ||
+ | ddata->state = RMC_PRELOAD; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | Open the printk code to get the usercode,then add remotectl_button array with the usercode and the buttons number | ||
+ | case RMC_GETDATA: | ||
+ | { | ||
+ | ddata->count ++; | ||
+ | ddata->scanData <<= 1; | ||
+ | if ((TIME_BIT1_MIN < ddata->period) && (ddata->period < TIME_BIT1_MAX)){ | ||
+ | ddata->scanData |= 0x01; | ||
+ | } | ||
+ | if (ddata->count == 0x10){ | ||
+ | // printk(KERN_ERR "d=%x\n",(ddata->scanData&0xFFFF)); | ||
+ | if ((ddata->scanData&0x0ff) == ((~ddata->scanData >> 8)&0x0ff)){ | ||
+ | if (remotectl_keycode_lookup(ddata)){ | ||
+ | ddata->press = 1; | ||
+ | ... | ||
+ | } | ||
+ | ... | ||
+ | } | ||
+ | ... | ||
+ | } | ||
+ | } | ||
+ | |||
+ | Open the printk code ,you can get the IR key value | ||
+ | |||
+ | Note: | ||
+ | |||
+ | 1、you will get four number in 0x format, the first two number is we needed ,the last two number is just used for check! | ||
+ | |||
+ | 2、Don't leave much log in code,too much log will result in the ir doesn't work. | ||
== Linux == | == Linux == |
Revision as of 14:59, 28 January 2014
The Radxa Rock comes with IR sensor(between the uSD card and USB otg port). This page describe how to use and configure the remote to work properly on RR.
Android
The SDK just supports IR with NEC Encode format
There is just one file related "kernel/drivers/input/remotectl/rkxx_remotectl.c"
Do as follows
1、Add a array as follows
static struct rkxx_remote_key_table remote_key_table_41C8[] = { {0x38, KEY_VOLUMEUP}, {0xb8, KEY_VOLUMEDOWN}, {0x58, KEY_MENU}, {0xd0, KEY_REPLY}, {0x48, KEY_BACK}, {0x98, KEY_BACK}, {0x50, KEY_UP}, {0x30, KEY_DOWN}, {0xc8, KEY_LEFT}, {0xc0, KEY_RIGHT}, {0x40, KEY_REPLY}, {0x80, KEY_SEARCH}, };
The first column is the IR key value,the second column is the corresponding key value.
2、Add one item in
"static struct rkxx_remotectl_button remotectl_button[]"
For example:
{ .usercode = 0x41c8, .nbuttons = 12, .key_table = &remote_key_table_41C8[0], },
The first is usercode, every IR has a usercode; the second is the buttons number the third is the first address of the array added in the 1st step.
How to get the usercode and IR key value In the remotectl_do_something func
case RMC_USERCODE: { ddata->scanData <<= 1; ddata->count ++; if ((TIME_BIT1_MIN < ddata->period) && (ddata->period < TIME_BIT1_MAX)){ ddata->scanData |= 0x01; } if (ddata->count == 0x10){//16 bit user code // printk("u=0x%x\n",((ddata->scanData)&0xFFFF)); if (remotectl_keybdNum_lookup(ddata)){ ddata->state = RMC_GETDATA; ddata->scanData = 0; ddata->count = 0; }else{ ddata->state = RMC_PRELOAD; } } }
Open the printk code to get the usercode,then add remotectl_button array with the usercode and the buttons number
case RMC_GETDATA: { ddata->count ++; ddata->scanData <<= 1; if ((TIME_BIT1_MIN < ddata->period) && (ddata->period < TIME_BIT1_MAX)){ ddata->scanData |= 0x01; } if (ddata->count == 0x10){ // printk(KERN_ERR "d=%x\n",(ddata->scanData&0xFFFF)); if ((ddata->scanData&0x0ff) == ((~ddata->scanData >> 8)&0x0ff)){ if (remotectl_keycode_lookup(ddata)){ ddata->press = 1; ... } ... } ... } }
Open the printk code ,you can get the IR key value
Note:
1、you will get four number in 0x format, the first two number is we needed ,the last two number is just used for check!
2、Don't leave much log in code,too much log will result in the ir doesn't work.