The Camera Device Interface I2C Programmer API encompasses all I2C related functions for programming all I2C controlled components such as deserializers, serializers, EEPROMs, and image sensors.
Data Structures | |
struct | DevBlkCDII2CReg |
Defines the I2C address/data pair and an optional delay. More... | |
struct | DevBlkCDII2CRegList |
Defines the I2C register table to write to the device. More... | |
struct | DevBlkCDII2CRegListWritable |
Defines the I2C register table to read from the device. More... | |
Macros | |
#define | I2C_ARRAY_SIZE(x) (uint32_t)(sizeof(x) / sizeof((x)[0])) |
Macro for determining the number of address/data pairs in a register table. More... | |
Typedefs | |
typedef void * | DevBlkCDII2CPgmr |
An opaque handle for an I2C programmer object. More... | |
Functions | |
DevBlkCDII2CPgmr | DevBlkCDII2CPgmrCreate (DevBlkCDIDevice *handle, const uint8_t addrLength, const uint8_t dataLength) |
Creates an I2C Programmer to read/write I2C registers of a device. More... | |
void | DevBlkCDII2CPgmrDestroy (DevBlkCDII2CPgmr i2cProgrammer) |
Destroys an I2C Programmer. More... | |
NvMediaStatus | DevBlkCDII2CPgmrWriteUint8 (DevBlkCDII2CPgmr i2cProgrammer, const uint16_t address, const uint8_t data) |
Writes 8-bit data to an I2C register. More... | |
NvMediaStatus | DevBlkCDII2CPgmrWriteUint16 (DevBlkCDII2CPgmr i2cProgrammer, const uint16_t address, const uint16_t data) |
Writes 16-bit data to an I2C register. More... | |
NvMediaStatus | DevBlkCDII2CPgmrReadUint8 (DevBlkCDII2CPgmr i2cProgrammer, const uint16_t address, uint8_t *data) |
Reads 8-bit data from an I2C register. More... | |
NvMediaStatus | DevBlkCDII2CPgmrReadUint16 (DevBlkCDII2CPgmr i2cProgrammer, const uint16_t address, uint16_t *data) |
Reads 16-bit data from an I2C register. More... | |
NvMediaStatus | DevBlkCDII2CPgmrWriteArray (DevBlkCDII2CPgmr i2cProgrammer, const DevBlkCDII2CRegList *regList) |
Performs write operation for a register table. More... | |
NvMediaStatus | DevBlkCDII2CPgmrReadArray (DevBlkCDII2CPgmr i2cProgrammer, const DevBlkCDII2CRegListWritable *regList) |
Performs read operation for a register table. More... | |
NvMediaStatus | DevBlkCDII2CPgmrReadBlock (DevBlkCDII2CPgmr i2cProgrammer, const uint16_t address, const uint16_t dataLength, uint8_t *dataBuff) |
Reads a block of data from I2C device. More... | |
NvMediaStatus | DevBlkCDII2CPgmrDumpArray (DevBlkCDII2CPgmr i2cProgrammer, const DevBlkCDII2CRegList *regList) |
Dumps the values for all registers in the register table. More... | |
NvMediaStatus | DevBlkCDII2CPgmrDebugLogControl (DevBlkCDII2CPgmr i2cProgrammer, NvMediaBool enable) |
Enables debug logs for I2C Programmer. More... | |
#define I2C_ARRAY_SIZE | ( | x | ) | (uint32_t)(sizeof(x) / sizeof((x)[0])) |
Macro for determining the number of address/data pairs in a register table.
This macro should be used by the device driver to set DevBlkCDII2CRegList::numRegs.
Do not use this macro when referencing register tables through pointers, otherwise the wrong number of address/data pairs will be returned.
Definition at line 36 of file devblk_cdi_i2c.h.
typedef void* DevBlkCDII2CPgmr |
An opaque handle for an I2C programmer object.
Definition at line 92 of file devblk_cdi_i2c.h.
DevBlkCDII2CPgmr DevBlkCDII2CPgmrCreate | ( | DevBlkCDIDevice * | handle, |
const uint8_t | addrLength, | ||
const uint8_t | dataLength | ||
) |
Creates an I2C Programmer to read/write I2C registers of a device.
This API does the following:
[in] | handle | A pointer to the device that needs I2C access; Valid value: [non-NULL]. |
[in] | addrLength | I2C register address length in bytes; Valid range: [1, 2]. |
[in] | dataLength | I2C register data length in bytes; Valid range: [1, 2]. |
Usage considerations
NvMediaStatus DevBlkCDII2CPgmrDebugLogControl | ( | DevBlkCDII2CPgmr | i2cProgrammer, |
NvMediaBool | enable | ||
) |
Enables debug logs for I2C Programmer.
[in] | i2cProgrammer | Device handle for I2C Programmer. |
[in] | enable | flag to enable/disable debug logs. |
NVMEDIA_STATUS_OK | If enable/disable debug log is successful. |
NVMEDIA_STATUS_BAD_PARAMETER | If one or more params was NULL or invalid. |
Usage considerations
void DevBlkCDII2CPgmrDestroy | ( | DevBlkCDII2CPgmr | i2cProgrammer | ) |
Destroys an I2C Programmer.
This API does the following:
[in] | i2cProgrammer | An opaque handle for I2C Programmer to destroy. Valid value: [non-NULL]. |
Usage considerations
NvMediaStatus DevBlkCDII2CPgmrDumpArray | ( | DevBlkCDII2CPgmr | i2cProgrammer, |
const DevBlkCDII2CRegList * | regList | ||
) |
Dumps the values for all registers in the register table.
The register table consists of multiple register address/data pairs. This function will dump the I2C regsister value for each address/data pair for debugging purpose.
[in] | i2cProgrammer | An opaque handle for I2C Programmer. |
[in] | regList | Pointer to the register table. |
NVMEDIA_STATUS_OK | If read from register is successful. |
NVMEDIA_STATUS_BAD_PARAMETER | If one or more params was NULL or invalid. |
NVMEDIA_STATUS_ERROR | If the devctl IPC call to CDAC device node failed. |
Usage considerations
NvMediaStatus DevBlkCDII2CPgmrReadArray | ( | DevBlkCDII2CPgmr | i2cProgrammer, |
const DevBlkCDII2CRegListWritable * | regList | ||
) |
Performs read operation for a register table.
This function calls CDAC to read each of the registers in a register table.
The register table consists of multiple register address/data pairs. This function will use the address/data pair information to read a sequence of I2C register values. To improve efficiency, this function batches reads from the hardware in one of two situations:
[in] | i2cProgrammer | An opaque handle for I2C Programmer; Valid value: [non-NULL]. |
[out] | regList | A pointer to the writable register table. Valid value: [non-NULL]. |
NVMEDIA_STATUS_OK | If read from register is successful. |
NVMEDIA_STATUS_BAD_PARAMETER | If one or more params was NULL or invalid. |
NVMEDIA_STATUS_ERROR | If the devctl IPC call to CDAC device node failed. |
Usage considerations
NvMediaStatus DevBlkCDII2CPgmrReadBlock | ( | DevBlkCDII2CPgmr | i2cProgrammer, |
const uint16_t | address, | ||
const uint16_t | dataLength, | ||
uint8_t * | dataBuff | ||
) |
Reads a block of data from I2C device.
This function calls CDAC to read data from consecutive register addresses. It is best used for reading a block of data from devices like EEPROM.
To improve performance, this function performs the I2C bulk read operation, by specifying the starting address and the length of data in bytes.
[in] | i2cProgrammer | An opaque handle for I2C Programmer; Valid value: [non-NULL]. |
[in] | address | 16-bit register address; Valid range: [0, UINT16_MAX]. |
[in] | dataLength | Size of the data to read; Valid range: [1, MAX_CDAC_I2C_BUFFER]. |
[out] | dataBuff | A pointer to a buffer that must be bigger than dataLength bytes to hold all the read values from the device; Valid value: [non-NULL]. |
NVMEDIA_STATUS_OK | If read from register is successful. |
NVMEDIA_STATUS_BAD_PARAMETER | If one or more params was NULL or invalid. |
NVMEDIA_STATUS_ERROR | If the devctl IPC call to CDAC device node failed. |
Usage considerations
NvMediaStatus DevBlkCDII2CPgmrReadUint16 | ( | DevBlkCDII2CPgmr | i2cProgrammer, |
const uint16_t | address, | ||
uint16_t * | data | ||
) |
Reads 16-bit data from an I2C register.
This API does the following:
[in] | i2cProgrammer | An opaque handle for I2C Programmer; Valid value: [non-NULL]. |
[in] | address | 16-bit register address; Valid range: [0, UINT16_MAX]. |
[out] | data | A pointer to a 16-bit buffer that holds the read value; Valid value: [non-NULL]. |
NVMEDIA_STATUS_OK | If read from register is successful. |
NVMEDIA_STATUS_BAD_PARAMETER | If one or more params was NULL or invalid. |
NVMEDIA_STATUS_ERROR | If the devctl IPC call to CDAC device node failed. |
Usage considerations
NvMediaStatus DevBlkCDII2CPgmrReadUint8 | ( | DevBlkCDII2CPgmr | i2cProgrammer, |
const uint16_t | address, | ||
uint8_t * | data | ||
) |
Reads 8-bit data from an I2C register.
This API does the following:
[in] | i2cProgrammer | An opaque handle for I2C Programmer; Valid value: [non-NULL]. |
[in] | address | 16-bit register address; Valid range: [0, UINT16_MAX]. |
[out] | data | A pointer to an 8-bit buffer that holds the read value; Valid value: [non-NULL]. |
NVMEDIA_STATUS_OK | If read from register is successful. |
NVMEDIA_STATUS_BAD_PARAMETER | If one or more params was NULL or invalid. |
NVMEDIA_STATUS_ERROR | If the devctl IPC call to CDAC device node failed. |
Usage considerations
NvMediaStatus DevBlkCDII2CPgmrWriteArray | ( | DevBlkCDII2CPgmr | i2cProgrammer, |
const DevBlkCDII2CRegList * | regList | ||
) |
Performs write operation for a register table.
This function calls CDAC to write each of the registers in a register table.
The register table consists of multiple register address/data pairs. This function will use the address/data pair information to program a sequence of I2C registers. To improve efficiency, this function batches writes and flushes them to the hardware in one of three situations:
delayUsec
> 0. In this case the batch is immediately flushed and the thread is put to sleep for the specified time.[in] | i2cProgrammer | An opaque handle for I2C Programmer; Valid value: [non-NULL]. |
[in] | regList | A pointer to the register table; Valid value: [non-NULL]. |
NVMEDIA_STATUS_OK | If write to register is successful. |
NVMEDIA_STATUS_BAD_PARAMETER | If one or more params was NULL or invalid. |
NVMEDIA_STATUS_ERROR | If the devctl IPC call to CDAC device node failed. |
Usage considerations
NvMediaStatus DevBlkCDII2CPgmrWriteUint16 | ( | DevBlkCDII2CPgmr | i2cProgrammer, |
const uint16_t | address, | ||
const uint16_t | data | ||
) |
Writes 16-bit data to an I2C register.
This API does the following:
[in] | i2cProgrammer | An opaque handle for I2C Programmer; Valid value: [non-NULL]. |
[in] | address | 16-bit register address; Valid range: [0, UINT16_MAX]. |
[in] | data | 16-bit register data; Valid range: [0, UINT16_MAX]. |
NVMEDIA_STATUS_OK | If write to register is successful. |
NVMEDIA_STATUS_BAD_PARAMETER | If one or more params was NULL or invalid. |
NVMEDIA_STATUS_ERROR | If the devctl IPC call to CDAC device node failed. |
Usage considerations
NvMediaStatus DevBlkCDII2CPgmrWriteUint8 | ( | DevBlkCDII2CPgmr | i2cProgrammer, |
const uint16_t | address, | ||
const uint8_t | data | ||
) |
Writes 8-bit data to an I2C register.
This API does the following:
[in] | i2cProgrammer | An opaque handle for I2C Programmer; Valid value: [non-NULL]. |
[in] | address | 16-bit register address; Valid range: [0, UINT16_MAX]. |
[in] | data | 8-bit register data; Valid range: [0, UINT8_MAX] |
NVMEDIA_STATUS_OK | If write to register is successful. |
NVMEDIA_STATUS_BAD_PARAMETER | If one or more params was NULL or invalid. |
NVMEDIA_STATUS_ERROR | If the devctl IPC call to CDAC device node failed. |
Usage considerations