📄 usbconf.c
字号:
/*
* Start of Zoran Standard Header
* Copyright (c) 2003 - 2004 Zoran Corporation.
*
*
* All rights reserved. Proprietary and confidential.
*
* DESCRIPTION for usbconf.c
* USB 2.0 Chapter 9 Lexmark se** printer initialization.
*
* NEW HISTORY COMMENT (description must be followed by a blank line)
* <Enter change description here>
* ===== HISTORY of changes in //depot/misc/projects/tps/usb/usbconf.c
*
* 15/Jun/04 #46 lee Fixed card reader for USB 2.0
* 15/Jun/04 #45 lee Move scanner (EP2->EP6) and mass storage (EP4->EP8)
* endpoints for USB PHY hardware issues.
* 27/May/04 #44 mrhines Advertise that we draw 0 mA from bus to make certain PCs happy.
* 21/May/04 #43 lee Set USB_Conf.HIDinterface to proper value for CH*
* 18/May/04 #42 emiller Fix fallback USB command strings
* 18/May/04 #41 emiller Get config info from NVRAM-in-Flash for boot builds
* 10/May/04 #40 lee Support config w/o scanner and/or debug channels, e.g., CH*
* 10/May/04 #39 lee Remove GRINDSTONE build option
* 3/May/04 #38 emiller Fix SE & CH Model Name in device id
* 16/Apr/04 #37 bdodge add TIMEX devid string
* 7/Apr/04 #36 lee Back out HPC interface (function replaced by tps debug)
* 25/Mar/04 #35 jwv Added Charismatic deviceID for boot code
* 10/Mar/04 #34 lee Fix compiler warnings: cast (char *) for strcpy and OM args.
* 5/Mar/04 #33 lee Remove ASSERTs from ParseDeviceID(); now returns false
* on error so "Unknown" can be used if NVRAM corrupted.
* 25/Feb/04 #32 lee Change static GetPidVid(), GetSerialNo(),
* GetDeviceID() to public USBGetPidVid(), USBGetSerialNo(), USBGetDeviceID().
* 23/Feb/04 #31 lee Replaced genos.h with util.h to get string prototypes
* 5/Feb/04 #30 lee Added BOOT VID/PID for Charismatic and Timex.
* 30/Jan/04 #29 lee Fixed length of concatinated Device ID string
* returned by GetDeviceID().
* 30/Jan/04 #28 emiller Add command string property
* 29/Jan/04 #27 emiller Debug device id problem
* 28/Jan/04 #26 emiller Use NVRAM properties for non-boot USB device id
* construction; waiting for info from the customer
* re: CMD string; also need to figure out how to pull
* out the device id info in the boot code.
* 23/Jan/04 #25 lee Change HS_BULK_SIZE to 64 bytes
* 21/Nov/03 #24 lee Fix comment.
* 10/Nov/03 #23 lee Fix ASSERT introduced on previous change.
* 10/Nov/03 #22 lee Added "HPC" interface for sending printf strings to host PC.
* 8/Nov/03 #21 mrhines LEX5100 (AKA X5150) is now default for Timex Alpha3 driver compatibility.
* 7/Nov/03 #20 lee Changed GRINDSTONE from "710" to "810".
* 31/Oct/03 #19 lee Fixes to pass USB2.0 and HID compliance.
* 29/Oct/03 #18 lee Fixed configuration tables for UNBRIDLED.
* 23/Oct/03 #17 mrhines One more 5200 change.
* 22/Oct/03 #16 mrhines Unbridled is really a 5200, not a 2200
* 15/Oct/03 #15 lee Add UNBRIDLED configuration as default.
* 14/Oct/03 #14 lee Remove local definition of ASSERT.
* 14/Oct/03 #13 lee Extract USB product string from Device ID "MODEL"
* (was "DES") per Lexmark request.
* 7/Oct/03 #12 lee Define "-DSEA" in compile line for SEA** configurations.
* 24/Sep/03 #11 lee Fix Grindstone tables.
* 22/Sep/03 #10 lee Small change for GRINDSTONE.
* 18/Sep/03 #9 lee Small changes.
* 16/Sep/03 #8 lee Didn't remove HID interface for GRINDSTONE. Sorry.
* Also, allow -DSERIAL_NO_STRING='"MySerialNoHere"'
* 15/Sep/03 #7 lee Added "GRINDSTONE" configuration (printer interface only)
* 3/Sep/03 #6 lee Fix errors in memory card reader interface tables.
* 2/Sep/03 #5 lee Missed a couple of ifdef's last time (MEMORY_CARD_READER)
* 29/Aug/03 #4 lee Made memory card reader depend on MEMORY_CARD_READER manifest
* 28/Aug/03 #3 lee Added memory card reader interface, various fixes.
* 27/Aug/03 #2 mrhines Fixed a few typos to make us look exactly like an X5150.
* 21/Aug/03 #1 lee Created
*
* End of Zoran Standard Header
*/
/******************************************************************************/
#ifdef BOOTCODE
typedef unsigned char uchar; /* unsigned character */
typedef unsigned char Uint8; /* 8-bit signed integer */
typedef unsigned short Uint16; /* 16-bit unsigned integer*/
typedef unsigned long Uint32; /* 32-bit unsigned integer*/
typedef long Sint32; /* 32-bit unsigned integer*/
typedef int Boolean;
#include "util.h"
#include "usbpriv.h"
#include "bios.h"
#else /* not BOOTCODE */
#include "univ.gh"
#include "arch.h"
#include "pile.h"
#include "dbg.h"
#include "util.h"
#include "propman.h"
#include "usbpriv.h"
#endif /* not BOOTCODE */
#include "usb.h"
/*
* Only one configuration allowed, LEX5100 is default - multiple
* definitions will cause compile error. These are only used for BOOT code.
*/
#ifdef SEA
#define VENDOR_ID 0x043D
#define PRODUCT_ID 0x0097
#endif
#ifdef UNBRIDLED
#define VENDOR_ID 0x043D
#define PRODUCT_ID 0x0093
#endif
#ifdef LEX5100
#define VENDOR_ID 0x043D
#define PRODUCT_ID 0x0065
#endif
#ifdef CHARISMATIC
#define VENDOR_ID 0x043D
#define PRODUCT_ID 0x009E
#endif
#ifdef TIMEX
#define VENDOR_ID 0x413C
#define PRODUCT_ID 0x5111
#endif
/* DEFAULT CONFIGURATION */
#ifndef PRODUCT_ID
#define LEX5100
#define PRODUCT_ID 0x0065
#endif
#if FULL_SPEED_ONLY
#define USB_REV 0x110 /* bcdUSB USB revision 1.10 */
#else
#define USB_REV 0x200 /* bcdUSB USB revision 2.00 */
#endif
/* prototypes */
static Boolean ParseDeviceID(Uint8 *DeviceID, Uint8 *key, Uint8 *descriptor);
/*
* USB Configuration structure: passes configuration initialization
* from USBConfigurationInit().
*/
USB_CONFIGURATION USB_Conf;
/****************************************************************/
#define LOB(w) ((Uint8)(w) & 255)
#define HIB(w) ((Uint8)((w) >> 8))
/**************************************************************************/
/* PORT SPECIFIC CODE BEGINS HERE: */
#define STR_DESC_CNT 7 /* Number of string descriptors not including
* language, illegal index or language error
* string descriptors
*/
#define STR_INDEX_ERR 8 /* index of "illegal index" string descriptor */
#define STR_LANGUAGE_ERR 9 /* index of language error string descriptor */
#if (STR_LANGUAGE_ERR >= MAX_STR_DESC_COUNT)
#error Must increase MAX_STR_DESC_COUNT in usbpriv.h
#endif
/* setup device descriptor */
static Uint8 DevDesc[] = {
18, 1, /* bLength, bDescType 1 = DEVICE */
LOB(USB_REV), /* bcdUSB USB revision */
HIB(USB_REV),
0, /* bDeviceClass */
0, /* bDeviceSubClass */
0, /* bDeviceProtocol */
EP0_PKT_SIZE, /* bMaxPacketSize0 */
LOB(0x0000), /* Vendor ID (filled in later) */
HIB(0x0000), /* Vendor ID (filled in later) */
LOB(0x0000), /* Product ID (filled in later) */
HIB(0x0000), /* Product ID (filled in later) */
1, /* bcd Device version 0.01 */
0,
1, /* iManufacturer */
2, /* iProduct */
3, /* iSerialNumber - number must be unique for each device */
1 /* bNumConfigurations */
};
/* USB 2.0 specific descriptor */
/* See section 9.6.2, Rev 2.0 USB specification (page 264). */
static Uint8 DevQualifierDesc[] = {
10, 6, /* bLength, bDescType 6 = DEVICE Qualifier */
LOB(USB_REV), /* bcdUSB USB revision */
HIB(USB_REV),
0, /* bDeviceClass */
0, /* bDeviceSubClass */
0, /* bDeviceProtocol */
EP0_PKT_SIZE, /* bMaxPacketSize0 */
1, /* bNumConfigurations */
0 /* reserved */
};
/*
* This table is retrieved by the host after the address has been set.
* This table defines the configurations available for the device.
* See section 9.6.1 of the Rev 2.0 USB specification (page 261).
* (section 9.6.2 of the Rev 1.0 USB specification, page 184.)
* These fields are application DEPENDENT.
*/
static Uint8 FSConfDesc[] = {
9, /* bLength Length of this descriptor */
2, /* bDescType 2=CONFIGURATION */
0, 0, /* total configuration length (filled in later 94) */
MAX_IFACE+1, /* bNumInterfaces Number of interfaces */
1, /* bConfigValue Configuration Value */
0, /* iConfig String Index for this config = #1 */
0xc0, /* bmAttributes attributes - self powered */
0, /* MaxPower draws 0 mA from the bus. */
/* See section 9.6.5, Rev 2.0 USB specification (page 267). */
/* (section 9.6.3, Rev 1.0 USB specification, page 185.) */
/* setup interface descriptors */
#ifdef SCAN_DB_IFACE
/* interface1.1 */
9, 4, /* bLength, bDescriptorType 4 = INTERFACE */
SCAN_DB_IFACE, /* bIfaceNum interface number */
0, /* bAltSetting Alternate setting 0 */
SCANNER_EPS+DEBUG_EPS, /* bNumEndpoints EP6 IN/OUT, EP7 IN/OUT */
0xFF, /* bIfaceClass (vendor specific device class) */
0xFF, /* bIfaceSubClass (vendor specific) */
0xFF, /* bIfaceProtocol (vendor specific) */
4, /* iInterface index to string ("Scan") */
/* setup endpoint descriptors */
#if SCANNER_EPS
/* endpoint1.1.1.1, Scan Status and Data from AIO (IN) */
7, 5, /* descriptor length, type */
0x80+SCN_EP, /* endpoint address IN */
2, /* attributes - 2 Bulk endpoint */
LOB(FS_BULK_SIZE), /* maximum packet size */
HIB(FS_BULK_SIZE),
0, /* interval - 0 msec. */
/* interval for polling endpoint for
* data transfers in frames (1msec. FS,
* 125usec. HS) Maximum NAK rate of
* endpoint. >0 => at most 1 NAK each
* interval no. of microframes. range
* 0 - 255.
*/
/* endpoint1.1.1.2, Scan Escape Language input to AIO: (OUT) */
7, 5, /* descriptor length, type */
SCN_EP, /* endpoint address OUT */
2, /* attributes - 2 Bulk endpoint */
LOB(FS_BULK_SIZE), /* maximum packet size */
HIB(FS_BULK_SIZE),
0, /* interval - 0 msec. */
#endif /* SCANNER_EPS */
#if DEBUG_EPS
/* endpoint1.1.1.3, Debug MDM from AIO (IN) */
7, 5, /* descriptor length, type */
0x80+DBG_EP, /* endpoint address IN */
2, /* attributes - 2 Bulk endpoint */
LOB(FS_BULK_SIZE), /* maximum packet size */
HIB(FS_BULK_SIZE),
0, /* interval - 0 msec. */
/* endpoint1.1.1.4, Debug MDM to AIO (OUT) */
7, 5, /* descriptor length, type */
DBG_EP, /* endpoint address OUT */
2, /* attributes - 2 Bulk endpoint */
LOB(FS_BULK_SIZE), /* maximum packet size */
HIB(FS_BULK_SIZE),
0, /* interval - 0 msec. */
#endif /* DEBUG_EPS */
#endif /* SCAN_DB_IFACE */
/* setup interface descriptors */
/* interface1.2 */
9, 4, /* bLength, bDescriptorType 4 = INTERFACE */
PRINTER_IFACE, /* bIfaceNum interface number */
0, /* bAltSetting Alternate setting 0 */
2, /* bNumEndpoints EP1 IN, EP1 OUT */
7, /* bIfaceClass 7 base class for printers */
1, /* bIfaceSubClass 1 subclass code for printers */
2, /* bIfaceProtocol 2 bidirectional interface */
5, /* iInterface index to string ("Print") */
/* setup endpoint descriptors */
/* endpoint1.1.2.1, Print status - NPA returns (IN) */
7, 5, /* descriptor length, type */
0x80+PRN_EP, /* endpoint address IN */
2, /* attributes - 2 Bulk endpoint */
LOB(FS_BULK_SIZE), /* maximum packet size */
HIB(FS_BULK_SIZE),
0, /* interval - 0 msec. */
/* endpoint1.1.2.2, Print Cmd/Data from Host (OUT) */
7, 5, /* descriptor length, type */
PRN_EP, /* endpoint address OUT */
2, /* attributes - 2 Bulk endpoint */
LOB(FS_BULK_SIZE), /* maximum packet size */
HIB(FS_BULK_SIZE),
0, /* interval - 0 msec. */
/* setup interface descriptors */
/* interface1.3 */
9, 4, /* bLength, bDescriptorType 4 = INTERFACE */
HID_IFACE, /* bIfaceNum interface number */
0, /* bAltSetting Alternate setting 0 */
1, /* bNumEndpoints EP3 IN (interrupt) */
3, /* bIfaceClass (USB specified device class) */
0, /* bIfaceSubClass 0 */
0, /* bIfaceProtocol 0 */
6, /* iInterface index to string ("Hid") */
/* HID descriptor */
9, 0x21, /* bLength, bDescriptorType 0x21 = HID */
0, 1, /* bcdHID HID Class Spec release no. 1.00 */
0, /* bCountryCode device target country */
1, /* bNumDescriptors to follow */
0x22, /* bDescriptor type - Report */
0x49, 0, /* wDescriptorLength - Report length (73 bytes) */
/* setup endpoint descriptors */
/* endpoint1.1.3.1, HID Interrupt from AIO (IN) */
7, 5, /* descriptor length, type */
0x80+HID_EP, /* endpoint address IN */
3, /* attributes - 3 Interrupt endpoint */
LOB(INT_BSIZE), /* maximum packet size (8) */
HIB(INT_BSIZE),
100 /* interval - 100 msec. */
#ifdef MEMORY_CARD_READER
,
/* setup interface descriptors */
/* interface1.4 */
9, 4, /* bLength, bDescriptorType 4 = INTERFACE */
CARD_IFACE, /* bIfaceNum interface number */
0, /* bAltSetting Alternate setting 0 */
2, /* bNumEndpoints EP8 IN, EP8 OUT */
8, /* bIfaceClass 8 Mass Storage class */
6, /* bIfaceSubClass 6 SCSI transparent cmd set */
0x50, /* bIfaceProtocol 50 Bulk-Only transport */
7, /* iInterface index to string ("MS Class") */
/* setup endpoint descriptors */
/* endpoint1.1.4.1, Card Reader Interface (IN) */
7, 5, /* descriptor length, type */
0x80+MEM_EP, /* endpoint address IN */
2, /* attributes - 2 Bulk endpoint */
LOB(FS_BULK_SIZE), /* maximum packet size */
HIB(FS_BULK_SIZE),
0, /* interval - 0 msec. */
/* endpoint1.1.4.2, Card Reader Interface (OUT) */
7, 5, /* descriptor length, type */
MEM_EP, /* endpoint address OUT */
2, /* attributes - 2 Bulk endpoint */
LOB(FS_BULK_SIZE), /* maximum packet size */
HIB(FS_BULK_SIZE),
0 /* interval - 0 msec. */
#endif /* MEMORY_CARD_READER */
};
/* High-speed table */
static Uint8 HSConfDesc[] = {
9, /* bLength Length of this descriptor */
7, /* bDescType 2=CONFIGURATION */
/* bDescType 7=OTHER_SPEED_CONFIGURATION */
0, 0, /* total configuration length (filled in later) */
MAX_IFACE+1, /* bNumInterfaces Number of interfaces */
1, /* bConfigValue Configuration Value */
0, /* iConfig String Index for this config = #1 */
0xc0, /* bmAttributes attributes - self powered */
0, /* MaxPower draws 0 mA from the bus. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -