int main(int argc, char *argv[]) { int ret; struct cavan_cache *cache; pthread_t rdthread; cache = cavan_cache_create(10); if (cache == NULL) { pr_red_info("cavan_cache_create"); return -1; } cavan_cache_open(cache); cavan_pthread_create(&rdthread, read_thread_handler, cache, true); while (1) { ssize_t wrlen; char buff[1024]; ret = scanf("%s", buff); if (ret != 1 || strcmp(buff, "exit") == 0) { break; } wrlen = cavan_cache_write(cache, buff, strlen(buff)); if (wrlen < 0) { pr_red_info("cavan_cache_write"); break; } wrlen = cavan_cache_write(cache, "\n", 1); if (wrlen < 0) { pr_red_info("cavan_cache_write"); break; } } cavan_cache_close(cache); pr_pos_info(); pthread_join(rdthread, NULL); pr_pos_info(); cavan_cache_destroy(cache); pr_pos_info(); msleep(1000); pr_pos_info(); return 0; }
static void __exit swan_virtual_keypad_exit(void) { pr_pos_info(); platform_device_unregister(&swan_virtual_keypad_device); platform_driver_unregister(&swan_virtual_keypad_driver); }
int HC548_attach_adapter(void) { struct i2c_board_info info; struct i2c_client *client; struct i2c_adapter *adapter; int ret1; pr_pos_info(); adapter = i2c_get_adapter(I2C_BUS_NUM); if(adapter == NULL) { pr_red_info("HC548 I2C get adapter %d failed\n", I2C_BUS_NUM); ret1 = -ENODEV; goto out_exit; } memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "HC548", I2C_NAME_SIZE); info.addr = HC548_SLAVE_ADDR; client = i2c_new_device(adapter, &info); if(client == NULL) { pr_red_info("HC548 I2C new device failed\n"); ret1 = -ENODEV; goto out_put_adapter; } return 0; out_put_adapter: i2c_put_adapter(adapter); out_exit: return ret1; }
static int swan_virtual_keypad_probe(struct platform_device *pdev) { int ret; struct device_attribute *p; pr_pos_info(); vk_input = input_allocate_device(); if (vk_input == NULL) { pr_red_info("input_allocate_device"); return -ENOMEM; } vk_input->name = SWAN_VK_DEVICE_NAME; swan_virtual_keypad_setup_events(vk_input); ret = input_register_device(vk_input); if (ret < 0) { pr_red_info("input_register_device"); goto out_input_free_device; } ret = misc_register(&swan_vk_misc); if (ret < 0) { pr_red_info("misc_register failed"); goto out_input_unregister_device; } for (p = vk_attrs + ARRAY_SIZE(vk_attrs) - 1; p >= vk_attrs; p--) { ret = device_create_file(&pdev->dev, p); if (ret < 0) { pr_red_info("device_create_file"); while (--p >= vk_attrs) { device_remove_file(&pdev->dev, p); } goto out_misc_deregister; } } pr_green_info("Swan Virtual Keypad is OK"); return 0; out_misc_deregister: misc_deregister(&swan_vk_misc); out_input_unregister_device: input_unregister_device(vk_input); out_input_free_device: input_free_device(vk_input); return ret; }
static void __exit tcp_keypad_exit(void) { pr_pos_info(); platform_device_unregister(&tcp_keypad_device); platform_driver_unregister(&tcp_keypad_driver); }
struct huamobile_input_device *huamobile_mouse_create(void) { struct huamobile_mouse_device *mouse; struct huamobile_input_device *dev; struct huamobile_touch_point *point; pr_pos_info(); mouse = malloc(sizeof(*mouse)); if (mouse == NULL) { pr_error_info("malloc"); return NULL; } mouse->xold = 0; mouse->yold = 0; point = &mouse->point; point->id = 0; point->x = 0; point->y = 0; point->pressure = 0; point->released = 1; dev = &mouse->input_dev; dev->probe = huamobile_mouse_probe; dev->remove = NULL; dev->event_handler = huamobile_mouse_event_handler; return dev; }
static int cy8c242_firmware_upgrade(struct cavan_input_chip *chip, struct cavan_firmware *fw) { int ret; pr_pos_info(); ret = cy8c242_enter_upgrade_mode(chip, 10); if (ret < 0) { pr_red_info("cy8c242_enter_upgrade_mode"); return ret; } ret = cy8c242_firmware_write_data(chip, fw); if (ret < 0) { pr_red_info("cy8c242_firmware_write_data"); return ret; } ret = cy8c242_exit_upgrade_mode(chip, 10); if (ret < 0) { pr_red_info("cy8c242_exit_upgrade_mode"); return ret; } cy8c242_readid(chip); return 0; }
struct huamobile_input_device *huamobile_single_touch_device_create(void) { struct huamobile_single_touch_device *ts; struct huamobile_touch_device *touch_dev; struct huamobile_input_device *dev; pr_pos_info(); ts = malloc(sizeof(*ts)); if (ts == NULL) { pr_error_info("malloc"); return NULL; } ts->pressed = 0; ts->point.released = 1; touch_dev = &ts->touch_dev; touch_dev->xaxis = ABS_X; touch_dev->yaxis = ABS_Y; dev = &touch_dev->input_dev; dev->probe = huamobile_single_touch_device_probe; dev->remove = NULL; dev->event_handler = huamobile_single_touch_event_handler; return dev; }
static int __init tcp_keypad_init(void) { int ret; pr_pos_info(); ret = platform_device_register(&tcp_keypad_device); if (ret < 0) { pr_red_info("platform_device_register"); return ret; } ret = platform_driver_register(&tcp_keypad_driver); if (ret < 0) { pr_red_info("platform_driver_register"); goto out_unregister_device; } return 0; out_unregister_device: platform_device_unregister(&tcp_keypad_device); return ret; }
bool huamobile_touch_device_matcher(int fd, const char *name, void *data) { int ret; uint8_t abs_bitmask[ABS_BITMASK_SIZE]; uint8_t key_bitmask[KEY_BITMASK_SIZE]; pr_pos_info(); ret = huamobile_event_get_abs_bitmask(fd, abs_bitmask); if (ret < 0) { pr_error_info("huamobile_event_get_abs_bitmask"); return false; } if (huamobile_multi_touch_device_match(abs_bitmask)) { pr_green_info("Deivce %s mutil touch screen", name); return true; } ret = huamobile_event_get_key_bitmask(fd, key_bitmask); if (ret < 0) { pr_error_info("huamobile_event_get_key_bitmask"); return false; } return huamobile_single_touch_device_match(abs_bitmask, key_bitmask); }
struct huamobile_input_device *huamobile_multi_touch_device_create(void) { struct huamobile_multi_touch_device *ts; struct huamobile_touch_device *touch_dev; struct huamobile_input_device *dev; struct huamobile_touch_point *p, *p_end; pr_pos_info(); ts = malloc(sizeof(*ts)); if (ts == NULL) { pr_error_info("malloc"); return NULL; } ts->point_count = 0; ts->point_count_old = 0; for (p = ts->points, p_end = p + NELEM(ts->points); p < p_end; p++) { p->id = p - ts->points; p->pressure = -1; p->released = 1; } touch_dev = &ts->touch_dev; touch_dev->xaxis = ABS_MT_POSITION_X; touch_dev->yaxis = ABS_MT_POSITION_Y; dev = &touch_dev->input_dev; dev->probe = huamobile_multi_touch_device_probe; dev->remove = NULL; dev->event_handler = huamobile_multi_touch_event_handler; return dev; }
static int bma2xx_sensor_chip_set_active(struct cavan_input_chip *chip, bool enable) { int ret; u8 value; pr_pos_info(); ret = chip->read_register(chip, REG_MODE_CTRL, &value); if (ret < 0) { pr_red_info("read_register"); return ret; } if (enable) { value &= ~(3 << 6); } else { value |= 1 << 7; } pr_bold_info("value = 0x%02x", value); ret = chip->write_register(chip, REG_MODE_CTRL, value); if (ret < 0) { pr_red_info("write_register"); return ret; } return 0; }
static void bma2xx_input_chip_remove(struct cavan_input_chip *chip) { struct cavan_sensor_device *sensor = cavan_input_chip_get_dev_data(chip); pr_pos_info(); cavan_input_device_unregister(chip, &sensor->dev); kfree(sensor); }
static void bl86x8_input_chip_remove(struct hua_input_chip *chip) { struct hua_bl86x8_device *dev = hua_input_chip_get_dev_data(chip); pr_pos_info(); hua_input_device_unregister(chip, &dev->ts.dev); kfree(dev); }
static void adxl34x_input_chip_remove(struct hua_input_chip *chip) { struct hua_sensor_device *sensor = hua_input_chip_get_dev_data(chip); pr_pos_info(); hua_input_device_unregister(chip, &sensor->dev); kfree(sensor); }
static void ltr553_input_chip_remove(struct cavan_input_chip *chip) { struct cavan_ltr553_device *ltr553 = cavan_input_chip_get_dev_data(chip); pr_pos_info(); cavan_input_device_unregister(chip, <r553->light.dev); cavan_input_device_unregister(chip, <r553->proxi.dev); kfree(ltr553); }
static int HC548_input_open(struct input_dev *dev) { struct HC548_touchscreen_data *data = input_get_drvdata(dev); pr_pos_info(); HC548_start(data); return 0; }
static int huamobile_touch_device_probe(struct huamobile_touch_device *dev, void *data) { int ret; int min, max, diff; int fd = dev->input_dev.event_dev->fd; struct huamobile_input_service *service = data; pr_pos_info(); pr_bold_info("lcd_width = %d, lcd_height = %d", service->lcd_width, service->lcd_height); if (service->lcd_width > 0) { ret = huamobile_event_get_absinfo(fd, dev->xaxis, &min, &max); if (ret < 0) { pr_red_info("huamobile_event_get_absinfo"); return ret; } pr_bold_info("x-min = %d, x-max = %d", min, max); diff = max - min; dev->xscale = ((double)service->lcd_width) / diff; dev->xoffset = ((double)service->lcd_width) * min / diff; } else { dev->xscale = 1; dev->xoffset = 0; } if (service->lcd_height > 0) { ret = huamobile_event_get_absinfo(fd, dev->yaxis, &min, &max); if (ret < 0) { pr_red_info("huamobile_event_get_absinfo"); return ret; } pr_bold_info("y-min = %d, y-max = %d", min, max); diff = max - min; dev->yscale = ((double)service->lcd_height) / diff; dev->yoffset = ((double)service->lcd_height) * min / diff; } else { dev->yscale = 1; dev->yoffset = 0; } pr_bold_info("xscale = %lf, xoffset = %lf", dev->xscale, dev->xoffset); pr_bold_info("yscale = %lf, yoffset = %lf", dev->yscale, dev->yoffset); return 0; }
static int bl86x8_i2c_remove(struct i2c_client *client) { struct hua_input_chip *chip = i2c_get_clientdata(client); pr_pos_info(); hua_input_chip_unregister(chip); kfree(chip); return 0; }
static void cy8c242_input_chip_remove(struct cavan_input_chip *chip) { struct cavan_cy8c242_device *dev = cavan_input_chip_get_dev_data(chip); pr_pos_info(); device_remove_file(&((struct i2c_client *) chip->bus_data)->dev, &dev_attr_firmware_id); cavan_input_device_unregister(chip, &dev->prox.dev); cavan_input_device_unregister(chip, &dev->ts.dev); kfree(dev); }
static int bma2xx_i2c_remove(struct i2c_client *client) { struct cavan_input_chip *chip = i2c_get_clientdata(client); pr_pos_info(); cavan_input_chip_unregister(chip); kfree(chip); return 0; }
static int lis3dh_input_chip_probe(struct cavan_input_chip *chip) { int ret; struct cavan_sensor_device *sensor; struct cavan_input_device *dev; pr_pos_info(); sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); if (sensor == NULL) { pr_red_info("kzalloc"); return -ENOMEM; } cavan_input_chip_set_dev_data(chip, sensor); sensor->power_consume = 145; dev = &sensor->dev; dev->name = "LIS3DH Three-Axis Digital Accelerometer"; dev->type = CAVAN_INPUT_DEVICE_TYPE_ACCELEROMETER; dev->min_delay = 20; dev->poll_delay = 200; dev->set_delay = lis3dh_acceleration_set_delay; if (strcmp(chip->name, "LIS3DH") == 0) { dev->fuzz = 32; dev->flat = 32; sensor->max_range = 2; sensor->resolution = 2048; dev->event_handler = lis3dh_acceleration_event_handler; } else { dev->fuzz = 0; dev->flat = 0; sensor->max_range = 4; sensor->resolution = 256; dev->event_handler = lis3de_acceleration_event_handler; } ret = cavan_input_device_register(chip, dev); if (ret < 0) { pr_red_info("cavan_input_device_register"); goto out_kfree_sensor; } return 0; out_kfree_sensor: kfree(sensor); return ret; }
bool huamobile_multi_touch_device_matcher(int fd, const char *name, void *data) { int ret; uint8_t abs_bitmask[ABS_BITMASK_SIZE]; pr_pos_info(); ret = huamobile_event_get_abs_bitmask(fd, abs_bitmask); if (ret < 0) { pr_error_info("huamobile_event_get_abs_bitmask"); return false; } return huamobile_multi_touch_device_match(abs_bitmask); }
static int mxc6225_input_chip_probe(struct cavan_input_chip *chip) { int ret; struct cavan_sensor_device *sensor; struct cavan_input_device *dev; pr_pos_info(); sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); if (sensor == NULL) { pr_red_info("kzalloc"); return -ENOMEM; } cavan_input_chip_set_dev_data(chip, sensor); sensor->power_consume = 145; dev = &sensor->dev; dev->name = "MXC6225 Two-Axis Digital Accelerometer"; dev->type = CAVAN_INPUT_DEVICE_TYPE_ACCELEROMETER; dev->min_delay = 20; dev->poll_delay = 200; dev->fuzz = 4; dev->flat = 4; sensor->axis_count = 2; sensor->max_range = 4; sensor->resolution = 256; if (chip->devid == CHIP_ID_MXC6225XC) { dev->event_handler = mxc6225xc_acceleration_event_handler; } else { dev->event_handler = mxc6225xu_acceleration_event_handler; } ret = cavan_input_device_register(chip, dev); if (ret < 0) { pr_red_info("cavan_input_device_register"); goto out_kfree_sensor; } return 0; out_kfree_sensor: kfree(sensor); return ret; }
static int cy8c242_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; struct cavan_input_chip *chip; pr_pos_info(); chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pr_red_info("kzalloc"); return -ENOMEM; } i2c_set_clientdata(client, chip); cavan_input_chip_set_bus_data(chip, client); chip->irq = client->irq; chip->irq_flags = IRQF_TRIGGER_FALLING; chip->name = "CY8C242"; chip->devmask = 1 << CAVAN_INPUT_DEVICE_TYPE_TOUCHSCREEN | 1 << CAVAN_INPUT_DEVICE_TYPE_PROXIMITY; chip->set_power = cy8c242_set_power; chip->set_active = cy8c242_set_active; chip->readid = cy8c242_readid; chip->probe = cy8c242_input_chip_probe; chip->remove = cy8c242_input_chip_remove; chip->read_data = cavan_input_read_data_i2c; chip->write_data = cavan_input_write_data_i2c; chip->read_register = cavan_input_read_register_i2c_smbus; chip->write_register = cavan_input_write_register_i2c_smbus; chip->firmware_upgrade = cy8c242_firmware_upgrade; chip->read_firmware_id = cy8c242_read_firmware_id; ret = cavan_input_chip_register(chip, &client->dev); if (ret < 0) { pr_red_info("cavan_input_chip_register"); goto out_kfree_chip; } pr_green_info("CY8C242 Probe Complete"); return 0; out_kfree_chip: kfree(chip); return ret; }
static int hua_ts_device_open(struct input_dev *dev) { int ret; struct hua_input_device *idev = input_get_drvdata(dev); pr_pos_info(); ret = hua_input_device_set_enable_lock(idev, true); if (ret < 0) { pr_red_info("hua_input_device_set_enable_lock"); return ret; } return 0; }
static int ltr553_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; struct cavan_input_chip *chip; pr_pos_info(); chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pr_red_info("kzalloc"); return -ENOMEM; } i2c_set_clientdata(client, chip); cavan_input_chip_set_bus_data(chip, client); #if LTR553_SUPPORT_IRQ chip->irq = client->irq; chip->irq_flags = IRQF_TRIGGER_FALLING; #else chip->irq = -1; #endif pr_bold_info("chip->irq = %d", chip->irq); chip->name = "LTR553"; chip->flags = CAVAN_INPUT_CHIP_FLAG_POWERON_INIT; chip->devmask = 1 << CAVAN_INPUT_DEVICE_TYPE_PROXIMITY | 1 << CAVAN_INPUT_DEVICE_TYPE_LIGHT; chip->read_data = cavan_input_read_data_i2c; chip->write_data = cavan_input_write_data_i2c_single; chip->readid = ltr553_sensor_chip_readid; chip->probe = ltr553_input_chip_probe; chip->remove = ltr553_input_chip_remove; ret = cavan_input_chip_register(chip, &client->dev); if (ret < 0) { pr_red_info("cavan_input_chip_register"); goto out_kfree_chip; } return 0; out_kfree_chip: kfree(chip); return ret; }
static int bl86x8_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret; struct hua_input_chip *chip; pr_pos_info(); chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { pr_red_info("kzalloc"); return -ENOMEM; } i2c_set_clientdata(client, chip); hua_input_chip_set_bus_data(chip, client); chip->irq = client->irq; chip->irq_flags = IRQF_TRIGGER_FALLING; chip->name = "BL86X8"; chip->devmask = 1 << HUA_INPUT_DEVICE_TYPE_TOUCHSCREEN | 1 << HUA_INPUT_DEVICE_TYPE_PROXIMITY; chip->set_power = bl86x8_set_power; chip->readid = bl86x8_readid; chip->probe = bl86x8_input_chip_probe; chip->remove = bl86x8_input_chip_remove; chip->read_data = hua_input_read_data_i2c; chip->write_data = hua_input_write_data_i2c; chip->read_register = hua_input_read_register_i2c_smbus; chip->write_register = hua_input_write_register_i2c_smbus; ret = hua_input_chip_register(chip, &client->dev); if (ret < 0) { pr_red_info("hua_input_chip_register"); goto out_kfree_chip; } pr_green_info("BL86X8 Probe Complete"); return 0; out_kfree_chip: kfree(chip); return ret; }
static int adxl34x_i2c_remove(struct i2c_client *client) { struct hua_input_chip *chip = i2c_get_clientdata(client); pr_pos_info(); hua_input_chip_unregister(chip); if (chip->irq > 0) { sprd_free_eic_irq(chip->irq); } kfree(chip); return 0; }
static int cy8c242_readid(struct cavan_input_chip *chip) { int ret; char buff[18]; pr_pos_info(); ret = chip->read_data(chip, 0x00, buff, sizeof(buff)); if (ret < 0) { pr_red_info("cavan_i2c_read_data"); return ret; } cavan_input_print_memory(buff, ret); return 0; }