Skip to content

Commit 764b8bf

Browse files
Merge pull request #1444 from snejok/new-usb-quirk-no_alt_set
new usb quirk: no-alt-set - won't even try set_conf or set_int_alt_set
2 parents 6642068 + 84289ea commit 764b8bf

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

backend/org.cups.usb-quirks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
0x04e8 0x344f whitelist
209209

210210
# Samsung M337x 387x 407x Series works without quirks
211-
0x04e8 0x3460 whitelist
211+
0x04e8 0x3460 whitelist no-alt-set
212212

213213
# Samsung ML-2160 Series (https://bugzilla.redhat.com/show_bug.cgi?id=873123)
214214
0x04e8 0x330f unidir

backend/usb-libusb.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ typedef struct usb_globals_s /* Global USB printer information */
9797
#define USB_QUIRK_VENDOR_CLASS 0x0020 /* Descriptor uses vendor-specific
9898
Class or SubClass */
9999
#define USB_QUIRK_DELAY_CLOSE 0x0040 /* Delay close */
100+
#define USB_QUIRK_NO_ALT_SET 0x0080 /* Some USB printers do not
101+
like set_configuration and
102+
set_interface */
100103
#define USB_QUIRK_WHITELIST 0x0000 /* no quirks */
101104

102105

@@ -692,7 +695,8 @@ close_device(usb_printer_t *printer) /* I - Printer */
692695
* If we have changed the configuration from one valid configuration
693696
* to another, restore the old one
694697
*/
695-
if (printer->origconf > 0 && printer->origconf != number2)
698+
699+
if (printer->origconf > 0 && printer->origconf != number2 && !(printer->quirks & USB_QUIRK_NO_ALT_SET))
696700
{
697701
fprintf(stderr, "DEBUG: Restoring USB device configuration: %d -> %d\n",
698702
number2, printer->origconf);
@@ -1339,6 +1343,9 @@ load_quirks(void)
13391343
if (strstr(line, " vendor-class"))
13401344
quirk->quirks |= USB_QUIRK_VENDOR_CLASS;
13411345

1346+
if (strstr(line, " no-alt-set"))
1347+
quirk->quirks |= USB_QUIRK_NO_ALT_SET;
1348+
13421349
cupsArrayAdd(all_quirks, quirk);
13431350
}
13441351

@@ -1597,7 +1604,7 @@ open_device(usb_printer_t *printer, /* I - Printer */
15971604
}
15981605
number1 = confptr->bConfigurationValue;
15991606

1600-
if (number1 != current)
1607+
if (number1 != current && !(printer->quirks & USB_QUIRK_NO_ALT_SET))
16011608
{
16021609
fprintf(stderr, "DEBUG: Switching USB device configuration: %d -> %d\n",
16031610
current, number1);
@@ -1649,7 +1656,7 @@ open_device(usb_printer_t *printer, /* I - Printer */
16491656
* printers (e.g., Samsung) don't like usb_set_altinterface.
16501657
*/
16511658

1652-
if (confptr->interface[printer->iface].num_altsetting > 1)
1659+
if (confptr->interface[printer->iface].num_altsetting > 1 && !(printer->quirks & USB_QUIRK_NO_ALT_SET))
16531660
{
16541661
number1 = confptr->interface[printer->iface].
16551662
altsetting[printer->altset].bInterfaceNumber;

0 commit comments

Comments
 (0)