Пример #1
0
//******************************************************************************
/// \brief Reopen sysfs MSG notify attribute
static void sysfs_reopen_notify_fd(struct mxt_device *mxt)
{
  uint16_t val;

  close(mxt->sysfs.debug_notify_fd);
  sysfs_open_notify_fd(mxt);
  read(mxt->sysfs.debug_notify_fd, &val, 2);
}
Пример #2
0
//******************************************************************************
/// \brief  Set debug state
/// \param  mxt Device context
/// \param  debug_state true = debug enabled, false = debug disabled
/// \return #mxt_rc
int sysfs_set_debug(struct mxt_device *mxt, bool debug_state)
{
  int ret;

  // Check device is initialised
  if (!mxt) {
    mxt_err(mxt->ctx, "Device uninitialised");
    return MXT_ERROR_NO_DEVICE;
  }

  if (mxt->sysfs.debug_v2 == true) {
    ret = write_boolean_file(mxt, make_path(mxt, "debug_v2_enable"), debug_state);
    if (ret)
      ret = write_boolean_file(mxt, make_path(mxt, "debug_enable"), debug_state);

    if (debug_state) {
      ret = sysfs_open_notify_fd(mxt);
      if (ret)
        return ret;
    } else {
      close(mxt->sysfs.debug_notify_fd);
    }
  } else {
    ret = MXT_SUCCESS;

    if (debug_state) {
      // Allocate buffer space
      mxt->sysfs.debug_msg_buf_size = dmesg_buf_size();
      mxt->sysfs.debug_msg_buf =
        (char *)calloc(mxt->sysfs.debug_msg_buf_size, sizeof(char));
      if (mxt->sysfs.debug_msg_buf == NULL) {
        mxt_err(mxt->ctx, "Error allocating memory for debug_msg_buf_size");
        ret = mxt_errno_to_rc(errno);
      }
    } else if (mxt->sysfs.debug_msg_buf) {
      // Free up the message buffer
      free(mxt->sysfs.debug_msg_buf);
      mxt->sysfs.debug_msg_buf = NULL;
    }

    if (ret == MXT_SUCCESS)
      ret = write_boolean_file(mxt, make_path(mxt, "debug_enable"), debug_state);
  }

  return ret;
}
Пример #3
0
//******************************************************************************
/// \brief  Set debug state
/// \param  mxt Device context
/// \param  debug_state true = debug enabled, false = debug disabled
/// \return #mxt_rc
int sysfs_set_debug(struct mxt_device *mxt, bool debug_state)
{
  int ret;

  // Check device is initialised
  if (!mxt) {
    mxt_err(mxt->ctx, "Device uninitialised");
    return MXT_ERROR_NO_DEVICE;
  }

  if (mxt->sysfs.debug_v2 == true) {
    ret = write_boolean_file(mxt, make_path(mxt, "debug_v2_enable"), debug_state);
    if (ret)
      ret = write_boolean_file(mxt, make_path(mxt, "debug_enable"), debug_state);

    if (debug_state) {
      ret = sysfs_open_notify_fd(mxt);
      if (ret)
        return ret;
    } else {
      close(mxt->sysfs.debug_notify_fd);
    }
  } else {
    if (debug_state) {
      ret = dmesg_alloc_buffer(mxt);
      if (ret)
        return ret;
    } else {
      dmesg_free_buffer(mxt);
    }

    ret = write_boolean_file(mxt, make_path(mxt, "debug_enable"), debug_state);
  }

  return ret;
}