[cpia] USB anyone?

Peter Pregler Peter.Pregler@risc.uni-linz.ac.at
Sun, 16 Jan 2000 14:40:24 +0100 (CET)


On 16-Jan-00 Jochen Scharrlach wrote:
> Peter Pregler writes:
>  > Actually the API of the modules cpia/cpia_pp was designed in a way to
> allow the
>  > addition of the usb stuff. The irq-stuff should not be any problem at all.
> 
> As I said, I didn't took a very close look at it, but it seems that
> the USB-API uses it's own model of buffering (so the IRQ-handler has
> to copy the stuff around), while the PP-code (AFAIR) seems to use the
> IRQ handler only to trigger the rest of the code. Maybe I
> misinterpreted it and everything is handled within cpia_pp.c.

Right now the interrupt handler is only used to notify DMA-transfer ends. And
that is done completly within cpia_pp.c. Have a look at cpia_pp_irq_handler in
cpia_pp.c. There is a api-function to register an additional image-ready
interrupt handler for usage within cpia.c (cpia_pp_registerCallback) which
would be used to implement asynchronous streaming (i.e. the interrupt would
flag a 'image ready' condition) which would be handled by a kernel thread. But
right now the interrupt handling for that case is not correct in the
ppc-driver. So I have removed that code from cpia.c and changed it to
synchronous read. And for that you need no interrupt handling at all.

As for buffering: the camera-frame buffer is allocated in cpia.c and passed to
the parport driver. It is up to your usb-code to grab directly to that buffer
or use your own additional buffer. In the parport case grabbing happens either
directly to that buffer (in PIO mode) or to a special DMA-buffer of PAGE_SIZE
that is copied in the bottom-half interrupt handler (dma_handler) to the actual
camera-frame buffer.

> Another problem is hot-plug: the current cpia.c recognizes only
> cameras that are plugged while the driver is loaded. But the USB-cpias
> can be plugged and unlugged any time (which is quite useful if the
> driver crashes), so the strategy with the two arrays in cpia.c and
> cpia_pp.c to recognize the correct camera won't work. The only elegant
> way would be to hide the lowlevel-stuff somewhere in video_device,
> which makes it necessary to change cpia.c.

That is fine with me as long as it does not blur the destinction between cpia.c
and cpia_XXX.c. I don't mind where internal structures are connected to. Can
you show me some code? Also note that I made sure that I cannot crash the box
if the parport-camera is removed during operation. So cpia.c should be hot-plug
safe. I did quite some testing with that. I guess one should not unplug a
working parport-camera because it might be damaged. But you will not crash the
kernel/driver right now.

-Peter

-------------------------------
Even the thought that a ship was waiting to take him back to Earth
did not wipe out the sense of loss he felt at that moment.
-------------------------------
Email: Peter.Pregler@risc.uni-linz.ac.at
Peter Pregler / RISC, University of Linz, Austria