~ubuntu-branches/ubuntu/utopic/hplip/utopic-proposed

« back to all changes in this revision

Viewing changes to scan/sane/hpaio.c

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-01-08 20:10:45 UTC
  • mfrom: (2.1.182 precise)
  • Revision ID: package-import@ubuntu.com-20120108201045-qbh9qngh29dziyot
Tags: 3.11.12-1
* New Upstream Release 
* Fix "Please rename the hplip packages to the printer-driver-
  convention" odyx patch - thks (Closes: #649991)
* Fix "debian/control uses hardcoded list of non-Linux architectures"
  Update Build-Depends: libudev-dev [linux-any] (Closes: #634488)
* Fix "hp-scan scans entire job and then reports inability to produce
  PDFs without reportlab" Added Depends: python-reportlab (Closes: #651240)
* Fix "hplip bug report" python handling correct (Closes: #609680)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
24
  Contributing Authors: David Paschal, Don Welch, David Suffield, Narla Naga Samrat Chowdary, 
25
 
                        Yashwant Sahu 
 
25
                        Yashwant Sahu, Sarbeswar Meher 
26
26
 
27
27
\************************************************************************************/
28
28
 
268
268
      }
269
269
      else
270
270
      {
271
 
         DBG6("unsupported scantype=%d %s\n", ma.scantype, uri);
 
271
         DBG(6,"unsupported scantype=%d %s\n", ma.scantype, uri);
272
272
      }
273
273
   }
274
274
 
285
285
      }
286
286
      else
287
287
      {
288
 
         DBG6("unsupported scantype=%d %s\n", ma.scantype, cups_printer[i]);
 
288
         DBG(6,"unsupported scantype=%d %s\n", ma.scantype, cups_printer[i]);
289
289
      }
290
290
      free(cups_printer[i]);
291
291
   }
315
315
{
316
316
    hpaioScanner_t p = FirstScanner;
317
317
    
318
 
    while( p != LastScanner )
 
318
    while( p != NULL )
319
319
    {
320
320
        if( strcasecmp( name, p->saneDevice.name ) == 0 )
321
321
            return p;
322
322
        
323
 
        p++;
 
323
        p=p->next;
324
324
    }
325
325
    
326
326
    return NULL;
757
757
    SendScanEvent( hpaio->deviceuri, EVENT_END_SCAN_JOB);
758
758
}
759
759
 
 
760
static SANE_Status SetResolutionListSCL(hpaioScanner_t hpaio)
 
761
{
 
762
     int supported_res[] = {50, 75, 100, 150, 200, 300, 600, 1200, 2400, 4800, 9600};
 
763
     int i, len = sizeof(supported_res)/sizeof(int);
 
764
     SANE_Status retcode;
 
765
     
 
766
     if (hpaio->currentAdfMode == ADF_MODE_ADF || hpaio->currentAdfMode == ADF_MODE_AUTO)
 
767
     {
 
768
        hpaio->resolutionRange.min = hpaio->scl.minResAdf;
 
769
        hpaio->resolutionRange.max = hpaio->scl.maxResAdf;
 
770
     }
 
771
     else
 
772
     {
 
773
        hpaio->resolutionRange.min = hpaio->scl.minRes;
 
774
        hpaio->resolutionRange.max = hpaio->scl.maxRes;
 
775
     }
 
776
    
 
777
        DBG(6,"minRes=%d maxRes=%d minResAdf=%d maxResAdf=%d\n", hpaio->scl.minRes, hpaio->scl.maxRes, hpaio->scl.minResAdf, hpaio->scl.maxResAdf);
 
778
 
 
779
        NumListClear( hpaio->resolutionList );
 
780
        NumListClear( hpaio->lineartResolutionList );
 
781
        for (i = 0; i < len; i++)
 
782
        {
 
783
          if (supported_res[i] >= hpaio->resolutionRange.min &&
 
784
          supported_res[i] <= hpaio->resolutionRange.max)
 
785
                  {
 
786
                          NumListAdd (hpaio->resolutionList, supported_res[i]);
 
787
                          NumListAdd (hpaio->lineartResolutionList, supported_res[i]);
 
788
                  }
 
789
        }
 
790
        hpaio->option[OPTION_SCAN_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST;
 
791
        
 
792
        return SANE_STATUS_GOOD;
 
793
}
 
794
 
760
795
static SANE_Status hpaioSetDefaultValue( hpaioScanner_t hpaio, int option )
761
796
{
762
797
    switch( option )
919
954
    {
920
955
        reload |= SANE_INFO_RELOAD_PARAMS;
921
956
    }
922
 
 
 
957
    
 
958
    if (hpaio->scannerType == SCANNER_TYPE_SCL)
 
959
            SetResolutionListSCL(hpaio);
923
960
    /* OPTION_SCAN_RESOLUTION: */
924
961
    if( hpaio->option[OPTION_SCAN_RESOLUTION].constraint_type ==
925
962
        SANE_CONSTRAINT_WORD_LIST )
1622
1659
    struct hpmud_model_attributes ma;
1623
1660
    SANE_Status retcode = SANE_STATUS_INVAL;
1624
1661
    hpaioScanner_t hpaio = 0;
1625
 
    int r, bytes_read;
 
1662
    int bytes_read;
1626
1663
    char deviceIDString[LEN_DEVICE_ID_STRING];
1627
1664
    char model[256];
1628
1665
    int forceJpegForGrayAndColor = 0;
1941
1978
        /* Determine the minimum and maximum resolution.
1942
1979
                  * Probe for both X and Y, and pick largest min and smallest max.
1943
1980
                 * For the 1150, set min to 50 to prevent scan head crashes (<42). */
1944
 
        SclInquire( hpaio->deviceid, hpaio->scan_channelid,
1945
 
                    SCL_CMD_INQUIRE_MINIMUM_VALUE,
1946
 
                    SCL_CMD_SET_X_RESOLUTION,
1947
 
                    &hpaio->scl.minXRes,
1948
 
                    0,
1949
 
                    0 );
1950
 
 
1951
 
        DBG6("min x resolution=%d\n", hpaio->scl.minXRes);
1952
 
        
1953
 
        SclInquire( hpaio->deviceid, hpaio->scan_channelid,
1954
 
                    SCL_CMD_INQUIRE_MINIMUM_VALUE,
1955
 
                    SCL_CMD_SET_Y_RESOLUTION,
1956
 
                    &hpaio->scl.minYRes,
1957
 
                    0,
1958
 
                    0 );
1959
 
 
1960
 
        DBG6("min y resolution=%d\n", hpaio->scl.minYRes);
 
1981
        int minXRes, minYRes, maxXRes, maxYRes;
 
1982
        retcode = SclInquire( hpaio->deviceid, hpaio->scan_channelid,
 
1983
                    SCL_CMD_INQUIRE_MINIMUM_VALUE,
 
1984
                    SCL_CMD_SET_X_RESOLUTION,
 
1985
                    &minXRes,
 
1986
                    0,
 
1987
                    0 );
 
1988
 
 
1989
        DBG(6, "minXRes=%d retcode=%d\n",minXRes, retcode);
 
1990
        
 
1991
        retcode = SclInquire( hpaio->deviceid, hpaio->scan_channelid,
 
1992
                    SCL_CMD_INQUIRE_MINIMUM_VALUE,
 
1993
                    SCL_CMD_SET_Y_RESOLUTION,
 
1994
                    &minYRes,
 
1995
                    0,
 
1996
                    0 );
 
1997
 
 
1998
        DBG(6,"minYRes=%d retcode=%d\n", minYRes, retcode);
 
1999
        
 
2000
        retcode = SclInquire( hpaio->deviceid, hpaio->scan_channelid,
 
2001
                    SCL_CMD_INQUIRE_MAXIMUM_VALUE,
 
2002
                    SCL_CMD_SET_X_RESOLUTION,
 
2003
                    &maxXRes,
 
2004
                    0,
 
2005
                    0 );
 
2006
 
 
2007
        DBG(6,"maxXRes=%d retcode=%d\n", maxXRes, retcode);
 
2008
        
 
2009
        retcode = SclInquire( hpaio->deviceid, hpaio->scan_channelid,
 
2010
                    SCL_CMD_INQUIRE_MAXIMUM_VALUE,
 
2011
                    SCL_CMD_SET_Y_RESOLUTION,
 
2012
                    &maxYRes,
 
2013
                    0,
 
2014
                   0 );
 
2015
 
 
2016
        DBG(6,"maxYRes=%d retcode=%d\n", maxYRes, retcode);
1961
2017
        
1962
2018
        if( hpaio->scl.compat & SCL_COMPAT_1150 &&
1963
 
            hpaio->scl.minYRes < SCL_MIN_Y_RES_1150 )
1964
 
        {
1965
 
            hpaio->scl.minYRes = SCL_MIN_Y_RES_1150;
1966
 
        }
1967
 
        r = hpaio->scl.minXRes;
1968
 
        if( r < hpaio->scl.minYRes )
1969
 
        {
1970
 
            r = hpaio->scl.minYRes;
1971
 
        }
1972
 
        
1973
 
        hpaio->resolutionRange.min = r;
1974
 
        
1975
 
        SclInquire( hpaio->deviceid, hpaio->scan_channelid,
1976
 
                    SCL_CMD_INQUIRE_MAXIMUM_VALUE,
1977
 
                    SCL_CMD_SET_X_RESOLUTION,
1978
 
                    &hpaio->scl.maxXRes,
1979
 
                    0,
1980
 
                    0 );
1981
 
 
1982
 
        DBG6("max x resolution=%d\n", hpaio->scl.maxXRes);
1983
 
        
1984
 
        SclInquire( hpaio->deviceid, hpaio->scan_channelid,
1985
 
                    SCL_CMD_INQUIRE_MAXIMUM_VALUE,
1986
 
                    SCL_CMD_SET_Y_RESOLUTION,
1987
 
                    &hpaio->scl.maxYRes,
1988
 
                    0,
1989
 
                   0 );
1990
 
 
1991
 
        DBG6("max y resolution=%d\n", hpaio->scl.maxYRes);
1992
 
        
1993
 
        r = hpaio->scl.maxXRes;
1994
 
        
1995
 
        if( r > hpaio->scl.maxYRes )
1996
 
        {
1997
 
            r = hpaio->scl.maxYRes;
1998
 
        }
1999
 
        
2000
 
        if( hpaio->scl.compat & ( SCL_COMPAT_1150 | SCL_COMPAT_1170 ) && r > SCL_MAX_RES_1150_1170 )
2001
 
        {
2002
 
            r = SCL_MAX_RES_1150_1170;
2003
 
        }
2004
 
        hpaio->resolutionRange.max = r;
2005
 
 
 
2019
            minYRes < SCL_MIN_Y_RES_1150 )
 
2020
        {
 
2021
            minYRes = SCL_MIN_Y_RES_1150;
 
2022
        }
 
2023
        hpaio->scl.minRes = minXRes;
 
2024
        if( hpaio->scl.minRes < minYRes )
 
2025
        {
 
2026
            hpaio->scl.minRes = minYRes;
 
2027
        }
 
2028
        
 
2029
        hpaio->resolutionRange.min = hpaio->scl.minRes;
 
2030
        
 
2031
        hpaio->scl.maxRes = maxXRes;
 
2032
        
 
2033
        if( hpaio->scl.maxRes > maxYRes )
 
2034
        {
 
2035
            hpaio->scl.maxRes = maxYRes;
 
2036
        }
 
2037
        
 
2038
        if( hpaio->scl.compat & ( SCL_COMPAT_1150 | SCL_COMPAT_1170 ) 
 
2039
            && hpaio->scl.maxRes > SCL_MAX_RES_1150_1170 )
 
2040
        {
 
2041
            hpaio->scl.maxRes = SCL_MAX_RES_1150_1170;
 
2042
        }
 
2043
        hpaio->resolutionRange.max = hpaio->scl.maxRes;
 
2044
                         
2006
2045
        /* Determine ADF/duplex capabilities. */
2007
2046
        {
2008
 
            int flatbedCapability = 1;
2009
 
            
2010
 
            SclInquire( hpaio->deviceid, hpaio->scan_channelid,
2011
 
                        SCL_CMD_INQUIRE_MAXIMUM_VALUE,
2012
 
                        SCL_PSEUDO_FLATBED_Y_RESOLUTION,
2013
 
                        &flatbedCapability,
2014
 
                        0,
2015
 
                        0 );
2016
 
                        
2017
 
            SclInquire( hpaio->deviceid, hpaio->scan_channelid,
 
2047
            retcode = SclInquire( hpaio->deviceid, hpaio->scan_channelid,
2018
2048
                        SCL_CMD_INQUIRE_DEVICE_PARAMETER,
2019
2049
                        SCL_INQ_ADF_CAPABILITY,
2020
2050
                        &hpaio->scl.adfCapability,
2021
2051
                        0,
2022
2052
                        0 );
2023
2053
            
2024
 
            DBG(6, "ADF capability=%d: %s %d\n", hpaio->scl.adfCapability, __FILE__, __LINE__);
 
2054
            DBG(6, "ADF capability=%d retcode=%d: %s %d\n", hpaio->scl.adfCapability, retcode,__FILE__, __LINE__);
2025
2055
            
 
2056
            if (hpaio->scl.adfCapability)
 
2057
            {
 
2058
                      retcode = SclInquire( hpaio->deviceid, hpaio->scan_channelid,
 
2059
                                SCL_CMD_INQUIRE_MINIMUM_VALUE,
 
2060
                                SCL_PSEUDO_ADF_X_RESOLUTION,
 
2061
                                &minXRes,
 
2062
                                0,
 
2063
                                0 );
 
2064
                      DBG(6, "minXResAdf=%d retcode=%d\n", minXRes, retcode);
 
2065
                      retcode = SclInquire( hpaio->deviceid, hpaio->scan_channelid,
 
2066
                                SCL_CMD_INQUIRE_MINIMUM_VALUE,
 
2067
                                SCL_PSEUDO_ADF_Y_RESOLUTION,
 
2068
                                &minYRes,
 
2069
                                0,
 
2070
                                0 );
 
2071
                      DBG(6, "minYResAdf=%d retcode=%d\n", minYRes, retcode);
 
2072
                      retcode = SclInquire( hpaio->deviceid, hpaio->scan_channelid,
 
2073
                                SCL_CMD_INQUIRE_MAXIMUM_VALUE,
 
2074
                                SCL_PSEUDO_ADF_X_RESOLUTION,
 
2075
                                &maxXRes,
 
2076
                                0,
 
2077
                                0 );
 
2078
                      DBG(6, "maxXResAdf=%d retcode=%d\n", maxXRes, retcode);
 
2079
                      retcode = SclInquire( hpaio->deviceid, hpaio->scan_channelid,
 
2080
                                SCL_CMD_INQUIRE_MAXIMUM_VALUE,
 
2081
                                SCL_PSEUDO_ADF_Y_RESOLUTION,
 
2082
                                &maxYRes,
 
2083
                                0,
 
2084
                               0 );
 
2085
                               DBG(6, "maxYResAdf=%d retcode=%d\n", maxYRes, retcode);
 
2086
                               if( hpaio->scl.compat & SCL_COMPAT_1150 &&
 
2087
                                        minYRes < SCL_MIN_Y_RES_1150 )
 
2088
                                {
 
2089
                                        minYRes = SCL_MIN_Y_RES_1150;
 
2090
                                }
 
2091
                                hpaio->scl.minResAdf = minXRes;
 
2092
                                if( hpaio->scl.minResAdf < minYRes )
 
2093
                                {
 
2094
                                        hpaio->scl.minResAdf = minYRes;
 
2095
                                }
 
2096
                                
 
2097
                                hpaio->scl.maxResAdf = maxXRes;
 
2098
                                
 
2099
                                if( hpaio->scl.maxResAdf > maxYRes )
 
2100
                                {
 
2101
                                        hpaio->scl.maxResAdf = maxYRes;
 
2102
                                }
 
2103
                        
 
2104
                                if( hpaio->scl.compat & ( SCL_COMPAT_1150 | SCL_COMPAT_1170 ) 
 
2105
                                && hpaio->scl.maxResAdf > SCL_MAX_RES_1150_1170 )
 
2106
                                {
 
2107
                                        hpaio->scl.maxResAdf = SCL_MAX_RES_1150_1170;
 
2108
                                }
 
2109
 
 
2110
            }
2026
2111
            if( !hpaio->scl.adfCapability )
2027
2112
            {
2028
2113
                hpaio->supportedAdfModes = ADF_MODE_FLATBED;
2029
2114
            }
2030
 
            else if( hpaio->scl.compat & SCL_COMPAT_K_SERIES ||
2031
 
                     !flatbedCapability )
 
2115
            else if( hpaio->scl.compat & SCL_COMPAT_K_SERIES &&
 
2116
                     hpaio->scl.adfCapability )
2032
2117
            {
2033
 
                hpaio->supportedAdfModes = ADF_MODE_ADF;
 
2118
                hpaio->supportedAdfModes = ADF_MODE_FLATBED | ADF_MODE_ADF;
2034
2119
            }
2035
2120
            else
2036
2121
            {