From 6e6fa910df0bf5881f5d143b66903d872de6f727 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Wed, 6 Feb 2002 20:41:21 +0000 Subject: [PATCH] Change caldac code to be slightly less confusing --- comedi/drivers/ni_atmio.c | 19 +++++------ comedi/drivers/ni_mio_common.c | 53 ++++++++++++++++------------- comedi/drivers/ni_mio_cs.c | 11 +++--- comedi/drivers/ni_pcimio.c | 61 ++++++++++++++++------------------ comedi/drivers/ni_stc.h | 7 ++-- 5 files changed, 71 insertions(+), 80 deletions(-) diff --git a/comedi/drivers/ni_atmio.c b/comedi/drivers/ni_atmio.c index 1dccaf4c..99c9776e 100644 --- a/comedi/drivers/ni_atmio.c +++ b/comedi/drivers/ni_atmio.c @@ -108,9 +108,6 @@ External triggering is supported for some events. The channel index #define NI_SIZE 0x20 -static struct caldac_struct *type1[]={&caldac_mb88341,NULL,NULL}; -static struct caldac_struct *type2[]={&caldac_dac8800,&caldac_dac8043,NULL}; - #define MAX_N_CALDACS 12 static ni_board ni_boards[]={ @@ -127,7 +124,7 @@ static ni_board ni_boards[]={ ao_fifo_depth: 2048, ao_unipolar: 1, has_8255: 0, - caldac: type1, + caldac: {mb88341}, }, { device_id: 25, name: "at-mio-16e-2", @@ -142,7 +139,7 @@ static ni_board ni_boards[]={ ao_fifo_depth: 2048, ao_unipolar: 1, has_8255: 0, - caldac: type1, + caldac: {mb88341}, }, { device_id: 36, name: "at-mio-16e-10", @@ -156,7 +153,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 0, ao_unipolar: 1, - caldac: type1, + caldac: {mb88341}, has_8255: 0, }, { device_id: 37, @@ -171,7 +168,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 0, ao_unipolar: 1, - caldac: type1, + caldac: {mb88341}, has_8255: 1, }, { device_id: 38, @@ -187,7 +184,7 @@ static ni_board ni_boards[]={ ao_fifo_depth: 2048, ao_unipolar: 1, has_8255: 0, - caldac: type1, + caldac: {mb88341}, }, { device_id: 39, name: "at-mio-16xe-50", @@ -201,7 +198,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 0, ao_unipolar: 0, - caldac: type2, + caldac: {dac8800,dac8043}, has_8255: 0, }, { device_id: 50, @@ -216,7 +213,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 0, /* unknown */ ao_unipolar: 0, /* unknown */ - caldac: type2, + caldac: {dac8800,dac8043}, has_8255: 0, }, { device_id: 51, @@ -232,7 +229,7 @@ static ni_board ni_boards[]={ ao_fifo_depth: 0, aorangelkup: 0, ao_unipolar: 0, - caldac: type2, + caldac: {dac8800,dac8043}, has_8255: 0, } }; diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index fe3bb480..4e923b23 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -2200,9 +2200,7 @@ static int ni_calib_insn_read(comedi_device *dev,comedi_subdevice *s, static int pack_mb88341(int addr,int val,int *bitstring); static int pack_dac8800(int addr,int val,int *bitstring); static int pack_dac8043(int addr,int val,int *bitstring); -#ifdef PCIMIO static int pack_ad8522(int addr,int val,int *bitstring); -#endif struct caldac_struct{ int n_chans; @@ -2210,13 +2208,12 @@ struct caldac_struct{ int (*packbits)(int,int,int *); }; -static struct caldac_struct caldac_mb88341={ 12, 8, pack_mb88341 }; -static struct caldac_struct caldac_dac8800={ 8, 8, pack_dac8800 }; -static struct caldac_struct caldac_dac8043={ 1, 12, pack_dac8043 }; -#ifdef PCIMIO -static struct caldac_struct caldac_ad8522={ 2, 12, pack_ad8522 }; -#endif - +static struct caldac_struct caldacs[] = { + [mb88341] = { 12, 8, pack_mb88341 }, + [dac8800] = { 8, 8, pack_dac8800 }, + [dac8043] = { 1, 12, pack_dac8043 }, + [ad8522] = { 2, 12, pack_ad8522 }, +}; static void caldac_setup(comedi_device *dev,comedi_subdevice *s) { @@ -2225,13 +2222,16 @@ static void caldac_setup(comedi_device *dev,comedi_subdevice *s) int n_chans=0; int n_bits; int diffbits=0; + int type; - if(!boardtype.caldac[0])return; - n_bits=boardtype.caldac[0]->n_bits; + type = boardtype.caldac[0]; + if(type==caldac_none)return; + n_bits=caldacs[type].n_bits; for(i=0;i<3;i++){ - if(!boardtype.caldac[i])break; - if(boardtype.caldac[i]->n_bits!=n_bits)diffbits=1; - n_chans+=boardtype.caldac[i]->n_chans; + type = boardtype.caldac[i]; + if(type==caldac_none)break; + if(caldacs[type].n_bits!=n_bits)diffbits=1; + n_chans+=caldacs[type].n_chans; } n_dacs=i; s->n_chan=n_chans; @@ -2245,30 +2245,37 @@ static void caldac_setup(comedi_device *dev,comedi_subdevice *s) s->maxdata_list=devpriv->caldac_maxdata_list; chan=0; for(i=0;in_chans;j++){ + type = boardtype.caldac[i]; + for(j=0;jmaxdata_list[chan]= - (1<n_bits)-1; + (1<maxdata=(1<n_bits)-1; + type = boardtype.caldac[0]; + s->maxdata=(1<n_chans){ - bits=boardtype.caldac[i]->packbits(addr,val,&bitstring); + type = boardtype.caldac[i]; + if(type==caldac_none)break; + if(addrn_chans; + addr-=caldacs[type].n_chans; } for(bit=1<<(bits-1);bit;bit>>=1){ @@ -2313,13 +2320,11 @@ static int pack_dac8043(int addr,int val,int *bitstring) return 12; } -#ifdef PCIMIO static int pack_ad8522(int addr,int val,int *bitstring) { *bitstring=(val&0xfff)|(addr ? 0xc000:0xa000); return 16; } -#endif diff --git a/comedi/drivers/ni_mio_cs.c b/comedi/drivers/ni_mio_cs.c index f73cf7d2..2d673a13 100644 --- a/comedi/drivers/ni_mio_cs.c +++ b/comedi/drivers/ni_mio_cs.c @@ -73,9 +73,6 @@ See the notes in the ni_atmio.o driver. #define NI_SIZE 0x20 -static struct caldac_struct *type1[]={&caldac_mb88341,NULL,NULL}; -static struct caldac_struct *type2[]={&caldac_dac8800,&caldac_dac8043,NULL}; - #define MAX_N_CALDACS 12 static ni_board ni_boards[]={ @@ -92,7 +89,7 @@ static ni_board ni_boards[]={ ao_fifo_depth: 0, ao_unipolar: 0, has_8255: 0, - caldac: type2, + caldac: {dac8800,dac8043}, }, { device_id: 0x010c, name: "DAQCard-ai-16e-4", @@ -107,7 +104,7 @@ static ni_board ni_boards[]={ ao_fifo_depth: 0, ao_unipolar: 0, has_8255: 0, - caldac: type1, /* or ad8804 */ + caldac: {mb88341}, /* or ad8804 */ }, { device_id: 0x02c4, name: "DAQCard-6062E", @@ -122,7 +119,7 @@ static ni_board ni_boards[]={ ao_fifo_depth: 2048, ao_unipolar: 0, has_8255: 0, - caldac: type2, + caldac: {dac8800,dac8043}, }, { device_id: 0x075e, name: "DAQCard-6024E", /* specs incorrect! */ @@ -137,7 +134,7 @@ static ni_board ni_boards[]={ ao_fifo_depth: 0, ao_unipolar: 0, has_8255: 0, - caldac: type2, + caldac: {dac8800,dac8043}, }, }; diff --git a/comedi/drivers/ni_pcimio.c b/comedi/drivers/ni_pcimio.c index 98901113..1d4b3144 100644 --- a/comedi/drivers/ni_pcimio.c +++ b/comedi/drivers/ni_pcimio.c @@ -109,11 +109,6 @@ DMA is halfway completed, but not yet operational. #define PCIMIO 1 #undef ATMIO -static struct caldac_struct *type1[]={&caldac_dac8800,&caldac_dac8043,NULL}; -static struct caldac_struct *type2[]={&caldac_dac8800,&caldac_dac8043,&caldac_ad8522}; -static struct caldac_struct *type3[]={&caldac_mb88341,NULL,NULL}; -static struct caldac_struct *type4[]={&caldac_mb88341,&caldac_mb88341,&caldac_ad8522}; - #define MAX_N_CALDACS (16+16+2) #define NI_VENDOR_ID 0x1093 @@ -162,7 +157,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 0, ao_unipolar: 0, - caldac: type1, + caldac: {dac8800,dac8043}, has_8255: 0, }, { device_id: 0x1170, @@ -177,7 +172,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_fifo_depth: 2048, ao_unipolar: 1, - caldac: type2, + caldac: {dac8800,dac8043,ad8522}, has_8255: 0, }, { device_id: 0x11d0, @@ -192,7 +187,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_fifo_depth: 2048, ao_unipolar: 1, - caldac: type2, + caldac: {dac8800,dac8043,ad8522}, has_8255: 0, }, @@ -208,7 +203,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 2048, ao_unipolar: 1, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, { device_id: 0x1190, @@ -223,7 +218,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 512, ao_unipolar: 1, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, { device_id: 0x11c0, @@ -238,7 +233,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 512, ao_unipolar: 1, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, @@ -254,7 +249,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_fifo_depth: 2048, ao_unipolar: 1, - caldac: type2, + caldac: {dac8800,dac8043,ad8522}, has_8255: 0, }, { device_id: 0x1270, @@ -269,7 +264,7 @@ static ni_board ni_boards[]={ aobits: 0, ao_fifo_depth: 0, ao_unipolar: 1, - caldac: type2, + caldac: {dac8800,dac8043,ad8522}, has_8255: 0, }, { device_id: 0x1340, @@ -284,7 +279,7 @@ static ni_board ni_boards[]={ aobits: 0, ao_fifo_depth: 0, ao_unipolar: 1, - caldac: type2, + caldac: {dac8800,dac8043,ad8522}, has_8255: 0, }, { device_id: 0x1350, @@ -299,7 +294,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 2048, ao_unipolar: 1, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, { device_id: 0x2a60, @@ -313,7 +308,7 @@ static ni_board ni_boards[]={ n_aochan: 0, aobits: 0, ao_unipolar: 0, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, { device_id: 0x2a70, @@ -328,7 +323,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 0, ao_unipolar: 1, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, { device_id: 0x2a80, @@ -343,7 +338,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 0, ao_unipolar: 1, - caldac: type3, + caldac: {mb88341}, has_8255: 1, }, { device_id: 0x2ab0, @@ -358,7 +353,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 0, ao_unipolar: 1, - caldac: type3, + caldac: {mb88341}, has_8255: 1, }, @@ -374,7 +369,7 @@ static ni_board ni_boards[]={ aobits: 0, ao_fifo_depth: 0, ao_unipolar: 0, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, { device_id: 0x2c80, @@ -389,7 +384,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 0, ao_unipolar: 0, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, { device_id: 0x18b0, @@ -404,9 +399,9 @@ static ni_board ni_boards[]={ aobits: 16, ao_unipolar: 1, ao_fifo_depth: 2048, - caldac: type4, + caldac: {mb88341,mb88341,ad8522}, }, - { device_id: 0x14e0, /* unknown */ + { device_id: 0x14e0, name: "pci-6110e", n_adchan: 4, adbits: 12, @@ -417,9 +412,9 @@ static ni_board ni_boards[]={ aobits: 16, ao_unipolar: 0, ao_fifo_depth: 2048, - caldac: type4, /* XXX */ + caldac: {mb88341,mb88341,ad8522},/* XXX */ }, - { device_id: 0x14f0, /* unknown */ + { device_id: 0x14f0, name: "pci-6111e", n_adchan: 2, adbits: 12, @@ -431,7 +426,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_unipolar: 0, ao_fifo_depth: 2048, - caldac: type4, /* XXX */ + caldac: {mb88341,mb88341,ad8522},/* XXX */ }, { device_id: 0x1880, name: "pci-6711", @@ -445,7 +440,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_unipolar: 0, ao_fifo_depth: 8192, - caldac: type4, /* XXX */ + caldac: {mb88341,mb88341,ad8522},/* XXX */ }, { device_id: 0x1870, name: "pci-6713", @@ -459,7 +454,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_unipolar: 0, ao_fifo_depth: 16384, - caldac: type4, /* XXX */ + caldac: {mb88341,mb88341,ad8522},/* XXX */ }, { device_id: 0x15b0, name: "pxi-6071e", @@ -473,7 +468,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 2048, ao_unipolar: 1, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, @@ -489,7 +484,7 @@ static ni_board ni_boards[]={ aobits: 12, ao_fifo_depth: 2048, ao_unipolar: 1, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, { device_id: 0x18c0, @@ -504,7 +499,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_unipolar: 1, ao_fifo_depth: 2048, - caldac: type4, + caldac: {mb88341,mb88341,ad8522}, }, { device_id: 0x1580, name: "pxi-6031e", @@ -518,7 +513,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_fifo_depth: 2048, ao_unipolar: 1, - caldac: type2, + caldac: {dac8800,dac8043,ad8522}, }, { device_id: 0x2890, name: "pci-6036e", @@ -532,7 +527,7 @@ static ni_board ni_boards[]={ aobits: 16, ao_fifo_depth: 0, ao_unipolar: 0, - caldac: type3, + caldac: {mb88341}, has_8255: 0, }, }; diff --git a/comedi/drivers/ni_stc.h b/comedi/drivers/ni_stc.h index 8615711f..914ef734 100644 --- a/comedi/drivers/ni_stc.h +++ b/comedi/drivers/ni_stc.h @@ -568,10 +568,7 @@ */ enum{ ai_gain_16=0, ai_gain_8, ai_gain_14, ai_gain_4, ai_gain_611x }; -extern struct caldac_struct caldac_mb88341, - caldac_dac8800, - caldac_dac8043, - caldac_ad8522; +enum caldac_enum { caldac_none=0, mb88341, dac8800, dac8043, ad8522 }; typedef struct ni_board_struct{ int device_id; @@ -597,7 +594,7 @@ typedef struct ni_board_struct{ int has_analog_trig : 1; - struct caldac_struct **caldac; + enum caldac_enum caldac[3]; }ni_board; static ni_board ni_boards[]; -- 2.26.2