[sane-devel] [PATCH] canon_dr: Add support for batch count

Olaf Meeuwissen paddy-hack at member.fsf.org
Sat Aug 12 04:28:48 UTC 2017


Hi Vadim,

Thanks for the patch.

@Allan> Since you're listed as the canon_dr backend's author, can you
        take a look at this?

Vadim V. Vlasov writes:

> The patch adds support for batch count by introducing "--batchMode=XX"
> parameter. This works at least with Canon DR-G1100 but may also
> work with other scanners. At least it should not break current
> behaviour (as long as you do not use "--batchMode=XX").
> Note, what you call "SSM2_BUFF_sync" is, probably, page count
> rather than "sync (unbuffered) mode".
>
> diff -rup a/backend/canon_dr.c b/backend/canon_dr.c
> --- a/backend/canon_dr.c        2017-08-09 18:50:33.725500231 +0300
> +++ b/backend/canon_dr.c        2017-08-09 19:16:42.073500044 +0300
> @@ -830,6 +830,7 @@ attach_one (const char *device_name, int
>     s->padded_read = global_padded_read;
>     s->extra_status = global_extra_status;
>     s->duplex_offset = global_duplex_offset;
> +  s->batchmode = 1;
>
>     /* copy the device name */
>     strcpy (s->device_name, device_name);
> @@ -2540,6 +2541,18 @@ sane_get_option_descriptor (SANE_Handle
>        opt->cap = SANE_CAP_INACTIVE;
>     }
>
> +  /*batch count*/
> +  if(option==OPT_BATCHMODE){
> +    opt->name = "batchMode";
> +    opt->title = "Batch count";
> +    opt->desc = "Request scanner to batch-scan N pages";
> +    opt->type = SANE_TYPE_INT;
> +    if (s->has_buffer)
> +     opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT |
> SANE_CAP_ADVANCED;
> +    else
> +     opt->cap = SANE_CAP_INACTIVE;
> +  }
> +
>     if(option==OPT_SIDE){
>       opt->name = "side";
>       opt->title = "Duplex side";
> @@ -2914,6 +2927,10 @@ sane_control_option (SANE_Handle handle,
>             *val_p = s->buffermode;
>             return SANE_STATUS_GOOD;
>
> +        case OPT_BATCHMODE:
> +          *val_p = s->batchmode;
> +          return SANE_STATUS_GOOD;
> +
>           case OPT_SIDE:
>             *val_p = s->side;
>             return SANE_STATUS_GOOD;
> @@ -3235,6 +3252,13 @@ sane_control_option (SANE_Handle handle,
>
>           case OPT_BUFFERMODE:
>             s->buffermode = val_c;
> +          s->batchmode = !s->buffermode;
> +          return SANE_STATUS_GOOD;
> +
> +        case OPT_BATCHMODE:
> +          s->batchmode = val_c;
> +          if (val_c != 1)
> +            s->buffermode = 1;
>             return SANE_STATUS_GOOD;
>
>         }
> @@ -3313,7 +3337,7 @@ ssm_buffer (struct scanner *s)
>       memset(out,0,outLen);
>       set_SSM2_BUFF_unk(out, !s->buffermode);
>       set_SSM2_BUFF_unk2(out, 0x40);
> -    set_SSM2_BUFF_sync(out, !s->buffermode);
> +    set_SSM2_BUFF_sync(out, s->batchmode);
>
>       ret = do_cmd (
>           s, 1, 0,
> diff -rup a/backend/canon_dr.h b/backend/canon_dr.h
> --- a/backend/canon_dr.h        2017-08-09 18:50:33.725500231 +0300
> +++ b/backend/canon_dr.h        2017-08-09 18:51:07.021500227 +0300
> @@ -48,6 +48,7 @@ enum scanner_Option
>     OPT_DROPOUT_COLOR_F,
>     OPT_DROPOUT_COLOR_B,
>     OPT_BUFFERMODE,
> +  OPT_BATCHMODE,
>     OPT_SIDE,
>
>     /*sensor group*/
> @@ -280,6 +281,7 @@ struct scanner
>     int df_thickness;
>     int dropout_color[2];
>     int buffermode;
> +  int batchmode;
>     int rollerdeskew;
>     int swdeskew;
>     int swdespeck;

--
Sent with my mu4e



More information about the sane-devel mailing list