kopia lustrzana https://gitlab.com/sane-project/backends
move specific gl843 shading function to genesys_gl843.c
rodzic
155bc33c62
commit
b05ca3c3f3
|
@ -2543,80 +2543,6 @@ compute_averaged_planar (Genesys_Device * dev,
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifndef UNIT_TESTING
|
||||
static
|
||||
#endif
|
||||
int
|
||||
compute_gl843_coefficients (Genesys_Device * dev,
|
||||
uint8_t ** shading_data,
|
||||
unsigned int pixels,
|
||||
unsigned int coeff,
|
||||
unsigned int target)
|
||||
{
|
||||
uint16_t *buffer = (uint16_t *) * shading_data, *darkptr, *whiteptr;
|
||||
int size;
|
||||
unsigned int i, count;
|
||||
uint16_t val;
|
||||
|
||||
darkptr = (uint16_t *) dev->dark_average_data;
|
||||
whiteptr = (uint16_t *) dev->white_average_data;
|
||||
|
||||
size = (pixels * 2 * 3 * 256) / 252 * 2 + 512;
|
||||
DBG (DBG_io, "%s: final shading size=%04x\n", __FUNCTION__, size);
|
||||
*shading_data = (uint8_t *) malloc (size);
|
||||
if (*shading_data == NULL)
|
||||
return 0;
|
||||
|
||||
memset(*shading_data,0,size);
|
||||
|
||||
/* offset */
|
||||
buffer = (uint16_t *)*shading_data;
|
||||
count = 0;
|
||||
|
||||
/* loop over calibration data to build shading coefficients */
|
||||
for (i = 0; i < pixels; i++)
|
||||
{
|
||||
/* red */
|
||||
*buffer = darkptr[3 * i];
|
||||
buffer++;
|
||||
count++;
|
||||
val =
|
||||
compute_coefficient (coeff, target, whiteptr[3 * i] - darkptr[3 * i]);
|
||||
*buffer = val;
|
||||
buffer++;
|
||||
count++;
|
||||
|
||||
/* green */
|
||||
*buffer = darkptr[3 * i + 1];
|
||||
buffer++;
|
||||
count++;
|
||||
val =
|
||||
compute_coefficient (coeff, target,
|
||||
whiteptr[3 * i + 1] - darkptr[3 * i + 1]);
|
||||
*buffer = val;
|
||||
buffer++;
|
||||
count++;
|
||||
|
||||
/* blue */
|
||||
*buffer = darkptr[3 * i + 2];
|
||||
buffer++;
|
||||
count++;
|
||||
val =
|
||||
compute_coefficient (coeff, target,
|
||||
whiteptr[3 * i + 2] - darkptr[3 * i + 2]);
|
||||
*buffer = val;
|
||||
buffer++;
|
||||
count++;
|
||||
|
||||
if ((count % 256) == 252)
|
||||
{
|
||||
buffer += 4;
|
||||
count += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes shading coefficient using formula in data sheet. 16bit data values
|
||||
|
@ -3060,10 +2986,13 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
|
|||
case CCD_KVSS080:
|
||||
case CCD_G4050:
|
||||
target_code = 0xf000;
|
||||
free(shading_data);
|
||||
length=compute_gl843_coefficients (dev,
|
||||
&shading_data,
|
||||
o = 0;
|
||||
compute_coefficients (dev,
|
||||
shading_data,
|
||||
pixels_per_line,
|
||||
3,
|
||||
cmat,
|
||||
o,
|
||||
coeff,
|
||||
target_code);
|
||||
break;
|
||||
|
|
|
@ -4049,6 +4049,70 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black)
|
|||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send shading calibration data. The buffer is considered to always hold values
|
||||
* for all the channels.
|
||||
*/
|
||||
#ifndef UNIT_TESTING
|
||||
static
|
||||
#endif
|
||||
SANE_Status
|
||||
gl843_send_shading_data (Genesys_Device * dev, uint8_t * data, int size)
|
||||
{
|
||||
SANE_Status status;
|
||||
int final_size;
|
||||
uint8_t *final_data;
|
||||
uint8_t *buffer;
|
||||
int i,count;
|
||||
|
||||
DBGSTART;
|
||||
|
||||
/* compute and allocate size for final data */
|
||||
final_size = (size / 252) * 256 + 512;
|
||||
DBG (DBG_io, "%s: final shading size=%04x\n", __FUNCTION__, final_size);
|
||||
final_data = (uint8_t *) malloc (final_size);
|
||||
if(final_data==NULL)
|
||||
{
|
||||
DBG (DBG_error, "%s: failed to allocate memory for shding data\n", __FUNCTION__);
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
|
||||
/* copy regular shading data to the expected layout */
|
||||
buffer = final_data;
|
||||
count = 0;
|
||||
|
||||
/* loop over calibration data */
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
buffer[count] = data[i];
|
||||
count++;
|
||||
if ((count % (256*2)) == (252*2))
|
||||
{
|
||||
count += 4*2;
|
||||
}
|
||||
}
|
||||
|
||||
/* send data */
|
||||
status = sanei_genesys_set_buffer_address (dev, 0);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error, "%s: failed to set buffer address: %s\n", __FUNCTION__, sane_strstatus (status));
|
||||
free(final_data);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = dev->model->cmd_set->bulk_write_data (dev, 0x3c, final_data, final_size);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error, "%s: failed to send shading table: %s\n", __FUNCTION__, sane_strstatus (status));
|
||||
}
|
||||
|
||||
free(final_data);
|
||||
DBGCOMPLETED;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/** the gl843 command set */
|
||||
static Genesys_Command_Set gl843_cmd_set = {
|
||||
"gl843-generic", /* the name of this set */
|
||||
|
@ -4102,7 +4166,7 @@ static Genesys_Command_Set gl843_cmd_set = {
|
|||
|
||||
sanei_genesys_is_compatible_calibration,
|
||||
NULL,
|
||||
NULL, /* gl843_send_shading_data */
|
||||
gl843_send_shading_data,
|
||||
gl843_calculate_current_setup
|
||||
};
|
||||
|
||||
|
|
|
@ -612,6 +612,11 @@ struct Genesys_Calibration_Cache
|
|||
struct Genesys_Calibration_Cache *next;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the current device status for the backend
|
||||
* session. This should be more accurately called
|
||||
* Genesys_Session .
|
||||
*/
|
||||
struct Genesys_Device
|
||||
{
|
||||
SANE_Int dn;
|
||||
|
|
Ładowanie…
Reference in New Issue