blob: 2a9bf07944c03b94adfc62ed5aa989c197fb04fe [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __HID_H
2#define __HID_H
3
4/*
5 * $Id: hid.h,v 1.24 2001/12/27 10:37:41 vojtech Exp $
6 *
7 * Copyright (c) 1999 Andreas Gal
8 * Copyright (c) 2000-2001 Vojtech Pavlik
9 */
10
11/*
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Should you need to contact me, the author, you can do so either by
27 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
28 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
29 */
30
31#include <linux/types.h>
32#include <linux/slab.h>
33#include <linux/list.h>
Alan Sternaef4e262006-01-31 12:58:38 -050034#include <linux/timer.h>
35#include <linux/workqueue.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37/*
38 * USB HID (Human Interface Device) interface class code
39 */
40
41#define USB_INTERFACE_CLASS_HID 3
42
43/*
Alan Stern0f28b552006-05-15 14:49:04 -040044 * USB HID interface subclass and protocol codes
45 */
46
47#define USB_INTERFACE_SUBCLASS_BOOT 1
48#define USB_INTERFACE_PROTOCOL_KEYBOARD 1
49#define USB_INTERFACE_PROTOCOL_MOUSE 2
50
51/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 * HID class requests
53 */
54
55#define HID_REQ_GET_REPORT 0x01
56#define HID_REQ_GET_IDLE 0x02
57#define HID_REQ_GET_PROTOCOL 0x03
58#define HID_REQ_SET_REPORT 0x09
59#define HID_REQ_SET_IDLE 0x0A
60#define HID_REQ_SET_PROTOCOL 0x0B
61
62/*
63 * HID class descriptor types
64 */
65
66#define HID_DT_HID (USB_TYPE_CLASS | 0x01)
67#define HID_DT_REPORT (USB_TYPE_CLASS | 0x02)
68#define HID_DT_PHYSICAL (USB_TYPE_CLASS | 0x03)
69
70/*
71 * We parse each description item into this structure. Short items data
72 * values are expanded to 32-bit signed int, long items contain a pointer
73 * into the data area.
74 */
75
76struct hid_item {
77 unsigned format;
78 __u8 size;
79 __u8 type;
80 __u8 tag;
81 union {
82 __u8 u8;
83 __s8 s8;
84 __u16 u16;
85 __s16 s16;
86 __u32 u32;
87 __s32 s32;
88 __u8 *longdata;
89 } data;
90};
91
92/*
93 * HID report item format
94 */
95
96#define HID_ITEM_FORMAT_SHORT 0
97#define HID_ITEM_FORMAT_LONG 1
98
99/*
100 * Special tag indicating long items
101 */
102
103#define HID_ITEM_TAG_LONG 15
104
105/*
106 * HID report descriptor item type (prefix bit 2,3)
107 */
108
109#define HID_ITEM_TYPE_MAIN 0
110#define HID_ITEM_TYPE_GLOBAL 1
111#define HID_ITEM_TYPE_LOCAL 2
112#define HID_ITEM_TYPE_RESERVED 3
113
114/*
115 * HID report descriptor main item tags
116 */
117
118#define HID_MAIN_ITEM_TAG_INPUT 8
119#define HID_MAIN_ITEM_TAG_OUTPUT 9
120#define HID_MAIN_ITEM_TAG_FEATURE 11
121#define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10
122#define HID_MAIN_ITEM_TAG_END_COLLECTION 12
123
124/*
125 * HID report descriptor main item contents
126 */
127
128#define HID_MAIN_ITEM_CONSTANT 0x001
129#define HID_MAIN_ITEM_VARIABLE 0x002
130#define HID_MAIN_ITEM_RELATIVE 0x004
Dmitry Torokhov05f091ab2005-05-29 02:29:01 -0500131#define HID_MAIN_ITEM_WRAP 0x008
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132#define HID_MAIN_ITEM_NONLINEAR 0x010
133#define HID_MAIN_ITEM_NO_PREFERRED 0x020
134#define HID_MAIN_ITEM_NULL_STATE 0x040
135#define HID_MAIN_ITEM_VOLATILE 0x080
136#define HID_MAIN_ITEM_BUFFERED_BYTE 0x100
137
138/*
139 * HID report descriptor collection item types
140 */
141
142#define HID_COLLECTION_PHYSICAL 0
143#define HID_COLLECTION_APPLICATION 1
144#define HID_COLLECTION_LOGICAL 2
145
146/*
147 * HID report descriptor global item tags
148 */
149
150#define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0
151#define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1
152#define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2
153#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3
154#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4
155#define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5
156#define HID_GLOBAL_ITEM_TAG_UNIT 6
157#define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7
158#define HID_GLOBAL_ITEM_TAG_REPORT_ID 8
159#define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9
160#define HID_GLOBAL_ITEM_TAG_PUSH 10
161#define HID_GLOBAL_ITEM_TAG_POP 11
162
163/*
164 * HID report descriptor local item tags
165 */
166
167#define HID_LOCAL_ITEM_TAG_USAGE 0
168#define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1
169#define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2
170#define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3
171#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4
172#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5
173#define HID_LOCAL_ITEM_TAG_STRING_INDEX 7
174#define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8
175#define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9
176#define HID_LOCAL_ITEM_TAG_DELIMITER 10
177
178/*
179 * HID usage tables
180 */
181
182#define HID_USAGE_PAGE 0xffff0000
183
184#define HID_UP_UNDEFINED 0x00000000
Dmitry Torokhov05f091ab2005-05-29 02:29:01 -0500185#define HID_UP_GENDESK 0x00010000
Vojtech Pavlik0aebfda2005-09-05 00:07:59 -0500186#define HID_UP_SIMULATION 0x00020000
Dmitry Torokhov05f091ab2005-05-29 02:29:01 -0500187#define HID_UP_KEYBOARD 0x00070000
188#define HID_UP_LED 0x00080000
189#define HID_UP_BUTTON 0x00090000
190#define HID_UP_ORDINAL 0x000a0000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191#define HID_UP_CONSUMER 0x000c0000
Dmitry Torokhov05f091ab2005-05-29 02:29:01 -0500192#define HID_UP_DIGITIZER 0x000d0000
193#define HID_UP_PID 0x000f0000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194#define HID_UP_HPVENDOR 0xff7f0000
195#define HID_UP_MSVENDOR 0xff000000
Stelian Pope875ce32005-09-05 01:57:33 -0500196#define HID_UP_CUSTOM 0x00ff0000
197#define HID_UP_LOGIVENDOR 0xffbc0000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199#define HID_USAGE 0x0000ffff
200
201#define HID_GD_POINTER 0x00010001
202#define HID_GD_MOUSE 0x00010002
203#define HID_GD_JOYSTICK 0x00010004
204#define HID_GD_GAMEPAD 0x00010005
205#define HID_GD_KEYBOARD 0x00010006
206#define HID_GD_KEYPAD 0x00010007
207#define HID_GD_MULTIAXIS 0x00010008
208#define HID_GD_X 0x00010030
209#define HID_GD_Y 0x00010031
210#define HID_GD_Z 0x00010032
211#define HID_GD_RX 0x00010033
212#define HID_GD_RY 0x00010034
213#define HID_GD_RZ 0x00010035
214#define HID_GD_SLIDER 0x00010036
215#define HID_GD_DIAL 0x00010037
216#define HID_GD_WHEEL 0x00010038
217#define HID_GD_HATSWITCH 0x00010039
218#define HID_GD_BUFFER 0x0001003a
219#define HID_GD_BYTECOUNT 0x0001003b
220#define HID_GD_MOTION 0x0001003c
221#define HID_GD_START 0x0001003d
222#define HID_GD_SELECT 0x0001003e
223#define HID_GD_VX 0x00010040
224#define HID_GD_VY 0x00010041
225#define HID_GD_VZ 0x00010042
226#define HID_GD_VBRX 0x00010043
227#define HID_GD_VBRY 0x00010044
228#define HID_GD_VBRZ 0x00010045
229#define HID_GD_VNO 0x00010046
230#define HID_GD_FEATURE 0x00010047
231#define HID_GD_UP 0x00010090
232#define HID_GD_DOWN 0x00010091
233#define HID_GD_RIGHT 0x00010092
234#define HID_GD_LEFT 0x00010093
235
236/*
237 * HID report types --- Ouch! HID spec says 1 2 3!
238 */
239
240#define HID_INPUT_REPORT 0
241#define HID_OUTPUT_REPORT 1
242#define HID_FEATURE_REPORT 2
243
244/*
245 * HID device quirks.
246 */
247
Michael Hanselmanneab9edd2006-01-14 10:08:06 -0500248#define HID_QUIRK_INVERT 0x00000001
249#define HID_QUIRK_NOTOUCH 0x00000002
250#define HID_QUIRK_IGNORE 0x00000004
251#define HID_QUIRK_NOGET 0x00000008
252#define HID_QUIRK_HIDDEV 0x00000010
253#define HID_QUIRK_BADPAD 0x00000020
254#define HID_QUIRK_MULTI_INPUT 0x00000040
255#define HID_QUIRK_2WHEEL_MOUSE_HACK_7 0x00000080
256#define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x00000100
257#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x00000200
Bart Masseya82e49b2006-05-08 14:40:13 -0700258#define HID_QUIRK_MIGHTYMOUSE 0x00000400
Michael Hanselmanneab9edd2006-01-14 10:08:06 -0500259#define HID_QUIRK_CYMOTION 0x00000800
260#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000
261#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000
Bart Masseya82e49b2006-05-08 14:40:13 -0700262#define HID_QUIRK_INVERT_HWHEEL 0x00004000
Olaf Heringbb7eef62006-11-08 19:58:07 -0800263#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00008000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
265/*
266 * This is the global environment of the parser. This information is
267 * persistent for main-items. The global environment can be saved and
268 * restored with PUSH/POP statements.
269 */
270
271struct hid_global {
272 unsigned usage_page;
273 __s32 logical_minimum;
274 __s32 logical_maximum;
275 __s32 physical_minimum;
276 __s32 physical_maximum;
277 __s32 unit_exponent;
278 unsigned unit;
279 unsigned report_id;
280 unsigned report_size;
281 unsigned report_count;
282};
283
284/*
285 * This is the local environment. It is persistent up the next main-item.
286 */
287
288#define HID_MAX_DESCRIPTOR_SIZE 4096
289#define HID_MAX_USAGES 1024
290#define HID_DEFAULT_NUM_COLLECTIONS 16
291
292struct hid_local {
293 unsigned usage[HID_MAX_USAGES]; /* usage array */
294 unsigned collection_index[HID_MAX_USAGES]; /* collection index array */
295 unsigned usage_index;
296 unsigned usage_minimum;
297 unsigned delimiter_depth;
298 unsigned delimiter_branch;
299};
300
301/*
302 * This is the collection stack. We climb up the stack to determine
303 * application and function of each field.
304 */
305
306struct hid_collection {
307 unsigned type;
308 unsigned usage;
309 unsigned level;
310};
311
312struct hid_usage {
313 unsigned hid; /* hid usage code */
314 unsigned collection_index; /* index into collection array */
315 /* hidinput data */
316 __u16 code; /* input driver code */
317 __u8 type; /* input driver type */
318 __s8 hat_min; /* hat switch fun */
319 __s8 hat_max; /* ditto */
320 __s8 hat_dir; /* ditto */
321};
322
323struct hid_input;
324
325struct hid_field {
326 unsigned physical; /* physical usage for this field */
327 unsigned logical; /* logical usage for this field */
328 unsigned application; /* application usage for this field */
329 struct hid_usage *usage; /* usage table for this function */
330 unsigned maxusage; /* maximum usage index */
331 unsigned flags; /* main-item flags (i.e. volatile,array,constant) */
332 unsigned report_offset; /* bit offset in the report */
333 unsigned report_size; /* size of this field in the report */
334 unsigned report_count; /* number of this field in the report */
335 unsigned report_type; /* (input,output,feature) */
336 __s32 *value; /* last known value(s) */
337 __s32 logical_minimum;
338 __s32 logical_maximum;
339 __s32 physical_minimum;
340 __s32 physical_maximum;
341 __s32 unit_exponent;
342 unsigned unit;
343 struct hid_report *report; /* associated report */
344 unsigned index; /* index into report->field[] */
345 /* hidinput data */
346 struct hid_input *hidinput; /* associated input structure */
347 __u16 dpad; /* dpad input code */
348};
349
350#define HID_MAX_FIELDS 64
351
352struct hid_report {
353 struct list_head list;
354 unsigned id; /* id of this report */
355 unsigned type; /* report type */
356 struct hid_field *field[HID_MAX_FIELDS]; /* fields of the report */
357 unsigned maxfield; /* maximum valid field index */
358 unsigned size; /* size of the report (bits) */
359 struct hid_device *device; /* associated device */
360};
361
362struct hid_report_enum {
363 unsigned numbered;
364 struct list_head report_list;
365 struct hid_report *report_id_hash[256];
366};
367
368#define HID_REPORT_TYPES 3
369
Michael Haboustakbf0964d2005-09-05 00:12:01 -0500370#define HID_MIN_BUFFER_SIZE 64 /* make sure there is at least a packet size of space */
371#define HID_MAX_BUFFER_SIZE 4096 /* 4kb */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372#define HID_CONTROL_FIFO_SIZE 256 /* to init devices with >100 reports */
373#define HID_OUTPUT_FIFO_SIZE 64
374
375struct hid_control_fifo {
376 unsigned char dir;
377 struct hid_report *report;
378};
379
380#define HID_CLAIMED_INPUT 1
381#define HID_CLAIMED_HIDDEV 2
382
383#define HID_CTRL_RUNNING 1
384#define HID_OUT_RUNNING 2
Alan Sternaef4e262006-01-31 12:58:38 -0500385#define HID_IN_RUNNING 3
386#define HID_RESET_PENDING 4
387#define HID_SUSPENDED 5
Alan Stern6d8fc4d2006-10-18 12:35:24 -0400388#define HID_CLEAR_HALT 6
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
390struct hid_input {
391 struct list_head list;
392 struct hid_report *report;
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -0500393 struct input_dev *input;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394};
395
396struct hid_device { /* device report descriptor */
397 __u8 *rdesc;
398 unsigned rsize;
399 struct hid_collection *collection; /* List of HID collections */
400 unsigned collection_size; /* Number of allocated hid_collections */
401 unsigned maxcollection; /* Number of parsed collections */
402 unsigned maxapplication; /* Number of applications */
403 unsigned version; /* HID version */
404 unsigned country; /* HID country */
405 struct hid_report_enum report_enum[HID_REPORT_TYPES];
406
407 struct usb_device *dev; /* USB device */
408 struct usb_interface *intf; /* USB interface */
409 int ifnum; /* USB interface number */
410
411 unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
Alan Sternaef4e262006-01-31 12:58:38 -0500412 struct timer_list io_retry; /* Retry timer */
413 unsigned long stop_retry; /* Time to give up, in jiffies */
414 unsigned int retry_delay; /* Delay length in ms */
415 struct work_struct reset_work; /* Task context for resets */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
Michael Haboustakbf0964d2005-09-05 00:12:01 -0500417 unsigned int bufsize; /* URB buffer size */
418
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 struct urb *urbin; /* Input URB */
420 char *inbuf; /* Input buffer */
421 dma_addr_t inbuf_dma; /* Input buffer dma */
Alan Sternaef4e262006-01-31 12:58:38 -0500422 spinlock_t inlock; /* Input fifo spinlock */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
424 struct urb *urbctrl; /* Control URB */
425 struct usb_ctrlrequest *cr; /* Control request struct */
426 dma_addr_t cr_dma; /* Control request struct dma */
427 struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */
428 unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */
429 char *ctrlbuf; /* Control buffer */
430 dma_addr_t ctrlbuf_dma; /* Control buffer dma */
431 spinlock_t ctrllock; /* Control fifo spinlock */
432
433 struct urb *urbout; /* Output URB */
434 struct hid_report *out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
435 unsigned char outhead, outtail; /* Output pipe fifo head & tail */
436 char *outbuf; /* Output buffer */
437 dma_addr_t outbuf_dma; /* Output buffer dma */
438 spinlock_t outlock; /* Output fifo spinlock */
439
Dmitry Torokhov05f091ab2005-05-29 02:29:01 -0500440 unsigned claimed; /* Claimed by hidinput, hiddev? */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 unsigned quirks; /* Various quirks the device can pull on us */
442
443 struct list_head inputs; /* The list of inputs */
444 void *hiddev; /* The hiddev structure */
445 int minor; /* Hiddev minor number */
446
447 wait_queue_head_t wait; /* For sleeping */
448
449 int open; /* is the device open by anyone? */
450 char name[128]; /* Device name */
451 char phys[64]; /* Device physical location */
452 char uniq[64]; /* Device unique identifier (serial #) */
453
Michael Hanselmanneab9edd2006-01-14 10:08:06 -0500454#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
455 unsigned long pb_pressed_fn[NBITS(KEY_MAX)];
456 unsigned long pb_pressed_numlock[NBITS(KEY_MAX)];
457#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458};
459
460#define HID_GLOBAL_STACK_SIZE 4
461#define HID_COLLECTION_STACK_SIZE 4
462
463struct hid_parser {
464 struct hid_global global;
465 struct hid_global global_stack[HID_GLOBAL_STACK_SIZE];
466 unsigned global_stack_ptr;
467 struct hid_local local;
468 unsigned collection_stack[HID_COLLECTION_STACK_SIZE];
469 unsigned collection_stack_ptr;
470 struct hid_device *device;
471};
472
473struct hid_class_descriptor {
474 __u8 bDescriptorType;
475 __u16 wDescriptorLength;
476} __attribute__ ((packed));
477
478struct hid_descriptor {
479 __u8 bLength;
480 __u8 bDescriptorType;
481 __u16 bcdHID;
482 __u8 bCountryCode;
483 __u8 bNumDescriptors;
484
485 struct hid_class_descriptor desc[1];
486} __attribute__ ((packed));
487
488#ifdef DEBUG
489#include "hid-debug.h"
490#else
491#define hid_dump_input(a,b) do { } while (0)
492#define hid_dump_device(c) do { } while (0)
493#define hid_dump_field(a,b) do { } while (0)
494#define resolv_usage(a) do { } while (0)
495#define resolv_event(a,b) do { } while (0)
496#endif
497
498#endif
499
500#ifdef CONFIG_USB_HIDINPUT
501/* Applications from HID Usage Tables 4/8/99 Version 1.1 */
502/* We ignore a few input applications that are not widely used */
503#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001))
David Howells7d12e782006-10-05 14:55:46 +0100504extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
506extern int hidinput_connect(struct hid_device *);
507extern void hidinput_disconnect(struct hid_device *);
508#else
509#define IS_INPUT_APPLICATION(a) (0)
David Howells7d12e782006-10-05 14:55:46 +0100510static inline void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511static inline void hidinput_report_event(struct hid_device *hid, struct hid_report *report) { }
512static inline int hidinput_connect(struct hid_device *hid) { return -ENODEV; }
513static inline void hidinput_disconnect(struct hid_device *hid) { }
514#endif
515
516int hid_open(struct hid_device *);
517void hid_close(struct hid_device *);
518int hid_set_field(struct hid_field *, unsigned, __s32);
519void hid_submit_report(struct hid_device *, struct hid_report *, unsigned char dir);
520void hid_init_reports(struct hid_device *hid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521int hid_wait_io(struct hid_device* hid);
522
523
524#ifdef CONFIG_HID_FF
525int hid_ff_init(struct hid_device *hid);
Anssi Hannula224ee882006-07-19 01:40:47 -0400526
527int hid_lgff_init(struct hid_device *hid);
528int hid_tmff_init(struct hid_device *hid);
Anssi Hannulabb3caf72006-07-19 01:44:17 -0400529int hid_zpff_init(struct hid_device *hid);
Anssi Hannula224ee882006-07-19 01:40:47 -0400530#ifdef CONFIG_HID_PID
531int hid_pidff_init(struct hid_device *hid);
532#else
533static inline int hid_pidff_init(struct hid_device *hid) { return -ENODEV; }
534#endif
535
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536#else
537static inline int hid_ff_init(struct hid_device *hid) { return -1; }
538#endif
Anssi Hannula224ee882006-07-19 01:40:47 -0400539