*BSD News Article 18113


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!pacbell.com!uop!usenet
From: hughes@napa.eng.uop.edu (Ken Hughes)
Newsgroups: comp.os.386bsd.development
Subject: writing a device driver for an interruptless controller
Date: 8 Jul 1993 16:53:53 GMT
Organization: Electrical and Computer Engineering, University of the Pacific
Lines: 51
Distribution: world
Message-ID: <21hjf1$dki@unix1.cc.uop.edu>
NNTP-Posting-Host: napa.eng.uop.edu

I've got a frame grabber card which I've been trying to write some code for
and, for other reasons, avoid writing a device driver for at this time.
However due to the nature of the card I don't think I can get around putting
the code in the kernel.

My concern now is this; the frame grabber doesn't generate any IRQ interrupts.  
The pseudo-code for capturing an frame (which works under MS-DOS) looks like
this: 

    poll for vertical retrace by reading status port;
    write to output port to start capture;
    for (i = 0 ; i < 2 ; ++ )
    {
	write brighness parameter to data port;
	write strobe to control port;
	wait X microseconds;
	write contrast parameter to data port;
	write strobe to control port;
	wait X microseconds;
	clear strobe from control port;
	poll for vertical retrace by reading status port;
    }
    write to output port to end capture;

This loop executes twice because the video image is interlaced (ie, I get the
even numbered lines in the image on one pass, the odd the next). Each
iteration of the loop takes appx 1/60 of a second.  The wait for the strobes
is relatively short.  The real problem is the second poll at the end of
the loop.

A program under 386bsd following this same structure doesn't work correctly
due to, I assume, context switches which throw off the timing.  If there were
an interrupt wich was generated by the arrival of the vertical retrace my life
would be easier but that's not the case.

So, my question is; how can I write a device driver under 386bsd which will
let me assure the timing is correct- ie, that I turn the capture on and off
only during the vertical retrace?  I obviously don't want to disable
interrupts during that time (do I?) but hope that if I can at least find the
start of the vertical retrace that somehow the driver can block after
clearing the strobe and have the kernel wake it up when the next vertical
retrace would start approx. 1/60 second later.
 
Can someone PLEASE point me in the right direction to start?  

Ken
--
	Ken Hughes		|  "I can't believe this is my life;
   (hughes@napa.eng.uop.edu)	|     I'm going to have to send my SAT
FT-Ph D candidate, PT-ex-sysadm	|     scores to San Quentin instead of
University of South Florida	|     Stanford..."  _Heathers_