Move dpcd_(read/write) to igt_dpcd
Subsystems (2)
cover Move dpcd_(read/write) to igt_dpcd
tests can use dpcd_read and dpcd_write for many use cases one such use case is reading crc present at below address
DP_TEST_CRC_R_CR 0x240DP_TEST_CRC_G_Y 0x242DP_TEST_CRC_B_CB 0x244
Kunal Joshi (2):
lib/igt_dpcd: move dpcd_read and dpcd_write to lib lib/meson.build: Add igt_dpcd for compilation
lib/igt_dpcd.c | 47 +++++++++++++++++++++++++++++++++++++ lib/igt_dpcd.h | 19 +++++++++++++++ lib/meson.build | 5 ++++ tools/dpcd_reg.c | 60 +----------------------------------------------- 4 files changed, 72 insertions(+), 59 deletions(-) create mode 100644 lib/igt_dpcd.c create mode 100644 lib/igt_dpcd.h
Signature · 1 line
2.25.1
PATCH 1/2 lib/igt_dpcd: move dpcd_read and dpcd_write to lib
moved dpcd_read and dpcd_write to lib/igt_dpcd
Signed-off-by Kunal Joshi <[email protected]>
Reviewed-by Bhanuprakash Modem <[email protected]>
--- lib/igt_dpcd.c | 47 +++++++++++++++++++++++++++++++++++++ lib/igt_dpcd.h | 19 +++++++++++++++ tools/dpcd_reg.c | 60 +----------------------------------------------- 3 files changed, 67 insertions(+), 59 deletions(-) create mode 100644 lib/igt_dpcd.c create mode 100644 lib/igt_dpcd.h
lib/igt_dpcd.c new file +47 -0
@@ -0,0 +1,47 @@ +#include "igt_dpcd.h" + +int dpcd_read (int fd,uint32_t offset,size_t count) +{ +int ret =EXIT_SUCCESS ; +uint8_t *buf =calloc (count,sizeof (uint8_t )); +ssize_t bytes_read; + +if (!buf) { +fprintf (stderr,"Can't allocate read buffer\n" ); +return ENOMEM ; + } + + bytes_read =pread (fd, buf, count, offset); + +if (bytes_read <0 ) { +fprintf (stderr,"Failed to read - %s\n" ,strerror (errno)); + ret = errno; + }else { +printf ("0x%04x: " , offset); +for (ssize_t i =0 ; i < bytes_read; i++) { +printf (" %02x" , buf[i]); + } +printf ("\n" ); + } + +free (buf); +return ret; +} + +int dpcd_write (int fd,uint32_t offset,uint8_t val) +{ +int ret =EXIT_SUCCESS ; +ssize_t bytes_written; + + bytes_written =pwrite (fd, &val,sizeof (uint8_t ), offset); + +if (bytes_written <0 ) { +fprintf (stderr,"Failed to write - %s\n" ,strerror (errno)); + ret = errno; + }else if (bytes_written ==0 ) { +fprintf (stderr,"Zero bytes were written\n" ); + ret =EXIT_FAILURE ; + } + +return ret; +}
lib/igt_dpcd.h new file +19 -0
@@ -0,0 +1,19 @@ +#ifndef IGT_DPCD_H +#define IGT_DPCD_H + +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <stdlib.h> +#include <fcntl.h> +#include <getopt.h> +#include <stdint.h> +#include <unistd.h> +#include <limits.h> +#include <stdbool.h> +#include <stdint.h> + +int dpcd_read (int fd,uint32_t offset,size_t count); +int dpcd_write (int fd,uint32_t offset,uint8_t val); + +#endif /* IGT_DPCD_H */
tools/dpcd_reg.c +1 -59
72 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/2 lib/meson.build: Add igt_dpcd for compilation
In reply to Kunal JoshiAdded igt_dpcd in meson.build for compilation
Signed-off-by Kunal Joshi <[email protected]>
Reviewed-by Bhanuprakash Modem <[email protected]>
--- lib/meson.build | 5 +++++ 1 file changed, 5 insertions(+)
lib/meson.build +5 -0
@@ -24,6 +24,7 @@ lib_sources = [ 'igt_device_scan.c', 'igt_drm_clients.h', 'igt_drm_fdinfo.c', + 'igt_dpcd.c', 'igt_aux.c', 'igt_gt.c', 'igt_halffloat.c',
@@ -254,6 +255,10 @@ lib_igt_perf_build = static_library('igt_perf', lib_igt_perf = declare_dependency(link_with : lib_igt_perf_build, include_directories : inc) +lib_igt_dpcd = static_library('igt_dpcd', + ['igt_dpcd.c'], + include_directories : inc) + scan_dep = [ glib, libudev,
Signature · 1 line
2.25.1