Fixed ai munging and dma setup for 18 bit m-series boards. ai commands
authorFrank Mori Hess <fmhess@speakeasy.net>
Wed, 28 Dec 2005 17:13:56 +0000 (17:13 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Wed, 28 Dec 2005 17:13:56 +0000 (17:13 +0000)
seem to work now.

comedi/drivers/ni_mio_common.c

index 809557080044aae0f9bbf8725828c1fc27ebe3d0..b5349ea05052fa03aedc8c0d467ef36a2729fa75 100644 (file)
@@ -1028,15 +1028,22 @@ static void ni_ai_munge(comedi_device *dev, comedi_subdevice *s,
 {
        comedi_async *async = s->async;
        unsigned int i;
-       unsigned int length = num_bytes / sizeof( sampl_t );
+       unsigned int length = num_bytes / bytes_per_sample(s);
        sampl_t *array = data;
-
+       lsampl_t *larray = data;
+       
        for(i = 0; i < length; i++)
        {
 #ifdef PCIDMA
-               array[i] = le16_to_cpu(array[i]);
+               if(s->subdev_flags & SDF_LSAMPL)
+                       larray[i] = le32_to_cpu(larray[i]);
+               else
+                       array[i] = le16_to_cpu(array[i]);
 #endif
-               array[i] += devpriv->ai_offset[ chan_index ];
+               if(s->subdev_flags & SDF_LSAMPL)
+                       larray[i] += devpriv->ai_offset[chan_index];
+               else
+                       array[i] += devpriv->ai_offset[chan_index];
                chan_index++;
                chan_index %= async->cmd.chanlist_len;
        }
@@ -1055,11 +1062,21 @@ static void ni_ai_setup_MITE_dma(comedi_device *dev,comedi_cmd *cmd)
 
        mite_chan->current_link = 0;
        mite_chan->dir = COMEDI_INPUT;
-       if(boardtype.reg_type == ni_reg_611x)
+       switch(boardtype.reg_type)
+       {
+       case ni_reg_611x:
                mite_prep_dma(mite, AI_DMA_CHAN, 32, 16);
-       else
+               break;
+       case ni_reg_m_series:
+               if(boardtype.adbits > 16)
+                       mite_prep_dma(mite, AI_DMA_CHAN, 32, 32);
+               else
+                       mite_prep_dma(mite, AI_DMA_CHAN, 16, 16);       //guess
+               break;
+       default:
                mite_prep_dma(mite, AI_DMA_CHAN, 16, 16);
-
+               break;
+       };
        /*start the MITE*/
        mite_dma_arm(mite, AI_DMA_CHAN);
 }