Monolta Dimage Scan Dual II (avision backend)
Alex via sane-devel <[email protected]>
| Newsgroups | gmane.comp.graphics.scanning.sane.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, I recently acquired a Monolta Dimage Scan Dual II which would not scan using SANE (1.2.1 in that case, but the relevant code is identical in master). It would just hang when uploading the gamma table, then timeout and abort the scan. The attached patch fixes scanning with my particular device. Comparison with the windows driver's USB bus traffic shows that my particular unit needs to be sent 4096 bytes of gamma table. It reports an ASIC of 3, i.e. AV_ASIC_C2, so SANE 1.2.1 sends it 512 bytes. This write times out, and so do all further commands sent to the device afterwards. I suspect the firmware ignores the length provided in the send command and just expects 4096 bytes anyway? It would sure explain the observed behavior since the next 3584 bytes of commands will be interpreted as gamma table data instead... In any case, setting gamma_table_raw_size = gamma_table_size = 4096 in send_gamma() works and the device scans beautifully in 8-bit mode. In the patch I set that for all AV_ASIC_C2 devices... Not sure if that's safe to do, or if it's specific to this particular model and will break other models. 12-bit mode didn't work properly (very strong banding). The related code in reader_process() is clearly wrong: It's a 12- and 16-bit only codepath, it produces a 16-bit sample... but then writes only a single byte (lowest 8 bits) to the output buffer. The output buffer clearly advances by 2 bytes per pixel, so I just made it write a 16-bit host-endian pixel instead. Scanning then works perfectly in 12-bit mode as well. That change should also fix 12- and 16-bit scanning for all other avision devices (I don't see how any of them can scan correctly in 12- or 16-bit mode when only 8 bits of the sample data are written). Please let me know if you need further information or need me to test something. Regards, - Alex PS: Sorry for reporting this the old-fashioned way. I don't have an existing gitlab.com account, and their current verification process is quite excessive IMHO.
avision.patch
(text/x-patch, 619 B)
--- sane-backends-1.2.1/backend/avision.c 2023-02-05 04:01:14.000000000 +0100
+++ sane-backends-1.2.1.new/backend/avision.c 2026-08-05 11:58:22.528435210 +0200
@@ -5810,6 +5810,7 @@
break;
break;
case AV_ASIC_OA980:
+ case AV_ASIC_C2:
gamma_table_raw_size = 4096;
gamma_table_size = 4096;
break;
@@ -7979,7 +7980,7 @@
/* SANE Standard 3.2.1 "... bytes of each sample value are
transmitted in the machine's native byte order." */
- *line_ptr = (uint8_t) v2;
+ *((uint16_t *) line_ptr) = v2;
line_ptr += s->avdimen.hw_bytes_per_line;
}