Skip to content

Commit

Permalink
d4xx: return hwmc error code to lrs sdk.
Browse files Browse the repository at this point in the history
Align MIPI driver NOT_READY error to UVC flow

Tracked-by: <RSDSO-19622>

Signed-off-by: Dmitry Perchanov <[email protected]>
  • Loading branch information
dmipx committed Apr 1, 2024
1 parent 2a705b3 commit ec5ca71
Showing 1 changed file with 10 additions and 21 deletions.
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

0 comments on commit ec5ca71

Please sign in to comment.