本文整理汇总了C++中dbg_hid函数的典型用法代码示例。如果您正苦于以下问题:C++ dbg_hid函数的具体用法?C++ dbg_hid怎么用?C++ dbg_hid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbg_hid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: samsung_actionmouse_input_mapping
static int samsung_actionmouse_input_mapping(struct hid_device *hdev,
struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
dbg_hid("samsung wireless actionmouse input mapping event [0x%x], [0x%x], %ld, %ld, [0x%x]\n",
usage->hid, usage->hid & HID_USAGE, hi->input->evbit[0], hi->input->absbit[0], usage->hid & HID_USAGE_PAGE);
if(((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) && ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON))
return 0;
switch (usage->hid & HID_USAGE) {
case 0x301: samsung_kbd_mouse_map_key_clear(KEY_RECENT); break;
default:
return 0;
}
return 1;
}
示例2: logi_dj_ll_input_event
static int logi_dj_ll_input_event(struct input_dev *dev, unsigned int type,
unsigned int code, int value)
{
/* Sent by the input layer to handle leds and Force Feedback */
struct hid_device *dj_hiddev = input_get_drvdata(dev);
struct dj_device *dj_dev = dj_hiddev->driver_data;
struct dj_receiver_dev *djrcv_dev =
dev_get_drvdata(dj_hiddev->dev.parent);
struct hid_device *dj_rcv_hiddev = djrcv_dev->hdev;
struct hid_report_enum *output_report_enum;
struct hid_field *field;
struct hid_report *report;
unsigned char data[8];
int offset;
dbg_hid("%s: %s, type:%d | code:%d | value:%d\n",
__func__, dev->phys, type, code, value);
if (type != EV_LED)
return -1;
offset = hidinput_find_field(dj_hiddev, type, code, &field);
if (offset == -1) {
dev_warn(&dev->dev, "event field not found\n");
return -1;
}
hid_set_field(field, offset, value);
hid_output_report(field->report, &data[0]);
output_report_enum = &dj_rcv_hiddev->report_enum[HID_OUTPUT_REPORT];
report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT];
hid_set_field(report->field[0], 0, dj_dev->device_index);
hid_set_field(report->field[0], 1, REPORT_TYPE_LEDS);
hid_set_field(report->field[0], 2, data[1]);
usbhid_submit_report(dj_rcv_hiddev, report, USB_DIR_OUT);
return 0;
}
示例3: dbg_hid
static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
{
struct hid_field *field;
if (report->maxfield == HID_MAX_FIELDS) {
dbg_hid("too many fields in report\n");
return NULL;
}
if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage)
+ values * sizeof(unsigned), GFP_KERNEL))) return NULL;
field->index = report->maxfield++;
report->field[field->index] = field;
field->usage = (struct hid_usage *)(field + 1);
field->value = (unsigned *)(field->usage + usages);
field->report = report;
return field;
}
示例4: hid_submit_out
static int hid_submit_out(struct hid_device *hid)
{
struct hid_report *report;
char *raw_report;
struct usbhid_device *usbhid = hid->driver_data;
report = usbhid->out[usbhid->outtail].report;
raw_report = usbhid->out[usbhid->outtail].raw_report;
if (!test_bit(HID_REPORTED_IDLE, &usbhid->iofl)) {
usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0);
usbhid->urbout->dev = hid_to_usb_dev(hid);
memcpy(usbhid->outbuf, raw_report, usbhid->urbout->transfer_buffer_length);
kfree(raw_report);
dbg_hid("submitting out urb\n");
if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) {
err_hid("usb_submit_urb(out) failed");
return -1;
}
} else {
示例5: logi_dj_recv_add_djhid_device
static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
struct dj_report *dj_report)
{
/* Called in delayed work context */
struct hid_device *djrcv_hdev = djrcv_dev->hdev;
struct usb_interface *intf = to_usb_interface(djrcv_hdev->dev.parent);
struct usb_device *usbdev = interface_to_usbdev(intf);
struct hid_device *dj_hiddev;
struct dj_device *dj_dev;
/* Device index goes from 1 to 6, we need 3 bytes to store the
* semicolon, the index, and a null terminator
*/
unsigned char tmpstr[3];
if (dj_report->report_params[DEVICE_PAIRED_PARAM_SPFUNCTION] &
SPFUNCTION_DEVICE_LIST_EMPTY) {
dbg_hid("%s: device list is empty\n", __func__);
return;
}
<<<<<<< HEAD
示例6: picolcd_remove
static void picolcd_remove(struct hid_device *hdev)
{
struct picolcd_data *data = hid_get_drvdata(hdev);
unsigned long flags;
dbg_hid(PICOLCD_NAME " hardware remove...\n");
spin_lock_irqsave(&data->lock, flags);
data->status |= PICOLCD_FAILED;
spin_unlock_irqrestore(&data->lock, flags);
picolcd_exit_devfs(data);
device_remove_file(&hdev->dev, &dev_attr_operation_mode);
device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay);
hid_hw_close(hdev);
hid_hw_stop(hdev);
/* Shortcut potential pending reply that will never arrive */
spin_lock_irqsave(&data->lock, flags);
if (data->pending)
complete(&data->pending->ready);
spin_unlock_irqrestore(&data->lock, flags);
/* Cleanup LED */
picolcd_exit_leds(data);
/* Clean up the framebuffer */
picolcd_exit_backlight(data);
picolcd_exit_lcd(data);
picolcd_exit_framebuffer(data);
/* Cleanup input */
picolcd_exit_cir(data);
picolcd_exit_keys(data);
hid_set_drvdata(hdev, NULL);
mutex_destroy(&data->mutex);
/* Finally, clean up the picolcd data itself */
kfree(data);
}
示例7: lg_probe
static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
struct usb_interface *iface = to_usb_interface(hdev->dev.parent);
__u8 iface_num = iface->cur_altsetting->desc.bInterfaceNumber;
unsigned int connect_mask = HID_CONNECT_DEFAULT;
struct lg_drv_data *drv_data;
int ret;
/* G29 only work with the 1st interface */
if ((hdev->product == USB_DEVICE_ID_LOGITECH_G29_WHEEL) &&
(iface_num != 0)) {
dbg_hid("%s: ignoring ifnum %d\n", __func__, iface_num);
return -ENODEV;
}
drv_data = kzalloc(sizeof(struct lg_drv_data), GFP_KERNEL);
if (!drv_data) {
hid_err(hdev, "Insufficient memory, cannot allocate driver data\n");
return -ENOMEM;
}
drv_data->quirks = id->driver_data;
hid_set_drvdata(hdev, (void *)drv_data);
if (drv_data->quirks & LG_NOGET)
hdev->quirks |= HID_QUIRK_NOGET;
ret = hid_parse(hdev);
if (ret) {
hid_err(hdev, "parse failed\n");
goto err_free;
}
if (drv_data->quirks & (LG_FF | LG_FF2 | LG_FF3 | LG_FF4))
connect_mask &= ~HID_CONNECT_FF;
ret = hid_hw_start(hdev, connect_mask);
if (ret) {
hid_err(hdev, "hw start failed\n");
goto err_free;
}
/* Setup wireless link with Logitech Wii wheel */
if (hdev->product == USB_DEVICE_ID_LOGITECH_WII_WHEEL) {
unsigned char buf[] = { 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
if (ret >= 0) {
/* insert a little delay of 10 jiffies ~ 40ms */
wait_queue_head_t wait;
init_waitqueue_head (&wait);
wait_event_interruptible_timeout(wait, 0,
msecs_to_jiffies(40));
/* Select random Address */
buf[1] = 0xB2;
get_random_bytes(&buf[2], 2);
ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
}
}
if (drv_data->quirks & LG_FF)
ret = lgff_init(hdev);
else if (drv_data->quirks & LG_FF2)
ret = lg2ff_init(hdev);
else if (drv_data->quirks & LG_FF3)
ret = lg3ff_init(hdev);
else if (drv_data->quirks & LG_FF4)
ret = lg4ff_init(hdev);
if (ret)
goto err_free;
return 0;
err_free:
kfree(drv_data);
return ret;
}
示例8: int
struct hid_device *hid_parse_report(__u8 *start, unsigned size)
{
struct hid_device *device;
struct hid_parser *parser;
struct hid_item item;
__u8 *end;
unsigned i;
static int (*dispatch_type[])(struct hid_parser *parser,
struct hid_item *item) = {
hid_parser_main,
hid_parser_global,
hid_parser_local,
hid_parser_reserved
};
if (!(device = kzalloc(sizeof(struct hid_device), GFP_KERNEL)))
return NULL;
if (!(device->collection = kzalloc(sizeof(struct hid_collection) *
HID_DEFAULT_NUM_COLLECTIONS, GFP_KERNEL))) {
kfree(device);
return NULL;
}
device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
for (i = 0; i < HID_REPORT_TYPES; i++)
INIT_LIST_HEAD(&device->report_enum[i].report_list);
if (!(device->rdesc = kmalloc(size, GFP_KERNEL))) {
kfree(device->collection);
kfree(device);
return NULL;
}
memcpy(device->rdesc, start, size);
device->rsize = size;
if (!(parser = vmalloc(sizeof(struct hid_parser)))) {
kfree(device->rdesc);
kfree(device->collection);
kfree(device);
return NULL;
}
memset(parser, 0, sizeof(struct hid_parser));
parser->device = device;
end = start + size;
while ((start = fetch_item(start, end, &item)) != NULL) {
if (item.format != HID_ITEM_FORMAT_SHORT) {
dbg_hid("unexpected long global item\n");
hid_free_device(device);
vfree(parser);
return NULL;
}
if (dispatch_type[item.type](parser, &item)) {
dbg_hid("item %u %u %u %u parsing failed\n",
item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag);
hid_free_device(device);
vfree(parser);
return NULL;
}
if (start == end) {
if (parser->collection_stack_ptr) {
dbg_hid("unbalanced collection at end of report description\n");
hid_free_device(device);
vfree(parser);
return NULL;
}
if (parser->local.delimiter_depth) {
dbg_hid("unbalanced delimiter at end of report description\n");
hid_free_device(device);
vfree(parser);
return NULL;
}
vfree(parser);
return device;
}
}
dbg_hid("item fetching failed at offset %d\n", (int)(end - start));
hid_free_device(device);
vfree(parser);
return NULL;
}
示例9: hid_parser_reserved
static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item)
{
dbg_hid("reserved item type, tag 0x%x\n", item->tag);
return 0;
}
示例10: hid_parser_local
static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
{
__u32 data;
unsigned n;
if (item->size == 0) {
dbg_hid("item data expected for local item\n");
return -1;
}
data = item_udata(item);
switch (item->tag) {
case HID_LOCAL_ITEM_TAG_DELIMITER:
if (data) {
/*
* We treat items before the first delimiter
* as global to all usage sets (branch 0).
* In the moment we process only these global
* items and the first delimiter set.
*/
if (parser->local.delimiter_depth != 0) {
dbg_hid("nested delimiters\n");
return -1;
}
parser->local.delimiter_depth++;
parser->local.delimiter_branch++;
} else {
if (parser->local.delimiter_depth < 1) {
dbg_hid("bogus close delimiter\n");
return -1;
}
parser->local.delimiter_depth--;
}
return 1;
case HID_LOCAL_ITEM_TAG_USAGE:
if (parser->local.delimiter_branch > 1) {
dbg_hid("alternative usage ignored\n");
return 0;
}
if (item->size <= 2)
data = (parser->global.usage_page << 16) + data;
return hid_add_usage(parser, data);
case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
if (parser->local.delimiter_branch > 1) {
dbg_hid("alternative usage ignored\n");
return 0;
}
if (item->size <= 2)
data = (parser->global.usage_page << 16) + data;
parser->local.usage_minimum = data;
return 0;
case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
if (parser->local.delimiter_branch > 1) {
dbg_hid("alternative usage ignored\n");
return 0;
}
if (item->size <= 2)
data = (parser->global.usage_page << 16) + data;
for (n = parser->local.usage_minimum; n <= data; n++)
if (hid_add_usage(parser, n)) {
dbg_hid("hid_add_usage failed\n");
return -1;
}
return 0;
default:
dbg_hid("unknown local item tag 0x%x\n", item->tag);
return 0;
}
return 0;
}
示例11: picolcd_probe
static int picolcd_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
struct picolcd_data *data;
int error = -ENOMEM;
dbg_hid(PICOLCD_NAME " hardware probe...\n");
/*
* Let's allocate the picolcd data structure, set some reasonable
* defaults, and associate it with the device
*/
data = kzalloc(sizeof(struct picolcd_data), GFP_KERNEL);
if (data == NULL) {
hid_err(hdev, "can't allocate space for Minibox PicoLCD device data\n");
error = -ENOMEM;
goto err_no_cleanup;
}
spin_lock_init(&data->lock);
mutex_init(&data->mutex);
data->hdev = hdev;
data->opmode_delay = 5000;
if (hdev->product == USB_DEVICE_ID_PICOLCD_BOOTLOADER)
data->status |= PICOLCD_BOOTLOADER;
hid_set_drvdata(hdev, data);
/* Parse the device reports and start it up */
error = hid_parse(hdev);
if (error) {
hid_err(hdev, "device report parse failed\n");
goto err_cleanup_data;
}
error = hid_hw_start(hdev, 0);
if (error) {
hid_err(hdev, "hardware start failed\n");
goto err_cleanup_data;
}
error = hid_hw_open(hdev);
if (error) {
hid_err(hdev, "failed to open input interrupt pipe for key and IR events\n");
goto err_cleanup_hid_hw;
}
error = device_create_file(&hdev->dev, &dev_attr_operation_mode_delay);
if (error) {
hid_err(hdev, "failed to create sysfs attributes\n");
goto err_cleanup_hid_ll;
}
error = device_create_file(&hdev->dev, &dev_attr_operation_mode);
if (error) {
hid_err(hdev, "failed to create sysfs attributes\n");
goto err_cleanup_sysfs1;
}
if (data->status & PICOLCD_BOOTLOADER)
error = picolcd_probe_bootloader(hdev, data);
else
error = picolcd_probe_lcd(hdev, data);
if (error)
goto err_cleanup_sysfs2;
dbg_hid(PICOLCD_NAME " activated and initialized\n");
return 0;
err_cleanup_sysfs2:
device_remove_file(&hdev->dev, &dev_attr_operation_mode);
err_cleanup_sysfs1:
device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay);
err_cleanup_hid_ll:
hid_hw_close(hdev);
err_cleanup_hid_hw:
hid_hw_stop(hdev);
err_cleanup_data:
kfree(data);
err_no_cleanup:
hid_set_drvdata(hdev, NULL);
return error;
}
示例12: samsung_kbd_input_mapping
static int samsung_kbd_input_mapping(struct hid_device *hdev,
struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
if (!(HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE) ||
HID_UP_KEYBOARD == (usage->hid & HID_USAGE_PAGE)))
return 0;
dbg_hid("samsung wireless keyboard input mapping event [0x%x]\n",
usage->hid & HID_USAGE);
if (HID_UP_KEYBOARD == (usage->hid & HID_USAGE_PAGE)) {
switch (usage->hid & HID_USAGE) {
/*set_bit(EV_REP, hi->input->evbit);*/
/* SS_BLUETOOTH(js80.hong) 2012.03.17 */
/* Only for UK keyboard */
/* key found */
case 0x32:
samsung_kbd_mouse_map_key_clear(KEY_KBDILLUMTOGGLE);
break;
case 0x64:
samsung_kbd_mouse_map_key_clear(KEY_BACKSLASH);
break;
default:
return 0;
}
}
if (HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE)) {
switch (usage->hid & HID_USAGE) {
/* report 2 */
/* MENU */
case 0x040:
samsung_kbd_mouse_map_key_clear(KEY_MENU);
break;
case 0x18a:
samsung_kbd_mouse_map_key_clear(KEY_MAIL);
break;
case 0x196:
samsung_kbd_mouse_map_key_clear(KEY_WWW);
break;
case 0x19e:
samsung_kbd_mouse_map_key_clear(KEY_SCREENLOCK);
break;
case 0x221:
samsung_kbd_mouse_map_key_clear(KEY_SEARCH);
break;
case 0x223:
samsung_kbd_mouse_map_key_clear(KEY_HOMEPAGE);
break;
/* RECENTAPPS */
case 0x301:
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY1);
break;
/* APPLICATION */
case 0x302:
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY2);
break;
/* Voice search */
case 0x305:
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY4);
break;
/* QPANEL on/off */
case 0x306:
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY5);
break;
/* SIP on/off */
case 0x307:
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY3);
break;
/* LANG */
case 0x308:
samsung_kbd_mouse_map_key_clear(KEY_LANGUAGE);
break;
case 0x30a:
samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSDOWN);
break;
case 0x30b:
samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSUP);
break;
default:
return 0;
}
}
return 1;
}
示例13: g15_probe
static int g15_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
unsigned long irq_flags;
int error;
struct gcommon_data *gdata;
struct g15_data *g15data;
int i;
int led_num;
struct usb_interface *intf;
struct usb_device *usbdev;
struct list_head *feature_report_list =
&hdev->report_enum[HID_FEATURE_REPORT].report_list;
struct list_head *output_report_list =
&hdev->report_enum[HID_OUTPUT_REPORT].report_list;
struct hid_report *report;
char *led_name;
dev_dbg(&hdev->dev, "Logitech G15 HID hardware probe...");
/* Get the usb device to send the start report on */
intf = to_usb_interface(hdev->dev.parent);
usbdev = interface_to_usbdev(intf);
/*
* Let's allocate the g15 data structure, set some reasonable
* defaults, and associate it with the device
*/
gdata = kzalloc(sizeof(struct gcommon_data), GFP_KERNEL);
if (gdata == NULL) {
dev_err(&hdev->dev, "can't allocate space for Logitech G15 device attributes\n");
error = -ENOMEM;
goto err_no_cleanup;
}
g15data = kzalloc(sizeof(struct g15_data), GFP_KERNEL);
if (g15data == NULL) {
dev_err(&hdev->dev, "can't allocate space for Logitech G15 device attributes\n");
error = -ENOMEM;
goto err_cleanup_gdata;
}
gdata->data = g15data;
spin_lock_init(&gdata->lock);
init_completion(&g15data->ready);
gdata->hdev = hdev;
hid_set_drvdata(hdev, gdata);
dbg_hid("Preparing to parse " G15_NAME " hid reports\n");
/* Parse the device reports and start it up */
error = hid_parse(hdev);
if (error) {
dev_err(&hdev->dev, G15_NAME " device report parse failed\n");
error = -EINVAL;
goto err_cleanup_g15data;
}
error = hid_hw_start(hdev, HID_CONNECT_DEFAULT | HID_CONNECT_HIDINPUT_FORCE);
if (error) {
dev_err(&hdev->dev, G15_NAME " hardware start failed\n");
error = -EINVAL;
goto err_cleanup_g15data;
}
dbg_hid(G15_NAME " claimed: %d\n", hdev->claimed);
error = hdev->ll_driver->open(hdev);
if (error) {
dev_err(&hdev->dev, G15_NAME " failed to open input interrupt pipe for key and joystick events\n");
error = -EINVAL;
goto err_cleanup_g15data;
}
/* Set up the input device for the key I/O */
gdata->input_dev = input_allocate_device();
if (gdata->input_dev == NULL) {
dev_err(&hdev->dev, G15_NAME " error initializing the input device");
error = -ENOMEM;
goto err_cleanup_g15data;
}
input_set_drvdata(gdata->input_dev, gdata);
gdata->input_dev->name = G15_NAME;
gdata->input_dev->phys = hdev->phys;
gdata->input_dev->uniq = hdev->uniq;
gdata->input_dev->id.bustype = hdev->bus;
gdata->input_dev->id.vendor = hdev->vendor;
gdata->input_dev->id.product = hdev->product;
gdata->input_dev->id.version = hdev->version;
gdata->input_dev->dev.parent = hdev->dev.parent;
gdata->input_dev->keycode = gdata->input_data.keycode;
gdata->input_dev->keycodemax = G15_KEYMAP_SIZE;
gdata->input_dev->keycodesize = sizeof(int);
gdata->input_dev->setkeycode = ginput_setkeycode;
gdata->input_dev->getkeycode = ginput_getkeycode;
//.........这里部分代码省略.........
示例14: g19_probe
static int g19_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
unsigned long irq_flags;
int error;
struct g19_data *data;
int i;
int led_num;
struct usb_interface *intf;
struct usb_device *usbdev;
struct list_head *feature_report_list =
&hdev->report_enum[HID_FEATURE_REPORT].report_list;
struct hid_report *report;
char *led_name;
dev_dbg(&hdev->dev, "Logitech G19 HID hardware probe...");
/* Get the usb device to send the start report on */
intf = to_usb_interface(hdev->dev.parent);
usbdev = interface_to_usbdev(intf);
/*
* Let's allocate the g19 data structure, set some reasonable
* defaults, and associate it with the device
*/
data = kzalloc(sizeof(struct g19_data), GFP_KERNEL);
if (data == NULL) {
dev_err(&hdev->dev, "can't allocate space for Logitech G19 device attributes\n");
error = -ENOMEM;
goto err_no_cleanup;
}
spin_lock_init(&data->lock);
init_completion(&data->ready);
data->hdev = hdev;
data->ep1_urb = usb_alloc_urb(0, GFP_KERNEL);
if (data->ep1_urb == NULL) {
dev_err(&hdev->dev, G19_NAME ": ERROR: can't alloc ep1 urb stuff\n");
error = -ENOMEM;
goto err_cleanup_data;
}
hid_set_drvdata(hdev, data);
dbg_hid("Preparing to parse " G19_NAME " hid reports\n");
/* Parse the device reports and start it up */
error = hid_parse(hdev);
if (error) {
dev_err(&hdev->dev, G19_NAME " device report parse failed\n");
error = -EINVAL;
goto err_cleanup_ep1_urb;
}
error = hid_hw_start(hdev, HID_CONNECT_DEFAULT | HID_CONNECT_HIDINPUT_FORCE);
if (error) {
dev_err(&hdev->dev, G19_NAME " hardware start failed\n");
error = -EINVAL;
goto err_cleanup_ep1_urb;
}
dbg_hid(G19_NAME " claimed: %d\n", hdev->claimed);
error = hdev->ll_driver->open(hdev);
if (error) {
dev_err(&hdev->dev, G19_NAME " failed to open input interrupt pipe for key and joystick events\n");
error = -EINVAL;
goto err_cleanup_ep1_urb;
}
/* Set up the input device for the key I/O */
data->input_dev = input_allocate_device();
if (data->input_dev == NULL) {
dev_err(&hdev->dev, G19_NAME " error initializing the input device");
error = -ENOMEM;
goto err_cleanup_ep1_urb;
}
input_set_drvdata(data->input_dev, hdev);
data->input_dev->name = G19_NAME;
data->input_dev->phys = hdev->phys;
data->input_dev->uniq = hdev->uniq;
data->input_dev->id.bustype = hdev->bus;
data->input_dev->id.vendor = hdev->vendor;
data->input_dev->id.product = hdev->product;
data->input_dev->id.version = hdev->version;
data->input_dev->dev.parent = hdev->dev.parent;
data->input_dev->keycode = data->keycode;
data->input_dev->keycodemax = G19_KEYMAP_SIZE;
data->input_dev->keycodesize = sizeof(int);
data->input_dev->setkeycode = g19_input_setkeycode;
data->input_dev->getkeycode = g19_input_getkeycode;
input_set_capability(data->input_dev, EV_KEY, KEY_UNKNOWN);
data->input_dev->evbit[0] |= BIT_MASK(EV_REP);
//.........这里部分代码省略.........
示例15: read_feature_reports
static int read_feature_reports(struct gcore_data *gdata)
{
struct hid_device *hdev = gdata->hdev;
struct g510_data *g510data = gdata->data;
struct list_head *feature_report_list =
&hdev->report_enum[HID_FEATURE_REPORT].report_list;
struct list_head *output_report_list =
&hdev->report_enum[HID_OUTPUT_REPORT].report_list;
struct hid_report *report;
if (list_empty(feature_report_list)) {
dev_err(&hdev->dev, "no feature report found\n");
return -ENODEV;
}
dbg_hid(G510_NAME " feature report found\n");
list_for_each_entry(report, feature_report_list, list) {
switch (report->id) {
case 0x04:
g510data->feature_report_4 = report;
break;
case 0x02:
g510data->led_report = report;
break;
case 0x06:
g510data->start_input_report = report;
break;
case 0x05:
g510data->backlight_report = report;
break;
default:
break;
}
dbg_hid("%s Feature report: id=%u type=%u size=%u maxfield=%u report_count=%u\n",
gdata->name,
report->id, report->type, report->size,
report->maxfield, report->field[0]->report_count);
}
if (list_empty(output_report_list)) {
dev_err(&hdev->dev, "no output report found\n");
return -ENODEV;
}
dbg_hid("%s output report found\n", gdata->name);
list_for_each_entry(report, output_report_list, list) {
dbg_hid("%s output report %d found size=%u maxfield=%u\n",
gdata->name,
report->id, report->size, report->maxfield);
if (report->maxfield > 0) {
dbg_hid("%s offset=%u size=%u count=%u type=%u\n",
gdata->name,
report->field[0]->report_offset,
report->field[0]->report_size,
report->field[0]->report_count,
report->field[0]->report_type);
}
switch (report->id) {
case 0x03:
g510data->output_report_3 = report;
break;
}
}