added i2C readbuf and writebuf routines, added extra check on supported BT/CX encoder type.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14279 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -18,22 +18,26 @@
|
|||||||
*/
|
*/
|
||||||
static uint8 BT_check (uint8 bus, uint8 adress)
|
static uint8 BT_check (uint8 bus, uint8 adress)
|
||||||
{
|
{
|
||||||
/* reset status */
|
uint8 buffer[3];
|
||||||
i2c_flag_error (-1);
|
|
||||||
|
|
||||||
/* do check */
|
buffer[0] = adress + WR;
|
||||||
i2c_bstart(bus);
|
|
||||||
i2c_writebyte(bus, adress + WR);
|
|
||||||
/* set ESTATUS at b'00'; and enable bt chip-outputs
|
/* set ESTATUS at b'00'; and enable bt chip-outputs
|
||||||
* WARNING:
|
* WARNING:
|
||||||
* If bit0 = 0 is issued below (EN_OUT = disabled), the BT will lock SDA
|
* If bit0 = 0 is issued below (EN_OUT = disabled), the BT will lock SDA
|
||||||
* after writing adress $A0 (setting EN_XCLK)!!!
|
* after writing adress $A0 (setting EN_XCLK)!!!
|
||||||
* Until a reboot the corresponding IIC bus will be inacessable then!!! */
|
* Until a reboot the corresponding IIC bus will be inacessable then!!! */
|
||||||
i2c_writebyte(bus, 0xc4);
|
buffer[1] = 0xc4;
|
||||||
/* fixme: if testimage 'was' active txbuffer[3] should become 0x05...
|
/* fixme: if testimage 'was' active txbuffer[3] should become 0x05...
|
||||||
* (currently this cannot be detected in a 'foolproof' way so don't touch...) */
|
* (currently this cannot be detected in a 'foolproof' way so don't touch...) */
|
||||||
/* (ESTATUS b'0x' means: RX ID and VERSION info later..) */
|
/* (ESTATUS b'0x' means: RX ID and VERSION info later..) */
|
||||||
i2c_writebyte(bus, 0x01);
|
buffer[2] = 0x01;
|
||||||
|
|
||||||
|
/* reset status */
|
||||||
|
i2c_flag_error (-1);
|
||||||
|
|
||||||
|
/* do check */
|
||||||
|
i2c_bstart(bus);
|
||||||
|
i2c_writebuffer(bus, buffer, sizeof(buffer));
|
||||||
i2c_bstop(bus);
|
i2c_bstop(bus);
|
||||||
return i2c_flag_error(0);
|
return i2c_flag_error(0);
|
||||||
}
|
}
|
||||||
@@ -41,20 +45,22 @@ static uint8 BT_check (uint8 bus, uint8 adress)
|
|||||||
/* identify chiptype */
|
/* identify chiptype */
|
||||||
static uint8 BT_read_type (void)
|
static uint8 BT_read_type (void)
|
||||||
{
|
{
|
||||||
uint8 id, stat;
|
uint8 id, type, stat;
|
||||||
|
uint8 buffer[3];
|
||||||
|
|
||||||
|
/* Make sure a CX (Conexant) chip (if this turns out to be there) is set to
|
||||||
|
* BT-compatibility mode! (This command will do nothing on a BT chip...) */
|
||||||
|
buffer[0] = si->ps.tv_encoder.adress + WR;
|
||||||
|
/* select CX reg. for BT-compatible readback, video still off */
|
||||||
|
buffer[1] = 0x6c;
|
||||||
|
/* set it up */
|
||||||
|
buffer[2] = 0x02;
|
||||||
|
|
||||||
/* reset status */
|
/* reset status */
|
||||||
i2c_flag_error (-1);
|
i2c_flag_error (-1);
|
||||||
|
|
||||||
//fixme: setup higher level static I2C routines in this file.
|
|
||||||
/* Make sure a CX (Conexant) chip (if this turns out to be there) is set to
|
|
||||||
* BT-compatibility mode! (This command will do nothing on a BT chip...) */
|
|
||||||
i2c_bstart(si->ps.tv_encoder.bus);
|
i2c_bstart(si->ps.tv_encoder.bus);
|
||||||
i2c_writebyte(si->ps.tv_encoder.bus, si->ps.tv_encoder.adress + WR);
|
i2c_writebuffer(si->ps.tv_encoder.bus, buffer, sizeof(buffer));
|
||||||
/* select CX reg. for BT-compatible readback, video still off */
|
|
||||||
i2c_writebyte(si->ps.tv_encoder.bus, 0x6c);
|
|
||||||
/* set it up */
|
|
||||||
i2c_writebyte(si->ps.tv_encoder.bus, 0x02);
|
|
||||||
i2c_bstop(si->ps.tv_encoder.bus);
|
i2c_bstop(si->ps.tv_encoder.bus);
|
||||||
/* abort on errors */
|
/* abort on errors */
|
||||||
stat = i2c_flag_error(0);
|
stat = i2c_flag_error(0);
|
||||||
@@ -75,9 +81,17 @@ static uint8 BT_read_type (void)
|
|||||||
stat = i2c_flag_error(0);
|
stat = i2c_flag_error(0);
|
||||||
if (stat) return stat;
|
if (stat) return stat;
|
||||||
|
|
||||||
|
/* check type to be supported one */
|
||||||
|
type = (id & 0xe0) >> 5;
|
||||||
|
if (type > 3)
|
||||||
|
{
|
||||||
|
LOG(4,("Brooktree: Found unsupported encoder type %d, aborting.\n", type));
|
||||||
|
return 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
/* inform driver about TV encoder found */
|
/* inform driver about TV encoder found */
|
||||||
si->ps.tvout = true;
|
si->ps.tvout = true;
|
||||||
si->ps.tv_encoder.type = BT868 + ((id & 0xe0) >> 5);
|
si->ps.tv_encoder.type = BT868 + type;
|
||||||
si->ps.tv_encoder.version = id & 0x1f;
|
si->ps.tv_encoder.version = id & 0x1f;
|
||||||
|
|
||||||
return stat;
|
return stat;
|
||||||
@@ -142,9 +156,15 @@ bool BT_probe()
|
|||||||
uint8 cnt = 0;
|
uint8 cnt = 0;
|
||||||
while ((stat = BT_read_type()) && (cnt < 3))
|
while ((stat = BT_read_type()) && (cnt < 3))
|
||||||
{
|
{
|
||||||
|
/* don't retry on unsupported chiptype */
|
||||||
|
if (stat == 0x80)
|
||||||
|
{
|
||||||
|
btfound = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
if (stat)
|
if (stat & 0x7f)
|
||||||
{
|
{
|
||||||
LOG(4,("Brooktree: too much errors occurred, aborting.\n"));
|
LOG(4,("Brooktree: too much errors occurred, aborting.\n"));
|
||||||
btfound = 0;
|
btfound = 0;
|
||||||
|
|||||||
@@ -262,6 +262,26 @@ bool i2c_writebyte (uint8 BusNR, uint8 byte)
|
|||||||
return bit;
|
return bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void i2c_readbuffer (uint8 BusNR, uint8* buf, uint8 size)
|
||||||
|
{
|
||||||
|
uint8 cnt;
|
||||||
|
|
||||||
|
for (cnt = 0; cnt < size; cnt++)
|
||||||
|
{
|
||||||
|
buf[cnt] = i2c_readbyte(BusNR, buf[cnt]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void i2c_writebuffer (uint8 BusNR, uint8* buf, uint8 size)
|
||||||
|
{
|
||||||
|
uint8 cnt;
|
||||||
|
|
||||||
|
for (cnt = 0; cnt < size; cnt++)
|
||||||
|
{
|
||||||
|
i2c_writebyte(BusNR, buf[cnt]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
status_t i2c_init(void)
|
status_t i2c_init(void)
|
||||||
{
|
{
|
||||||
uint8 bus;
|
uint8 bus;
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ void i2c_bstart (uint8 BusNR);
|
|||||||
void i2c_bstop (uint8 BusNR);
|
void i2c_bstop (uint8 BusNR);
|
||||||
uint8 i2c_readbyte(uint8 BusNR, bool Ack);
|
uint8 i2c_readbyte(uint8 BusNR, bool Ack);
|
||||||
bool i2c_writebyte (uint8 BusNR, uint8 byte);
|
bool i2c_writebyte (uint8 BusNR, uint8 byte);
|
||||||
|
void i2c_readbuffer (uint8 BusNR, uint8* buf, uint8 size);
|
||||||
|
void i2c_writebuffer (uint8 BusNR, uint8* buf, uint8 size);
|
||||||
status_t i2c_init(void);
|
status_t i2c_init(void);
|
||||||
|
|
||||||
/* card info functions */
|
/* card info functions */
|
||||||
|
|||||||
Reference in New Issue
Block a user