brother_mfp: Added ADF duplex function for supported devices.

brother_mfp_backend
Ralph Little 2022-11-19 20:38:24 -08:00
rodzic 4173926d3b
commit cc4ad6be99
6 zmienionych plików z 83 dodań i 16 usunięć

Wyświetl plik

@ -466,7 +466,7 @@ DecodeStatus BrotherEncoderFamily2::EncodeParameterBlock (SANE_Byte *data, size_
"%s\n"
"B=%u\nN=%u\n"
"A=%u,%u,%u,%u\n"
"D=SIN\n"
"D=%s\n"
"\x80",
(unsigned int) scan_params.param_x_res,
(unsigned int) scan_params.param_y_res,
@ -481,7 +481,8 @@ DecodeStatus BrotherEncoderFamily2::EncodeParameterBlock (SANE_Byte *data, size_
(unsigned int) (scan_params.param_pixel_x_offset
+ scan_params.param_pixel_x_width),
(unsigned int) (scan_params.param_pixel_y_offset
+ scan_params.param_pixel_y_height));
+ scan_params.param_pixel_y_height),
scan_params.param_source == BROTHER_SOURCE_ADF_DUPLEX? "DUP": "SIN");
if (*length > data_len)
{
@ -1137,7 +1138,7 @@ DecodeStatus BrotherEncoderFamily3::EncodeParameterBlock (SANE_Byte *data, size_
"%s\n"
"B=%u\nN=%u\n"
"A=%u,%u,%u,%u\n"
"D=SIN\n"
"D=%s\n"
"\x80",
(unsigned int) scan_params.param_x_res,
(unsigned int) scan_params.param_y_res,
@ -1152,7 +1153,8 @@ DecodeStatus BrotherEncoderFamily3::EncodeParameterBlock (SANE_Byte *data, size_
(unsigned int) (scan_params.param_pixel_x_offset
+ scan_params.param_pixel_x_width),
(unsigned int) (scan_params.param_pixel_y_offset
+ scan_params.param_pixel_y_height));
+ scan_params.param_pixel_y_height),
scan_params.param_source == BROTHER_SOURCE_ADF_DUPLEX ? "DUP" : "SIN");
if (*length > data_len)
{
@ -1834,6 +1836,7 @@ DecodeStatus BrotherEncoderFamily4::EncodeParameterBlock (SANE_Byte *data, size_
"A=%u,%u,%u,%u\n"
"S=NORMAL_SCAN\n"
"P=0\nG=0\nL=0\n"
"D=%s\n"
"\x80",
(unsigned int) scan_params.param_x_res,
(unsigned int) scan_params.param_y_res,
@ -1847,7 +1850,8 @@ DecodeStatus BrotherEncoderFamily4::EncodeParameterBlock (SANE_Byte *data, size_
(unsigned int) (scan_params.param_pixel_x_offset
+ scan_params.param_pixel_x_width),
(unsigned int) (scan_params.param_pixel_y_offset
+ scan_params.param_pixel_y_height));
+ scan_params.param_pixel_y_height),
scan_params.param_source == BROTHER_SOURCE_ADF_DUPLEX ? "DUP" : "SIN");
if (*length > data_len)
{

Wyświetl plik

@ -88,6 +88,7 @@ typedef enum
{
BROTHER_SOURCE_FLATBED,
BROTHER_SOURCE_ADF,
BROTHER_SOURCE_ADF_DUPLEX,
} BrotherSource;
typedef SANE_Int BrotherSensor;

Wyświetl plik

@ -57,6 +57,8 @@
#define SANE_VALUE_SOURCE_FLATBED SANE_I18N("Flatbed")
#define SANE_VALUE_SOURCE_ADF SANE_I18N("Automatic Document Feeder")
#define SANE_VALUE_SOURCE_ADF_SIMPLEX SANE_I18N("Automatic Document Feeder (one sided)")
#define SANE_VALUE_SOURCE_ADF_DUPLEX SANE_I18N("Automatic Document Feeder (duplex)")
#define SANE_NAME_FILE_BUTTON "file-sensor"
#define SANE_NAME_EMAIL_BUTTON "email-sensor"
@ -410,7 +412,15 @@ attach_with_ret (const char *devicename, BrotherDevice **dev)
}
if (model->capabilities & CAP_SOURCE_HAS_ADF)
{
device->sources[num_sources++] = SANE_VALUE_SOURCE_ADF;
if (model->capabilities & CAP_SOURCE_HAS_ADF_DUPLEX)
{
device->sources[num_sources++] = SANE_VALUE_SOURCE_ADF_SIMPLEX;
device->sources[num_sources++] = SANE_VALUE_SOURCE_ADF_DUPLEX;
}
else
{
device->sources[num_sources++] = SANE_VALUE_SOURCE_ADF;
}
}
++num_devices;
@ -1397,7 +1407,8 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params)
return rc;
}
}
else if (strcmp(device->val[OPT_SOURCE].s, SANE_VALUE_SOURCE_ADF) == 0)
else if ((strcmp (device->val[OPT_SOURCE].s, SANE_VALUE_SOURCE_ADF) == 0)
|| (strcmp (device->val[OPT_SOURCE].s, SANE_VALUE_SOURCE_ADF) == 0))
{
rc = device->driver->SetSource(BROTHER_SOURCE_ADF);
if (rc != SANE_STATUS_GOOD)
@ -1405,6 +1416,14 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params)
return rc;
}
}
else if (strcmp(device->val[OPT_SOURCE].s, SANE_VALUE_SOURCE_ADF_DUPLEX) == 0)
{
rc = device->driver->SetSource(BROTHER_SOURCE_ADF_DUPLEX);
if (rc != SANE_STATUS_GOOD)
{
return rc;
}
}
/*
* Compute the geometry in terms of pixels at the selected resolution.

Wyświetl plik

@ -348,6 +348,20 @@ static void test_family2_encode_param()
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
// ADF duplex
encoder.SetScanDimensions (0, 10, 50, 100);
encoder.SetSource (BROTHER_SOURCE_ADF_DUPLEX);
decode_resp = encoder.EncodeParameterBlock (data_buffer, sizeof(data_buffer), &ret_length);
ASSERT_EQ(decode_resp, DECODE_STATUS_GOOD);
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=TEXT\nC=RLENGTH\n"
"B=100\nN=90\nA=0,50,10,150\nD=DUP\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
// Buffer too short.
decode_resp = encoder.EncodeParameterBlock (data_buffer, 15, &ret_length);

Wyświetl plik

@ -348,6 +348,20 @@ static void test_family3_encode_param()
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
// ADF duplex
encoder.SetScanDimensions (0, 10, 50, 100);
encoder.SetSource(BROTHER_SOURCE_ADF_DUPLEX);
decode_resp = encoder.EncodeParameterBlock (data_buffer, sizeof(data_buffer), &ret_length);
ASSERT_EQ(decode_resp, DECODE_STATUS_GOOD);
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=TEXT\nC=RLENGTH\n"
"B=100\nN=90\nA=0,50,10,150\nD=DUP\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
// Buffer too short.
decode_resp = encoder.EncodeParameterBlock (data_buffer, 15, &ret_length);

Wyświetl plik

@ -237,7 +237,7 @@ static void test_family4_encode_param()
{
const char test_ret[] = "\x1b" "X\nR=100,100\nM=CGRAY\nC=JPEG\nJ=MID\n"
"B=50\nN=50\nA=0,0,0,0\nS=NORMAL_SCAN\nP=0\n"
"G=0\nL=0\n" "\x80";
"G=0\nL=0\nD=SIN\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp(test_ret, data_buffer, sizeof(test_ret)), 0);
}
@ -252,7 +252,7 @@ static void test_family4_encode_param()
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=CGRAY\nC=JPEG\nJ=MID\n"
"B=50\nN=50\nA=0,0,0,0\nS=NORMAL_SCAN\nP=0\n"
"G=0\nL=0\n" "\x80";
"G=0\nL=0\nD=SIN\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp(test_ret, data_buffer, sizeof(test_ret)), 0);
}
@ -267,7 +267,7 @@ static void test_family4_encode_param()
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=GRAY64\nC=RLENGTH\n"
"B=50\nN=50\nA=0,0,0,0\nS=NORMAL_SCAN\nP=0\n"
"G=0\nL=0\n" "\x80";
"G=0\nL=0\nD=SIN\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
@ -281,7 +281,7 @@ static void test_family4_encode_param()
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=CGRAY\nC=JPEG\nJ=MID\n"
"B=50\nN=50\nA=0,0,0,0\nS=NORMAL_SCAN\nP=0\n"
"G=0\nL=0\n" "\x80";
"G=0\nL=0\nD=SIN\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
@ -295,7 +295,7 @@ static void test_family4_encode_param()
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=ERRDIF\nC=RLENGTH\n"
"B=50\nN=50\nA=0,0,0,0\nS=NORMAL_SCAN\nP=0\n"
"G=0\nL=0\n" "\x80";
"G=0\nL=0\nD=SIN\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
@ -309,7 +309,7 @@ static void test_family4_encode_param()
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=TEXT\nC=RLENGTH\n"
"B=50\nN=50\nA=0,0,0,0\nS=NORMAL_SCAN\nP=0\n"
"G=0\nL=0\n" "\x80";
"G=0\nL=0\nD=SIN\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
@ -324,7 +324,7 @@ static void test_family4_encode_param()
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=TEXT\nC=RLENGTH\n"
"B=30\nN=20\nA=0,0,0,0\nS=NORMAL_SCAN\nP=0\n"
"G=0\nL=0\n" "\x80";
"G=0\nL=0\nD=SIN\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
@ -338,7 +338,7 @@ static void test_family4_encode_param()
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=TEXT\nC=RLENGTH\n"
"B=100\nN=90\nA=0,0,0,0\nS=NORMAL_SCAN\nP=0\n"
"G=0\nL=0\n" "\x80";
"G=0\nL=0\nD=SIN\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
@ -352,7 +352,22 @@ static void test_family4_encode_param()
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=TEXT\nC=RLENGTH\n"
"B=100\nN=90\nA=0,50,10,150\nS=NORMAL_SCAN\nP=0\n"
"G=0\nL=0\n" "\x80";
"G=0\nL=0\nD=SIN\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}
// Duplex ADF
encoder.SetScanDimensions (0, 10, 50, 100);
encoder.SetSource (BROTHER_SOURCE_ADF_DUPLEX);
decode_resp = encoder.EncodeParameterBlock (data_buffer, sizeof(data_buffer), &ret_length);
ASSERT_EQ(decode_resp, DECODE_STATUS_GOOD);
{
const char test_ret[] = "\x1b" "X\nR=200,300\nM=TEXT\nC=RLENGTH\n"
"B=100\nN=90\nA=0,50,10,150\nS=NORMAL_SCAN\nP=0\n"
"G=0\nL=0\nD=DUP\n" "\x80";
ASSERT_EQ(ret_length, sizeof(test_ret) - 1);
ASSERT_EQ(memcmp (test_ret, data_buffer, sizeof(test_ret) - 1), 0);
}