xref: /haiku/src/add-ons/kernel/drivers/ports/usb_serial/KLSI.h (revision 25a7b01d15612846f332751841da3579db313082)
17aa661d4SMichael Lotz /*
27aa661d4SMichael Lotz  * Copyright (c) 2007-2008 by Michael Lotz
37aa661d4SMichael Lotz  * Heavily based on the original usb_serial driver which is:
47aa661d4SMichael Lotz  *
57aa661d4SMichael Lotz  * Copyright (c) 2003-2004 by Siarzhuk Zharski <imker@gmx.li>
67aa661d4SMichael Lotz  * Distributed under the terms of the MIT License.
77aa661d4SMichael Lotz  */
87aa661d4SMichael Lotz #ifndef _USB_KLSI_H_
97aa661d4SMichael Lotz #define _USB_KLSI_H_
107aa661d4SMichael Lotz 
11*5ba5e31fSAlexander von Gluck IV 
127aa661d4SMichael Lotz #include "SerialDevice.h"
137aa661d4SMichael Lotz 
14*5ba5e31fSAlexander von Gluck IV 
157aa661d4SMichael Lotz /* supported vendor and product ids */
167aa661d4SMichael Lotz #define VENDOR_PALM		0x0830
177aa661d4SMichael Lotz #define VENDOR_KLSI		0x05e9
18*5ba5e31fSAlexander von Gluck IV 
19*5ba5e31fSAlexander von Gluck IV const usb_serial_device kKLSIDevices[] = {
20*5ba5e31fSAlexander von Gluck IV 	{VENDOR_PALM, 0x0080, "PalmConnect RS232"},
21*5ba5e31fSAlexander von Gluck IV 	{VENDOR_KLSI, 0x00c0, "KLSI KL5KUSB105D"}
22*5ba5e31fSAlexander von Gluck IV };
23*5ba5e31fSAlexander von Gluck IV 
247aa661d4SMichael Lotz 
257aa661d4SMichael Lotz /* protocol defines */
267aa661d4SMichael Lotz #define KLSI_SET_REQUEST			0x01
277aa661d4SMichael Lotz #define KLSI_POLL_REQUEST			0x02
287aa661d4SMichael Lotz #define KLSI_CONF_REQUEST			0x03
297aa661d4SMichael Lotz #define KLSI_CONF_REQUEST_READ_ON	0x03
307aa661d4SMichael Lotz #define KLSI_CONF_REQUEST_READ_OFF	0x02
317aa661d4SMichael Lotz 
327aa661d4SMichael Lotz // not sure
337aa661d4SMichael Lotz #define KLSI_BUFFER_SIZE			64
347aa661d4SMichael Lotz 
357aa661d4SMichael Lotz enum {
367aa661d4SMichael Lotz 	klsi_sio_b115200 = 0,
377aa661d4SMichael Lotz 	klsi_sio_b57600 = 1,
387aa661d4SMichael Lotz 	klsi_sio_b38400 = 2,
397aa661d4SMichael Lotz 	klsi_sio_b19200 = 4,
407aa661d4SMichael Lotz 	klsi_sio_b9600 = 6,
417aa661d4SMichael Lotz 	/* unchecked */
427aa661d4SMichael Lotz 	klsi_sio_b4800 = 8,
437aa661d4SMichael Lotz 	klsi_sio_b2400 = 9,
447aa661d4SMichael Lotz 	klsi_sio_b1200 = 10,
457aa661d4SMichael Lotz 	klsi_sio_b600 = 11,
467aa661d4SMichael Lotz 	klsi_sio_b300 = 12
477aa661d4SMichael Lotz };
487aa661d4SMichael Lotz 
497aa661d4SMichael Lotz 
507aa661d4SMichael Lotz class KLSIDevice : public SerialDevice {
517aa661d4SMichael Lotz public:
527aa661d4SMichael Lotz 								KLSIDevice(usb_device device, uint16 vendorID,
537aa661d4SMichael Lotz 									uint16 productID, const char *description);
547aa661d4SMichael Lotz 
557aa661d4SMichael Lotz virtual	status_t				AddDevice(const usb_configuration_info *config);
567aa661d4SMichael Lotz 
577aa661d4SMichael Lotz virtual	status_t				ResetDevice();
587aa661d4SMichael Lotz 
59c5f2df28SPhilippe Houdoin virtual	status_t				SetLineCoding(usb_cdc_line_coding *coding);
607aa661d4SMichael Lotz 
617aa661d4SMichael Lotz virtual	void					OnRead(char **buffer, size_t *numBytes);
6212f32926SFrançois Revol virtual	void					OnWrite(const char *buffer, size_t *numBytes,
6312f32926SFrançois Revol 									size_t *packetBytes);
647aa661d4SMichael Lotz virtual	void					OnClose();
657aa661d4SMichael Lotz };
667aa661d4SMichael Lotz 
67*5ba5e31fSAlexander von Gluck IV 
687aa661d4SMichael Lotz #endif //_USB_KLSI_H_
69