summaryrefslogtreecommitdiff
path: root/2003/i
diff options
context:
space:
mode:
authorschodet2003-05-13 19:14:29 +0000
committerschodet2003-05-13 19:14:29 +0000
commit50271769ff6e75d753bddc905df444bef142af8d (patch)
tree30d6c84d99cea3d01c95213bab5759921ddce595 /2003/i
parentc26565727fadf8b516111ec34aa4fceaf0121b71 (diff)
Ajout de l'i2c ovt.
Modif de l'aquisition d'images.
Diffstat (limited to '2003/i')
-rw-r--r--2003/i/buzz/src/kernel/pbus.c59
-rw-r--r--2003/i/buzz/src/kernel/pbus.h8
2 files changed, 62 insertions, 5 deletions
diff --git a/2003/i/buzz/src/kernel/pbus.c b/2003/i/buzz/src/kernel/pbus.c
index 6f65538..3935199 100644
--- a/2003/i/buzz/src/kernel/pbus.c
+++ b/2003/i/buzz/src/kernel/pbus.c
@@ -8,11 +8,12 @@
#include <sys/conf.h>
#include <sys/ioctl.h>
+#define BONITO_I2C
+#include <machine/bonito.h>
#include <ioconf.h>
#include <machine/bonito_io.h>
#include <arch/bonito/dev/tests/pbus.h>
-
/* autoconfig stuff... */
#define BUFSZ (256<<10)
@@ -40,6 +41,8 @@ struct pbus_softc {
static int pbusprobe(struct device *, struct cfdata *, void *);
static void pbusattach(struct device *, struct device *, void *);
+unsigned char i2c_ovt_read(unsigned char addr);
+int i2c_ovt_write(unsigned char addr, unsigned char data);
struct cfattach pbus_ca = {
sizeof(struct pbus_softc), pbusprobe, pbusattach
@@ -199,7 +202,7 @@ pbusread(dev, uio, flags)
{
int bufok,remain;
int resid=uio->uio_resid;
- int s;
+ int s,err;
struct pbus_softc *sc= pbus_cd.cd_devs[0];
s=splhigh();
bufok=*((volatile int *)(&sc->buf_ok));
@@ -210,7 +213,15 @@ pbusread(dev, uio, flags)
sc->in_dma=1;
}
splx(s);
- if (!bufok) return 0;
+ if (!resid) return 0;
+
+ while (!bufok)
+ {
+ err=tsleep(sc,PUSER | PCATCH,"camera",0);
+ if (err) return err;
+ bufok=*((volatile int *)(&sc->buf_ok));
+ }
+
remain=sc->framesize-sc->buf_consumed;
if (resid>remain) resid=remain;
@@ -260,12 +271,43 @@ int pbus_intr(void *p)
BUFSYNC_POST;
sc->buf_ok=1;
sc->in_dma=0;
+ wakeup(sc);
}
return 0;
}
#define PBUS_WAIT \
tsleep(sc,PUSER | PCATCH,"pbusio",(HZ/10000)?(HZ/10000):1)
+
+
+#define OVTDEV 0xC0
+#define OVTCHN BOARDI2C
+
+unsigned char i2c_ovt_read(unsigned char addr)
+{
+ int retval;
+
+ i2c_send_start(OVTCHN);
+ i2c_write_byte(OVTCHN,OVTDEV|0);
+ i2c_write_byte(OVTCHN,addr);
+ i2c_send_stop(OVTCHN);
+ i2c_send_start(OVTCHN);
+ i2c_write_byte(OVTCHN,OVTDEV|1);
+ retval=i2c_read_byte(OVTCHN,0);
+ i2c_send_stop(OVTCHN);
+
+ return retval;
+}
+
+int i2c_ovt_write(unsigned char addr, unsigned char data)
+{
+ i2c_send_start(OVTCHN);
+ i2c_write_byte(OVTCHN,OVTDEV|0);
+ i2c_write_byte(OVTCHN,addr);
+ i2c_write_byte(OVTCHN,data);
+ i2c_send_stop(OVTCHN);
+ return 1;
+}
int
pbusioctl(dev, cmd, addr, flag, proc)
@@ -277,6 +319,7 @@ pbusioctl(dev, cmd, addr, flag, proc)
{
struct pbus_softc *sc= pbus_cd.cd_devs[0];
struct pbus_io *parm=(struct pbus_io *)addr;
+ struct sccb_io *sccb=(struct sccb_io *)addr;
unsigned long *fsize=(unsigned long *)addr;
/* PBUS IOctl */
if (minor(dev)==1) /* PBUS */
@@ -302,14 +345,14 @@ pbusioctl(dev, cmd, addr, flag, proc)
case PBUS_INTDISABLE:
sc->pbusinten=0;
PBUS_WRITE_4(8,0|PBUS_RnW|sc->pbusinten);
- break;
+ break;
case PBUS_INTENABLE:
sc->pbusinten=PBUS_INTEN;
PBUS_WRITE_4(8,0|PBUS_RnW|sc->pbusinten);
break;
case PBUS_INTREAD:
parm->ints=(PBUS_READ_4(8)>>16)&0x1F;
- break;
+ break;
}
}
@@ -332,6 +375,12 @@ pbusioctl(dev, cmd, addr, flag, proc)
}
splx(s);
break;
+ case CAM_SCCBREAD:
+ sccb->data=i2c_ovt_read(sccb->addr);
+ break;
+ case CAM_SCCBWRITE:
+ i2c_ovt_write(sccb->addr,sccb->data);
+ break;
}
}
diff --git a/2003/i/buzz/src/kernel/pbus.h b/2003/i/buzz/src/kernel/pbus.h
index 65b6024..8e4a67e 100644
--- a/2003/i/buzz/src/kernel/pbus.h
+++ b/2003/i/buzz/src/kernel/pbus.h
@@ -22,5 +22,13 @@ struct pbus_io
#define PBUS_INTDISABLE _IO('R', 4)
#define PBUS_INTREAD _IOWR('R', 5, struct pbus_io)
+struct sccb_io
+{
+ unsigned char addr; /* Address */
+ unsigned char data; /* Data */
+};
+
#define CAM_SETFRAMESIZE _IOW('R', 10, unsigned long)
+#define CAM_SCCBREAD _IOWR('R',11, struct sccb_io)
+#define CAM_SCCBWRITE _IOWR('R',12, struct sccb_io)
#endif