2022-09-14 04:18:58 +00:00
|
|
|
/* sane - Scanner Access Now Easy.
|
|
|
|
|
|
|
|
BACKEND brother_mfp
|
|
|
|
|
|
|
|
Copyright (C) 2022 Ralph Little <skelband@gmail.com>
|
|
|
|
|
|
|
|
This file is part of the SANE package.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
This file implements a SANE backend for Brother Multifunction Devices.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../include/sane/config.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2022-09-24 18:38:34 +00:00
|
|
|
#include <jpeglib.h>
|
|
|
|
#include <jerror.h>
|
|
|
|
|
2022-09-14 04:18:58 +00:00
|
|
|
#include "brother_mfp-common.h"
|
|
|
|
|
|
|
|
#include "../include/sane/sane.h"
|
|
|
|
#include "../include/sane/sanei.h"
|
|
|
|
#include "../include/sane/saneopts.h"
|
|
|
|
#include "../include/sane/sanei_config.h"
|
|
|
|
#include "../include/sane/sanei_usb.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functionality sets.
|
|
|
|
*
|
|
|
|
* For the moment, I am going to assume that the various proprietary
|
|
|
|
* drivers follow the broad protocol versions and I will reflect this
|
|
|
|
* until I see different.
|
|
|
|
*
|
|
|
|
* So these will reflect the brscan2, brscan3, etc that Brother use.
|
|
|
|
*
|
|
|
|
* We will have a encoder/decoder for each family.
|
|
|
|
* From what I have seen, pretty much all the Brother families implement
|
|
|
|
* the same basic protocol sequence, just with variations in technology.
|
|
|
|
* So we don't need to abstract out the entire sequence, just the encoding
|
|
|
|
* and decoding of each packet. The biggest aspect by far is the difference
|
|
|
|
* in scan data formats.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
BROTHER_FAMILY_NONE,
|
2022-10-23 19:53:04 +00:00
|
|
|
BROTHER_FAMILY_1,
|
2022-10-15 23:53:46 +00:00
|
|
|
BROTHER_FAMILY_2,
|
2022-10-21 03:54:35 +00:00
|
|
|
BROTHER_FAMILY_3,
|
2022-09-14 04:18:58 +00:00
|
|
|
BROTHER_FAMILY_4,
|
2022-10-23 19:53:04 +00:00
|
|
|
BROTHER_FAMILY_5
|
2022-09-14 04:18:58 +00:00
|
|
|
} BrotherFamily;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
BROTHER_SCAN_MODE_COLOR,
|
|
|
|
BROTHER_SCAN_MODE_GRAY,
|
|
|
|
BROTHER_SCAN_MODE_GRAY_DITHERED,
|
|
|
|
BROTHER_SCAN_MODE_TEXT
|
|
|
|
} BrotherScanMode;
|
|
|
|
|
2022-10-15 23:53:46 +00:00
|
|
|
typedef SANE_Int BrotherSensor;
|
|
|
|
|
|
|
|
#define BROTHER_SENSOR_NONE 0
|
|
|
|
#define BROTHER_SENSOR_EMAIL (1 << 0)
|
|
|
|
#define BROTHER_SENSOR_FILE (1 << 1)
|
|
|
|
#define BROTHER_SENSOR_OCR (1 << 2)
|
|
|
|
#define BROTHER_SENSOR_IMAGE (1 << 3)
|
2022-09-14 04:18:58 +00:00
|
|
|
|
|
|
|
struct BrotherSessionResponse
|
|
|
|
{
|
|
|
|
SANE_Bool ready;
|
|
|
|
};
|
|
|
|
|
2022-10-15 23:53:46 +00:00
|
|
|
struct BrotherButtonQueryResponse
|
|
|
|
{
|
|
|
|
SANE_Bool has_button_press;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BrotherButtonStateResponse
|
|
|
|
{
|
|
|
|
BrotherSensor button_value; // raw value we get from the packet
|
|
|
|
};
|
|
|
|
|
2022-09-14 04:18:58 +00:00
|
|
|
struct BrotherParameters
|
|
|
|
{
|
|
|
|
BrotherParameters():
|
2022-09-25 03:44:28 +00:00
|
|
|
param_brightness (0),
|
|
|
|
param_contrast (0),
|
2022-10-23 19:53:04 +00:00
|
|
|
param_compression (SANE_TRUE),
|
2022-09-14 04:18:58 +00:00
|
|
|
param_pixel_x_offset (0),
|
|
|
|
param_pixel_x_width (0),
|
|
|
|
param_pixel_y_offset (0),
|
|
|
|
param_pixel_y_height (0),
|
|
|
|
param_scan_mode (BROTHER_SCAN_MODE_COLOR),
|
|
|
|
param_x_res(100),
|
|
|
|
param_y_res(100)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
SANE_Int param_brightness;
|
|
|
|
SANE_Int param_contrast;
|
2022-10-23 19:53:04 +00:00
|
|
|
SANE_Bool param_compression;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
|
|
|
SANE_Int param_pixel_x_offset;
|
|
|
|
SANE_Int param_pixel_x_width;
|
|
|
|
SANE_Int param_pixel_y_offset;
|
|
|
|
SANE_Int param_pixel_y_height;
|
|
|
|
|
|
|
|
BrotherScanMode param_scan_mode;
|
|
|
|
|
|
|
|
SANE_Int param_x_res;
|
|
|
|
SANE_Int param_y_res;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BrotherBasicParamResponse
|
|
|
|
{
|
|
|
|
int dummy;
|
|
|
|
// fill me
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BrotherADFResponse
|
|
|
|
{
|
|
|
|
SANE_Byte resp_code;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DecodeStatus
|
|
|
|
*
|
|
|
|
* DECODE_STATUS_GOOD - decode finished. Nothing more to do.
|
|
|
|
* DECODE_STATUS_TRUNCATED - starved of input. Need more src data.
|
|
|
|
* DECODE_STATUS_MORE - starved of output. Have more output available.
|
|
|
|
* DECODE_STATUS_ERROR - format of the data is incorrect.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
enum DecodeStatus
|
|
|
|
{
|
|
|
|
DECODE_STATUS_GOOD,
|
|
|
|
DECODE_STATUS_TRUNCATED,
|
|
|
|
DECODE_STATUS_ENDOFDATA,
|
2022-10-26 04:46:41 +00:00
|
|
|
DECODE_STATUS_ENDOFFRAME_NO_MORE,
|
|
|
|
DECODE_STATUS_ENDOFFRAME_WITH_MORE,
|
2022-10-23 19:53:04 +00:00
|
|
|
DECODE_STATUS_CANCEL,
|
2022-10-21 03:54:35 +00:00
|
|
|
DECODE_STATUS_ERROR,
|
2022-10-26 04:46:41 +00:00
|
|
|
DECODE_STATUS_MEMORY,
|
|
|
|
DECODE_STATUS_INVAL,
|
|
|
|
DECODE_STATUS_UNSUPPORTED
|
2022-09-14 04:18:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ScanDataHeader
|
|
|
|
{
|
|
|
|
ScanDataHeader():
|
|
|
|
block_type(0),
|
|
|
|
block_len(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
SANE_Byte block_type;
|
|
|
|
size_t block_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BrotherEncoder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BrotherEncoder ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~BrotherEncoder ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual void NewPage () = 0;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus SetScanMode (BrotherScanMode scan_mode);
|
|
|
|
DecodeStatus SetRes (SANE_Int x, SANE_Int y);
|
|
|
|
DecodeStatus SetContrast (SANE_Int contrast);
|
|
|
|
DecodeStatus SetBrightness (SANE_Int brightness);
|
|
|
|
DecodeStatus SetCompression (SANE_Bool compression);
|
|
|
|
|
|
|
|
DecodeStatus SetScanDimensions (SANE_Int pixel_x_offset, SANE_Int pixel_x_width,
|
|
|
|
SANE_Int pixel_y_offset, SANE_Int pixel_y_height);
|
|
|
|
|
|
|
|
SANE_Status DecodeStatusToSaneStatus(DecodeStatus dec_ret)
|
|
|
|
{
|
|
|
|
static SANE_Status status_lookup[] =
|
|
|
|
{
|
|
|
|
SANE_STATUS_GOOD,
|
|
|
|
SANE_STATUS_GOOD,
|
|
|
|
SANE_STATUS_EOF,
|
|
|
|
SANE_STATUS_EOF,
|
|
|
|
SANE_STATUS_EOF,
|
|
|
|
SANE_STATUS_CANCELLED,
|
|
|
|
SANE_STATUS_IO_ERROR,
|
|
|
|
SANE_STATUS_NO_MEM,
|
|
|
|
SANE_STATUS_INVAL,
|
|
|
|
SANE_STATUS_UNSUPPORTED
|
|
|
|
};
|
|
|
|
|
|
|
|
return status_lookup[dec_ret];
|
|
|
|
}
|
2022-09-14 04:18:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
static const char* ScanModeToText (BrotherScanMode scan_mode);
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual DecodeStatus DecodeSessionResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherSessionResponse &response) = 0;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual DecodeStatus DecodeButtonQueryResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherButtonQueryResponse &response) = 0;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual DecodeStatus DecodeButtonStateResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherButtonStateResponse &response) = 0;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual DecodeStatus EncodeBasicParameterBlock (SANE_Byte *data, size_t data_len,
|
|
|
|
size_t *length) = 0;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual DecodeStatus DecodeBasicParameterBlockResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherBasicParamResponse &response) = 0;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual DecodeStatus EncodeADFBlock (SANE_Byte *data, size_t data_len, size_t *length) = 0;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual DecodeStatus DecodeADFBlockResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherADFResponse &response) = 0;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual DecodeStatus EncodeParameterBlock (SANE_Byte *data, size_t data_len, size_t *length) = 0;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual DecodeStatus EncodeParameterBlockBlank (SANE_Byte *data, size_t data_len,
|
|
|
|
size_t *length) = 0;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
virtual DecodeStatus DecodeScanData (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, SANE_Byte *dst_data,
|
|
|
|
size_t dest_data_len, size_t *dest_data_written) = 0;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-09-14 04:18:58 +00:00
|
|
|
protected:
|
|
|
|
BrotherParameters scan_params;
|
|
|
|
};
|
|
|
|
|
2022-09-24 18:38:34 +00:00
|
|
|
#include <setjmp.h>
|
|
|
|
|
|
|
|
|
2022-09-14 04:18:58 +00:00
|
|
|
class BrotherJFIFDecoder
|
|
|
|
{
|
|
|
|
public:
|
2022-09-24 18:38:34 +00:00
|
|
|
BrotherJFIFDecoder():
|
2022-10-10 23:00:40 +00:00
|
|
|
decompress_bytes(0)
|
2022-09-24 18:38:34 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Not sure if this is a safe way to get the cinfo into
|
|
|
|
* a consistent state but at least all pointers will be NULL.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
(void)memset(&state.cinfo, 0, sizeof(state.cinfo));
|
|
|
|
|
|
|
|
// TODO: override error stuff to avoid exit on error.
|
|
|
|
// Also provide a mechanism to check for errors.
|
|
|
|
state.cinfo.err = jpeg_std_error(&state.jerr);
|
|
|
|
state.cinfo.err->error_exit = ErrorExitManager;
|
|
|
|
|
|
|
|
jpeg_create_decompress (&state.cinfo);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up source manager.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
state.src_mgr.init_source = InitSource;
|
|
|
|
state.src_mgr.fill_input_buffer = FillInputBuffer;
|
|
|
|
state.src_mgr.skip_input_data = SkipInputData;
|
|
|
|
state.src_mgr.resync_to_restart = jpeg_resync_to_restart;
|
|
|
|
state.src_mgr.term_source = TermSource;
|
|
|
|
|
|
|
|
state.cinfo.src = &state.src_mgr;
|
|
|
|
}
|
|
|
|
|
2022-10-10 23:00:40 +00:00
|
|
|
static void ErrorExitManager(j_common_ptr cinfo);
|
2022-09-24 18:38:34 +00:00
|
|
|
|
|
|
|
~BrotherJFIFDecoder()
|
|
|
|
{
|
|
|
|
jpeg_destroy_decompress(&state.cinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewBlock();
|
2022-10-15 23:53:46 +00:00
|
|
|
void NewPage(const BrotherParameters ¶ms);
|
2022-09-14 04:18:58 +00:00
|
|
|
|
|
|
|
DecodeStatus DecodeScanData (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, SANE_Byte *dst_data, size_t dest_data_len,
|
|
|
|
size_t *dest_data_written);
|
2022-09-24 18:38:34 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static void InitSource (j_decompress_ptr cinfo);
|
|
|
|
static boolean FillInputBuffer(j_decompress_ptr cinfo);
|
|
|
|
static void SkipInputData(j_decompress_ptr cinfo, long num_bytes);
|
|
|
|
static void TermSource(j_decompress_ptr cinfo);
|
|
|
|
|
2022-10-10 23:00:40 +00:00
|
|
|
DecodeStatus DecodeScanData_CompressBuffer (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, SANE_Byte *dst_data, size_t dest_data_len,
|
|
|
|
size_t *dest_data_written);
|
|
|
|
|
|
|
|
|
2022-09-24 18:38:34 +00:00
|
|
|
struct CompressionState
|
|
|
|
{
|
|
|
|
struct jpeg_decompress_struct cinfo;
|
|
|
|
struct jpeg_error_mgr jerr;
|
|
|
|
struct jpeg_source_mgr src_mgr;
|
|
|
|
bool have_read_header;
|
|
|
|
} state;
|
|
|
|
|
2022-10-10 23:00:40 +00:00
|
|
|
SANE_Byte decompress_buffer[1024 * 16];
|
|
|
|
size_t decompress_bytes;
|
2022-09-24 18:38:34 +00:00
|
|
|
|
|
|
|
// TODO: Move me to the state.
|
|
|
|
static jmp_buf my_env;
|
|
|
|
|
2022-10-15 23:53:46 +00:00
|
|
|
BrotherParameters decode_params;
|
|
|
|
|
2022-09-14 04:18:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BrotherGrayRLengthDecoder
|
|
|
|
{
|
|
|
|
public:
|
2022-10-15 23:53:46 +00:00
|
|
|
BrotherGrayRLengthDecoder()
|
2022-09-14 04:18:58 +00:00
|
|
|
{
|
|
|
|
}
|
2022-09-24 18:38:34 +00:00
|
|
|
void NewBlock();
|
2022-10-15 23:53:46 +00:00
|
|
|
|
|
|
|
void NewPage(const BrotherParameters ¶ms);
|
2022-09-14 04:18:58 +00:00
|
|
|
|
|
|
|
DecodeStatus DecodeScanData (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, SANE_Byte *dst_data, size_t dest_data_len,
|
|
|
|
size_t *dest_data_written);
|
|
|
|
|
|
|
|
private:
|
2022-10-15 23:53:46 +00:00
|
|
|
BrotherParameters decode_params;
|
2022-09-14 04:18:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-10-21 03:54:35 +00:00
|
|
|
class BrotherInterleavedRGBColourDecoder
|
|
|
|
{
|
|
|
|
public:
|
2022-10-23 19:53:04 +00:00
|
|
|
BrotherInterleavedRGBColourDecoder(SANE_Word capabilities):
|
|
|
|
capabilities(capabilities),
|
2022-10-21 03:54:35 +00:00
|
|
|
scanline_buffer(nullptr),
|
|
|
|
scanline_buffer_size(0),
|
|
|
|
scanline_length(0),
|
|
|
|
scanline_buffer_data(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~BrotherInterleavedRGBColourDecoder()
|
|
|
|
{
|
|
|
|
free(scanline_buffer);
|
|
|
|
}
|
|
|
|
void NewBlock();
|
|
|
|
|
|
|
|
void NewPage(const BrotherParameters ¶ms);
|
|
|
|
|
|
|
|
DecodeStatus DecodeScanData (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, SANE_Byte *dst_data, size_t dest_data_len,
|
|
|
|
size_t *dest_data_written);
|
|
|
|
|
2022-10-23 19:53:04 +00:00
|
|
|
enum ChannelEncoding
|
|
|
|
{
|
|
|
|
CHANNELS_RGB, // RGB
|
|
|
|
CHANNELS_CrYCb // YCrCb
|
|
|
|
};
|
2022-10-21 03:54:35 +00:00
|
|
|
private:
|
2022-10-23 19:53:04 +00:00
|
|
|
void ConvertYCbCrToRGB (SANE_Byte y, SANE_Byte cb, SANE_Byte cr, SANE_Byte *red, SANE_Byte *green,
|
|
|
|
SANE_Byte *blue);
|
|
|
|
|
2022-10-21 03:54:35 +00:00
|
|
|
BrotherParameters decode_params;
|
2022-10-23 19:53:04 +00:00
|
|
|
SANE_Word capabilities;
|
2022-10-21 03:54:35 +00:00
|
|
|
|
|
|
|
SANE_Byte *scanline_buffer;
|
|
|
|
size_t scanline_buffer_size;
|
|
|
|
size_t scanline_length;
|
|
|
|
size_t scanline_buffer_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-09-14 04:18:58 +00:00
|
|
|
class BrotherGrayRawDecoder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BrotherGrayRawDecoder()
|
|
|
|
{
|
|
|
|
}
|
2022-09-24 18:38:34 +00:00
|
|
|
void NewBlock();
|
2022-10-15 23:53:46 +00:00
|
|
|
|
|
|
|
void NewPage(const BrotherParameters ¶ms);
|
2022-09-14 04:18:58 +00:00
|
|
|
|
|
|
|
DecodeStatus DecodeScanData (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, SANE_Byte *dst_data, size_t dest_data_len,
|
|
|
|
size_t *dest_data_written);
|
|
|
|
|
|
|
|
private:
|
2022-10-15 23:53:46 +00:00
|
|
|
BrotherParameters decode_params;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BrotherEncoderFamily2 : public BrotherEncoder
|
|
|
|
{
|
|
|
|
public:
|
2022-10-23 19:53:04 +00:00
|
|
|
BrotherEncoderFamily2(SANE_Word capabilities):
|
|
|
|
colour_decoder(capabilities)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-10-15 23:53:46 +00:00
|
|
|
~BrotherEncoderFamily2 ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
void NewPage () override
|
2022-10-15 23:53:46 +00:00
|
|
|
{
|
|
|
|
current_header.block_type = 0;
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
jfif_decoder.NewPage (scan_params);
|
|
|
|
gray_decoder.NewPage (scan_params);
|
|
|
|
gray_raw_decoder.NewPage (scan_params);
|
|
|
|
colour_decoder.NewPage (scan_params);
|
2022-10-15 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeSessionResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherSessionResponse &response) override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeBasicParameterBlock (SANE_Byte *data, size_t data_len, size_t *length)
|
|
|
|
override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeBasicParameterBlockResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherBasicParamResponse &response) override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeADFBlock (SANE_Byte *data, size_t data_len, size_t *length) override
|
2022-10-15 23:53:46 +00:00
|
|
|
{
|
2022-10-26 04:46:41 +00:00
|
|
|
(void) data;
|
|
|
|
(void) data_len;
|
|
|
|
(void) length;
|
|
|
|
return DECODE_STATUS_UNSUPPORTED;
|
2022-10-15 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeADFBlockResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherADFResponse &response) override
|
2022-10-15 23:53:46 +00:00
|
|
|
{
|
2022-10-26 04:46:41 +00:00
|
|
|
(void) data;
|
|
|
|
(void) data_len;
|
|
|
|
(void) response;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
return DECODE_STATUS_UNSUPPORTED;
|
2022-10-15 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeParameterBlock (SANE_Byte *data, size_t data_len, size_t *length) override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeParameterBlockBlank (SANE_Byte *data, size_t data_len, size_t *length)
|
|
|
|
override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeScanData (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, SANE_Byte *dst_data, size_t dest_data_len,
|
|
|
|
size_t *dest_data_written) override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeButtonQueryResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherButtonQueryResponse &response) override;
|
|
|
|
|
|
|
|
DecodeStatus DecodeButtonStateResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherButtonStateResponse &response) override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DecodeStatus DecodeScanDataHeader (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, ScanDataHeader &header);
|
|
|
|
|
|
|
|
ScanDataHeader current_header;
|
|
|
|
|
|
|
|
BrotherJFIFDecoder jfif_decoder;
|
|
|
|
BrotherGrayRLengthDecoder gray_decoder;
|
2022-10-16 01:12:05 +00:00
|
|
|
BrotherGrayRawDecoder gray_raw_decoder;
|
2022-10-23 19:53:04 +00:00
|
|
|
BrotherInterleavedRGBColourDecoder colour_decoder;
|
2022-09-14 04:18:58 +00:00
|
|
|
};
|
|
|
|
|
2022-10-21 03:54:35 +00:00
|
|
|
class BrotherEncoderFamily3 : public BrotherEncoder
|
|
|
|
{
|
|
|
|
public:
|
2022-10-23 19:53:04 +00:00
|
|
|
BrotherEncoderFamily3(SANE_Word capabilities):
|
|
|
|
colour_decoder(capabilities)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-10-21 03:54:35 +00:00
|
|
|
~BrotherEncoderFamily3 ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewPage() override
|
|
|
|
{
|
|
|
|
current_header.block_type = 0;
|
|
|
|
|
|
|
|
gray_raw_decoder.NewPage(scan_params);
|
|
|
|
gray_decoder.NewPage(scan_params);
|
|
|
|
colour_decoder.NewPage(scan_params);
|
|
|
|
jfif_decoder.NewPage(scan_params);
|
|
|
|
}
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeSessionResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherSessionResponse &response) override;
|
2022-10-21 03:54:35 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeBasicParameterBlock (SANE_Byte *data, size_t data_len, size_t *length)
|
|
|
|
override;
|
2022-10-21 03:54:35 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeBasicParameterBlockResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherBasicParamResponse &response) override;
|
2022-10-21 03:54:35 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeADFBlock (SANE_Byte *data, size_t data_len, size_t *length) override
|
2022-10-21 03:54:35 +00:00
|
|
|
{
|
2022-10-26 04:46:41 +00:00
|
|
|
(void) data;
|
|
|
|
(void) data_len;
|
|
|
|
(void) length;
|
|
|
|
return DECODE_STATUS_UNSUPPORTED;
|
2022-10-21 03:54:35 +00:00
|
|
|
}
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeADFBlockResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherADFResponse &response) override
|
2022-10-21 03:54:35 +00:00
|
|
|
{
|
2022-10-26 04:46:41 +00:00
|
|
|
(void) data;
|
|
|
|
(void) data_len;
|
|
|
|
(void) response;
|
2022-10-21 03:54:35 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
return DECODE_STATUS_UNSUPPORTED;
|
2022-10-21 03:54:35 +00:00
|
|
|
}
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeParameterBlock (SANE_Byte *data, size_t data_len, size_t *length) override;
|
2022-10-21 03:54:35 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeParameterBlockBlank (SANE_Byte *data, size_t data_len, size_t *length)
|
|
|
|
override;
|
2022-10-21 03:54:35 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeScanData (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, SANE_Byte *dst_data, size_t dest_data_len,
|
|
|
|
size_t *dest_data_written) override;
|
2022-10-21 03:54:35 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeButtonQueryResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherButtonQueryResponse &response) override;
|
|
|
|
|
|
|
|
DecodeStatus DecodeButtonStateResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherButtonStateResponse &response) override;
|
2022-10-21 03:54:35 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DecodeStatus DecodeScanDataHeader (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, ScanDataHeader &header);
|
|
|
|
|
|
|
|
ScanDataHeader current_header;
|
|
|
|
|
|
|
|
BrotherGrayRawDecoder gray_raw_decoder;
|
|
|
|
BrotherGrayRLengthDecoder gray_decoder;
|
|
|
|
BrotherInterleavedRGBColourDecoder colour_decoder;
|
|
|
|
BrotherJFIFDecoder jfif_decoder;
|
|
|
|
};
|
|
|
|
|
2022-09-14 04:18:58 +00:00
|
|
|
class BrotherEncoderFamily4 : public BrotherEncoder
|
|
|
|
{
|
|
|
|
public:
|
2022-10-23 21:26:42 +00:00
|
|
|
BrotherEncoderFamily4(SANE_Word capabilities)
|
2022-10-23 19:53:04 +00:00
|
|
|
{
|
2022-10-23 21:26:42 +00:00
|
|
|
(void)capabilities;
|
2022-10-23 19:53:04 +00:00
|
|
|
}
|
|
|
|
|
2022-09-14 04:18:58 +00:00
|
|
|
~BrotherEncoderFamily4 ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-09-24 18:38:34 +00:00
|
|
|
void NewPage() override
|
2022-09-14 04:18:58 +00:00
|
|
|
{
|
|
|
|
current_header.block_type = 0;
|
2022-10-10 23:00:40 +00:00
|
|
|
|
2022-10-15 23:53:46 +00:00
|
|
|
jfif_decoder.NewPage(scan_params);
|
2022-10-26 04:46:41 +00:00
|
|
|
gray_decoder.NewPage (scan_params);
|
|
|
|
gray_raw_decoder.NewPage (scan_params);
|
2022-09-14 04:18:58 +00:00
|
|
|
}
|
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeSessionResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherSessionResponse &response) override;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeBasicParameterBlock (SANE_Byte *data, size_t data_len, size_t *length)
|
|
|
|
override;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeBasicParameterBlockResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherBasicParamResponse &response) override;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeADFBlock (SANE_Byte *data, size_t data_len, size_t *length) override;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeADFBlockResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherADFResponse &response) override;
|
2022-09-14 04:18:58 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeParameterBlock (SANE_Byte *data, size_t data_len, size_t *length) override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus EncodeParameterBlockBlank (SANE_Byte *data, size_t data_len, size_t *length)
|
|
|
|
override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeScanData (const SANE_Byte *src_data, size_t src_data_len,
|
|
|
|
size_t *src_data_consumed, SANE_Byte *dst_data, size_t dest_data_len,
|
|
|
|
size_t *dest_data_written) override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeButtonQueryResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherButtonQueryResponse &response) override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-10-26 04:46:41 +00:00
|
|
|
DecodeStatus DecodeButtonStateResp (const SANE_Byte *data, size_t data_len,
|
|
|
|
BrotherButtonStateResponse &response) override;
|
2022-10-15 23:53:46 +00:00
|
|
|
|
2022-09-14 04:18:58 +00:00
|
|
|
private:
|
|
|
|
DecodeStatus DecodeScanDataHeader (const SANE_Byte *src_data, size_t src_data_len,
|
2022-10-15 23:53:46 +00:00
|
|
|
size_t *src_data_consumed, ScanDataHeader &header);
|
2022-09-14 04:18:58 +00:00
|
|
|
|
|
|
|
ScanDataHeader current_header;
|
|
|
|
|
|
|
|
BrotherJFIFDecoder jfif_decoder;
|
|
|
|
BrotherGrayRLengthDecoder gray_decoder;
|
|
|
|
BrotherGrayRawDecoder gray_raw_decoder;
|
|
|
|
};
|