static unsigned int headset_map_code2key_type(unsigned int code) { unsigned int key_type = EV_KEY; int i; pr_info("headset_map_code2key_type [%d] \n",code); for(i = 0; headset_key_capability[i].key != KEY_RESERVED && headset_key_capability[i].key != code && i < ARRY_SIZE(headset_key_capability); i++); if (i < ARRY_SIZE(headset_key_capability) && headset_key_capability[i].key == code) key_type = headset_key_capability[i].type; else pr_err("headset not find code [0x%x]'s maping type\n", code); return key_type; }
int main(int argc, char *argv[]) { bitree root; int arr[20] = { 29, 23, 45, 16, 18, 17, 34, 38, 24, 19, 0 }; root = create_bitree(arr, ARRY_SIZE(arr)); // 构建顺序二叉树遇到 0 结束 printf("/******************************************/\n"); inorder_bitree(root, dump_node); // 中序遍历二叉树 printf("/******************************************/\n"); destroy_bitree(root); // 中序遍历释放内存 return 0; }
static unsigned int headset_get_button_code_board_method(int v) { static struct headset_adc_range { int min; int max; int code; } adc_range[] = { { 0x0005, 0x0050, KEY_MEDIA}, { 0x0050, 0x0090, KEY_VOLUMEUP }, { 0x0090, 0x0150, KEY_VOLUMEDOWN }, }; int adc_value = sci_adc_get_value(ADC_CHANNEL_TEMP, false); int i; for (i = 0; i < ARRY_SIZE(adc_range); i++) if (adc_value >= adc_range[i].min && adc_value < adc_range[i].max) return adc_range[i].code; return KEY_RESERVED; }
static unsigned int headset_get_button_code_board_method(int v) { static struct headset_adc_range { int min; int max; int code; } adc_range[] = { { 0, 171, KEY_MEDIA}, { 171, 350, KEY_VOLUMEUP }, { 350, 700, KEY_VOLUMEDOWN }, }; int temp; int adc_value; temp = sci_adc_get_value(ADC_CHANNEL_TEMP, false); adc_value = ((1200 * (temp)) / 0x3FC); int i; pr_info("[%s]temp : %d, [button_adc_value] : %d\n", __func__,temp, adc_value); for (i = 0; i < ARRY_SIZE(adc_range); i++) if (adc_value >= adc_range[i].min && adc_value < adc_range[i].max) return adc_range[i].code; return KEY_RESERVED; }
static unsigned int headset_get_button_code_board_method(int v) { static struct headset_adc_range { int min; int max; int code; } adc_range[] = { { 0x0000, 0x0030, KEY_MEDIA}, { 0x0031, 0x0065, KEY_VOLUMEUP}, { 0x0066, 0x00cf, KEY_VOLUMEDOWN }, }; int adc_value; adc_value = sci_adc_get_value(ADC_CHANNEL_TEMP, ADC_SCALE_3V); pr_info("[headset] ********* adc value7 SCALE 0~3V : 0x%x ******* \n", adc_value); int i; for (i = 0; i < ARRY_SIZE(adc_range); i++) if (adc_value >= adc_range[i].min && adc_value < adc_range[i].max) return adc_range[i].code; return KEY_RESERVED; }