~ubuntu-branches/ubuntu/raring/hplip/raring

« back to all changes in this revision

Viewing changes to scan/sane/marvell.c

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-10-06 15:03:44 UTC
  • mfrom: (1.6.1) (20.1.16 quantal)
  • Revision ID: package-import@ubuntu.com-20121006150344-2p3xz26br0t3hu2q
Tags: 3.12.10-1
* New upstream release
  - Fixes "Network scanning fails (Closes: #683033)
* quilt refresh hplip-syslog-fix-debug-messages-to-error.dpatch
* Fix "error in clean build env" updated debian/rules (Closes: #687129)

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
   /* Load hpmud manually with symbols exported. Otherwise the plugin will not find it. */ 
64
64
   if ((ps->hpmud_handle = dlopen("libhpmud.so", RTLD_LAZY|RTLD_GLOBAL)) == NULL)
65
65
   {
66
 
      BUG("unable to load restricted library: %s\n", dlerror());
67
 
      goto bugout;
 
66
      if ((ps->hpmud_handle = dlopen("libhpmud.so.0", RTLD_LAZY|RTLD_GLOBAL)) == NULL)
 
67
      {
 
68
         BUG("unable to load restricted library: %s\n", dlerror());
 
69
         goto bugout;
 
70
      }
68
71
   } 
69
72
 
70
73
   /* Load math library manually with symbols exported (Ubuntu 8.04). Otherwise the plugin will not find it. */ 
365
368
   return ps;
366
369
}
367
370
 
 
371
static void set_supported_resolutions(struct marvell_session *ps)
 
372
{
 
373
    int i;
 
374
    if(ps->scansrc & HPMUD_SCANSRC_ADF)
 
375
    {
 
376
       i = 0;
 
377
       ps->adf_resolution_list[i++] = 5; /*Number of supported resolutions*/
 
378
       ps->adf_resolution_list[i++] = 75;
 
379
       ps->adf_resolution_list[i++] = 100;
 
380
       ps->adf_resolution_list[i++] = 150;
 
381
       ps->adf_resolution_list[i++] = 200;
 
382
       ps->adf_resolution_list[i++] = 300;
 
383
    }
 
384
    if(ps->scansrc & HPMUD_SCANSRC_FLATBED)
 
385
    {
 
386
       i = 0;
 
387
       ps->platen_resolution_list[i++] = 7; /*Number of supported resolutions*/
 
388
       ps->platen_resolution_list[i++] = 75;
 
389
       ps->platen_resolution_list[i++] = 100;
 
390
       ps->platen_resolution_list[i++] = 150;
 
391
       ps->platen_resolution_list[i++] = 200;
 
392
       ps->platen_resolution_list[i++] = 300;
 
393
       ps->platen_resolution_list[i++] = 600;
 
394
       ps->platen_resolution_list[i++] = 1200;
 
395
    }
 
396
 
 
397
    if(ps->scansrc & HPMUD_SCANSRC_FLATBED)
 
398
    {
 
399
        ps->resolution_list[0] = ps->platen_resolution_list[0];
 
400
        i = ps->platen_resolution_list[0] + 1;
 
401
        while(i--)
 
402
        {
 
403
            ps->resolution_list[i] = ps->platen_resolution_list[i];
 
404
        }
 
405
    }
 
406
    else 
 
407
    {
 
408
        ps->resolution_list[0] = ps->adf_resolution_list[0];
 
409
        i = ps->adf_resolution_list[0] + 1;
 
410
        while(i--)
 
411
        {
 
412
            ps->resolution_list[i] = ps->adf_resolution_list[i];
 
413
        }
 
414
        
 
415
    }
 
416
}
368
417
/*
369
418
 * SANE APIs.
370
419
 */
397
446
   switch (ma.scantype)
398
447
   {
399
448
      case HPMUD_SCANTYPE_MARVELL:
400
 
         session->version = MARVELL_1;           
 
449
         session->version = MARVELL_1;
401
450
                 break;
402
451
          case HPMUD_SCANTYPE_MARVELL2:
403
 
         session->version = MARVELL_2;          
 
452
         session->version = MARVELL_2;
404
453
                 break;
405
454
          default:
406
455
         session->version = MARVELL_1;
453
502
   i=0;
454
503
   /* Some of the marvell devices supports both flatbed and ADF, No command to get the src types supported */
455
504
   /* Getting from the model file */
456
 
   if ( session->scansrc == HPMUD_SCANSRC_BOTH)
457
 
   {
458
 
         session->input_source_list[i] = STR_ADF_MODE_ADF;
459
 
         session->input_source_map[i++] = IS_ADF;
460
 
         session->input_source_list[i] = STR_ADF_MODE_FLATBED;
461
 
         session->input_source_map[i++] = IS_PLATEN;               
462
 
         DBG8("scan src  HPMUD_SCANSRC_BOTH \n"); 
463
 
   }
464
 
   else if ( session->scansrc == HPMUD_SCANSRC_ADF)
 
505
   if ( session->scansrc & HPMUD_SCANSRC_ADF)
465
506
   {
466
507
         session->input_source_list[i] = STR_ADF_MODE_ADF;
467
508
         session->input_source_map[i++] = IS_ADF;
468
509
         DBG8("scan src  HPMUD_SCANSRC_ADF \n"); 
469
510
   }
470
 
   else if ( session->scansrc == HPMUD_SCANSRC_FLATBED)
 
511
   if ( session->scansrc & HPMUD_SCANSRC_FLATBED)
471
512
   {
472
513
         session->input_source_list[i] = STR_ADF_MODE_FLATBED;
473
 
         session->input_source_map[i++] = IS_PLATEN;               
474
 
         DBG8("scan src  HPMUD_SCANSRC_FLATBED \n"); 
 
514
         session->input_source_map[i++] = IS_PLATEN;
 
515
         DBG8("scan src  HPMUD_SCANSRC_FLATBED \n");
475
516
    }
476
517
    /* Values if un specified in the, value is 0,  get ADF state from the printer */   
477
 
   else if (session->bb_is_paper_in_adf(session) == 2) 
478
 
   {
479
 
      session->input_source_list[i] = STR_ADF_MODE_FLATBED;
480
 
      session->input_source_map[i++] = IS_PLATEN;
481
 
      DBG8("scan src  b_is_paper_in_adf value  2 \n");       
482
 
   }
483
 
   else
484
 
   {
485
 
      session->input_source_list[i] = STR_ADF_MODE_ADF;
486
 
      session->input_source_map[i++] = IS_ADF;
487
 
      DBG8("scan src  b_is_paper_in_adf value not 2 \n");             
488
 
   }
 
518
   if (session->scansrc == HPMUD_SCANSRC_NA)
 
519
   {
 
520
     if (session->bb_is_paper_in_adf(session) == 2) 
 
521
     {
 
522
       session->input_source_list[i] = STR_ADF_MODE_FLATBED;
 
523
       session->input_source_map[i++] = IS_PLATEN;
 
524
       DBG8("scan src  b_is_paper_in_adf value  2 \n");
 
525
     }
 
526
     else
 
527
     {
 
528
       session->input_source_list[i] = STR_ADF_MODE_ADF;
 
529
       session->input_source_map[i++] = IS_ADF;
 
530
       DBG8("scan src  b_is_paper_in_adf value not 2 \n");
 
531
     }
 
532
    }
489
533
 
490
 
      
491
534
   marvell_control_option(session, MARVELL_OPTION_INPUT_SOURCE, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */  
492
535
 
493
536
   /* Set supported resolutions. */
494
 
   i=1;
495
 
   session->resolution_list[i++] = 75;
496
 
   session->resolution_list[i++] = 100;
497
 
   session->resolution_list[i++] = 150;
498
 
   session->resolution_list[i++] = 200;
499
 
   session->resolution_list[i++] = 300;
500
 
   session->resolution_list[i++] = 600;
501
 
   session->resolution_list[i++] = 1200;
502
 
   session->resolution_list[0] = i-1;    /* length of word_list */
 
537
   set_supported_resolutions(session);
503
538
   marvell_control_option(session, MARVELL_OPTION_SCAN_RESOLUTION, SANE_ACTION_SET_AUTO, NULL, NULL); /* set default option */
504
539
 
505
540
   /* Set supported contrast. */
641
676
               {
642
677
                  ps->current_input_source = ps->input_source_map[i];
643
678
                  stat = SANE_STATUS_GOOD;
 
679
                  if(ps->current_input_source == IS_PLATEN) 
 
680
                  {
 
681
                    i = ps->platen_resolution_list[0] + 1;
 
682
                    while(i--) ps->resolution_list[i] = ps->platen_resolution_list[i];
 
683
                  }
 
684
                  else
 
685
                  {
 
686
                     i = ps->adf_resolution_list[0] + 1;
 
687
                     while(i--) ps->resolution_list[i] = ps->adf_resolution_list[i];
 
688
                  }
 
689
                  ps->current_resolution = ps->resolution_list[1];
 
690
                  mset_result |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS;
 
691
                  stat = SANE_STATUS_GOOD;
644
692
                  break;
645
693
               }
646
694
            }
648
696
         else
649
697
         {  /* Set default. */
650
698
            ps->current_input_source = ps->input_source_map[0];
 
699
            mset_result |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS;
651
700
            stat = SANE_STATUS_GOOD;
652
701
         }
653
702
         break;
669
718
                  break;
670
719
               }
671
720
            }
 
721
            if (stat != SANE_STATUS_GOOD)
 
722
            {
 
723
                ps->current_resolution = ps->resolution_list[1];
 
724
                stat = SANE_STATUS_GOOD;
 
725
            }
672
726
         }
673
727
         else
674
728
         {  /* Set default. */
687
741
            if (*int_value >= MARVELL_CONTRAST_MIN && *int_value <= MARVELL_CONTRAST_MAX)
688
742
            {
689
743
               ps->current_contrast = *int_value;
 
744
               mset_result |= SANE_INFO_RELOAD_PARAMS;
690
745
               stat = SANE_STATUS_GOOD;
691
746
               break;
692
747
            }
831
886
//   int tmo=EXCEPTION_TIMEOUT*2;
832
887
 
833
888
   DBG8("sane_hpaio_start()\n");
834
 
 
 
889
   ps->is_user_cancel = 0;
 
890
   
835
891
   if (set_extents(ps))
836
892
   {
837
893
      BUG("invalid extents: tlx=%d brx=%d tly=%d bry=%d minwidth=%d minheight%d maxwidth=%d maxheight=%d\n",
847
903
      if (ret == 0)
848
904
      {
849
905
         stat = SANE_STATUS_NO_DOCS;     /* done scanning */
 
906
         SendScanEvent(ps->uri, EVENT_SCAN_ADF_NO_DOCS);
850
907
         goto bugout;
851
908
      }
852
909
      else if (ret < 0)
862
919
      goto bugout;
863
920
   }
864
921
 
 
922
   SendScanEvent(ps->uri, EVENT_START_SCAN_JOB);
865
923
   memset(xforms, 0, sizeof(xforms));    
866
924
 
867
925
   /* Setup image-processing pipeline for xform. */
955
1013
   }
956
1014
 
957
1015
   if (ret & IP_DONE)
 
1016
   {
958
1017
      stat = SANE_STATUS_EOF;
 
1018
      SendScanEvent(ps->uri, EVENT_END_SCAN_JOB);
 
1019
   }
959
1020
   else
960
1021
      stat = SANE_STATUS_GOOD;
961
1022
 
968
1029
         ipClose(ps->ip_handle);  
969
1030
         ps->ip_handle = 0;
970
1031
      } 
971
 
      ps->bb_end_page(ps, stat == SANE_STATUS_IO_ERROR ? 1: 0);
 
1032
       //If user has cancelled scan from device
 
1033
      if (ps->is_user_cancel)
 
1034
      {
 
1035
          //Don't do anything. sane_hpaio_cancel() will be invoked automatically
 
1036
          SendScanEvent(ps->uri, EVENT_SCAN_CANCEL);
 
1037
          return SANE_STATUS_CANCELLED;
 
1038
 
 
1039
       }
 
1040
       else 
 
1041
           {
 
1042
               ps->bb_end_page(ps, stat == SANE_STATUS_IO_ERROR ? 1: 0);
 
1043
           }
972
1044
   }
973
1045
 
974
1046
   DBG8("-sane_hpaio_read() output=%p bytes_read=%d maxLength=%d status=%d\n", data, *length, maxLength, stat);
986
1058
    * Sane_cancel is always called at the end of the scan job. Note that on a multiple page scan job 
987
1059
    * sane_cancel is called only once.
988
1060
    */
989
 
 
 
1061
   ps->is_user_cancel = 1 ;
 
1062
   
990
1063
   if (ps->ip_handle)
991
1064
   {
992
1065
      ipClose(ps->ip_handle);