Page MenuHomeFreeBSD

linux: add Linux i2c-dev ioctl compatibility support
ClosedPublic

Authored by mr.yaoxin_outlook.com on Sat, Apr 4, 6:16 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 25, 4:24 AM
Unknown Object (File)
Tue, Apr 21, 12:45 AM
Unknown Object (File)
Mon, Apr 20, 12:51 PM
Unknown Object (File)
Mon, Apr 20, 6:51 AM
Unknown Object (File)
Sun, Apr 19, 10:58 AM
Unknown Object (File)
Sat, Apr 18, 11:25 AM
Unknown Object (File)
Sat, Apr 18, 8:45 AM
Unknown Object (File)
Sat, Apr 18, 5:20 AM
Subscribers

Details

Summary

Implement Linux I2C ioctl translation in the Linux compatibility layer
and wire iicbus cdevs up for in-kernel rdwr handling.
Support common i2c-dev requests including SLAVE, FUNCS, and RDWR,
while rejecting unsupported 10-bit and SMBus operations.

Signed-off-by: YAO, Xin <mr.yaoxin@outlook.com>

This change is for Linux application to communicate with monitor using DDC/CI interface (I2C) on FreeBSD.

Test Plan

can be tested by this tool https://github.com/ilovegrape/ddcci and the output is as below.

root@test:~ # ./DellDevice
i2c_write: ioctl returned -1, ioctl() error No such device or address
Reading EDID 0x50@/dev/iic0 failed.
Failed to get monitor info from /dev/iic0
i2c_write: ioctl returned -1, ioctl() error No such device or address
Reading EDID 0x50@/dev/iic1 failed.
Failed to get monitor info from /dev/iic1
0000: 00 ff ff ff ff ff ff 00 10 ac df 42 4c 50 35 48 | ...........BLP5H
0010: 0f 21 01 04 b5 3c 22 78 39 62 a5 ad 50 46 ab 24 | .!...<"x9b..PF.$
0020: 0e 50 54 a5 4b 00 71 4f 81 80 a9 40 d1 c0 81 c0 | .PT.K.qO...@....
0030: a9 c0 01 01 01 01 56 5e 00 a0 a0 a0 29 50 30 20 | ......V^....)P0
0040: 35 00 55 50 21 00 00 1a 00 00 00 ff 00 43 4e 30 | 5.UP!........CN0
0050: 37 33 4b 30 0a 20 20 20 20 20 00 00 00 fc 00 44 | 73K0.     .....D
0060: 45 4c 4c 20 55 32 37 32 34 44 45 0a 00 00 00 fd | ELL U2724DE.....
0070: 00 30 78 b2 b2 3c 01 0a 20 20 20 20 20 20 01 ad | .0x..<..      ..
isDellDevice: DEL
Control 0xc8: +/38921/39
Control 0xc9: +/16645/65535
Control 0xfd: +/116/255
Fetched value: C8_value = 38921, C9_value = 16645, FD_value = 116
getScalar(C8_value = 38921) = "3"
getSICode(FD_value = 116) = "T"
getFWStage_H(C9_value = 16645) = "M"
   C9High = "1"
getFWStage_L(C9_value = 16645, FD_value = 116) = "05"
Model = DELL U2724DE
Serial = CN073K0
Firmware Version = M3T105
/dev/iic10: Model = U2724DE, Serial = CN073K0, Firmware Version = M3T105
i2c_write: ioctl returned -1, ioctl() error Connection timed out
Reading EDID 0x50@/dev/iic11 failed.
Failed to get monitor info from /dev/iic11
i2c_write: ioctl returned -1, ioctl() error No such device or address
Reading EDID 0x50@/dev/iic2 failed.
Failed to get monitor info from /dev/iic2
i2c_write: ioctl returned -1, ioctl() error Resource temporarily unavailable
Reading EDID 0x50@/dev/iic3 failed.
Failed to get monitor info from /dev/iic3
i2c_write: ioctl returned -1, ioctl() error Resource temporarily unavailable
Reading EDID 0x50@/dev/iic4 failed.
Failed to get monitor info from /dev/iic4
i2c_write: ioctl returned -1, ioctl() error Resource temporarily unavailable
Reading EDID 0x50@/dev/iic5 failed.
Failed to get monitor info from /dev/iic5
i2c_write: ioctl returned -1, ioctl() error Resource temporarily unavailable
Reading EDID 0x50@/dev/iic6 failed.
Failed to get monitor info from /dev/iic6
i2c_write: ioctl returned -1, ioctl() error Resource temporarily unavailable
Reading EDID 0x50@/dev/iic7 failed.
Failed to get monitor info from /dev/iic7
i2c_write: ioctl returned -1, ioctl() error Resource temporarily unavailable
Reading EDID 0x50@/dev/iic8 failed.
Failed to get monitor info from /dev/iic8
i2c_write: ioctl returned -1, ioctl() error Connection timed out
Reading EDID 0x50@/dev/iic9 failed.
Failed to get monitor info from /dev/iic9

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 71959
Build 68842: arc lint + arc unit

Event Timeline

pouria edited the test plan for this revision. (Show Details)
pouria added reviewers: linuxkpi, imp, emaste, phk, wulf.
adrian added a subscriber: adrian.

nice work!

This revision is now accepted and ready to land.Sun, Apr 12, 3:40 AM

Hi @pouria

Since both imp and adrian accepted this revision, could you please help me or find some one to submit the change?

Thank you for your support on it~

Regards,
Xin

Thank you @adrian and @imp for the help on the review and @pouria for the next step