kopia lustrzana https://gitlab.com/sane-project/backends
gamma handling refactor
- use arrays instead of gamma tables - send_gamma_table does only send gamma table and doesn't create ramp if no custom gamma - create a default gamma table with gamma value from device descriptionmerge-requests/1/head
rodzic
3af19cf7ef
commit
bd44b058a0
|
@ -58,7 +58,7 @@
|
|||
* SANE backend for Genesys Logic GL646/GL841/GL842/GL843/GL847/GL124 based scanners
|
||||
*/
|
||||
|
||||
#define BUILD 2405
|
||||
#define BUILD 2407
|
||||
#define BACKEND_NAME genesys
|
||||
|
||||
#include "genesys.h"
|
||||
|
@ -715,7 +715,16 @@ sanei_genesys_create_slope_table (Genesys_Device * dev,
|
|||
return sum_time;
|
||||
}
|
||||
|
||||
/* computes gamma table */
|
||||
/** @brief computes gamma table
|
||||
* Generates a gamma table of the given length within 0 and the given
|
||||
* maximum value
|
||||
* @param gamma_table gamma table to fill
|
||||
* @param size size of the table
|
||||
* @param maximum value allowed for gamma
|
||||
* @param gamma_max maximum gamma value
|
||||
* @param gamma gamma to compute values
|
||||
* @return a gamma table filled with the computed values
|
||||
* */
|
||||
void
|
||||
sanei_genesys_create_gamma_table (uint16_t * gamma_table, int size,
|
||||
float maximum, float gamma_max, float gamma)
|
||||
|
@ -733,9 +742,6 @@ sanei_genesys_create_gamma_table (uint16_t * gamma_table, int size,
|
|||
if (value > maximum)
|
||||
value = maximum;
|
||||
gamma_table[i] = value;
|
||||
/* DBG (DBG_data,
|
||||
"sanei_genesys_create_gamma_table: gamma_table[%.3d] = %.5d\n",
|
||||
i, (int) value); */
|
||||
}
|
||||
DBG (DBG_proc, "sanei_genesys_create_gamma_table: completed\n");
|
||||
}
|
||||
|
@ -3108,9 +3114,6 @@ genesys_restore_calibration (Genesys_Device * dev)
|
|||
{
|
||||
memcpy (&dev->frontend, &cache->frontend, sizeof (dev->frontend));
|
||||
/* we don't restore the gamma fields */
|
||||
/* XXX STEF XXX
|
||||
memcpy (&dev->sensor, &cache->sensor, offsetof (Genesys_Sensor, red_gamma));
|
||||
*/
|
||||
memcpy (dev->sensor.regs_0x10_0x1d, cache->sensor.regs_0x10_0x1d, 6);
|
||||
free (dev->dark_average_data);
|
||||
free (dev->white_average_data);
|
||||
|
@ -4085,17 +4088,9 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
|
|||
}
|
||||
}
|
||||
|
||||
/* send custom or generic gamma tables depending on flag */
|
||||
if (dev->model->flags & GENESYS_FLAG_CUSTOM_GAMMA)
|
||||
{
|
||||
/* use custom gamma table */
|
||||
status = dev->model->cmd_set->send_gamma_table (dev, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* send default gamma table if no custom gamma */
|
||||
status = dev->model->cmd_set->send_gamma_table (dev, 1);
|
||||
}
|
||||
/* send gamma tbales. They have been set ot device or user value
|
||||
* when setting option value */
|
||||
status = dev->model->cmd_set->send_gamma_table (dev);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -6235,7 +6230,7 @@ sanei_genesys_read_calibration (Genesys_Device * dev)
|
|||
BILT1 (fread (&cache->last_calibration, sizeof (cache->last_calibration), 1, fp));
|
||||
BILT1 (fread (&cache->frontend, sizeof (cache->frontend), 1, fp));
|
||||
/* the gamma (and later) fields are not stored */
|
||||
BILT1 (fread (&cache->sensor, offsetof (Genesys_Sensor, red_gamma), 1, fp));
|
||||
BILT1 (fread (&cache->sensor, offsetof (Genesys_Sensor, gamma[0]), 1, fp));
|
||||
BILT1 (fread (&cache->calib_pixels, sizeof (cache->calib_pixels), 1, fp));
|
||||
BILT1 (fread (&cache->calib_channels, sizeof (cache->calib_channels), 1, fp));
|
||||
BILT1 (fread (&cache->average_size, sizeof (cache->average_size), 1, fp));
|
||||
|
@ -6310,7 +6305,7 @@ write_calibration (Genesys_Device * dev)
|
|||
fwrite (&cache->last_calibration, sizeof (cache->last_calibration), 1, fp);
|
||||
fwrite (&cache->frontend, sizeof (cache->frontend), 1, fp);
|
||||
/* the gamma (and later) fields are not stored */
|
||||
fwrite (&cache->sensor, offsetof (Genesys_Sensor, red_gamma), 1, fp);
|
||||
fwrite (&cache->sensor, offsetof (Genesys_Sensor, gamma[0]), 1, fp);
|
||||
|
||||
fwrite (&cache->calib_pixels, sizeof (cache->calib_pixels), 1, fp);
|
||||
fwrite (&cache->calib_channels, sizeof (cache->calib_channels), 1, fp);
|
||||
|
@ -6853,9 +6848,9 @@ sane_close (SANE_Handle handle)
|
|||
FREE_IFNOT_NULL (s->dev->calib_file);
|
||||
|
||||
/* free allocated gamma tables */
|
||||
FREE_IFNOT_NULL (s->dev->sensor.red_gamma_table);
|
||||
FREE_IFNOT_NULL (s->dev->sensor.green_gamma_table);
|
||||
FREE_IFNOT_NULL (s->dev->sensor.blue_gamma_table);
|
||||
FREE_IFNOT_NULL (s->dev->sensor.gamma_table[0]);
|
||||
FREE_IFNOT_NULL (s->dev->sensor.gamma_table[1]);
|
||||
FREE_IFNOT_NULL (s->dev->sensor.gamma_table[2]);
|
||||
|
||||
/* for an handful of bytes .. */
|
||||
free ((void *)s->opt[OPT_RESOLUTION].constraint.word_list);
|
||||
|
@ -6964,15 +6959,15 @@ get_option_value (Genesys_Scanner * s, int option, void *val)
|
|||
table = (SANE_Word *) val;
|
||||
if (strcmp (s->val[OPT_COLOR_FILTER].s, "Red") == 0)
|
||||
{
|
||||
gamma = s->dev->sensor.red_gamma_table;
|
||||
gamma = s->dev->sensor.gamma_table[GENESYS_RED];
|
||||
}
|
||||
else if (strcmp (s->val[OPT_COLOR_FILTER].s, "Blue") == 0)
|
||||
{
|
||||
gamma = s->dev->sensor.blue_gamma_table;
|
||||
gamma = s->dev->sensor.gamma_table[GENESYS_BLUE];
|
||||
}
|
||||
else
|
||||
{
|
||||
gamma = s->dev->sensor.green_gamma_table;
|
||||
gamma = s->dev->sensor.gamma_table[GENESYS_GREEN];
|
||||
}
|
||||
for (i = 0; i < s->opt[option].size / sizeof (SANE_Word); i++)
|
||||
{
|
||||
|
@ -6983,21 +6978,21 @@ get_option_value (Genesys_Scanner * s, int option, void *val)
|
|||
table = (SANE_Word *) val;
|
||||
for (i = 0; i < s->opt[option].size / sizeof (SANE_Word); i++)
|
||||
{
|
||||
table[i] = s->dev->sensor.red_gamma_table[i];
|
||||
table[i] = s->dev->sensor.gamma_table[GENESYS_RED][i];
|
||||
}
|
||||
break;
|
||||
case OPT_GAMMA_VECTOR_G:
|
||||
table = (SANE_Word *) val;
|
||||
for (i = 0; i < s->opt[option].size / sizeof (SANE_Word); i++)
|
||||
{
|
||||
table[i] = s->dev->sensor.green_gamma_table[i];
|
||||
table[i] = s->dev->sensor.gamma_table[GENESYS_GREEN][i];
|
||||
}
|
||||
break;
|
||||
case OPT_GAMMA_VECTOR_B:
|
||||
table = (SANE_Word *) val;
|
||||
for (i = 0; i < s->opt[option].size / sizeof (SANE_Word); i++)
|
||||
{
|
||||
table[i] = s->dev->sensor.blue_gamma_table[i];
|
||||
table[i] = s->dev->sensor.gamma_table[GENESYS_BLUE][i];
|
||||
}
|
||||
break;
|
||||
/* sensors */
|
||||
|
@ -7254,31 +7249,21 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
|
|||
/* restore default sensor gamma table */
|
||||
/* currently there is no sensor's specific gamma table,
|
||||
* tables are built by sanei_genesys_create_gamma_table */
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.red_gamma_table,
|
||||
s->opt[OPT_GAMMA_VECTOR_R].size /
|
||||
sizeof (SANE_Word),
|
||||
s->opt
|
||||
[OPT_GAMMA_VECTOR_R].
|
||||
constraint.range->max,
|
||||
s->opt[OPT_GAMMA_VECTOR_R].
|
||||
constraint.range->max,
|
||||
s->dev->sensor.red_gamma);
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.green_gamma_table,
|
||||
s->opt[OPT_GAMMA_VECTOR_G].size /
|
||||
sizeof (SANE_Word),
|
||||
s->opt[OPT_GAMMA_VECTOR_G].
|
||||
constraint.range->max,
|
||||
s->opt[OPT_GAMMA_VECTOR_G].
|
||||
constraint.range->max,
|
||||
s->dev->sensor.red_gamma);
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.blue_gamma_table,
|
||||
s->opt[OPT_GAMMA_VECTOR_B].size /
|
||||
sizeof (SANE_Word),
|
||||
s->opt[OPT_GAMMA_VECTOR_B].
|
||||
constraint.range->max,
|
||||
s->opt[OPT_GAMMA_VECTOR_B].
|
||||
constraint.range->max,
|
||||
s->dev->sensor.red_gamma);
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.gamma_table[GENESYS_RED],
|
||||
s->opt[OPT_GAMMA_VECTOR_R].size / sizeof (SANE_Word),
|
||||
s->opt[OPT_GAMMA_VECTOR_R].constraint.range->max,
|
||||
s->opt[OPT_GAMMA_VECTOR_R].constraint.range->max,
|
||||
s->dev->sensor.gamma[GENESYS_RED]);
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.gamma_table[GENESYS_GREEN],
|
||||
s->opt[OPT_GAMMA_VECTOR_G].size / sizeof (SANE_Word),
|
||||
s->opt[OPT_GAMMA_VECTOR_G].constraint.range->max,
|
||||
s->opt[OPT_GAMMA_VECTOR_G].constraint.range->max,
|
||||
s->dev->sensor.gamma[GENESYS_GREEN]);
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.gamma_table[GENESYS_BLUE],
|
||||
s->opt[OPT_GAMMA_VECTOR_B].size / sizeof (SANE_Word),
|
||||
s->opt[OPT_GAMMA_VECTOR_B].constraint.range->max,
|
||||
s->opt[OPT_GAMMA_VECTOR_B].constraint.range->max,
|
||||
s->dev->sensor.gamma[GENESYS_BLUE]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -7286,30 +7271,30 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
|
|||
table = (SANE_Word *) val;
|
||||
for (i = 0; i < s->opt[option].size / sizeof (SANE_Word); i++)
|
||||
{
|
||||
s->dev->sensor.red_gamma_table[i] = table[i];
|
||||
s->dev->sensor.green_gamma_table[i] = table[i];
|
||||
s->dev->sensor.blue_gamma_table[i] = table[i];
|
||||
s->dev->sensor.gamma_table[GENESYS_RED][i] = table[i];
|
||||
s->dev->sensor.gamma_table[GENESYS_GREEN][i] = table[i];
|
||||
s->dev->sensor.gamma_table[GENESYS_BLUE][i] = table[i];
|
||||
}
|
||||
break;
|
||||
case OPT_GAMMA_VECTOR_R:
|
||||
table = (SANE_Word *) val;
|
||||
for (i = 0; i < s->opt[option].size / sizeof (SANE_Word); i++)
|
||||
{
|
||||
s->dev->sensor.red_gamma_table[i] = table[i];
|
||||
s->dev->sensor.gamma_table[GENESYS_RED][i] = table[i];
|
||||
}
|
||||
break;
|
||||
case OPT_GAMMA_VECTOR_G:
|
||||
table = (SANE_Word *) val;
|
||||
for (i = 0; i < s->opt[option].size / sizeof (SANE_Word); i++)
|
||||
{
|
||||
s->dev->sensor.green_gamma_table[i] = table[i];
|
||||
s->dev->sensor.gamma_table[GENESYS_GREEN][i] = table[i];
|
||||
}
|
||||
break;
|
||||
case OPT_GAMMA_VECTOR_B:
|
||||
table = (SANE_Word *) val;
|
||||
for (i = 0; i < s->opt[option].size / sizeof (SANE_Word); i++)
|
||||
{
|
||||
s->dev->sensor.blue_gamma_table[i] = table[i];
|
||||
s->dev->sensor.gamma_table[GENESYS_BLUE][i] = table[i];
|
||||
}
|
||||
break;
|
||||
case OPT_CALIBRATE:
|
||||
|
|
|
@ -206,7 +206,8 @@ static Genesys_Frontend Wolfson[] = {
|
|||
*/
|
||||
static Genesys_Sensor Sensor[] = {
|
||||
/* 0: UMAX */
|
||||
{CCD_UMAX,1200, 48, 64, 0, 10800, 210, 230,
|
||||
{CCD_UMAX,
|
||||
1200, 48, 64, 0, 10800, 210, 230,
|
||||
{0x01, 0x03, 0x05, 0x07}
|
||||
,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x05, 0x31, 0x2a, 0x00, 0x00,
|
||||
|
@ -215,84 +216,69 @@ static Genesys_Sensor Sensor[] = {
|
|||
{0x13, 0x17, 0x03, 0x07, 0x0b, 0x0f, 0x23, 0x00, 0xc1, 0x00, 0x00, 0x00,
|
||||
0x00}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}}
|
||||
,
|
||||
/* 1: Plustek OpticPro S12/ST12 */
|
||||
{CCD_ST12,600, 48, 85, 152, 5416, 210, 230,
|
||||
{0x02, 0x00, 0x06, 0x04}
|
||||
,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x08, 0x20, 0x2a, 0x00, 0x00,
|
||||
0x0c, 0x03}
|
||||
,
|
||||
{0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0xc1, 0x00, 0x00, 0x00,
|
||||
0x00}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{CCD_ST12,
|
||||
600, 48, 85, 152, 5416, 210, 230,
|
||||
{0x02, 0x00, 0x06, 0x04} ,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x08, 0x20, 0x2a, 0x00, 0x00, 0x0c, 0x03} ,
|
||||
{0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00} ,
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* 2: Plustek OpticPro S24/ST24 */
|
||||
{CCD_ST24,1200, 48, 64, 0, 10800, 210, 230,
|
||||
{0x0e, 0x0c, 0x00, 0x0c}
|
||||
,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x08, 0x31, 0x2a, 0x00, 0x00,
|
||||
0x00, 0x02}
|
||||
,
|
||||
{0x17, 0x03, 0x07, 0x0b, 0x0f, 0x13, 0x03, 0x00, 0xc1, 0x00, 0x00, 0x00,
|
||||
0x00}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{CCD_ST24,
|
||||
1200,
|
||||
48, 64, 0, 10800, 210, 230,
|
||||
{0x0e, 0x0c, 0x00, 0x0c} ,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x08, 0x31, 0x2a, 0x00, 0x00, 0x00, 0x02} ,
|
||||
{0x17, 0x03, 0x07, 0x0b, 0x0f, 0x13, 0x03, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00} ,
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* 3: MD6471 */
|
||||
{CCD_5345,1200,
|
||||
{CCD_5345,
|
||||
1200,
|
||||
48,
|
||||
16, 0, 10872,
|
||||
190, 190,
|
||||
{0x0d, 0x0f, 0x11, 0x13}
|
||||
,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x0a, 0x30, 0x2a, 0x00, 0x00,
|
||||
0x00, 0x03}
|
||||
,
|
||||
{0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x23, 0x00, 0xc1, 0x00, 0x00, 0x00,
|
||||
0x00}
|
||||
,
|
||||
2.38, 2.35, 2.34,
|
||||
NULL, NULL, NULL}
|
||||
{0x0d, 0x0f, 0x11, 0x13} ,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x0a, 0x30, 0x2a, 0x00, 0x00, 0x00, 0x03} ,
|
||||
{0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x23, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00} ,
|
||||
{2.38, 2.35, 2.34},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* 4: HP2400c */
|
||||
{CCD_HP2400,1200,
|
||||
{CCD_HP2400,
|
||||
1200,
|
||||
48,
|
||||
15, 0, 10872, 210, 200,
|
||||
{0x14, 0x15, 0x00, 0x00} /* registers 0x08-0x0b */
|
||||
,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0x08, 0x3f, 0x2a, 0x00, 0x00,
|
||||
0x00, 0x02}
|
||||
,
|
||||
{0x0b, 0x0f, 0x13, 0x17, 0x03, 0x07, 0x63, 0x00, 0xc1, 0x00, 0x0e, 0x00,
|
||||
0x00}
|
||||
,
|
||||
2.1, 2.1, 2.1,
|
||||
NULL, NULL, NULL}
|
||||
{0x14, 0x15, 0x00, 0x00} /* registers 0x08-0x0b */ ,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0x08, 0x3f, 0x2a, 0x00, 0x00, 0x00, 0x02} ,
|
||||
{0x0b, 0x0f, 0x13, 0x17, 0x03, 0x07, 0x63, 0x00, 0xc1, 0x00, 0x0e, 0x00, 0x00} ,
|
||||
{2.1, 2.1, 2.1},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* 5: HP2300c */
|
||||
{CCD_HP2300,600,
|
||||
{CCD_HP2300,
|
||||
600,
|
||||
48,
|
||||
20, 0, 5368, 180, 180, /* 5376 */
|
||||
{0x16, 0x00, 0x01, 0x03}
|
||||
,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0x0a, 0x20, 0x2a, 0x6a, 0x8a,
|
||||
0x00, 0x05}
|
||||
,
|
||||
{0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0xc1, 0x06, 0x0b, 0x10,
|
||||
0x16}
|
||||
,
|
||||
2.1, 2.1, 2.1,
|
||||
NULL, NULL, NULL}
|
||||
{0x16, 0x00, 0x01, 0x03} ,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0x0a, 0x20, 0x2a, 0x6a, 0x8a, 0x00, 0x05} ,
|
||||
{0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0xc1, 0x06, 0x0b, 0x10, 0x16} ,
|
||||
{2.1, 2.1, 2.1},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* CANOLIDE35 */
|
||||
{CCD_CANONLIDE35, 1200,
|
||||
/*TODO: find a good reason for keeping all three following variables*/
|
||||
87, /*(black) */
|
||||
87, /* (dummy) */
|
||||
0, /* (startxoffset) */
|
||||
|
@ -310,23 +296,21 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x00, 0x00, 0x00, 0x00 /*TODO (these do no harm, but may be neccessery for CCD) */
|
||||
}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* 7: Strobe XP200 */
|
||||
{CIS_XP200, 600,
|
||||
5,
|
||||
38, 0, 5200, 200, 200, /* 5125 */
|
||||
{0x16, 0x00, 0x01, 0x03}
|
||||
{0x16, 0x00, 0x01, 0x03} ,
|
||||
{0x14, 0x50, 0x0c, 0x80, 0x0a, 0x28, 0xb7, 0x0a, 0x20, 0x2a, 0x6a, 0x8a, 0x00, 0x05} ,
|
||||
{0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0xc1, 0x06, 0x0b, 0x10, 0x16} ,
|
||||
{2.1, 2.1, 2.1},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
{0x14, 0x50, 0x0c, 0x80, 0x0a, 0x28, 0xb7, 0x0a, 0x20, 0x2a, 0x6a, 0x8a,
|
||||
0x00, 0x05}
|
||||
,
|
||||
{0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0xc1, 0x06, 0x0b, 0x10,
|
||||
0x16}
|
||||
,
|
||||
2.1, 2.1, 2.1,
|
||||
NULL, NULL, NULL},
|
||||
/* HP3670 */
|
||||
{CCD_HP3670,1200,
|
||||
48,
|
||||
|
@ -335,12 +319,12 @@ static Genesys_Sensor Sensor[] = {
|
|||
{0x00, 0x0a, 0x0b, 0x0d} ,
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x07, 0x20, 0x2a, 0x00, 0x00, 0xc0, 0x43} ,
|
||||
{0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0x15, 0x05, 0x0a, 0x0f, 0x00},
|
||||
1.00, 1.00, 1.00,
|
||||
NULL, NULL, NULL}
|
||||
{1.00, 1.00, 1.00},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* Syscan DP 665 */
|
||||
{CCD_DP665, 600,
|
||||
/*TODO: find a good reason for keeping all three following variables*/
|
||||
27, /*(black) */
|
||||
27, /* (dummy) */
|
||||
0, /* (startxoffset) */
|
||||
|
@ -358,12 +342,12 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */
|
||||
}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* Visioneer Roadwarrior */
|
||||
{CCD_ROADWARRIOR, 600,
|
||||
/*TODO: find a good reason for keeping all three following variables*/
|
||||
27, /*(black) */
|
||||
27, /* (dummy) */
|
||||
0, /* (startxoffset) */
|
||||
|
@ -381,12 +365,12 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */
|
||||
}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* Pentax DS Mobile 600 */
|
||||
{CCD_DSMOBILE600, 600,
|
||||
/*TODO: find a good reason for keeping all three following variables*/
|
||||
28, /*(black) */
|
||||
28, /* (dummy) */
|
||||
0, /* (startxoffset) */
|
||||
|
@ -404,9 +388,10 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */
|
||||
}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
,
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* 13: Strobe XP300 */
|
||||
{CCD_XP300, 600,
|
||||
27, /*(black) */
|
||||
|
@ -426,8 +411,9 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */
|
||||
}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* 13: Strobe XP300 */
|
||||
{CCD_DP685, 600,
|
||||
|
@ -448,8 +434,9 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x00, 0x00, 0x00, 0x01 /*TODO (these do no harm, but may be neccessery for CCD) */
|
||||
}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* CANONLIDE200 */
|
||||
{CIS_CANONLIDE200,
|
||||
|
@ -473,8 +460,9 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x41
|
||||
}
|
||||
,
|
||||
1.7, 1.7, 1.7,
|
||||
NULL, NULL, NULL}
|
||||
{1.7, 1.7, 1.7},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* CANONLIDE700 */
|
||||
{CIS_CANONLIDE700,
|
||||
|
@ -498,8 +486,9 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x41
|
||||
}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* CANONLIDE100 */
|
||||
{CIS_CANONLIDE100,
|
||||
|
@ -524,8 +513,9 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x41
|
||||
}
|
||||
,
|
||||
1.7, 1.7, 1.7,
|
||||
NULL, NULL, NULL}
|
||||
{1.7, 1.7, 1.7},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
{CCD_KVSS080,
|
||||
600,
|
||||
|
@ -541,8 +531,9 @@ static Genesys_Sensor Sensor[] = {
|
|||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x1c, 0x00, 0x2a, 0x2c, 0x00, 0x20, 0x04} , /* 18=00 at 600 dpi */
|
||||
/* 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e */
|
||||
{0x0c, 0x0f, 0x00, 0x03, 0x06, 0x09, 0x6b, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x23} ,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
{CCD_G4050,
|
||||
4800,
|
||||
|
@ -558,8 +549,9 @@ static Genesys_Sensor Sensor[] = {
|
|||
{0x2c, 0x09, 0x22, 0xb8, 0x10, 0xf0, 0x33, 0x0c, 0x00, 0x2a, 0x30, 0x00, 0x00, 0x08} ,
|
||||
/* 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e */
|
||||
{0x0b, 0x0e, 0x11, 0x02, 0x05, 0x08, 0x63, 0x00, 0x40, 0x00, 0x00, 0x00, 0x6f} ,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
{CCD_CS4400F,
|
||||
4800,
|
||||
|
@ -575,8 +567,9 @@ static Genesys_Sensor Sensor[] = {
|
|||
{0x9c, 0x40, 0x9c, 0x40, 0x9c, 0x40, 0x13, 0x0a, 0x10, 0x2a, 0x30, 0x00, 0x00, 0x6b},
|
||||
/* 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e */
|
||||
{0x0a, 0x0d, 0x00, 0x03, 0x06, 0x08, 0x5b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3f},
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
{CCD_CS8400F,
|
||||
4800,
|
||||
|
@ -592,8 +585,9 @@ static Genesys_Sensor Sensor[] = {
|
|||
{0x9c, 0x40, 0x9c, 0x40, 0x9c, 0x40, 0x13, 0x0a, 0x10, 0x2a, 0x30, 0x00, 0x00, 0x6b},
|
||||
/* 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e */
|
||||
{0x0a, 0x0d, 0x00, 0x03, 0x06, 0x08, 0x5b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3f},
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
/* HP N6310 */
|
||||
{CCD_HP_N6310,
|
||||
|
@ -610,9 +604,8 @@ static Genesys_Sensor Sensor[] = {
|
|||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x0c, 0x02, 0x2a, 0x30, 0x00, 0x00, 0x08} ,
|
||||
/* 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e */
|
||||
{0x0b, 0x0e, 0x11, 0x02, 0x05, 0x08, 0x63, 0x00, 0x40, 0x00, 0x00, 0x06, 0x6f} ,
|
||||
1.0, 1.0, 1.0,
|
||||
|
||||
NULL, NULL, NULL
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}
|
||||
}
|
||||
,
|
||||
|
||||
|
@ -622,7 +615,7 @@ static Genesys_Sensor Sensor[] = {
|
|||
87, /* black pixels */
|
||||
16, /* dummy pixels 16 */
|
||||
303, /* 303 */
|
||||
5168*4,
|
||||
5168*4, /* total pixels */
|
||||
210,
|
||||
200,
|
||||
{0x00, 0x00, 0x00, 0x00},
|
||||
|
@ -636,11 +629,11 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x1a, 0x00, 0xc0, 0x00, 0x00
|
||||
}
|
||||
,
|
||||
1.7, 1.7, 1.7,
|
||||
NULL, NULL, NULL}
|
||||
{2.1, 2.1, 2.1},
|
||||
{NULL, NULL, NULL}}
|
||||
,
|
||||
{CCD_PLUSTEK_3600, 1200,
|
||||
/*TODO: find a good reason for keeping all three following variables*/
|
||||
{CCD_PLUSTEK_3600,
|
||||
1200,
|
||||
87, /*(black) */
|
||||
87, /* (dummy) */
|
||||
0, /* (startxoffset) */
|
||||
|
@ -658,8 +651,8 @@ static Genesys_Sensor Sensor[] = {
|
|||
0x00, 0x00, 0x00, 0x02 /*TODO (these do no harm, but may be neccessery for CCD) */
|
||||
}
|
||||
,
|
||||
1.0, 1.0, 1.0,
|
||||
NULL, NULL, NULL}
|
||||
{1.0, 1.0, 1.0},
|
||||
{NULL, NULL, NULL}}
|
||||
,
|
||||
};
|
||||
|
||||
|
|
|
@ -2904,25 +2904,15 @@ gl124_send_shading_data (Genesys_Device * dev, uint8_t * data, int size)
|
|||
* @param generic flag for using generic gamma tables
|
||||
*/
|
||||
static SANE_Status
|
||||
gl124_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
||||
gl124_send_gamma_table (Genesys_Device * dev)
|
||||
{
|
||||
int size;
|
||||
int status;
|
||||
uint8_t *gamma, val;
|
||||
int i, gmmval;
|
||||
float gmm;
|
||||
int i;
|
||||
|
||||
DBG (DBG_proc, "gl124_send_gamma_table\n");
|
||||
|
||||
/* don't send anything if no specific gamma table defined */
|
||||
if (!generic
|
||||
&& (dev->sensor.red_gamma_table == NULL
|
||||
|| dev->sensor.green_gamma_table == NULL
|
||||
|| dev->sensor.blue_gamma_table == NULL))
|
||||
{
|
||||
DBG (DBG_proc, "gl124_send_gamma_table: nothing to send, skipping\n");
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
size = 256 + 1;
|
||||
|
||||
|
@ -2934,48 +2924,15 @@ gl124_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
|||
}
|
||||
memset(gamma, 255, size*3*2);
|
||||
|
||||
/* take care off generic/specific data */
|
||||
if (generic)
|
||||
{
|
||||
/* fill with default values built from device gamma */
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
gmm=dev->sensor.red_gamma;
|
||||
break;
|
||||
case 1:
|
||||
gmm=dev->sensor.green_gamma;
|
||||
break;
|
||||
case 2:
|
||||
gmm=dev->sensor.blue_gamma;
|
||||
break;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (gamma+i*size*2,
|
||||
size-1,
|
||||
65535,
|
||||
65535,
|
||||
gmm);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* copy sensor user defined gamma tables */
|
||||
/* copy sensor defined gamma tables */
|
||||
for (i = 0; i < size-1; i++)
|
||||
{
|
||||
gamma[i * 2 + size * 0 + 0] = dev->sensor.red_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + size * 0 + 1] =
|
||||
(dev->sensor.red_gamma_table[i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 2 + 0] =
|
||||
dev->sensor.green_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + size * 2 + 1] =
|
||||
(dev->sensor.green_gamma_table[i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 4 + 0] =
|
||||
dev->sensor.blue_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + size * 4 + 1] =
|
||||
(dev->sensor.blue_gamma_table[i] >> 8) & 0xff;
|
||||
}
|
||||
gamma[i * 2 + size * 0 + 0] = dev->sensor.gamma_table[GENESYS_RED][i] & 0xff;
|
||||
gamma[i * 2 + size * 0 + 1] = (dev->sensor.gamma_table[GENESYS_RED][i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 2 + 0] = dev->sensor.gamma_table[GENESYS_GREEN][i] & 0xff;
|
||||
gamma[i * 2 + size * 2 + 1] = (dev->sensor.gamma_table[GENESYS_GREEN][i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 4 + 0] = dev->sensor.gamma_table[GENESYS_BLUE][i] & 0xff;
|
||||
gamma[i * 2 + size * 4 + 1] = (dev->sensor.gamma_table[GENESYS_BLUE][i] >> 8) & 0xff;
|
||||
}
|
||||
|
||||
/* loop sending gamma tables NOTE: 0x01000000 not 0x10000000 */
|
||||
|
@ -2983,23 +2940,19 @@ gl124_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
|||
{
|
||||
/* clear corresponding GMM_N bit */
|
||||
RIE (sanei_genesys_read_register (dev, 0xbd, &val));
|
||||
/* val &= ~(0x01 << i); */
|
||||
val = 0x00;
|
||||
val &= ~(0x01 << i);
|
||||
RIE (sanei_genesys_write_register (dev, 0xbd, val));
|
||||
|
||||
/* clear corresponding GMM_F bit */
|
||||
RIE (sanei_genesys_read_register (dev, 0xbe, &val));
|
||||
/* val &= ~(0x01 << i); */
|
||||
val = 0x07;
|
||||
val &= ~(0x01 << i);
|
||||
RIE (sanei_genesys_write_register (dev, 0xbe, val));
|
||||
|
||||
/* set GMM_Z */
|
||||
RIE (sanei_genesys_write_register (dev, 0xc5+2*i, gamma[size*2*i+1]));
|
||||
RIE (sanei_genesys_write_register (dev, 0xc6+2*i, gamma[size*2*i]));
|
||||
|
||||
status =
|
||||
sanei_genesys_write_ahb (dev->dn, 0x01000000 + 0x200 * i, (size-1) * 2,
|
||||
gamma + i * size * 2+2);
|
||||
status = sanei_genesys_write_ahb (dev->dn, 0x01000000 + 0x200 * i, (size-1) * 2, gamma + i * size * 2+2);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
@ -3843,7 +3796,7 @@ gl124_init (Genesys_Device * dev)
|
|||
SANE_Status status;
|
||||
uint8_t val;
|
||||
SANE_Bool cold = SANE_TRUE;
|
||||
int size;
|
||||
int size, i;
|
||||
|
||||
DBG_INIT ();
|
||||
DBGSTART;
|
||||
|
@ -3896,9 +3849,9 @@ gl124_init (Genesys_Device * dev)
|
|||
/* now hardware part is OK, set up device struct */
|
||||
FREE_IFNOT_NULL (dev->white_average_data);
|
||||
FREE_IFNOT_NULL (dev->dark_average_data);
|
||||
FREE_IFNOT_NULL (dev->sensor.red_gamma_table);
|
||||
FREE_IFNOT_NULL (dev->sensor.green_gamma_table);
|
||||
FREE_IFNOT_NULL (dev->sensor.blue_gamma_table);
|
||||
FREE_IFNOT_NULL (dev->sensor.gamma_table[0]);
|
||||
FREE_IFNOT_NULL (dev->sensor.gamma_table[1]);
|
||||
FREE_IFNOT_NULL (dev->sensor.gamma_table[2]);
|
||||
|
||||
dev->settings.color_filter = 0;
|
||||
|
||||
|
@ -3910,42 +3863,24 @@ gl124_init (Genesys_Device * dev)
|
|||
|
||||
/* init gamma tables */
|
||||
size = 256;
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
dev->sensor.red_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl124_init: could not allocate memory for gamma table\n");
|
||||
"gl124_init: could not allocate memory for gamma table %d\n", i);
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.red_gamma_table, size,
|
||||
65535, 65535, dev->sensor.red_gamma);
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i],
|
||||
size,
|
||||
65535,
|
||||
65535,
|
||||
dev->sensor.gamma[i]);
|
||||
}
|
||||
if (dev->sensor.green_gamma_table == NULL)
|
||||
{
|
||||
dev->sensor.green_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl124_init: could not allocate memory for gamma table\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.green_gamma_table, size,
|
||||
65535, 65535,
|
||||
dev->sensor.green_gamma);
|
||||
}
|
||||
if (dev->sensor.blue_gamma_table == NULL)
|
||||
{
|
||||
dev->sensor.blue_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl124_init: could not allocate memory for gamma table\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.blue_gamma_table, size,
|
||||
65535, 65535, dev->sensor.blue_gamma);
|
||||
}
|
||||
|
||||
dev->oe_buffer.buffer = NULL;
|
||||
|
|
|
@ -3597,12 +3597,11 @@ setup_for_scan (Genesys_Device * dev, Genesys_Settings settings,
|
|||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* this function sends generic gamma table (ie linear ones)
|
||||
* or the Sensor specific one if provided
|
||||
/**
|
||||
* this function sen gamm table to ASIC
|
||||
*/
|
||||
static SANE_Status
|
||||
gl646_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
||||
gl646_send_gamma_table (Genesys_Device * dev)
|
||||
{
|
||||
int size;
|
||||
int address;
|
||||
|
@ -3610,15 +3609,7 @@ gl646_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
|||
uint8_t *gamma;
|
||||
int i;
|
||||
|
||||
/* don't send anything if no specific gamma table defined */
|
||||
if (!generic
|
||||
&& (dev->sensor.red_gamma_table == NULL
|
||||
|| dev->sensor.green_gamma_table == NULL
|
||||
|| dev->sensor.blue_gamma_table == NULL))
|
||||
{
|
||||
DBG (DBG_proc, "gl646_send_gamma_table: nothing to send, skipping\n");
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
DBGSTART;
|
||||
|
||||
/* gamma table size */
|
||||
if (dev->reg[reg_0x05].value & REG05_GMMTYPE)
|
||||
|
@ -3630,32 +3621,16 @@ gl646_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
|||
gamma = (uint8_t *) malloc (size * 2 * 3);
|
||||
if (!gamma)
|
||||
return SANE_STATUS_NO_MEM;
|
||||
/* take care off generic/specific data */
|
||||
if (generic)
|
||||
{
|
||||
/* fill with default values */
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
gamma[i * 2] = i & 0xff;
|
||||
gamma[i * 2 + 1] = i >> 8;
|
||||
gamma[i * 2 + size * 2] = i & 0xff;
|
||||
gamma[i * 2 + 1 + size * 2] = i >> 8;
|
||||
gamma[i * 2 + size * 4] = i & 0xff;
|
||||
gamma[i * 2 + 1 + size * 4] = i >> 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* copy sensor specific's gamma tables */
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
gamma[i * 2] = dev->sensor.red_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + 1] = dev->sensor.red_gamma_table[i] >> 8;
|
||||
gamma[i * 2 + size * 2] = dev->sensor.green_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + 1 + size * 2] = dev->sensor.green_gamma_table[i] >> 8;
|
||||
gamma[i * 2 + size * 4] = dev->sensor.blue_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + 1 + size * 4] = dev->sensor.blue_gamma_table[i] >> 8;
|
||||
}
|
||||
gamma[i * 2] = dev->sensor.gamma_table[GENESYS_RED][i] & 0xff;
|
||||
gamma[i * 2 + 1] = dev->sensor.gamma_table[GENESYS_RED][i] >> 8;
|
||||
gamma[i * 2 + size * 2] = dev->sensor.gamma_table[GENESYS_GREEN][i] & 0xff;
|
||||
gamma[i * 2 + 1 + size * 2] = dev->sensor.gamma_table[GENESYS_GREEN][i] >> 8;
|
||||
gamma[i * 2 + size * 4] = dev->sensor.gamma_table[GENESYS_BLUE][i] & 0xff;
|
||||
gamma[i * 2 + 1 + size * 4] = dev->sensor.gamma_table[GENESYS_BLUE][i] >> 8;
|
||||
}
|
||||
|
||||
/* table address */
|
||||
|
@ -3696,9 +3671,9 @@ gl646_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
|||
sane_strstatus (status));
|
||||
return status;
|
||||
}
|
||||
|
||||
DBG (DBG_proc, "gl646_send_gamma_table: end\n");
|
||||
free (gamma);
|
||||
|
||||
DBGCOMPLETED;
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
|
@ -4677,7 +4652,7 @@ gl646_init (Genesys_Device * dev)
|
|||
struct timeval tv;
|
||||
uint8_t cold = 0, val = 0;
|
||||
uint32_t addr = 0xdead;
|
||||
int size;
|
||||
int size, i;
|
||||
size_t len;
|
||||
|
||||
DBG_INIT ();
|
||||
|
@ -4734,44 +4709,22 @@ gl646_init (Genesys_Device * dev)
|
|||
else
|
||||
size = 4096;
|
||||
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
dev->sensor.red_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl646_init: could not allocate memory for gamma table\n");
|
||||
dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG (DBG_error, "gl646_init: could not allocate memory for gamma table %d\n",i);
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.red_gamma_table,
|
||||
size, size - 1, size - 1,
|
||||
dev->sensor.red_gamma);
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i],
|
||||
size,
|
||||
size - 1,
|
||||
size - 1,
|
||||
dev->sensor.gamma[i]);
|
||||
}
|
||||
if (dev->sensor.green_gamma_table == NULL)
|
||||
{
|
||||
dev->sensor.green_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl646_init: could not allocate memory for gamma table\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.green_gamma_table,
|
||||
size, size - 1, size - 1,
|
||||
dev->sensor.green_gamma);
|
||||
}
|
||||
if (dev->sensor.blue_gamma_table == NULL)
|
||||
{
|
||||
dev->sensor.blue_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl646_init: could not allocate memory for gamma table\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.blue_gamma_table,
|
||||
size, size - 1, size - 1,
|
||||
dev->sensor.blue_gamma);
|
||||
}
|
||||
|
||||
/* Init shading data */
|
||||
|
@ -4805,7 +4758,7 @@ gl646_init (Genesys_Device * dev)
|
|||
}
|
||||
|
||||
/* send gamma tables if needed */
|
||||
status = gl646_send_gamma_table (dev, 1);
|
||||
status = gl646_send_gamma_table (dev);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
|
|
|
@ -4140,25 +4140,14 @@ gl841_init_regs_for_scan (Genesys_Device * dev)
|
|||
* or the Sensor specific one if provided
|
||||
*/
|
||||
static SANE_Status
|
||||
gl841_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
||||
gl841_send_gamma_table (Genesys_Device * dev)
|
||||
{
|
||||
int size;
|
||||
int status;
|
||||
uint8_t *gamma;
|
||||
int i,gmmval;
|
||||
|
||||
DBG (DBG_proc, "gl841_send_gamma_table\n");
|
||||
|
||||
/* don't send anything if no specific gamma table defined */
|
||||
if (!generic
|
||||
&& (dev->sensor.red_gamma_table == NULL
|
||||
|| dev->sensor.green_gamma_table == NULL
|
||||
|| dev->sensor.blue_gamma_table == NULL))
|
||||
{
|
||||
DBG (DBG_proc,
|
||||
"gl841_send_gamma_table: nothing to send, skipping\n");
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
DBGSTART;
|
||||
|
||||
size = 256;
|
||||
|
||||
|
@ -4167,39 +4156,14 @@ gl841_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
|||
if (!gamma)
|
||||
return SANE_STATUS_NO_MEM;
|
||||
|
||||
/* take care off generic/specific data */
|
||||
if (generic)
|
||||
{
|
||||
/* fill with default values */
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
gmmval = i* 256;
|
||||
gamma[i*2 + size * 0 + 0] = gmmval & 0xff;
|
||||
gamma[i*2 + size * 0 + 1] = (gmmval >> 8) & 0xff;
|
||||
gamma[i*2 + size * 2 + 0] = gmmval & 0xff;
|
||||
gamma[i*2 + size * 2 + 1] = (gmmval >> 8) & 0xff;
|
||||
gamma[i*2 + size * 4 + 0] = gmmval & 0xff;
|
||||
gamma[i*2 + size * 4 + 1] = (gmmval >> 8) & 0xff;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* copy sensor specific's gamma tables */
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
gamma[i*2 + size * 0 + 0] =
|
||||
dev->sensor.red_gamma_table[i] & 0xff;
|
||||
gamma[i*2 + size * 0 + 1] =
|
||||
(dev->sensor.red_gamma_table[i] >> 8) & 0xff;
|
||||
gamma[i*2 + size * 2 + 0] =
|
||||
dev->sensor.green_gamma_table[i] & 0xff;
|
||||
gamma[i*2 + size * 2 + 1] =
|
||||
(dev->sensor.green_gamma_table[i] >> 8) & 0xff;
|
||||
gamma[i*2 + size * 4 + 0] =
|
||||
dev->sensor.blue_gamma_table[i] & 0xff;
|
||||
gamma[i*2 + size * 4 + 1] =
|
||||
(dev->sensor.blue_gamma_table[i] >> 8) & 0xff;
|
||||
}
|
||||
gamma[i*2 + size * 0 + 0] = dev->sensor.gamma_table[GENESYS_RED][i] & 0xff;
|
||||
gamma[i*2 + size * 0 + 1] = (dev->sensor.gamma_table[GENESYS_RED][i] >> 8) & 0xff;
|
||||
gamma[i*2 + size * 2 + 0] = dev->sensor.gamma_table[GENESYS_GREEN][i] & 0xff;
|
||||
gamma[i*2 + size * 2 + 1] = (dev->sensor.gamma_table[GENESYS_GREEN][i] >> 8) & 0xff;
|
||||
gamma[i*2 + size * 4 + 0] = dev->sensor.gamma_table[GENESYS_BLUE][i] & 0xff;
|
||||
gamma[i*2 + size * 4 + 1] = (dev->sensor.gamma_table[GENESYS_BLUE][i] >> 8) & 0xff;
|
||||
}
|
||||
|
||||
/* send address */
|
||||
|
@ -4214,9 +4178,7 @@ gl841_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
|||
}
|
||||
|
||||
/* send data */
|
||||
status =
|
||||
gl841_bulk_write_data_gamma (dev, 0x28, (uint8_t *) gamma,
|
||||
size * 2 * 3);
|
||||
status = gl841_bulk_write_data_gamma (dev, 0x28, (uint8_t *) gamma, size * 2 * 3);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
free (gamma);
|
||||
|
@ -4226,8 +4188,8 @@ gl841_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
|||
return status;
|
||||
}
|
||||
|
||||
DBG (DBG_proc, "gl841_send_gamma_table: completed\n");
|
||||
free (gamma);
|
||||
DBGCOMPLETED;
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
|
@ -5207,6 +5169,7 @@ gl841_init (Genesys_Device * dev)
|
|||
uint8_t val;
|
||||
size_t size;
|
||||
uint8_t *line;
|
||||
int i;
|
||||
|
||||
DBG_INIT ();
|
||||
DBG (DBG_proc, "gl841_init\n");
|
||||
|
@ -5272,54 +5235,34 @@ gl841_init (Genesys_Device * dev)
|
|||
}
|
||||
}
|
||||
|
||||
/* initalize sensor gamma tables */
|
||||
size = 256;
|
||||
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
dev->sensor.red_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl841_init: could not allocate memory for gamma table\n");
|
||||
"gl841_init: could not allocate memory for gamma table %d\n",i);
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.red_gamma_table, size,
|
||||
65535, 65535,
|
||||
dev->sensor.red_gamma);
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i],
|
||||
size,
|
||||
65535,
|
||||
65535,
|
||||
dev->sensor.gamma[i]);
|
||||
}
|
||||
if (dev->sensor.green_gamma_table == NULL)
|
||||
{
|
||||
dev->sensor.green_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl841_init: could not allocate memory for gamma table\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.green_gamma_table, size,
|
||||
65535, 65535,
|
||||
dev->sensor.green_gamma);
|
||||
}
|
||||
if (dev->sensor.blue_gamma_table == NULL)
|
||||
{
|
||||
dev->sensor.blue_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl841_init: could not allocate memory for gamma table\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.blue_gamma_table, size,
|
||||
65535, 65535,
|
||||
dev->sensor.blue_gamma);
|
||||
}
|
||||
|
||||
/* send gamma tables if needed */
|
||||
status = gl841_send_gamma_table (dev, 1);
|
||||
/* send gamma tables */
|
||||
status = gl841_send_gamma_table (dev);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl841_init: failed to send generic gamma tables: %s\n",
|
||||
"gl841_init: failed to send initial gamma tables: %s\n",
|
||||
sane_strstatus (status));
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -3166,29 +3166,18 @@ gl843_init_regs_for_scan (Genesys_Device * dev)
|
|||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
/*
|
||||
* this function sends generic gamma table (ie linear ones)
|
||||
* or the Sensor specific one if provided
|
||||
/**
|
||||
* This function sends gamma tables to ASIC
|
||||
*/
|
||||
static SANE_Status
|
||||
gl843_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
||||
gl843_send_gamma_table (Genesys_Device * dev)
|
||||
{
|
||||
int size;
|
||||
int status;
|
||||
uint8_t *gamma;
|
||||
int i, gmmval;
|
||||
|
||||
DBG (DBG_proc, "gl843_send_gamma_table\n");
|
||||
|
||||
/* don't send anything if no specific gamma table defined */
|
||||
if (!generic
|
||||
&& (dev->sensor.red_gamma_table == NULL
|
||||
|| dev->sensor.green_gamma_table == NULL
|
||||
|| dev->sensor.blue_gamma_table == NULL))
|
||||
{
|
||||
DBG (DBG_proc, "gl843_send_gamma_table: nothing to send, skipping\n");
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
DBGSTART;
|
||||
|
||||
size = 256;
|
||||
|
||||
|
@ -3197,38 +3186,15 @@ gl843_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
|||
if (!gamma)
|
||||
return SANE_STATUS_NO_MEM;
|
||||
|
||||
/* take care off generic/specific data */
|
||||
if (generic)
|
||||
{
|
||||
/* fill with default values */
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
gmmval = i * 256;
|
||||
gamma[i * 2 + size * 0 + 0] = gmmval & 0xff;
|
||||
gamma[i * 2 + size * 0 + 1] = (gmmval >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 2 + 0] = gmmval & 0xff;
|
||||
gamma[i * 2 + size * 2 + 1] = (gmmval >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 4 + 0] = gmmval & 0xff;
|
||||
gamma[i * 2 + size * 4 + 1] = (gmmval >> 8) & 0xff;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* copy sensor specific's gamma tables */
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
gamma[i * 2 + size * 0 + 0] = dev->sensor.red_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + size * 0 + 1] =
|
||||
(dev->sensor.red_gamma_table[i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 2 + 0] =
|
||||
dev->sensor.green_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + size * 2 + 1] =
|
||||
(dev->sensor.green_gamma_table[i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 4 + 0] =
|
||||
dev->sensor.blue_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + size * 4 + 1] =
|
||||
(dev->sensor.blue_gamma_table[i] >> 8) & 0xff;
|
||||
}
|
||||
gamma[i * 2 + size * 0 + 0] = dev->sensor.gamma_table[GENESYS_RED][i] & 0xff;
|
||||
gamma[i * 2 + size * 0 + 1] = (dev->sensor.gamma_table[GENESYS_RED][i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 2 + 0] = dev->sensor.gamma_table[GENESYS_GREEN][i] & 0xff;
|
||||
gamma[i * 2 + size * 2 + 1] = (dev->sensor.gamma_table[GENESYS_GREEN][i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 4 + 0] = dev->sensor.gamma_table[GENESYS_BLUE][i] & 0xff;
|
||||
gamma[i * 2 + size * 4 + 1] = (dev->sensor.gamma_table[GENESYS_BLUE][i] >> 8) & 0xff;
|
||||
}
|
||||
|
||||
/* send address */
|
||||
|
@ -4023,7 +3989,7 @@ gl843_init (Genesys_Device * dev)
|
|||
SANE_Status status;
|
||||
uint8_t val;
|
||||
SANE_Bool cold = SANE_TRUE;
|
||||
int size;
|
||||
int size, i;
|
||||
|
||||
DBG_INIT ();
|
||||
DBGSTART;
|
||||
|
@ -4085,9 +4051,9 @@ gl843_init (Genesys_Device * dev)
|
|||
/* now hardware part is OK, set up device struct */
|
||||
FREE_IFNOT_NULL (dev->white_average_data);
|
||||
FREE_IFNOT_NULL (dev->dark_average_data);
|
||||
FREE_IFNOT_NULL (dev->sensor.red_gamma_table);
|
||||
FREE_IFNOT_NULL (dev->sensor.green_gamma_table);
|
||||
FREE_IFNOT_NULL (dev->sensor.blue_gamma_table);
|
||||
FREE_IFNOT_NULL (dev->sensor.gamma_table[0]);
|
||||
FREE_IFNOT_NULL (dev->sensor.gamma_table[1]);
|
||||
FREE_IFNOT_NULL (dev->sensor.gamma_table[2]);
|
||||
|
||||
dev->settings.color_filter = 0;
|
||||
|
||||
|
@ -4098,38 +4064,22 @@ gl843_init (Genesys_Device * dev)
|
|||
|
||||
/* init gamma tables */
|
||||
size = 256;
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
dev->sensor.red_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl843_init: could not allocate memory for gamma table\n");
|
||||
dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG (DBG_error, "gl843_init: could not allocate memory for gamma table %d\n", i);
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.red_gamma_table, size, 65535, 65535, dev->sensor.red_gamma);
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i],
|
||||
size,
|
||||
65535,
|
||||
65535,
|
||||
dev->sensor.gamma[i]);
|
||||
}
|
||||
if (dev->sensor.green_gamma_table == NULL)
|
||||
{
|
||||
dev->sensor.green_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl843_init: could not allocate memory for gamma table\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.green_gamma_table, size, 65535, 65535, dev->sensor.green_gamma);
|
||||
}
|
||||
if (dev->sensor.blue_gamma_table == NULL)
|
||||
{
|
||||
dev->sensor.blue_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl843_init: could not allocate memory for gamma table\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.blue_gamma_table, size, 65535, 65535, dev->sensor.blue_gamma);
|
||||
}
|
||||
|
||||
dev->oe_buffer.buffer = NULL;
|
||||
|
|
|
@ -2031,7 +2031,7 @@ gl847_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
|
|||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl847_end_scan: Failed to stop: %s\n",
|
||||
"gl847_end_scan: failed to stop: %s\n",
|
||||
sane_strstatus (status));
|
||||
return status;
|
||||
}
|
||||
|
@ -2622,32 +2622,22 @@ gl847_init_regs_for_scan (Genesys_Device * dev)
|
|||
}
|
||||
|
||||
|
||||
/** @brief send gmma table to scanner
|
||||
* This function sends generic gamma table (ie ones built with
|
||||
/** @brief send gamma table to scanner
|
||||
* This function sends sensor gamma table (ie ones built with
|
||||
* provided gamma) or the user defined one if provided by
|
||||
* fontend.
|
||||
* @param dev device to write to
|
||||
* @param generic flag for using generic gamma tables
|
||||
*/
|
||||
static SANE_Status
|
||||
gl847_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
||||
gl847_send_gamma_table (Genesys_Device * dev)
|
||||
{
|
||||
int size;
|
||||
int status;
|
||||
uint8_t *gamma, val;
|
||||
int i, gmmval;
|
||||
|
||||
DBG (DBG_proc, "gl847_send_gamma_table\n");
|
||||
|
||||
/* don't send anything if no specific gamma table defined */
|
||||
if (!generic
|
||||
&& (dev->sensor.red_gamma_table == NULL
|
||||
|| dev->sensor.green_gamma_table == NULL
|
||||
|| dev->sensor.blue_gamma_table == NULL))
|
||||
{
|
||||
DBG (DBG_proc, "gl847_send_gamma_table: nothing to send, skipping\n");
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
DBGSTART;
|
||||
|
||||
size = 256;
|
||||
|
||||
|
@ -2656,38 +2646,15 @@ gl847_send_gamma_table (Genesys_Device * dev, SANE_Bool generic)
|
|||
if (!gamma)
|
||||
return SANE_STATUS_NO_MEM;
|
||||
|
||||
/* take care off generic/specific data */
|
||||
if (generic)
|
||||
{
|
||||
/* fill with default values */
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
gmmval = i * 256;
|
||||
gamma[i * 2 + size * 0 + 0] = gmmval & 0xff;
|
||||
gamma[i * 2 + size * 0 + 1] = (gmmval >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 2 + 0] = gmmval & 0xff;
|
||||
gamma[i * 2 + size * 2 + 1] = (gmmval >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 4 + 0] = gmmval & 0xff;
|
||||
gamma[i * 2 + size * 4 + 1] = (gmmval >> 8) & 0xff;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* copy sensor specific's gamma tables */
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
gamma[i * 2 + size * 0 + 0] = dev->sensor.red_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + size * 0 + 1] =
|
||||
(dev->sensor.red_gamma_table[i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 2 + 0] =
|
||||
dev->sensor.green_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + size * 2 + 1] =
|
||||
(dev->sensor.green_gamma_table[i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 4 + 0] =
|
||||
dev->sensor.blue_gamma_table[i] & 0xff;
|
||||
gamma[i * 2 + size * 4 + 1] =
|
||||
(dev->sensor.blue_gamma_table[i] >> 8) & 0xff;
|
||||
}
|
||||
gamma[i * 2 + size * 0 + 0] = dev->sensor.gamma_table[GENESYS_RED][i] & 0xff;
|
||||
gamma[i * 2 + size * 0 + 1] = (dev->sensor.gamma_table[GENESYS_RED][i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 2 + 0] = dev->sensor.gamma_table[GENESYS_GREEN][i] & 0xff;
|
||||
gamma[i * 2 + size * 2 + 1] = (dev->sensor.gamma_table[GENESYS_GREEN][i] >> 8) & 0xff;
|
||||
gamma[i * 2 + size * 4 + 0] = dev->sensor.gamma_table[GENESYS_BLUE][i] & 0xff;
|
||||
gamma[i * 2 + size * 4 + 1] = (dev->sensor.gamma_table[GENESYS_BLUE][i] >> 8) & 0xff;
|
||||
}
|
||||
|
||||
/* loop sending gamma tables NOTE: 0x01000000 not 0x10000000 */
|
||||
|
@ -3209,7 +3176,7 @@ gl847_init (Genesys_Device * dev)
|
|||
SANE_Status status;
|
||||
uint8_t val;
|
||||
SANE_Bool cold = SANE_TRUE;
|
||||
int size;
|
||||
int size, i;
|
||||
|
||||
DBG_INIT ();
|
||||
DBGSTART;
|
||||
|
@ -3254,9 +3221,9 @@ gl847_init (Genesys_Device * dev)
|
|||
/* now hardware part is OK, set up device struct */
|
||||
FREE_IFNOT_NULL (dev->white_average_data);
|
||||
FREE_IFNOT_NULL (dev->dark_average_data);
|
||||
FREE_IFNOT_NULL (dev->sensor.red_gamma_table);
|
||||
FREE_IFNOT_NULL (dev->sensor.green_gamma_table);
|
||||
FREE_IFNOT_NULL (dev->sensor.blue_gamma_table);
|
||||
FREE_IFNOT_NULL (dev->sensor.gamma_table[0]);
|
||||
FREE_IFNOT_NULL (dev->sensor.gamma_table[1]);
|
||||
FREE_IFNOT_NULL (dev->sensor.gamma_table[2]);
|
||||
|
||||
dev->settings.color_filter = 0;
|
||||
|
||||
|
@ -3265,42 +3232,22 @@ gl847_init (Genesys_Device * dev)
|
|||
|
||||
/* init gamma tables */
|
||||
size = 256;
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
dev->sensor.red_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl847_init: could not allocate memory for gamma table\n");
|
||||
dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG (DBG_error, "gl847_init: could not allocate memory for gamma table %d\n", i);
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.red_gamma_table, size,
|
||||
65535, 65535, dev->sensor.red_gamma);
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i],
|
||||
size,
|
||||
65535,
|
||||
65535,
|
||||
dev->sensor.gamma[i]);
|
||||
}
|
||||
if (dev->sensor.green_gamma_table == NULL)
|
||||
{
|
||||
dev->sensor.green_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl847_init: could not allocate memory for gamma table\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.green_gamma_table, size,
|
||||
65535, 65535,
|
||||
dev->sensor.green_gamma);
|
||||
}
|
||||
if (dev->sensor.blue_gamma_table == NULL)
|
||||
{
|
||||
dev->sensor.blue_gamma_table = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.red_gamma_table == NULL)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"gl847_init: could not allocate memory for gamma table\n");
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.blue_gamma_table, size,
|
||||
65535, 65535, dev->sensor.blue_gamma);
|
||||
}
|
||||
|
||||
dev->oe_buffer.buffer=NULL;
|
||||
|
|
|
@ -99,6 +99,10 @@
|
|||
#define DBGSTART DBG (DBG_proc, "%s start\n", __FUNCTION__);
|
||||
#define DBGCOMPLETED DBG (DBG_proc, "%s completed\n", __FUNCTION__);
|
||||
|
||||
#define GENESYS_RED 0
|
||||
#define GENESYS_GREEN 1
|
||||
#define GENESYS_BLUE 2
|
||||
|
||||
/* Flags */
|
||||
#define GENESYS_FLAG_UNTESTED (1 << 0) /**< Print a warning for these scanners */
|
||||
#define GENESYS_FLAG_14BIT_GAMMA (1 << 1) /**< use 14bit Gamma table instead of 12 */
|
||||
|
@ -235,12 +239,8 @@ typedef struct
|
|||
uint8_t regs_0x08_0x0b[4];
|
||||
uint8_t regs_0x10_0x1d[14];
|
||||
uint8_t regs_0x52_0x5e[13];
|
||||
float red_gamma;
|
||||
float green_gamma;
|
||||
float blue_gamma;
|
||||
uint16_t *red_gamma_table;
|
||||
uint16_t *green_gamma_table;
|
||||
uint16_t *blue_gamma_table;
|
||||
float gamma[3]; /**< red, green and blue gamma coefficient for default gamma tables */
|
||||
uint16_t *gamma_table[3]; /**< sensor specific gamma tables */
|
||||
} Genesys_Sensor;
|
||||
|
||||
typedef struct
|
||||
|
@ -443,7 +443,10 @@ typedef struct Genesys_Command_Set
|
|||
Genesys_Register_Set * regs,
|
||||
SANE_Bool check_stop);
|
||||
|
||||
SANE_Status (*send_gamma_table) (Genesys_Device * dev, SANE_Bool generic);
|
||||
/**
|
||||
* Send gamma tables to ASIC
|
||||
*/
|
||||
SANE_Status (*send_gamma_table) (Genesys_Device * dev);
|
||||
|
||||
SANE_Status (*search_start_position) (Genesys_Device * dev);
|
||||
SANE_Status (*offset_calibration) (Genesys_Device * dev);
|
||||
|
|
Ładowanie…
Reference in New Issue