[Prev][Next][Index][Thread]
Re: Black Images
hello again,
As requested here is the additional info:
I am currently using qcam-simple.c Version 0.3 Later ported to work
with the color quickcam (I think by Kenny).
Here are the functions that I changed:
int read_lpstatus(struct qcam *q)
{
int statusreg, n;
n = ioctl(q->port, PPIOCGSREG, &statusreg);
if(n == -1) printf("********* ioctl error occured *********\n");
return statusreg;
}
int read_lpcontrol(struct qcam *q)
{
int controlreg, n;
n = ioctl(q->port, PPIOCGCREG, (char *) &controlreg);
if(n == -1) printf("********* ioctl error occured *********\n");
return controlreg;
}
int read_lpdata(struct qcam *q)
{
int datareg, n;
n = ioctl(q->port, PPIOCGDREG, (char *) &datareg);
if(n == -1) printf("********* ioctl error occured *********\n");
return datareg;
}
void write_lpdata(struct qcam *q, int cmd)
{
int n;
n = ioctl(q->port, QCWRITDATA, (char *) &cmd);
if(n == -1) printf("********* ioctl error occured *********\n");
}
void write_lpcontrol(struct qcam *q, int cmd)
{
int n;
n = ioctl(q->port, QCWRITCONT, (char *) &cmd);
if(n == -1) printf("********* ioctl error occured *********\n");
}
IN openstep, I have to communicate with a seprate parallel port
driver using ioctl in order to read and write to the port:
Here is the excerpt of the relevant parts of the code:
static int par_ioctl(dev_t dev, int cmd, caddr_t data, int flag)
{
int *arg = (int *) data;
int iobase, hw, mask;
dev = minor(dev);
if(dev < 0 || dev >= instances){
DLOG(("%s%d: par_ioctl: dev out of range\n", DeviceName, dev));
return ENXIO;
}
iobase = instance_data[dev].iobase;
switch(cmd){
case PPIOCSW: /* read status word (int)*/
DLOG(("%s%d: par_ioctl: get status\n", DeviceName, dev));
hw = inb(PORT_ICTL);
mask = PP_ST_INITIALIZED;
if(!(hw & PP_NOTBUSY))
mask |= PP_ST_BUSY;
if(hw & PP_NOPAPER)
mask |= PP_ST_NOPAPER;
if(!(hw & PP_ONLINE))
mask |= PP_ST_NOTSELECTED;
if(!(hw & PP_NOTERROR))
mask |= PP_ST_ERROR;
*arg = mask;
break;
case PPIOCGDREG: /* Get raw data from the data register
***change*** */
DLOG(("%s%d: par_ioctl: get raw data\n", DeviceName, dev));
*arg = inb(PORT_DATA);
break;
case PPIOCGCREG: /* Get raw data from the Control register
***change*** */
DLOG(("%s%d: par_ioctl: get raw control\n", DeviceName, dev));
*arg = inb(PORT_OCTL);
break;
case PPIOCGSREG: /* Get raw data from the status register
***change*** */
DLOG(("%s%d: par_ioctl: get raw status\n", DeviceName, dev));
*arg = inb(PORT_ICTL);
break;
case PPIOCINIT: /* initialize printer */
DLOG(("%s%d: par_ioctl: reset\n", DeviceName, dev));
outb(PORT_OCTL, instance_data[dev].octl & ~PP_NOTRESET);
IODelay(20); /* ***Change*** */
outb(PORT_OCTL, instance_data[dev].octl);
break;
case PPIOCSETTIMO: /* set timeout period (secs) (int)*/
DLOG(("%s%d: par_ioctl: set timeout to %ds\n", DeviceName,
dev, *arg));
#ifdef ALLOW_SET_TIMEOUT
instance_data[dev].timeout = *arg;
#endif
break;
/* The following ioctls are specific to the Quickcam ***change*** */
case QCWRITDATA: /* write to the data register int pointed to
by arg */
DLOG(("%s%d: par_ioctl: Writing to data register\n",
DeviceName, dev));
outb(PORT_DATA, *arg);
break;
case QCWRITCONT: /* write to the data register int pointed to
by arg */
DLOG(("%s%d: par_ioctl: Writing control register\n",
DeviceName, dev));
outb(PORT_OCTL, *arg);
break;
}
DLOG(("%s%d: par_ioctl: success\n", DeviceName, dev));
return 0;
}