-
Notifications
You must be signed in to change notification settings - Fork 0
/
edid.c
58 lines (51 loc) · 1003 Bytes
/
edid.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Copyright (c) 2014 Charles-Henri Mousset
* Distributed under the GNU GPL v2. For full terms see the file LICENSE
*/
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/i2c-dev.h>
int main(int argc, char const *argv[])
{
int file;
int len = 256;
unsigned char buffer[len];
if (argc != 2)
{
printf("Usage:\nedid.bin /dev/i2c");
exit(1);
}
if ((file = open(argv[1],O_RDWR)) < 0) {
printf("Failed to open the bus %s\n", argv[1]);
exit(1);
}
// connect to EID chip
if (ioctl(file, I2C_SLAVE, 0x50) < 0)
{
printf("Cannot init chip address\n");
exit(1);
}
if (read(file, buffer, len) != len)
{
printf("error : %s\n", strerror(errno));
exit(1) ;
}
close(file);
int i, j;
printf("DATAT :\n");
for (i=0; i<len; i++)
{
if((i%16) == 0)
printf("\n");
printf("%02X ", buffer[i]);
}
printf("\n");
return 0;
}