Skip to content

Commit

Permalink
[datapipe] Make cache control property of datapipe. JB#22475
Browse files Browse the repository at this point in the history
While in thery it might be useful to be able to control datapipe
caching with every exec call, in practice the extra parameter just
makes things look more complicated and errors are extremely difficult
to spot.

Define caching policy for each datapipe on initialization, and drop the
cache control parameter from datapipe_exec_full() function.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Sep 19, 2018
1 parent 1bbed44 commit c70ea98
Show file tree
Hide file tree
Showing 29 changed files with 256 additions and 443 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -290,6 +290,7 @@ MCE_CFLAGS += $(MCE_PKG_CFLAGS)
MCE_LDLIBS += $(MCE_PKG_LDLIBS)

# These must be made callable from the plugins
MCE_CORE += datapipe.c
MCE_CORE += tklock.c
MCE_CORE += modetransition.c
MCE_CORE += powerkey.c
Expand All @@ -308,7 +309,6 @@ MCE_CORE += mce-hal.c
MCE_CORE += mce-log.c
MCE_CORE += mce-command-line.c
MCE_CORE += mce-conf.c
MCE_CORE += datapipe.c
MCE_CORE += mce-modules.c
MCE_CORE += multitouch.c
MCE_CORE += mce-io.c
Expand Down
261 changes: 101 additions & 160 deletions datapipe.c

Large diffs are not rendered by default.

44 changes: 23 additions & 21 deletions datapipe.h
Expand Up @@ -43,22 +43,6 @@ typedef enum

const char *devicelock_state_repr(devicelock_state_t state);

/**
* Datapipe structure
*
* Only access this struct through the functions
*/
typedef struct {
const char *dp_name; /**< Name of the datapipe */
GSList *dp_filters; /**< The filters */
GSList *dp_input_triggers; /**< Triggers called on indata */
GSList *dp_output_triggers; /**< Triggers called on outdata */
gpointer dp_cached_data; /**< Latest cached data */
gsize dp_datasize; /**< Size of data; NULL == automagic */
gboolean dp_free_cache; /**< Free the cache? */
gboolean dp_read_only; /**< Datapipe is read only */
} datapipe_t;

/**
* Read only policy type
*/
Expand All @@ -74,8 +58,28 @@ typedef enum {
DATAPIPE_CACHE_NOTHING = 0, /**< Do not cache the indata */
DATAPIPE_CACHE_INDATA = 1<<0, /**< Cache the unfiltered indata */
DATAPIPE_CACHE_OUTDATA = 1<<1, /**< Cache the filtered outdata */

DATAPIPE_CACHE_DEFAULT = (DATAPIPE_CACHE_INDATA |
DATAPIPE_CACHE_OUTDATA),
} datapipe_cache_t;

/**
* Datapipe structure
*
* Only access this struct through the functions
*/
typedef struct {
const char *dp_name; /**< Name of the datapipe */
GSList *dp_filters; /**< The filters */
GSList *dp_input_triggers; /**< Triggers called on indata */
GSList *dp_output_triggers; /**< Triggers called on outdata */
gpointer dp_cached_data; /**< Latest cached data */
gsize dp_datasize; /**< Size of data; NULL == automagic */

datapipe_filtering_t dp_read_only; /**< Datapipe is read only */
datapipe_cache_t dp_cache;
} datapipe_t;

typedef struct
{
datapipe_t *datapipe;
Expand Down Expand Up @@ -103,7 +107,7 @@ typedef struct
const char *datapipe_name (datapipe_t *const datapipe);
gpointer datapipe_value (datapipe_t *const datapipe);
void datapipe_exec_output_triggers(const datapipe_t *const datapipe, gconstpointer indata);
gconstpointer datapipe_exec_full (datapipe_t *const datapipe, gpointer indata, const datapipe_cache_t cache_indata);
gconstpointer datapipe_exec_full (datapipe_t *const datapipe, gpointer indata);

/* ------------------------------------------------------------------------- *
* MCE_DATAPIPE
Expand Down Expand Up @@ -152,8 +156,7 @@ void mce_datapipe_quit_bindings (datapipe_bindings_t *self);
* else might be already queued up and we want't the \
* last request to reach the queue to "win". */ \
datapipe_exec_full(&display_state_request_pipe,\
GINT_TO_POINTER(req_target),\
DATAPIPE_CACHE_OUTDATA);\
GINT_TO_POINTER(req_target));\
} while(0)

/** Execute tklock request
Expand All @@ -164,8 +167,7 @@ void mce_datapipe_quit_bindings (datapipe_bindings_t *self);
mce_log(LL_DEBUG, "Requesting tklock=%s",\
tklock_request_repr(tklock_request));\
datapipe_exec_full(&tklock_request_pipe,\
GINT_TO_POINTER(tklock_request),\
DATAPIPE_CACHE_INDATA);\
GINT_TO_POINTER(tklock_request));\
}while(0)

/* ========================================================================= *
Expand Down
60 changes: 20 additions & 40 deletions event-input.c
Expand Up @@ -1922,8 +1922,7 @@ evin_iomon_generate_activity(struct input_event *ev, bool cooked, bool raw)
if( t_cooked != t || (submode & MCE_SUBMODE_EVEATER) ) {
t_cooked = t;
datapipe_exec_full(&inactivity_event_pipe,
GINT_TO_POINTER(FALSE),
DATAPIPE_CACHE_OUTDATA);
GINT_TO_POINTER(FALSE));
}
}

Expand Down Expand Up @@ -2075,14 +2074,12 @@ evin_iomon_touchscreen_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
evin_iomon_generate_activity(ev, false, true);

/* But otherwise are handled in powerkey.c. */
datapipe_exec_full(&keypress_event_pipe, &ev,
DATAPIPE_CACHE_NOTHING);
datapipe_exec_full(&keypress_event_pipe, &ev);
}
else if( (ev->type == EV_ABS && ev->code == ABS_PRESSURE) ||
(ev->type == EV_KEY && ev->code == BTN_TOUCH ) ) {
/* Only send pressure events */
datapipe_exec_full(&touchscreen_event_pipe, &ev,
DATAPIPE_CACHE_NOTHING);
datapipe_exec_full(&touchscreen_event_pipe, &ev);
}

EXIT:
Expand Down Expand Up @@ -2169,8 +2166,7 @@ evin_iomon_keypress_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
key_state_t key_state = ev->value ?
KEY_STATE_PRESSED : KEY_STATE_RELEASED;
datapipe_exec_full(&lockkey_state_pipe,
GINT_TO_POINTER(key_state),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(key_state));
}

/* For now there's no reason to cache the keypress
Expand All @@ -2191,8 +2187,7 @@ evin_iomon_keypress_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
((((submode & MCE_SUBMODE_EVEATER) == 0) &&
(ev->value == 1)) || (ev->value == 0))) &&
((submode & MCE_SUBMODE_PROXIMITY_TKLOCK) == 0)) {
datapipe_exec_full(&keypress_event_pipe, &ev,
DATAPIPE_CACHE_NOTHING);
datapipe_exec_full(&keypress_event_pipe, &ev);
}
}

Expand All @@ -2203,8 +2198,7 @@ evin_iomon_keypress_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
cover_state_t cover_state = ev->value ?
COVER_CLOSED : COVER_OPEN;
datapipe_exec_full(&lens_cover_state_pipe,
GINT_TO_POINTER(cover_state),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(cover_state));
}

/* Don't generate activity on COVER_CLOSED */
Expand All @@ -2218,8 +2212,7 @@ evin_iomon_keypress_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
cover_state_t cover_state = ev->value ?
COVER_CLOSED : COVER_OPEN;
datapipe_exec_full(&keyboard_slide_state_pipe,
GINT_TO_POINTER(cover_state),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(cover_state));
evin_iomon_keyboard_state_update();
}

Expand All @@ -2234,8 +2227,7 @@ evin_iomon_keypress_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
cover_state_t cover_state = ev->value ?
COVER_CLOSED : COVER_OPEN;
datapipe_exec_full(&proximity_sensor_actual_pipe,
GINT_TO_POINTER(cover_state),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(cover_state));
}

break;
Expand All @@ -2248,8 +2240,7 @@ evin_iomon_keypress_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
cover_state_t cover_state = ev->value ?
COVER_CLOSED : COVER_OPEN;
datapipe_exec_full(&jack_sense_state_pipe,
GINT_TO_POINTER(cover_state),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(cover_state));
}

break;
Expand All @@ -2259,13 +2250,11 @@ evin_iomon_keypress_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
* same datapipe as N770 sliding cover uses */
if( ev->value ) {
datapipe_exec_full(&lid_sensor_actual_pipe,
GINT_TO_POINTER(COVER_CLOSED),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(COVER_CLOSED));
}
else {
datapipe_exec_full(&lid_sensor_actual_pipe,
GINT_TO_POINTER(COVER_OPEN),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(COVER_OPEN));
}
break;

Expand Down Expand Up @@ -2519,24 +2508,21 @@ evin_iomon_switch_states_update_iter_cb(gpointer io_monitor, gpointer user_data)
ecode = evin_event_mapper_rlookup_switch(SW_CAMERA_LENS_COVER);
if( test_bit(ecode, featurelist) ) {
state = test_bit(ecode, statelist) ? COVER_CLOSED : COVER_OPEN;
datapipe_exec_full(&lens_cover_state_pipe, GINT_TO_POINTER(state),
DATAPIPE_CACHE_INDATA);
datapipe_exec_full(&lens_cover_state_pipe, GINT_TO_POINTER(state));
}

/* Check initial keypad slide state */
ecode = evin_event_mapper_rlookup_switch(SW_KEYPAD_SLIDE);
if( test_bit(ecode, featurelist) ) {
state = test_bit(ecode, statelist) ? COVER_CLOSED : COVER_OPEN;
datapipe_exec_full(&keyboard_slide_state_pipe, GINT_TO_POINTER(state),
DATAPIPE_CACHE_INDATA);
datapipe_exec_full(&keyboard_slide_state_pipe, GINT_TO_POINTER(state));
}

/* Check initial front proximity state */
ecode = evin_event_mapper_rlookup_switch(SW_FRONT_PROXIMITY);
if( test_bit(ecode, featurelist) ) {
state = test_bit(ecode, statelist) ? COVER_CLOSED : COVER_OPEN;
datapipe_exec_full(&proximity_sensor_actual_pipe, GINT_TO_POINTER(state),
DATAPIPE_CACHE_INDATA);
datapipe_exec_full(&proximity_sensor_actual_pipe, GINT_TO_POINTER(state));
}

/* Check initial lid sensor state */
Expand All @@ -2545,8 +2531,7 @@ evin_iomon_switch_states_update_iter_cb(gpointer io_monitor, gpointer user_data)
state = test_bit(ecode, statelist) ? COVER_CLOSED : COVER_OPEN;
mce_log(LL_DEVEL, "SW_LID initial state = %s",
cover_state_repr(state));
datapipe_exec_full(&lid_sensor_actual_pipe, GINT_TO_POINTER(state),
DATAPIPE_CACHE_INDATA);
datapipe_exec_full(&lid_sensor_actual_pipe, GINT_TO_POINTER(state));
}

/* Need to consider more than one switch state when setting the
Expand All @@ -2573,8 +2558,7 @@ evin_iomon_switch_states_update_iter_cb(gpointer io_monitor, gpointer user_data)

if( have ) {
state = value ? COVER_CLOSED : COVER_OPEN;
datapipe_exec_full(&jack_sense_state_pipe, GINT_TO_POINTER(state),
DATAPIPE_CACHE_INDATA);
datapipe_exec_full(&jack_sense_state_pipe, GINT_TO_POINTER(state));
}

EXIT:
Expand Down Expand Up @@ -2690,8 +2674,7 @@ evin_iomon_keyboard_state_update(void)
cover_state_t state = available ? COVER_OPEN : COVER_CLOSED;

datapipe_exec_full(&keyboard_available_state_pipe,
GINT_TO_POINTER(state),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(state));
}

/** Scan /dev/input for input event devices
Expand Down Expand Up @@ -2923,8 +2906,7 @@ evin_touchstate_update_cb(gpointer aptr)

mce_log(LL_DEBUG, "touch_detected=%s", touching ? "true" : "false");
datapipe_exec_full(&touch_detected_pipe,
GINT_TO_POINTER(touching),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(touching));

EXIT:
return FALSE;
Expand Down Expand Up @@ -3306,8 +3288,7 @@ evin_ts_grab_set_active(gboolean grab)

// STATE MACHINE -> OUTPUT DATAPIPE
datapipe_exec_full(&touch_grab_active_pipe,
GINT_TO_POINTER(grab),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(grab));

EXIT:
return;
Expand Down Expand Up @@ -3561,8 +3542,7 @@ evin_kp_grab_set_active(gboolean grab)

// STATE MACHINE -> OUTPUT DATAPIPE
datapipe_exec_full(&keypad_grab_active_pipe,
GINT_TO_POINTER(grab),
DATAPIPE_CACHE_INDATA);
GINT_TO_POINTER(grab));

EXIT:
return;
Expand Down

0 comments on commit c70ea98

Please sign in to comment.