elan: Work-around sensors returning incorrect dimensions

The dimensions some sensors return is the maximum zero-based index
rather than the number of pixels. Assuming every sensor has an
even number of pixels is safe.
This commit is contained in:
Dave 2019-04-09 02:27:56 -04:00 committed by Bastien Nocera
parent 66461e4c81
commit b20a74a22c

View file

@ -755,6 +755,14 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
elandev->frame_height = elandev->raw_frame_height =
elandev->last_read[0];
}
/* Work-around sensors returning the sizes as zero-based index
* rather than the number of pixels. */
if ((elandev->frame_width % 2 == 1) &&
(elandev->frame_height % 2 == 1)) {
elandev->frame_width++;
elandev->frame_height++;
elandev->raw_frame_height = elandev->frame_height;
}
if (elandev->frame_height > ELAN_MAX_FRAME_HEIGHT)
elandev->frame_height = ELAN_MAX_FRAME_HEIGHT;
fp_dbg("sensor dimensions, WxH: %dx%d", elandev->frame_width,