static int soundtrigger_input_init(struct device *dev)
{
	int error = 0;

	soundtrigger_input_dev = input_allocate_device();
	if (!soundtrigger_input_dev) {
		pr_err("failed to allocate memory for input dev\n");
		error = -ENOMEM;
		goto err_dev;
	}

	soundtrigger_input_dev->name = "soundtrigger_input_dev";

	soundtrigger_input_dev->evbit[0] = BIT_MASK(EV_KEY);
	soundtrigger_input_dev->keybit[BIT_WORD(KEY_F14)] |= BIT_MASK(KEY_F14);
	soundtrigger_input_dev->keybit[BIT_WORD(KEY_F15)] |= BIT_MASK(KEY_F15);
	soundtrigger_input_dev->keybit[BIT_WORD(KEY_F16)] |= BIT_MASK(KEY_F16);
	soundtrigger_input_dev->keybit[BIT_WORD(KEY_F17)] |= BIT_MASK(KEY_F17);
	soundtrigger_input_dev->keybit[BIT_WORD(KEY_F18)] |= BIT_MASK(KEY_F18);
	error = input_register_device(soundtrigger_input_dev);
	if(error < 0) {
		pr_err("input register device failed, error_no is %d.\n", error);
		goto err_free_dev;
	}
	pr_info("input register device successful.\n");
	return 0;

err_free_dev:
	input_free_device(soundtrigger_input_dev);

err_dev:
	pr_err("error_no is %d.\n", error);

	return error;
}
Exemple #2
0
void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
{
    input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
    input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_0) |
            BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3);
    input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
}
Exemple #3
0
void input_dev_i4s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
{
	input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
	input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) | BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3);
	input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_4) | BIT_MASK(BTN_5) | BIT_MASK(BTN_6);
	input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
}
Exemple #4
0
int touchkit_ps2_detect(struct psmouse *psmouse, bool set_properties)
{
	struct input_dev *dev = psmouse->dev;
	unsigned char param[3];
	int command;

	param[0] = TOUCHKIT_CMD_LENGTH;
	param[1] = TOUCHKIT_CMD_ACTIVE;
	command = TOUCHKIT_SEND_PARMS(2, 3, TOUCHKIT_CMD);

	if (ps2_command(&psmouse->ps2dev, param, command))
		return -ENODEV;

	if (param[0] != TOUCHKIT_CMD || param[1] != 0x01 ||
	    param[2] != TOUCHKIT_CMD_ACTIVE)
		return -ENODEV;

	if (set_properties) {
		dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
		dev->keybit[BIT_WORD(BTN_MOUSE)] = 0;
		dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
		input_set_abs_params(dev, ABS_X, 0, TOUCHKIT_MAX_XC, 0, 0);
		input_set_abs_params(dev, ABS_Y, 0, TOUCHKIT_MAX_YC, 0, 0);

		psmouse->vendor = "eGalax";
		psmouse->name = "Touchscreen";
		psmouse->protocol_handler = touchkit_ps2_process_byte;
		psmouse->pktsize = 5;
	}

	return 0;
}
Exemple #5
0
void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
{
	input_dev->evbit[0] |= BIT_MASK(EV_MSC);
	input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
	input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
	input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
		BIT_MASK(BTN_4);
}
Exemple #6
0
void input_dev_bamboo_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
{
	input_dev->absbit[BIT_WORD(ABS_MISC)] &= ~ABS_MISC;
	/* for now, BAMBOO_PT will only handle pen */
	input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
		BIT_MASK(BTN_STYLUS2);
	input_set_abs_params(input_dev, ABS_DISTANCE, 0,
			     wacom_wac->features->distance_max, 0, 0);
}
Exemple #7
0
void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
{
	input_dev->evbit[0] |= BIT_MASK(EV_REL);
	input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
	input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) |
		BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
	input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
		BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2);
	input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0);
}
Exemple #8
0
static int check_fd(struct tslib_input *i)
{
	struct tsdev *ts = i->module.dev;
	int version;
	long evbit[BITS_TO_LONGS(EV_CNT)];
	long absbit[BITS_TO_LONGS(ABS_CNT)];
	long keybit[BITS_TO_LONGS(KEY_CNT)];

	if (ioctl(ts->fd, EVIOCGVERSION, &version) < 0) {
		fprintf(stderr, "tslib: Selected device is not a Linux input event device\n");
		return -1;
	}

	/* support version EV_VERSION 0x010000 and 0x010001
	 * this check causes more troubles than it solves here */
	if (version < EV_VERSION)
		fprintf(stderr, "tslib: Warning: Selected device uses a different version of the event protocol than tslib was compiled for\n");

	if ( (ioctl(ts->fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) ||
		!(evbit[BIT_WORD(EV_ABS)] & BIT_MASK(EV_ABS)) ||
		!(evbit[BIT_WORD(EV_KEY)] & BIT_MASK(EV_KEY)) ) {
		fprintf(stderr, "tslib: Selected device is not a touchscreen (must support ABS and KEY event types)\n");
		return -1;
	}

	if ((ioctl(ts->fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit)) < 0 ||
		!(absbit[BIT_WORD(ABS_X)] & BIT_MASK(ABS_X)) ||
		!(absbit[BIT_WORD(ABS_Y)] & BIT_MASK(ABS_Y))) {
		fprintf(stderr, "tslib: Selected device is not a touchscreen (must support ABS_X and ABS_Y events)\n");
		return -1;
	}

	/* Since some touchscreens (eg. infrared) physically can't measure pressure,
	the input system doesn't report it on those. Tslib relies on pressure, thus
	we set it to constant 255. It's still controlled by BTN_TOUCH/BTN_LEFT -
	when not touched, the pressure is forced to 0. */

	if (!(absbit[BIT_WORD(ABS_PRESSURE)] & BIT_MASK(ABS_PRESSURE)))
		i->no_pressure = 1;

	if ((ioctl(ts->fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) ||
		!(keybit[BIT_WORD(BTN_TOUCH)] & BIT_MASK(BTN_TOUCH) ||
		  keybit[BIT_WORD(BTN_LEFT)] & BIT_MASK(BTN_LEFT))) {
		fprintf(stderr, "tslib: Selected device is not a touchscreen (must support BTN_TOUCH or BTN_LEFT events)\n");
		return -1;
	}

	if (evbit[BIT_WORD(EV_SYN)] & BIT_MASK(EV_SYN))
		i->using_syn = 1;

	if (i->grab_events == GRAB_EVENTS_WANTED) {
		if (ioctl(ts->fd, EVIOCGRAB, (void *)1)) {
			fprintf(stderr, "tslib: Unable to grab selected input device\n");
			return -1;
		}
		i->grab_events = GRAB_EVENTS_ACTIVE;
	}

	return ts->fd;
}
Exemple #9
0
int bfilter_get_hash(struct bloom_filter *bf, unsigned long hash)
{
	unsigned long *addr;
	hash = hash % bf->nbits;
	addr = bf->bitmap + BIT_WORD(hash);
	return test_bit(hash & (BITS_PER_LONG - 1), addr);
}
Exemple #10
0
int __init vtmodule_init(void)
{
	int i = 0;
	debug_i("vmodule_init called entered");
	/* extra safe initialization */
	vtouch_dev = input_allocate_device();

	/* set up descriptive labels */
	vtouch_dev->name = "Ineda Virtual Touch";
	/* phys is unique on a running system */
	vtouch_dev->phys = "No Physical Path";
	vtouch_dev->id.bustype = BUS_HOST;
	vtouch_dev->id.vendor = 0x0001;

	vtouch_dev->id.product = 0x0001;
	vtouch_dev->id.version = 0x0100;


	vtouch_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
	vtouch_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
	input_set_abs_params(vtouch_dev, ABS_X, 0, 1280, 0, 0);
	input_set_abs_params(vtouch_dev, ABS_Y, 0, 1024, 0, 0);

//	input_set_abs_params(vtouch_dev, ABS_PRESSURE, 1,
//	                     0, 0, 0);

	/* and finally register with the input core */

	i = input_register_device(vtouch_dev);
	debug_i("vmodule_init called exited %d",i);
	return 0;
}
Exemple #11
0
static void copy_abs(struct input_dev *dev, unsigned int dst, unsigned int src)
{
	if (dev->absinfo && test_bit(src, dev->absbit)) {
		dev->absinfo[dst] = dev->absinfo[src];
		dev->absbit[BIT_WORD(dst)] |= BIT_MASK(dst);
	}
}
Exemple #12
0
/**
 * Init function.
 * Allocates interrupt for power button and registers itself to input layer.
 */
static int __init retubutton_init(void)
{
	int irq;

	printk(KERN_INFO "Retu power button driver initialized\n");
	irq = RETU_INT_PWR;

	init_timer(&pwrbtn_timer);
	pwrbtn_timer.function = retubutton_timer_func;

	if (retu_request_irq(irq, &retubutton_irq, 0, "PwrOnX") < 0) {
		printk(KERN_ERR "%s@%s: Cannot allocate irq\n",
		       __FUNCTION__, __FILE__);
		return -EBUSY;
	}

	pwrbtn_dev = input_allocate_device();
	if (!pwrbtn_dev)
		return -ENOMEM;

	pwrbtn_dev->evbit[0] = BIT_MASK(EV_KEY);
	pwrbtn_dev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
	pwrbtn_dev->name = "retu-pwrbutton";

	return input_register_device(pwrbtn_dev);
}
static struct input_dev *alloc_and_register(void)
{
	int error;
	struct input_dev *tmp = input_allocate_device();
	if (!tmp)
		return ERR_PTR(-ENOMEM);

	tmp->name = "IR emulated Mouse";
	tmp->phys = "irmouse/input0";
	tmp->id.bustype = BUS_HOST;
	tmp->id.vendor = 0x0001;
	tmp->id.product = 0x0001;
	tmp->id.version = 0x0100;
	tmp->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
	tmp->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) |
		BIT_MASK(BTN_RIGHT);
	tmp->relbit[0]	= BIT_MASK(REL_X) | BIT_MASK(REL_Y);
	tmp->open = ir_input_open;
	error = input_register_device(tmp);
	if (error) {
		printk("unable to register IR-emu mouse\n");
		input_free_device(tmp);
		return ERR_PTR(error);
	}
	return tmp;

}
Exemple #14
0
static int __init amimouse_init(void)
{
	int err;

	if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE))
		return -ENODEV;

	amimouse_dev = input_allocate_device();
	if (!amimouse_dev)
		return -ENOMEM;

	amimouse_dev->name = "Amiga mouse";
	amimouse_dev->phys = "amimouse/input0";
	amimouse_dev->id.bustype = BUS_AMIGA;
	amimouse_dev->id.vendor = 0x0001;
	amimouse_dev->id.product = 0x0002;
	amimouse_dev->id.version = 0x0100;

	amimouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
	amimouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
	amimouse_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) |
		BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
	amimouse_dev->open = amimouse_open;
	amimouse_dev->close = amimouse_close;

	err = input_register_device(amimouse_dev);
	if (err) {
		input_free_device(amimouse_dev);
		return err;
	}

	return 0;
}
Exemple #15
0
static int __init button_init(void) 
{ 
	int error; 

	if (request_irq(BUTTON_IRQ, button_interrupt, IRQ_TYPE_EDGE_BOTH , "button", NULL)) { 
//	if (request_irq(BUTTON_IRQ, button_interrupt, IRQ_TYPE_EDGE_FALLING , "button", NULL)) { 
		printk(KERN_ERR "button.c: Can't allocate irq %d\n", BUTTON_IRQ); 
        return -EBUSY; 
    } 

	button_dev = input_allocate_device(); 
	if (!button_dev) { 
		printk(KERN_ERR "button.c: Not enough memory\n"); 
		error = -ENOMEM; 
		goto err_free_irq; 
	} 

	button_dev->evbit[0] = BIT_MASK(EV_KEY); 
	button_dev->keybit[BIT_WORD(BTN_0)] = BIT_MASK(BTN_0); 
	button_dev->name = "button"; //input: Unspecified device as /devices/virtual/input/input7
	error = input_register_device(button_dev); 
	if (error) { 
		printk(KERN_ERR "button.c: Failed to register device\n"); 
		goto err_free_dev; 
	} 

 return 0; 

 err_free_dev: 
	input_free_device(button_dev); 
 err_free_irq: 
	free_irq(BUTTON_IRQ, button_interrupt); 
 return error; 
} 
Exemple #16
0
void bfilter_clear_hash(struct bloom_filter *bf, unsigned long hash)
{
	unsigned long *addr;
	hash = hash % bf->nbits;
	addr = bf->bitmap + BIT_WORD(hash);
	clear_bit(hash & (BITS_PER_LONG - 1), addr);
}
Exemple #17
0
static int __init pc110pad_init(void)
{
	int err;

	if (!no_pci_devices())
		return -ENODEV;

	if (!request_region(pc110pad_io, 4, "pc110pad")) {
		printk(KERN_ERR "pc110pad: I/O area %#x-%#x in use.\n",
				pc110pad_io, pc110pad_io + 4);
		return -EBUSY;
	}

	outb(PC110PAD_OFF, pc110pad_io + 2);

	if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) {
		printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq);
		err = -EBUSY;
		goto err_release_region;
	}

	pc110pad_dev = input_allocate_device();
	if (!pc110pad_dev) {
		printk(KERN_ERR "pc110pad: Not enough memory.\n");
		err = -ENOMEM;
		goto err_free_irq;
	}

	pc110pad_dev->name = "IBM PC110 TouchPad";
	pc110pad_dev->phys = "isa15e0/input0";
	pc110pad_dev->id.bustype = BUS_ISA;
	pc110pad_dev->id.vendor = 0x0003;
	pc110pad_dev->id.product = 0x0001;
	pc110pad_dev->id.version = 0x0100;

	pc110pad_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
	pc110pad_dev->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y);
	pc110pad_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);

	pc110pad_dev->absmax[ABS_X] = 0x1ff;
	pc110pad_dev->absmax[ABS_Y] = 0x0ff;

	pc110pad_dev->open = pc110pad_open;
	pc110pad_dev->close = pc110pad_close;

	err = input_register_device(pc110pad_dev);
	if (err)
		goto err_free_dev;

	return 0;

 err_free_dev:
	input_free_device(pc110pad_dev);
 err_free_irq:
	free_irq(pc110pad_irq, NULL);
 err_release_region:
	release_region(pc110pad_io, 4);

	return err;
}
Exemple #18
0
static int vmouse_input_dev_setup(void)
{
    int ret = 0;
    vmouse_idev = input_allocate_device();
 
    if(vmouse_idev == NULL)
    {
        return -ENOMEM;
    }
 
    vmouse_idev->name = "vmouse";
    vmouse_idev->phys = "vmouse/input0";
	vmouse_idev->id.bustype = BUS_HOST;
	vmouse_idev->id.product = 0x0001;
	vmouse_idev->id.vendor = 0x0002;
	vmouse_idev->id.version = 0x0100;
    vmouse_idev->open = vmouse_input_dev_open;
    vmouse_idev->close = vmouse_input_dev_close;

	vmouse_idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
	vmouse_idev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) |
		BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_TOUCH);
	vmouse_idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y) | BIT_MASK(REL_WHEEL) | BIT_MASK(REL_HWHEEL);
 
    ret = input_register_device(vmouse_idev);
 
    return ret;
}
Exemple #19
0
static int __init atamouse_init(void)
{
	if (!MACH_IS_ATARI || !ATARIHW_PRESENT(ST_MFP))
		return -ENODEV;

	if (!(atari_keyb_init()))
		return -ENODEV;

	atamouse_dev = input_allocate_device();
	if (!atamouse_dev)
		return -ENOMEM;

	atamouse_dev->name = "Atari mouse";
	atamouse_dev->phys = "atamouse/input0";
	atamouse_dev->id.bustype = BUS_HOST;
	atamouse_dev->id.vendor = 0x0001;
	atamouse_dev->id.product = 0x0002;
	atamouse_dev->id.version = 0x0100;

	atamouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
	atamouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
	atamouse_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) |
		BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
	atamouse_dev->open = atamouse_open;
	atamouse_dev->close = atamouse_close;

	if (input_register_device(atamouse_dev)) {
		input_free_device(atamouse_dev);
		return -ENOMEM;
	}

	return 0;
}
static int __init amimouse_probe(struct platform_device *pdev)
{
	int err;
	struct input_dev *dev;

	dev = input_allocate_device();
	if (!dev)
		return -ENOMEM;

	dev->name = pdev->name;
	dev->phys = "amimouse/input0";
	dev->id.bustype = BUS_AMIGA;
	dev->id.vendor = 0x0001;
	dev->id.product = 0x0002;
	dev->id.version = 0x0100;

	dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
	dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
	dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) |
		BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
	dev->open = amimouse_open;
	dev->close = amimouse_close;
	dev->dev.parent = &pdev->dev;

	err = input_register_device(dev);
	if (err) {
		input_free_device(dev);
		return err;
	}

	platform_set_drvdata(pdev, dev);

	return 0;
}
Exemple #21
0
static int cp_intc_set_irq_type(struct irq_data *d, unsigned int flow_type)
{
	unsigned reg		= BIT_WORD(d->irq);
	unsigned mask		= BIT_MASK(d->irq);
	unsigned polarity	= cp_intc_read(CP_INTC_SYS_POLARITY(reg));
	unsigned type		= cp_intc_read(CP_INTC_SYS_TYPE(reg));

	switch (flow_type) {
	case IRQ_TYPE_EDGE_RISING:
		polarity |= mask;
		type |= mask;
		break;
	case IRQ_TYPE_EDGE_FALLING:
		polarity &= ~mask;
		type |= mask;
		break;
	case IRQ_TYPE_LEVEL_HIGH:
		polarity |= mask;
		type &= ~mask;
		break;
	case IRQ_TYPE_LEVEL_LOW:
		polarity &= ~mask;
		type &= ~mask;
		break;
	default:
		return -EINVAL;
	}

	cp_intc_write(polarity, CP_INTC_SYS_POLARITY(reg));
	cp_intc_write(type, CP_INTC_SYS_TYPE(reg));

	return 0;
}
static int mac_hid_create_emumouse(void)
{
	static struct lock_class_key mac_hid_emumouse_dev_event_class;
	static struct lock_class_key mac_hid_emumouse_dev_mutex_class;
	int err;

	mac_hid_emumouse_dev = input_allocate_device();
	if (!mac_hid_emumouse_dev)
		return -ENOMEM;

	lockdep_set_class(&mac_hid_emumouse_dev->event_lock,
			  &mac_hid_emumouse_dev_event_class);
	lockdep_set_class(&mac_hid_emumouse_dev->mutex,
			  &mac_hid_emumouse_dev_mutex_class);

	mac_hid_emumouse_dev->name = "Macintosh mouse button emulation";
	mac_hid_emumouse_dev->id.bustype = BUS_ADB;
	mac_hid_emumouse_dev->id.vendor = 0x0001;
	mac_hid_emumouse_dev->id.product = 0x0001;
	mac_hid_emumouse_dev->id.version = 0x0100;

	mac_hid_emumouse_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
	mac_hid_emumouse_dev->keybit[BIT_WORD(BTN_MOUSE)] =
		BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
	mac_hid_emumouse_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);

	err = input_register_device(mac_hid_emumouse_dev);
	if (err) {
		input_free_device(mac_hid_emumouse_dev);
		mac_hid_emumouse_dev = NULL;
		return err;
	}

	return 0;
}
Exemple #23
0
static int __init mxc_ts_init(void)
{
	int retval;

	if (!is_pmic_adc_ready())
		return -ENODEV;

	mxc_inputdev = input_allocate_device();
	if (!mxc_inputdev) {
		printk(KERN_ERR
		       "mxc_ts_init: not enough memory\n");
		return -ENOMEM;
	}

	mxc_inputdev->name = MXC_TS_NAME;
	mxc_inputdev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
	mxc_inputdev->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH);
	mxc_inputdev->absbit[0] =
	    BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | BIT_MASK(ABS_PRESSURE);
	retval = input_register_device(mxc_inputdev);
	if (retval < 0) {
		input_free_device(mxc_inputdev);
		return retval;
	}

	tstask = kthread_run(ts_thread, NULL, "mxc_ts");
	if (IS_ERR(tstask)) {
		printk(KERN_ERR
			"mxc_ts_init: failed to create kthread");
		tstask = NULL;
		return -1;
	}
	printk("mxc input touchscreen loaded\n");
	return 0;
}
Exemple #24
0
int test_bit(int nr, const volatile unsigned long *addr)
{
	const volatile unsigned long *word = addr + BIT_WORD(nr);
	unsigned long mask = BIT_MASK(nr);

	return (*word & mask) != 0;
}
Exemple #25
0
static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev)
{
	struct input_dev *input_dev;
	int error;

	usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname));
	strlcat(cam->input_physname, "/input0", sizeof(cam->input_physname));

	cam->input = input_dev = input_allocate_device();
	if (!input_dev) {
		dev_warn(&dev->dev,
			 "Not enough memory for camera's input device\n");
		return;
	}

	input_dev->name = "Konicawc snapshot button";
	input_dev->phys = cam->input_physname;
	usb_to_input_id(dev, &input_dev->id);
	input_dev->dev.parent = &dev->dev;

	input_dev->evbit[0] = BIT_MASK(EV_KEY);
	input_dev->keybit[BIT_WORD(KEY_CAMERA)] = BIT_MASK(KEY_CAMERA);

	error = input_register_device(cam->input);
	if (error) {
		dev_warn(&dev->dev,
			 "Failed to register camera's input device, err: %d\n",
			 error);
		input_free_device(cam->input);
		cam->input = NULL;
	}
}
Exemple #26
0
static int __init imx_adc_ts_init(void)
{
	int retval;

	if (!is_imx_adc_ready())
		return -ENODEV;

	imx_inputdev = input_allocate_device();
	if (!imx_inputdev) {
		pr_err("imx_ts_init: not enough memory for input device\n");
		return -ENOMEM;
	}

	imx_inputdev->name = IMX_ADC_TS_NAME;
	imx_inputdev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
	imx_inputdev->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH);
	imx_inputdev->absbit[0] =
	    BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | BIT_MASK(ABS_PRESSURE);
	retval = input_register_device(imx_inputdev);
	if (retval < 0) {
		input_free_device(imx_inputdev);
		return retval;
	}

	input_ts_installed = 1;
	kthread_run(ts_thread, NULL, "ts_thread");
	pr_info("i.MX ADC input touchscreen loaded.\n");
	return 0;
}
static int __devinit twl6030_pwrbutton_probe(struct platform_device *pdev)
{
	struct twl6030_pwr_button *pwr_button;
	int irq = platform_get_irq(pdev, 0);
	int err = -ENODEV;

	pr_info("%s: Enter\n", __func__);
	pwr_button = kzalloc(sizeof(struct twl6030_pwr_button), GFP_KERNEL);
	if (!pwr_button)
		return -ENOMEM;

	pwr_button->input_dev = input_allocate_device();
	if (!pwr_button->input_dev) {
		dev_dbg(&pdev->dev, "Can't allocate power button\n");
		goto input_error;
	}

	__set_bit(EV_KEY, pwr_button->input_dev->evbit);

	/*change report_key value equal to KEY_POWER*/
	//pwr_button->report_key = KEY_END;
	pwr_button->report_key = KEY_POWER;
	pwr_button->dev = &pdev->dev;
	pwr_button->input_dev->evbit[0] = BIT_MASK(EV_KEY);
	pwr_button->input_dev->keybit[BIT_WORD(pwr_button->report_key)] =
			BIT_MASK(pwr_button->report_key);
	pwr_button->input_dev->name = "twl6030_pwrbutton";
	pwr_button->input_dev->phys = "twl6030_pwrbutton/input0";
	pwr_button->input_dev->dev.parent = &pdev->dev;

	err = request_threaded_irq(irq, NULL, powerbutton_irq,
			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
			"twl6030_pwrbutton", pwr_button);
	if (err < 0) {
		dev_dbg(&pdev->dev, "Can't get IRQ for pwrbutton: %d\n", err);
		goto free_input_dev;
	}

	err = input_register_device(pwr_button->input_dev);
	if (err) {
		dev_dbg(&pdev->dev, "Can't register power button: %d\n", err);
		goto free_irq;
	}

	twl6030_interrupt_unmask(0x01, REG_INT_MSK_LINE_A);
	twl6030_interrupt_unmask(0x01, REG_INT_MSK_STS_A);

	platform_set_drvdata(pdev, pwr_button);

	return 0;

free_irq:
	free_irq(irq, NULL);
free_input_dev:
	input_free_device(pwr_button->input_dev);
input_error:
	kfree(pwr_button);
	return err;
}
void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
{
	if (wacom_wac->features.device_type == BTN_TOOL_TRIPLETAP) {
		input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP);
		input_dev->evbit[0] |= BIT_MASK(EV_MSC);
		input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
	}
}
Exemple #29
0
int test_and_set_bit(int nr, volatile unsigned long *addr) {
	unsigned long mask = BIT_MASK(nr);
	unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
	unsigned long old = *p;
	
	*p = old | mask;
	return (old & mask) != 0;
}
Exemple #30
0
static int __init inport_init(void)
{
    unsigned char a, b, c;
    int err;

    if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) {
        printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE);
        return -EBUSY;
    }

    a = inb(INPORT_SIGNATURE_PORT);
    b = inb(INPORT_SIGNATURE_PORT);
    c = inb(INPORT_SIGNATURE_PORT);
    if (a == b || a != c) {
        printk(KERN_INFO "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE);
        err = -ENODEV;
        goto err_release_region;
    }

    inport_dev = input_allocate_device();
    if (!inport_dev) {
        printk(KERN_ERR "inport.c: Not enough memory for input device\n");
        err = -ENOMEM;
        goto err_release_region;
    }

    inport_dev->name = INPORT_NAME;
    inport_dev->phys = "isa023c/input0";
    inport_dev->id.bustype = BUS_ISA;
    inport_dev->id.vendor  = INPORT_VENDOR;
    inport_dev->id.product = 0x0001;
    inport_dev->id.version = 0x0100;

    inport_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
    inport_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) |
        BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
    inport_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);

    inport_dev->open  = inport_open;
    inport_dev->close = inport_close;

    outb(INPORT_RESET, INPORT_CONTROL_PORT);
    outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
    outb(INPORT_MODE_BASE, INPORT_DATA_PORT);

    err = input_register_device(inport_dev);
    if (err)
        goto err_free_dev;

    return 0;

 err_free_dev:
    input_free_device(inport_dev);
 err_release_region:
    release_region(INPORT_BASE, INPORT_EXTENT);

    return err;
}