Re: [PATCH] staging: comedi: das1800: fix analog input number of channels
On 07/04/16 18:45, Hartley Sweeten wrote: On Thursday, April 07, 2016 9:48 AM, Hartley Sweeten wrote: On Thursday, April 07, 2016 3:16 AM, Ian Abbott wrote: On 06/04/16 19:06, H Hartley Sweeten wrote: The "hc" type boards have 64 analog input channels with a 64 entry queue. All the others have 16 channels and a 256 entry queue. Currently the boardinfo 'qram_len' is used to initialize the subdevice 'n_chan' and 'len_chanlist'. This works for the 64 channel boards but sets the 'n_chan' wrong for the 16 channel boards. I think the 256 QRAM positions is to allow use with a set of EXP-1800 boards, each of which can multiplex one of the single-ended inputs of the DAS-1800 series into 16 channels. According to the user's guide, they can be daisy chained to provide up to 256 channels. Datasheet: http://www.tek.com/sites/tek.com/files/media/media/resources/exp-1800_ds.pdf User's Guide download page (need to fill in contact info!): http://www.tek.com/manual/exp-1800-users-guide-92160b-manual So it's probably best to leave the number of channels alone. Finally able to get the user's guide to download. The EXP-1800 support looks like it will need additional changes to the driver in order to work correctly. According to the data sheet: 1) all board input channels must be configured as single-ended, EXP-1800 inputs can be single-ended or differential. Not sure how the board needs to be programmed to achieve this. 2) only gains of 1 and 50 are selectable on a per-channel basis 3) resolution is 12-bit, not clear how this works on a 16-bit board 4) max ai speed depends on the EXP-1800 gain not the board gain 1 = 312kHz sample rate gain 50 = 150kHz sample rate 5) gain must be the same on all channels and the boards gain must be 1 Additionally, it's not clear how the channel mapping works for each EXP-1800 connected to a board input channel. The channel mapping is a bit warped as far as comedi is concerned. Each EXP-1800 is jumper configured for what board input channel will be used to return the 16 channels on the EXP-1800. The hi bits of the QRAM are output to the EXP-1800 boards to select the channel as the MUX4-7 pins on the connector. Channel mapping looks like this: On-board channel 0 EXP-1800 logical channels 0 to 15 On-board channel 1 EXP-1800 logical channels 16 to 31 ... On-board channel 15 EXP-1800 logical channels 240 to 255 So it looks like the QRAM 'channel' (i.e. the comedi channel) to physical channel mapping goes: channel 0 On-board channel 0 / EXP-1800 logical channel 0 channel 1 On-board channel 1 / EXP-1800 logical channel 16 channel 2 On-board channel 2 / EXP-1800 logical channel 32 channel 3 On-board channel 3 / EXP-1800 logical channel 48 channel 4 On-board channel 4 / EXP-1800 logical channel 64 channel 5 On-board channel 5 / EXP-1800 logical channel 80 channel 6 On-board channel 6 / EXP-1800 logical channel 96 channel 7 On-board channel 7 / EXP-1800 logical channel 112 channel 8 On-board channel 8 / EXP-1800 logical channel 128 channel 9 On-board channel 9 / EXP-1800 logical channel 144 channel 10 On-board channel 10 / EXP-1800 logical channel 160 channel 11 On-board channel 11 / EXP-1800 logical channel 176 channel 12 On-board channel 12 / EXP-1800 logical channel 192 channel 13 On-board channel 13 / EXP-1800 logical channel 208 channel 14 On-board channel 14 / EXP-1800 logical channel 224 channel 15 On-board channel 15 / EXP-1800 logical channel 240 channel 16 On-board channel 0 / EXP-1800 logical channel 1 channel 17 On-board channel 1 / EXP-1800 logical channel 17 ... channel 254 On-board channel 14 / EXP-1800 logical channel 239 channel 255 On-board channel 15 / EXP-1800 logical channel 255 It's not entirely clear that's the case, as that table appears in the section called "When using DAS Boards with ASO Software" and refres to the channels as "software (logical) channels". The section called "When using DriverLINX Software (DAS or KPCI Boards)" says, "The channel numbers assigned to the EXP are different under ASO than they are under DriverLINX." Figure C-2 shows the channel mapping under the DriverLINX software. It shows channels 0 to 15 as the onboard channels, channels 16 to 31 as the EXP-1800 channels connected to onboard channel 0, channels 32 to 63 as the EXP-1800 channels connected to onboard channel 1, ..., channels 256 to 271 as the EXP-1800 channels connected to onboard channel 15. The DriverLINX mapping has up to 272 channels, but of course, there are only 256 QRAM positions, so this doesn't really give a clue to the actual mapping of channels to QRAM positions when EXP-1800 boards are connected. So if no EXP-1800 boards are used the comedi channel matches the on-board channel. But, if any EXP-1800 boards are used the comedi channel to physical channel gets all screwy. Just using one EXP-1800 bo
[PATCH] staging: unisys: visorinput: remove erroneous 'FIXME' comments
From: Tim Sell These comments were mistakenly carried forward by a previous copy/paste. Signed-off-by: Tim Sell Signed-off-by: David Kershner --- drivers/staging/unisys/visorinput/visorinput.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visorinput/visorinput.c b/drivers/staging/unisys/visorinput/visorinput.c index 3299cf50..dc94261 100644 --- a/drivers/staging/unisys/visorinput/visorinput.c +++ b/drivers/staging/unisys/visorinput/visorinput.c @@ -123,9 +123,9 @@ static const unsigned char visorkbd_keycode[KEYCODE_TABLE_BYTES] = { [38] = KEY_L, [39] = KEY_SEMICOLON, [40] = KEY_APOSTROPHE, - [41] = KEY_GRAVE, /* FIXME, '#' */ + [41] = KEY_GRAVE, [42] = KEY_LEFTSHIFT, - [43] = KEY_BACKSLASH, /* FIXME, '~' */ + [43] = KEY_BACKSLASH, [44] = KEY_Z, [45] = KEY_X, [46] = KEY_C, @@ -173,7 +173,7 @@ static const unsigned char visorkbd_keycode[KEYCODE_TABLE_BYTES] = { [88] = KEY_F12, [90] = KEY_KPLEFTPAREN, [91] = KEY_KPRIGHTPAREN, - [92] = KEY_KPASTERISK, /* FIXME */ + [92] = KEY_KPASTERISK, [93] = KEY_KPASTERISK, [94] = KEY_KPPLUS, [95] = KEY_HELP, -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[patch] staging: lowmemorykiller: remove bogus NULL check
The NULL checking here doesn't make sense, so it causes a static checker warning. It turns out that p->mm can't be NULL so the inconsistency is harmless and we should just remove the check. Signed-off-by: Dan Carpenter diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c index c79f224..24d2745 100644 --- a/drivers/staging/android/lowmemorykiller.c +++ b/drivers/staging/android/lowmemorykiller.c @@ -131,7 +131,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc) if (!p) continue; - if (task_lmk_waiting(p) && p->mm && + if (task_lmk_waiting(p) && time_before_eq(jiffies, lowmem_deathpending_timeout)) { task_unlock(p); rcu_read_unlock(); ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: unisys: visornic: prevent double-unlock of priv_lock
From: Tim Sell Previously, devdata->priv_lock was being unlocked in visornic_serverdown() both before calling visornic_serverdown_complete(), then again at the end of the function. This bug was corrected. The structure of visornic_serverdown() was also improved to make it easier to follow and to decrease the chance that such bugs will be introduced again. The main-path logic now falls thru down the left-side of the page, with a common error-exit point to handle error conditions. Signed-off-by: Tim Sell Signed-off-by: David Kershner --- drivers/staging/unisys/visornic/visornic_main.c | 40 +++-- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c index cd30d0a..bb3c189 100644 --- a/drivers/staging/unisys/visornic/visornic_main.c +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -354,28 +354,38 @@ visornic_serverdown(struct visornic_devdata *devdata, visorbus_state_complete_func complete_func) { unsigned long flags; + int err; spin_lock_irqsave(&devdata->priv_lock, flags); - if (!devdata->server_down && !devdata->server_change_state) { - if (devdata->going_away) { - spin_unlock_irqrestore(&devdata->priv_lock, flags); - dev_dbg(&devdata->dev->device, - "%s aborting because device removal pending\n", - __func__); - return -ENODEV; - } - devdata->server_change_state = true; - devdata->server_down_complete_func = complete_func; - spin_unlock_irqrestore(&devdata->priv_lock, flags); - visornic_serverdown_complete(devdata); - } else if (devdata->server_change_state) { + if (devdata->server_change_state) { dev_dbg(&devdata->dev->device, "%s changing state\n", __func__); - spin_unlock_irqrestore(&devdata->priv_lock, flags); - return -EINVAL; + err = -EINVAL; + goto err_unlock; + } + if (devdata->server_down) { + dev_dbg(&devdata->dev->device, "%s already down\n", + __func__); + err = -EINVAL; + goto err_unlock; } + if (devdata->going_away) { + dev_dbg(&devdata->dev->device, + "%s aborting because device removal pending\n", + __func__); + err = -ENODEV; + goto err_unlock; + } + devdata->server_change_state = true; + devdata->server_down_complete_func = complete_func; spin_unlock_irqrestore(&devdata->priv_lock, flags); + + visornic_serverdown_complete(devdata); return 0; + +err_unlock: + spin_unlock_irqrestore(&devdata->priv_lock, flags); + return err; } /** -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH] staging: comedi: das1800: fix analog input number of channels
On Friday, April 08, 2016 3:16 AM, Ian Abbott wrote: > On 07/04/16 18:45, Hartley Sweeten wrote: > The channel mapping is a bit warped as far as comedi is concerned. > > Each EXP-1800 is jumper configured for what board input channel will > be used to return the 16 channels on the EXP-1800. The hi bits of the > QRAM are output to the EXP-1800 boards to select the channel as the > MUX4-7 pins on the connector. >> It's not entirely clear that's the case, as that table appears in the >> section called "When using DAS Boards with ASO Software" and refres to >> the channels as "software (logical) channels". >> >> The section called "When using DriverLINX Software (DAS or KPCI Boards)" >> says, "The channel numbers assigned to the EXP are different under ASO >> than they are under DriverLINX." Figure C-2 shows the channel mapping >> under the DriverLINX software. It shows channels 0 to 15 as the onboard >> channels, channels 16 to 31 as the EXP-1800 channels connected to >> onboard channel 0, channels 32 to 63 as the EXP-1800 channels connected >> to onboard channel 1, ..., channels 256 to 271 as the EXP-1800 channels >> connected to onboard channel 15. >> >> The DriverLINX mapping has up to 272 channels, but of course, there are >> only 256 QRAM positions, so this doesn't really give a clue to the >> actual mapping of channels to QRAM positions when EXP-1800 boards are >> connected. So the software layers are somehow manipulating the user's channel (0 to 255 with the ASO software or 0 to 271 with the DriverLINX software) to the QRAM channel value to correctly set the MUX4-7 bits that go to the EXP-1800 boards. Regardless, the channel mapping isn't very clear. > I'd say it's better to leave the channel mapping as is, in case someone > already figured it out. Presumably, they could try reading each of the > 256 channels to see which ones are actually connected. Fair enough. I'll redo this patch and leave the number of channels at 64 or 256 based on the board type. I'll probably add a comment mentioning the issue with the channel mapping when EXP-1800 boards are used. Since this patch is no longer fixing a "bug" I'll add it to the cleanup series. >> There is also the issue with the gain when using an EXP-1800 board. >> For now I think limiting the channels to 16 is the best option. > The external gain multiplier bit (GEXT) should be easy to support. For > the EXP-1800, the external gain multiplier will be 1 or 50, depending on > the state of this bit. I suppose other external boards might interpret > the GEXT bit differently, but I'm not aware of any. I thought I saw a comment that one of the board types can only use an external gain of 1. But now I can't find it. >> Also, the driver doesn't state that the EXP-1800 boards are supported. >> I'm not sure the author (Frank Mori Hess) actually thought about or >> tested it when he originally wrote the driver. > > I don't know if Frank tried an EXP-1800 either, but I just added him to > the Cc list. (It may be so long ago that he can't remember either!) Great. Maybe Frank can add some input. I'll rebase the bug fix comments and repost them as a v2 series. Then I'll rebase the cleanup series to apply after the bug fixes. Thanks, Hartley ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/3] staging: comedi: das1800: fix analog input sample munging
The analog input samples are 2's complement when the inputs are configured for bipolar ranges and offset binary when they are unipolar ranges. For bipolar ranges the sample needs to be munged to the offset binary format that comedi uses. The (*insn_read) does the munging correctly but the async command support incorrectly munges the data for both bipolar and unipolar ranges when reading the remaining samples from the fifo in das1800_handle_fifo_not_empty(). Add a (*munge) function to the analog input subdevice so that the samples are correctly munged when they are added to the async buffer by comedi_buf_write_samples(). Add a flag to the private data and set it in the (*do_cmd) so that the munging is only done for bipolar ranges. Clarify the code by using the core helper functions to check the range and do the munging. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 84 ++-- 1 file changed, 36 insertions(+), 48 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 3be1096..ea54ed8 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -107,7 +107,6 @@ TODO: /* misc. defines */ #define DAS1800_SIZE 16 /* uses 16 io addresses */ #define FIFO_SIZE 1024/* 1024 sample fifo */ -#define UNIPOLAR 0x4 /* bit that determines whether input range is uni/bipolar */ #define DMA_BUF_SIZE 0x1ff00 /* size in bytes of dma buffers */ /* Registers for the das1800 */ @@ -429,6 +428,7 @@ struct das1800_private { unsigned long iobase2; /* secondary io address used for analog out on 'ao' boards */ unsigned short ao_update_bits; /* remembers the last write to the * 'update' dac */ + bool ai_is_unipolar; }; /* analog out range for 'ao' boards */ @@ -441,29 +441,21 @@ static const struct comedi_lrange range_ao_2 = { }; */ -static inline uint16_t munge_bipolar_sample(const struct comedi_device *dev, - uint16_t sample) -{ - const struct das1800_board *board = dev->board_ptr; - - sample += 1 << (board->resolution - 1); - return sample; -} - -static void munge_data(struct comedi_device *dev, uint16_t *array, - unsigned int num_elements) +static void das1800_ai_munge(struct comedi_device *dev, +struct comedi_subdevice *s, +void *data, unsigned int num_bytes, +unsigned int start_chan_index) { + struct das1800_private *devpriv = dev->private; + unsigned short *array = data; + unsigned int num_samples = comedi_bytes_to_samples(s, num_bytes); unsigned int i; - int unipolar; - /* see if card is using a unipolar or bipolar range so we can munge data correctly */ - unipolar = inb(dev->iobase + DAS1800_CONTROL_C) & UB; + if (devpriv->ai_is_unipolar) + return; - /* convert to unsigned type if we are in a bipolar mode */ - if (!unipolar) { - for (i = 0; i < num_elements; i++) - array[i] = munge_bipolar_sample(dev, array[i]); - } + for (i = 0; i < num_samples; i++) + array[i] = comedi_offset_munge(s, array[i]); } static void das1800_handle_fifo_half_full(struct comedi_device *dev, @@ -473,7 +465,6 @@ static void das1800_handle_fifo_half_full(struct comedi_device *dev, unsigned int nsamples = comedi_nsamples_left(s, FIFO_SIZE / 2); insw(dev->iobase + DAS1800_FIFO, devpriv->fifo_buf, nsamples); - munge_data(dev, devpriv->fifo_buf, nsamples); comedi_buf_write_samples(s, devpriv->fifo_buf, nsamples); } @@ -482,14 +473,9 @@ static void das1800_handle_fifo_not_empty(struct comedi_device *dev, { struct comedi_cmd *cmd = &s->async->cmd; unsigned short dpnt; - int unipolar; - - unipolar = inb(dev->iobase + DAS1800_CONTROL_C) & UB; while (inb(dev->iobase + DAS1800_STATUS) & FNE) { dpnt = inw(dev->iobase + DAS1800_FIFO); - /* convert to unsigned type */ - dpnt = munge_bipolar_sample(dev, dpnt); comedi_buf_write_samples(s, &dpnt, 1); if (cmd->stop_src == TRIG_COUNT && @@ -511,7 +497,6 @@ static void das1800_flush_dma_channel(struct comedi_device *dev, nsamples = comedi_bytes_to_samples(s, nbytes); nsamples = comedi_nsamples_left(s, nsamples); - munge_data(dev, desc->virt_addr, nsamples); comedi_buf_write_samples(s, desc->virt_addr, nsamples); } @@ -707,13 +692,14 @@ static int das1800_ai_check_chanlist(struct comedi_device *dev, struct comedi_subdevice *s,
[PATCH v2 0/3] staging: comedi: das1800: bug fixes
These fix a bug (patch 1) and a couple issues in the das1800 driver that have existed forever (patches 2 and 3). Patch 1 was originally posted in another series as two paches: "[PATCH 28/35] staging: comedi: das1800: fix das1800_ai_cancel()" "[PATCH 29/35] staging: comedi: das1800: fix NULL pointer dereference in das1800_ai_setup_dma()" To make backporting easier, they have been squashed to add the Fixes and Cc tags for stable. The other two were posted separately along with another patch to fix the analog input number of channels. That patch has been dropped at the request of Ian Abbott. H Hartley Sweeten (3): staging: comedi: das1800: fix possible NULL dereference staging: comedi: das1800: fix analog input sample munging staging: comedi: das1800: fix das-1801st-da boardinfo drivers/staging/comedi/drivers/das1800.c | 106 ++- 1 file changed, 49 insertions(+), 57 deletions(-) -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/3] staging: comedi: das1800: fix das-1801st-da boardinfo
The "da" type boards all have 4 analog outputs. Fix the boardinfo for the das-1801st-da. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index ea54ed8..24b33a4 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -324,7 +324,7 @@ static const struct das1800_board das1800_boards[] = { .qram_len = 256, .common = 1, .do_n_chan = 4, -.ao_ability = 0, +.ao_ability = 1, .ao_n_chan = 4, .range_ai = &range_ai_das1801, }, -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/3] staging: comedi: das1800: fix possible NULL dereference
DMA is optional with this driver. If it was not enabled the devpriv->dma pointer will be NULL. Fix the possible NULL pointer dereference when trying to disable the DMA channels in das1800_ai_cancel() and tidy up the comments to fix the checkpatch.pl issues: WARNING: line over 80 characters It's probably harmless in das1800_ai_setup_dma() because the 'desc' pointer will not be used if DMA is disabled but fix it there also. Fixes: 99dfc3357e98 ("staging: comedi: das1800: remove depends on ISA_DMA_API limitation") Cc: # 4.0+ Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 22 +- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 94078118..3be1096 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -567,14 +567,17 @@ static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_isadma_desc *desc; int i; - outb(0x0, dev->iobase + DAS1800_STATUS);/* disable conversions */ - outb(0x0, dev->iobase + DAS1800_CONTROL_B); /* disable interrupts and dma */ - outb(0x0, dev->iobase + DAS1800_CONTROL_A); /* disable and clear fifo and stop triggering */ - - for (i = 0; i < 2; i++) { - desc = &dma->desc[i]; - if (desc->chan) - comedi_isadma_disable(desc->chan); + /* disable and stop conversions */ + outb(0x0, dev->iobase + DAS1800_STATUS); + outb(0x0, dev->iobase + DAS1800_CONTROL_B); + outb(0x0, dev->iobase + DAS1800_CONTROL_A); + + if (dma) { + for (i = 0; i < 2; i++) { + desc = &dma->desc[i]; + if (desc->chan) + comedi_isadma_disable(desc->chan); + } } return 0; @@ -934,13 +937,14 @@ static void das1800_ai_setup_dma(struct comedi_device *dev, { struct das1800_private *devpriv = dev->private; struct comedi_isadma *dma = devpriv->dma; - struct comedi_isadma_desc *desc = &dma->desc[0]; + struct comedi_isadma_desc *desc; unsigned int bytes; if ((devpriv->irq_dma_bits & DMA_ENABLED) == 0) return; dma->cur_dma = 0; + desc = &dma->desc[0]; /* determine a dma transfer size to fill buffer in 0.3 sec */ bytes = das1800_ai_transfer_size(dev, s, desc->maxsize, 3); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH v2 0/3] staging: comedi: das1800: bug fixes
On Friday, April 08, 2016 10:15 AM, H Hartley Sweeten wrote: > These fix a bug (patch 1) and a couple issues in the das1800 driver > that have existed forever (patches 2 and 3). Greg, Sorry, I forgot to add "v2" to the actual patches. Hartley > H Hartley Sweeten (3): > staging: comedi: das1800: fix possible NULL dereference > staging: comedi: das1800: fix analog input sample munging > staging: comedi: das1800: fix das-1801st-da boardinfo > > drivers/staging/comedi/drivers/das1800.c | 106 > ++- > 1 file changed, 49 insertions(+), 57 deletions(-) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 20/37] staging: comedi: das1800: absorb control_c_bits()
Absorb this helper function into the analog input (*do_cmd). For aesthetics, convert the switch code into if/else. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 58 +++- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 5694bdb..0a4876e 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -767,44 +767,6 @@ static unsigned char das1800_ai_chanspec_bits(struct comedi_subdevice *s, return bits; } -static int control_c_bits(struct comedi_subdevice *s, - const struct comedi_cmd *cmd) -{ - int control_c; - - control_c = das1800_ai_chanspec_bits(s, cmd->chanlist[0]); - - /* set clock source to internal or external */ - switch (cmd->scan_begin_src) { - case TRIG_FOLLOW: /* not in burst mode */ - switch (cmd->convert_src) { - case TRIG_TIMER: - /* trig on cascaded counters */ - control_c |= IPCLK; - break; - case TRIG_EXT: - /* trig on falling edge of external trigger */ - control_c |= XPCLK; - break; - default: - break; - } - break; - case TRIG_TIMER: - /* burst mode with internal pacer clock */ - control_c |= BMDE | IPCLK; - break; - case TRIG_EXT: - /* burst mode with external trigger */ - control_c |= BMDE | XPCLK; - break; - default: - break; - } - - return control_c; -} - static unsigned int das1800_ai_transfer_size(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int maxbytes, @@ -922,7 +884,25 @@ static int das1800_ai_cmd(struct comedi_device *dev, /* determine proper bits for control registers */ control_a = control_a_bits(cmd); - control_c = control_c_bits(s, cmd); + + control_c = das1800_ai_chanspec_bits(s, cmd->chanlist[0]); + /* set clock source to internal or external */ + if (cmd->scan_begin_src == TRIG_FOLLOW) { + /* not in burst mode */ + if (cmd->convert_src == TRIG_TIMER) { + /* trig on cascaded counters */ + control_c |= IPCLK; + } else { /* TRIG_EXT */ + /* trig on falling edge of external trigger */ + control_c |= XPCLK; + } + } else if (cmd->scan_begin_src == TRIG_TIMER) { + /* burst mode with internal pacer clock */ + control_c |= BMDE | IPCLK; + } else { /* TRIG_EXT */ + /* burst mode with external trigger */ + control_c |= BMDE | XPCLK; + } /* setup card and start */ program_chanlist(dev, cmd); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 07/37] staging: comedi: das1800: remove 'common' boardinfo member
The "hc" type boards do not support common mode analog inputs all the other board types do. Remove the unnecessary member from the boardinfo and use the 'id' member to determine if the SDF_COMMON flag should be set for the subdevice. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 21 + 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index e24d0c9..6795f3e 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -229,7 +229,6 @@ struct das1800_board { int ai_speed; /* max conversion period in nanoseconds */ int resolution; /* bits of ai resolution */ int qram_len; /* length of card's channel / gain queue */ - int common; /* supports AREF_COMMON flag */ int do_n_chan; /* number of digital output channels */ int ao_ability; /* 0 == no analog out, 1 == basic analog out, 2 == waveform analog out */ int ao_n_chan; /* number of analog out channels */ @@ -247,7 +246,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .resolution = 12, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 0, .ao_n_chan = 0, @@ -259,7 +257,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .resolution = 12, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 1, .ao_n_chan = 4, @@ -271,7 +268,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .resolution = 12, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 0, .ao_n_chan = 0, @@ -283,7 +279,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .resolution = 12, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 1, .ao_n_chan = 4, @@ -295,7 +290,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 2, .resolution = 16, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 0, .ao_n_chan = 0, @@ -307,7 +301,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 2, .resolution = 16, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 1, .ao_n_chan = 2, @@ -319,7 +312,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .resolution = 12, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 2, .ao_n_chan = 2, @@ -331,7 +323,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .resolution = 12, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 2, .ao_n_chan = 2, @@ -343,7 +334,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 3000, .resolution = 12, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 0, .ao_n_chan = 0, @@ -355,7 +345,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 3000, .resolution = 12, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 1, .ao_n_chan = 4, @@ -367,7 +356,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 3000, .resolution = 12, .qram_len = 256, - .common = 1, .do_n_chan = 4, .ao_ability = 0, .ao_n_chan = 0, @@ -379,7 +367,6 @@ static const stru
[PATCH v2 13/37] staging: comedi: das1800: remove 'ao_n_chan' boardinfo
The "st-da" board types have 4 analog output channels. All other board types, with analog outputs, only have 2 channels. Remove the 'ao_n_chan' member of the boardinfo and use the 'id' member to determine the subdevice 'n_chan'. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 21 + 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 962a414..1a9565e 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -229,7 +229,6 @@ struct das1800_board { int ai_speed; /* max conversion period in nanoseconds */ int qram_len; /* length of card's channel / gain queue */ int ao_ability; /* 0 == no analog out, 1 == basic analog out, 2 == waveform analog out */ - int ao_n_chan; /* number of analog out channels */ const struct comedi_lrange *range_ai; /* available input ranges */ }; @@ -244,7 +243,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .qram_len = 256, .ao_ability = 0, - .ao_n_chan = 0, .range_ai = &range_ai_das1801, }, [BOARD_DAS1701ST_DA] = { @@ -253,7 +251,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .qram_len = 256, .ao_ability = 1, - .ao_n_chan = 4, .range_ai = &range_ai_das1801, }, [BOARD_DAS1702ST] = { @@ -262,7 +259,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .qram_len = 256, .ao_ability = 0, - .ao_n_chan = 0, .range_ai = &range_ai_das1802, }, [BOARD_DAS1702ST_DA] = { @@ -271,7 +267,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .qram_len = 256, .ao_ability = 1, - .ao_n_chan = 4, .range_ai = &range_ai_das1802, }, [BOARD_DAS1702HR] = { @@ -280,7 +275,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 2, .qram_len = 256, .ao_ability = 0, - .ao_n_chan = 0, .range_ai = &range_ai_das1802, }, [BOARD_DAS1702HR_DA] = { @@ -289,7 +283,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 2, .qram_len = 256, .ao_ability = 1, - .ao_n_chan = 2, .range_ai = &range_ai_das1802, }, [BOARD_DAS1701AO] = { @@ -298,7 +291,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .qram_len = 256, .ao_ability = 2, - .ao_n_chan = 2, .range_ai = &range_ai_das1801, }, [BOARD_DAS1702AO] = { @@ -307,7 +299,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 6250, .qram_len = 256, .ao_ability = 2, - .ao_n_chan = 2, .range_ai = &range_ai_das1802, }, [BOARD_DAS1801ST] = { @@ -316,7 +307,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 3000, .qram_len = 256, .ao_ability = 0, - .ao_n_chan = 0, .range_ai = &range_ai_das1801, }, [BOARD_DAS1801ST_DA] = { @@ -325,7 +315,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 3000, .qram_len = 256, .ao_ability = 1, - .ao_n_chan = 4, .range_ai = &range_ai_das1801, }, [BOARD_DAS1802ST] = { @@ -334,7 +323,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 3000, .qram_len = 256, .ao_ability = 0, - .ao_n_chan = 0, .range_ai = &range_ai_das1802, }, [BOARD_DAS1802ST_DA] = { @@ -343,7 +331,6 @@ static const struct das1800_board das1800_boards[] = { .ai_speed = 3000, .qram_len = 256, .ao_ability = 1, - .ao_n_chan = 4, .range_ai = &range_ai_das1802, }, [BOARD_DAS1802HR] = { @@ -352,7 +339,6
[PATCH v2 02/37] staging: comedi: das1800: tidy up digital input subdevice init
For aesthetics, add some whitespace to the subdevice init and rename the (*insn_bits) function. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index e7787ae3..93a9d1f 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1130,10 +1130,10 @@ static int das1800_ao_winsn(struct comedi_device *dev, return 1; } -/* reads from digital input channels */ -static int das1800_di_rbits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das1800_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { data[1] = inb(dev->iobase + DAS1800_DIGITAL) & 0xf; data[0] = 0; @@ -1387,14 +1387,14 @@ static int das1800_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - /* di */ + /* Digital Input subdevice */ s = &dev->subdevices[2]; - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->n_chan = 4; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = das1800_di_rbits; + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 4; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits= das1800_di_insn_bits; /* Digital Output subdevice */ s = &dev->subdevices[3]; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 14/37] staging: comedi: das1800: remove 'ao_ability' boardinfo
The "da" and "hc" type boards have normal analog outputs. The "ao" type boards have move advanced analog outputs with waveform generation capability. Remove the 'ao_ability' member of the boardinfo and use the 'id' member to determine if the subdevice should be initialized. The "ao" waveform analog outputs are not currently supported. For aesthetics, add an else if for the initialization of the subdevice for these boards. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 31 +-- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 1a9565e..5d40811 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -228,7 +228,6 @@ struct das1800_board { unsigned char id; int ai_speed; /* max conversion period in nanoseconds */ int qram_len; /* length of card's channel / gain queue */ - int ao_ability; /* 0 == no analog out, 1 == basic analog out, 2 == waveform analog out */ const struct comedi_lrange *range_ai; /* available input ranges */ }; @@ -242,7 +241,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST, .ai_speed = 6250, .qram_len = 256, - .ao_ability = 0, .range_ai = &range_ai_das1801, }, [BOARD_DAS1701ST_DA] = { @@ -250,7 +248,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST_DA, .ai_speed = 6250, .qram_len = 256, - .ao_ability = 1, .range_ai = &range_ai_das1801, }, [BOARD_DAS1702ST] = { @@ -258,7 +255,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST, .ai_speed = 6250, .qram_len = 256, - .ao_ability = 0, .range_ai = &range_ai_das1802, }, [BOARD_DAS1702ST_DA] = { @@ -266,7 +262,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST_DA, .ai_speed = 6250, .qram_len = 256, - .ao_ability = 1, .range_ai = &range_ai_das1802, }, [BOARD_DAS1702HR] = { @@ -274,7 +269,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_HR, .ai_speed = 2, .qram_len = 256, - .ao_ability = 0, .range_ai = &range_ai_das1802, }, [BOARD_DAS1702HR_DA] = { @@ -282,7 +276,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_HR_DA, .ai_speed = 2, .qram_len = 256, - .ao_ability = 1, .range_ai = &range_ai_das1802, }, [BOARD_DAS1701AO] = { @@ -290,7 +283,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_AO, .ai_speed = 6250, .qram_len = 256, - .ao_ability = 2, .range_ai = &range_ai_das1801, }, [BOARD_DAS1702AO] = { @@ -298,7 +290,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_AO, .ai_speed = 6250, .qram_len = 256, - .ao_ability = 2, .range_ai = &range_ai_das1802, }, [BOARD_DAS1801ST] = { @@ -306,7 +297,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST, .ai_speed = 3000, .qram_len = 256, - .ao_ability = 0, .range_ai = &range_ai_das1801, }, [BOARD_DAS1801ST_DA] = { @@ -314,7 +304,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST_DA, .ai_speed = 3000, .qram_len = 256, - .ao_ability = 1, .range_ai = &range_ai_das1801, }, [BOARD_DAS1802ST] = { @@ -322,7 +311,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST, .ai_speed = 3000, .qram_len = 256, - .ao_ability = 0, .range_ai = &range_ai_das1802, }, [BOARD_DAS1802ST_DA] = { @@ -330,7 +318,6 @@ static
[PATCH v2 19/37] staging: comedi: das1800: introduce das1800_ai_chanspec_bits()
Introduce a helper function for the common code needed to set the control c register bits for a channel specification. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 47 +++- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 64b5403..5694bdb 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -749,25 +749,32 @@ static int control_a_bits(const struct comedi_cmd *cmd) return control_a; } -/* returns appropriate bits for control register c, depending on command */ -static int control_c_bits(struct comedi_subdevice *s, - const struct comedi_cmd *cmd) +static unsigned char das1800_ai_chanspec_bits(struct comedi_subdevice *s, + unsigned int chanspec) { - unsigned int range = CR_RANGE(cmd->chanlist[0]); - unsigned int aref = CR_AREF(cmd->chanlist[0]); - int control_c; + unsigned int range = CR_RANGE(chanspec); + unsigned int aref = CR_AREF(chanspec); + unsigned char bits; - /* set clock source to internal or external, select analog reference, -* select unipolar / bipolar -*/ - control_c = UQEN; /* enable upper qram addresses */ + bits = UQEN; if (aref != AREF_DIFF) - control_c |= SD; + bits |= SD; if (aref == AREF_COMMON) - control_c |= CMEN; + bits |= CMEN; if (comedi_range_is_unipolar(s, range)) - control_c |= UB; + bits |= UB; + + return bits; +} + +static int control_c_bits(struct comedi_subdevice *s, + const struct comedi_cmd *cmd) +{ + int control_c; + control_c = das1800_ai_chanspec_bits(s, cmd->chanlist[0]); + + /* set clock source to internal or external */ switch (cmd->scan_begin_src) { case TRIG_FOLLOW: /* not in burst mode */ switch (cmd->convert_src) { @@ -955,25 +962,15 @@ static int das1800_ai_insn_read(struct comedi_device *dev, { unsigned int chan = CR_CHAN(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec); - unsigned int aref = CR_AREF(insn->chanspec); bool is_unipolar = comedi_range_is_unipolar(s, range); int i, n; int chan_range; int timeout = 1000; unsigned short dpnt; - int conv_flags = 0; unsigned long irq_flags; - /* set up analog reference and unipolar / bipolar mode */ - conv_flags |= UQEN; - if (aref != AREF_DIFF) - conv_flags |= SD; - if (aref == AREF_COMMON) - conv_flags |= CMEN; - if (is_unipolar) - conv_flags |= UB; - - outb(conv_flags, dev->iobase + DAS1800_CONTROL_C); /* software conversion enabled */ + outb(das1800_ai_chanspec_bits(s, insn->chanspec), +dev->iobase + DAS1800_CONTROL_C); /* software pacer */ outb(CVEN, dev->iobase + DAS1800_STATUS); /* enable conversions */ outb(0x0, dev->iobase + DAS1800_CONTROL_A); /* reset fifo */ outb(FFEN, dev->iobase + DAS1800_CONTROL_A); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 05/37] staging: comedi: das1800: tidy up boardinfo
For aesthetics, add some whitespace to the boardinfo array. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 377 +++ 1 file changed, 180 insertions(+), 197 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index fc8c0f9..aba8021 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -219,203 +219,186 @@ struct das1800_board { */ static const struct das1800_board das1800_boards[] = { { -.name = "das-1701st", -.ai_speed = 6250, -.resolution = 12, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 0, -.ao_n_chan = 0, -.range_ai = &range_ai_das1801, -}, - { -.name = "das-1701st-da", -.ai_speed = 6250, -.resolution = 12, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 1, -.ao_n_chan = 4, -.range_ai = &range_ai_das1801, -}, - { -.name = "das-1702st", -.ai_speed = 6250, -.resolution = 12, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 0, -.ao_n_chan = 0, -.range_ai = &range_ai_das1802, -}, - { -.name = "das-1702st-da", -.ai_speed = 6250, -.resolution = 12, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 1, -.ao_n_chan = 4, -.range_ai = &range_ai_das1802, -}, - { -.name = "das-1702hr", -.ai_speed = 2, -.resolution = 16, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 0, -.ao_n_chan = 0, -.range_ai = &range_ai_das1802, -}, - { -.name = "das-1702hr-da", -.ai_speed = 2, -.resolution = 16, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 1, -.ao_n_chan = 2, -.range_ai = &range_ai_das1802, -}, - { -.name = "das-1701ao", -.ai_speed = 6250, -.resolution = 12, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 2, -.ao_n_chan = 2, -.range_ai = &range_ai_das1801, -}, - { -.name = "das-1702ao", -.ai_speed = 6250, -.resolution = 12, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 2, -.ao_n_chan = 2, -.range_ai = &range_ai_das1802, -}, - { -.name = "das-1801st", -.ai_speed = 3000, -.resolution = 12, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 0, -.ao_n_chan = 0, -.range_ai = &range_ai_das1801, -}, - { -.name = "das-1801st-da", -.ai_speed = 3000, -.resolution = 12, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 1, -.ao_n_chan = 4, -.range_ai = &range_ai_das1801, -}, - { -.name = "das-1802st", -.ai_speed = 3000, -.resolution = 12, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 0, -.ao_n_chan = 0, -.range_ai = &range_ai_das1802, -}, - { -.name = "das-1802st-da", -.ai_speed = 3000, -.resolution = 12, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 1, -.ao_n_chan = 4, -.range_ai = &range_ai_das1802, -}, - { -.name = "das-1802hr", -.ai_speed = 1, -.resolution = 16, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 0, -.ao_n_chan = 0, -.range_ai = &range_ai_das1802, -}, - { -.name = "das-1802hr-da", -.ai_speed = 1, -.resolution = 16, -.qram_len = 256, -.common = 1, -.do_n_chan = 4, -.ao_ability = 1, -.ao_n_chan = 2, -.range_ai = &range_ai_das1802, -}, - { -.name = "das-1801hc", -.ai_speed = 3000, -.resolution = 12, -.qram_len = 64, -.common = 0, -.do_n_chan = 8, -.ao_ability = 1, -.ao_n_chan = 2, -.range_ai = &range_ai_das1801, -}, - { -.name = "das-1802hc", -.ai_speed = 3000, -.resolution = 12, -.qram_len = 64, -.common = 0, -.do_n_chan = 8, -.ao_ability = 1, -.ao_n_chan = 2, -.range_ai = &range_ai_das1802, -}, - { -.name = "das-1801ao",
[PATCH v2 17/37] staging: comedi: das1800: change type of 'ai_speed' boardinfo
This value is compared against the unsigned int cmd->convert_arg to check the minimum value (max speed) for the analog input conversion timing. For aesthetics, change the type to match the cmd->convert_arg type. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index d3aca97..52a8c5b 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -225,7 +225,7 @@ enum das1800_boardid { struct das1800_board { const char *name; unsigned char id; - int ai_speed; /* max conversion period in nanoseconds */ + unsigned int ai_speed; unsigned int is_01_series:1; }; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 11/37] staging: comedi: das1800: initialize all analog outputs
The current code used to initialize the analog outputs only sets the last channel. The other channels will be reloaded with the last value that was written to them. Move the code into the subdevice init and properly initialize all the channels to 0V. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 15 +++ 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 6641f2e..45d7201 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1262,6 +1262,7 @@ static int das1800_attach(struct comedi_device *dev, unsigned int irq = it->options[1]; bool is_16bit; int ret; + int i; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) @@ -1365,6 +1366,12 @@ static int das1800_attach(struct comedi_device *dev, s->maxdata = is_16bit ? 0x : 0x0fff; s->range_table = &range_bipolar10; s->insn_write = das1800_ao_insn_write; + + /* initialize all channels to 0V */ + for (i = 0; i < s->n_chan; i++) { + outb(DAC(i), dev->iobase + DAS1800_SELECT); + outw(0, dev->iobase + DAS1800_DAC); + } } else { s->type = COMEDI_SUBD_UNUSED; } @@ -1392,14 +1399,6 @@ static int das1800_attach(struct comedi_device *dev, /* initialize digital out channels */ outb(0, dev->iobase + DAS1800_DIGITAL); - /* initialize analog out channels */ - if (board->ao_ability == 1) { - /* select 'update' dac channel for baseAddress + 0x0 */ - outb(DAC(board->ao_n_chan - 1), -dev->iobase + DAS1800_SELECT); - outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC); - } - return 0; }; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 03/37] staging: comedi: das1800: tidy up analog output subdevice init
For aesthetics, add some whitespace to the subdevice init and rename the (*insn_write) function. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 93a9d1f..7f7b1d0 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1098,10 +1098,10 @@ exit: return n; } -/* writes to an analog output channel */ -static int das1800_ao_winsn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das1800_ao_insn_write(struct comedi_device *dev, +struct comedi_subdevice *s, +struct comedi_insn *insn, +unsigned int *data) { const struct das1800_board *board = dev->board_ptr; struct das1800_private *devpriv = dev->private; @@ -1374,17 +1374,17 @@ static int das1800_attach(struct comedi_device *dev, s->munge = das1800_ai_munge; } - /* analog out */ + /* Analog Output subdevice */ s = &dev->subdevices[1]; if (board->ao_ability == 1) { - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = board->ao_n_chan; - s->maxdata = (1 << board->resolution) - 1; - s->range_table = &range_bipolar10; - s->insn_write = das1800_ao_winsn; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = board->ao_n_chan; + s->maxdata = (1 << board->resolution) - 1; + s->range_table = &range_bipolar10; + s->insn_write = das1800_ao_insn_write; } else { - s->type = COMEDI_SUBD_UNUSED; + s->type = COMEDI_SUBD_UNUSED; } /* Digital Input subdevice */ -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 33/37] staging: comedi: das1800: fix lines over 80 characters
These comments are just extra cruft. Remove them to fix the checkpatch.pl issues: WARNING: line over 80 characters Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 1edb3d6..87285b2 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -100,7 +100,7 @@ #define DMA_CH5_CH6 0x5 #define DMA_CH6_CH7 0x6 #define DMA_CH7_CH5 0x7 -#define DMA_ENABLED 0x3 /* mask used to determine if dma is enabled */ +#define DMA_ENABLED 0x3 #define DMA_DUAL0x4 #define IRQ30x8 #define IRQ50x10 @@ -118,22 +118,21 @@ #define SD 0x40 #define UB 0x80 #define DAS1800_STATUS 0x7 -/* bits that prevent interrupt status bits (and CVEN) from being cleared on write */ -#define CLEAR_INTR_MASK (CVEN_MASK | 0x1f) #define INT 0x1 #define DMATC 0x2 #define CT0TC 0x8 #define OVF 0x10 #define FHF 0x20 #define FNE 0x40 -#define CVEN_MASK 0x40 /* masks CVEN on write */ #define CVEN0x80 +#define CVEN_MASK 0x40 +#define CLEAR_INTR_MASK (CVEN_MASK | 0x1f) #define DAS1800_BURST_LENGTH0x8 #define DAS1800_BURST_RATE 0x9 #define DAS1800_QRAM_ADDRESS0xa #define DAS1800_COUNTER 0xc -#define IOBASE2 0x400/* offset of additional ioports used on 'ao' cards */ +#define IOBASE2 0x400 static const struct comedi_lrange das1801_ai_range = { 8, { -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 34/37] staging: comedi: das1800: fix comments about the 'ao' board range
The waveform analog outputs on the 'ao' boards are not currently supported. Modify the comment about the analog output range on these boards so that the information is saved but fixes the checkpatch.pl issues: WARNING: Block comments use a trailing */ on a separate line Move the comment so it's grouped with the comedi_lrange info. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 16 ++-- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 87285b2..9153c9b 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -160,6 +160,12 @@ static const struct comedi_lrange das1802_ai_range = { } }; +/* + * The waveform analog outputs on the 'ao' boards are not currently + * supported. They have a comedi_lrange of: + * { 2, { BIP_RANGE(10), BIP_RANGE(5) } } + */ + enum das1800_boardid { BOARD_DAS1701ST, BOARD_DAS1701ST_DA, @@ -305,16 +311,6 @@ struct das1800_private { bool ai_is_unipolar; }; -/* analog out range for 'ao' boards */ -/* -static const struct comedi_lrange range_ao_2 = { - 2, { - BIP_RANGE(10), - BIP_RANGE(5) - } -}; -*/ - static void das1800_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *data, unsigned int num_bytes, -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 24/37] staging: comedi: das1800: document the spinlock
The comedi_device spinlock is used to protect the indirect addressing selected by the DAS1800_SELECT register. It also prevents races between the interrupt handler and the analog input (*poll). Update the comments to make this clear. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 677f430..365a3d5 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -490,8 +490,9 @@ static void das1800_ai_handler(struct comedi_device *dev) struct comedi_cmd *cmd = &async->cmd; unsigned int status = inb(dev->iobase + DAS1800_STATUS); - /* select adc for base address + 0 */ + /* select adc register (spinlock is already held) */ outb(ADC, dev->iobase + DAS1800_SELECT); + /* dma buffer full */ if (devpriv->irq_dma_bits & DMA_ENABLED) { /* look for data from dma transfer even if dma terminal count hasn't happened yet */ @@ -535,9 +536,14 @@ static int das1800_ai_poll(struct comedi_device *dev, { unsigned long flags; - /* prevent race with interrupt handler */ + /* +* Protects the indirect addressing selected by DAS1800_SELECT +* in das1800_ai_handler() also prevents race with das1800_interrupt(). +*/ spin_lock_irqsave(&dev->spinlock, flags); + das1800_ai_handler(dev); + spin_unlock_irqrestore(&dev->spinlock, flags); return comedi_buf_n_bytes_ready(s); @@ -553,9 +559,12 @@ static irqreturn_t das1800_interrupt(int irq, void *d) return IRQ_HANDLED; } - /* Prevent race with das1800_ai_poll() on multi processor systems. -* Also protects indirect addressing in das1800_ai_handler */ + /* +* Protects the indirect addressing selected by DAS1800_SELECT +* in das1800_ai_handler() also prevents race with das1800_ai_poll(). +*/ spin_lock(&dev->spinlock); + status = inb(dev->iobase + DAS1800_STATUS); /* if interrupt was not caused by das-1800 */ @@ -1289,6 +1298,7 @@ static int das1800_attach(struct comedi_device *dev, /* initialize all channels to 0V */ for (i = 0; i < s->n_chan; i++) { + /* spinlock is not necessary during the attach */ outb(DAC(i), dev->iobase + DAS1800_SELECT); outw(0, dev->iobase + DAS1800_DAC); } -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 21/37] staging: comedi: das1800: refactor program_chanlist()
Refactor this function so it can be used to program the chanlist for the analog input (*do_cmd) and (*insn_read). Rename the function so it has namespace associated with the driver. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 68 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 0a4876e..2bb53db 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -828,30 +828,33 @@ static void das1800_ai_setup_dma(struct comedi_device *dev, } } -/* programs channel/gain list into card */ -static void program_chanlist(struct comedi_device *dev, -const struct comedi_cmd *cmd) +static void das1800_ai_set_chanlist(struct comedi_device *dev, + unsigned int *chanlist, unsigned int len) { - int i, n, chan_range; - unsigned long irq_flags; - const int range_mask = 0x3; /* masks unipolar/bipolar bit off range */ - const int range_bitshift = 8; - - n = cmd->chanlist_len; - /* spinlock protects indirect addressing */ - spin_lock_irqsave(&dev->spinlock, irq_flags); - outb(QRAM, dev->iobase + DAS1800_SELECT); /* select QRAM for baseAddress + 0x0 */ - outb(n - 1, dev->iobase + DAS1800_QRAM_ADDRESS);/*set QRAM address start */ + unsigned long flags; + unsigned int i; + + /* protects the indirect addressing selected by DAS1800_SELECT */ + spin_lock_irqsave(&dev->spinlock, flags); + + /* select QRAM register and set start address */ + outb(QRAM, dev->iobase + DAS1800_SELECT); + outb(len - 1, dev->iobase + DAS1800_QRAM_ADDRESS); + /* make channel / gain list */ - for (i = 0; i < n; i++) { - chan_range = - CR_CHAN(cmd->chanlist[i]) | - ((CR_RANGE(cmd->chanlist[i]) & range_mask) << -range_bitshift); - outw(chan_range, dev->iobase + DAS1800_QRAM); + for (i = 0; i < len; i++) { + unsigned int chan = CR_CHAN(chanlist[i]); + unsigned int range = CR_RANGE(chanlist[i]); + unsigned short val; + + val = chan | ((range & 0x3) << 8); + outw(val, dev->iobase + DAS1800_QRAM); } - outb(n - 1, dev->iobase + DAS1800_QRAM_ADDRESS);/*finish write to QRAM */ - spin_unlock_irqrestore(&dev->spinlock, irq_flags); + + /* finish write to QRAM */ + outb(len - 1, dev->iobase + DAS1800_QRAM_ADDRESS); + + spin_unlock_irqrestore(&dev->spinlock, flags); } static int das1800_ai_cmd(struct comedi_device *dev, @@ -904,8 +907,7 @@ static int das1800_ai_cmd(struct comedi_device *dev, control_c |= BMDE | XPCLK; } - /* setup card and start */ - program_chanlist(dev, cmd); + das1800_ai_set_chanlist(dev, cmd->chanlist, cmd->chanlist_len); /* setup cascaded counters for conversion/scan frequency */ if ((cmd->scan_begin_src == TRIG_FOLLOW || @@ -940,14 +942,12 @@ static int das1800_ai_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec); bool is_unipolar = comedi_range_is_unipolar(s, range); int i, n; - int chan_range; int timeout = 1000; unsigned short dpnt; - unsigned long irq_flags; + unsigned long flags; outb(das1800_ai_chanspec_bits(s, insn->chanspec), dev->iobase + DAS1800_CONTROL_C); /* software pacer */ @@ -955,13 +955,13 @@ static int das1800_ai_insn_read(struct comedi_device *dev, outb(0x0, dev->iobase + DAS1800_CONTROL_A); /* reset fifo */ outb(FFEN, dev->iobase + DAS1800_CONTROL_A); - chan_range = chan | ((range & 0x3) << 8); - spin_lock_irqsave(&dev->spinlock, irq_flags); - outb(QRAM, dev->iobase + DAS1800_SELECT); /* select QRAM for baseAddress + 0x0 */ - outb(0x0, dev->iobase + DAS1800_QRAM_ADDRESS); /* set QRAM address start */ - outw(chan_range, dev->iobase + DAS1800_QRAM); - outb(0x0, dev->iobase + DAS1800_QRAM_ADDRESS); /*finish write to QRAM */ - outb(ADC, dev->iobase + DAS1800_SELECT);/* select ADC for baseAddress + 0x0 */ + das1800_ai_set_chanlist(dev, &insn->chanspec, 1); + + /* protects the indirect addressing selected by DAS1800_SELECT */ + spin_lock_irqsave(&dev->spinlock, flags); + + /* select ai fifo register */ + outb(ADC, dev->iobase + DAS1800_SELECT); for (n = 0; n < insn->n; n++) { /* trigger conv
[PATCH v2 25/37] staging: comedi: das1800: cleanup copyright and comedi comment blocks
Tidy up these multi-line comments to fix the checkpatch.pl issues: WARNING: Block comments use * on subsequent lines WARNING: line over 80 characters Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 150 --- 1 file changed, 58 insertions(+), 92 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 365a3d5..118fa76 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1,97 +1,63 @@ /* -comedi/drivers/das1800.c -Driver for Keitley das1700/das1800 series boards -Copyright (C) 2000 Frank Mori Hess - -COMEDI - Linux Control and Measurement Device Interface -Copyright (C) 2000 David A. Schleef - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ -/* -Driver: das1800 -Description: Keithley Metrabyte DAS1800 (& compatibles) -Author: Frank Mori Hess -Devices: [Keithley Metrabyte] DAS-1701ST (das-1701st), - DAS-1701ST-DA (das-1701st-da), DAS-1701/AO (das-1701ao), - DAS-1702ST (das-1702st), DAS-1702ST-DA (das-1702st-da), - DAS-1702HR (das-1702hr), DAS-1702HR-DA (das-1702hr-da), - DAS-1702/AO (das-1702ao), DAS-1801ST (das-1801st), - DAS-1801ST-DA (das-1801st-da), DAS-1801HC (das-1801hc), - DAS-1801AO (das-1801ao), DAS-1802ST (das-1802st), - DAS-1802ST-DA (das-1802st-da), DAS-1802HR (das-1802hr), - DAS-1802HR-DA (das-1802hr-da), DAS-1802HC (das-1802hc), - DAS-1802AO (das-1802ao) -Status: works - -The waveform analog output on the 'ao' cards is not supported. -If you need it, send me (Frank Hess) an email. - -Configuration options: - [0] - I/O port base address - [1] - IRQ (optional, required for timed or externally triggered conversions) - [2] - DMA0 (optional, requires irq) - [3] - DMA1 (optional, requires irq and dma0) -*/ -/* + * Comedi driver for Keithley DAS-1700/DAS-1800 series boards + * Copyright (C) 2000 Frank Mori Hess + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ -This driver supports the following Keithley boards: - -das-1701st -das-1701st-da -das-1701ao -das-1702st -das-1702st-da -das-1702hr -das-1702hr-da -das-1702ao -das-1801st -das-1801st-da -das-1801hc -das-1801ao -das-1802st -das-1802st-da -das-1802hr -das-1802hr-da -das-1802hc -das-1802ao - -Options: - [0] - base io address - [1] - irq (optional, required for timed or externally triggered conversions) - [2] - dma0 (optional, requires irq) - [3] - dma1 (optional, requires irq and dma0) - -irq can be omitted, although the cmd interface will not work without it. - -analog input cmd triggers supported: - start_src: TRIG_NOW | TRIG_EXT - scan_begin_src: TRIG_FOLLOW | TRIG_TIMER | TRIG_EXT - scan_end_src: TRIG_COUNT - convert_src:TRIG_TIMER | TRIG_EXT (TRIG_EXT requires scan_begin_src == TRIG_FOLLOW) - stop_src: TRIG_COUNT | TRIG_EXT | TRIG_NONE - -scan_begin_src triggers TRIG_TIMER and TRIG_EXT use the card's -'burst mode' which limits the valid conversion time to 64 microseconds -(convert_arg <= 64000). This limitation does not apply if scan_begin_src -is TRIG_FOLLOW. - -NOTES: -Only the DAS-1801ST has been tested by me. -Unipolar and bipolar ranges cannot be mixed in the channel/gain list. - -TODO: - Make it automatically allocate irq and dma channels if they are not specified - Add support for analog out on 'ao' cards -*/ +/* + * Driver: das1800 + * Description: Keithley Metrabyte DAS1800 (& compatibles) + * Author: Frank Mori Hess + * Devices: [Keithley Metrabyte] DAS-1701ST (das-1701st), + * DAS-1701ST-DA (das-1701st-da), DAS-1701/AO (das-1701ao), + * DAS-1702ST (das-1702st), DAS-1702ST-DA (das-1702st-da), + * DAS-1702HR (das-1702hr), DAS-1702HR-DA (das-1702hr-da), + * DAS-1702/AO (das-1702ao), DAS-1801ST (das-1801st), + * DAS-1801ST-DA (das-1801st-da), DAS-1801HC (das-1801hc
[PATCH v2 30/37] staging: comedi: das1800: remove the function comments
These comments are just added cruft. Remove them. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index ea6aa5a..3bfe041 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -359,7 +359,6 @@ static void das1800_handle_fifo_not_empty(struct comedi_device *dev, } } -/* Utility function used by das1800_flush_dma() and das1800_handle_dma() */ static void das1800_flush_dma_channel(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_isadma_desc *desc) @@ -375,8 +374,6 @@ static void das1800_flush_dma_channel(struct comedi_device *dev, comedi_buf_write_samples(s, desc->virt_addr, nsamples); } -/* flushes remaining data from board when external trigger has stopped acquisition - * and we are using dma transfers */ static void das1800_flush_dma(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -444,7 +441,6 @@ static int das1800_ai_cancel(struct comedi_device *dev, return 0; } -/* the guts of the interrupt handler, that is shared with das1800_ai_poll */ static void das1800_ai_handler(struct comedi_device *dev) { struct das1800_private *devpriv = dev->private; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 15/37] staging: comedi: das1800: refactor 'range_ai' boardinfo
The boards supported by this driver have analog inputs with gains of 1, 10, 50, and 250 ("01" type) or 1, 2, 4, and 8 ("02" type). Unfortunately, the "01"/"02" type cannot be determined from the boards id or by probing. Replace the 'range_ai' member of the boardinfo with a bit-field flag, 'is_01_series' and only set it for the "01" type boards. Remove the unnecessary initialization for the "02" type boards. For aesthetics, rename the comedi_lrange arrays and document the gain. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 67 +--- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 5d40811..3280763 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -167,30 +167,29 @@ TODO: #define IOBASE2 0x400/* offset of additional ioports used on 'ao' cards */ -/* analog input ranges */ -static const struct comedi_lrange range_ai_das1801 = { +static const struct comedi_lrange das1801_ai_range = { 8, { - BIP_RANGE(5), - BIP_RANGE(1), - BIP_RANGE(0.1), - BIP_RANGE(0.02), - UNI_RANGE(5), - UNI_RANGE(1), - UNI_RANGE(0.1), - UNI_RANGE(0.02) + BIP_RANGE(5), /* bipolar gain = 1 */ + BIP_RANGE(1), /* bipolar gain = 10 */ + BIP_RANGE(0.1), /* bipolar gain = 50 */ + BIP_RANGE(0.02),/* bipolar gain = 250 */ + UNI_RANGE(5), /* unipolar gain = 1 */ + UNI_RANGE(1), /* unipolar gain = 10 */ + UNI_RANGE(0.1), /* unipolar gain = 50 */ + UNI_RANGE(0.02) /* unipolar gain = 250 */ } }; -static const struct comedi_lrange range_ai_das1802 = { +static const struct comedi_lrange das1802_ai_range = { 8, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2.5), - UNI_RANGE(1.25) + BIP_RANGE(10), /* bipolar gain = 1 */ + BIP_RANGE(5), /* bipolar gain = 2 */ + BIP_RANGE(2.5), /* bipolar gain = 4 */ + BIP_RANGE(1.25),/* bipolar gain = 8 */ + UNI_RANGE(10), /* unipolar gain = 1 */ + UNI_RANGE(5), /* unipolar gain = 2 */ + UNI_RANGE(2.5), /* unipolar gain = 4 */ + UNI_RANGE(1.25) /* unipolar gain = 8 */ } }; @@ -228,7 +227,7 @@ struct das1800_board { unsigned char id; int ai_speed; /* max conversion period in nanoseconds */ int qram_len; /* length of card's channel / gain queue */ - const struct comedi_lrange *range_ai; /* available input ranges */ + unsigned int is_01_series:1; }; /* Warning: the maximum conversion speeds listed below are @@ -241,126 +240,115 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST, .ai_speed = 6250, .qram_len = 256, - .range_ai = &range_ai_das1801, + .is_01_series = 1, }, [BOARD_DAS1701ST_DA] = { .name = "das-1701st-da", .id = DAS1800_ID_ST_DA, .ai_speed = 6250, .qram_len = 256, - .range_ai = &range_ai_das1801, + .is_01_series = 1, }, [BOARD_DAS1702ST] = { .name = "das-1702st", .id = DAS1800_ID_ST, .ai_speed = 6250, .qram_len = 256, - .range_ai = &range_ai_das1802, }, [BOARD_DAS1702ST_DA] = { .name = "das-1702st-da", .id = DAS1800_ID_ST_DA, .ai_speed = 6250, .qram_len = 256, - .range_ai = &range_ai_das1802, }, [BOARD_DAS1702HR] = { .name = "das-1702hr", .id = DAS1800_ID_HR, .ai_speed = 2, .qram_len = 256, - .range_ai = &range_ai_das1802, }, [BOARD_DAS1702HR_DA] = { .name = "das-1702hr-da", .id = DAS1800_ID_HR_DA, .ai_speed = 2, .qram_len = 256, - .range_ai = &range_ai_das1802,
[PATCH v2 32/37] staging: comedi: das1800: fix comments in das1800_ai_handler()
Fix the checkpatch.pl issues: WARNING: line over 80 characters Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 42996cd..1edb3d6 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -452,15 +452,13 @@ static void das1800_ai_handler(struct comedi_device *dev) /* select adc register (spinlock is already held) */ outb(ADC, dev->iobase + DAS1800_SELECT); - /* dma buffer full */ - if (devpriv->irq_dma_bits & DMA_ENABLED) { - /* look for data from dma transfer even if dma terminal count hasn't happened yet */ + /* get samples with dma, fifo, or polled as necessary */ + if (devpriv->irq_dma_bits & DMA_ENABLED) das1800_handle_dma(dev, s, status); - } else if (status & FHF) { /* if fifo half full */ + else if (status & FHF) das1800_handle_fifo_half_full(dev, s); - } else if (status & FNE) { /* if fifo not empty */ + else if (status & FNE) das1800_handle_fifo_not_empty(dev, s); - } /* if the card's fifo has overflowed */ if (status & OVF) { @@ -476,7 +474,7 @@ static void das1800_ai_handler(struct comedi_device *dev) if (status & CT0TC) { /* clear CT0TC interrupt bit */ outb(CLEAR_INTR_MASK & ~CT0TC, dev->iobase + DAS1800_STATUS); - /* make sure we get all remaining data from board before quitting */ + /* get all remaining samples before quitting */ if (devpriv->irq_dma_bits & DMA_ENABLED) das1800_flush_dma(dev, s); else -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 18/37] staging: comedi: das1800: add analog output readback
Use the core provided readback support to allow reading back the last value written to the analog output channels. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 52a8c5b..64b5403 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -91,7 +91,6 @@ Unipolar and bipolar ranges cannot be mixed in the channel/gain list. TODO: Make it automatically allocate irq and dma channels if they are not specified Add support for analog out on 'ao' cards - read insn for analog out */ #include @@ -341,8 +340,6 @@ struct das1800_private { int dma_bits; uint16_t *fifo_buf; /* bounce buffer for analog input FIFO */ unsigned long iobase2; /* secondary io address used for analog out on 'ao' boards */ - unsigned short ao_update_bits; /* remembers the last write to the -* 'update' dac */ bool ai_is_unipolar; }; @@ -1017,7 +1014,6 @@ static int das1800_ao_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct das1800_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); unsigned int update_chan = s->n_chan - 1; unsigned long flags; @@ -1029,9 +1025,9 @@ static int das1800_ao_insn_write(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { unsigned int val = data[i]; + s->readback[chan] = val; + val = comedi_offset_munge(s, val); - if (chan == update_chan) - devpriv->ao_update_bits = val; /* load this channel (and update if it's the last channel) */ outb(DAC(chan), dev->iobase + DAS1800_SELECT); @@ -1039,9 +1035,10 @@ static int das1800_ao_insn_write(struct comedi_device *dev, /* update all channels */ if (chan != update_chan) { + val = comedi_offset_munge(s, s->readback[update_chan]); + outb(DAC(update_chan), dev->iobase + DAS1800_SELECT); - outw(devpriv->ao_update_bits, -dev->iobase + DAS1800_DAC); + outw(val, dev->iobase + DAS1800_DAC); } } spin_unlock_irqrestore(&dev->spinlock, flags); @@ -1318,6 +1315,10 @@ static int das1800_attach(struct comedi_device *dev, s->range_table = &range_bipolar10; s->insn_write = das1800_ao_insn_write; + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + /* initialize all channels to 0V */ for (i = 0; i < s->n_chan; i++) { outb(DAC(i), dev->iobase + DAS1800_SELECT); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 16/37] staging: comedi: das1800: remove 'qram_len' boardinfo
The "hc" type boards have 64 analog input channels with a 64 entry queue. All the others have 16 channels and a 256 entry queue. EXP-1800 expansion boards can be used to increase the number of analog inputs on the 16 channel boards, 16 channels per EXP-1800, for a total of 256 channels. Remove the 'qram_len' member of the boardinfo and use the 'id' member to determine the number of channels. Add a comment about the number of channels and the unclear mapping of the channels when EXP-1800 boards are used. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 36 +--- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 3280763..d3aca97 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -226,7 +226,6 @@ struct das1800_board { const char *name; unsigned char id; int ai_speed; /* max conversion period in nanoseconds */ - int qram_len; /* length of card's channel / gain queue */ unsigned int is_01_series:1; }; @@ -239,116 +238,98 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1701st", .id = DAS1800_ID_ST, .ai_speed = 6250, - .qram_len = 256, .is_01_series = 1, }, [BOARD_DAS1701ST_DA] = { .name = "das-1701st-da", .id = DAS1800_ID_ST_DA, .ai_speed = 6250, - .qram_len = 256, .is_01_series = 1, }, [BOARD_DAS1702ST] = { .name = "das-1702st", .id = DAS1800_ID_ST, .ai_speed = 6250, - .qram_len = 256, }, [BOARD_DAS1702ST_DA] = { .name = "das-1702st-da", .id = DAS1800_ID_ST_DA, .ai_speed = 6250, - .qram_len = 256, }, [BOARD_DAS1702HR] = { .name = "das-1702hr", .id = DAS1800_ID_HR, .ai_speed = 2, - .qram_len = 256, }, [BOARD_DAS1702HR_DA] = { .name = "das-1702hr-da", .id = DAS1800_ID_HR_DA, .ai_speed = 2, - .qram_len = 256, }, [BOARD_DAS1701AO] = { .name = "das-1701ao", .id = DAS1800_ID_AO, .ai_speed = 6250, - .qram_len = 256, .is_01_series = 1, }, [BOARD_DAS1702AO] = { .name = "das-1702ao", .id = DAS1800_ID_AO, .ai_speed = 6250, - .qram_len = 256, }, [BOARD_DAS1801ST] = { .name = "das-1801st", .id = DAS1800_ID_ST, .ai_speed = 3000, - .qram_len = 256, .is_01_series = 1, }, [BOARD_DAS1801ST_DA] = { .name = "das-1801st-da", .id = DAS1800_ID_ST_DA, .ai_speed = 3000, - .qram_len = 256, .is_01_series = 1, }, [BOARD_DAS1802ST] = { .name = "das-1802st", .id = DAS1800_ID_ST, .ai_speed = 3000, - .qram_len = 256, }, [BOARD_DAS1802ST_DA] = { .name = "das-1802st-da", .id = DAS1800_ID_ST_DA, .ai_speed = 3000, - .qram_len = 256, }, [BOARD_DAS1802HR] = { .name = "das-1802hr", .id = DAS1800_ID_HR, .ai_speed = 1, - .qram_len = 256, }, [BOARD_DAS1802HR_DA] = { .name = "das-1802hr-da", .id = DAS1800_ID_HR_DA, .ai_speed = 1, - .qram_len = 256, }, [BOARD_DAS1801HC] = { .name = "das-1801hc", .id = DAS1800_ID_HC, .ai_speed = 3000, - .qram_len = 64, .is_01_series = 1, }, [BOARD_DAS1802HC] = { .name = "das-1802hc", .id = DAS1800_ID_HC, .ai_speed = 3000, -
[PATCH v2 06/37] staging: comedi: das1800: tidy up das1800_probe()
Refactor das1800_probe() to return an errno instead of the boardinfo pointer. Add the board 'id' to the boardinfo to tidy up this function to clarify the sanity check when the user provided a board name when trying to attach to the driver. Currently when this function probes for a boardinfo based on the board id it returns the wrong boardinfo for the "st-da" and "hr-da" types. This causes the analog input subdevice for those boards to not be available. Fix the probe so that a proper boardinfo is used. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 207 +++ 1 file changed, 131 insertions(+), 76 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index aba8021..e24d0c9 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -167,13 +167,6 @@ TODO: #define IOBASE2 0x400/* offset of additional ioports used on 'ao' cards */ -enum { - das1701st, das1701st_da, das1702st, das1702st_da, das1702hr, - das1702hr_da, - das1701ao, das1702ao, das1801st, das1801st_da, das1802st, das1802st_da, - das1802hr, das1802hr_da, das1801hc, das1802hc, das1801ao, das1802ao -}; - /* analog input ranges */ static const struct comedi_lrange range_ai_das1801 = { 8, { @@ -201,8 +194,38 @@ static const struct comedi_lrange range_ai_das1802 = { } }; +enum das1800_boardid { + BOARD_DAS1701ST, + BOARD_DAS1701ST_DA, + BOARD_DAS1702ST, + BOARD_DAS1702ST_DA, + BOARD_DAS1702HR, + BOARD_DAS1702HR_DA, + BOARD_DAS1701AO, + BOARD_DAS1702AO, + BOARD_DAS1801ST, + BOARD_DAS1801ST_DA, + BOARD_DAS1802ST, + BOARD_DAS1802ST_DA, + BOARD_DAS1802HR, + BOARD_DAS1802HR_DA, + BOARD_DAS1801HC, + BOARD_DAS1802HC, + BOARD_DAS1801AO, + BOARD_DAS1802AO +}; + +/* board probe id values (hi byte of the digital input register) */ +#define DAS1800_ID_ST_DA 0x3 +#define DAS1800_ID_HR_DA 0x4 +#define DAS1800_ID_AO 0x5 +#define DAS1800_ID_HR 0x6 +#define DAS1800_ID_ST 0x7 +#define DAS1800_ID_HC 0x8 + struct das1800_board { const char *name; + unsigned char id; int ai_speed; /* max conversion period in nanoseconds */ int resolution; /* bits of ai resolution */ int qram_len; /* length of card's channel / gain queue */ @@ -218,8 +241,9 @@ struct das1800_board { * user manual.) */ static const struct das1800_board das1800_boards[] = { - { + [BOARD_DAS1701ST] = { .name = "das-1701st", + .id = DAS1800_ID_ST, .ai_speed = 6250, .resolution = 12, .qram_len = 256, @@ -228,8 +252,10 @@ static const struct das1800_board das1800_boards[] = { .ao_ability = 0, .ao_n_chan = 0, .range_ai = &range_ai_das1801, - }, { + }, + [BOARD_DAS1701ST_DA] = { .name = "das-1701st-da", + .id = DAS1800_ID_ST_DA, .ai_speed = 6250, .resolution = 12, .qram_len = 256, @@ -238,8 +264,10 @@ static const struct das1800_board das1800_boards[] = { .ao_ability = 1, .ao_n_chan = 4, .range_ai = &range_ai_das1801, - }, { + }, + [BOARD_DAS1702ST] = { .name = "das-1702st", + .id = DAS1800_ID_ST, .ai_speed = 6250, .resolution = 12, .qram_len = 256, @@ -248,8 +276,10 @@ static const struct das1800_board das1800_boards[] = { .ao_ability = 0, .ao_n_chan = 0, .range_ai = &range_ai_das1802, - }, { + }, + [BOARD_DAS1702ST_DA] = { .name = "das-1702st-da", + .id = DAS1800_ID_ST_DA, .ai_speed = 6250, .resolution = 12, .qram_len = 256, @@ -258,8 +288,10 @@ static const struct das1800_board das1800_boards[] = { .ao_ability = 1, .ao_n_chan = 4, .range_ai = &range_ai_das1802, - }, { + }, + [BOARD_DAS1702HR] = { .name = "das-1702hr", + .id = DAS1800_ID_HR, .ai_speed = 2, .resolution = 16, .qram_len = 256, @@ -268,8 +300,10 @@ static const struct das1800_board das1800_boards[] = {
[PATCH v2 08/37] staging: comedi: das1800: use comedi_offset_munge() for analog output
The analog outputs expect 2's complement data. For aesthetics, use the helper function to handle the munging instead of depending on the boardinfo 'resolution'. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 6795f3e..f870824 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1132,8 +1132,7 @@ static int das1800_ao_insn_write(struct comedi_device *dev, unsigned short output; unsigned long irq_flags; - /* card expects two's complement data */ - output = data[0] - (1 << (board->resolution - 1)); + output = comedi_offset_munge(s, data[0]); /* if the write is to the 'update' channel, we need to remember its value */ if (chan == update_chan) devpriv->ao_update_bits = output; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 22/37] staging: comedi: das1800: use comedi_timeout()
Use the helper function to handle the busywaiting for the analog input conversion to complete. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 34 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 2bb53db..4355171 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -937,6 +937,19 @@ static int das1800_ai_cmd(struct comedi_device *dev, return 0; } +static int das1800_ai_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + unsigned char status; + + status = inb(dev->iobase + DAS1800_STATUS); + if (status & FNE) + return 0; + return -EBUSY; +} + static int das1800_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -944,8 +957,8 @@ static int das1800_ai_insn_read(struct comedi_device *dev, { unsigned int range = CR_RANGE(insn->chanspec); bool is_unipolar = comedi_range_is_unipolar(s, range); - int i, n; - int timeout = 1000; + int ret = 0; + int n; unsigned short dpnt; unsigned long flags; @@ -966,24 +979,19 @@ static int das1800_ai_insn_read(struct comedi_device *dev, for (n = 0; n < insn->n; n++) { /* trigger conversion */ outb(0, dev->iobase + DAS1800_FIFO); - for (i = 0; i < timeout; i++) { - if (inb(dev->iobase + DAS1800_STATUS) & FNE) - break; - } - if (i == timeout) { - dev_err(dev->class_dev, "timeout\n"); - n = -ETIME; - goto exit; - } + + ret = comedi_timeout(dev, s, insn, das1800_ai_eoc, 0); + if (ret) + break; + dpnt = inw(dev->iobase + DAS1800_FIFO); if (!is_unipolar) dpnt = comedi_offset_munge(s, dpnt); data[n] = dpnt; } -exit: spin_unlock_irqrestore(&dev->spinlock, flags); - return n; + return ret ? ret : insn->n; } static int das1800_ao_insn_write(struct comedi_device *dev, -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 26/37] staging: comedi: das1800: change type of private data 'fifo_buf'
Fix the checkpatch.pl issue: CHECK: Prefer kernel type 'u16' over 'uint16_t' Change the type to 'unsigned short' as that is more typical in comedi drivers. Use sizeof(*p) instead of sizeof(type) when allocation the buffer. Also fix the checkpatch.pl issue: WARNING: line over 80 characters Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 118fa76..6045978 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -304,7 +304,7 @@ struct das1800_private { /* dma bits for control register b, stored so that dma can be * turned on and off */ int dma_bits; - uint16_t *fifo_buf; /* bounce buffer for analog input FIFO */ + unsigned short *fifo_buf; unsigned long iobase2; /* secondary io address used for analog out on 'ao' boards */ bool ai_is_unipolar; }; @@ -1200,7 +1200,9 @@ static int das1800_attach(struct comedi_device *dev, if (dev->irq & it->options[2]) das1800_init_dma(dev, it); - devpriv->fifo_buf = kmalloc_array(FIFO_SIZE, sizeof(uint16_t), GFP_KERNEL); + devpriv->fifo_buf = kmalloc_array(FIFO_SIZE, + sizeof(*devpriv->fifo_buf), + GFP_KERNEL); if (!devpriv->fifo_buf) return -ENOMEM; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 27/37] staging: comedi: das1800: move comment about max conversion speeds
For aesthetics, move this information into the comedi comment block. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 6045978..9268acb 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -51,6 +51,9 @@ * (convert_arg <= 64000). This limitation does not apply if scan_begin_src * is TRIG_FOLLOW. * + * The maximum conversion speeds are not always achievable depending on the + * board setup (see user manual). + * * NOTES: * Only the DAS-1801ST has been tested by me. * Unipolar and bipolar ranges cannot be mixed in the channel/gain list. @@ -194,10 +197,6 @@ struct das1800_board { unsigned int is_01_series:1; }; -/* Warning: the maximum conversion speeds listed below are - * not always achievable depending on board setup (see - * user manual.) - */ static const struct das1800_board das1800_boards[] = { [BOARD_DAS1701ST] = { .name = "das-1701st", -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 29/37] staging: comedi: das1800: clarify step 4 of the ai (*do_cmdtest)
This step of the (*do_cmdtest) fixes the timing arguments when the cmd->convert_src is TRIG_TIMER. The code is compact but it's a bit hard to understand the "burst mode" vs. "non burst mode" (i.e. paced) timing. Clarify the fixup by splitting it into separate functions to check the arguments based on if the command is doing 'paced' or 'burst' timing. Add some comments to clarify the fixups. This also fixes a minor issue with the 'burst' timing. When the cmd->scan_begin_src is also TRIG_TIMER the pacer clock is used to start each scan. The cmd->scan_begin_arg specifies the scan time. The minimum (not maximum) value for this time must be large enough for the 'burst' conversion time to sample all the channels. The current 'max' check limits the scan time to the minimum time (i.e. the max conversion speed). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 101 +++ 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 8302f33..ea6aa5a 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -544,33 +544,73 @@ static irqreturn_t das1800_interrupt(int irq, void *d) return IRQ_HANDLED; } -/* converts requested conversion timing to timing compatible with - * hardware, used only when card is in 'burst mode' - */ -static unsigned int burst_convert_arg(unsigned int convert_arg, int flags) +static int das1800_ai_fixup_paced_timing(struct comedi_device *dev, +struct comedi_cmd *cmd) { - unsigned int micro_sec; + unsigned int arg = cmd->convert_arg; + + /* +* Paced mode: +* scan_begin_src is TRIG_FOLLOW +* convert_src is TRIG_TIMER +* +* The convert_arg sets the pacer sample acquisition time. +* The max acquisition speed is limited to the boards +* 'ai_speed' (this was already verified). The min speed is +* limited by the cascaded 8254 timer. +*/ + comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags); + return comedi_check_trigger_arg_is(&cmd->convert_arg, arg); +} - /* in burst mode, the maximum conversion time is 64 microseconds */ - if (convert_arg > 64000) - convert_arg = 64000; +static int das1800_ai_fixup_burst_timing(struct comedi_device *dev, +struct comedi_cmd *cmd) +{ + unsigned int arg = cmd->convert_arg; + int err = 0; + + /* +* Burst mode: +* scan_begin_src is TRIG_TIMER or TRIG_EXT +* convert_src is TRIG_TIMER +* +* The convert_arg sets burst sample acquisition time. +* The max acquisition speed is limited to the boards +* 'ai_speed' (this was already verified). The min speed is +* limiited to 64 microseconds, +*/ + err |= comedi_check_trigger_arg_max(&arg, 64000); - /* the conversion time must be an integral number of microseconds */ - switch (flags & CMDF_ROUND_MASK) { + /* round to microseconds then verify */ + switch (cmd->flags & CMDF_ROUND_MASK) { case CMDF_ROUND_NEAREST: default: - micro_sec = (convert_arg + 500) / 1000; + arg = DIV_ROUND_CLOSEST(arg, 1000); break; case CMDF_ROUND_DOWN: - micro_sec = convert_arg / 1000; + arg = arg / 1000; break; case CMDF_ROUND_UP: - micro_sec = (convert_arg - 1) / 1000 + 1; + arg = DIV_ROUND_UP(arg, 1000); break; } + err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg * 1000); + + /* +* The pacer can be used to set the scan sample rate. The max scan +* speed is limited by the conversion speed and the number of channels +* to convert. The min speed is limited by the cascaded 8254 timer. +*/ + if (cmd->scan_begin_src == TRIG_TIMER) { + arg = cmd->convert_arg * cmd->chanlist_len; + err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg, arg); - /* return number of nanoseconds */ - return micro_sec * 1000; + arg = cmd->scan_begin_arg; + comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags); + err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg); + } + + return err; } static int das1800_ai_check_chanlist(struct comedi_device *dev, @@ -600,7 +640,6 @@ static int das1800_ai_cmdtest(struct comedi_device *dev, { const struct das1800_board *board = dev->board_ptr; int err = 0; - unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -659,31 +698,13 @@ static int da
[PATCH v2 10/37] staging: comedi: das1800: remove 'do_n_chan' boardinfo
The "hc" type boards have 8 digtial outputs. All other board types have 4. Remove the 'do_n_chan' member of the boardinfo and use the 'id' member to determine the subdevice 'n_chan'. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 21 + 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 43e621b..6641f2e 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -228,7 +228,6 @@ struct das1800_board { unsigned char id; int ai_speed; /* max conversion period in nanoseconds */ int qram_len; /* length of card's channel / gain queue */ - int do_n_chan; /* number of digital output channels */ int ao_ability; /* 0 == no analog out, 1 == basic analog out, 2 == waveform analog out */ int ao_n_chan; /* number of analog out channels */ const struct comedi_lrange *range_ai; /* available input ranges */ @@ -244,7 +243,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST, .ai_speed = 6250, .qram_len = 256, - .do_n_chan = 4, .ao_ability = 0, .ao_n_chan = 0, .range_ai = &range_ai_das1801, @@ -254,7 +252,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST_DA, .ai_speed = 6250, .qram_len = 256, - .do_n_chan = 4, .ao_ability = 1, .ao_n_chan = 4, .range_ai = &range_ai_das1801, @@ -264,7 +261,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST, .ai_speed = 6250, .qram_len = 256, - .do_n_chan = 4, .ao_ability = 0, .ao_n_chan = 0, .range_ai = &range_ai_das1802, @@ -274,7 +270,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST_DA, .ai_speed = 6250, .qram_len = 256, - .do_n_chan = 4, .ao_ability = 1, .ao_n_chan = 4, .range_ai = &range_ai_das1802, @@ -284,7 +279,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_HR, .ai_speed = 2, .qram_len = 256, - .do_n_chan = 4, .ao_ability = 0, .ao_n_chan = 0, .range_ai = &range_ai_das1802, @@ -294,7 +288,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_HR_DA, .ai_speed = 2, .qram_len = 256, - .do_n_chan = 4, .ao_ability = 1, .ao_n_chan = 2, .range_ai = &range_ai_das1802, @@ -304,7 +297,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_AO, .ai_speed = 6250, .qram_len = 256, - .do_n_chan = 4, .ao_ability = 2, .ao_n_chan = 2, .range_ai = &range_ai_das1801, @@ -314,7 +306,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_AO, .ai_speed = 6250, .qram_len = 256, - .do_n_chan = 4, .ao_ability = 2, .ao_n_chan = 2, .range_ai = &range_ai_das1802, @@ -324,7 +315,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST, .ai_speed = 3000, .qram_len = 256, - .do_n_chan = 4, .ao_ability = 0, .ao_n_chan = 0, .range_ai = &range_ai_das1801, @@ -334,7 +324,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST_DA, .ai_speed = 3000, .qram_len = 256, - .do_n_chan = 4, .ao_ability = 1, .ao_n_chan = 4, .range_ai = &range_ai_das1801, @@ -344,7 +333,6 @@ static const struct das1800_board das1800_boards[] = { .id = DAS1800_ID_ST, .ai_speed = 3000,
[PATCH v2 31/37] staging: comedi: das1800: fix comments in das1800_ai_cmd()
Fix the checkpatch.pl issues: WARNING: Block comments use a trailing */ on a separate line WARNING: line over 80 characters Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 3bfe041..42996cd 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -833,8 +833,10 @@ static int das1800_ai_cmd(struct comedi_device *dev, const struct comedi_cmd *cmd = &async->cmd; unsigned int range0 = CR_RANGE(cmd->chanlist[0]); - /* disable dma on CMDF_WAKE_EOS, or CMDF_PRIORITY -* (because dma in handler is unsafe at hard real-time priority) */ + /* +* Disable dma on CMDF_WAKE_EOS, or CMDF_PRIORITY (because dma in +* handler is unsafe at hard real-time priority). +*/ if (cmd->flags & (CMDF_WAKE_EOS | CMDF_PRIORITY)) devpriv->irq_dma_bits &= ~DMA_ENABLED; else @@ -897,14 +899,15 @@ static int das1800_ai_cmd(struct comedi_device *dev, outb(control_c, dev->iobase + DAS1800_CONTROL_C); /* set conversion rate and length for burst mode */ if (control_c & BMDE) { - /* program conversion period with number of microseconds minus 1 */ - outb(cmd->convert_arg / 1000 - 1, + outb(cmd->convert_arg / 1000 - 1, /* microseconds - 1 */ dev->iobase + DAS1800_BURST_RATE); outb(cmd->chanlist_len - 1, dev->iobase + DAS1800_BURST_LENGTH); } - outb(devpriv->irq_dma_bits, dev->iobase + DAS1800_CONTROL_B); /* enable irq/dma */ - outb(control_a, dev->iobase + DAS1800_CONTROL_A); /* enable fifo and triggering */ - outb(CVEN, dev->iobase + DAS1800_STATUS); /* enable conversions */ + + /* enable and start conversions */ + outb(devpriv->irq_dma_bits, dev->iobase + DAS1800_CONTROL_B); + outb(control_a, dev->iobase + DAS1800_CONTROL_A); + outb(CVEN, dev->iobase + DAS1800_STATUS); return 0; } -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 00/37] staging: comedi: das1800: tidy up driver
Tidy up this driver and fix all the checkpatch.pl issues. This series applies after the bug fix series: [PATCH v2 0/3] staging: comedi: das1800: bug fixes v2 changes: * refactor based on the bug fix series * reorder the series to tidy up das1800_probe() early and then use the board 'id' to set various subdevice info instead of adding additional bit-field flags to the boardinfo * leave the number of analog input channels as-is, at the request of Ian Abbott * clarify step 4 of the analog input (*do_cmdtest) * allow setting the external trigger polarity H Hartley Sweeten (37): staging: comedi: das1800: tidy up digital output subdevice init staging: comedi: das1800: tidy up digital input subdevice init staging: comedi: das1800: tidy up analog output subdevice init staging: comedi: das1800: tidy up analog input subdevice init staging: comedi: das1800: tidy up boardinfo staging: comedi: das1800: tidy up das1800_probe() staging: comedi: das1800: remove 'common' boardinfo member staging: comedi: das1800: use comedi_offset_munge() for analog output staging: comedi: das1800: remove 'resolution' boardinfo staging: comedi: das1800: remove 'do_n_chan' boardinfo staging: comedi: das1800: initialize all analog outputs staging: comedi: das1800: tidy up das1800_ao_insn_write() staging: comedi: das1800: remove 'ao_n_chan' boardinfo staging: comedi: das1800: remove 'ao_ability' boardinfo staging: comedi: das1800: refactor 'range_ai' boardinfo staging: comedi: das1800: remove 'qram_len' boardinfo staging: comedi: das1800: change type of 'ai_speed' boardinfo staging: comedi: das1800: add analog output readback staging: comedi: das1800: introduce das1800_ai_chanspec_bits() staging: comedi: das1800: absorb control_c_bits() staging: comedi: das1800: refactor program_chanlist() staging: comedi: das1800: use comedi_timeout() staging: comedi: das1800: absorb control_a_bits() staging: comedi: das1800: document the spinlock staging: comedi: das1800: cleanup copyright and comedi comment blocks staging: comedi: das1800: change type of private data 'fifo_buf' staging: comedi: das1800: move comment about max conversion speeds staging: comedi: das1800: remove the private data member comments staging: comedi: das1800: clarify step 4 of the ai (*do_cmdtest) staging: comedi: das1800: remove the function comments staging: comedi: das1800: fix comments in das1800_ai_cmd() staging: comedi: das1800: fix comments in das1800_ai_handler() staging: comedi: das1800: fix lines over 80 characters staging: comedi: das1800: fix comments about the 'ao' board range staging: comedi: das1800: clarify the analog input cmd triggers staging: comedi: das1800: allow setting the external trigger polarity staging: comedi: das1800: update the MODULE_DESCRIPTION drivers/staging/comedi/drivers/das1800.c | 1305 ++ 1 file changed, 614 insertions(+), 691 deletions(-) -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 28/37] staging: comedi: das1800: remove the private data member comments
The comments about the members of the private data are not really necessary and removing them fixes a couple checkpatch.pl issues. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 9268acb..8302f33 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -299,12 +299,10 @@ static const struct das1800_board das1800_boards[] = { struct das1800_private { struct comedi_isadma *dma; - int irq_dma_bits; /* bits for control register b */ - /* dma bits for control register b, stored so that dma can be -* turned on and off */ + int irq_dma_bits; int dma_bits; unsigned short *fifo_buf; - unsigned long iobase2; /* secondary io address used for analog out on 'ao' boards */ + unsigned long iobase2; bool ai_is_unipolar; }; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 09/37] staging: comedi: das1800: remove 'resolution' boardinfo
The "hr" type boards have 16-bit analog inputs and outputs. All other board types have 12-bit. Remove the 'resolution' member of the boardinfo and use the 'id' member to determine the subdevices 'maxdata'. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 26 +- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index f870824..43e621b 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -227,7 +227,6 @@ struct das1800_board { const char *name; unsigned char id; int ai_speed; /* max conversion period in nanoseconds */ - int resolution; /* bits of ai resolution */ int qram_len; /* length of card's channel / gain queue */ int do_n_chan; /* number of digital output channels */ int ao_ability; /* 0 == no analog out, 1 == basic analog out, 2 == waveform analog out */ @@ -244,7 +243,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1701st", .id = DAS1800_ID_ST, .ai_speed = 6250, - .resolution = 12, .qram_len = 256, .do_n_chan = 4, .ao_ability = 0, @@ -255,7 +253,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1701st-da", .id = DAS1800_ID_ST_DA, .ai_speed = 6250, - .resolution = 12, .qram_len = 256, .do_n_chan = 4, .ao_ability = 1, @@ -266,7 +263,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1702st", .id = DAS1800_ID_ST, .ai_speed = 6250, - .resolution = 12, .qram_len = 256, .do_n_chan = 4, .ao_ability = 0, @@ -277,7 +273,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1702st-da", .id = DAS1800_ID_ST_DA, .ai_speed = 6250, - .resolution = 12, .qram_len = 256, .do_n_chan = 4, .ao_ability = 1, @@ -288,7 +283,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1702hr", .id = DAS1800_ID_HR, .ai_speed = 2, - .resolution = 16, .qram_len = 256, .do_n_chan = 4, .ao_ability = 0, @@ -299,7 +293,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1702hr-da", .id = DAS1800_ID_HR_DA, .ai_speed = 2, - .resolution = 16, .qram_len = 256, .do_n_chan = 4, .ao_ability = 1, @@ -310,7 +303,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1701ao", .id = DAS1800_ID_AO, .ai_speed = 6250, - .resolution = 12, .qram_len = 256, .do_n_chan = 4, .ao_ability = 2, @@ -321,7 +313,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1702ao", .id = DAS1800_ID_AO, .ai_speed = 6250, - .resolution = 12, .qram_len = 256, .do_n_chan = 4, .ao_ability = 2, @@ -332,7 +323,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1801st", .id = DAS1800_ID_ST, .ai_speed = 3000, - .resolution = 12, .qram_len = 256, .do_n_chan = 4, .ao_ability = 0, @@ -343,7 +333,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1801st-da", .id = DAS1800_ID_ST_DA, .ai_speed = 3000, - .resolution = 12, .qram_len = 256, .do_n_chan = 4, .ao_ability = 1, @@ -354,7 +343,6 @@ static const struct das1800_board das1800_boards[] = { .name = "das-1802st", .id = DAS1800_ID_ST, .ai_speed = 3000, -
[PATCH v2 12/37] staging: comedi: das1800: tidy up das1800_ao_insn_write()
The (*insn_write) functions are supposed to write insn->n values to the specified channel. Tidy up this function and make it work like the core expects. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 46 ++-- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 45d7201..962a414 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1086,30 +1086,36 @@ static int das1800_ao_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - const struct das1800_board *board = dev->board_ptr; struct das1800_private *devpriv = dev->private; - int chan = CR_CHAN(insn->chanspec); -/* int range = CR_RANGE(insn->chanspec); */ - int update_chan = board->ao_n_chan - 1; - unsigned short output; - unsigned long irq_flags; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int update_chan = s->n_chan - 1; + unsigned long flags; + int i; - output = comedi_offset_munge(s, data[0]); - /* if the write is to the 'update' channel, we need to remember its value */ - if (chan == update_chan) - devpriv->ao_update_bits = output; - /* write to channel */ - spin_lock_irqsave(&dev->spinlock, irq_flags); - outb(DAC(chan), dev->iobase + DAS1800_SELECT); /* select dac channel for baseAddress + 0x0 */ - outw(output, dev->iobase + DAS1800_DAC); - /* now we need to write to 'update' channel to update all dac channels */ - if (chan != update_chan) { - outb(DAC(update_chan), dev->iobase + DAS1800_SELECT); /* select 'update' channel for baseAddress + 0x0 */ - outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC); + /* protects the indirect addressing selected by DAS1800_SELECT */ + spin_lock_irqsave(&dev->spinlock, flags); + + for (i = 0; i < insn->n; i++) { + unsigned int val = data[i]; + + val = comedi_offset_munge(s, val); + if (chan == update_chan) + devpriv->ao_update_bits = val; + + /* load this channel (and update if it's the last channel) */ + outb(DAC(chan), dev->iobase + DAS1800_SELECT); + outw(val, dev->iobase + DAS1800_DAC); + + /* update all channels */ + if (chan != update_chan) { + outb(DAC(update_chan), dev->iobase + DAS1800_SELECT); + outw(devpriv->ao_update_bits, +dev->iobase + DAS1800_DAC); + } } - spin_unlock_irqrestore(&dev->spinlock, irq_flags); + spin_unlock_irqrestore(&dev->spinlock, flags); - return 1; + return insn->n; } static int das1800_di_insn_bits(struct comedi_device *dev, -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 37/37] staging: comedi: das1800: update the MODULE_DESCRIPTION
Change the MODULE_DESCRIPTION to something more usefull than the generic "Comedi low-level driver". Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 875b6f5..e0a34c2 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1369,5 +1369,5 @@ static struct comedi_driver das1800_driver = { module_comedi_driver(das1800_driver); MODULE_AUTHOR("Comedi http://www.comedi.org";); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi driver for DAS1800 compatible ISA boards"); MODULE_LICENSE("GPL"); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 36/37] staging: comedi: das1800: allow setting the external trigger polarity
The external pin TGIN can be used to start and/or stop the analog input command. Currently the driver only supports negative edge polarity for this signal. Add support to allow the user to select positive edge polarity using the CR_INVERT flag. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index bfbc2bb..875b6f5 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -60,6 +60,9 @@ * If TRIG_EXT is used for both the start_src and stop_src, the first TGIN * trigger starts the command, and the second trigger will stop it. If only * one is TRIG_EXT, the first trigger will either stop or start the command. + * The external pin TGIN is normally set for negative edge triggering. It + * can be set to positive edge with the CR_INVERT flag. If TRIG_EXT is used + * for both the start_src and stop_src they must have the same polarity. * * Minimum conversion speed is limited to 64 microseconds (convert_arg <= 64000) * for 'burst' scans. This limitation does not apply for 'paced' scans. The @@ -105,6 +108,7 @@ #define CGSL0x8 #define TGEN0x10 #define TGSL0x20 +#define TGPL0x40 #define ATEN0x80 #define DAS1800_CONTROL_B 0x5 #define DMA_CH5 0x1 @@ -671,12 +675,18 @@ static int das1800_ai_cmdtest(struct comedi_device *dev, cmd->convert_src != TRIG_TIMER) err |= -EINVAL; + /* the external pin TGIN must use the same polarity */ + if (cmd->start_src == TRIG_EXT && cmd->stop_src == TRIG_EXT) + err |= comedi_check_trigger_arg_is(&cmd->start_arg, + cmd->stop_arg); + if (err) return 2; /* Step 3: check if arguments are trivially valid */ - err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0); + if (cmd->start_arg == TRIG_NOW) + err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0); if (cmd->convert_src == TRIG_TIMER) { err |= comedi_check_trigger_arg_min(&cmd->convert_arg, @@ -868,6 +878,10 @@ static int das1800_ai_cmd(struct comedi_device *dev, control_a |= TGEN | CGSL; else /* TRIG_NOW */ control_a |= CGEN; + if (control_a & (ATEN | TGEN)) { + if ((cmd->start_arg & CR_INVERT) || (cmd->stop_arg & CR_INVERT)) + control_a |= TGPL; + } control_c = das1800_ai_chanspec_bits(s, cmd->chanlist[0]); /* set clock source to internal or external */ -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 04/37] staging: comedi: das1800: tidy up analog input subdevice init
For aesthetics, add some whitespace to the subdevice init and rename the subdevice support functions. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 57 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 7f7b1d0..fc8c0f9 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -545,7 +545,8 @@ static void das1800_handle_dma(struct comedi_device *dev, } } -static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int das1800_ai_cancel(struct comedi_device *dev, +struct comedi_subdevice *s) { struct das1800_private *devpriv = dev->private; struct comedi_isadma *dma = devpriv->dma; @@ -709,10 +710,9 @@ static int das1800_ai_check_chanlist(struct comedi_device *dev, return 0; } -/* test analog input cmd */ -static int das1800_ai_do_cmdtest(struct comedi_device *dev, -struct comedi_subdevice *s, -struct comedi_cmd *cmd) +static int das1800_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { const struct das1800_board *board = dev->board_ptr; int err = 0; @@ -973,9 +973,8 @@ static void program_chanlist(struct comedi_device *dev, spin_unlock_irqrestore(&dev->spinlock, irq_flags); } -/* analog input do_cmd */ -static int das1800_ai_do_cmd(struct comedi_device *dev, -struct comedi_subdevice *s) +static int das1800_ai_cmd(struct comedi_device *dev, + struct comedi_subdevice *s) { struct das1800_private *devpriv = dev->private; int control_a, control_c; @@ -998,7 +997,7 @@ static int das1800_ai_do_cmd(struct comedi_device *dev, devpriv->irq_dma_bits |= FIMD; } - das1800_cancel(dev, s); + das1800_ai_cancel(dev, s); devpriv->ai_is_unipolar = comedi_range_is_unipolar(s, range0); @@ -1037,10 +1036,10 @@ static int das1800_ai_do_cmd(struct comedi_device *dev, return 0; } -/* read analog input */ -static int das1800_ai_rinsn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das1800_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec); @@ -1353,25 +1352,25 @@ static int das1800_attach(struct comedi_device *dev, if (ret) return ret; - /* analog input subdevice */ + /* Analog Input subdevice */ s = &dev->subdevices[0]; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND; if (board->common) - s->subdev_flags |= SDF_COMMON; - s->n_chan = board->qram_len; - s->maxdata = (1 << board->resolution) - 1; - s->range_table = board->range_ai; - s->insn_read = das1800_ai_rinsn; + s->subdev_flags |= SDF_COMMON; + s->n_chan = board->qram_len; + s->maxdata = (1 << board->resolution) - 1; + s->range_table = board->range_ai; + s->insn_read= das1800_ai_insn_read; if (dev->irq) { dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - s->len_chanlist = s->n_chan; - s->do_cmd = das1800_ai_do_cmd; - s->do_cmdtest = das1800_ai_do_cmdtest; - s->poll = das1800_ai_poll; - s->cancel = das1800_cancel; - s->munge = das1800_ai_munge; + s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = s->n_chan; + s->do_cmd = das1800_ai_cmd; + s->do_cmdtest = das1800_ai_cmdtest; + s->poll = das1800_ai_poll; + s->cancel = das1800_ai_cancel; + s->munge= das1800_ai_munge; } /* Analog Output subdevice */ @@ -1405,7 +1404,7 @@ static int das1800_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_bits= das1800_do_insn_bits; - das1800_cancel(dev, dev->read_subdev); + das1800_ai_cancel(dev, dev->read_subdev); /* initialize digital out channels */ outb(0, dev->iobase + DAS1800_DIGITAL); -- 2.6.
[PATCH v2 35/37] staging: comedi: das1800: clarify the analog input cmd triggers
Clarify the documentation in the comedi driver comment block to better explain the cmd triggert. Add a comment to step 2b of the (*do_cmdtest) to clarify the trigger check. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 36 ++-- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 9153c9b..bfbc2bb 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -39,19 +39,32 @@ * [3] - DMA1 (optional, requires irq and dma0) * * analog input cmd triggers supported: - * start_src:TRIG_NOW | TRIG_EXT - * scan_begin_src: TRIG_FOLLOW | TRIG_TIMER | TRIG_EXT - * scan_end_src: TRIG_COUNT - * convert_src: TRIG_TIMER | TRIG_EXT - * (TRIG_EXT requires scan_begin_src == TRIG_FOLLOW) - * stop_src: TRIG_COUNT | TRIG_EXT | TRIG_NONE * - * scan_begin_src triggers TRIG_TIMER and TRIG_EXT use the card's - * 'burst mode' which limits the valid conversion time to 64 microseconds - * (convert_arg <= 64000). This limitation does not apply if scan_begin_src - * is TRIG_FOLLOW. + * start_src TRIG_NOWcommand starts immediately + * TRIG_EXTcommand starts on external pin TGIN * - * The maximum conversion speeds are not always achievable depending on the + * scan_begin_srcTRIG_FOLLOW paced/external scans start immediately + * TRIG_TIMER burst scans start periodically + * TRIG_EXTburst scans start on external pin XPCLK + * + * scan_end_src TRIG_COUNT scan ends after last channel + * + * convert_src TRIG_TIMER paced/burst conversions are timed + * TRIG_EXTconversions on external pin XPCLK + * (requires scan_begin_src == TRIG_FOLLOW) + * + * stop_src TRIG_COUNT command stops after stop_arg scans + * TRIG_EXTcommand stops on external pin TGIN + * TRIG_NONE command runs until canceled + * + * If TRIG_EXT is used for both the start_src and stop_src, the first TGIN + * trigger starts the command, and the second trigger will stop it. If only + * one is TRIG_EXT, the first trigger will either stop or start the command. + * + * Minimum conversion speed is limited to 64 microseconds (convert_arg <= 64000) + * for 'burst' scans. This limitation does not apply for 'paced' scans. The + * maximum conversion speed is limited by the board (convert_arg >= ai_speed). + * Maximum conversion speeds are not always achievable depending on the * board setup (see user manual). * * NOTES: @@ -653,6 +666,7 @@ static int das1800_ai_cmdtest(struct comedi_device *dev, /* Step 2b : and mutually compatible */ + /* burst scans must use timed conversions */ if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->convert_src != TRIG_TIMER) err |= -EINVAL; -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 01/37] staging: comedi: das1800: tidy up digital output subdevice init
For aesthetics, add some whitespace to the subdevice init and rename the (*insn_bits) function. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 24b33a4..e7787ae3 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1141,10 +1141,10 @@ static int das1800_di_rbits(struct comedi_device *dev, return insn->n; } -static int das1800_do_wbits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int das1800_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { if (comedi_dio_update_state(s, data)) outb(s->state, dev->iobase + DAS1800_DIGITAL); @@ -1396,14 +1396,14 @@ static int das1800_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_bits = das1800_di_rbits; - /* do */ + /* Digital Output subdevice */ s = &dev->subdevices[3]; - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = board->do_n_chan; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = das1800_do_wbits; + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = board->do_n_chan; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits= das1800_do_insn_bits; das1800_cancel(dev, dev->read_subdev); -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 23/37] staging: comedi: das1800: absorb control_a_bits()
Absorb this helper function into the analog input (*do_cmd). For aesthetics, convert the switch code into if/else. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 31 +++ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 4355171..677f430 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -727,28 +727,6 @@ static int das1800_ai_cmdtest(struct comedi_device *dev, return 0; } -/* returns appropriate bits for control register a, depending on command */ -static int control_a_bits(const struct comedi_cmd *cmd) -{ - int control_a; - - control_a = FFEN; /* enable fifo */ - if (cmd->stop_src == TRIG_EXT) - control_a |= ATEN; - switch (cmd->start_src) { - case TRIG_EXT: - control_a |= TGEN | CGSL; - break; - case TRIG_NOW: - control_a |= CGEN; - break; - default: - break; - } - - return control_a; -} - static unsigned char das1800_ai_chanspec_bits(struct comedi_subdevice *s, unsigned int chanspec) { @@ -885,8 +863,13 @@ static int das1800_ai_cmd(struct comedi_device *dev, devpriv->ai_is_unipolar = comedi_range_is_unipolar(s, range0); - /* determine proper bits for control registers */ - control_a = control_a_bits(cmd); + control_a = FFEN; + if (cmd->stop_src == TRIG_EXT) + control_a |= ATEN; + if (cmd->start_src == TRIG_EXT) + control_a |= TGEN | CGSL; + else /* TRIG_NOW */ + control_a |= CGEN; control_c = das1800_ai_chanspec_bits(s, cmd->chanlist[0]); /* set clock source to internal or external */ -- 2.6.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] ion: scatterlist offset not used for buffer map
On 04/07/2016 11:56 PM, John Einar Reitan wrote: On Thu, Apr 07, 2016 at 12:37:50PM -0700, Laura Abbott wrote: On 04/07/2016 04:29 AM, John Einar Reitan wrote: ion's default user/kernel page mapping code don't honor the offset option for scatterlists. It uses sg_page and expect the whole page to be mapped, while the offset could dictate an offset within a large page. sg_phys correctly accounts for the offset, so should be used instead. Can you be more specific about which heap and which allocation pattern is exposing this bug? The heap that exposed the bug is one I'm developing and will be posting as a RFC soon. It uses compound pages and an sub-divides it into surface buffers. The ion buffers are configured to hold sgl's with the compound page and the correct offset of the buffer, via sg_set_page(.., compound_page, .., offset_of_logical_buffer); sg_phys/sg_virt includes this offset, but if you poke the sg and extract the page with sg_page yourself you must include this offset in your calculations too. This patch should be re-sent when you have the RFC for the heap. Unless there is a heap available in tree we don't really need this patch. Thanks, Laura ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[RFC][PATCH] MAINTAINERS: Add Android Ion as a separate entry
The android drivers have a few other people reviewing patches. Add a separate entry to ensure patches go to the right people. Signed-off-by: Laura Abbott --- Sumit and I have been doing review anyway so I think it makes sense for us to be cc-ed on patches in addition to the generic Android maintainers. Anyone else who wants to join in is welcome. --- MAINTAINERS | 9 + 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 40eb1db..c697c6e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -776,6 +776,15 @@ S: Supported F: drivers/android/ F: drivers/staging/android/ +ANDROID ION DRIVER +M: Laura Abbott +M: Sumit Semwal +L: de...@driverdev.osuosl.org +S: Supported +F: drivers/staging/android/ion +F: drivers/staging/android/uapi/ion.h +F: drivers/staging/android/uapi/ion_test.h + AOA (Apple Onboard Audio) ALSA DRIVER M: Johannes Berg L: linuxppc-...@lists.ozlabs.org -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [RFC][PATCH] MAINTAINERS: Add Android Ion as a separate entry
On Fri, Apr 08, 2016 at 04:35:25PM -0700, Laura Abbott wrote: > The android drivers have a few other people reviewing patches. > Add a separate entry to ensure patches go to the right people. > > Signed-off-by: Laura Abbott > --- > Sumit and I have been doing review anyway so I think it makes sense for > us to be cc-ed on patches in addition to the generic Android maintainers. > Anyone else who wants to join in is welcome. Thanks for this, I'll queue it up soon. greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [patch] staging: lowmemorykiller: remove bogus NULL check
Dan Carpenter wrote: > The NULL checking here doesn't make sense, so it causes a static checker > warning. It turns out that p->mm can't be NULL so the inconsistency is > harmless and we should just remove the check. Commit 77ed2c5745d9 ("android,lowmemorykiller: Don't abuse TIF_MEMDIE.") replaced test_tsk_thread_flag(p, TIF_MEMDIE) with task_lmk_waiting(p) && p->mm because TIF_MEMDIE is cleared after p->mm became NULL whereas PFA_LMK_WAITING is not cleared after p->mm became NULL. But p is a thread which is guaranteed to be p->mm != NULL. > > Signed-off-by: Dan Carpenter Acked-by: Tetsuo Handa > > diff --git a/drivers/staging/android/lowmemorykiller.c > b/drivers/staging/android/lowmemorykiller.c > index c79f224..24d2745 100644 > --- a/drivers/staging/android/lowmemorykiller.c > +++ b/drivers/staging/android/lowmemorykiller.c > @@ -131,7 +131,7 @@ static unsigned long lowmem_scan(struct shrinker *s, > struct shrink_control *sc) > if (!p) > continue; > > - if (task_lmk_waiting(p) && p->mm && > + if (task_lmk_waiting(p) && > time_before_eq(jiffies, lowmem_deathpending_timeout)) { > task_unlock(p); > rcu_read_unlock(); > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel