xref: /haiku/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.h (revision 002f37b0cca92e4cf72857c72ac95db5a8b09615)
1 /*
2  * Copyright 2004-2008, François Revol, <revol@free.fr>.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _NW80X_CAM_DEVICE_H
6 #define _NW80X_CAM_DEVICE_H
7 
8 #include "CamDevice.h"
9 
10 #define STV_REG_COUNT	0x0c
11 // Control registers of the STV0600 ASIC
12 #define STV_I2C_WRITE   0x400
13 #define STV_I2C_WRITE1  0x400
14 #define STV_I2C_READ   0x1410
15 #define STV_ISO_ENABLE 0x1440
16 #define STV_SCAN_RATE  0x1443
17 #define STV_ISO_SIZE   0x15c1
18 #define STV_Y_CTRL     0x15c3
19 #define STV_X_CTRL     0x1680
20 #define STV_REG00      0x1500
21 #define STV_REG01      0x1501
22 #define STV_REG02      0x1502
23 #define STV_REG03      0x1503
24 #define STV_REG04      0x1504
25 #define STV_REG23      0x0423
26 
27 
28 // This class represents each webcam
29 class NW80xCamDevice : public CamDevice {
30 	public:
31 						NW80xCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device);
32 						~NW80xCamDevice();
33 	virtual bool		SupportsBulk();
34 	virtual bool		SupportsIsochronous();
35 	virtual status_t	StartTransfer();
36 	virtual status_t	StopTransfer();
37 
38 	// generic register-like access
39 	virtual ssize_t		WriteReg(uint16 address, uint8 *data, size_t count=1);
40 	virtual ssize_t		ReadReg(uint16 address, uint8 *data, size_t count=1, bool cached=false);
41 
42 	// I2C-like access
43 	virtual status_t	GetStatusIIC();
44 	virtual status_t	WaitReadyIIC();
45 	virtual ssize_t		WriteIIC(uint8 address, uint8 *data, size_t count=1);
46 	virtual ssize_t		ReadIIC(uint8 address, uint8 *data);
47 	virtual ssize_t		ReadIIC8(uint8 address, uint8 *data);
48 	virtual ssize_t		ReadIIC16(uint8 address, uint16 *data);
49 	virtual status_t	SetIICBitsMode(size_t bits=8);
50 
51 	private:
52 	virtual status_t	SendCommand(uint8 dir, uint8 request, uint16 value,
53 									uint16 index, uint16 length, void* data);
54 };
55 
56 // the addon itself, that instanciate
57 
58 class NW80xCamDeviceAddon : public CamDeviceAddon
59 {
60 	public:
61 						NW80xCamDeviceAddon(WebCamMediaAddOn* webcam);
62 	virtual 			~NW80xCamDeviceAddon();
63 
64 	virtual const char	*BrandName();
65 	virtual NW80xCamDevice	*Instantiate(CamRoster &roster, BUSBDevice *from);
66 
67 };
68 
69 #endif /* _NW80X_CAM_CAM_DEVICE_H */
70