return ret;
}
+
+SR_PRIV int cem_dt_885x_weight_time_get(const struct sr_dev_inst *sdi)
+{
+ struct dev_context *devc;
+ int cur_setting;
+ char tokens[5];
+
+ devc = sdi->priv;
+
+ cur_setting = devc->cur_mqflags & (SR_MQFLAG_SPL_TIME_WEIGHT_F | SR_MQFLAG_SPL_TIME_WEIGHT_S);
+ if (cur_setting == 0) {
+ /* Didn't pick up device state yet. */
+ tokens[0] = TOKEN_WEIGHT_TIME_FAST;
+ tokens[1] = TOKEN_WEIGHT_TIME_SLOW;
+ tokens[2] = -1;
+ if (wait_for_token(sdi, tokens, 0) != SR_OK)
+ return SR_ERR;
+ if (devc->token == TOKEN_WEIGHT_TIME_FAST)
+ return SR_MQFLAG_SPL_TIME_WEIGHT_F;
+ else
+ return SR_MQFLAG_SPL_TIME_WEIGHT_S;
+ } else
+ return cur_setting;
+
+}
+
+SR_PRIV int cem_dt_885x_weight_time_set(const struct sr_dev_inst *sdi, int timew)
+{
+ struct dev_context *devc;
+ int cur_setting, ret;
+ char tokens[5];
+
+ devc = sdi->priv;
+
+ cur_setting = devc->cur_mqflags & (SR_MQFLAG_SPL_TIME_WEIGHT_F | SR_MQFLAG_SPL_TIME_WEIGHT_S);
+ if (cur_setting == timew)
+ /* Already set to this time weighting. */
+ return SR_OK;
+
+ /* The toggle below needs the desired state in first position. */
+ if (timew == SR_MQFLAG_SPL_TIME_WEIGHT_F) {
+ tokens[0] = TOKEN_WEIGHT_TIME_FAST;
+ tokens[1] = TOKEN_WEIGHT_TIME_SLOW;
+ } else {
+ tokens[0] = TOKEN_WEIGHT_TIME_SLOW;
+ tokens[1] = TOKEN_WEIGHT_TIME_FAST;
+ }
+ tokens[2] = -1;
+
+ if (cur_setting == 0) {
+ /* Didn't pick up device state yet. */
+ if (wait_for_token(sdi, tokens, 0) != SR_OK)
+ return SR_ERR;
+ if (devc->token == tokens[0])
+ /* Nothing to do. */
+ return SR_OK;
+ }
+
+ /* 51ms timeout seems to work best for this. */
+ ret = cem_dt_885x_toggle(sdi, CMD_TOGGLE_WEIGHT_TIME, tokens, 51);
+
+ return ret;
+}