From 9f986147931e4ec9fc6abc07a61f991b8836866e Mon Sep 17 00:00:00 2001 From: David Schleef Date: Thu, 8 Mar 2001 09:21:03 +0000 Subject: [PATCH] Conversion of drivers from trig to insn/cmd. --- comedi/drivers/8255.c | 46 --- comedi/drivers/dt2801.c | 137 ++++---- comedi/drivers/dt2814.c | 56 +-- comedi/drivers/dt2817.c | 121 +++---- comedi/drivers/dt282x.c | 279 +-------------- comedi/drivers/ni_mio_common.c | 604 --------------------------------- 6 files changed, 161 insertions(+), 1082 deletions(-) diff --git a/comedi/drivers/8255.c b/comedi/drivers/8255.c index 25e18aee..e9bd6a92 100644 --- a/comedi/drivers/8255.c +++ b/comedi/drivers/8255.c @@ -136,51 +136,6 @@ static int subdev_8255_insn_config(comedi_device *dev,comedi_subdevice *s, return 1; } -static int subdev_8255_dio(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - int mask,data_in; - int i; - - if(it->flags & TRIG_CONFIG){ - int bits; - - for(i=0;in_chan;i++){ - mask=1<chanlist[i]); - if(mask&0x0000ff){ - bits=0x0000ff; - }else if(mask&0x00ff00){ - bits=0x00ff00; - }else if(mask&0x0f0000){ - bits=0x0f0000; - }else{ - bits=0xf00000; - } - if(it->data[i]){ - s->io_bits|=bits; - }else{ - s->io_bits&=~bits; - } - } - do_config(dev,s); - }else{ - if(it->flags&TRIG_WRITE){ - do_pack(&s->state,it); - - CALLBACK_FUNC(1,_8255_DATA,s->state&0xff,CALLBACK_ARG); - CALLBACK_FUNC(1,_8255_DATA+1,(s->state>>8)&0xff,CALLBACK_ARG); - CALLBACK_FUNC(1,_8255_DATA+2,(s->state>>16)&0xff,CALLBACK_ARG); - }else{ - data_in=CALLBACK_FUNC(0,_8255_DATA,0,CALLBACK_ARG); - data_in|=(CALLBACK_FUNC(0,_8255_DATA+1,0,CALLBACK_ARG)<<8); - data_in|=(CALLBACK_FUNC(0,_8255_DATA+2,0,CALLBACK_ARG)<<16); - - di_unpack(data_in,it); - } - } - - return it->n_chan; -} - static void do_config(comedi_device *dev,comedi_subdevice *s) { int config; @@ -216,7 +171,6 @@ int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,int (*cb)(int,int,in }else{ CALLBACK_FUNC=cb; } - s->trig[0]=subdev_8255_dio; s->insn_bits = subdev_8255_insn; s->insn_config = subdev_8255_insn_config; diff --git a/comedi/drivers/dt2801.c b/comedi/drivers/dt2801.c index b8fbb67a..3b1dcc75 100644 --- a/comedi/drivers/dt2801.c +++ b/comedi/drivers/dt2801.c @@ -76,6 +76,7 @@ comedi_driver driver_dt2801={ attach: dt2801_attach, detach: dt2801_detach, }; +COMEDI_INITCLEANUP(driver_dt2801); #if 0 // ignore 'defined but not used' warning @@ -202,13 +203,20 @@ static boardtype_t boardtypes[] = typedef struct{ comedi_lrange *dac_range_types[2]; + lsampl_t ao_readback[2]; }dt2801_private; #define devpriv ((dt2801_private *)dev->private) - -static int dt2801_ai_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it); -static int dt2801_ao_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it); -static int dt2801_dio(comedi_device *dev,comedi_subdevice *s,comedi_trig *it); +static int dt2801_ai_insn_read(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data); +static int dt2801_ao_insn_read(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data); +static int dt2801_ao_insn_write(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data); +static int dt2801_dio_insn_bits(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data); +static int dt2801_dio_insn_config(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data); /* These are the low-level routines: writecommand: write a command to the board @@ -519,7 +527,7 @@ havetype: #endif s->maxdata=(1<range_table=ai_range_lkup(boardtype.adrangetype,it->options[3]); - s->trig[0]=dt2801_ai_mode0; + s->insn_read=dt2801_ai_insn_read; s++; /* ao subdevice */ @@ -530,7 +538,8 @@ havetype: s->range_table_list=devpriv->dac_range_types; devpriv->dac_range_types[0]=dac_range_lkup(it->options[4]); devpriv->dac_range_types[1]=dac_range_lkup(it->options[5]); - s->trig[0]=dt2801_ao_mode0; + s->insn_read=dt2801_ao_insn_read; + s->insn_write=dt2801_ao_insn_write; s++; /* 1st digital subdevice */ @@ -539,7 +548,8 @@ havetype: s->n_chan=8; s->maxdata=1; s->range_table=&range_digital; - s->trig[0]=dt2801_dio; + s->insn_bits=dt2801_dio_insn_bits; + s->insn_config=dt2801_dio_insn_config; s++; /* 2nd digital subdevice */ @@ -548,7 +558,8 @@ havetype: s->n_chan=8; s->maxdata=1; s->range_table=&range_digital; - s->trig[0]=dt2801_dio; + s->insn_bits=dt2801_dio_insn_bits; + s->insn_config=dt2801_dio_insn_config; ret = 0; out: @@ -583,80 +594,86 @@ static int dt2801_error(comedi_device *dev,int stat) return -EIO; } -static int dt2801_ai_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) +static int dt2801_ai_insn_read(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data) { - int data; + int d; int stat; + int i; + for(i=0;in;i++){ + stat = dt2801_writecmd(dev, DT_C_READ_ADIM); + dt2801_writedata(dev, CR_RANGE(insn->chanspec)); + dt2801_writedata(dev, CR_CHAN(insn->chanspec)); + stat = dt2801_readdata2(dev, &d); - stat = dt2801_writecmd(dev, DT_C_READ_ADIM); - dt2801_writedata(dev, CR_RANGE(it->chanlist[0])); - dt2801_writedata(dev, CR_CHAN(it->chanlist[0])); - stat = dt2801_readdata2(dev, &data); - - if (stat != 0) return dt2801_error(dev,stat); + if (stat != 0) return dt2801_error(dev,stat); - it->data[0]=data; + data[i]=d; + } - return 1; + return i; } -static int dt2801_ao_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) +static int dt2801_ao_insn_read(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data) { - int chan=CR_CHAN(it->chanlist[0]); + data[0]=devpriv->ao_readback[CR_CHAN(insn->chanspec)]; + return 1; +} + +static int dt2801_ao_insn_write(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data) +{ dt2801_writecmd(dev, DT_C_WRITE_DAIM); - dt2801_writedata(dev, chan); - dt2801_writedata2(dev, it->data[0]); - + dt2801_writedata(dev, CR_CHAN(insn->chanspec)); + dt2801_writedata2(dev, data[0]); + + devpriv->ao_readback[CR_CHAN(insn->chanspec)]=data[0]; + return 1; } -static int dt2801_dio(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) +static int dt2801_dio_insn_bits(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data) { - unsigned int bits; int which=0; - + if(s==dev->subdevices+4)which=1; - - if(it->flags & TRIG_CONFIG){ - /* configure */ - if(it->chanlist[it->n_chan-1]){ - s->io_bits=0xff; - dt2801_writecmd(dev, DT_C_SET_DIGOUT); - }else{ - s->io_bits=0; - dt2801_writecmd(dev, DT_C_SET_DIGIN); - } + + if(insn->n!=2)return -EINVAL; + if(data[0]){ + s->state &= ~data[0]; + s->state |= (data[0]&data[1]); + dt2801_writecmd(dev, DT_C_WRITE_DIG); dt2801_writedata(dev, which); - }else{ - if(s->io_bits){ - do_pack(&s->state,it); - dt2801_writecmd(dev, DT_C_WRITE_DIG); - dt2801_writedata(dev, which); - dt2801_writedata(dev, s->state); - }else{ - dt2801_writecmd(dev, DT_C_READ_DIG); - dt2801_writedata(dev, which); - dt2801_readdata(dev, &bits); - di_unpack(bits,it); - } + dt2801_writedata(dev, s->state); } - return it->n_chan; + dt2801_writecmd(dev, DT_C_READ_DIG); + dt2801_writedata(dev, which); + dt2801_readdata(dev, data+1); + + return 2; } +static int dt2801_dio_insn_config(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data) +{ + int which=0; + if(s==dev->subdevices+4)which=1; -#ifdef MODULE -int init_module(void) -{ - comedi_driver_register(&driver_dt2801); - - return 0; -} + /* configure */ + if(data[0]){ + s->io_bits=0xff; + dt2801_writecmd(dev, DT_C_SET_DIGOUT); + }else{ + s->io_bits=0; + dt2801_writecmd(dev, DT_C_SET_DIGIN); + } + dt2801_writedata(dev, which); -void cleanup_module(void) -{ - comedi_driver_unregister(&driver_dt2801); + return 1; } -#endif + diff --git a/comedi/drivers/dt2814.c b/comedi/drivers/dt2814.c index b6909c3a..651c6fc3 100644 --- a/comedi/drivers/dt2814.c +++ b/comedi/drivers/dt2814.c @@ -72,7 +72,7 @@ typedef struct{ #define devpriv ((dt2814_private *)dev->private) -#define DT2814_TIMEOUT 1000 +#define DT2814_TIMEOUT 10 #define DT2814_MAX_SPEED 100000 /* XXX 10 khz */ static int dt2814_ai_insn_read(comedi_device *dev,comedi_subdevice *s, @@ -80,16 +80,23 @@ static int dt2814_ai_insn_read(comedi_device *dev,comedi_subdevice *s, { int n,i,hi,lo; int chan; + int status=0; for(n=0;nn;n++){ chan=CR_CHAN(insn->chanspec); outb(chan,dev->iobase+DT2814_CSR); for(i=0;iiobase+DT2814_CSR)&DT2814_FINISH) + status = inb(dev->iobase+DT2814_CSR); +printk("dt2814: status: %02x\n",status); +udelay(10); + if(status&DT2814_FINISH) break; } - if(i>=DT2814_TIMEOUT)return -ETIMEDOUT; + if(i>=DT2814_TIMEOUT){ + printk("dt2814: status: %02x\n",status); + return -ETIMEDOUT; + } hi=inb(dev->iobase+DT2814_DATA); lo=inb(dev->iobase+DT2814_DATA); @@ -100,28 +107,6 @@ static int dt2814_ai_insn_read(comedi_device *dev,comedi_subdevice *s, return n; } -#ifdef CONFIG_COMEDI_MODE0 -static int dt2814_ai_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - int i,hi,lo; - int chan; - - chan=CR_CHAN(it->chanlist[0]); - - outb(chan,dev->iobase+DT2814_CSR); - for(i=0;iiobase+DT2814_CSR)&DT2814_FINISH) - break; - } - hi=inb(dev->iobase+DT2814_DATA); - lo=inb(dev->iobase+DT2814_DATA); - - it->data[0]=(hi<<4)|(lo>>4); - - return 1; -} -#endif - static int dt2814_ns_to_timer(unsigned int *ns,unsigned int flags) { int i; @@ -240,21 +225,6 @@ static int dt2814_ai_cmd(comedi_device *dev,comedi_subdevice *s) } -#ifdef CONFIG_COMEDI_MODES -static int dt2814_ai_mode1(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - int chan; - - chan=CR_CHAN(it->chanlist[0]); - - devpriv->ntrig=it->n; - outb(chan|DT2814_ENB|(it->trigvar<<5), - dev->iobase+DT2814_CSR); - - return 0; -} -#endif - static int dt2814_attach(comedi_device *dev,comedi_devconfig *it) { int i,irq; @@ -325,12 +295,6 @@ static int dt2814_attach(comedi_device *dev,comedi_devconfig *it) s->subdev_flags=SDF_READABLE; s->n_chan=16; /* XXX */ s->len_chanlist=1; -#ifdef CONFIG_COMEDI_MODE0 - s->trig[0]=dt2814_ai_mode0; -#endif -#ifdef CONFIG_COMEDI_MODES - s->trig[1]=dt2814_ai_mode1; -#endif s->insn_read = dt2814_ai_insn_read; s->do_cmd = dt2814_ai_cmd; s->do_cmdtest = dt2814_ai_cmdtest; diff --git a/comedi/drivers/dt2817.c b/comedi/drivers/dt2817.c index 52e01394..bdfa7f17 100644 --- a/comedi/drivers/dt2817.c +++ b/comedi/drivers/dt2817.c @@ -51,56 +51,69 @@ comedi_driver driver_dt2817={ attach: dt2817_attach, detach: dt2817_detach, }; +COMEDI_INITCLEANUP(driver_dt2817); -static int dt2817_dio(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) +static int dt2817_dio_insn_config(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data) { - if(it->flags & TRIG_CONFIG){ - int mask,i; - int chan; - int oe=0; - - for(i=0;in_chan;i++){ - chan=CR_CHAN(it->chanlist[i]); - if(chan<8){ - mask=0xff; - }else if(chan<16){ - mask=0xff00; - }else if(chan<24){ - mask=0xff0000; - }else mask=0xff000000; - if(it->data[i])s->io_bits|=mask; - else s->io_bits&=~mask; - } - if(s->io_bits&0x000000ff)oe|=0x1; - if(s->io_bits&0x0000ff00)oe|=0x2; - if(s->io_bits&0x00ff0000)oe|=0x4; - if(s->io_bits&0xff000000)oe|=0x8; - - outb(oe,dev->iobase + DT2817_CR); - }else{ - int data; - - if(it->flags & TRIG_WRITE){ - do_pack(&s->state,it); - if(s->io_bits&0x000000ff) - outb(s->state&0xff, dev->iobase + DT2817_DATA+0); - if(s->io_bits&0x0000ff00) - outb((s->state>>8)&0xff, dev->iobase + DT2817_DATA+1); - if(s->io_bits&0x00ff0000) - outb((s->state>>16)&0xff, dev->iobase + DT2817_DATA+2); - if(s->io_bits&0xff000000) - outb((s->state>>24)&0xff, dev->iobase + DT2817_DATA+3); - }else{ - data = inb(dev->iobase + DT2817_DATA + 0); - data |= (inb(dev->iobase + DT2817_DATA + 1)<<8); - data |= (inb(dev->iobase + DT2817_DATA + 2)<<16); - data |= (inb(dev->iobase + DT2817_DATA + 3)<<24); - di_unpack(data,it); - } + int mask; + int chan; + int oe=0; + + if(insn->n!=1)return -EINVAL; + + chan=CR_CHAN(insn->chanspec); + if(chan<8){ + mask=0xff; + }else if(chan<16){ + mask=0xff00; + }else if(chan<24){ + mask=0xff0000; + }else mask=0xff000000; + if(data[0])s->io_bits|=mask; + else s->io_bits&=~mask; + + if(s->io_bits&0x000000ff)oe|=0x1; + if(s->io_bits&0x0000ff00)oe|=0x2; + if(s->io_bits&0x00ff0000)oe|=0x4; + if(s->io_bits&0xff000000)oe|=0x8; + + outb(oe,dev->iobase + DT2817_CR); + + return 1; +} + +static int dt2817_dio_insn_bits(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data) +{ + unsigned int changed; + + /* It's questionable whether it is more important in + * a driver like this to be deterministic or fast. + * We choose fast. */ + + if(data[0]){ + changed = s->state; + s->state &= ~data[0]; + s->state |= (data[0]&data[1]); + changed ^= s->state; + changed &= s->io_bits; + if(changed&0x000000ff) + outb(s->state&0xff, dev->iobase + DT2817_DATA+0); + if(changed&0x0000ff00) + outb((s->state>>8)&0xff, dev->iobase + DT2817_DATA+1); + if(changed&0x00ff0000) + outb((s->state>>16)&0xff, dev->iobase + DT2817_DATA+2); + if(changed&0xff000000) + outb((s->state>>24)&0xff, dev->iobase + DT2817_DATA+3); } - - return it->n_chan; + data[1] = inb(dev->iobase + DT2817_DATA + 0); + data[1] |= (inb(dev->iobase + DT2817_DATA + 1)<<8); + data[1] |= (inb(dev->iobase + DT2817_DATA + 2)<<16); + data[1] |= (inb(dev->iobase + DT2817_DATA + 3)<<24); + + return 2; } static int dt2817_attach(comedi_device *dev,comedi_devconfig *it) @@ -129,7 +142,8 @@ static int dt2817_attach(comedi_device *dev,comedi_devconfig *it) s->subdev_flags=SDF_READABLE|SDF_WRITEABLE; s->range_table=&range_digital; s->maxdata=1; - s->trig[0]=dt2817_dio; + s->insn_bits=dt2817_dio_insn_bits; + s->insn_config=dt2817_dio_insn_config; s->state=0; outb(0,dev->iobase+DT2817_CR); @@ -149,16 +163,3 @@ static int dt2817_detach(comedi_device *dev) return 0; } -#ifdef MODULE -int init_module(void) -{ - comedi_driver_register(&driver_dt2817); - - return 0; -} - -void cleanup_module(void) -{ - comedi_driver_unregister(&driver_dt2817); -} -#endif diff --git a/comedi/drivers/dt282x.c b/comedi/drivers/dt282x.c index 83f55c30..c3f384b0 100644 --- a/comedi/drivers/dt282x.c +++ b/comedi/drivers/dt282x.c @@ -677,32 +677,6 @@ static int dt282x_ai_insn_read(comedi_device *dev,comedi_subdevice *s, return i; } -static int dt282x_ai_mode0(comedi_device * dev, comedi_subdevice * s, comedi_trig * it) -{ - devpriv->adcsr = DT2821_ADCLK; - update_adcsr(0); - - dt282x_load_changain(dev, 1, it->chanlist); - - update_supcsr(DT2821_PRLD); - wait_for(!mux_busy(), - comedi_error(dev, "timeout\n"); - return -ETIME; - ); - - update_supcsr(DT2821_STRIG); - wait_for(ad_done(), - comedi_error(dev, "timeout\n"); - return -ETIME; - ); - - it->data[0] = inw(dev->iobase + DT2821_ADDAT) & ((1<ad_2scomp) - it->data[0] ^= (1 << (boardtype.adbits - 1)); - - return 1; -} - static int dt282x_ai_cmdtest(comedi_device * dev, comedi_subdevice * s,comedi_cmd *cmd) { int err=0; @@ -855,143 +829,6 @@ static int dt282x_ai_cmd(comedi_device * dev, comedi_subdevice * s) return 0; } -#ifdef CONFIG_COMEDI_MODES -static int dt282x_ai_mode1(comedi_device * dev, comedi_subdevice * s, comedi_trig * it) -{ - int timer; - - if (!devpriv->usedma) { - dt282x_load_changain(dev,it->n_chan,it->chanlist); - - devpriv->ntrig=it->n*it->n_chan; - devpriv->nread=devpriv->ntrig; - - timer=dt282x_ns_to_timer(&it->trigvar,TRIG_ROUND_NEAREST); - outw(timer, dev->iobase + DT2821_TMRCTR); - - devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE; - update_adcsr(0); - - devpriv->supcsr = DT2821_ERRINTEN ; - - update_supcsr(DT2821_PRLD); - wait_for(!mux_busy(), - comedi_error(dev, "timeout\n"); - return -ETIME; - ); - update_supcsr(DT2821_STRIG); - - return 0; - } else { - timer=dt282x_ns_to_timer(&it->trigvar,TRIG_ROUND_NEAREST); - outw(timer, dev->iobase + DT2821_TMRCTR); - - devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS0; - update_supcsr(DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_ADCINIT); - devpriv->adcsr = 0; - - devpriv->ntrig=it->n*it->n_chan; - devpriv->nread=devpriv->ntrig; - - devpriv->dma_dir=DMA_MODE_READ; - devpriv->current_dma_chan=0; - prep_ai_dma(dev,0,0); - enable_dma(devpriv->dma[0].chan); - if(devpriv->ntrig){ - prep_ai_dma(dev,1,0); - enable_dma(devpriv->dma[1].chan); - devpriv->supcsr |= DT2821_DDMA; - update_supcsr(0); - } - - devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE; - update_adcsr(0); - - dt282x_load_changain(dev,it->n_chan,it->chanlist); - - devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE; - update_adcsr(0); - - update_supcsr(DT2821_PRLD); - wait_for(!mux_busy(), - comedi_error(dev, "timeout\n"); - return -ETIME; - ); - update_supcsr(DT2821_STRIG); - - return 0; - } -} - -static int dt282x_ai_mode4(comedi_device * dev, comedi_subdevice * s, comedi_trig * it) -{ - int timer; - - if (!devpriv->usedma) { - dt282x_load_changain(dev,it->n_chan,it->chanlist); - - devpriv->ntrig=it->n*it->n_chan; - devpriv->nread=devpriv->ntrig; - - timer=dt282x_ns_to_timer(&it->trigvar1,TRIG_ROUND_NEAREST); - outw(timer, dev->iobase + DT2821_TMRCTR); - - devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE; - update_adcsr(0); - - devpriv->supcsr = DT2821_ERRINTEN ; - - update_supcsr(DT2821_PRLD); - wait_for(!mux_busy(), - comedi_error(dev, "timeout\n"); - return -ETIME; - ); - update_supcsr(DT2821_STRIG); - - return 0; - } else { - timer=dt282x_ns_to_timer(&it->trigvar1,TRIG_ROUND_NEAREST); - outw(timer, dev->iobase + DT2821_TMRCTR); - - devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS0 | DT2821_DS1; - update_supcsr(DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_ADCINIT); - devpriv->adcsr = 0; - - devpriv->ntrig=it->n*it->n_chan; - devpriv->nread=devpriv->ntrig; - - devpriv->dma_dir=DMA_MODE_READ; - devpriv->current_dma_chan=0; - prep_ai_dma(dev,0,0); - enable_dma(devpriv->dma[0].chan); - if(devpriv->ntrig){ - prep_ai_dma(dev,1,0); - enable_dma(devpriv->dma[1].chan); - devpriv->supcsr |= DT2821_DDMA; - update_supcsr(0); - } - - devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE; - update_adcsr(0); - - dt282x_load_changain(dev,it->n_chan,it->chanlist); - - devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE; - update_adcsr(0); - - update_supcsr(DT2821_PRLD); - wait_for(!mux_busy(), - comedi_error(dev, "timeout\n"); - return -ETIME; - ); - devpriv->supcsr |= DT2821_XTRIG; - update_supcsr(0); - - return 0; - } -} -#endif - static int dt282x_ai_cancel(comedi_device * dev, comedi_subdevice * s) { devpriv->adcsr=0; @@ -1082,36 +919,6 @@ static int dt282x_ao_insn_write(comedi_device * dev, comedi_subdevice * s, return 1; } -static int dt282x_ao(comedi_device * dev, comedi_subdevice * s, comedi_trig * it) -{ - sampl_t data; - unsigned int chan; - - data = it->data[0]; - chan = CR_CHAN(it->chanlist[0]); - - devpriv->dacsr |= DT2821_SSEL; - - if (chan) { - /* select channel */ - devpriv->dacsr |= DT2821_YSEL; - if (devpriv->da0_2scomp) - data ^= (1<<(boardtype.dabits-1)); - } else { - devpriv->dacsr &= ~DT2821_YSEL; - if (devpriv->da1_2scomp) - data ^= (1<<(boardtype.dabits-1)); - } - - update_dacsr(0); - - outw(data, dev->iobase + DT2821_DADAT); - - update_supcsr(DT2821_DACON); - - return 1; -} - static int dt282x_ao_cmdtest(comedi_device *dev,comedi_subdevice *s,comedi_cmd *cmd) { int err=0; @@ -1227,41 +1034,6 @@ static int dt282x_ao_cmd(comedi_device *dev,comedi_subdevice *s) return 0; } -#ifdef CONFIG_COMEDI_MODES -static int dt282x_ao_mode2(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - int size; - int timer; - - devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS1 | DT2821_DDMA; - update_supcsr(DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_DACINIT); - - devpriv->ntrig=it->n*it->n_chan; - devpriv->nread=devpriv->ntrig; - - devpriv->dma_dir=DMA_MODE_WRITE; - devpriv->current_dma_chan=0; - - size=copy_from_buf(dev,s,devpriv->dma[0].buf,devpriv->dma_maxsize*2); - prep_ao_dma(dev,0,size/2); - enable_dma(devpriv->dma[0].chan); - - size=copy_from_buf(dev,s,devpriv->dma[1].buf,devpriv->dma_maxsize*2); - prep_ao_dma(dev,1,size/2); - enable_dma(devpriv->dma[1].chan); - - timer=dt282x_ns_to_timer(&it->trigvar,TRIG_ROUND_NEAREST); - outw(timer, dev->iobase + DT2821_TMRCTR); - - devpriv->dacsr = DT2821_SSEL| DT2821_DACLK | DT2821_IDARDY; - update_dacsr(0); - - update_supcsr(DT2821_STRIG); - - return 0; -} -#endif - static int dt282x_ao_cancel(comedi_device * dev, comedi_subdevice * s) { devpriv->dacsr=0; @@ -1287,35 +1059,23 @@ static int dt282x_dio_insn_bits(comedi_device *dev,comedi_subdevice *s, return 2; } -static int dt282x_dio(comedi_device * dev, comedi_subdevice * s, comedi_trig * it) +static int dt282x_dio_insn_config(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn,lsampl_t *data) { - if(it->flags&TRIG_CONFIG){ - int mask,i; + int mask; - for(i=0;in_chan;i++){ - mask=(CR_CHAN(it->chanlist[i])<8)?0x00ff:0xff00; - if(it->data[i])s->io_bits|=mask; - else s->io_bits&=~mask; - } - if(s->io_bits&0x00ff)devpriv->dacsr|=DT2821_LBOE; - else devpriv->dacsr&=~DT2821_LBOE; - if(s->io_bits&0xff00)devpriv->dacsr|=DT2821_HBOE; - else devpriv->dacsr&=~DT2821_HBOE; + mask=(CR_CHAN(insn->chanspec)<8)?0x00ff:0xff00; + if(data[0])s->io_bits|=mask; + else s->io_bits&=~mask; - outw(devpriv->dacsr, dev->iobase + DT2821_DACSR); - }else{ - unsigned int data; + if(s->io_bits&0x00ff)devpriv->dacsr|=DT2821_LBOE; + else devpriv->dacsr&=~DT2821_LBOE; + if(s->io_bits&0xff00)devpriv->dacsr|=DT2821_HBOE; + else devpriv->dacsr&=~DT2821_HBOE; - if(it->flags&TRIG_WRITE){ - do_pack(&s->state,it); - outw(s->state, dev->iobase + DT2821_DIODAT); - }else{ - data = inw(dev->iobase + DT2821_DIODAT); - di_unpack(data,it); - } - } + outw(devpriv->dacsr, dev->iobase + DT2821_DACSR); - return it->n_chan; + return 0; } @@ -1465,13 +1225,6 @@ static int dt282x_attach(comedi_device * dev, comedi_devconfig * it) s->type=COMEDI_SUBD_AI; s->subdev_flags=SDF_READABLE|((it->options[opt_diff])?SDF_DIFF:SDF_COMMON); s->n_chan=(it->options[opt_diff])?boardtype.adchan_di:boardtype.adchan_se; -#ifdef CONFIG_COMEDI_MODE0 - s->trig[0]=dt282x_ai_mode0; -#endif -#ifdef CONFIG_COMEDI_MODES - s->trig[1]=dt282x_ai_mode1; - s->trig[4]=dt282x_ai_mode4; -#endif s->insn_read=dt282x_ai_insn_read; s->do_cmdtest=dt282x_ai_cmdtest; s->do_cmd=dt282x_ai_cmd; @@ -1487,12 +1240,6 @@ static int dt282x_attach(comedi_device * dev, comedi_devconfig * it) s->type=COMEDI_SUBD_AO; dev->write_subdev=s; s->subdev_flags=SDF_WRITEABLE; -#ifdef CONFIG_COMEDI_MODE0 - s->trig[0]=dt282x_ao; -#endif -#ifdef CONFIG_COMEDI_MODES - s->trig[2]=dt282x_ao_mode2; -#endif s->insn_read=dt282x_ao_insn_read; s->insn_write=dt282x_ao_insn_write; s->do_cmdtest=dt282x_ao_cmdtest; @@ -1516,8 +1263,8 @@ static int dt282x_attach(comedi_device * dev, comedi_devconfig * it) s->type=COMEDI_SUBD_DIO; s->subdev_flags=SDF_READABLE|SDF_WRITEABLE; s->n_chan=16; - s->trig[0]=dt282x_dio; s->insn_bits = dt282x_dio_insn_bits; + s->insn_config = dt282x_dio_insn_config; s->maxdata=1; s->range_table = &range_digital; diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index f031881b..18777da0 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -51,7 +51,6 @@ */ -//#define USE_TRIG //#define DEBUG_INTERRUPT //#define TRY_DMA @@ -157,13 +156,7 @@ static int ni_dio_insn_config(comedi_device *dev,comedi_subdevice *s, comedi_insn *insn,lsampl_t *data); static int ni_dio_insn_bits(comedi_device *dev,comedi_subdevice *s, comedi_insn *insn,lsampl_t *data); -#ifdef USE_TRIG -static int ni_dio(comedi_device *dev,comedi_subdevice *s,comedi_trig *it); -#endif -#ifdef USE_TRIG -static int ni_eeprom(comedi_device *dev,comedi_subdevice *s,comedi_trig *it); -#endif static int ni_calib_insn_read(comedi_device *dev,comedi_subdevice *s, comedi_insn *insn,lsampl_t *data); static int ni_calib_insn_write(comedi_device *dev,comedi_subdevice *s, @@ -617,58 +610,6 @@ static void ni_load_channelgain_list(comedi_device *dev,unsigned int n_chan,unsi #define NI_TIMEOUT 1000 -#ifdef USE_TRIG -/* - Mode 0 is immediate -*/ -static int ni_ai_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - int i; - int chan; - int wsave; - - wsave=win_save(); - - win_out(1,ADC_FIFO_Clear); - - /* interrupt on errors */ - win_out(0x0020,Interrupt_A_Enable_Register) ; - - for(chan=0;chann_chan;chan++){ - ni_load_channelgain_list(dev,1,it->chanlist+chan,(it->flags&TRIG_DITHER)==TRIG_DITHER); -#if 0 - /* needs start configuration */ - win_out(AI_START_Edge|AI_START_Sync| - AI_STOP_Select(19)|AI_STOP_Sync, - AI_START_STOP_Select_Register); -#endif - - - win_out(1,AI_Command_1_Register); - - /* I don't know how long it takes to access the bus, - so shorter loops might cause timeouts */ - for(i=0;idata[chan]=ni_readw(ADC_FIFO_Data_Register); - it->data[chan]^=devpriv->ai_xorlist[0]; - it->data[chan]&=(1<n_left = 1; return 0; } -#ifdef USE_TRIG -/* - mode 2 is timed, multi-channel -*/ -static int ni_ai_mode2(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - int wsave; - int trigvar; - int trigvar1; - - wsave=win_save(); - - win_out(1,ADC_FIFO_Clear); - - trigvar = ni_ns_to_timer(&it->trigvar,TRIG_ROUND_NEAREST); - trigvar1 = ni_ns_to_timer(&it->trigvar1,TRIG_ROUND_NEAREST); - - ni_load_channelgain_list(dev,it->n_chan,it->chanlist,(it->flags&TRIG_DITHER)==TRIG_DITHER); - - /* start configuration */ - win_out(AI_Configuration_Start,Joint_Reset_Register); - - /* stage number of scans */ - if(it->n==0){ - /* hack for continuous acquisition */ - win_out(0,AI_SC_Load_A_Registers); - win_out(0,AI_SC_Load_A_Registers+1); - win_out(0x000e,AI_Mode_1_Register); - }else{ - win_out((it->n-1)>>16,AI_SC_Load_A_Registers); - win_out((it->n-1)&0xffff,AI_SC_Load_A_Registers+1); - win_out(0x000d,AI_Mode_1_Register); - } - - /* load SC (Scan Count) */ - win_out(0x20,AI_Command_1_Register); - - /* - AI_SI_Special_Trigger_Delay=0 - AI_Pre_Trigger=0 - AI_START_STOP_Select_Register: - AI_START_Polarity=0 (?) rising edge - AI_START_Edge=1 edge triggered - AI_START_Sync=1 (?) - AI_START_Select=0 SI_TC - AI_STOP_Polarity=0 rising edge - AI_STOP_Edge=0 level - AI_STOP_Sync=1 - AI_STOP_Select=19 external pin (configuration mem) - */ - win_out(AI_START_Edge|AI_START_Sync| - AI_STOP_Select(19)|AI_STOP_Sync, - AI_START_STOP_Select_Register); - - win_out((trigvar>>16),AI_SI_Load_A_Registers); - win_out((trigvar&0xffff),AI_SI_Load_A_Registers+1); - /* AI_SI_Initial_Load_Source=A */ - win_out(0,AI_Mode_2_Register); - /* load SI */ - win_out(0x200,AI_Command_1_Register); - - /* stage freq. counter into SI B */ - win_out((trigvar>>16),AI_SI_Load_B_Registers); - win_out((trigvar&0xffff),AI_SI_Load_B_Registers+1); - - win_out(trigvar1,AI_SI2_Load_A_Register); /* 0,0 does not work. */ - win_out(trigvar1,AI_SI2_Load_B_Register); - - /* AI_SI2_Reload_Mode = alternate */ - /* AI_SI2_Initial_Load_Source = A */ - win_out(0x0100,AI_Mode_2_Register); - - /* AI_SI2_Load */ - win_out(0x0800,AI_Command_1_Register); - - /* AI_SI_Initial_Load_Source=0 - AI_SI_Reload_Mode(0) - AI_SI2_Reload_Mode = alternate, AI_SI2_Initial_Load_Source = B */ - win_out(0x0300,AI_Mode_2_Register); - - if(dev->irq){ - int bits; - - /* interrupt on FIFO, errors, SC_TC */ - bits=AI_FIFO_Interrupt_Enable|AI_Error_Interrupt_Enable| - AI_SC_TC_Interrupt_Enable; - //bits|=Pass_Thru_0_Interrupt_Enable; - - if(s->async->cb_mask&COMEDI_CB_EOS){ - /* wake on end-of-scan */ - devpriv->aimode=AIMODE_SCAN; - }else{ - devpriv->aimode=AIMODE_HALF_FULL; - } - switch(devpriv->aimode){ - case AIMODE_HALF_FULL: - /*generate FIFO interrupts on half-full */ - win_out(AI_FIFO_Mode_HF|0x0000,AI_Mode_3_Register); - break; - case AIMODE_SAMPLE: - /*generate FIFO interrupts on non-empty */ - win_out(AI_FIFO_Mode_NE|0x0000,AI_Mode_3_Register); - break; - case AIMODE_SCAN: - /*generate FIFO interrupts on half-full */ - win_out(AI_FIFO_Mode_HF|0x0000,AI_Mode_3_Register); - bits|=AI_STOP_Interrupt_Enable; - break; - default: - break; - } - - win_out(0x3f80,Interrupt_A_Ack_Register); /* clear interrupts */ - - win_out(bits,Interrupt_A_Enable_Register) ; - }else{ - /* interrupt on nothing */ - win_out(0x0000,Interrupt_A_Enable_Register) ; - - /* XXX start polling if necessary */ - } - -#ifdef PCIDMA -#if 0 - Strobes_Register - AI_AO_Select_Register - Interrupt_B_Enable_Register MSC_Pass_thru -#endif - - ni_writeb(0x01,AI_AO_Select); - mite_dma_prep(devpriv->mite, s); - - mite_dma_arm(devpriv->mite); -#endif - -#ifdef DEBUG -rt_printk("end config\n"); -#endif - /* end configuration */ - win_out(AI_Configuration_End,Joint_Reset_Register); - - /* AI_SI2_Arm, AI_SI_Arm, AI_DIV_Arm, AI_SC_Arm */ - win_out(0x1540,AI_Command_1_Register); - - /* AI_START1_Pulse */ - win_out(AI_START1_Pulse,AI_Command_2_Register); -#ifdef DEBUG -rt_printk("START1 pulse\n"); -#endif - - win_restore(wsave); - return 0; -} -#endif - -#ifdef USE_TRIG -/* - mode 4 is external trigger for scans, timer for samples - in a scan -*/ -static int ni_ai_mode4(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - int wsave; - int trigvar1; - - wsave=win_save(); - - win_out(1,ADC_FIFO_Clear); - - trigvar1 = ni_ns_to_timer(&it->trigvar1,TRIG_ROUND_NEAREST); - ni_load_channelgain_list(dev,it->n_chan,it->chanlist,(it->flags&TRIG_DITHER)==TRIG_DITHER); - - /* start configuration */ - win_out(AI_Configuration_Start,Joint_Reset_Register); - - /* stage number of scans */ - if(it->n==0){ - /* hack for continuous acquisition */ - win_out(0,AI_SC_Load_A_Registers); - win_out(0,AI_SC_Load_A_Registers+1); - win_out(0x000e,AI_Mode_1_Register); - }else{ - win_out((it->n-1)>>16,AI_SC_Load_A_Registers); - win_out((it->n-1)&0xffff,AI_SC_Load_A_Registers+1); - win_out(0x000d,AI_Mode_1_Register); - } - - /* load SC (Scan Count) */ - win_out(0x20,AI_Command_1_Register); - - /* - AI_SI_Special_Trigger_Delay=0 - AI_Pre_Trigger=0 - AI_START_STOP_Select_Register: - AI_START_Polarity=0 (?) rising edge - AI_START_Edge=1 edge triggered - AI_START_Sync=1 (?) - AI_START_Select=1 PFI0 - AI_STOP_Polarity=0 rising edge - AI_STOP_Edge=0 level - AI_STOP_Sync=1 - AI_STOP_Select=19 external pin (configuration mem) - */ - win_out(AI_START_Edge|AI_START_Sync|AI_START_Select(1)| - AI_STOP_Select(19)|AI_STOP_Sync, - AI_START_STOP_Select_Register); - -#if 0 - win_out((it->trigvar>>16),AI_SI_Load_A_Registers); - win_out((it->trigvar&0xffff),AI_SI_Load_A_Registers+1); - /* AI_SI_Initial_Load_Source=A */ - win_out(0,AI_Mode_2_Register); - /* load SI */ - win_out(0x200,AI_Command_1_Register); - - /* stage freq. counter into SI B */ - win_out((it->trigvar>>16),AI_SI_Load_B_Registers); - win_out((it->trigvar&0xffff),AI_SI_Load_B_Registers+1); -#endif - - win_out(trigvar1,AI_SI2_Load_A_Register); /* 0,0 does not work. */ - win_out(trigvar1,AI_SI2_Load_B_Register); - - /* AI_SI2_Reload_Mode = alternate */ - /* AI_SI2_Initial_Load_Source = A */ - win_out(0x0100,AI_Mode_2_Register); - - /* AI_SI2_Load */ - win_out(0x0800,AI_Command_1_Register); - - /* AI_SI_Initial_Load_Source=0 - AI_SI_Reload_Mode(0) - AI_SI2_Reload_Mode = alternate, AI_SI2_Initial_Load_Source = B */ - win_out(0x0300,AI_Mode_2_Register); - - if(dev->irq){ - int bits; - - /* interrupt on FIFO, errors, SC_TC */ - bits=0x00a1; - - if(s->async->cb_mask&COMEDI_CB_EOS){ - /* wake on end-of-scan */ - devpriv->aimode=AIMODE_SCAN; - }else{ - devpriv->aimode=AIMODE_HALF_FULL; - } - switch(devpriv->aimode){ - case AIMODE_HALF_FULL: - /*generate FIFO interrupts on half-full */ - win_out(AI_SI2_Source_Select|AI_FIFO_Mode_HF|0x0000,AI_Mode_3_Register); - break; - case AIMODE_SAMPLE: - /*generate FIFO interrupts on non-empty */ - win_out(AI_SI2_Source_Select|AI_FIFO_Mode_NE|0x0000,AI_Mode_3_Register); - break; - case AIMODE_SCAN: - /*generate FIFO interrupts on half-full */ - win_out(AI_SI2_Source_Select|AI_FIFO_Mode_HF|0x0000,AI_Mode_3_Register); - bits|=AI_STOP_Interrupt_Enable; - break; - default: - break; - } - - /* clear interrupts */ - win_out(0x3f80,Interrupt_A_Ack_Register); - - win_out(bits,Interrupt_A_Enable_Register) ; - }else{ - /* interrupt on nothing */ - win_out(0x0000,Interrupt_A_Enable_Register) ; - - /* XXX start polling if necessary */ - } - - /* end configuration */ - win_out(AI_Configuration_End,Joint_Reset_Register); - - /* AI_SI2_Arm, AI_DIV_Arm, AI_SC_Arm */ - win_out(0x1500,AI_Command_1_Register); - - /* AI_START1_Pulse */ - win_out(AI_START1_Pulse,AI_Command_2_Register); - - win_restore(wsave); - return 0; -} -#endif - static void ni_ao_fifo_load(comedi_device *dev,comedi_subdevice *s, sampl_t *data,int n) @@ -1782,230 +1433,6 @@ static int ni_ao_cmdtest(comedi_device *dev,comedi_subdevice *s,comedi_cmd *cmd) return 0; } -#ifdef USE_TRIG -static int ni_ao_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - unsigned int data; - unsigned int conf; - unsigned int chan; - unsigned int range; - int i; - - /* XXX this function could use a little cleanup to make sure that it - * gets the range settings correct for every board. */ - -for(i=0;in_chan;i++){ - data=it->data[i]; - chan=CR_CHAN(it->chanlist[i]); - - conf=chan<<8; - - /* XXX check range with current range in flaglist[chan] */ - /* should update calibration if range changes (ick) */ - - range = CR_RANGE(it->chanlist[i]); - if(boardtype.ao_unipolar){ - conf |= (range&1)^1; - } - conf |= (range&2)<<1; - - /* not all boards can deglitch, but this shouldn't hurt */ - if(it->flags & TRIG_DEGLITCH) - conf |= 2; - - /* analog reference */ - /* AREF_OTHER connects AO ground to AI ground, i think */ - conf |= (CR_AREF(it->chanlist[i])==AREF_OTHER)? 8 : 0; - - ni_writew(conf,AO_Configuration); - - if(((range&1)==0) || !boardtype.ao_unipolar) - data^=(1<<(boardtype.aobits-1)); - - ni_writew(data,(chan)? DAC1_Direct_Data : DAC0_Direct_Data); -} - - return i; -} -#endif - -#ifdef USE_TRIG -static int ni_ao_mode2(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - unsigned int conf; - unsigned int chan; - unsigned int range; - int trigvar; - - trigvar = ni_ns_to_timer(&it->trigvar,TRIG_ROUND_NEAREST); - - chan=CR_CHAN(it->chanlist[0]); - - conf=chan<<8; - - /* XXX check range with current range in flaglist[chan] */ - /* should update calibration if range changes (ick) */ - - range = CR_RANGE(it->chanlist[0]); - conf |= (range&1); - conf |= (range&2)<<1; - - /* not all boards can deglitch, but this shouldn't hurt */ - if(it->flags & TRIG_DEGLITCH) - conf |= 2; - - /* analog reference */ - /* AREF_OTHER connects AO ground to AI ground, i think */ - conf |= (CR_AREF(it->chanlist[0])==AREF_OTHER)? 8 : 0; - - win_out(AO_Disarm,AO_Command_1_Register); - - ni_writew(conf,AO_Configuration); - - /* user is supposed to write() to buffer before triggering */ - if(ni_ao_prep_fifo(dev,s)==0) - return -EIO; - - win_out(AO_Configuration_Start,Joint_Reset_Register); - - devpriv->ao_mode1|=AO_Trigger_Once; - win_out(devpriv->ao_mode1,AO_Mode_1_Register); - devpriv->ao_trigger_select&=~(AO_START1_Polarity|AO_START1_Select(-1)); - devpriv->ao_trigger_select|=AO_START1_Edge|AO_START1_Sync; - win_out(devpriv->ao_trigger_select,AO_Trigger_Select_Register); - devpriv->ao_mode3&=~AO_Trigger_Length; - win_out(devpriv->ao_mode3,AO_Mode_3_Register); - - if(it->n==0){ - devpriv->ao_mode1|=AO_Continuous; - }else{ - devpriv->ao_mode1&=~AO_Continuous; - } - win_out(devpriv->ao_mode1,AO_Mode_1_Register); - devpriv->ao_mode2&=~AO_BC_Initial_Load_Source; - win_out(devpriv->ao_mode2,AO_Mode_2_Register); - if(it->n==0){ - win_out(0xff,AO_BC_Load_A_Register_High); - win_out(0xffff,AO_BC_Load_A_Register_Low); - }else{ - win_out(0,AO_BC_Load_A_Register_High); - win_out(0,AO_BC_Load_A_Register_Low); - } - win_out(AO_BC_Load,AO_Command_1_Register); - devpriv->ao_mode2&=~AO_UC_Initial_Load_Source; - win_out(devpriv->ao_mode2,AO_Mode_2_Register); - if(it->n==0){ - win_out(0xff,AO_UC_Load_A_Register_High); - win_out(0xffff,AO_UC_Load_A_Register_Low); - win_out(AO_UC_Load,AO_Command_1_Register); - win_out(0xff,AO_UC_Load_A_Register_High); - win_out(0xffff,AO_UC_Load_A_Register_Low); - }else{ - win_out(0,AO_UC_Load_A_Register_High); - win_out(0,AO_UC_Load_A_Register_Low); - win_out(AO_UC_Load,AO_Command_1_Register); - win_out((it->n-1)>>16,AO_UC_Load_A_Register_High); - win_out((it->n-1)&0xffff,AO_UC_Load_A_Register_Low); - } - - devpriv->ao_cmd2&=~AO_BC_Gate_Enable; - ni_writew(devpriv->ao_cmd2,AO_Command_2); - devpriv->ao_mode1&=~(AO_UI_Source_Select(0x1f)|AO_UI_Source_Polarity); - win_out(devpriv->ao_mode1,AO_Mode_1_Register); - devpriv->ao_mode2&=~(AO_UI_Reload_Mode(3)|AO_UI_Initial_Load_Source); - win_out(devpriv->ao_mode2,AO_Mode_2_Register); - win_out(0,AO_UI_Load_A_Register_High); - win_out(1,AO_UI_Load_A_Register_Low); - win_out(AO_UI_Load,AO_Command_1_Register); - win_out((trigvar>>16),AO_UI_Load_A_Register_High); - win_out((trigvar&0xffff),AO_UI_Load_A_Register_Low); - - devpriv->ao_mode1&=~AO_Multiple_Channels; - win_out(devpriv->ao_mode1,AO_Mode_1_Register); - win_out(AO_UPDATE_Output_Select(1),AO_Output_Control_Register); - - win_out(AO_DAC0_Update_Mode|AO_DAC1_Update_Mode,AO_Command_1_Register); - - devpriv->ao_mode3|=AO_Stop_On_Overrun_Error; - win_out(devpriv->ao_mode3,AO_Mode_3_Register); - -devpriv->ao_mode2|=AO_FIFO_Mode(1); - devpriv->ao_mode2&=~AO_FIFO_Retransmit_Enable; - win_out(devpriv->ao_mode2,AO_Mode_2_Register); - - win_out(AO_Configuration_End,Joint_Reset_Register); - - win_out(devpriv->ao_mode3|AO_Not_An_UPDATE,AO_Mode_3_Register); - win_out(devpriv->ao_mode3,AO_Mode_3_Register); - - /* wait for DACs to be loaded */ - udelay(100); - - win_out(devpriv->ao_cmd1|AO_UI_Arm|AO_UC_Arm|AO_BC_Arm|AO_DAC1_Update_Mode|AO_DAC0_Update_Mode, - AO_Command_1_Register); - - win_out(AO_FIFO_Interrupt_Enable|AO_Error_Interrupt_Enable,Interrupt_B_Enable_Register); - - - ni_writew(devpriv->ao_cmd2|AO_START1_Pulse,AO_Command_2); - - return 0; -} -#endif - - -#ifdef USE_TRIG -/* - digital i/o - -*/ -static int ni_dio(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - int data,mask; - int i; - int temp; - - /* rt stuff */ - temp=win_save(); - - if(it->flags & TRIG_CONFIG){ - data=s->io_bits; - for(i=0;in_chan;i++){ - mask=1<chanlist[i]); - data&= ~mask; - if(it->data[i]) - data|=mask; - } - s->io_bits=data; - devpriv->dio_control &= ~DIO_Pins_Dir_Mask; - devpriv->dio_control |= DIO_Pins_Dir(s->io_bits); - win_out(devpriv->dio_control,DIO_Control_Register); -#ifdef DEBUG_DIO - printk("Parallel DIO config bits=0x%x\n", s->io_bits); -#endif - }else{ - if(it->flags & TRIG_WRITE){ - do_pack(&s->state,it); -#ifdef DEBUG_DIO - printk("Parallel DIO write bits=0x%x\n", s->state); -#endif - devpriv->dio_output &= ~DIO_Parallel_Data_Mask; - devpriv->dio_output |= DIO_Parallel_Data_Out(s->state); - win_out(devpriv->dio_output,DIO_Output_Register); - }else{ - data=ni_readw(DIO_Parallel_Input); - di_unpack(data,it); -#ifdef DEBUG_DIO - printk("Parallel DIO read bits=0x%x\n", data); -#endif - } - } - - win_restore(temp); - - return it->n_chan; -} -#endif static int ni_dio_insn_config(comedi_device *dev,comedi_subdevice *s, comedi_insn *insn,lsampl_t *data) @@ -2108,11 +1535,6 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it) s->len_chanlist=512; /* XXX is this the same for PCI-MIO ? */ s->maxdata=(1<range_table=ni_range_lkup[boardtype.gainlkup]; -#ifdef USE_TRIG - s->trig[0]=ni_ai_mode0; - s->trig[2]=ni_ai_mode2; - s->trig[4]=ni_ai_mode4; -#endif s->insn_read=ni_ai_insn_read; s->do_cmdtest=ni_ai_cmdtest; s->do_cmd=ni_ai_cmd; @@ -2136,15 +1558,7 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it) s->insn_write=ni_ao_insn_write; s->do_cmd=ni_ao_cmd; s->do_cmdtest=ni_ao_cmdtest; -#ifdef USE_TRIG - s->trig[0]=ni_ao_mode0; -#endif s->len_chanlist = 2; -#ifdef USE_TRIG - if(boardtype.ao_fifo_depth){ - s->trig[2]=ni_ao_mode2; - } -#endif }else{ s->type=COMEDI_SUBD_UNUSED; } @@ -2160,9 +1574,6 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it) s->io_bits=0; /* all bits input */ s->insn_bits=ni_dio_insn_bits; s->insn_config=ni_dio_insn_config; -#ifdef USE_TRIG - s->trig[0]=ni_dio; -#endif /* dio setup */ devpriv->dio_control = DIO_Pins_Dir(s->io_bits); @@ -2202,9 +1613,6 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it) s->n_chan=512; s->maxdata=0xff; s->insn_read=ni_eeprom_insn_read; -#ifdef USE_TRIG - s->trig[0]=ni_eeprom; -#endif /* ai configuration */ ni_ai_reset(dev,dev->subdevices+0); @@ -2266,18 +1674,6 @@ static int ni_eeprom_insn_read(comedi_device *dev,comedi_subdevice *s, return 1; } -#ifdef USE_TRIG -static int ni_eeprom(comedi_device *dev,comedi_subdevice *s,comedi_trig *it) -{ - int i; - - for(i=0;in_chan;i++) - it->data[i]=ni_read_eeprom(dev,CR_CHAN(it->chanlist[i])); - - return i; -} -#endif - /* reads bytes out of eeprom */ -- 2.26.2