Hi.
Firstly thanks for your kindly work on parport in linux and sorry for my
poor english. English is not my mother tongue. I am korean.
I am currently trying to build a custom kernel with parport
support(especially only for ecp data transfer) on redhat 7.3.
I selected items as follow in 'make xconfig'. Of course I am not listing all
the items I make kernel with. This includes only items in suspicious for
fear of this being an lengty mail.
System:
Via VT82c686b chipset.
Celleron 850
Major selected items added to default selection in 'make xconfig':
category: Parallel posrt support
Parallel posrt support(m)
Pc style hardware(m)
use fifo dma if available(y)
superio chipset support(y)
ieee1284 transfer modes(y)
category: Plug and play configuration
Plug and play support(y)
ISA p&p support(y)
pnp bios support(y)
category: Character device
parallel printer support(m)
support for user space parallel port device driver(m)
I use folloing commands:
> modprobe parport_pc io=0x378 irq=7 dma=3
and the messages are:
> opened parport0: 0x378(ECR at 0x778)
RAW NIBBLE BYTE COMPAT ECP ECPRLE ECPSWE IRQ DMA
but negotiation to ECP fails with error code -4
this is messages from 'dmesg'
lp0: using parport0 (interrupt driven)
lp0: ECP mode
parport0: PC-style at 0x378 (0x778), irq=7, dma 3(PCSPP, TRISTATE, COMPAT,
ECP, DMA)
ps: i am developing prototype application with libieee1284 written by tim
waugh.
below is source code which I modified slightly from library test code:
I hope you would look at especially method 'test_open (struct parport_list
*pl)'
Could you please help me finding what's wrong with my build?
I've tried all the combinations I can think of to no avail.
TIA
#include
#include
#include
#include
#include "crc.h"
#include
#pragma pack(1)
typedef union _Header{
struct{
char bytes[6];
}buf;
struct{
char bSTX; //0x02;
unsigned long dwSize;
char bCMD;
}st;
} Header;
typedef union _CmdStatus{
struct{
char bytes[11];
}buf;
struct{
Header header;
char ETX;
unsigned long crc;
}st;
} CmdStatus;
typedef union _Cmd{
struct{
char bytes[11];
}buf;
struct{
Header header;
char ETX;
unsigned long crc;
}st;
} Cmd;
#pragma pack()
enum devid_field { devid_cls, devid_mfg, devid_mdl };
static char *field (char *id, enum devid_field f)
{
char *result = "(?)";
char *p = NULL;
id += 2;
switch (f)
{
case devid_cls:
p = strstr (id, "CLASS:");
if (!p)
p = strstr (id, "class:");
if (!p)
p = strstr (id, "CLS:");
if (!p)
p = strstr (id, "cls:");
break;
case devid_mfg:
p = strstr (id, "MANUFACTURER:");
if (!p)
p = strstr (id, "manufacturer:");
if (!p)
p = strstr (id, "MFG:");
if (!p)
p = strstr (id, "mfg:");
break;
case devid_mdl:
p = strstr (id, "MODEL:");
if (!p)
p = strstr (id, "model:");
if (!p)
p = strstr (id, "MDL:");
if (!p)
p = strstr (id, "mdl:");
break;
}
if (p)
{
char *q;
char c;
p = strchr (p, ':') + 1;
q = strchr (p, ';');
if (q)
{
c = *q;
*q = '\0';
}
result = strdup (p); // leaks, but this is just a test harness
if (q)
*q = c;
}
return result;
}
static void test_deviceid (struct parport_list *pl)
{
int i, j;
printf ("Found %d ports:\n", pl->portc);
for (i = 0; i < pl->portc; i++) {
char id[500];
printf ("- %s: ", pl->portv[i]->name);
if (ieee1284_get_deviceid (pl->portv[i], -1, F1284_FRESH, id, 500) > -1) {
printf ("%s, %s %s", field (id, devid_cls), field (id, devid_mfg), field
(id, devid_mdl));
} else if (ieee1284_get_deviceid (pl->portv[i], -1, 0, id, 500) > -1) {
printf ("(may be cached) %s, %s %s", field (id, devid_cls), field (id,
devid_mfg), field (id, devid_mdl));
printf ("\n");
}
for (j = 0; j < 4; j++) {
if (ieee1284_get_deviceid (pl->portv[i], j, 0, id, 500) > -1)
printf (" Daisy chain address %d: (may be cached) %s, %s %s\n", j, field
(id, devid_cls), field (id, devid_mfg), field (id, devid_mdl));
}
}
putchar ('\n');
}
static int show_capabilities (unsigned int cap)
{
#define CAP(x) \
if (cap & CAP1284_##x) \
printf (#x " ");
CAP(RAW);
CAP(NIBBLE);
CAP(BYTE);
CAP(COMPAT);
CAP(BECP);
CAP(ECP);
CAP(ECPRLE);
CAP(ECPSWE);
CAP(EPP);
CAP(EPPSL);
CAP(EPPSWE);
CAP(IRQ);
CAP(DMA);
putchar ('\n');
return 0;
}
void test_open (struct parport_list *pl)
{
int i;
int res;
int parportfd;
int bytesWritten, bytesRead;
int mode;
int addr;
unsigned char ECP_ECR = 0x60;
unsigned char old_ECR;
unsigned char low_bits;
unsigned char new_ECR;
char buf[1000];
Header header;
CmdStatus cmdStatus;
Cmd cmd;
struct timeval tout;
printf("port count: %d\n", pl->portc);
for (i = 0; i < pl->portc; i++)
{
struct parport *port = pl->portv[i];
unsigned int cap;
/* Just try to open the port, then close it. */
int ret = ieee1284_open (port, 0, &cap);
if (ret)
printf ("%s, %d: inaccessible\n", port->name, ret);
else
{
printf ("opened %s: %#lx", port->name, port->base_addr);
if (port->hibase_addr)
printf (" (ECR at %#lx)", port->hibase_addr);
printf ("\n ");
show_capabilities (cap);
ret = ieee1284_claim(port);
printf("claim ret: %d\n", ret);
printf("nego\n");
ret = ieee1284_negotiate(port, M1284_ECP);
printf("ecp ret: %d\n", ret);
printf("read status\n");
ret = ieee1284_read_status(port);
printf("ret: %d\n", ret);
tout.tv_usec = 10;
tout.tv_sec = 0;
ieee1284_set_timeout(port, &tout);
// init command
memset(&header, 0,sizeof(Header));
header.st.bSTX = 0x02;
header.st.dwSize = sizeof(cmd.buf.bytes) - 4; // size except for crc
header.st.bCMD = 'I';
memset(&cmd, 0x00, sizeof(Cmd));
cmd.st.header = header;
cmd.st.ETX = 0x03;
cmd.st.crc = Crc32(cmd.buf.bytes, sizeof(Cmd) - 4);
pr("crc", cmd.st.crc);
for(i = 0; i < sizeof(cmd.buf.bytes); i++) {
printf("%x ", cmd.buf.bytes[i]);
}
ret = ieee1284_ecp_rev_to_fwd(port);
printf("fwd ret: %d\n", ret);
ret = ieee1284_ecp_write_data(port, F1284_NONBLOCK, cmd.buf.bytes,
sizeof(cmd.buf.bytes));
printf("written: %d\n", ret);
ret = ieee1284_ecp_fwd_to_rev(port);
printf("rev ret: %d\n", ret);
ret = ieee1284_ecp_read_data(port, F1284_NONBLOCK, buf, sizeof(buf));
printf("read: %d\n", ret);
// get ecr
printf("ECR: %x\n", port->hibase_addr);
// old_ECR = inb_p(port->hibase_addr);
// printf("ECR: %X\n", old_ECR);
ieee1284_release(port);
if (cap & CAP1284_IRQ)
{
int fd = ieee1284_get_irq_fd (port);
if (fd < 0)
printf ("Couldn't get IRQ fd: %d\n", fd);
else
{
int r = ieee1284_claim (port);
if (r != E1284_OK)
printf ("Couldn't claim port: %d\n", r);
else
r = ieee1284_clear_irq (port, NULL);
if (r != E1284_OK)
printf ("Couldn't clear IRQ: %d\n", r);
ieee1284_release (port);
}
}
ieee1284_close (port);
printf ("closed");
}
}
}
int main ()
{
struct parport_list pl;
ieee1284_find_ports (&pl, 0);
test_deviceid (&pl);
test_open (&pl);
ieee1284_free_ports (&pl);
return 0;
}
int pr(char* msg, unsigned long i) {
printf("%20s, result: %d\n", msg, i);
return 0;
}
-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --
This archive was generated by hypermail 2b29 : Thu Jan 16 2003 - 02:14:50 EST