Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d4xx: return hwmc error code to lrs sdk. #192

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions kernel/realsense/d4xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,8 @@ enum DS5_HWMC_ERR {
DS5_HWMC_ERR_CMD = -1,
DS5_HWMC_ERR_PARAM = -6,
DS5_HWMC_ERR_NODATA = -21,
DS5_HWMC_ERR_UNKNOWN = -64,
DS5_HWMC_ERR_LAST,
};

static int ds5_get_hwmc_status(struct ds5 *state)
Expand All @@ -1795,26 +1797,11 @@ static int ds5_get_hwmc_status(struct ds5 *state)
if (ret || status != DS5_HWMC_STATUS_OK) {
if (status == DS5_HWMC_STATUS_ERR) {
ds5_raw_read(state, DS5_HWMC_DATA, &errorCode, sizeof(errorCode));
switch(errorCode) {
case (DS5_HWMC_ERR_CMD):
case (DS5_HWMC_ERR_PARAM):
ret = -EBADMSG;
break;
case (DS5_HWMC_ERR_NODATA):
ret = -ENODATA;
break;

default:
dev_dbg(&state->client->dev,
"%s(): HWMC failed, ret: %d, status: %x, error code: %d\n",
__func__, ret, status, errorCode);
ret = -EBADMSG;
break;
}
return errorCode;
}
}
if (!ret && (status != DS5_HWMC_STATUS_OK))
ret = -EBUSY;
ret = DS5_HWMC_ERR_LAST;

return ret;
}
Expand All @@ -1834,7 +1821,13 @@ static int ds5_get_hwmc(struct ds5 *state, unsigned char *data,
dev_dbg(&state->client->dev,
"%s(): HWMC status not clear, ret: %d\n",
__func__, ret);
if (ret != DS5_HWMC_ERR_LAST) {
int *p = (int *)data;
*p = ret;
return 0;
} else {
return ret;
}
}

ret = regmap_raw_read(state->regmap, DS5_HWMC_RESP_LEN,
Expand Down Expand Up @@ -2534,10 +2527,6 @@ static int ds5_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
u16 dataLen = 0;
u16 bufLen = ctrl->dims[0];
ret = ds5_get_hwmc(state, data, bufLen, &dataLen);
if (ret) {
ret = 0; // LRS doesn't expect to get errors with HWMC
break;
}
/* This is needed for librealsense, to align there code with UVC,
* last word is length - 4 bytes header length */
dataLen -= 4;
Expand Down
Loading