vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / media-add-ons / usb_webcam / addons / quickcam / QuickCamDevice.h
blobf6653d5e23ddd5e3d7fdf0326d574e74418da1b6
1 /*
2 * Copyright 2004-2008, François Revol, <revol@free.fr>.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _QUICK_CAM_DEVICE_H
6 #define _QUICK_CAM_DEVICE_H
8 #include "CamDevice.h"
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
28 // This class represents each webcam
29 class QuickCamDevice : public CamDevice {
30 public:
31 QuickCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device);
32 ~QuickCamDevice();
33 virtual bool SupportsBulk();
34 virtual bool SupportsIsochronous();
35 virtual status_t StartTransfer();
36 virtual status_t StopTransfer();
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);
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);
51 private:
52 virtual status_t SendCommand(uint8 dir, uint8 request, uint16 value,
53 uint16 index, uint16 length, void* data);
56 // the addon itself, that instanciate
58 class QuickCamDeviceAddon : public CamDeviceAddon {
59 public:
60 QuickCamDeviceAddon(WebCamMediaAddOn* webcam);
61 virtual ~QuickCamDeviceAddon();
63 virtual const char *BrandName();
64 virtual QuickCamDevice *Instantiate(CamRoster &roster, BUSBDevice *from);
68 #endif /* _QUICK_CAM_CAM_DEVICE_H */