int pp_transfer(WD_TRANSFER *tr, int fd, unsigned int request, unsigned char *wdioctl) {
int ret = 0;
+ unsigned long port = (unsigned long)tr->dwPort;
unsigned char val;
DPRINTF("dwPort: 0x%lx, cmdTrans: %lu, dwbytes: %ld, fautoinc: %ld, dwoptions: %ld\n",
if (parportfd < 0)
return ret;
- switch(tr->cmdTrans) {
- case 10: /* Read Byte */
- if ((unsigned long)tr->dwPort == ppbase) { /* Data Port */
+ if (port == ppbase + PP_DATA) {
+ DPRINTF("data port\n");
+ switch(tr->cmdTrans) {
+ case PP_READ:
ret = 0; /* We don't support reading of the data port */
- } else if ((unsigned long)tr->dwPort == ppbase + 1) { /* Status Port */
- DPRINTF("status port\n");
- ret = ioctl(parportfd, PPRSTATUS, &val);
- } else if ((unsigned long)tr->dwPort == ppbase + 2) { /* Control Port */
- DPRINTF("control port\n");
- ret = ioctl(parportfd, PPRCONTROL, &val);
- }
- break;
- case 13: /* Write Byte */
- if ((unsigned long)tr->dwPort == ppbase) { /* Data Port */
- DPRINTF("data port\n");
+ break;
+
+ case PP_WRITE:
ret = ioctl(parportfd, PPWDATA, &val);
- } else if ((unsigned long)tr->dwPort == ppbase + 1) { /* Status Port */
+ break;
+
+ default:
+ fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
+ ret = -1;
+ break;
+ }
+ } else if (port == ppbase + PP_STATUS) {
+ DPRINTF("status port\n");
+ switch(tr->cmdTrans) {
+ case PP_READ:
+ ret = ioctl(parportfd, PPRSTATUS, &val);
+ break;
+
+ case PP_WRITE:
ret = 0; /* Status Port is readonly */
- } else if ((unsigned long)tr->dwPort == ppbase + 2) { /* Control Port */
- DPRINTF("control port\n");
+ break;
+
+ default:
+ fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
+ ret = -1;
+ break;
+ }
+ } else if (port == ppbase + PP_CONTROL) {
+ DPRINTF("control port\n");
+ switch(tr->cmdTrans) {
+ case PP_READ:
+ ret = ioctl(parportfd, PPRCONTROL, &val);
+ break;
+
+ case PP_WRITE:
ret = ioctl(parportfd, PPWCONTROL, &val);
- }
- break;
- default:
- fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
- ret = -1;
- break;
+ break;
+
+ default:
+ fprintf(stderr,"!!!Unsupported TRANSFER command: %lu!!!\n", tr->cmdTrans);
+ ret = -1;
+ break;
+ }
+ } else if ((port == ecpbase + PP_ECP_CFGA) && ecpbase) {
+ DPRINTF("ECP_CFGA port\n");
+ } else if ((port == ecpbase + PP_ECP_CFGB) && ecpbase) {
+ DPRINTF("ECP_CFGB port\n");
+ } else if ((port == ecpbase + PP_ECP_ECR) && ecpbase) {
+ DPRINTF("ECP_ECR port\n");
+ } else {
+ DPRINTF("access to unsupported address range!\n");
+ ret = 0;
}
tr->Data.Byte = val;
if (ioctl(parportfd, PPCLAIM) == -1)
return ret;
+ ecpbase = 0;
pmode = IEEE1284_MODE_COMPAT;
if (ioctl(parportfd, PPNEGOT, &pmode) == -1)
return ret;
- if (cr->Card.dwItems > 1 && cr->Card.Item[1].I.IO.dwBytes) {
+ if (cr->Card.dwItems > 1 && cr->Card.Item[1].I.IO.dwAddr) {
DPRINTF("ECP mode requested\n");
- ecpbase = cr->Card.Item[1].I.IO.dwBytes;
+ ecpbase = (unsigned long)cr->Card.Item[1].I.IO.dwAddr;
/* TODO: Implement ECP mode */
#if 0
pmode = IEEE1284_MODE_ECP;
if (ioctl(parportfd, PPNEGOT, &pmode) == -1) {
+ ecpbase = 0;
pmode = IEEE1284_MODE_COMPAT;
if (ioctl(parportfd, PPNEGOT, &pmode) == -1)
return ret;