~ubuntu-branches/ubuntu/wily/hplip/wily-proposed

« back to all changes in this revision

Viewing changes to debian/patches/hpscan-deskjet-3520-aio-allow-non-jpeg-scanning.patch

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2015-03-02 17:48:00 UTC
  • Revision ID: package-import@ubuntu.com-20150302174800-lp4owtk0ndpfkpre
Tags: 3.15.2-0ubuntu3
debian/patches/hpscan-deskjet-3520-aio-allow-non-jpeg-scanning.patch:
Allow non-JPEG scanning on the HP DeskJet 3520 All-in-One and similar
devices. Thanks to Lubos Dolezel for the patch (LP: #1245578).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- a/scan/sane/bb_ledm.c
 
2
+++ b/scan/sane/bb_ledm.c
 
3
@@ -189,7 +189,7 @@
 
4
 <YStart>%d</YStart>\
 
5
 <Height>%d</Height>\
 
6
 <Format>%s</Format>\
 
7
-<CompressionQFactor>15</CompressionQFactor>\
 
8
+<CompressionQFactor>0</CompressionQFactor>\
 
9
 <ColorSpace>%s</ColorSpace>\
 
10
 <BitDepth>%d</BitDepth>\
 
11
 <InputSource>%s</InputSource>\
 
12
@@ -234,6 +234,38 @@
 
13
 # define JOBSTATE_COMPLETED "<j:JobState>Completed</j:JobState>"
 
14
 # define PRESCANPAGE "<PreScanPage>"
 
15
 
 
16
+static int parse_status_elements(const char *payload, int size, struct wscn_create_scan_job_response *resp)
 
17
+{
 
18
+  char tag[512];
 
19
+  char value[128];
 
20
+  char *tail=(char *)payload;
 
21
+
 
22
+  while (1)
 
23
+  {
 
24
+    get_tag(tail, size-(tail-payload), tag, sizeof(tag), &tail);
 
25
+
 
26
+    if (!tag[0])
 
27
+      break;
 
28
+
 
29
+    if (strncmp(tag, "ImageWidth", 10) == 0)
 
30
+    {
 
31
+      get_element(tail, size-(tail-payload), value, sizeof(value), &tail);
 
32
+      resp->pixels_per_line = strtol(value, NULL, 10);
 
33
+    }
 
34
+    else if (strncmp(tag, "ImageHeight", 11) == 0)
 
35
+    {
 
36
+      get_element(tail, size-(tail-payload), value, sizeof(value), &tail);
 
37
+      resp->lines = strtol(value, NULL, 10);
 
38
+    }
 
39
+    else if (strncmp(tag, "BytesPerLine", 12) == 0)
 
40
+    {
 
41
+      get_element(tail, size-(tail-payload), value, sizeof(value), &tail);
 
42
+      resp->bytes_per_line = strtol(value, NULL, 10);
 
43
+    }
 
44
+  }
 
45
+  return 0;
 
46
+}
 
47
+
 
48
 static int parse_scan_elements(const char *payload, int size, struct wscn_scan_elements *elements)
 
49
 {
 
50
   char tag[512];
 
51
@@ -762,8 +794,7 @@
 
52
       if (ps->currentCompression == SF_RAW && ps->currentScanMode != CE_GRAY8)
 
53
       {
 
54
          /* Set scan parameters based on scan job response values */
 
55
-        //pp->lines = pbb->job.lines;
 
56
-        pp->lines = (int)(SANE_UNFIX(ps->effectiveBry - ps->effectiveTly)/MM_PER_INCH*ps->currentResolution);
 
57
+        pp->lines = pbb->job.lines;
 
58
         pp->pixels_per_line = pbb->job.pixels_per_line;
 
59
         pp->bytes_per_line = pbb->job.bytes_per_line;
 
60
       }
 
61
@@ -784,8 +815,8 @@
 
62
       break;
 
63
     case SPO_BEST_GUESS:  /* called by xsane & sane_start */
 
64
       /* Set scan parameters based on best guess. */
 
65
-      pp->lines = (int)round(SANE_UNFIX(ps->effectiveBry - ps->effectiveTly)/MM_PER_INCH*ps->currentResolution);
 
66
-      pp->pixels_per_line = (int)round(SANE_UNFIX(ps->effectiveBrx -ps->effectiveTlx)/MM_PER_INCH*ps->currentResolution);
 
67
+      pp->lines = (int)(SANE_UNFIX(ps->effectiveBry - ps->effectiveTly)/MM_PER_INCH*ps->currentResolution);
 
68
+      pp->pixels_per_line = ps->image_traits.iPixelsPerRow;
 
69
       pp->bytes_per_line = BYTES_PER_LINE(pp->pixels_per_line, pp->depth * factor);
 
70
       break;
 
71
     default:
 
72
@@ -889,7 +920,7 @@
 
73
         (int) ((ps->currentBrx / 5548.7133) - (ps->currentTlx / 5548.7133)),//<Width>
 
74
         (int) (ps->currentTly / 5548.7133),//<YStart>
 
75
         (int) ((ps->currentBry / 5548.7133) - (ps->currentTly / 5548.7133)),//<Height>
 
76
-        "Jpeg",//<Format>
 
77
+        (ps->currentCompression == SF_RAW) ? "Raw" : "Jpeg", //<Format>
 
78
         (! strcmp(ce_element[ps->currentScanMode], "Color8")) ? "Color" : (! strcmp(ce_element[ps->currentScanMode], "Gray8")) ? "Gray" : "Gray",//<ColorSpace>
 
79
         ((! strcmp(ce_element[ps->currentScanMode], "Color8")) || (! strcmp(ce_element[ps->currentScanMode], "Gray8"))) ? 8: 8,//<BitDepth>
 
80
         ps->currentInputSource == IS_PLATEN ? is_element[1] : is_element[2],//<InputSource>
 
81
@@ -987,6 +1018,7 @@
 
82
         _DBG("bb_start_scan() read_http_payload FAILED len=%d buf=%s\n", len, buf);
 
83
         break;
 
84
      }
 
85
+
 
86
       //For a new scan, buf must contain <PreScanPage>. 
 
87
      if (NULL == strstr(buf,PRESCANPAGE)) 
 
88
      {         //i.e Paper is not present in Scanner
 
89
@@ -1005,6 +1037,9 @@
 
90
         stat = SANE_STATUS_GOOD;
 
91
         goto bugout;
 
92
      }
 
93
+        // Parse buf here
 
94
+     parse_status_elements(buf, len, &pbb->job);
 
95
+
 
96
      usleep(500000);//0.5 sec delay
 
97
   }//end while()
 
98
 
 
99
--- a/scan/sane/ledm.c
 
100
+++ b/scan/sane/ledm.c
 
101
@@ -170,11 +170,11 @@
 
102
       case CE_GRAY8:
 
103
       case CE_COLOR8:
 
104
       default:
 
105
-//         ps->compressionList[j] = STR_COMPRESSION_NONE;
 
106
-//         ps->compressionMap[j++] = SF_RAW;
 
107
+         ps->compressionList[j] = STR_COMPRESSION_NONE;
 
108
+         ps->compressionMap[j++] = SF_RAW;
 
109
          ps->compressionList[j] = STR_COMPRESSION_JPEG;
 
110
          ps->compressionMap[j++] = SF_JPEG;
 
111
-         ps->currentCompression = SF_JPEG;
 
112
+         ps->currentCompression = SF_RAW;
 
113
          ps->option[LEDM_OPTION_JPEG_QUALITY].cap |= SANE_CAP_SOFT_SELECT;   /* enable jpeg quality */
 
114
          break;
 
115
    }
 
116
@@ -679,7 +679,7 @@
 
117
          }
 
118
          else
 
119
          {  /* Set default. */
 
120
-            ps->currentCompression = SF_JPEG;
 
121
+            ps->currentCompression = SF_RAW;
 
122
             stat = SANE_STATUS_GOOD;
 
123
          }
 
124
          break;
 
125
@@ -984,7 +984,9 @@
 
126
     }
 
127
   }
 
128
   else
 
129
-  ipGetImageTraits(ps->ip_handle, NULL, &ps->image_traits);  /* get valid image traits */
 
130
+  {
 
131
+    ipGetOutputTraits(ps->ip_handle, &ps->image_traits);  /* get valid image traits */
 
132
+  }
 
133
 
 
134
   stat = SANE_STATUS_GOOD;
 
135