Ignore:
Timestamp:
01/03/09 11:35:00 (3 years ago)
Author:
alonbl
Message:

Support event mode for drivers

Current implementation forces poll loop every one second or so,
this consume CPU and power.

This changeset adds the ability for a driver to provide file
descriptor for event handling, removing the need to poll.

Only Linux USB interface was modified to use this new interface.

All other environments will fall-back into the poll mode.

New driver methods:

before_command

Executed before command, makes it easy to remove event capture.

after_command

Execute after command, makes it easy to add event capture.

get_eventfd

Get an event fd out of the driver, if unsupported -1 should
be returned, this fall-back into the poll mode.

event

Event method to call with th evntfd is signaled.

before_command

Execute whatever needed before executing a command. Useful
if driver need to turn off event capture.

after_command

Execute whatever needed before blocking. Useful if driver
need to turn on event capture.

New device methods:

get_eventfd

Gets eventfd if available.

New USB methods:

ifd_usb_get_eventfd

Get event fd to poll for events.

ifd_usb_capture_event

None blocking capture.

New CT socket methods:

error

Called with POLLERR is received.

New configuration file options:

force_poll

Force polling, default is true (as correct behavior),
until Linux kernel will resolve its issues.

New command-line options:

ifdhandler -p

Force polling.

Linux specific notes:

This enable safe detection of device removal and allow USB drivers
to stop polling device, even if they do not have interrupt interface.

As OpenCT uses /dev/bus/usb namespace if exists, and this feature worked
only on usbfs prior to linux-2.6.28, it will not work with older kernels.

linux-2.6.28 has a bug that cause the signal not to be sent if kernel
is configured without CONFIG_USB_DEVICEFS, see [1].

linux-2.6.29 is expected to solve this issue.

Even if ccid driver works correctly, as it uses interrupt endpoint,
by default polling will be forced.

[1]  http://marc.info/?t=123075926900001&r=1&w=2

M src/ifd/ifdhandler.c
M src/ifd/utils.c
M src/ifd/process.c
M src/ifd/sys-osx.c
M src/ifd/sys-null.c
M src/ifd/device.c
M src/ifd/internal.h
M src/ifd/usb.c
M src/ifd/reader.c
M src/ifd/sys-linux.c
M src/ifd/sys-bsd.c
M src/ifd/sys-solaris.c
M src/ifd/sys-sunray.c
M src/include/openct/driver.h
M src/include/openct/device.h
M src/include/openct/ifd.h
M src/include/openct/socket.h
M src/ct/mainloop.c
M etc/openct.conf.in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ifd/sys-bsd.c

    r1051 r1114  
    148148} 
    149149 
     150int ifd_sysdep_usb_get_eventfd(ifd_device_t * dev) 
     151{ 
     152        return -1; 
     153} 
     154 
    150155/* 
    151156 * USB URB capture 
     
    183188        *capret = cap; 
    184189        return 0; 
     190} 
     191 
     192int ifd_sysdep_usb_capture_event(ifd_device_t * dev, ifd_usb_capture_t * cap, 
     193                           void *buffer, size_t len) 
     194{ 
     195        return IFD_ERROR_NOT_SUPPORTED; 
    185196} 
    186197 
Note: See TracChangeset for help on using the changeset viewer.