diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-02-22 23:27:15 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-04-16 23:40:56 +0200 |
commit | 558ba6935cc99188018bff9c43a701a291b1aafc (patch) | |
tree | 1e6afb111a85c6c6d99d64cfeea457a1f1ff4fc6 | |
parent | 74fe31ca9a338ed6874e072e5f750f9c59f7b329 (diff) |
Add support for exception events
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | events.c | 18 | ||||
-rw-r--r-- | events.h | 1 |
2 files changed, 16 insertions, 3 deletions
@@ -67,6 +67,9 @@ void events_watch_fd(struct events *events, int fd, case OMAP3_ISP_EVENT_WRITE: FD_SET(fd, &events->wfds); break; + case OMAP3_ISP_EVENT_EXCEPTION: + FD_SET(fd, &events->efds); + break; } events->maxfd = max(events->maxfd, fd); @@ -97,6 +100,9 @@ void events_unwatch_fd(struct events *events, int fd) case OMAP3_ISP_EVENT_WRITE: FD_CLR(fd, &events->wfds); break; + case OMAP3_ISP_EVENT_EXCEPTION: + FD_CLR(fd, &events->efds); + break; } events->maxfd = maxfd; @@ -106,7 +112,7 @@ void events_unwatch_fd(struct events *events, int fd) } static void events_dispatch(struct events *events, const fd_set *rfds, - const fd_set *wfds) + const fd_set *wfds, const fd_set *efds) { struct event_fd *event; @@ -117,6 +123,9 @@ static void events_dispatch(struct events *events, const fd_set *rfds, if (event->type == OMAP3_ISP_EVENT_WRITE && FD_ISSET(event->fd, wfds)) event->callback(event->priv); + if (event->type == OMAP3_ISP_EVENT_EXCEPTION && + FD_ISSET(event->fd, efds)) + event->callback(event->priv); } } @@ -126,14 +135,16 @@ bool events_loop(struct events *events) struct timeval timeout; fd_set rfds; fd_set wfds; + fd_set efds; int ret; timeout.tv_sec = SELECT_TIMEOUT / 1000; timeout.tv_usec = (SELECT_TIMEOUT % 1000) * 1000; rfds = events->rfds; wfds = events->wfds; + efds = events->efds; - ret = select(events->maxfd + 1, &rfds, &wfds, NULL, &timeout); + ret = select(events->maxfd + 1, &rfds, &wfds, &efds, &timeout); if (ret < 0) { /* EINTR means that a signal has been received, continue * to the next iteration in that case. @@ -153,7 +164,7 @@ bool events_loop(struct events *events) break; } - events_dispatch(events, &rfds, &wfds); + events_dispatch(events, &rfds, &wfds, &efds); } return !events->done; @@ -170,6 +181,7 @@ void events_init(struct events *events) FD_ZERO(&events->rfds); FD_ZERO(&events->wfds); + FD_ZERO(&events->efds); events->maxfd = 0; list_init(&events->events); } @@ -35,6 +35,7 @@ struct events { int maxfd; fd_set rfds; fd_set wfds; + fd_set efds; }; void events_watch_fd(struct events *events, int fd, |