vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / media-add-ons / radeon / I2CPort.h
blob767c52011f1053340c4651218875ef12cfdcf0a8
1 /******************************************************************************
3 / File: I2C.h
5 / Description: ATI Radeon I2C Serial Bus interface.
7 / Copyright 2001, Carlos Hasan
9 *******************************************************************************/
11 #ifndef __I2C_PORT_H__
12 #define __I2C_PORT_H__
14 #include "Radeon.h"
16 enum i2c_port_clock_rate {
17 C_RADEON_I2C_MIN_CLOCK_RATE = 7500,
18 C_RADEON_I2C_MAX_CLOCK_RATE = 100000,
19 C_RADEON_I2C_DEFAULT_CLOCK_RATE = 80000
22 class CI2CPort {
23 public:
24 CI2CPort(CRadeon & radeon, int rate = C_RADEON_I2C_DEFAULT_CLOCK_RATE);
26 ~CI2CPort();
28 status_t InitCheck() const;
30 CRadeon & Radeon() const;
32 bool Probe(int address);
34 public:
35 bool Write(int address, const char * buffer, int length);
37 bool Read(int address, char * buffer, int length);
39 bool Write(int address, const char * buffer, int length, char * output, int outlen);
41 public:
42 int Register(int address, int index);
44 void SetRegister(int address, int index, int value);
46 private:
47 int Send(int address, const char * buffer, int length, bool start, bool stop);
49 int Receive(int address, char * buffer, int length, bool start, bool stop);
51 int WaitAck();
53 void Stop();
55 private:
56 CRadeon & fRadeon;
57 int fNfactor;
58 int fMfactor;
59 int fTimeLimit;
60 shared_info* si;
64 #endif