d/wmr: consolidate interface getters

Moving them into one function makes it simpler to add more HMDs.
This commit is contained in:
Christoph Haag 2022-01-20 14:27:24 +01:00 committed by Jakob Bornecrantz
parent 09603144f9
commit 96c09e06e7

View file

@ -40,8 +40,10 @@ DEBUG_GET_ONCE_LOG_OPTION(wmr_log, "WMR_LOG", U_LOGGING_INFO)
*/ */
static bool static bool
check_and_get_interface_hp(struct xrt_prober_device *device, enum wmr_headset_type *out_hmd_type, int *out_interface) check_and_get_interface(struct xrt_prober_device *device, enum wmr_headset_type *out_hmd_type, int *out_interface)
{ {
switch (device->vendor_id) {
case HP_VID:
if (device->product_id != REVERB_G1_PID && device->product_id != REVERB_G2_PID) { if (device->product_id != REVERB_G1_PID && device->product_id != REVERB_G2_PID) {
return false; return false;
} }
@ -50,39 +52,30 @@ check_and_get_interface_hp(struct xrt_prober_device *device, enum wmr_headset_ty
*out_hmd_type = WMR_HEADSET_REVERB_G1; *out_hmd_type = WMR_HEADSET_REVERB_G1;
else else
*out_hmd_type = WMR_HEADSET_REVERB_G2; *out_hmd_type = WMR_HEADSET_REVERB_G2;
*out_interface = 0; *out_interface = 0;
return true; return true;
}
static bool case LENOVO_VID:
check_and_get_interface_lenovo(struct xrt_prober_device *device,
enum wmr_headset_type *out_hmd_type,
int *out_interface)
{
if (device->product_id != EXPLORER_PID) { if (device->product_id != EXPLORER_PID) {
return false; return false;
} }
*out_hmd_type = WMR_HEADSET_LENOVO_EXPLORER; *out_hmd_type = WMR_HEADSET_LENOVO_EXPLORER;
*out_interface = 0; *out_interface = 0;
return true; return true;
}
static bool case SAMSUNG_VID:
check_and_get_interface_samsung(struct xrt_prober_device *device,
enum wmr_headset_type *out_hmd_type,
int *out_interface)
{
if (device->product_id != ODYSSEY_PID) { if (device->product_id != ODYSSEY_PID) {
return false; return false;
} }
*out_hmd_type = WMR_HEADSET_SAMSUNG_800ZAA; *out_hmd_type = WMR_HEADSET_SAMSUNG_800ZAA;
*out_interface = 0; *out_interface = 0;
return true; return true;
default: return false;
}
} }
static bool static bool
@ -104,12 +97,7 @@ find_companion_device(struct xrt_prober *xp,
continue; continue;
} }
switch (devices[i]->vendor_id) { match = check_and_get_interface(devices[i], out_hmd_type, &interface);
case HP_VID: match = check_and_get_interface_hp(devices[i], out_hmd_type, &interface); break;
case LENOVO_VID: match = check_and_get_interface_lenovo(devices[i], out_hmd_type, &interface); break;
case SAMSUNG_VID: match = check_and_get_interface_samsung(devices[i], out_hmd_type, &interface); break;
default: break;
}
if (!match) { if (!match) {
continue; continue;