diff --git a/include/platform/mipi_dsi_if.h b/include/platform/mipi_dsi_if.h
index 9e173de593c618793bed9d4e1ef47c8ab271c6da..ca6b5d6cb2a7601f1da624ae93a05707c1f830a3 100644
--- a/include/platform/mipi_dsi_if.h
+++ b/include/platform/mipi_dsi_if.h
@@ -210,6 +210,7 @@ DevHandle MipiDsiOpen(uint8_t id);
* @since 1.0
*/
void MipiDsiClose(DevHandle handle);
+
/**
* @brief Sets configuration parameters for a MIPI DSI device.
*
@@ -278,6 +279,18 @@ int32_t MipiDsiTx(DevHandle handle, struct DsiCmdDesc *cmd);
*/
int32_t MipiDsiRx(DevHandle handle, struct DsiCmdDesc *cmd, int32_t readLen, uint8_t *out);
+/**
+* @brief attach a DSI device to its DSI host
+ *
+ * @param handle Indicates the MIPI DSI device handle obtained via {@link MipiDsiOpen}.
+ * @param name Indicates the name of a peripheral.
+ *
+ * @return Returns 0 if the operation is successful; returns a negative value otherwise.
+ *
+ * @since 1.0
+ */
+int32_t MipiDsiAttach(DevHandle handle, uint8_t *name);
+
#ifdef __cplusplus
#if __cplusplus
}
diff --git a/support/platform/include/mipi_dsi_core.h b/support/platform/include/mipi_dsi_core.h
index 268c6d1779402be365b14cf98d0daacd992156d9..58fa709c06ba7f29e57548c84d4332abf7b74729 100644
--- a/support/platform/include/mipi_dsi_core.h
+++ b/support/platform/include/mipi_dsi_core.h
@@ -26,14 +26,16 @@ extern "C" {
#define MAX_CNTLR_CNT 4
struct MipiDsiCntlr {
- unsigned int devNo; /* device number */
- enum DsiLane lane;
- enum DsiMode mode;
- enum DsiBurstMode burstMode;
- enum DsiOutFormat format;
- struct DsiTimingInfo timing;
- unsigned int phyDataRate; /* mbps */
- unsigned int pixelClk; /* KHz */
+ struct IDeviceIoService service;
+ struct HdfDeviceObject *device;
+ unsigned int devNo; /* device number */
+ struct MipiCfg cfg;
+ struct MipiDsiCntlrMethod *ops;
+ struct OsalMutex lock;
+ void *priv; /* be struct mipi_dsi_device */
+};
+
+struct MipiDsiCntlrMethod {
int32_t (*setCntlrCfg)(struct MipiDsiCntlr *cntlr);
int32_t (*setCmd)(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *cmd);
int32_t (*getCmd)(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *cmd, uint32_t readLen, uint8_t *out);
@@ -42,14 +44,121 @@ struct MipiDsiCntlr {
void (*enterUlps)(struct MipiDsiCntlr *cntlr);
void (*exitUlps)(struct MipiDsiCntlr *cntlr);
int32_t (*powerControl)(struct MipiDsiCntlr *cntlr, uint8_t enable);
+ int32_t (*attach)(struct MipiDsiCntlr *cntlr, uint8_t *name);
};
-struct MipiDsiHandle {
- struct MipiDsiCntlr *cntlr;
- struct OsalMutex lock;
-};
+int32_t MipiDsiRegisterCntlr(struct MipiDsiCntlr *cntlr, struct HdfDeviceObject *device);
+void MipiDsiUnregisterCntlr(struct MipiDsiCntlr *cntlr);
+
+/**
+ * @brief Turn HdfDeviceObject to an MipiDsiCntlr.
+ *
+ * @param device Indicates a HdfDeviceObject.
+ *
+ * @return Retrns the pointer of the MipiDsiCntlr on success; returns NULL otherwise.
+ * @since 1.0
+ */
+struct MipiDsiCntlr *MipiDsiCntlrFromDevice(struct HdfDeviceObject *device);
+
+/**
+ * @brief Obtains the MIPI DSI device handle with a specified channel ID.
+ *
+ * @param id Indicates the MIPI DSI channel ID.
+ *
+ * @return Returns the MIPI DSI device if the operation is successful; returns NULL otherwise.
+ *
+ * @since 1.0
+ */
+struct MipiDsiCntlr *MipiDsiCntlrOpen(uint8_t id);
+
+/**
+ * @brief Releases the MIPI DSI device handle.
+ *
+ * @param cntlr Indicates the MIPI DSI device obtained via {@link MipiDsiOpen}.
+ *
+ * @since 1.0
+ */
+void MipiDsiCntlrClose(struct MipiDsiCntlr *cntlr);
+
+/**
+ * @brief Sets configuration parameters for a MIPI DSI device.
+ *
+ * @param cntlr Indicates the MIPI DSI device obtained via {@link MipiDsiOpen}.
+ * @param cfg Indicates the pointer to the configuration parameters.
+ *
+ * @return Returns 0 if the operation is successful; returns a negative value otherwise.
+ *
+ * @since 1.0
+ */
+int32_t MipiDsiCntlrSetCfg(struct MipiDsiCntlr *cntlr, struct MipiCfg *cfg);
+
+/**
+ * @brief Obtains the configuration parameters of a MIPI DSI device.
+ *
+ * @param cntlr Indicates the MIPI DSI device obtained via {@link MipiDsiOpen}.
+ * @param cfg Indicates the pointer to the configuration parameters.
+ *
+ * @return Returns 0 if the operation is successful; returns a negative value otherwise.
+ *
+ * @since 1.0
+ */
+int32_t MipiDsiCntlrGetCfg(struct MipiDsiCntlr *cntlr, struct MipiCfg *cfg);
+
+/**
+ * @brief Sets LP mode for a MIPI DSI device.
+ *
+ * @param cntlr Indicates the MIPI DSI device obtained via {@link MipiDsiOpen}.
+ *
+ * @since 1.0
+ */
+void MipiDsiCntlrSetLpMode(struct MipiDsiCntlr *cntlr);
-int32_t MipiDsiRegisterCntlr(struct MipiDsiCntlr *);
+/**
+ * @brief Sets the high-speed (HS) mode for a MIPI DSI device.
+ *
+ * @param cntlr Indicates the MIPI DSI device obtained via {@link MipiDsiOpen}.
+ *
+ * @since 1.0
+ */
+void MipiDsiCntlrSetHsMode(struct MipiDsiCntlr *cntlr);
+
+/**
+ * @brief Sends a display command set (DCS) command used for sending the initial parameters of a peripheral.
+ *
+ * @param cntlr Indicates the MIPI DSI device obtained via {@link MipiDsiOpen}.
+ * @param cmd Indicates the pointer to the command to be sent.
+ *
+ * @return Returns 0 if the operation is successful; returns a negative value otherwise.
+ *
+ * @since 1.0
+ */
+int32_t MipiDsiCntlrTx(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *cmd);
+
+/**
+* @brief Receives a DCS command used for reading data, such as the status and parameters of a peripheral
+ *
+ * @param cntlr Indicates the MIPI DSI device obtained via {@link MipiDsiOpen}.
+ * @param cmd Indicates the pointer to the command to be received.
+ * @param readLen Indicates the length of the data to read, in bytes.
+ * @param out Indicates the pointer to the read data.
+ *
+ * @return Returns 0 if the operation is successful; returns a negative value otherwise.
+ *
+ * @since 1.0
+ */
+int32_t MipiDsiCntlrRx(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *cmd, int32_t readLen, uint8_t *out);
+
+/**
+* @brief attach a DSI device to its DSI host
+ *
+ * @param cntlr Indicates the MIPI DSI device obtained via {@link MipiDsiOpen}.
+ * @param name Indicates the name of a peripheral.
+ *
+ * @return Returns 0 if the operation is successful; returns a negative value otherwise.
+ *
+ * @since 1.0
+ */
+int32_t MipiDsiCntlrAttach(struct MipiDsiCntlr *cntlr, uint8_t *name);
#ifdef __cplusplus
#if __cplusplus
diff --git a/support/platform/src/mipi_dsi_core.c b/support/platform/src/mipi_dsi_core.c
index 6a6169351a017420469f32d9be1e5a4df50c5ee9..8d75f5b1311358a4726f953ab3526dba8806889c 100644
--- a/support/platform/src/mipi_dsi_core.c
+++ b/support/platform/src/mipi_dsi_core.c
@@ -13,219 +13,342 @@
#define HDF_LOG_TAG mipi_dsi_core
+struct MipiDsiHandle {
+ struct MipiDsiCntlr *cntlr;
+ struct OsalMutex lock;
+ void *priv;
+};
+
static struct MipiDsiHandle g_mipiDsihandle[MAX_CNTLR_CNT];
-int32_t MipiDsiRegisterCntlr(struct MipiDsiCntlr *cntlr)
+int32_t MipiDsiRegisterCntlr(struct MipiDsiCntlr *cntlr, struct HdfDeviceObject *device)
{
+ HDF_LOGI("%s: enter!", __func__);
if (cntlr == NULL) {
+ HDF_LOGE("%s: cntlr is NULL.", __func__);
return HDF_ERR_INVALID_PARAM;
}
if (cntlr->devNo >= MAX_CNTLR_CNT) {
+ HDF_LOGE("%s: cntlr->devNo is error.", __func__);
return HDF_ERR_INVALID_PARAM;
}
+
+ if (device == NULL) {
+ HDF_LOGE("%s: device is NULL.", __func__);
+ return HDF_FAILURE;
+ }
+
if (g_mipiDsihandle[cntlr->devNo].cntlr == NULL) {
+ (void)OsalMutexInit(&g_mipiDsihandle[cntlr->devNo].lock);
+ (void)OsalMutexInit(&(cntlr->lock));
+
g_mipiDsihandle[cntlr->devNo].cntlr = cntlr;
- if (OsalMutexInit(&g_mipiDsihandle[cntlr->devNo].lock) != HDF_SUCCESS) {
- HDF_LOGE("%s: init lock fail!", __func__);
- g_mipiDsihandle[cntlr->devNo].cntlr = NULL;
- return HDF_FAILURE;
- }
+ g_mipiDsihandle[cntlr->devNo].priv = NULL;
+ cntlr->device = device;
+ device->service = &(cntlr->service);
+ cntlr->priv = NULL;
+ HDF_LOGI("%s: success.", __func__);
+
return HDF_SUCCESS;
}
- HDF_LOGE("cntlr is not NULL");
+
+ HDF_LOGE("%s: cntlr already exists.", __func__);
return HDF_FAILURE;
}
-DevHandle MipiDsiOpen(uint8_t number)
+void MipiDsiUnregisterCntlr(struct MipiDsiCntlr *cntlr)
+{
+ if (cntlr == NULL) {
+ HDF_LOGE("%s: cntlr is NULL.", __func__);
+ return;
+ }
+
+ (void)OsalMutexDestroy(&(cntlr->lock));
+ (void)OsalMutexDestroy(&(g_mipiDsihandle[cntlr->devNo].lock));
+
+ HDF_LOGI("%s: success.", __func__);
+ return;
+}
+
+struct MipiDsiCntlr *MipiDsiCntlrFromDevice(struct HdfDeviceObject *device)
+{
+ return (device == NULL) ? NULL : (struct MipiDsiCntlr *)device->service;
+}
+
+struct MipiDsiCntlr *MipiDsiCntlrOpen(uint8_t number)
{
+ struct MipiDsiCntlr *cntlr = NULL;
+ HDF_LOGI("%s: enter!", __func__);
+
if (number >= MAX_CNTLR_CNT) {
- HDF_LOGE("invalid number");
+ HDF_LOGE("%s: invalid number.", __func__);
return NULL;
}
+
if (g_mipiDsihandle[number].cntlr == NULL) {
- HDF_LOGE("no mipi_dsi %d cntlr", number);
+ HDF_LOGE("%s: g_mipiDsihandle[number].cntlr is NULL.", __func__);
return NULL;
}
- if (OsalMutexLock(&(g_mipiDsihandle[number].lock)) != HDF_SUCCESS) {
- HDF_LOGE("mutex lock fail");
- return NULL;
- }
- return (DevHandle)(&(g_mipiDsihandle[number]));
+
+ (void)OsalMutexLock(&(g_mipiDsihandle[number].lock));
+ g_mipiDsihandle[number].cntlr->devNo = number;
+ cntlr = g_mipiDsihandle[number].cntlr;
+ (void)OsalMutexUnlock(&(g_mipiDsihandle[number].lock));
+
+ return cntlr;
}
-void MipiDsiClose(DevHandle handle)
+void MipiDsiCntlrClose(struct MipiDsiCntlr *cntlr)
{
- struct MipiDsiHandle *mipiHandle = (struct MipiDsiHandle *)handle;
+ if (cntlr == NULL) {
+ HDF_LOGE("%s: cntlr is NULL.", __func__);
+ return;
+ }
- if (mipiHandle != NULL) {
- (void)OsalMutexUnlock(&(mipiHandle->lock));
+ uint8_t number = cntlr->devNo;
+ if (number >= MAX_CNTLR_CNT) {
+ HDF_LOGE("%s: invalid number.", __func__);
+ return;
}
+
+ HDF_LOGI("%s: success!", __func__);
}
-static int32_t MipiDsiSetDevCfg(struct MipiDsiCntlr *cntlr)
+int32_t MipiDsiCntlrSetCfg(struct MipiDsiCntlr *cntlr, struct MipiCfg *cfg)
{
- /* set controller config */
- if (cntlr->setCntlrCfg == NULL) {
- HDF_LOGE("setCntlrCfg is NULL");
+ int32_t ret;
+ HDF_LOGI("%s: enter!", __func__);
+
+ if ((cntlr == NULL) || (cntlr->ops == NULL)) {
+ HDF_LOGE("%s: cntlr or ops is NULL.", __func__);
return HDF_FAILURE;
}
- return cntlr->setCntlrCfg(cntlr);
-}
-static struct MipiDsiCntlr *GetCntlr(DevHandle handle)
-{
- struct MipiDsiHandle *mipiHandle = (struct MipiDsiHandle *)handle;
+ if (cfg == NULL) {
+ HDF_LOGE("%s: cfg is NULL.", __func__);
+ return HDF_FAILURE;
+ }
- return (mipiHandle == NULL) ? NULL : mipiHandle->cntlr;
-}
+ if (cntlr->ops->setCntlrCfg == NULL) {
+ HDF_LOGE("%s: setCntlrCfg is NULL.", __func__);
+ return HDF_ERR_NOT_SUPPORT;
+ }
-int32_t MipiDsiSetCfg(DevHandle handle, struct MipiCfg *cfg)
-{
- struct MipiDsiCntlr *cntlr = NULL;
+ (void)OsalMutexLock(&(cntlr->lock));
+ cntlr->cfg = *cfg;
+ ret = cntlr->ops->setCntlrCfg(cntlr);
+ (void)OsalMutexUnlock(&(cntlr->lock));
- cntlr = GetCntlr(handle);
- if (cntlr == NULL || cfg == NULL) {
- return HDF_FAILURE;
+ if (ret == HDF_SUCCESS) {
+ HDF_LOGI("%s: success!", __func__);
+ } else {
+ HDF_LOGE("%s: failed!", __func__);
}
- cntlr->phyDataRate = cfg->phyDataRate;
- cntlr->pixelClk = cfg->pixelClk;
- cntlr->timing = cfg->timing;
- cntlr->mode = cfg->mode;
- cntlr->burstMode = cfg->burstMode;
- cntlr->format = cfg->format;
- cntlr->lane = cfg->lane;
- return MipiDsiSetDevCfg(cntlr);
+
+ return ret;
}
-int32_t MipiDsiGetCfg(DevHandle handle, struct MipiCfg *cfg)
+int32_t MipiDsiCntlrGetCfg(struct MipiDsiCntlr *cntlr, struct MipiCfg *cfg)
{
- struct MipiDsiCntlr *cntlr = NULL;
-
- cntlr = GetCntlr(handle);
- if (cntlr == NULL || cfg == NULL) {
+ if ((cntlr == NULL) || (cntlr->ops == NULL)) {
+ HDF_LOGE("%s: cntlr or ops is NULL.", __func__);
+ return HDF_FAILURE;
+ }
+ if (cfg == NULL) {
+ HDF_LOGE("%s: cfg is NULL.", __func__);
return HDF_FAILURE;
}
- cfg->phyDataRate = cntlr->phyDataRate;
- cfg->pixelClk = cntlr->pixelClk;
- cfg->timing.xPixels = cntlr->timing.xPixels;
- cfg->timing.hsaPixels = cntlr->timing.hsaPixels;
- cfg->timing.hbpPixels = cntlr->timing.hbpPixels;
- cfg->timing.hlinePixels = cntlr->timing.hlinePixels;
- cfg->timing.vsaLines = cntlr->timing.vsaLines;
- cfg->timing.vbpLines = cntlr->timing.vbpLines;
- cfg->timing.vfpLines = cntlr->timing.vfpLines;
- cfg->timing.ylines = cntlr->timing.ylines;
- cfg->timing.edpiCmdSize = cntlr->timing.edpiCmdSize;
- cfg->mode = cntlr->mode;
- cfg->burstMode = cntlr->burstMode;
- cfg->format = cntlr->format;
- cfg->lane = cntlr->lane;
+
+ (void)OsalMutexLock(&(cntlr->lock));
+ *cfg = cntlr->cfg;
+ (void)OsalMutexUnlock(&(cntlr->lock));
+
return HDF_SUCCESS;
}
-void MipiDsiSetLpMode(DevHandle handle)
+void MipiDsiCntlrSetLpMode(struct MipiDsiCntlr *cntlr)
{
- struct MipiDsiCntlr *cntlr = NULL;
-
- cntlr = GetCntlr(handle);
- if (cntlr == NULL) {
+ if ((cntlr == NULL) || (cntlr->ops == NULL)) {
+ HDF_LOGE("%s: cntlr or ops is NULL.", __func__);
return;
}
- if (cntlr->toLp != NULL) {
- cntlr->toLp(cntlr);
- } else {
- HDF_LOGI("toLp not support!");
+
+ if (cntlr->ops->toLp == NULL) {
+ HDF_LOGE("%s: toLp is NULL.", __func__);
+ return;
}
+
+ (void)OsalMutexLock(&(cntlr->lock));
+ cntlr->ops->toLp(cntlr);
+ (void)OsalMutexUnlock(&(cntlr->lock));
}
-void MipiDsiSetHsMode(DevHandle handle)
+void MipiDsiCntlrSetHsMode(struct MipiDsiCntlr *cntlr)
{
- struct MipiDsiCntlr *cntlr = NULL;
-
- cntlr = GetCntlr(handle);
- if (cntlr == NULL) {
+ if ((cntlr == NULL) || (cntlr->ops == NULL)) {
+ HDF_LOGE("%s: cntlr or ops is NULL.", __func__);
return;
}
- if (cntlr->toHs != NULL) {
- cntlr->toHs(cntlr);
- } else {
- HDF_LOGI("toHs not support!");
+
+ if (cntlr->ops->toHs == NULL) {
+ HDF_LOGE("%s: toHs is NULL.", __func__);
+ return;
}
+
+ (void)OsalMutexLock(&(cntlr->lock));
+ cntlr->ops->toHs(cntlr);
+ (void)OsalMutexUnlock(&(cntlr->lock));
}
-void MipiDsiEnterUlps(DevHandle handle)
+void MipiDsiCntlrEnterUlps(struct MipiDsiCntlr *cntlr)
{
- struct MipiDsiCntlr *cntlr = NULL;
-
- cntlr = GetCntlr(handle);
- if (cntlr == NULL) {
+ if ((cntlr == NULL) || (cntlr->ops == NULL)) {
+ HDF_LOGE("%s: cntlr or ops is NULL.", __func__);
return;
}
- if (cntlr->enterUlps != NULL) {
- cntlr->enterUlps(cntlr);
- } else {
- HDF_LOGI("enterUlps not support!");
+
+ if (cntlr->ops->enterUlps == NULL) {
+ HDF_LOGE("%s: enterUlps is NULL.", __func__);
+ return;
}
+
+ (void)OsalMutexLock(&(cntlr->lock));
+ cntlr->ops->enterUlps(cntlr);
+ (void)OsalMutexUnlock(&(cntlr->lock));
}
-void MipiDsiExitUlps(DevHandle handle)
+void MipiDsiCntlrExitUlps(struct MipiDsiCntlr *cntlr)
{
- struct MipiDsiCntlr *cntlr = NULL;
+ if ((cntlr == NULL) || (cntlr->ops == NULL)) {
+ HDF_LOGE("%s: cntlr, ops or exitUlps is NULL.", __func__);
+ return;
+ }
- cntlr = GetCntlr(handle);
- if (cntlr == NULL) {
+ if (cntlr->ops->exitUlps == NULL) {
+ HDF_LOGE("%s: exitUlps is NULL.", __func__);
return;
}
- if (cntlr->exitUlps != NULL) {
- cntlr->exitUlps(cntlr);
+
+ (void)OsalMutexLock(&(cntlr->lock));
+ cntlr->ops->exitUlps(cntlr);
+ (void)OsalMutexUnlock(&(cntlr->lock));
+}
+
+int32_t MipiDsiCntlrTx(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *cmd)
+{
+ int32_t ret;
+
+ if ((cntlr == NULL) || (cntlr->ops == NULL)) {
+ HDF_LOGE("%s: cntlr or ops is NULL.", __func__);
+ return HDF_FAILURE;
+ }
+ if (cmd == NULL) {
+ HDF_LOGE("%s: cmd is NULL.", __func__);
+ return HDF_FAILURE;
+ }
+
+ if (cntlr->ops->setCmd == NULL) {
+ HDF_LOGE("%s: setCmd is NULL.", __func__);
+ return HDF_ERR_NOT_SUPPORT;
+ }
+
+ (void)OsalMutexLock(&(cntlr->lock));
+ ret = cntlr->ops->setCmd(cntlr, cmd);
+ if (cmd->delay > 0) {
+ OsalMSleep(cmd->delay);
+ }
+ (void)OsalMutexUnlock(&(cntlr->lock));
+
+ if (ret == HDF_SUCCESS) {
+ HDF_LOGI("%s: success!", __func__);
} else {
- HDF_LOGI("exitUlps not support!");
+ HDF_LOGE("%s: failed!", __func__);
}
+
+ return ret;
}
-int32_t MipiDsiTx(DevHandle handle, struct DsiCmdDesc *cmd)
+int32_t MipiDsiCntlrRx(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *cmd, int32_t readLen, uint8_t *out)
{
- struct MipiDsiCntlr *cntlr = NULL;
int32_t ret;
- cntlr = GetCntlr(handle);
- if (cntlr == NULL || cmd == NULL) {
+ if ((cntlr == NULL) || (cntlr->ops == NULL)) {
+ HDF_LOGE("%s: cntlr or ops is NULL.", __func__);
return HDF_FAILURE;
}
- if (cntlr->setCmd != NULL) {
- ret = cntlr->setCmd(cntlr, cmd);
- if (cmd->delay > 0) {
- OsalMSleep(cmd->delay);
- }
- return ret;
+ if ((cmd == NULL) || (out == NULL)) {
+ HDF_LOGE("%s: cmd or out is NULL.", __func__);
+ return HDF_FAILURE;
+ }
+
+ if (cntlr->ops->getCmd == NULL) {
+ HDF_LOGE("%s: getCmd is NULL.", __func__);
+ return HDF_ERR_NOT_SUPPORT;
}
- return HDF_ERR_NOT_SUPPORT;
+
+ (void)OsalMutexLock(&(cntlr->lock));
+ ret = cntlr->ops->getCmd(cntlr, cmd, readLen, out);
+ (void)OsalMutexUnlock(&(cntlr->lock));
+
+ if (ret == HDF_SUCCESS) {
+ HDF_LOGI("%s: success!", __func__);
+ } else {
+ HDF_LOGE("%s: failed!", __func__);
+ }
+
+ return ret;
}
-int32_t MipiDsiRx(DevHandle handle, struct DsiCmdDesc *cmd, int32_t readLen, uint8_t *out)
+int32_t MipiDsiCntlrPowerControl(struct MipiDsiCntlr *cntlr, uint8_t enable)
{
- struct MipiDsiCntlr *cntlr = NULL;
+ int32_t ret;
- cntlr = GetCntlr(handle);
- if (cntlr == NULL || cmd == NULL) {
+ if ((cntlr == NULL) || (cntlr->ops == NULL)) {
+ HDF_LOGE("%s: cntlr or ops is NULL.", __func__);
return HDF_FAILURE;
}
- if (cntlr->getCmd != NULL) {
- return cntlr->getCmd(cntlr, cmd, readLen, out);
+
+ if (cntlr->ops->powerControl == NULL) {
+ HDF_LOGE("%s: powerControl is NULL.", __func__);
+ return HDF_ERR_NOT_SUPPORT;
}
- return HDF_ERR_NOT_SUPPORT;
+
+ (void)OsalMutexLock(&(cntlr->lock));
+ ret = cntlr->ops->powerControl(cntlr, enable);
+ (void)OsalMutexUnlock(&(cntlr->lock));
+
+ if (ret == HDF_SUCCESS) {
+ HDF_LOGI("%s: success!", __func__);
+ } else {
+ HDF_LOGE("%s: failed!", __func__);
+ }
+
+ return ret;
}
-int32_t MipiDsiPowerControl(DevHandle handle, uint8_t enable)
+int32_t MipiDsiCntlrAttach(struct MipiDsiCntlr *cntlr, uint8_t *name)
{
- struct MipiDsiCntlr *cntlr = NULL;
+ int32_t ret;
- cntlr = GetCntlr(handle);
- if (cntlr == NULL) {
+ if ((cntlr == NULL) || (cntlr->ops == NULL)) {
+ HDF_LOGE("%s: cntlr or ops is NULL.", __func__);
return HDF_FAILURE;
}
- if (cntlr->powerControl != NULL) {
- return cntlr->powerControl(cntlr, enable);
+
+ if (cntlr->ops->attach == NULL) {
+ HDF_LOGE("%s: attach is NULL.", __func__);
+ return HDF_ERR_NOT_SUPPORT;
}
- return HDF_ERR_NOT_SUPPORT;
+
+ (void)OsalMutexLock(&(cntlr->lock));
+ ret = cntlr->ops->attach(cntlr, name);
+ (void)OsalMutexUnlock(&(cntlr->lock));
+
+ if (ret == HDF_SUCCESS) {
+ HDF_LOGI("%s: success!", __func__);
+ } else {
+ HDF_LOGE("%s: failed!", __func__);
+ }
+
+ return ret;
}
diff --git a/support/platform/src/mipi_dsi_if.c b/support/platform/src/mipi_dsi_if.c
new file mode 100755
index 0000000000000000000000000000000000000000..a1c4827494f60a177da331a8af495ea2016d0c16
--- /dev/null
+++ b/support/platform/src/mipi_dsi_if.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
+ *
+ * HDF is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ * See the LICENSE file in the root of this repository for complete details.
+ */
+
+#include "mipi_dsi_if.h"
+#include "mipi_dsi_core.h"
+
+#define HDF_LOG_TAG mipi_dsi_if
+
+DevHandle MipiDsiOpen(uint8_t id)
+{
+ return (DevHandle)MipiDsiCntlrOpen(id);
+}
+
+void MipiDsiClose(DevHandle handle)
+{
+ MipiDsiCntlrClose((struct MipiDsiCntlr *)handle);
+}
+
+int32_t MipiDsiSetCfg(DevHandle handle, struct MipiCfg *cfg)
+{
+ return MipiDsiCntlrSetCfg((struct MipiDsiCntlr *)handle, cfg);
+}
+
+int32_t MipiDsiGetCfg(DevHandle handle, struct MipiCfg *cfg)
+{
+ return MipiDsiCntlrGetCfg((struct MipiDsiCntlr *)handle, cfg);
+}
+
+void MipiDsiSetLpMode(DevHandle handle)
+{
+ MipiDsiCntlrSetLpMode((struct MipiDsiCntlr *)handle);
+}
+
+void MipiDsiSetHsMode(DevHandle handle)
+{
+ MipiDsiCntlrSetHsMode((struct MipiDsiCntlr *)handle);
+}
+
+int32_t MipiDsiTx(DevHandle handle, struct DsiCmdDesc *cmd)
+{
+ return MipiDsiCntlrTx((struct MipiDsiCntlr *)handle, cmd);
+}
+
+int32_t MipiDsiRx(DevHandle handle, struct DsiCmdDesc *cmd, int32_t readLen, uint8_t *out)
+{
+ return MipiDsiCntlrRx((struct MipiDsiCntlr *)handle, cmd, readLen, out);
+}
+
+int32_t MipiDsiAttach(DevHandle handle, uint8_t *name)
+{
+ return MipiDsiCntlrAttach((struct MipiDsiCntlr *)handle, name);
+}