Compare commits

..

3 Commits

Author SHA1 Message Date
mincrmatt12
4fa199aeb4 elan: Make 0c3d not rotate before assembling 2022-01-22 21:06:35 -05:00
mincrmatt12
5beac0ded7 elanspi: Try to avoid cancellation problems 2021-12-23 05:35:38 +00:00
mincrmatt12
7565562903 elanspi: Adjust register tables (fixes #438)
New values taken from a newer version of the official driver.
2021-12-22 00:20:57 -05:00
7 changed files with 66 additions and 42 deletions

View File

@@ -247,7 +247,6 @@ fpi_ssm_new_full
fpi_ssm_free fpi_ssm_free
fpi_ssm_start fpi_ssm_start
fpi_ssm_start_subsm fpi_ssm_start_subsm
fpi_ssm_set_critical
fpi_ssm_next_state fpi_ssm_next_state
fpi_ssm_next_state_delayed fpi_ssm_next_state_delayed
fpi_ssm_jump_to_state fpi_ssm_jump_to_state

View File

@@ -31,9 +31,10 @@
#define ELAN_0907 (1 << 0) #define ELAN_0907 (1 << 0)
#define ELAN_0C03 (1 << 1) #define ELAN_0C03 (1 << 1)
#define ELAN_0C42 (1 << 2) #define ELAN_0C42 (1 << 2)
#define ELAN_0C3D (1 << 3)
/* devices which don't require frame rotation before assembling */ /* devices which don't require frame rotation before assembling */
#define ELAN_NOT_ROTATED ELAN_0C03 #define ELAN_NOT_ROTATED (ELAN_0C03 | ELAN_0C3D)
/* min FW version that supports calibration */ /* min FW version that supports calibration */
#define ELAN_MIN_CALIBRATION_FW 0x0138 #define ELAN_MIN_CALIBRATION_FW 0x0138
@@ -213,7 +214,7 @@ static const FpIdEntry elan_id_table[] = {
{.vid = ELAN_VEND_ID, .pid = 0x0c31, .driver_data = ELAN_ALL_DEV}, {.vid = ELAN_VEND_ID, .pid = 0x0c31, .driver_data = ELAN_ALL_DEV},
{.vid = ELAN_VEND_ID, .pid = 0x0c32, .driver_data = ELAN_ALL_DEV}, {.vid = ELAN_VEND_ID, .pid = 0x0c32, .driver_data = ELAN_ALL_DEV},
{.vid = ELAN_VEND_ID, .pid = 0x0c33, .driver_data = ELAN_ALL_DEV}, {.vid = ELAN_VEND_ID, .pid = 0x0c33, .driver_data = ELAN_ALL_DEV},
{.vid = ELAN_VEND_ID, .pid = 0x0c3d, .driver_data = ELAN_ALL_DEV}, {.vid = ELAN_VEND_ID, .pid = 0x0c3d, .driver_data = ELAN_0C3D},
{.vid = ELAN_VEND_ID, .pid = 0x0c42, .driver_data = ELAN_0C42}, {.vid = ELAN_VEND_ID, .pid = 0x0c42, .driver_data = ELAN_0C42},
{.vid = ELAN_VEND_ID, .pid = 0x0c4d, .driver_data = ELAN_ALL_DEV}, {.vid = ELAN_VEND_ID, .pid = 0x0c4d, .driver_data = ELAN_ALL_DEV},
{.vid = ELAN_VEND_ID, .pid = 0x0c4f, .driver_data = ELAN_ALL_DEV}, {.vid = ELAN_VEND_ID, .pid = 0x0c4f, .driver_data = ELAN_ALL_DEV},

View File

@@ -434,9 +434,27 @@ elanspi_capture_old_line_handler (FpiSpiTransfer *transfer, FpDevice *dev, gpoin
self->old_data.line_ptr += 1; self->old_data.line_ptr += 1;
/* if there is still data, continue from check lineready */ /* if there is still data, continue from check lineready */
if (self->old_data.line_ptr < self->sensor_height) if (self->old_data.line_ptr < self->sensor_height)
{
fpi_ssm_jump_to_state (transfer->ssm, ELANSPI_CAPTOLD_CHECK_LINEREADY); fpi_ssm_jump_to_state (transfer->ssm, ELANSPI_CAPTOLD_CHECK_LINEREADY);
}
else else
{
/* check for termination */
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_NONE)
{
fpi_ssm_mark_completed (transfer->ssm); fpi_ssm_mark_completed (transfer->ssm);
return;
}
/* check for cancellation */
if (fpi_device_action_is_cancelled (dev))
{
g_cancellable_set_error_if_cancelled (fpi_device_get_cancellable (dev), &error);
fpi_ssm_mark_failed (transfer->ssm, error);
return;
}
/* otherwise finish succesfully */
fpi_ssm_mark_completed (transfer->ssm);
}
} }
static void static void
@@ -595,7 +613,6 @@ elanspi_calibrate_old_handler (FpiSsm *ssm, FpDevice *dev)
case ELANSPI_CALIBOLD_DACFINE_CAPTURE: case ELANSPI_CALIBOLD_DACFINE_CAPTURE:
chld = fpi_ssm_new (dev, elanspi_capture_old_handler, ELANSPI_CAPTOLD_NSTATES); chld = fpi_ssm_new (dev, elanspi_capture_old_handler, ELANSPI_CAPTOLD_NSTATES);
fpi_ssm_silence_debug (chld); fpi_ssm_silence_debug (chld);
fpi_ssm_set_critical (chld);
fpi_ssm_start_subsm (ssm, chld); fpi_ssm_start_subsm (ssm, chld);
return; return;
@@ -851,7 +868,6 @@ elanspi_calibrate_hv_handler (FpiSsm *ssm, FpDevice *dev)
case ELANSPI_CALIBHV_CAPTURE: case ELANSPI_CALIBHV_CAPTURE:
chld = fpi_ssm_new (dev, elanspi_capture_hv_handler, ELANSPI_CAPTHV_NSTATES); chld = fpi_ssm_new (dev, elanspi_capture_hv_handler, ELANSPI_CAPTHV_NSTATES);
fpi_ssm_silence_debug (chld); fpi_ssm_silence_debug (chld);
fpi_ssm_set_critical (chld);
fpi_ssm_start_subsm (ssm, chld); fpi_ssm_start_subsm (ssm, chld);
return; return;
@@ -1108,7 +1124,6 @@ do_sw_reset:
else else
chld = fpi_ssm_new_full (dev, elanspi_calibrate_old_handler, ELANSPI_CALIBOLD_NSTATES, ELANSPI_CALIBOLD_PROTECT, "old calibrate"); chld = fpi_ssm_new_full (dev, elanspi_calibrate_old_handler, ELANSPI_CALIBOLD_NSTATES, ELANSPI_CALIBOLD_PROTECT, "old calibrate");
fpi_ssm_silence_debug (chld); fpi_ssm_silence_debug (chld);
fpi_ssm_set_critical (chld);
fpi_ssm_start_subsm (ssm, chld); fpi_ssm_start_subsm (ssm, chld);
return; return;
@@ -1118,7 +1133,6 @@ do_sw_reset:
else else
chld = fpi_ssm_new (dev, elanspi_capture_old_handler, ELANSPI_CAPTOLD_NSTATES); chld = fpi_ssm_new (dev, elanspi_capture_old_handler, ELANSPI_CAPTOLD_NSTATES);
fpi_ssm_silence_debug (chld); fpi_ssm_silence_debug (chld);
fpi_ssm_set_critical (chld);
fpi_ssm_start_subsm (ssm, chld); fpi_ssm_start_subsm (ssm, chld);
return; return;
@@ -1478,11 +1492,12 @@ elanspi_fp_capture_ssm_handler (FpiSsm *ssm, FpDevice *dev)
if (self->deactivating) if (self->deactivating)
{ {
fp_dbg ("<capture> got deactivate; exiting"); fp_dbg ("<capture> got deactivate; exiting");
self->deactivating = FALSE;
fpi_ssm_mark_completed (ssm); fpi_ssm_mark_completed (ssm);
/* mark deactivate done */ /* mark deactivate done */
fpi_image_device_deactivate_complete (FP_IMAGE_DEVICE (dev), NULL); fpi_image_device_deactivate_complete (FP_IMAGE_DEVICE (dev), NULL);
self->deactivating = FALSE;
return; return;
} }
@@ -1492,7 +1507,6 @@ elanspi_fp_capture_ssm_handler (FpiSsm *ssm, FpDevice *dev)
else else
chld = fpi_ssm_new (dev, elanspi_capture_old_handler, ELANSPI_CAPTOLD_NSTATES); chld = fpi_ssm_new (dev, elanspi_capture_old_handler, ELANSPI_CAPTOLD_NSTATES);
fpi_ssm_silence_debug (chld); fpi_ssm_silence_debug (chld);
fpi_ssm_set_critical (chld);
fpi_ssm_start_subsm (ssm, chld); fpi_ssm_start_subsm (ssm, chld);
return; return;

View File

@@ -97,7 +97,37 @@ static const struct elanspi_reg_entry elanspi_calibration_table_default[] = {
{0xff, 0xff} {0xff, 0xff}
}; };
static const struct elanspi_reg_entry elanspi_calibration_table_id567[] = { static const struct elanspi_reg_entry elanspi_calibration_table_id6[] = {
{0x2A, 0x07},
{0x1, 0x00},
{0x2, 0x5f},
{0x3, 0x00},
{0x4, 0x5f},
{0x5, 0x60},
{0x6, 0xC0},
{0x7, 0x80},
{0x8, 0x04},
{0xA, 0x97},
{0xB, 0x72},
{0xC, 0x69},
{0xF, 0x2A},
{0x11, 0x2A},
{0x13, 0x27},
{0x15, 0x67},
{0x18, 0x04},
{0x21, 0x20},
{0x22, 0x36},
{0x29, 0x02},
{0x2A, 0x03},
{0x2A, 0x5F},
{0x2B, 0xC0},
{0x2C, 0x10},
{0x2E, 0xFF},
{0xff, 0xff}
};
static const struct elanspi_reg_entry elanspi_calibration_table_id57[] = {
{0x2A, 0x07}, {0x2A, 0x07},
{0x5, 0x60}, {0x5, 0x60},
{0x6, 0xC0}, {0x6, 0xC0},
@@ -143,9 +173,9 @@ static const struct elanspi_regtable elanspi_calibration_table_old = {
.other = elanspi_calibration_table_default, .other = elanspi_calibration_table_default,
.entries = { .entries = {
{ .sid = 0x0, .table = elanspi_calibration_table_id0 }, { .sid = 0x0, .table = elanspi_calibration_table_id0 },
{ .sid = 0x5, .table = elanspi_calibration_table_id567 }, { .sid = 0x5, .table = elanspi_calibration_table_id57 },
{ .sid = 0x6, .table = elanspi_calibration_table_id567 }, { .sid = 0x6, .table = elanspi_calibration_table_id6 },
{ .sid = 0x7, .table = elanspi_calibration_table_id567 }, { .sid = 0x7, .table = elanspi_calibration_table_id57 },
{ .sid = 0x0, .table = NULL } { .sid = 0x0, .table = NULL }
} }
}; };

View File

@@ -81,7 +81,6 @@ struct _FpiSsm
int start_cleanup; int start_cleanup;
int cur_state; int cur_state;
gboolean completed; gboolean completed;
gboolean critical;
gboolean silence; gboolean silence;
GSource *timeout; GSource *timeout;
GError *error; GError *error;
@@ -278,10 +277,6 @@ fpi_ssm_start (FpiSsm *ssm, FpiSsmCompletedCallback callback)
ssm->cur_state = 0; ssm->cur_state = 0;
ssm->completed = FALSE; ssm->completed = FALSE;
ssm->error = NULL; ssm->error = NULL;
if (ssm->critical)
fpi_device_critical_enter (ssm->dev);
__ssm_call_handler (ssm, TRUE); __ssm_call_handler (ssm, TRUE);
} }
@@ -371,10 +366,6 @@ fpi_ssm_mark_completed (FpiSsm *machine)
machine->callback (machine, machine->dev, error); machine->callback (machine, machine->dev, error);
} }
if (machine->critical)
fpi_device_critical_leave (machine->dev);
fpi_ssm_free (machine); fpi_ssm_free (machine);
} }
@@ -669,23 +660,6 @@ fpi_ssm_silence_debug (FpiSsm *machine)
machine->silence = TRUE; machine->silence = TRUE;
} }
/**
* fpi_ssm_set_critical:
* @machine: an #FpiSsm state machine
*
* Sets up the SSM to hold a critical section in the driver code. See
* fpi_device_critical_enter() for more details. This is useful if the SSM must
* not be interrupted in order to keep the device in a good state. You can e.g.
* guarantee that an image transfer is completed.
*
* This function must be called before starting the SSM.
*/
void
fpi_ssm_set_critical (FpiSsm *machine)
{
machine->critical = TRUE;
}
/** /**
* fpi_ssm_usb_transfer_cb: * fpi_ssm_usb_transfer_cb:
* @transfer: a #FpiUsbTransfer * @transfer: a #FpiUsbTransfer

View File

@@ -97,7 +97,6 @@ GError * fpi_ssm_dup_error (FpiSsm *machine);
int fpi_ssm_get_cur_state (FpiSsm *machine); int fpi_ssm_get_cur_state (FpiSsm *machine);
void fpi_ssm_silence_debug (FpiSsm *machine); void fpi_ssm_silence_debug (FpiSsm *machine);
void fpi_ssm_set_critical (FpiSsm *machine);
/* Callbacks to be used by the driver instead of implementing their own /* Callbacks to be used by the driver instead of implementing their own
* logic. * logic.

View File

@@ -24,6 +24,10 @@ TW 8c62
TW 805a TW 805a
TW 04 TW 04
TW aa07 TW aa07
TW 8100
TW 825f
TW 8300
TW 845f
TW 8560 TW 8560
TW 86c0 TW 86c0
TW 8780 TW 8780
@@ -38,8 +42,11 @@ TW 9567
TW 9804 TW 9804
TW a120 TW a120
TW a236 TW a236
TW a902
TW aa03
TW aa5f TW aa5f
TW abc0 TW abc0
TW ac10
TW aeff TW aeff
TW 01 TW 01
TW 03ff TW 03ff