xref: /haiku/src/add-ons/media/media-add-ons/radeon/I2CPort.h (revision 17889a8c70dbb3d59c1412f6431968753c767bab)
1 /******************************************************************************
2 /
3 /	File:			I2C.h
4 /
5 /	Description:	ATI Radeon I2C Serial Bus interface.
6 /
7 /	Copyright 2001, Carlos Hasan
8 /
9 *******************************************************************************/
10 
11 #ifndef __I2C_PORT_H__
12 #define __I2C_PORT_H__
13 
14 #include "Radeon.h"
15 
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
20 };
21 
22 class CI2CPort {
23 public:
24 	CI2CPort(CRadeon & radeon, int rate = C_RADEON_I2C_DEFAULT_CLOCK_RATE);
25 
26 	~CI2CPort();
27 
28 	status_t InitCheck() const;
29 
30 	CRadeon & Radeon() const;
31 
32 	bool Probe(int address);
33 
34 public:
35 	bool Write(int address, const char * buffer, int length);
36 
37 	bool Read(int address, char * buffer, int length);
38 
39 	bool Write(int address, const char * buffer, int length, char * output, int outlen);
40 
41 public:
42 	int Register(int address, int index);
43 
44 	void SetRegister(int address, int index, int value);
45 
46 private:
47 	int Send(int address, const char * buffer, int length, bool start, bool stop);
48 
49 	int Receive(int address, char * buffer, int length, bool start, bool stop);
50 
51 	int WaitAck();
52 
53 	void Stop();
54 
55 private:
56 	CRadeon & fRadeon;
57 	int fNfactor;
58 	int fMfactor;
59 	int fTimeLimit;
60 	shared_info* si;
61 };
62 
63 
64 #endif
65