platform/chrome: cros_ec_lpc: Match on Framework ACPI device
Subsystems (8)
Sasha Levin
maintainerPATCH 1/24 platform/chrome: cros_ec_lpc: Match on Framework ACPI device
From: Daniel Schaefer <[email protected]>
[ Upstream commit d83c45aeec9b223fe6db4175e9d1c4f5699cc37a ]
Load the cros_ec_lpc driver based on a Framework FRMWC004 ACPI device, which mirrors GOOG0004, but also applies npcx quirks for Framework systems.
Matching on ACPI will let us avoid having to change the SMBIOS match rules again and again.
--- drivers/platform/chrome/cros_ec_lpc.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/platform/chrome/cros_ec_lpc.c +14 -8
@@ -30,6 +30,7 @@#define DRV_NAME "cros_ec_lpcs"#define ACPI_DRV_NAME "GOOG0004" +#define FRMW_ACPI_DRV_NAME "FRMWC004"/* True if ACPI device is present */ static bool cros_ec_lpc_acpi_device_found;
@@ -460,7 +461,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)acpi_status status;struct cros_ec_device *ec_dev;struct cros_ec_lpc *ec_lpc; -struct lpc_driver_data *driver_data; +const struct lpc_driver_data *driver_data;u8 buf[2 ] = {};int irq, ret;u32 quirks;
@@ -472,6 +473,9 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) ec_lpc->mmio_memory_base =EC_LPC_ADDR_MEMMAP ; driver_data =platform_get_drvdata (pdev); +if (!driver_data) + driver_data =acpi_device_get_match_data (dev); +if (driver_data) { quirks = driver_data->quirks;
@@ -625,12 +629,6 @@ static void cros_ec_lpc_remove(struct platform_device *pdev)cros_ec_unregister (ec_dev); } -static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = { - {ACPI_DRV_NAME ,0 }, - { } -}; -MODULE_DEVICE_TABLE (acpi, cros_ec_lpc_acpi_device_ids); -static const struct lpc_driver_data framework_laptop_npcx_lpc_driver_data__initconst = { .quirks =CROS_EC_LPC_QUIRK_REMAP_MEMORY , .quirk_mmio_memory_base =0xE00 ,
@@ -642,6 +640,13 @@ static const struct lpc_driver_data framework_laptop_mec_lpc_driver_data __initc .quirk_aml_mutex_name = "ECMT", }; +static const struct acpi_device_id cros_ec_lpc_acpi_device_ids[] = { + {ACPI_DRV_NAME ,0 }, + {FRMW_ACPI_DRV_NAME , (kernel_ulong_t)&framework_laptop_npcx_lpc_driver_data }, + { } +}; +MODULE_DEVICE_TABLE (acpi, cros_ec_lpc_acpi_device_ids); +static const struct dmi_system_id cros_ec_lpc_dmi_table[]__initconst = { {/*
@@ -795,7 +800,8 @@ static int __init cros_ec_lpc_init(void)int ret;const struct dmi_system_id *dmi_match; - cros_ec_lpc_acpi_device_found = !!cros_ec_lpc_get_device (ACPI_DRV_NAME ); + cros_ec_lpc_acpi_device_found = !!cros_ec_lpc_get_device (ACPI_DRV_NAME ) || + !!cros_ec_lpc_get_device (FRMW_ACPI_DRV_NAME ); dmi_match =dmi_first_match (cros_ec_lpc_dmi_table);
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 2/24 ASoC: SOF: topology: Use krealloc_array() to replace krealloc()
From: Zhang Heng <[email protected]>
[ Upstream commit a05143a8f713d9ae6abc41141dac52c66fca8b06 ]
Use krealloc_array() to replace krealloc() with multiplication. krealloc_array() has multiply overflow check, which will be safer.
--- sound/soc/sof/topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/topology.c +2 -2
@@ -1269,8 +1269,8 @@ static int sof_widget_parse_tokens(struct snd_soc_component *scomp, struct snd_sstruct snd_sof_tuple *new_tuples; num_tuples += token_list[object_token_list[i]].count * (num_sets -1 ); - new_tuples =krealloc (swidget->tuples, -sizeof (*new_tuples) * num_tuples,GFP_KERNEL ); + new_tuples =krealloc_array (swidget->tuples, + num_tuples,sizeof (*new_tuples),GFP_KERNEL );if (!new_tuples) { ret = -ENOMEM ; goto err;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 3/24 HID: pidff: Convert infinite length from Linux API to PID standard
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit 37e0591fe44dce39d1ebc7a82d5b6e4dba1582eb ]
Software uses 0 as de-facto infinite lenght on Linux FF apis (SDL), Linux doesn't actually define anythi as of now, while USB PID defines NULL (0xffff). Most PID devices do not expect a 0-length effect and can't interpret it as infinite. This change fixes Force Feedback for most PID compliant devices.
As most games depend on updating the values of already playing infinite effects, this is crucial to ensure they will actually work.
Previously, users had to rely on third-party software to do this conversion and make their PID devices usable.
--- drivers/hid/usbhid/hid-pidff.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/hid/usbhid/hid-pidff.c +7 -1
@@ -21,6 +21,7 @@#include "usbhid.h" #define PID_EFFECTS_MAX 64 +#define PID_INFINITE 0xffff/* Report usage table used to put reports into an array */
@@ -301,7 +302,12 @@ static void pidff_set_effect_report(struct pidff_device *pidff, pidff->block_load[PID_EFFECT_BLOCK_INDEX ].value[0 ]; pidff->set_effect_type->value[0 ] = pidff->create_new_effect_type->value[0 ]; - pidff->set_effect[PID_DURATION ].value[0 ] = effect->replay.length; + +/* Convert infinite length from Linux API (0) +to PID standard (NULL) if needed */ + pidff->set_effect[PID_DURATION ].value[0 ] = + effect->replay.length ==0 ?PID_INFINITE : effect->replay.length; + pidff->set_effect[PID_TRIGGER_BUTTON ].value[0 ] = effect->trigger.button; pidff->set_effect[PID_TRIGGER_REPEAT_INT ].value[0 ] = effect->trigger.interval;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 4/24 HID: pidff: Do not send effect envelope if it's empty
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit 8876fc1884f5b39550c8387ff3176396c988541d ]
Envelope struct is always initialized, but the envelope itself is optional as described in USB PID Device class definition 1.0.
5.1.1.1 Type Specific Block Offsets
...
4) Effects that do not use Condition Blocks use 1 Parameter Block and an *optional* Envelope Block.
Sending out "empty" envelope breaks force feedback on some devices with games that use SINE effect + offset to emulate constant force effect, as well as generally breaking Constant/Periodic effects. One of the affected brands is Moza Racing.
This change prevents the envelope from being sent if it contains all 0 values while keeping the old behavior of only sending it, if it differs from the old one.
Changes in v6:
- Simplify the checks to make them clearer
- Fix possible null pointer dereference while calling pidff_needs_set_envelope
--- drivers/hid/usbhid/hid-pidff.c | 42 +++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 18 deletions(-)
drivers/hid/usbhid/hid-pidff.c +24 -18
@@ -262,10 +262,22 @@ static void pidff_set_envelope_report(struct pidff_device *pidff,static int pidff_needs_set_envelope (struct ff_envelope *envelope,struct ff_envelope *old) { -return envelope->attack_level != old->attack_level || - envelope->fade_level != old->fade_level || +bool needs_new_envelope; + needs_new_envelope = envelope->attack_level !=0 || + envelope->fade_level !=0 || + envelope->attack_length !=0 || + envelope->fade_length !=0 ; + +if (!needs_new_envelope) +return false; + +if (!old) +return needs_new_envelope; + +return envelope->attack_level != old->attack_level || + envelope->fade_level != old->fade_level || envelope->attack_length != old->attack_length || - envelope->fade_length != old->fade_length; + envelope->fade_length != old->fade_length; }/*
@@ -580,11 +592,9 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,pidff_set_effect_report (pidff, effect);if (!old ||pidff_needs_set_constant (effect, old))pidff_set_constant_force_report (pidff, effect); -if (!old || -pidff_needs_set_envelope (&effect->u.constant.envelope, - &old->u.constant.envelope)) -pidff_set_envelope_report (pidff, - &effect->u.constant.envelope); +if (pidff_needs_set_envelope (&effect->u.constant.envelope, + old ? &old->u.constant.envelope :NULL )) +pidff_set_envelope_report (pidff, &effect->u.constant.envelope);break ;case FF_PERIODIC :
@@ -619,11 +629,9 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,pidff_set_effect_report (pidff, effect);if (!old ||pidff_needs_set_periodic (effect, old))pidff_set_periodic_report (pidff, effect); -if (!old || -pidff_needs_set_envelope (&effect->u.periodic.envelope, - &old->u.periodic.envelope)) -pidff_set_envelope_report (pidff, - &effect->u.periodic.envelope); +if (pidff_needs_set_envelope (&effect->u.periodic.envelope, + old ? &old->u.periodic.envelope :NULL )) +pidff_set_envelope_report (pidff, &effect->u.periodic.envelope);break ;case FF_RAMP :
@@ -637,11 +645,9 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,pidff_set_effect_report (pidff, effect);if (!old ||pidff_needs_set_ramp (effect, old))pidff_set_ramp_force_report (pidff, effect); -if (!old || -pidff_needs_set_envelope (&effect->u.ramp.envelope, - &old->u.ramp.envelope)) -pidff_set_envelope_report (pidff, - &effect->u.ramp.envelope); +if (pidff_needs_set_envelope (&effect->u.ramp.envelope, + old ? &old->u.ramp.envelope :NULL )) +pidff_set_envelope_report (pidff, &effect->u.ramp.envelope);break ;case FF_SPRING :
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 5/24 HID: pidff: Add MISSING_DELAY quirk and its detection
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit 2d5c7ce5bf4cc27db41632f357f682d0ee4518e7 ]
A lot of devices do not include this field, and it's seldom used in force feedback implementations. I tested about three dozen applications and none of them make use of the delay.
This fixes initialization of a lot of PID wheels like Cammus, VRS, FFBeast
This change has no effect on fully compliant devices
--- drivers/hid/usbhid/hid-pidff.c | 33 ++++++++++++++++++++++++++++----- include/linux/hid.h | 3 +++ 2 files changed, 31 insertions(+), 5 deletions(-)
drivers/hid/usbhid/hid-pidff.c +28 -5
@@ -185,6 +185,8 @@ struct pidff_device {int operation_id[sizeof (pidff_effect_operation_status)];int pid_id[PID_EFFECTS_MAX ]; + +u32 quirks; };/*
@@ -329,7 +331,10 @@ static void pidff_set_effect_report(struct pidff_device *pidff, pidff->effect_direction->value[0 ] =pidff_rescale (effect->direction,0xffff , pidff->effect_direction); - pidff->set_effect[PID_START_DELAY ].value[0 ] = effect->replay.delay; + +/* Omit setting delay field if it's missing */ +if (!(pidff->quirks &HID_PIDFF_QUIRK_MISSING_DELAY )) + pidff->set_effect[PID_START_DELAY ].value[0 ] = effect->replay.delay;hid_hw_request (pidff->hid, pidff->reports[PID_SET_EFFECT ],HID_REQ_SET_REPORT );
@@ -748,7 +753,10 @@ static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude) pidff->set_effect[PID_TRIGGER_REPEAT_INT ].value[0 ] =0 ;pidff_set (&pidff->set_effect[PID_GAIN ], magnitude); pidff->set_effect[PID_DIRECTION_ENABLE ].value[0 ] =1 ; - pidff->set_effect[PID_START_DELAY ].value[0 ] =0 ; + +/* Omit setting delay field if it's missing */ +if (!(pidff->quirks &HID_PIDFF_QUIRK_MISSING_DELAY )) + pidff->set_effect[PID_START_DELAY ].value[0 ] =0 ;hid_hw_request (pidff->hid, pidff->reports[PID_SET_EFFECT ],HID_REQ_SET_REPORT );
@@ -771,6 +779,7 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table, struct hid_report *report, int count, int strict) { int i, j, k, found; +int return_value =0 ;for (k =0 ; k < count; k++) { found =0 ;
@@ -795,12 +804,17 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,if (found)break ; } -if (!found && strict) { +if (!found && table[k] == pidff_set_effect[PID_START_DELAY ]) { +pr_debug ("Delay field not found, but that's OK\n" ); +pr_debug ("Setting MISSING_DELAY quirk\n" ); + return_value |=HID_PIDFF_QUIRK_MISSING_DELAY ; + } +else if (!found && strict) {pr_debug ("failed to locate %d\n" , k);return -1 ; } } -return 0 ; +return return_value; }/*
@@ -1075,11 +1089,19 @@ static int pidff_find_effects(struct pidff_device *pidff,static int pidff_init_fields (struct pidff_device *pidff,struct input_dev *dev) {int envelope_ok =0 ; +int status =0 ; -if (PIDFF_FIND_FIELDS (set_effect,PID_SET_EFFECT ,1 )) { +/* Save info about the device not having the DELAY ffb field. */ + status =PIDFF_FIND_FIELDS (set_effect,PID_SET_EFFECT ,1 ); +if (status ==-1 ) {hid_err (pidff->hid,"unknown set_effect report layout\n" );return -ENODEV ; } + pidff->quirks |= status; + +if (status &HID_PIDFF_QUIRK_MISSING_DELAY ) +hid_dbg (pidff->hid,"Adding MISSING_DELAY quirk\n" ); +PIDFF_FIND_FIELDS (block_load,PID_BLOCK_LOAD ,0 );if (!pidff->block_load[PID_EFFECT_BLOCK_INDEX ].value) {
@@ -1323,6 +1345,7 @@ int hid_pidff_init(struct hid_device *hid) ff->playback = pidff_playback;hid_info (dev,"Force feedback for USB HID PID devices by Anssi Hannula <[email protected]>\n" ); +hid_dbg (dev,"Active quirks mask: 0x%x\n" , pidff->quirks);hid_device_io_stop (hid);
include/linux/hid.h +3 -0
@@ -1228,6 +1228,9 @@ int hid_pidff_init(struct hid_device *hid);#define hid_pidff_init NULL#endif +/* HID PIDFF quirks */ +#define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0) +#define dbg_hid (fmt, ...) pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__)#define hid_err (hid, fmt, ...) \
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 6/24 HID: pidff: Add MISSING_PBO quirk and its detection
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit fc7c154e9bb3c2b98875cfc565406f4787e3b7a4 ]
Some devices with only one axis are missing PARAMETER_BLOCK_OFFSET field for conditional effects. They can only have one axis, so we're limiting the max_axis when setting the report for those effects.
Automatic detection ensures compatibility even if such device won't be explicitly defined in the kernel.
Fixes initialization of VRS DirectForce PRO and possibly other devices.
Changes in v6:
- Fixed NULL pointer dereference. When PBO is missing, make sure not to set it anyway
--- drivers/hid/usbhid/hid-pidff.c | 47 +++++++++++++++++++++------------- include/linux/hid.h | 1 + 2 files changed, 30 insertions(+), 18 deletions(-)
drivers/hid/usbhid/hid-pidff.c +29 -18
@@ -391,13 +391,19 @@ static int pidff_needs_set_periodic(struct ff_effect *effect,static void pidff_set_condition_report (struct pidff_device *pidff,struct ff_effect *effect) { -int i; +int i, max_axis; + +/* Devices missing Parameter Block Offset can only have one axis */ + max_axis = pidff->quirks &HID_PIDFF_QUIRK_MISSING_PBO ?1 :2 ; pidff->set_condition[PID_EFFECT_BLOCK_INDEX ].value[0 ] = pidff->block_load[PID_EFFECT_BLOCK_INDEX ].value[0 ]; -for (i =0 ; i <2 ; i++) { - pidff->set_condition[PID_PARAM_BLOCK_OFFSET ].value[0 ] = i; +for (i =0 ; i < max_axis; i++) { +/* Omit Parameter Block Offset if missing */ +if (!(pidff->quirks &HID_PIDFF_QUIRK_MISSING_PBO )) + pidff->set_condition[PID_PARAM_BLOCK_OFFSET ].value[0 ] = i; +pidff_set_signed (&pidff->set_condition[PID_CP_OFFSET ], effect->u.condition[i].center); pidff_set_signed(&pidff->set_condition[PID_POS_COEFFICIENT],
@@ -809,6 +815,11 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,pr_debug ("Setting MISSING_DELAY quirk\n" ); return_value |=HID_PIDFF_QUIRK_MISSING_DELAY ; } +else if (!found && table[k] == pidff_set_condition[PID_PARAM_BLOCK_OFFSET ]) { +pr_debug ("PBO field not found, but that's OK\n" ); +pr_debug ("Setting MISSING_PBO quirk\n" ); + return_value |=HID_PIDFF_QUIRK_MISSING_PBO ; + }else if (!found && strict) {pr_debug ("failed to locate %d\n" , k);return -1 ;
@@ -1088,7 +1099,6 @@ static int pidff_find_effects(struct pidff_device *pidff,*/ static int pidff_init_fields (struct pidff_device *pidff,struct input_dev *dev) { -int envelope_ok =0 ;int status =0 ;/* Save info about the device not having the DELAY ffb field. */
@@ -1119,13 +1129,10 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev)return -ENODEV ; } -if (!PIDFF_FIND_FIELDS (set_envelope,PID_SET_ENVELOPE ,1 )) - envelope_ok =1 ; -if (pidff_find_special_fields (pidff) ||pidff_find_effects (pidff, dev))return -ENODEV ; -if (!envelope_ok) { +if (PIDFF_FIND_FIELDS (set_envelope,PID_SET_ENVELOPE ,1 )) {if (test_and_clear_bit (FF_CONSTANT , dev->ffbit))hid_warn (pidff->hid,"has constant effect but no envelope\n" );
@@ -1150,16 +1157,20 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev)clear_bit (FF_RAMP , dev->ffbit); } -if ((test_bit (FF_SPRING , dev->ffbit) || -test_bit (FF_DAMPER , dev->ffbit) || -test_bit (FF_FRICTION , dev->ffbit) || -test_bit (FF_INERTIA , dev->ffbit)) && -PIDFF_FIND_FIELDS (set_condition,PID_SET_CONDITION ,1 )) { -hid_warn (pidff->hid,"unknown condition effect layout\n" ); -clear_bit (FF_SPRING , dev->ffbit); -clear_bit (FF_DAMPER , dev->ffbit); -clear_bit (FF_FRICTION , dev->ffbit); -clear_bit (FF_INERTIA , dev->ffbit); +if (test_bit (FF_SPRING , dev->ffbit) || +test_bit (FF_DAMPER , dev->ffbit) || +test_bit (FF_FRICTION , dev->ffbit) || +test_bit (FF_INERTIA , dev->ffbit)) { + status =PIDFF_FIND_FIELDS (set_condition,PID_SET_CONDITION ,1 ); + +if (status <0 ) { +hid_warn (pidff->hid,"unknown condition effect layout\n" ); +clear_bit (FF_SPRING , dev->ffbit); +clear_bit (FF_DAMPER , dev->ffbit); +clear_bit (FF_FRICTION , dev->ffbit); +clear_bit (FF_INERTIA , dev->ffbit); + } + pidff->quirks |= status; } if (test_bit(FF_PERIODIC, dev->ffbit) &&
include/linux/hid.h +1 -0
@@ -1230,6 +1230,7 @@ int hid_pidff_init(struct hid_device *hid);/* HID PIDFF quirks */ #define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0) +#define HID_PIDFF_QUIRK_MISSING_PBO BIT(1)#define dbg_hid (fmt, ...) pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 7/24 HID: pidff: Add PERMISSIVE_CONTROL quirk
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit a4119108d2530747e61c7cbf52e2affd089cb1f6 ]
With this quirk, a PID device isn't required to have a strict logical_minimum of 1 for the the PID_DEVICE_CONTROL usage page.
Some devices come with weird values in their device descriptors and this quirk enables their initialization even if the logical minimum of the DEVICE_CONTROL page is not 1.
Fixes initialization of VRS Direct Force Pro
Changes in v6:
- Change quirk name to better reflect it's intention
--- drivers/hid/usbhid/hid-pidff.c | 3 ++- include/linux/hid.h | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/hid/usbhid/hid-pidff.c +2 -1
@@ -969,7 +969,8 @@ static int pidff_find_special_fields(struct pidff_device *pidff) 0x57, 0); pidff->device_control =pidff_find_special_field (pidff->reports[PID_DEVICE_CONTROL ], -0x96 ,1 ); +0x96 , !(pidff->quirks &HID_PIDFF_QUIRK_PERMISSIVE_CONTROL )); + pidff->block_load_status =pidff_find_special_field (pidff->reports[PID_BLOCK_LOAD ],0x8b ,1 );
include/linux/hid.h +3 -2
@@ -1229,8 +1229,9 @@ int hid_pidff_init(struct hid_device *hid);#endif /* HID PIDFF quirks */ -#define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0) -#define HID_PIDFF_QUIRK_MISSING_PBO BIT(1) +#define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0) +#define HID_PIDFF_QUIRK_MISSING_PBO BIT(1) +#define HID_PIDFF_QUIRK_PERMISSIVE_CONTROL BIT(2)#define dbg_hid (fmt, ...) pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 8/24 HID: pidff: Add hid_pidff_init_with_quirks and export as GPL symbol
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit 36de0164bbaff1484288e84ac5df5cff00580263 ]
This lays out a way to provide an initial set of quirks to enable before device initialization takes place. GPL symbol export needed for the possibility of building HID drivers which use this function as modules.
Adding a wrapper function to ensure compatibility with the old behavior of hid_pidff_init.
--- drivers/hid/usbhid/hid-pidff.c | 15 ++++++++++++++- include/linux/hid.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-)
drivers/hid/usbhid/hid-pidff.c +14 -1
@@ -1268,8 +1268,9 @@ static int pidff_check_autocenter(struct pidff_device *pidff,/* * Check if the device is PID and initialize it +* Set initial quirks */ -int hid_pidff_init (struct hid_device *hid) +int hid_pidff_init_with_quirks (struct hid_device *hid,__u32 initial_quirks) {struct pidff_device *pidff; struct hid_input *hidinput = list_entry(hid->inputs.next,
@@ -1291,6 +1292,7 @@ int hid_pidff_init(struct hid_device *hid)return -ENOMEM ; pidff->hid = hid; + pidff->quirks = initial_quirks;hid_device_io_start (hid);
@@ -1369,3 +1371,14 @@ int hid_pidff_init(struct hid_device *hid)kfree (pidff);return error; } +EXPORT_SYMBOL_GPL (hid_pidff_init_with_quirks); + +/* +* Check if the device is PID and initialize it +* Wrapper made to keep the compatibility with old +* init function +*/ +int hid_pidff_init (struct hid_device *hid) +{ +return hid_pidff_init_with_quirks (hid,0 ); +}
include/linux/hid.h +2 -0
@@ -1224,8 +1224,10 @@ void hid_quirks_exit(__u16 bus);#ifdef CONFIG_HID_PID int hid_pidff_init (struct hid_device *hid); +int hid_pidff_init_with_quirks (struct hid_device *hid,__u32 initial_quirks);#else #define hid_pidff_init NULL +#define hid_pidff_init_with_quirks NULL#endif /* HID PIDFF quirks */
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 9/24 HID: pidff: Add FIX_WHEEL_DIRECTION quirk
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit 3051bf5ec773b803c474ea556b57d678a8885be3 ]
Most steering wheels simply ignore DIRECTION field, but some try to be compliant with the PID standard and use it in force calculations. Games often ignore setting this field properly and/or there can be issues with dinput8 -> wine -> SDL -> Linux API translation, and this value can be incorrect. This can lead to partial/complete loss of Force Feedback or even unexpected force reversal.
Sadly, this quirk can't be detected automatically without sending out effects that would move an axis.
This fixes FFB on Moza Racing devices and others where effect direction is not simply ignored.
--- drivers/hid/usbhid/hid-pidff.c | 12 +++++++++--- include/linux/hid.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/hid/usbhid/hid-pidff.c +9 -3
@@ -137,6 +137,9 @@ static const u8 pidff_block_load_status[] = { 0x8c, 0x8d };#define PID_EFFECT_STOP 1static const u8 pidff_effect_operation_status[] = {0x79 ,0x7b }; +/* Polar direction 90 degrees (North) */ +#define PIDFF_FIXED_WHEEL_DIRECTION 0x4000 +struct pidff_usage {struct hid_field *field;s32 *value;
@@ -328,9 +331,12 @@ static void pidff_set_effect_report(struct pidff_device *pidff, pidff->set_effect[PID_GAIN ].value[0 ] = pidff->set_effect[PID_GAIN ].field->logical_maximum; pidff->set_effect[PID_DIRECTION_ENABLE ].value[0 ] =1 ; - pidff->effect_direction->value[0 ] = -pidff_rescale (effect->direction,0xffff , - pidff->effect_direction); + +/* Use fixed direction if needed */ + pidff->effect_direction->value[0 ] =pidff_rescale ( + pidff->quirks &HID_PIDFF_QUIRK_FIX_WHEEL_DIRECTION ? +PIDFF_FIXED_WHEEL_DIRECTION : effect->direction, +0xffff , pidff->effect_direction);/* Omit setting delay field if it's missing */ if (!(pidff->quirks &HID_PIDFF_QUIRK_MISSING_DELAY ))
include/linux/hid.h +1 -0
@@ -1234,6 +1234,7 @@ int hid_pidff_init_with_quirks(struct hid_device *hid, __u32 initial_quirks);#define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0)#define HID_PIDFF_QUIRK_MISSING_PBO BIT(1)#define HID_PIDFF_QUIRK_PERMISSIVE_CONTROL BIT(2) +#define HID_PIDFF_QUIRK_FIX_WHEEL_DIRECTION BIT(3)#define dbg_hid (fmt, ...) pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 10/24 HID: Add hid-universal-pidff driver and supported device ids
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit f06bf8d94fffbb544b1cb5402c92e0a075f0d420 ]
Extend pidff compatibility, usable button range, manage pidff quirks and set improved fuzz/flat default for high precision devices. Possibility of fixing device descriptors in the future if such needs arises.
As many of PID devices are quite similar and not dependent on custom drivers, this one can handle all of PID devices which need special care.
Numerous sim racing/sim flight bases report a lot of buttons in excess of 100. Moza Racing exposes 128 of them and thus the need to extend the available range.
All the included devices were tested and confirmed working with the help of the sim racing community.
Changes in v6:
- Support "split" devices with a separate "input device" for buttons
- Fixed comment styling
--- drivers/hid/Kconfig | 14 +++ drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 31 +++++ drivers/hid/hid-universal-pidff.c | 192 ++++++++++++++++++++++++++++++ 4 files changed, 238 insertions(+) create mode 100644 drivers/hid/hid-universal-pidff.c
drivers/hid/Kconfig +14 -0
@@ -1218,6 +1218,20 @@ config HID_U2FZERO allow setting the brightness to anything but 1, which will trigger a single blink and immediately reset back to 0. +config HID_UNIVERSAL_PIDFF + tristate "universal-pidff: extended USB PID driver compatibility and usage" + depends on USB_HID + depends on HID_PID + help + Extended PID support for selected devices. + + Contains report fixups, extended usable button range and + pidff quirk management to extend compatibility with slightly + non-compliant USB PID devices and better fuzz/flat values for + high precision direct drive devices. + + Supports Moza Racing, Cammus, VRS, FFBeast and more. + config HID_WACOM tristate "Wacom Intuos/Graphire tablet support (USB)" depends on USB_HID
drivers/hid/Makefile +1 -0
@@ -140,6 +140,7 @@ hid-uclogic-objs := hid-uclogic-core.o \ hid-uclogic-params.o obj-$(CONFIG_HID_UCLOGIC) += hid-uclogic.o obj-$(CONFIG_HID_UDRAW_PS3) += hid-udraw-ps3.o +obj-$(CONFIG_HID_UNIVERSAL_PIDFF) += hid-universal-pidff.o obj-$(CONFIG_HID_LED) += hid-led.o obj-$(CONFIG_HID_XIAOMI) += hid-xiaomi.o obj-$(CONFIG_HID_XINMO) += hid-xinmo.o
drivers/hid/hid-ids.h +31 -0
@@ -262,6 +262,10 @@#define USB_DEVICE_ID_BTC_EMPREX_REMOTE 0x5578#define USB_DEVICE_ID_BTC_EMPREX_REMOTE_2 0x5577 +#define USB_VENDOR_ID_CAMMUS 0x3416 +#define USB_DEVICE_ID_CAMMUS_C5 0x0301 +#define USB_DEVICE_ID_CAMMUS_C12 0x0302 +#define USB_VENDOR_ID_CANDO 0x2087#define USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH 0x0703#define USB_DEVICE_ID_CANDO_MULTI_TOUCH 0x0a01
@@ -453,6 +457,11 @@#define USB_VENDOR_ID_EVISION 0x320f#define USB_DEVICE_ID_EVISION_ICL01 0x5041 +#define USB_VENDOR_ID_FFBEAST 0x045b +#define USB_DEVICE_ID_FFBEAST_JOYSTICK 0x58f9 +#define USB_DEVICE_ID_FFBEAST_RUDDER 0x5968 +#define USB_DEVICE_ID_FFBEAST_WHEEL 0x59d7 +#define USB_VENDOR_ID_FLATFROG 0x25b5#define USB_DEVICE_ID_MULTITOUCH_3200 0x0002
@@ -817,6 +826,13 @@#define I2C_DEVICE_ID_LG_8001 0x8001#define I2C_DEVICE_ID_LG_7010 0x7010 +#define USB_VENDOR_ID_LITE_STAR 0x11ff +#define USB_DEVICE_ID_PXN_V10 0x3245 +#define USB_DEVICE_ID_PXN_V12 0x1212 +#define USB_DEVICE_ID_PXN_V12_LITE 0x1112 +#define USB_DEVICE_ID_PXN_V12_LITE_2 0x1211 +#define USB_DEVICE_LITE_STAR_GT987_FF 0x2141 +#define USB_VENDOR_ID_LOGITECH 0x046d#define USB_DEVICE_ID_LOGITECH_Z_10_SPK 0x0a07#define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e
@@ -964,6 +980,18 @@#define USB_VENDOR_ID_MONTEREY 0x0566#define USB_DEVICE_ID_GENIUS_KB29E 0x3004 +#define USB_VENDOR_ID_MOZA 0x346e +#define USB_DEVICE_ID_MOZA_R3 0x0005 +#define USB_DEVICE_ID_MOZA_R3_2 0x0015 +#define USB_DEVICE_ID_MOZA_R5 0x0004 +#define USB_DEVICE_ID_MOZA_R5_2 0x0014 +#define USB_DEVICE_ID_MOZA_R9 0x0002 +#define USB_DEVICE_ID_MOZA_R9_2 0x0012 +#define USB_DEVICE_ID_MOZA_R12 0x0006 +#define USB_DEVICE_ID_MOZA_R12_2 0x0016 +#define USB_DEVICE_ID_MOZA_R16_R21 0x0000 +#define USB_DEVICE_ID_MOZA_R16_R21_2 0x0010 +#define USB_VENDOR_ID_MSI 0x1770#define USB_DEVICE_ID_MSI_GT683R_LED_PANEL 0xff00
@@ -1375,6 +1403,9 @@#define USB_DEVICE_ID_VELLEMAN_K8061_FIRST 0x8061#define USB_DEVICE_ID_VELLEMAN_K8061_LAST 0x8068 +#define USB_VENDOR_ID_VRS 0x0483 +#define USB_DEVICE_ID_VRS_DFP 0xa355 +#define USB_VENDOR_ID_VTL 0x0306#define USB_DEVICE_ID_VTL_MULTITOUCH_FF3F 0xff3f
drivers/hid/hid-universal-pidff.c new file +192 -0
192 lines not on this page · raw message
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 11/24 HID: pidff: Add PERIODIC_SINE_ONLY quirk
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit abdbf8764f4962af2a910abb3a213ecf304a73d3 ]
Some devices only support SINE periodic effect although they advertise support for all PERIODIC effect in their HID descriptor. Some just do nothing when trying to play such an effect (upload goes fine), some express undefined behavior like turning to one side.
This quirk forces all the periodic effects to be uploaded as SINE. This is acceptable as all these effects are similar in nature and are mostly used as rumble. SINE is the most popular with others seldom used (especially SAW_UP and SAW_DOWN).
Fixes periodic effects for PXN and LITE STAR wheels
--- drivers/hid/hid-universal-pidff.c | 15 ++++++++++----- drivers/hid/usbhid/hid-pidff.c | 3 +++ include/linux/hid.h | 1 + 3 files changed, 14 insertions(+), 5 deletions(-)
drivers/hid/hid-universal-pidff.c +10 -5
@@ -168,11 +168,16 @@ static const struct hid_device_id universal_pidff_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_FFBEAST, USB_DEVICE_ID_FFBEAST_JOYSTICK), }, { HID_USB_DEVICE(USB_VENDOR_ID_FFBEAST, USB_DEVICE_ID_FFBEAST_RUDDER), }, { HID_USB_DEVICE(USB_VENDOR_ID_FFBEAST, USB_DEVICE_ID_FFBEAST_WHEEL) }, - { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_PXN_V10) }, - { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_PXN_V12) }, - { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_PXN_V12_LITE) }, - { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_PXN_V12_LITE_2) }, - { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_LITE_STAR_GT987_FF) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_PXN_V10), + .driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY }, + { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_PXN_V12), + .driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY }, + { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_PXN_V12_LITE), + .driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY }, + { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_PXN_V12_LITE_2), + .driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY }, + { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_LITE_STAR_GT987_FF), + .driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY }, { } };MODULE_DEVICE_TABLE (hid, universal_pidff_devices);
drivers/hid/usbhid/hid-pidff.c +3 -0
@@ -637,6 +637,9 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,return -EINVAL ; } +if (pidff->quirks &HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY ) + type_id =PID_SINE ; + error =pidff_request_effect_upload (pidff, pidff->type_id[type_id]);if (error)
include/linux/hid.h +1 -0
@@ -1235,6 +1235,7 @@ int hid_pidff_init_with_quirks(struct hid_device *hid, __u32 initial_quirks);#define HID_PIDFF_QUIRK_MISSING_PBO BIT(1)#define HID_PIDFF_QUIRK_PERMISSIVE_CONTROL BIT(2)#define HID_PIDFF_QUIRK_FIX_WHEEL_DIRECTION BIT(3) +#define HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY BIT(4)#define dbg_hid (fmt, ...) pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 12/24 HID: pidff: Fix null pointer dereference in pidff_find_fields
In reply to Sasha LevinFrom: Tomasz Pakuła <[email protected]>
[ Upstream commit 22a05462c3d0eee15154faf8d13c49e6295270a5 ]
This function triggered a null pointer dereference if used to search for a report that isn't implemented on the device. This happened both for optional and required reports alike.
The same logic was applied to pidff_find_special_field and although pidff_init_fields should return an error earlier if one of the required reports is missing, future modifications could change this logic and resurface this possible null pointer dereference again.
LKML bug report:
https://lore.kernel.org/all/CAL-gK7f5=R0nrrQdPtaZZr1fd-cdAMbDMuZ_NLA8vM0SX+nGSw@mail.gmail.com
--- drivers/hid/usbhid/hid-pidff.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/hid/usbhid/hid-pidff.c +10 -0
@@ -793,6 +793,11 @@ static void pidff_set_autocenter(struct input_dev *dev, u16 magnitude)static int pidff_find_fields (struct pidff_usage *usage,const u8 *table,struct hid_report *report,int count,int strict) { +if (!report) { +pr_debug ("pidff_find_fields, null report\n" ); +return -1 ; + } +int i, j, k, found;int return_value =0 ;
@@ -917,6 +922,11 @@ static int pidff_reports_ok(struct pidff_device *pidff)static struct hid_field *pidff_find_special_field (struct hid_report *report,int usage,int enforce_min) { +if (!report) { +pr_debug ("pidff_find_special_field, null report\n" ); +return NULL ; + } +int i;for (i =0 ; i < report->maxfield; i++) {
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 13/24 ASoC: amd: ps: use macro for ACP6.3 pci revision id
In reply to Sasha LevinFrom: Vijendar Mukunda <[email protected]>
[ Upstream commit 4b36a47e2d989b98953dbfb1e97da0f0169f5086 ]
Use macro for ACP6.3 PCI revision id instead of hard coded value.
--- sound/soc/amd/ps/acp63.h | 1 + sound/soc/amd/ps/pci-ps.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
sound/soc/amd/ps/acp63.h +1 -0
@@ -11,6 +11,7 @@#define ACP_DEVICE_ID 0x15E2#define ACP63_REG_START 0x1240000#define ACP63_REG_END 0x125C000 +#define ACP63_PCI_REV 0x63#define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001#define ACP_PGFSM_CNTL_POWER_ON_MASK 1
sound/soc/amd/ps/pci-ps.c +1 -1
@@ -559,7 +559,7 @@ static int snd_acp63_probe(struct pci_dev *pci,/* Pink Sardine device check */ switch (pci->revision) { -case 0x63 : +case ACP63_PCI_REV :break ;default :dev_dbg (&pci->dev,"acp63 pci device not found\n" );
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 14/24 ASoC: amd: amd_sdw: Add quirks for Dell SKU's
In reply to Sasha LevinFrom: Vijendar Mukunda <[email protected]>
[ Upstream commit 4bb5b6f13fd83b32c8a93fbd399e7558415d1ce0 ]
This patch adds a quirk to include the codec amplifier function for Dell SKU's listed in quirk table.
Note: In these SKU's, the RT722 codec amplifier is excluded, and an external amplifier is used instead.
--- sound/soc/amd/acp/acp-sdw-legacy-mach.c | 34 +++++++++++++++++++++++++ sound/soc/amd/acp/soc_amd_sdw_common.h | 1 + 2 files changed, 35 insertions(+)
sound/soc/amd/acp/acp-sdw-legacy-mach.c +34 -0
@@ -28,6 +28,8 @@ static void log_quirks(struct device *dev) SOC_JACK_JDSRC(soc_sdw_quirk));if (soc_sdw_quirk &ASOC_SDW_ACP_DMIC )dev_dbg (dev,"quirk SOC_SDW_ACP_DMIC enabled\n" ); +if (soc_sdw_quirk &ASOC_SDW_CODEC_SPKR ) +dev_dbg (dev,"quirk ASOC_SDW_CODEC_SPKR enabled\n" ); }static int soc_sdw_quirk_cb (const struct dmi_system_id *id)
@@ -45,6 +47,38 @@ static const struct dmi_system_id soc_sdw_quirk_table[] = { }, .driver_data = (void *)RT711_JD2, }, + { + .callback = soc_sdw_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), + DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0D80"), + }, + .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), + }, + { + .callback = soc_sdw_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), + DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0D81"), + }, + .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), + }, + { + .callback = soc_sdw_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), + DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0D82"), + }, + .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), + }, + { + .callback = soc_sdw_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), + DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0D83"), + }, + .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), + }, {} };
sound/soc/amd/acp/soc_amd_sdw_common.h +1 -0
@@ -22,6 +22,7 @@#define SOC_JACK_JDSRC (quirk) ((quirk) & GENMASK(3, 0))#define ASOC_SDW_FOUR_SPK BIT(4)#define ASOC_SDW_ACP_DMIC BIT(5) +#define ASOC_SDW_CODEC_SPKR BIT(15)#define AMD_SDW0 0#define AMD_SDW1 1
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 15/24 ALSA: hda: intel: Fix Optimus when GPU has no sound
In reply to Sasha LevinFrom: Maxim Mikityanskiy <[email protected]>
[ Upstream commit 2b360ba9a4936486380bc30d1eabceb40a714d98 ]
quirk_nvidia_hda() forcefully enables HDA controller on all NVIDIA GPUs, because some buggy BIOSes leave it disabled. However, some dual-GPU laptops do not have a functional HDA controller in DGPU, and BIOS disables it on purpose. After quirk_nvidia_hda() reenables this dummy HDA controller, attempting to probe it fails at azx_first_init(), which is too late to cancel the probe, as it happens in azx_probe_continue().
The sna_hda_intel driver calls azx_free() and stops the chip, however, it stays probed, and from the runtime PM point of view, the device remains active (it was set as active by the PCI subsystem on probe). It prevents vga_switcheroo from turning off the DGPU, because pci_create_device_link() syncs power management for video and audio devices.
Affected devices should be added to driver_denylist to prevent them from probing early. This patch helps identify such devices by printing a warning, and also forces the device to the suspended state to allow vga_switcheroo turn off DGPU.
--- sound/pci/hda/hda_intel.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
sound/pci/hda/hda_intel.c +14 -1
@@ -1352,8 +1352,21 @@ static void azx_free(struct azx *chip)if (use_vga_switcheroo (hda)) {if (chip->disabled && hda->probe_continued)snd_hda_unlock_devices (&chip->bus); -if (hda->vga_switcheroo_registered) +if (hda->vga_switcheroo_registered) {vga_switcheroo_unregister_client (chip->pci); + +/* Some GPUs don't have sound, and azx_first_init fails, +* leaving the device probed but non-functional. As long +* as it's probed, the PCI subsystem keeps its runtime +* PM status as active. Force it to suspended (as we +* actually stop the chip) to allow GPU to suspend via +* vga_switcheroo, and print a warning. +*/ +dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" ); +pm_runtime_disable (&pci->dev); +pm_runtime_set_suspended (&pci->dev); +pm_runtime_enable (&pci->dev); + } }if (bus->chip_init) {
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 16/24 ALSA: hda: intel: Add Lenovo IdeaPad Z570 to probe denylist
In reply to Sasha LevinFrom: Maxim Mikityanskiy <[email protected]>
[ Upstream commit becc794c5e46f4dfca59f2385f78d83fc9e84700 ]
Lenovo IdeaPad Z570 with NVIDIA GeForce Ge 540M doesn't have sound on the discrete GPU. The HDA controller in DGPU is disabled by BIOS, but then reenabled by quirk_nvidia_hda(). The probe fails and ends up with the "GPU sound probed, but not operational" error.
Add this laptop to DMI-based denylist to prevent probe early. DMI is used, because the audio device has zero subsystem IDs, and this entry would be too much, blocking all 540M chips:
PCI_DEVICE_SUB(0x10de, 0x0bea, 0x0000, 0x0000)
Also, this laptop comes in a variety of modifications with different NVIDIA GPUs, so the DMI check will cover them all.
--- sound/pci/hda/hda_intel.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
sound/pci/hda/hda_intel.c +29 -0
@@ -37,6 +37,7 @@#include <linux/completion.h> #include <linux/acpi.h> #include <linux/pgtable.h> +#include <linux/dmi.h> #ifdef CONFIG_X86 /* for snoop control */
@@ -2074,6 +2075,27 @@ static const struct pci_device_id driver_denylist[] = { {} }; +static struct pci_device_id driver_denylist_ideapad_z570[] = { + {PCI_DEVICE_SUB (0x10de ,0x0bea ,0x0000 ,0x0000 ) },/* NVIDIA GF108 HDA */ + {} +}; + +/* DMI-based denylist, to be used when: +* - PCI subsystem IDs are zero, impossible to distinguish from valid sound cards. +* - Different modifications of the same laptop use different GPU models. +*/ +static const struct dmi_system_id driver_denylist_dmi[] = { + { +/* No HDA in NVIDIA DGPU. BIOS disables it, but quirk_nvidia_hda() reenables. */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), +DMI_MATCH (DMI_PRODUCT_VERSION ,"Ideapad Z570" ), + }, + .driver_data = &driver_denylist_ideapad_z570, + }, + {} +}; +static const struct hda_controller_ops pci_hda_ops = { .disable_msi_reset_irq = disable_msi_reset_irq, .position_check = azx_position_check,
@@ -2084,6 +2106,7 @@ static DECLARE_BITMAP(probed_devs, SNDRV_CARDS);static int azx_probe (struct pci_dev *pci,const struct pci_device_id *pci_id) { +const struct dmi_system_id *dmi;struct snd_card *card;struct hda_intel *hda;struct azx *chip;
@@ -2096,6 +2119,12 @@ static int azx_probe(struct pci_dev *pci,return -ENODEV ; } + dmi =dmi_first_match (driver_denylist_dmi); +if (dmi &&pci_match_id (dmi->driver_data, pci)) { +dev_info (&pci->dev,"Skipping the device on the DMI denylist\n" ); +return -ENODEV ; + } + dev =find_first_zero_bit (probed_devs,SNDRV_CARDS );if (dev >=SNDRV_CARDS )return -ENODEV ;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 17/24 ASoC: fsl_audmix: register card device depends on 'dais' property
In reply to Sasha LevinFrom: Shengjiu Wang <[email protected]>
[ Upstream commit 294a60e5e9830045c161181286d44ce669f88833 ]
In order to make the audmix device linked by audio graph card, make 'dais' property to be optional.
If 'dais' property exists, then register the imx-audmix card driver. otherwise, it should be linked by audio graph card.
--- sound/soc/fsl/fsl_audmix.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
sound/soc/fsl/fsl_audmix.c +11 -5
@@ -488,11 +488,17 @@ static int fsl_audmix_probe(struct platform_device *pdev) goto err_disable_pm; } - priv->pdev =platform_device_register_data (dev,"imx-audmix" ,0 ,NULL ,0 ); -if (IS_ERR (priv->pdev)) { - ret =PTR_ERR (priv->pdev); -dev_err (dev,"failed to register platform: %d\n" , ret); - goto err_disable_pm; +/* +* If dais property exist, then register the imx-audmix card driver. +* otherwise, it should be linked by audio graph card. +*/ +if (of_find_property (pdev->dev.of_node,"dais" ,NULL )) { + priv->pdev =platform_device_register_data (dev,"imx-audmix" ,0 ,NULL ,0 ); +if (IS_ERR (priv->pdev)) { + ret =PTR_ERR (priv->pdev); +dev_err (dev,"failed to register platform: %d\n" , ret); + goto err_disable_pm; + } }return 0 ;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 18/24 media: uvcvideo: Add quirk for Actions UVC05
In reply to Sasha LevinFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 8c54e58f94ed3ff28643aefd2c0c2c98313ee770 ]
Actions UVC05 is a HDMI to USB dongle that implements the UVC protocol.
When the device suspends, its firmware seems to enter a weird mode when it does not produce more frames.
Add the device to the quirk list to disable autosuspend.
Bus 001 Device 007: ID 1de1:f105 Actions Microelectronics Co. Display
capture-UVC05
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x1de1 Actions Microelectronics Co.
idProduct 0xf105 Display capture-UVC05
bcdDevice 4.09
iManufacturer 1 Actions Micro iProduct 2 Display capture-UVC05 iSerial 3 -1005308387 bNumConfigurations 1
--- drivers/media/usb/uvc/uvc_driver.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +9 -0
@@ -3030,6 +3030,15 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceProtocol = 0, .driver_info =UVC_INFO_QUIRK (UVC_QUIRK_PROBE_MINMAX | UVC_QUIRK_IGNORE_SELECTOR_UNIT) }, + /* Actions Microelectronics Co. Display capture-UVC05 */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x1de1, + .idProduct = 0xf105, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_DISABLE_AUTOSUSPEND) }, /* NXP Semiconductors IR VIDEO */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 19/24 media: s5p-mfc: Corrected NV12M/NV21M plane-sizes
In reply to Sasha LevinFrom: Aakarsh Jain <[email protected]>
[ Upstream commit 7d0d0b2342bebc47a46499cdf21257ed1e58c4aa ]
There is a possibility of getting page fault if the overall buffer size is not aligned to 256bytes. Since MFC does read operation only and it won't corrupt the data values even if it reads the extra bytes.
Corrected luma and chroma plane sizes for V4L2_PIX_FMT_NV12M and V4L2_PIX_FMT_NV21M pixel format.
--- drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c +3 -2
@@ -549,8 +549,9 @@ static void s5p_mfc_enc_calc_src_size_v6(struct s5p_mfc_ctx *ctx)case V4L2_PIX_FMT_NV21M : ctx->stride[0 ] =ALIGN (ctx->img_width,S5P_FIMV_NV12M_HALIGN_V6 ); ctx->stride[1 ] =ALIGN (ctx->img_width,S5P_FIMV_NV12M_HALIGN_V6 ); - ctx->luma_size = ctx->stride[0 ] *ALIGN (ctx->img_height,16 ); - ctx->chroma_size = ctx->stride[0 ] *ALIGN (ctx->img_height /2 ,16 ); + ctx->luma_size =ALIGN (ctx->stride[0 ] *ALIGN (ctx->img_height,16 ),256 ); + ctx->chroma_size =ALIGN (ctx->stride[0 ] *ALIGN (ctx->img_height /2 ,16 ), +256 );break ;case V4L2_PIX_FMT_YUV420M :case V4L2_PIX_FMT_YVU420M :
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 20/24 mmc: dw_mmc: add a quirk for accessing 64-bit FIFOs in two halves
In reply to Sasha LevinFrom: Kaustabh Chakraborty <[email protected]>
[ Upstream commit 57c0902f8bec51add5a1eb908d8b876592725d81 ]
In certain DW MMC implementations (such as in some Exynos7870 controllers), 64-bit read/write is not allowed from a 64-bit FIFO. Add a quirk which facilitates accessing the 64-bit FIFO registers in two 32-bit halves.
--- drivers/mmc/host/dw_mmc.c | 94 ++++++++++++++++++++++++++++++++++++++- drivers/mmc/host/dw_mmc.h | 27 +++++++++++ 2 files changed, 119 insertions(+), 2 deletions(-)
drivers/mmc/host/dw_mmc.c +92 -2
@@ -2579,6 +2579,91 @@ static void dw_mci_pull_data64(struct dw_mci *host, void *buf, int cnt) } } +static void dw_mci_push_data64_32 (struct dw_mci *host,void *buf,int cnt) +{ +struct mmc_data *data = host->data; +int init_cnt = cnt; + +/* try and push anything in the part_buf */ +if (unlikely (host->part_buf_count)) { +int len =dw_mci_push_part_bytes (host, buf, cnt); + + buf += len; + cnt -= len; + +if (host->part_buf_count ==8 ) { +mci_fifo_l_writeq (host->fifo_reg, host->part_buf); + host->part_buf_count =0 ; + } + } +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +if (unlikely ((unsigned long )buf &0x7 )) { +while (cnt >=8 ) { +u64 aligned_buf[16 ]; +int len =min (cnt &-8 , (int )sizeof (aligned_buf)); +int items = len >>3 ; +int i; +/* memcpy from input buffer into aligned buffer */ +memcpy (aligned_buf, buf, len); + buf += len; + cnt -= len; +/* push data from aligned buffer into fifo */ +for (i =0 ; i < items; ++i) +mci_fifo_l_writeq (host->fifo_reg, aligned_buf[i]); + } + } else +#endif + { +u64 *pdata = buf; + +for (; cnt >=8 ; cnt -=8 ) +mci_fifo_l_writeq (host->fifo_reg, *pdata++); + buf = pdata; + } +/* put anything remaining in the part_buf */ +if (cnt) { +dw_mci_set_part_bytes (host, buf, cnt); +/* Push data if we have reached the expected data length */ +if ((data->bytes_xfered + init_cnt) == + (data->blksz * data->blocks)) +mci_fifo_l_writeq (host->fifo_reg, host->part_buf); + } +} + +static void dw_mci_pull_data64_32 (struct dw_mci *host,void *buf,int cnt) +{ +#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +if (unlikely ((unsigned long )buf &0x7 )) { +while (cnt >=8 ) { +/* pull data from fifo into aligned buffer */ +u64 aligned_buf[16 ]; +int len =min (cnt &-8 , (int )sizeof (aligned_buf)); +int items = len >>3 ; +int i; + +for (i =0 ; i < items; ++i) + aligned_buf[i] =mci_fifo_l_readq (host->fifo_reg); + +/* memcpy from aligned buffer into output buffer */ +memcpy (buf, aligned_buf, len); + buf += len; + cnt -= len; + } + } else +#endif + { +u64 *pdata = buf; + +for (; cnt >=8 ; cnt -=8 ) + *pdata++ =mci_fifo_l_readq (host->fifo_reg); + buf = pdata; + } +if (cnt) { + host->part_buf =mci_fifo_l_readq (host->fifo_reg); +dw_mci_pull_final_bytes (host, buf, cnt); + } +} +static void dw_mci_pull_data (struct dw_mci *host,void *buf,int cnt) {int len;
@@ -3379,8 +3464,13 @@ int dw_mci_probe(struct dw_mci *host) width =16 ; host->data_shift =1 ; }else if (i ==2 ) { - host->push_data = dw_mci_push_data64; - host->pull_data = dw_mci_pull_data64; +if ((host->quirks &DW_MMC_QUIRK_FIFO64_32 )) { + host->push_data = dw_mci_push_data64_32; + host->pull_data = dw_mci_pull_data64_32; + }else { + host->push_data = dw_mci_push_data64; + host->pull_data = dw_mci_pull_data64; + } width =64 ; host->data_shift =3 ; }else {
drivers/mmc/host/dw_mmc.h +27 -0
@@ -281,6 +281,8 @@ struct dw_mci_board {/* Support for longer data read timeout */ #define DW_MMC_QUIRK_EXTENDED_TMOUT BIT(0) +/* Force 32-bit access to the FIFO */ +#define DW_MMC_QUIRK_FIFO64_32 BIT(1)#define DW_MMC_240A 0x240a#define DW_MMC_280A 0x280a
@@ -472,6 +474,31 @@ struct dw_mci_board {#define mci_fifo_writel (__value, __reg) __raw_writel(__reg, __value)#define mci_fifo_writeq (__value, __reg) __raw_writeq(__reg, __value) +/* +* Some dw_mmc devices have 64-bit FIFOs, but expect them to be +* accessed using two 32-bit accesses. If such controller is used +* with a 64-bit kernel, this has to be done explicitly. +*/ +static inline u64 mci_fifo_l_readq (void __iomem *addr) +{ +u64 ans; +u32 proxy[2 ]; + + proxy[0 ] =mci_fifo_readl (addr); + proxy[1 ] =mci_fifo_readl (addr +4 ); +memcpy (&ans, proxy,8 ); +return ans; +} + +static inline void mci_fifo_l_writeq (void __iomem *addr,u64 value) +{ +u32 proxy[2 ]; + +memcpy (proxy, &value,8 ); +mci_fifo_writel (addr, proxy[0 ]); +mci_fifo_writel (addr +4 , proxy[1 ]); +} +/* Register access macros */ #define mci_readl (dev, reg) \ readl_relaxed((dev)->regs + SDMMC_##reg)
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 21/24 ALSA: usb-audio: Fix CME quirk for UF series keyboards
In reply to Sasha LevinFrom: Ricard Wanderlof <[email protected]>
[ Upstream commit c2820405ba55a38932aa2177f026b70064296663 ]
Fix quirk for CME master keyboards so it not only handles sysex but also song position pointer, MIDI timing clock, start and stop messages, and active sensing. All of these can be output by the CME UF series master keyboards.
Tested with a CME UF6 in a desktop Linux environment as well as on the Zynthian Raspberry Pi based platform.
--- sound/usb/midi.c | 80 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 6 deletions(-)
sound/usb/midi.c +74 -6
@@ -489,16 +489,84 @@ static void ch345_broken_sysex_input(struct snd_usb_midi_in_endpoint *ep,/* * CME protocol: like the standard protocol, but SysEx commands are sent as a -* single USB packet preceded by a 0x0F byte. +* single USB packet preceded by a 0x0F byte, as are system realtime +* messages and MIDI Active Sensing. +* Also, multiple messages can be sent in the same packet. */ static void snd_usbmidi_cme_input (struct snd_usb_midi_in_endpoint *ep,uint8_t *buffer,int buffer_length) { -if (buffer_length <2 || (buffer[0 ] &0x0f ) !=0x0f ) -snd_usbmidi_standard_input (ep, buffer, buffer_length); -else -snd_usbmidi_input_data (ep, buffer[0 ] >>4 , - &buffer[1 ], buffer_length -1 ); +int remaining = buffer_length; + +/* +* CME send sysex, song position pointer, system realtime +* and active sensing using CIN 0x0f, which in the standard +* is only intended for single byte unparsed data. +* So we need to interpret these here before sending them on. +* By default, we assume single byte data, which is true +* for system realtime (midi clock, start, stop and continue) +* and active sensing, and handle the other (known) cases +* separately. +* In contrast to the standard, CME does not split sysex +* into multiple 4-byte packets, but lumps everything together +* into one. In addition, CME can string multiple messages +* together in the same packet; pressing the Record button +* on an UF6 sends a sysex message directly followed +* by a song position pointer in the same packet. +* For it to have any reasonable meaning, a sysex message +* needs to be at least 3 bytes in length (0xf0, id, 0xf7), +* corresponding to a packet size of 4 bytes, and the ones sent +* by CME devices are 6 or 7 bytes, making the packet fragments +* 7 or 8 bytes long (six or seven bytes plus preceding CN+CIN byte). +* For the other types, the packet size is always 4 bytes, +* as per the standard, with the data size being 3 for SPP +* and 1 for the others. +* Thus all packet fragments are at least 4 bytes long, so we can +* skip anything that is shorter; this also conveniantly skips +* packets with size 0, which CME devices continuously send when +* they have nothing better to do. +* Another quirk is that sometimes multiple messages are sent +* in the same packet. This has been observed for midi clock +* and active sensing i.e. 0x0f 0xf8 0x00 0x00 0x0f 0xfe 0x00 0x00, +* but also multiple note ons/offs, and control change together +* with MIDI clock. Similarly, some sysex messages are followed by +* the song position pointer in the same packet, and occasionally +* additionally by a midi clock or active sensing. +* We handle this by looping over all data and parsing it along the way. +*/ +while (remaining >=4 ) { +int source_length =4 ;/* default */ + +if ((buffer[0 ] &0x0f ) ==0x0f ) { +int data_length =1 ;/* default */ + +if (buffer[1 ] ==0xf0 ) { +/* Sysex: Find EOX and send on whole message. */ +/* To kick off the search, skip the first +* two bytes (CN+CIN and SYSEX (0xf0). +*/ +uint8_t *tmp_buf = buffer +2 ; +int tmp_length = remaining -2 ; + +while (tmp_length >1 && *tmp_buf !=0xf7 ) { + tmp_buf++; + tmp_length--; + } + data_length = tmp_buf - buffer; + source_length = data_length +1 ; + }else if (buffer[1 ] ==0xf2 ) { +/* Three byte song position pointer */ + data_length =3 ; + } +snd_usbmidi_input_data (ep, buffer[0 ] >>4 , + &buffer[1 ], data_length); + }else { +/* normal channel events */ +snd_usbmidi_standard_input (ep, buffer, source_length); + } + buffer += source_length; + remaining -= source_length; + } }/*
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 22/24 ASoC: amd: Add DMI quirk for ACP6X mic support
In reply to Sasha LevinFrom: keenplify <[email protected]>
[ Upstream commit 309b367eafc8e162603cd29189da6db770411fea ]
Some AMD laptops with ACP6X do not expose the DMIC properly on Linux. Adding a DMI quirk enables mic functionality.
Similar to Bugzilla #218402, this issue affects multiple users.
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -584,6 +584,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_VERSION, "pang13"), } }, + { + .driver_data = &acp6x_card, + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "Micro-Star International Co., Ltd."), + DMI_MATCH(DMI_PRODUCT_NAME, "Bravo 15 C7UCX"), + } + }, {} };
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 23/24 ASoC: amd: yc: update quirk data for new Lenovo model
In reply to Sasha LevinFrom: Syed Saba kareem <[email protected]>
[ Upstream commit 5a4dd520ef8a94ecf81ac77b90d6a03e91c100a9 ]
Update Quirk data for new Lenovo model 83J2 for YC platform.
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -339,6 +339,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "83Q3"), } }, + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "83J2"), + } + }, { .driver_data = &acp6x_card, .matches = {
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 24/24 platform/x86: x86-android-tablets: Add select POWER_SUPPLY to Kconfig
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 2c30357e755b087217c7643fda2b8aea6d6deda4 ]
Commit c78dd25138d1 ("platform/x86: x86-android-tablets: Add Vexia EDU ATLA 10 EC battery driver"), adds power_supply class registering to the x86-android-tablets code.
Add "select POWER_SUPPLY" to the Kconfig entry to avoid these errors:
ERROR: modpost: "power_supply_get_drvdata" [drivers/platform/x86/x86-android-tablets/vexia_atla10_ec.ko] undefined!
ERROR: modpost: "power_supply_changed" [drivers/platform/x86/x86-android-tablets/vexia_atla10_ec.ko] undefined!
ERROR: modpost: "devm_power_supply_register" [drivers/platform/x86/x86-android-tablets/vexia_atla10_ec.ko] undefined!
When POWER_SUPPLY support is not enabled.
--- drivers/platform/x86/x86-android-tablets/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/x86-android-tablets/Kconfig +1 -0
@@ -10,6 +10,7 @@ config X86_ANDROID_TABLETS depends on ACPI && EFI && PCI select NEW_LEDS select LEDS_CLASS + select POWER_SUPPLY help X86 tablets which ship with Android as (part of) the factory image typically have various problems with their DSDTs. The factory kernels
Signature · 1 line
2.39.5