Why is I2C_SMBUS_BLOCK_MAX limited to 32 bytes?

I am trying to configure a SAA6752HS chip (MPEG-2 encoder) over the I2C bus using a Raspberry Pi as my development kit. It was a piece of cake until I had to write to the 0xC2 address of the chip. For this task, I have to use an I2C command that expects a 189 byte payload. So I stumbled upon the 32 byte limit inside the I2C driver defined by I2C_SMBUS_BLOCK_MAX in / usr / include / linux / i 2c.h. It is not possible to force different values โ€‹โ€‹of the maximum limit. Everything around the I2C lib goes into the i2c_smbus_access function and any request with more than 32 bytes makes the ioctl return -1. I don't know how to debug it so far.

static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
                                     int size, union i2c_smbus_data *data)
{
        struct i2c_smbus_ioctl_data args;

        args.read_write = read_write;
        args.command = command;
        args.size = size;
        args.data = data;
        return ioctl(file,I2C_SMBUS,&args);
}

      

I don't understand why there is such a limitation, given that there are devices that require more than 32 bytes of payload data to operate (e.g. SAA6752HS).

Is there a way to overcome this limitation without rewriting the new driver?

Thanks in advance.

+3


source to share


1 answer


Here's the documentation for the Linux i2c interface: https://www.kernel.org/doc/Documentation/i2c/dev-interface

At its simplest level, you can use ioctl(I2C_SLAVE)

to set the slave address and system call write

to write the command. Something like:



i2c_write(int file, int address, int subaddress, int size, char *data) {
    char buf[size + 1];               // note: variable length array
    ioctl(file, I2C_SLAVE, address);  // real code would need to check for an error
    buf[0] = subaddress;              // need to send everything in one call to write
    memcpy(buf + 1, data, size);      // so copy subaddress and data to a buffer 
    write(file, buf, size + 1); 
}

      

+5


source







All Articles