/pf.c (9daad256ae24e196d376e6d1aa2826466be7ee8f) (2452 bytes) (mode 100644) (type blob)
//author Sylvain Bertrand <digital.ragnarok@gmail.com>
//Protected by GNU Affero GPL v3 with some exceptions.
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/mman.h>
#include <error.h>
#include <sys/epoll.h>
#include <errno.h>
#include <linux/types.h>
#include <alga/pixel_fmts.h>
#include <alga/amd/dce6/dce6.h>
#include <alga/amd/si/ioctl.h>
#define e(m,...) error(0,0,m,##__VA_ARGS__)
#define o(m,...) printf(m "\n",##__VA_ARGS__)
#define unsignedl unsigned long
#define EVTS_MAX 10
int main(int argc, char *argv[])
{
errno=0;
int d_fd=open("/dev/si0", O_RDWR);
if(d_fd==-1){
e("open failed:%s\n",strerror(errno));
return EXIT_FAILURE;
}
errno=0;
int efd=epoll_create1(0);
if(efd==-1){
e("epoll_create:%s",strerror(errno));
return EXIT_FAILURE;
}
struct epoll_event evt;
evt.events=EPOLLIN;
evt.data.fd=d_fd;
errno=0;
int r=epoll_ctl(efd,EPOLL_CTL_ADD,d_fd,&evt);
if(r==-1){
e("epoll_ctl:add driver file descriptor:%s",strerror(errno));
return EXIT_FAILURE;
}
while (1) {
uint8_t idx=strtoul(argv[1],NULL,10);
unsignedl req=_IOW('d',SI_DCE_PF,idx);
errno=0;
r=ioctl(d_fd,req,&idx);
if(r==-1){
e("pf failed:%s",strerror(errno));
return EXIT_FAILURE;
}
struct epoll_event evts[EVTS_MAX];
memset(&evts,0,sizeof(evts));
errno=0;
int fds_n=epoll_wait(efd,&evts[0],EVTS_MAX,-1);
if(fds_n==-1){
e("epoll_wait:%s",strerror(errno));
return EXIT_FAILURE;
}
o("fds_n=%u",fds_n);
int fd=0;
while(1){
if(fd==fds_n) break;
if(evts[fd].data.fd==d_fd){
struct si_evt si_evt;
o("found driver fd");
//XXX:the driver file has no end and read will block if there is no
//event available.
errno=0;
ssize_t rd=read(d_fd,&si_evt,sizeof(si_evt));
o("read one event of %ld bytes",(long)rd);
if(rd==-1){
e("read:%s",strerror(errno));
return EXIT_FAILURE;
}
struct si_evt_pf *si_evt_pf=&si_evt.params.pf;
struct timespec *tp=&si_evt.params.pf.monotonic_raw_tp;
o("pf event on dp%u vblanks_n=0x%08x sec=%lu nsec=%lu",si_evt_pf->idx,
si_evt_pf->vblanks_n,tp->tv_sec,tp->tv_nsec);
}
++fd;
}
}
return EXIT_SUCCESS;
}
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
35123 |
f891bd326c39a671fddfd210c0d951c97674c7c3 |
LICENSE |
100644 |
blob |
405 |
3ed5aa544d933f7b88b648964752e5443c27df85 |
README.md |
100644 |
blob |
2282 |
1c4b0d5ba77ce6e79cbb62295b3e8d15ec7a9689 |
dma_l2l.c |
100644 |
blob |
1746 |
a4d2242bba822dc989ee13598862483e47ab101f |
dma_u32_fill.c |
100644 |
blob |
1260 |
a458be504b627da28249b6787b60d01d7194c32a |
dpm.c |
100644 |
blob |
1653 |
3650ee140eab2d08eee33d9c30072580a4e7e6e8 |
edid.c |
100644 |
blob |
804 |
7d3d87f7d43f8000784ad4bf16ae9d055e177640 |
makefile |
100644 |
blob |
3029 |
77fa08994a1b8edf40a103d2cb73250e7ef49f81 |
modeset.c |
100644 |
blob |
2452 |
9daad256ae24e196d376e6d1aa2826466be7ee8f |
pf.c |
100644 |
blob |
36311 |
fec6dbe39290da3a33e42c89be93646569d10691 |
tri.c |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/sylware/si-user
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/sylware/si-user
Clone this repository using git:
git clone git://git.rocketgit.com/user/sylware/si-user
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main