Skip to content

Commit 9b8e4ad

Browse files
Sandeep C SJiri Kosina
authored andcommitted
HID: samsung: Add Samsung wireless keyboard support
Add Support for samsung wireless keyboard with input mapping events. Device 7021 (Samsung wireless keyboard). Signed-off-by: Sandeep C S <[email protected]> Signed-off-by: Junwan Cho <[email protected]> Signed-off-by: Jitender Sajwan <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 6168f71 commit 9b8e4ad

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

drivers/hid/hid-ids.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,8 +1143,10 @@
11431143
#define USB_DEVICE_ID_SAITEK_X65 0x0b6a
11441144

11451145
#define USB_VENDOR_ID_SAMSUNG 0x0419
1146+
#define USB_VENDOR_ID_SAMSUNG_ELECTRONICS 0x04e8
11461147
#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
11471148
#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600
1149+
#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD 0x7021
11481150

11491151
#define USB_VENDOR_ID_SEMICO 0x1a2c
11501152
#define USB_DEVICE_ID_SEMICO_USB_KEYKOARD 0x0023

drivers/hid/hid-samsung.c

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,99 @@ static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
139139
return 1;
140140
}
141141

142+
static int samsung_kbd_input_mapping(struct hid_device *hdev,
143+
struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
144+
unsigned long **bit, int *max)
145+
{
146+
if (!(HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE) ||
147+
HID_UP_KEYBOARD == (usage->hid & HID_USAGE_PAGE)))
148+
return 0;
149+
150+
dbg_hid("samsung wireless keyboard input mapping event [0x%x]\n",
151+
usage->hid & HID_USAGE);
152+
153+
if (HID_UP_KEYBOARD == (usage->hid & HID_USAGE_PAGE)) {
154+
set_bit(EV_REP, hi->input->evbit);
155+
switch (usage->hid & HID_USAGE) {
156+
case 0x32:
157+
samsung_kbd_mouse_map_key_clear(KEY_BACKSLASH);
158+
break;
159+
case 0x64:
160+
samsung_kbd_mouse_map_key_clear(KEY_102ND);
161+
break;
162+
/* Only for BR keyboard */
163+
case 0x87:
164+
samsung_kbd_mouse_map_key_clear(KEY_RO);
165+
break;
166+
default:
167+
return 0;
168+
}
169+
}
170+
171+
if (HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE)) {
172+
switch (usage->hid & HID_USAGE) {
173+
/* report 2 */
174+
/* MENU */
175+
case 0x040:
176+
samsung_kbd_mouse_map_key_clear(KEY_MENU);
177+
break;
178+
case 0x18a:
179+
samsung_kbd_mouse_map_key_clear(KEY_MAIL);
180+
break;
181+
case 0x196:
182+
samsung_kbd_mouse_map_key_clear(KEY_WWW);
183+
break;
184+
case 0x19e:
185+
samsung_kbd_mouse_map_key_clear(KEY_SCREENLOCK);
186+
break;
187+
case 0x221:
188+
samsung_kbd_mouse_map_key_clear(KEY_SEARCH);
189+
break;
190+
case 0x223:
191+
samsung_kbd_mouse_map_key_clear(KEY_HOMEPAGE);
192+
break;
193+
/* Smtart Voice Key */
194+
case 0x300:
195+
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY13);
196+
break;
197+
/* RECENTAPPS */
198+
case 0x301:
199+
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY1);
200+
break;
201+
/* APPLICATION */
202+
case 0x302:
203+
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY2);
204+
break;
205+
/* Voice search */
206+
case 0x305:
207+
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY4);
208+
break;
209+
/* QPANEL on/off */
210+
case 0x306:
211+
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY5);
212+
break;
213+
/* SIP on/off */
214+
case 0x307:
215+
samsung_kbd_mouse_map_key_clear(BTN_TRIGGER_HAPPY3);
216+
break;
217+
/* LANG */
218+
case 0x308:
219+
samsung_kbd_mouse_map_key_clear(KEY_LANGUAGE);
220+
break;
221+
case 0x30a:
222+
samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSDOWN);
223+
break;
224+
case 0x30b:
225+
samsung_kbd_mouse_map_key_clear(KEY_BRIGHTNESSUP);
226+
break;
227+
default:
228+
return 0;
229+
}
230+
}
231+
232+
return 1;
233+
}
234+
142235
static __u8 *samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
143236
unsigned int *rsize)
144237
{
@@ -156,6 +249,9 @@ static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi,
156249
if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE && hid_is_usb(hdev))
157250
ret = samsung_kbd_mouse_input_mapping(hdev,
158251
hi, field, usage, bit, max);
252+
else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD)
253+
ret = samsung_kbd_input_mapping(hdev,
254+
hi, field, usage, bit, max);
159255

160256
return ret;
161257
}
@@ -198,6 +294,7 @@ static int samsung_probe(struct hid_device *hdev,
198294
static const struct hid_device_id samsung_devices[] = {
199295
{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
200296
{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
297+
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD) },
201298
{ }
202299
};
203300
MODULE_DEVICE_TABLE(hid, samsung_devices);

0 commit comments

Comments
 (0)