aeslib: image assembly
All 3 authentec drivers now use a shared image assembly function.
This commit is contained in:
parent
e228f2c7da
commit
3479dee0e4
5 changed files with 33 additions and 44 deletions
|
@ -93,3 +93,18 @@ int aes_write_regv(struct fp_img_dev *dev, struct aes_regwrite *regs,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int aes_assemble_image(unsigned char *input, size_t width, size_t height,
|
||||||
|
unsigned char *output)
|
||||||
|
{
|
||||||
|
size_t frame_size = width * height;
|
||||||
|
size_t row, column;
|
||||||
|
|
||||||
|
for (column = 0; column < width; column++) {
|
||||||
|
for (row = 0; row < height; row += 2) {
|
||||||
|
output[width * row + column] = (*input & 0x07) * 36;
|
||||||
|
output[width * (row + 1) + column] = ((*input & 0x70) >> 4) * 36;
|
||||||
|
input++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,5 +30,8 @@ struct aes_regwrite {
|
||||||
int aes_write_regv(struct fp_img_dev *dev, struct aes_regwrite *regs,
|
int aes_write_regv(struct fp_img_dev *dev, struct aes_regwrite *regs,
|
||||||
unsigned int num);
|
unsigned int num);
|
||||||
|
|
||||||
|
int aes_assemble_image(unsigned char *input, size_t width, size_t height,
|
||||||
|
unsigned char *output);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -231,15 +231,8 @@ static unsigned int assemble(unsigned char *input, unsigned char *output,
|
||||||
if (reverse)
|
if (reverse)
|
||||||
output += (num_strips - 1) * FRAME_SIZE;
|
output += (num_strips - 1) * FRAME_SIZE;
|
||||||
for (frame = 0; frame < num_strips; frame++) {
|
for (frame = 0; frame < num_strips; frame++) {
|
||||||
int column;
|
aes_assemble_image(input, FRAME_WIDTH, FRAME_HEIGHT, output);
|
||||||
for (column = 0; column < FRAME_WIDTH; column++) {
|
input += FRAME_WIDTH * (FRAME_HEIGHT / 2);
|
||||||
int row;
|
|
||||||
for (row = 0; row < (FRAME_HEIGHT / 2); row++) {
|
|
||||||
output[FRAME_WIDTH * ( 2 * row) + column] = *input & 0x0F;
|
|
||||||
output[FRAME_WIDTH * ( 2 * row + 1) + column] = *input >> 4;
|
|
||||||
input++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reverse)
|
if (reverse)
|
||||||
output -= FRAME_SIZE;
|
output -= FRAME_SIZE;
|
||||||
|
@ -410,6 +403,7 @@ static int capture(struct fp_img_dev *dev, gboolean unconditional,
|
||||||
unsigned char *cooked;
|
unsigned char *cooked;
|
||||||
unsigned char *imgptr;
|
unsigned char *imgptr;
|
||||||
unsigned char buf[665];
|
unsigned char buf[665];
|
||||||
|
int final_size;
|
||||||
int sum;
|
int sum;
|
||||||
unsigned int count_blank = 0;
|
unsigned int count_blank = 0;
|
||||||
int i;
|
int i;
|
||||||
|
@ -511,10 +505,9 @@ static int capture(struct fp_img_dev *dev, gboolean unconditional,
|
||||||
fp_dbg("reversed scan direction");
|
fp_dbg("reversed scan direction");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < img->height * FRAME_WIDTH; i++)
|
final_size = img->height * FRAME_WIDTH;
|
||||||
img->data[i] = (cooked[i] << 4) | 0xf;
|
memcpy(img->data, cooked, final_size);
|
||||||
|
img = fpi_img_resize(img, final_size);
|
||||||
img = fpi_img_resize(img, img->height * FRAME_WIDTH);
|
|
||||||
*ret = img;
|
*ret = img;
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
|
|
|
@ -394,15 +394,8 @@ static unsigned int assemble(unsigned char *input, unsigned char *output,
|
||||||
if (reverse)
|
if (reverse)
|
||||||
output += (num_strips - 1) * FRAME_SIZE;
|
output += (num_strips - 1) * FRAME_SIZE;
|
||||||
for (frame = 0; frame < num_strips; frame++) {
|
for (frame = 0; frame < num_strips; frame++) {
|
||||||
int column;
|
aes_assemble_image(input, FRAME_WIDTH, FRAME_HEIGHT, output);
|
||||||
for (column = 0; column < FRAME_WIDTH; column++) {
|
input += FRAME_WIDTH * (FRAME_HEIGHT / 2);
|
||||||
int row;
|
|
||||||
for (row = 0; row < (FRAME_HEIGHT / 2); row++) {
|
|
||||||
output[FRAME_WIDTH * ( 2 * row) + column] = *input & 0x0F;
|
|
||||||
output[FRAME_WIDTH * ( 2 * row + 1) + column] = *input >> 4;
|
|
||||||
input++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reverse)
|
if (reverse)
|
||||||
output -= FRAME_SIZE;
|
output -= FRAME_SIZE;
|
||||||
|
@ -492,8 +485,8 @@ static int capture(struct fp_img_dev *dev, gboolean unconditional,
|
||||||
unsigned char *cooked;
|
unsigned char *cooked;
|
||||||
unsigned char *imgptr;
|
unsigned char *imgptr;
|
||||||
unsigned char buf[1705];
|
unsigned char buf[1705];
|
||||||
|
int final_size;
|
||||||
int sum;
|
int sum;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* FIXME can do better here in terms of buffer management? */
|
/* FIXME can do better here in terms of buffer management? */
|
||||||
fp_dbg("");
|
fp_dbg("");
|
||||||
|
@ -563,10 +556,9 @@ static int capture(struct fp_img_dev *dev, gboolean unconditional,
|
||||||
fp_dbg("reversed scan direction");
|
fp_dbg("reversed scan direction");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < img->height * FRAME_WIDTH; i++)
|
final_size = img->height * FRAME_WIDTH;
|
||||||
img->data[i] = (cooked[i] << 4) | 0xf;
|
memcpy(img->data, cooked, final_size);
|
||||||
|
img = fpi_img_resize(img, final_size);
|
||||||
img = fpi_img_resize(img, img->height * FRAME_WIDTH);
|
|
||||||
*ret = img;
|
*ret = img;
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
err:
|
||||||
|
|
|
@ -34,20 +34,6 @@
|
||||||
#define NR_SUBARRAYS 6
|
#define NR_SUBARRAYS 6
|
||||||
#define SUBARRAY_LEN 768
|
#define SUBARRAY_LEN 768
|
||||||
|
|
||||||
static void process_subarray(unsigned char *src, unsigned char *dst)
|
|
||||||
{
|
|
||||||
int col, row;
|
|
||||||
int offset = -1;
|
|
||||||
|
|
||||||
for (col = 95; col >= 0; col--) {
|
|
||||||
for (row = 15; row >= 0; row -= 2) {
|
|
||||||
unsigned char val = src[++offset];
|
|
||||||
dst[(row * 96) + col] = (val & 0x7) * 36;
|
|
||||||
dst[((row - 1) * 96) + col] = ((val & 0x70) >> 4) * 36;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct aes_regwrite init_reqs[] = {
|
static const struct aes_regwrite init_reqs[] = {
|
||||||
/* master reset */
|
/* master reset */
|
||||||
{ 0x80, 0x01 },
|
{ 0x80, 0x01 },
|
||||||
|
@ -156,14 +142,14 @@ retry:
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = NR_SUBARRAYS - 1; i >= 0; i--) {
|
for (i = 0; i < NR_SUBARRAYS; i++) {
|
||||||
fp_dbg("subarray header byte %02x", *ptr);
|
fp_dbg("subarray header byte %02x", *ptr);
|
||||||
ptr++;
|
ptr++;
|
||||||
process_subarray(ptr, img->data + (i * 96 * 16));
|
aes_assemble_image(ptr, 96, 16, img->data + (i * 96 * 16));
|
||||||
ptr += SUBARRAY_LEN;
|
ptr += SUBARRAY_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
img->flags = FP_IMG_COLORS_INVERTED;
|
img->flags = FP_IMG_COLORS_INVERTED | FP_IMG_V_FLIPPED | FP_IMG_H_FLIPPED;
|
||||||
*ret = img;
|
*ret = img;
|
||||||
g_free(data);
|
g_free(data);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue