Updated code style
This commit is contained in:
parent
3b760157a1
commit
af53672352
44
perixxkbd.c
44
perixxkbd.c
@ -49,6 +49,9 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
|
|||||||
MODULE_DESCRIPTION(DRIVER_DESC);
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
||||||
MODULE_LICENSE(DRIVER_LICENSE);
|
MODULE_LICENSE(DRIVER_LICENSE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define keycodes
|
||||||
|
*/
|
||||||
static const unsigned char px_kbd_keycode[256] = {
|
static const unsigned char px_kbd_keycode[256] = {
|
||||||
/* BEGIN 04 */
|
/* BEGIN 04 */
|
||||||
/* 0-7 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
|
/* 0-7 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
|
||||||
@ -94,6 +97,32 @@ static const unsigned char px_kbd_keycode[256] = {
|
|||||||
/* END 06 */
|
/* END 06 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct usb_kbd - state of each attached keyboard
|
||||||
|
*
|
||||||
|
* @dev: input device associated with this keyboard
|
||||||
|
* @usbdev: usb device associated with this keyboard
|
||||||
|
* @old: data received in the past from the @irq URB representing which
|
||||||
|
* keys were pressed. By comparing with the current list of keys
|
||||||
|
* that are pressed, we are able to see key releases.
|
||||||
|
* @irq: URB for receiving a list of keys that are pressed when a
|
||||||
|
* new key is pressed or a key that was pressed is released.
|
||||||
|
* @led: URB for sending LEDs (e.g. numlock, ...)
|
||||||
|
* @newleds: data that will be sent with the @led URB representing which LEDs
|
||||||
|
* should be on
|
||||||
|
* @name: Name of the keyboard. @dev's name field points to this buffer
|
||||||
|
* @phys: Physical path of the keyboard. @dev's phys field points to this
|
||||||
|
* buffer
|
||||||
|
* @new: Buffer for the @irq URB
|
||||||
|
* @cr: Control request for @led URB
|
||||||
|
* @leds: Buffer for the @led URB
|
||||||
|
* @new_dma: DMA address for @irq URB
|
||||||
|
* @leds_dma: DMA address for @led URB
|
||||||
|
* @leds_lock: spinlock that protects @leds, @newleds, and @led_urb_submitted
|
||||||
|
* @led_urb_submitted: indicates whether @led is in progress, i.e. it has been
|
||||||
|
* submitted and its completion handler has not returned yet
|
||||||
|
* without resubmitting @led
|
||||||
|
*/
|
||||||
struct usb_kbd {
|
struct usb_kbd {
|
||||||
struct input_dev *dev;
|
struct input_dev *dev;
|
||||||
struct usb_device *usbdev;
|
struct usb_device *usbdev;
|
||||||
@ -218,22 +247,19 @@ static void usb_kbd_irq(struct urb *urb)
|
|||||||
input_report_key(kbd->dev, px_kbd_keycode[138], 1);
|
input_report_key(kbd->dev, px_kbd_keycode[138], 1);
|
||||||
if (kbd->old[1] == 146 && kbd->new[1] != 146)
|
if (kbd->old[1] == 146 && kbd->new[1] != 146)
|
||||||
input_report_key(kbd->dev, px_kbd_keycode[138], 0);
|
input_report_key(kbd->dev, px_kbd_keycode[138], 0);
|
||||||
}
|
} else if (kbd->new[0] == 4) {
|
||||||
else if (kbd->new[0] == 4) {
|
|
||||||
for (j = 1; j < 8; j++) {
|
for (j = 1; j < 8; j++) {
|
||||||
offset = j * 8;
|
offset = j * 8;
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
input_report_key(kbd->dev, px_kbd_keycode[offset + i], (kbd->new[j] >> i) & 1);
|
input_report_key(kbd->dev, px_kbd_keycode[offset + i], (kbd->new[j] >> i) & 1);
|
||||||
}
|
}
|
||||||
}
|
} else if (kbd->new[0] == 5) {
|
||||||
else if (kbd->new[0] == 5) {
|
|
||||||
for (j = 1; j < 8; j++) {
|
for (j = 1; j < 8; j++) {
|
||||||
offset = (j * 8) + 64;
|
offset = (j * 8) + 64;
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
input_report_key(kbd->dev, px_kbd_keycode[offset + i], (kbd->new[j] >> i) & 1);
|
input_report_key(kbd->dev, px_kbd_keycode[offset + i], (kbd->new[j] >> i) & 1);
|
||||||
}
|
}
|
||||||
}
|
} else if (kbd->new[0] == 6) {
|
||||||
else if (kbd->new[0] == 6) {
|
|
||||||
for (j = 1; j < 8; j++) {
|
for (j = 1; j < 8; j++) {
|
||||||
offset = (j * 8) + 192;
|
offset = (j * 8) + 192;
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
@ -253,8 +279,7 @@ resubmit:
|
|||||||
kbd->usbdev->devpath, i);
|
kbd->usbdev->devpath, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usb_kbd_event(struct input_dev *dev, unsigned int type,
|
static int usb_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
|
||||||
unsigned int code, int value)
|
|
||||||
{
|
{
|
||||||
struct usb_kbd *kbd = input_get_drvdata(dev);
|
struct usb_kbd *kbd = input_get_drvdata(dev);
|
||||||
|
|
||||||
@ -340,8 +365,7 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
|
|||||||
usb_free_coherent(dev, 1, kbd->leds, kbd->leds_dma);
|
usb_free_coherent(dev, 1, kbd->leds, kbd->leds_dma);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usb_kbd_probe(struct usb_interface *iface,
|
static int usb_kbd_probe(struct usb_interface *iface, const struct usb_device_id *id)
|
||||||
const struct usb_device_id *id)
|
|
||||||
{
|
{
|
||||||
struct usb_device *dev = interface_to_usbdev(iface);
|
struct usb_device *dev = interface_to_usbdev(iface);
|
||||||
struct usb_host_interface *interface;
|
struct usb_host_interface *interface;
|
||||||
|
Loading…
Reference in New Issue
Block a user