From d7864398b7209963dd33fcd5f53aaff7a2715320 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sun, 6 Mar 2005 17:31:08 +0000 Subject: [PATCH] add support for new INSN_CONFIG_DIO_QUERY --- comedi/drivers/8255.c | 8 +++-- comedi/drivers/adl_pci6208.c | 2 -- comedi/drivers/cb_das16_cs.c | 19 ++++++++---- comedi/drivers/cb_pcidas64.c | 7 +++-- comedi/drivers/dt3000.c | 24 +++++++++++---- comedi/drivers/gsc_hpdi.c | 15 +++++----- comedi/drivers/me4000.c | 9 +++--- comedi/drivers/mpc8260cpm.c | 14 +++++---- comedi/drivers/ni_660x.c | 53 ++++++++++++++++++---------------- comedi/drivers/ni_670x.c | 21 +++++++++----- comedi/drivers/ni_at_ao.c | 17 ++++++++--- comedi/drivers/ni_mio_common.c | 9 ++++-- comedi/drivers/ni_pcidio.c | 8 +++-- comedi/drivers/rtd520.c | 23 ++++++++++----- comedi/drivers/skel.c | 20 +++++++++---- comedi/drivers/ssv_dnp.c | 14 ++++++++- comedi/drivers/usbdux.c | 18 ++++++++---- 17 files changed, 185 insertions(+), 96 deletions(-) diff --git a/comedi/drivers/8255.c b/comedi/drivers/8255.c index 09d69821..3a8679b7 100644 --- a/comedi/drivers/8255.c +++ b/comedi/drivers/8255.c @@ -184,12 +184,16 @@ static int subdev_8255_insn_config(comedi_device *dev,comedi_subdevice *s, } switch(data[0]){ - case COMEDI_INPUT: + case INSN_CONFIG_DIO_INPUT: s->io_bits&=~bits; break; - case COMEDI_OUTPUT: + case INSN_CONFIG_DIO_OUTPUT: s->io_bits|=bits; break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; default: return -EINVAL; } diff --git a/comedi/drivers/adl_pci6208.c b/comedi/drivers/adl_pci6208.c index 29706560..2ec2518f 100644 --- a/comedi/drivers/adl_pci6208.c +++ b/comedi/drivers/adl_pci6208.c @@ -283,8 +283,6 @@ static int pci6208_ao_rinsn(comedi_device *dev,comedi_subdevice *s, //{ // int chan=CR_CHAN(insn->chanspec); -// if(insn->n!=1)return -EINVAL; - /* The input or output configuration of each digital line is * configured by a special insn_config instruction. chanspec * contains the channel to be changed, and data[0] contains the diff --git a/comedi/drivers/cb_das16_cs.c b/comedi/drivers/cb_das16_cs.c index 5ef12f38..c437b836 100644 --- a/comedi/drivers/cb_das16_cs.c +++ b/comedi/drivers/cb_das16_cs.c @@ -555,15 +555,24 @@ static int das16cs_dio_insn_config(comedi_device *dev,comedi_subdevice *s, int chan=CR_CHAN(insn->chanspec); int bits; - if(insn->n!=1)return -EINVAL; - if(chan<4)bits=0x0f; else bits=0xf0; - if(data[0]==COMEDI_OUTPUT){ + switch(data[0]) + { + case INSN_CONFIG_DIO_OUTPUT: s->io_bits |= bits; - }else{ + break; + case INSN_CONFIG_DIO_INPUT: s->io_bits &= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + break; } devpriv->status2 &= ~0x00c0; @@ -572,7 +581,7 @@ static int das16cs_dio_insn_config(comedi_device *dev,comedi_subdevice *s, outw(devpriv->status2,dev->iobase + 6); - return 1; + return insn->n; } static int das16cs_timer_insn_read(comedi_device *dev,comedi_subdevice *s, diff --git a/comedi/drivers/cb_pcidas64.c b/comedi/drivers/cb_pcidas64.c index 14caf9f2..ba9e546d 100644 --- a/comedi/drivers/cb_pcidas64.c +++ b/comedi/drivers/cb_pcidas64.c @@ -3537,12 +3537,15 @@ static int dio_60xx_config_insn(comedi_device *dev, comedi_subdevice *s, comedi_ switch(data[0]) { - case COMEDI_INPUT: + case INSN_CONFIG_DIO_INPUT: s->io_bits &= ~mask; break; - case COMEDI_OUTPUT: + case INSN_CONFIG_DIO_OUTPUT: s->io_bits |= mask; break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; + return 2; default: return -EINVAL; } diff --git a/comedi/drivers/dt3000.c b/comedi/drivers/dt3000.c index 81a355fd..ae2827d8 100644 --- a/comedi/drivers/dt3000.c +++ b/comedi/drivers/dt3000.c @@ -704,16 +704,28 @@ static int dt3k_dio_insn_config(comedi_device *dev,comedi_subdevice *s, { int mask; - if(insn->n!=1)return -EINVAL; - mask=(CR_CHAN(insn->chanspec)<4)?0x0f:0xf0; - if(data[0]==COMEDI_OUTPUT)s->io_bits|=mask; - else s->io_bits&=~mask; - + + switch(data[0]) + { + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits|=mask; + break; + case INSN_CONFIG_DIO_INPUT: + s->io_bits&=~mask; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + break; + } mask=(s->io_bits&0x01)|((s->io_bits&0x10)>>3); dt3k_dio_config(dev,mask); - return 1; + return insn->n; } static int dt3k_dio_insn_bits(comedi_device *dev,comedi_subdevice *s, diff --git a/comedi/drivers/gsc_hpdi.c b/comedi/drivers/gsc_hpdi.c index d485a1f7..45e9f5e6 100644 --- a/comedi/drivers/gsc_hpdi.c +++ b/comedi/drivers/gsc_hpdi.c @@ -346,18 +346,19 @@ static int dio_config_insn( comedi_device *dev,comedi_subdevice *s, { switch( data[ 0 ] ) { - case COMEDI_OUTPUT: - if( insn->n != 1 ) return -EINVAL; + case INSN_CONFIG_DIO_OUTPUT: priv(dev)->dio_config_output = 1; - return 1; + return insn->n; break; - case COMEDI_INPUT: - if( insn->n != 1 ) return -EINVAL; + case INSN_CONFIG_DIO_INPUT: priv(dev)->dio_config_output = 0; - return 1; + return insn->n; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = priv(dev)->dio_config_output ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; break; case INSN_CONFIG_BLOCK_SIZE: - if( insn->n != 2 ) return -EINVAL; return dio_config_block_size( dev, data ); break; default: diff --git a/comedi/drivers/me4000.c b/comedi/drivers/me4000.c index cea0e2fa..90deda78 100644 --- a/comedi/drivers/me4000.c +++ b/comedi/drivers/me4000.c @@ -1956,10 +1956,11 @@ static int me4000_dio_insn_config( CALL_PDEBUG("In me4000_dio_insn_config()\n"); - - /* Only data[0] is valid */ - if(insn->n != 1) - return -EINVAL; + if(data[0] == INSN_CONFIG_DIO_QUERY) + { + data[1] = (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + } /* * The input or output configuration of each digital line is diff --git a/comedi/drivers/mpc8260cpm.c b/comedi/drivers/mpc8260cpm.c index 2470295a..87be848f 100644 --- a/comedi/drivers/mpc8260cpm.c +++ b/comedi/drivers/mpc8260cpm.c @@ -82,8 +82,8 @@ static int mpc8260cpm_attach(comedi_device *dev,comedi_devconfig *it) s->n_chan=32; s->maxdata=1; s->range_table=&range_digital; - s->insn_config = &mpc8260cpm_dio_config; - s->insn_bits = &mpc8260cpm_dio_bits; + s->insn_config = mpc8260cpm_dio_config; + s->insn_bits = mpc8260cpm_dio_bits; } return 1; @@ -117,8 +117,6 @@ static int mpc8260cpm_dio_config(comedi_device *dev,comedi_subdevice *s,comedi_i unsigned int mask; int port; - if(insn->n!=1)return -EINVAL; - port = (int)s->private; mask = 1<chanspec); if(mask&cpm_reserved_bits[port]){ @@ -126,12 +124,16 @@ static int mpc8260cpm_dio_config(comedi_device *dev,comedi_subdevice *s,comedi_i } switch(data[0]){ - case COMEDI_OUTPUT: + case INSN_CONFIG_DIO_OUTPUT: s->io_bits |= mask; break; - case COMEDI_INPUT: + case INSN_CONFIG_DIO_INPUT: s->io_bits &= ~mask; break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; default: return -EINVAL; } diff --git a/comedi/drivers/ni_660x.c b/comedi/drivers/ni_660x.c index 77e10014..a4249b4b 100644 --- a/comedi/drivers/ni_660x.c +++ b/comedi/drivers/ni_660x.c @@ -1322,31 +1322,34 @@ static int ni_660x_dio_insn_config(comedi_device *dev, comedi_insn *insn, lsampl_t *data) { - int chan=CR_CHAN(insn->chanspec); - - if(insn->n!=1)return -EINVAL; - - /* The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. */ - - if(data[0]==COMEDI_OUTPUT) - { - s->io_bits |= 1<io_bits &= ~(1<io_bits,dev->iobase + registerData[STCDIOControl].offset); - /* Should we do also something with the IO configuration registers, - see p 3-38 of register level prog. manual - */ - - return 1; - return -EINVAL; + int chan=CR_CHAN(insn->chanspec); + + /* The input or output configuration of each digital line is + * configured by a special insn_config instruction. chanspec + * contains the channel to be changed, and data[0] contains the + * value COMEDI_INPUT or COMEDI_OUTPUT. */ + + switch(data[0]) + { + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= 1<io_bits &= ~(1<io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + default: + return -EINVAL; + break; + }; + // No GPCT_OFFSET[chipset] offset here?? + writew(s->io_bits,dev->iobase + registerData[STCDIOControl].offset); + /* Should we do also something with the IO configuration registers, + see p 3-38 of register level prog. manual + */ + return insn->n; } diff --git a/comedi/drivers/ni_670x.c b/comedi/drivers/ni_670x.c index 11ed48d4..7d29bbd8 100644 --- a/comedi/drivers/ni_670x.c +++ b/comedi/drivers/ni_670x.c @@ -277,21 +277,26 @@ static int ni_670x_dio_insn_bits(comedi_device *dev,comedi_subdevice *s,comedi_i static int ni_670x_dio_insn_config(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) { int chan=CR_CHAN(insn->chanspec); - - - if(insn->n!=1) return -EINVAL; - if(data[0]==COMEDI_OUTPUT) + switch(data[0]) { + case INSN_CONFIG_DIO_OUTPUT: s->io_bits |= 1<io_bits &= ~(1<io_bits & (1<n; + break; + default: + return -EINVAL; + break; } writel(s->io_bits,dev->iobase + DIO_PORT0_DIR_OFFSET); - return 1; + return insn->n; } static int ni_670x_find_device(comedi_device *dev,int bus,int slot) diff --git a/comedi/drivers/ni_at_ao.c b/comedi/drivers/ni_at_ao.c index 546013ea..5f0e57d8 100644 --- a/comedi/drivers/ni_at_ao.c +++ b/comedi/drivers/ni_at_ao.c @@ -378,8 +378,6 @@ static int atao_dio_insn_config(comedi_device *dev,comedi_subdevice *s, int chan=CR_CHAN(insn->chanspec); unsigned int mask, bit; - if(insn->n!=1)return -EINVAL; - /* The input or output configuration of each digital line is * configured by a special insn_config instruction. chanspec * contains the channel to be changed, and data[0] contains the @@ -388,12 +386,23 @@ static int atao_dio_insn_config(comedi_device *dev,comedi_subdevice *s, mask = (chan < 4) ? 0x0f : 0xf0; bit = (chan < 4) ? DOUTEN1 : DOUTEN2; - if(data[0]==COMEDI_OUTPUT){ + switch(data[0]) + { + case INSN_CONFIG_DIO_OUTPUT: s->io_bits |= mask; devpriv->cfg3 |= bit; - }else{ + break; + case INSN_CONFIG_DIO_INPUT: s->io_bits &= ~mask; devpriv->cfg3 &= ~bit; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + break; } outw(devpriv->cfg3, dev->iobase + ATAO_CFG3); diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index 4bf0c1d4..502eaba0 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -2401,14 +2401,17 @@ static int ni_dio_insn_config(comedi_device *dev,comedi_subdevice *s, printk("ni_dio_insn_config() chan=%d io=%d\n", CR_CHAN(insn->chanspec),data[0]); #endif - if(insn->n!=1)return -EINVAL; switch(data[0]){ - case COMEDI_OUTPUT: + case INSN_CONFIG_DIO_OUTPUT: s->io_bits |= 1<chanspec); break; - case COMEDI_INPUT: + case INSN_CONFIG_DIO_INPUT: s->io_bits &= ~(1<chanspec)); break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & (1<chanspec))) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; default: return -EINVAL; } diff --git a/comedi/drivers/ni_pcidio.c b/comedi/drivers/ni_pcidio.c index f47b5de1..297845b6 100644 --- a/comedi/drivers/ni_pcidio.c +++ b/comedi/drivers/ni_pcidio.c @@ -622,12 +622,16 @@ static int ni_pcidio_insn_config(comedi_device *dev,comedi_subdevice *s, { if(insn->n!=1)return -EINVAL; switch(data[0]){ - case COMEDI_OUTPUT: + case INSN_CONFIG_DIO_OUTPUT: s->io_bits |= 1<chanspec); break; - case COMEDI_INPUT: + case INSN_CONFIG_DIO_INPUT: s->io_bits &= ~(1<chanspec)); break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & (1<chanspec))) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; default: return -EINVAL; } diff --git a/comedi/drivers/rtd520.c b/comedi/drivers/rtd520.c index 1781a805..cc22ddd2 100644 --- a/comedi/drivers/rtd520.c +++ b/comedi/drivers/rtd520.c @@ -2266,18 +2266,25 @@ static int rtd_dio_insn_config ( { int chan=CR_CHAN(insn->chanspec); - if (insn->n!=1) return -EINVAL; - /* The input or output configuration of each digital line is * configured by a special insn_config instruction. chanspec * contains the channel to be changed, and data[0] contains the * value COMEDI_INPUT or COMEDI_OUTPUT. */ - - if (data[0]==COMEDI_OUTPUT) { - s->io_bits |= 1<io_bits &= ~(1<io_bits |= 1<io_bits &= ~(1<io_bits & (1<n; + break; + default: + return -EINVAL; + } DPRINTK("rtd520: port_0_direction=0x%x (1 means out)\n", s->io_bits); /* TODO support digital match interrupts and strobes */ diff --git a/comedi/drivers/skel.c b/comedi/drivers/skel.c index 63141c0a..dda15200 100644 --- a/comedi/drivers/skel.c +++ b/comedi/drivers/skel.c @@ -561,21 +561,29 @@ static int skel_dio_insn_config(comedi_device *dev,comedi_subdevice *s, { int chan=CR_CHAN(insn->chanspec); - if(insn->n!=1)return -EINVAL; - /* The input or output configuration of each digital line is * configured by a special insn_config instruction. chanspec * contains the channel to be changed, and data[0] contains the * value COMEDI_INPUT or COMEDI_OUTPUT. */ - - if(data[0]==COMEDI_OUTPUT){ + switch(data[0]) + { + case INSN_CONFIG_DIO_OUTPUT: s->io_bits |= 1<io_bits &= ~(1<io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + break; } //outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); - return 1; + return insn->n; } /* diff --git a/comedi/drivers/ssv_dnp.c b/comedi/drivers/ssv_dnp.c index f1ee19f3..5ca01889 100644 --- a/comedi/drivers/ssv_dnp.c +++ b/comedi/drivers/ssv_dnp.c @@ -279,8 +279,20 @@ static int dnp_dio_insn_config( u8 register_buffer; int chan=CR_CHAN(insn->chanspec); /* reduces chanspec to lower 16 bits */ - if (insn->n != 1) return -EINVAL; /* this insn uses only data[0] */ + switch(data[0]) + { + case INSN_CONFIG_DIO_OUTPUT: + case INSN_CONFIG_DIO_INPUT: + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (inb(CSCDR) & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + break; + } /* Test: which port does the channel belong to? */ /* We have to pay attention with port C: this is the meaning of PCMR: */ diff --git a/comedi/drivers/usbdux.c b/comedi/drivers/usbdux.c index 229e095e..c6b38977 100644 --- a/comedi/drivers/usbdux.c +++ b/comedi/drivers/usbdux.c @@ -1876,21 +1876,29 @@ static int usbdux_dio_insn_config (comedi_device *dev, lsampl_t *data) { int chan=CR_CHAN(insn->chanspec); - if (insn->n!=1) return -EINVAL; - /* The input or output configuration of each digital line is * configured by a special insn_config instruction. chanspec * contains the channel to be changed, and data[0] contains the * value COMEDI_INPUT or COMEDI_OUTPUT. */ - if (data[0]==COMEDI_OUTPUT) { + switch(data[0]) + { + case INSN_CONFIG_DIO_OUTPUT: s->io_bits |= 1<io_bits &= ~(1<io_bits & (1<n; } -- 2.26.2