!102 DRM 平台驱动适配

Merge pull request !102 from wangyeyu/master
This commit is contained in:
openharmony_ci
2021-09-08 06:10:44 +00:00
committed by Gitee
5 changed files with 264 additions and 46 deletions
+2 -2
View File
@@ -15,8 +15,8 @@
include drivers/hdf/khdf/platform/platform.mk
obj-y += $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mipi_dsi_core.o \
$(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mipi_dsi_if.o \
mipi_dsi_adapter.o
$(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mipi_dsi_if.o
obj-$(CONFIG_DRM_MIPI_DSI) += mipi_dsi_adapter.o
obj-y += mipi_tx_dev.o \
mipi_tx_hi35xx.o
+248 -2
View File
@@ -3,7 +3,7 @@
*
* Mipi dsi adapter driver.
*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Copyright (c) Huawei Device Co., Ltd. 2021. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -16,5 +16,251 @@
*
*/
#include "mipi_dsi_adapter.h"
#include <drm/drm_mipi_dsi.h>
#include <linux/of.h>
#include <video/mipi_display.h>
#include "hdf_base.h"
#include "hdf_device_desc.h"
#include "hdf_log.h"
#include "mipi_dsi_core.h"
#include "mipi_dsi_if.h"
#include "osal_time.h"
#define HDF_LOG_TAG mipi_dsi_drm_adapter
static struct mipi_dsi_device *GetLinuxPanel(struct MipiDsiCntlr *cntlr)
{
if (cntlr == NULL) {
HDF_LOGE("%s: dev is NULL!", __func__);
return NULL;
}
if (cntlr->devNo >= MAX_CNTLR_CNT) {
HDF_LOGE("%s: dev is NULL!", __func__);
return NULL;
}
return (struct mipi_dsi_device *)cntlr->priv;
}
// "sprd,generic-mipi-panel"
static int32_t MipiDsiAdapterAttach(struct MipiDsiCntlr *cntlr, uint8_t *name)
{
int32_t ret;
struct device_node *panelNode;
struct mipi_dsi_device *linuxPanel;
if ((cntlr == NULL) || (name == NULL)) {
HDF_LOGE("%s: cntlr or name is NULL!", __func__);
return HDF_ERR_INVALID_PARAM;
}
if (cntlr->devNo >= MAX_CNTLR_CNT) {
HDF_LOGE("%s: cntlr->devNo is erro!", __func__);
return HDF_ERR_INVALID_PARAM;
}
panelNode = of_find_compatible_node(NULL, NULL, name);
if (panelNode == NULL) {
HDF_LOGE("%s: [of_find_compatible_node] failed!", __func__);
return HDF_FAILURE;
}
linuxPanel = of_find_mipi_dsi_device_by_node(panelNode);
if (linuxPanel == NULL) {
HDF_LOGE("%s: [of_find_mipi_dsi_device_by_node] failed!", __func__);
return HDF_FAILURE;
}
ret = mipi_dsi_attach(linuxPanel);
if (ret < 0) {
HDF_LOGE("%s: mipi_dsi_attach failed.", __func__);
return HDF_FAILURE;
}
cntlr->priv = (DevHandle)linuxPanel;
return HDF_SUCCESS;
}
static int32_t MipiDsiAdapterSetDrvData(struct MipiDsiCntlr *cntlr, DevHandle *panelData)
{
struct mipi_dsi_device *linuxPanel;
if ((cntlr == NULL) || (panelData == NULL)) {
HDF_LOGE("%s: cntlr or panelData is NULL!", __func__);
return HDF_ERR_INVALID_PARAM;
}
if (cntlr->devNo >= MAX_CNTLR_CNT) {
HDF_LOGE("%s: cntlr->devNo is erro!", __func__);
return HDF_ERR_INVALID_PARAM;
}
linuxPanel = GetLinuxPanel(cntlr);
if (linuxPanel == NULL) {
HDF_LOGE("%s: linuxPanel is NULL!", __func__);
return HDF_FAILURE;
}
mipi_dsi_set_drvdata(linuxPanel, panelData);
return HDF_SUCCESS;
}
static int32_t MipiDsiAdapterSetCmd(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *cmd)
{
int32_t ret;
struct mipi_dsi_device *linuxPanel;
if (cntlr == NULL) {
HDF_LOGE("%s: cntlr is NULL.", __func__);
return HDF_FAILURE;
}
linuxPanel = GetLinuxPanel(cntlr);
if (linuxPanel == NULL) {
HDF_LOGE("%s: linuxPanel is NULL!", __func__);
return HDF_FAILURE;
}
if ((cmd->dataType == MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM) || // 0x13,
(cmd->dataType == MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM) || // 0x23
(cmd->dataType == MIPI_DSI_GENERIC_LONG_WRITE)) { // 0x29
ret = mipi_dsi_generic_write(linuxPanel, cmd->payload, cmd->dataLen);
HDF_LOGI("%s: [mipi_dsi_generic_write] dataType = 0x%x, payload = 0x%x, dataLen = 0x%x",
__func__, cmd->dataType, cmd->payload[0], cmd->dataLen);
if (ret < 0) {
HDF_LOGE("%s: [mipi_dsi_generic_write] failed.", __func__);
return HDF_FAILURE;
}
} else if ((cmd->dataType == MIPI_DSI_DCS_SHORT_WRITE) || // 0x05
(cmd->dataType == MIPI_DSI_DCS_SHORT_WRITE_PARAM) || // 0x15
(cmd->dataType == MIPI_DSI_DCS_LONG_WRITE)) { // 0x39
ret = mipi_dsi_dcs_write_buffer(linuxPanel, cmd->payload, cmd->dataLen);
HDF_LOGI("%s: [mipi_dsi_dcs_write_buffer] dataType = 0x%x, payload = 0x%x, dataLen = 0x%x",
__func__, cmd->dataType, cmd->payload[0], cmd->dataLen);
if (ret < 0) {
HDF_LOGE("%s: [mipi_dsi_dcs_write_buffer] failed.", __func__);
return HDF_FAILURE;
}
} else {
if (cmd->dataLen == 0) {
cmd->payload = NULL;
}
ret = mipi_dsi_dcs_write(linuxPanel, cmd->dataType, cmd->payload, cmd->dataLen);
HDF_LOGI("%s: [mipi_dsi_dcs_write] dataType = 0x%x, dataLen = 0x%x",
__func__, cmd->dataType, cmd->dataLen);
if (ret < 0) {
HDF_LOGE("%s: [mipi_dsi_dcs_write] failed.", __func__);
return HDF_FAILURE;
}
}
if (cmd->delay > 0) {
OsalMDelay(cmd->delay);
}
return HDF_SUCCESS;
}
static int32_t MipiDsiAdapterGetCmd(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *cmd, uint32_t readLen, uint8_t *out)
{
int32_t ret;
const void *params = NULL;
size_t numParams;
struct mipi_dsi_device *linuxPanel;
if (cntlr == NULL) {
HDF_LOGE("%s: cntlr is NULL.", __func__);
return HDF_FAILURE;
}
linuxPanel = GetLinuxPanel(cntlr);
if (linuxPanel == NULL) {
HDF_LOGE("%s: linuxPanel is NULL!", __func__);
return HDF_FAILURE;
}
if (cmd->payload != NULL) {
params = cmd->payload;
numParams = cmd->dataLen;
ret = mipi_dsi_generic_read(linuxPanel, params, numParams, out, readLen);
HDF_LOGI("%s: [mipi_dsi_generic_read] dataType = 0x%x, payload = 0x%x, readLen = 0x%x",
__func__, cmd->dataType, cmd->payload[0], readLen);
if (ret < 0) {
HDF_LOGE("%s: [mipi_dsi_generic_read] failed.", __func__);
return HDF_FAILURE;
}
} else {
ret = mipi_dsi_dcs_read(linuxPanel, cmd->dataType, out, readLen);
HDF_LOGI("%s: [mipi_dsi_dcs_read] dataType = 0x%x, readLen = 0x%x",
__func__, cmd->dataType, readLen);
if (ret < 0) {
HDF_LOGE("%s: [mipi_dsi_dcs_read] failed.", __func__);
return HDF_FAILURE;
}
}
return HDF_SUCCESS;
}
static struct MipiDsiCntlr g_mipiTx = {
.devNo = 0
};
static struct MipiDsiCntlrMethod g_method = {
.setCntlrCfg = NULL,
.setCmd = MipiDsiAdapterSetCmd,
.getCmd = MipiDsiAdapterGetCmd,
.toHs = NULL,
.toLp = NULL,
.enterUlps = NULL,
.exitUlps = NULL,
.powerControl = NULL,
.attach = MipiDsiAdapterAttach,
.setDrvData = MipiDsiAdapterSetDrvData,
};
static int32_t MipiDsiAdapterBind(struct HdfDeviceObject *device)
{
int32_t ret;
HDF_LOGI("%s: enter.", __func__);
g_mipiTx.priv = NULL;
g_mipiTx.ops = &g_method;
ret = MipiDsiRegisterCntlr(&g_mipiTx, device);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: [MipiDsiRegisterCntlr] failed.", __func__);
return ret;
}
HDF_LOGI("%s: success.", __func__);
return HDF_SUCCESS;
}
static int32_t MipiDsiAdapterInit(struct HdfDeviceObject *device)
{
(void)device;
HDF_LOGI("%s: success.", __func__);
return HDF_SUCCESS;
}
static void MipiDsiAdapterRelease(struct HdfDeviceObject *device)
{
struct MipiDsiCntlr *cntlr;
if (device == NULL) {
HDF_LOGE("%s: device is NULL.", __func__);
return;
}
cntlr = MipiDsiCntlrFromDevice(device);
if (cntlr == NULL) {
HDF_LOGE("%s: cntlr is NULL.", __func__);
return;
}
MipiDsiUnregisterCntlr(cntlr);
cntlr->priv = NULL;
HDF_LOGI("%s: success.", __func__);
}
struct HdfDriverEntry g_mipiDsiLinuxDriverEntry = {
.moduleVersion = 1,
.Bind = MipiDsiAdapterBind,
.Init = MipiDsiAdapterInit,
.Release = MipiDsiAdapterRelease,
.moduleName = "linux_mipi_dsi_adapter",
};
HDF_INIT(g_mipiDsiLinuxDriverEntry);
-24
View File
@@ -1,24 +0,0 @@
/*
* mipi_dsi_adapter.h
*
* Mipi dsi adapter driver.
*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef MIPI_DSI_ADAPTER_H
#define MIPI_DSI_ADAPTER_H
#include <linux/fs.h>
#endif /* MIPI_DSI_ADAPTER_H */
+13 -17
View File
@@ -3,7 +3,7 @@
*
* create vfs node for mipi
*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -17,31 +17,27 @@
*/
#include "mipi_tx_dev.h"
#include <asm/io.h>
#include <asm/uaccess.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/semaphore.h>
#include <linux/seq_file.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
#include <linux/proc_fs.h>
#endif
#include <linux/init.h>
#include <linux/kdev_t.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/semaphore.h>
#include <linux/seq_file.h>
#include <linux/version.h>
#include "hdf_base.h"
#include "hdf_log.h"
#include "securec.h"
#include "mipi_dsi_core.h"
#include "mipi_tx_reg.h"
#include "osal_io.h"
#include "osal_mem.h"
#include "osal_uaccess.h"
#include <asm/io.h>
#include <asm/uaccess.h>
#include "mipi_dsi_adapter.h"
#include "mipi_dsi_core.h"
#include "mipi_tx_reg.h"
#include "securec.h"
#ifdef __cplusplus
#if __cplusplus
@@ -123,9 +119,9 @@ static int32_t RegisterDevice(const char *name, uint8_t id, unsigned short mode,
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
static int32_t ProcRegister(const char *name, uint32_t id, unsigned short mode, const struct proc_ops *ops)
static int32_t ProcRegister(const char *name, uint8_t id, unsigned short mode, const struct proc_ops *ops)
#else
static int32_t ProcRegister(const char *name, uint32_t id, unsigned short mode, const struct file_operations *ops)
static int32_t ProcRegister(const char *name, uint8_t id, unsigned short mode, const struct file_operations *ops)
#endif
{
char procName[NAME_LEN + 1];
+1 -1
View File
@@ -3,7 +3,7 @@
*
* hi35xx mipi_tx driver implement.
*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Copyright (c) 2021 Huawei Device Co., Ltd.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and