feat: add mipidsi support

add mipi dsi subsystem support.

reference links:
https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/drm_mipi_dsi.c
https://github.com/torvalds/linux/blob/master/include/video/mipi_display.h

Signed-off-by: liushuai25 <liushuai25@xiaomi.com>
This commit is contained in:
liushuai25 2022-12-28 18:57:02 +08:00 committed by Xiang Xiao
parent 890f9ad2ed
commit 6b729487fb
13 changed files with 3021 additions and 0 deletions

View File

@ -322,5 +322,6 @@ config OV2640_REGDEBUG
endif endif
source "drivers/video/vnc/Kconfig" source "drivers/video/vnc/Kconfig"
source "drivers/video/mipidsi/Kconfig"
endif # DRIVERS_VIDEO endif # DRIVERS_VIDEO

View File

@ -59,6 +59,7 @@ endif
endif endif
include video/vnc/Make.defs include video/vnc/Make.defs
include video/mipidsi/Make.defs
# Include video driver build support # Include video driver build support

View File

@ -0,0 +1,19 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menuconfig MIPI_DSI
bool "Dsi Driver Support"
default n
---help---
Enables building of a dsi generic driver.
if MIPI_DSI
config MIPI_DSI_DRIVER
bool "MIPI DSI Character Driver"
default n
endif

View File

@ -0,0 +1,35 @@
############################################################################
# drivers/video/mipidsi/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
# Don't build anything if there is no mipi dsi support
ifeq ($(CONFIG_MIPI_DSI),y)
CSRCS += mipi_dsi_device.c mipi_dsi_host.c mipi_dsi_packet.c
ifeq ($(CONFIG_MIPI_DSI_DRIVER),y)
CSRCS += mipi_dsi_device_driver.c mipi_dsi_host_driver.c
endif
DEPPATH += --dep-path video/mipidsi
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)drivers$(DELIM)video$(DELIM)mipidsi
VPATH += :video/mipidsi
endif # CONFIG_MIPI_DSI

View File

@ -0,0 +1,90 @@
/****************************************************************************
* drivers/video/mipidsi/mipi_dsi.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __DRIVERS_VIDEO_MIPIDSI_MIPI_DSI_H
#define __DRIVERS_VIDEO_MIPIDSI_MIPI_DSI_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/video/mipi_dsi.h>
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Functions Definitions
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: mipi_dsi_host_driver_register
*
* Description:
* Create and register the dsi host character driver.
*
* The dsi host character driver is a simple character driver that
* supports dsi transfer.
*
* Input Parameters:
* host - An instance of the struct mipi_dsi_host
*
* Returned Value:
* OK if the driver was successfully register; A negated errno value is
* returned on any failure.
*
****************************************************************************/
int mipi_dsi_host_driver_register(FAR struct mipi_dsi_host *host);
/****************************************************************************
* Name: mipi_dsi_device_driver_register
*
* Description:
* Create and register the dsi device character driver.
*
* The dsi device character driver is a simple character driver that
* supports get dsi device params.
*
* Input Parameters:
* device - An instance of the struct mipi_dsi_device
*
* Returned Value:
* OK if the driver was successfully register; A negated errno value is
* returned on any failure.
*
****************************************************************************/
int mipi_dsi_device_driver_register(FAR struct mipi_dsi_device *device);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __DRIVERS_VIDEO_MIPIDSI_MIPI_DSI_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,234 @@
/****************************************************************************
* drivers/video/mipidsi/mipi_dsi_device_driver.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <stdio.h>
#include <nuttx/kmalloc.h>
#include "mipi_dsi.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Device naming ************************************************************/
#define MIPI_DSI_DEVNAME_FMT "/dev/dsi%d/dev.%d.%s"
#define MIPI_DSI_DEVNAME_LEN 128
/****************************************************************************
* Private Types
****************************************************************************/
struct mipi_dsi_device_driver_s
{
FAR struct mipi_dsi_device *dsi_dev;
mutex_t lock; /* Mutual exclusion */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static ssize_t dsi_dev_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static ssize_t dsi_dev_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen);
static int dsi_dev_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
/****************************************************************************
* Private Data
****************************************************************************/
static const struct file_operations dsi_dev_fops =
{
NULL, /* open */
NULL, /* close */
dsi_dev_read, /* read */
dsi_dev_write, /* write */
NULL, /* seek */
dsi_dev_ioctl, /* ioctl */
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: dsi_dev_read
****************************************************************************/
static ssize_t dsi_dev_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
return 0; /* Return EOF */
}
/****************************************************************************
* Name: dsi_dev_write
****************************************************************************/
static ssize_t dsi_dev_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen)
{
return buflen; /* Say that everything was written */
}
/****************************************************************************
* Name: dsi_dev_ioctl
****************************************************************************/
static int dsi_dev_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct inode *inode;
FAR struct mipi_dsi_device_driver_s *priv;
int ret = OK;
/* Get our private data structure */
DEBUGASSERT(filep != NULL && filep->f_inode != NULL);
inode = filep->f_inode;
priv = (FAR struct mipi_dsi_device_driver_s *)inode->i_private;
DEBUGASSERT(priv);
/* Get exclusive access to the DSI device driver state structure */
ret = nxmutex_lock(&priv->lock);
if (ret < 0)
{
return ret;
}
/* Process the IOCTL command */
switch (cmd)
{
case MIPIDSI_GETDEVLANES:
{
FAR uint16_t *planes = (FAR uint16_t *)((uintptr_t)arg);
DEBUGASSERT(planes != NULL);
*planes = priv->dsi_dev->lanes;
}
break;
case MIPIDSI_GETDEVFMT:
{
FAR uint32_t *fmt = (FAR uint32_t *)((uintptr_t)arg);
DEBUGASSERT(fmt != NULL);
*fmt = priv->dsi_dev->format;
}
break;
case MIPIDSI_GETDEVMODE:
{
FAR uint32_t *mode = (FAR uint32_t *)((uintptr_t)arg);
DEBUGASSERT(mode != NULL);
*mode = priv->dsi_dev->mode_flags;
}
break;
case MIPIDSI_GETDEVHSRATE:
{
FAR uint32_t *hsrate = (FAR uint32_t *)((uintptr_t)arg);
DEBUGASSERT(hsrate != NULL);
*hsrate = priv->dsi_dev->hs_rate;
}
break;
case MIPIDSI_GETDEVLPRATE:
{
FAR uint32_t *lprate = (FAR uint32_t *)((uintptr_t)arg);
DEBUGASSERT(lprate != NULL);
*lprate = priv->dsi_dev->lp_rate;
}
break;
default:
ret = -ENOTTY;
break;
}
nxmutex_unlock(&priv->lock);
return ret;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: mipi_dsi_device_driver_register
*
* Description:
* Create and register the dsi device character driver.
*
* The dsi device character driver is a simple character driver that
* supports get dsi device params.
*
* Input Parameters:
* device - An instance of the struct mipi_dsi_device
*
* Returned Value:
* OK if the driver was successfully register; A negated errno value is
* returned on any failure.
*
****************************************************************************/
int mipi_dsi_device_driver_register(FAR struct mipi_dsi_device *device)
{
FAR struct mipi_dsi_device_driver_s *priv;
FAR struct mipi_dsi_host *host;
char devpath[MIPI_DSI_DEVNAME_LEN];
int ret = OK;
DEBUGASSERT(device != NULL && device->host != NULL);
priv = kmm_zalloc(sizeof(struct mipi_dsi_device_driver_s));
if (priv == NULL)
{
verr("mipi dsi device driver register failed, no memory.\n");
return -ENOMEM;
}
priv->dsi_dev = device;
nxmutex_init(&priv->lock);
host = device->host;
snprintf(devpath, sizeof(devpath), MIPI_DSI_DEVNAME_FMT, host->bus,
device->channel, device->name);
ret = register_driver(devpath, &dsi_dev_fops, 0666, priv);
if (ret < 0)
{
nxmutex_destroy(&priv->lock);
kmm_free(priv);
}
return ret;
}

View File

@ -0,0 +1,165 @@
/****************************************************************************
* drivers/video/mipidsi/mipi_dsi_host.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include "mipi_dsi.h"
/****************************************************************************
* Private Types
****************************************************************************/
struct mipi_dsi_hosts_s
{
int count;
struct mipi_dsi_host *hosts[0];
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
static FAR struct mipi_dsi_hosts_s *g_hosts;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: mipi_dsi_host_exist
****************************************************************************/
static bool mipi_dsi_host_exist(int bus)
{
int i = 0;
while (g_hosts != NULL && i < g_hosts->count)
{
if (g_hosts->hosts[i]->bus == bus)
{
return true;
}
i++;
}
return false;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: mipi_dsi_host_register
*
* Description:
* Register mipi dsi host, if defined CONFIG_MIPI_DSI_DRIVER, will create
* character device at /dev.
*
* Input Parameters:
* host - An instance of the dsi host
*
* Returned Value:
* OK if the driver was successfully register; A negated errno value is
* returned on any failure.
*
****************************************************************************/
int mipi_dsi_host_register(FAR struct mipi_dsi_host *host)
{
DEBUGASSERT(host != NULL && host->ops != NULL);
if (mipi_dsi_host_exist(host->bus))
{
return -EINVAL;
}
if (g_hosts == NULL)
{
g_hosts = kmm_zalloc(sizeof(struct mipi_dsi_hosts_s) +
sizeof(FAR struct mipi_dsi_host *));
}
else
{
g_hosts = kmm_realloc(g_hosts, sizeof(struct mipi_dsi_hosts_s) +
sizeof(FAR struct mipi_dsi_host *) *
(g_hosts->count + 1));
}
if (g_hosts == NULL)
{
return -ENOMEM;
}
g_hosts->hosts[g_hosts->count] = host;
g_hosts->count++;
#ifdef CONFIG_MIPI_DSI_DRIVER
return mipi_dsi_host_driver_register(host);
#else
return OK;
#endif
}
/****************************************************************************
* Name: mipi_dsi_host_get
*
* Description:
* Find host in list by bus number. Lcd driver can get host by this
* interface to register dsi device.
*
* Input Parameters:
* bus - The dsi host bus number.
*
* Returned Value:
* struct mipi_dsi_host pointer if the host was successfully registered;
* NULL pointer is returned on any failure.
*
****************************************************************************/
FAR struct mipi_dsi_host *mipi_dsi_host_get(int bus)
{
int i = 0;
while (g_hosts != NULL && i < g_hosts->count)
{
if (g_hosts->hosts[i]->bus == bus)
{
return g_hosts->hosts[i];
}
i++;
}
return NULL;
}

View File

@ -0,0 +1,209 @@
/****************************************************************************
* drivers/video/mipidsi/mipi_dsi_host_driver.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <stdio.h>
#include <nuttx/kmalloc.h>
#include "mipi_dsi.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Device naming ************************************************************/
#define MIPI_DSI_HOSTNAME_FMT "/dev/dsi%d/host"
#define MIPI_DSI_HOSTNAME_LEN 128
/****************************************************************************
* Private Types
****************************************************************************/
/* Driver state structure */
struct mipi_dsi_host_driver_s
{
FAR struct mipi_dsi_host *host;
mutex_t lock; /* Mutual exclusion */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static ssize_t dsi_host_read(FAR struct file *filep, FAR char *buffer,
size_t len);
static ssize_t dsi_host_write(FAR struct file *filep, FAR const char *buffer,
size_t len);
static int dsi_host_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
/****************************************************************************
* Private Data
****************************************************************************/
static const struct file_operations dsi_host_fops =
{
NULL, /* open */
NULL, /* close */
dsi_host_read, /* read */
dsi_host_write, /* write */
NULL, /* seek */
dsi_host_ioctl, /* ioctl */
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: dsi_host_read
****************************************************************************/
static ssize_t dsi_host_read(FAR struct file *filep, FAR char *buffer,
size_t len)
{
return 0; /* Return EOF */
}
/****************************************************************************
* Name: DSI hostdrvr_write
****************************************************************************/
static ssize_t dsi_host_write(FAR struct file *filep, FAR const char *buffer,
size_t len)
{
return len; /* Say that everything was written */
}
/****************************************************************************
* Name: dsi_host_ioctl
****************************************************************************/
static int dsi_host_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct mipi_dsi_host_driver_s *priv;
FAR struct inode *inode;
FAR struct mipi_dsi_msg *msg;
FAR struct mipi_dsi_host *host;
int ret;
/* Get our private data structure */
DEBUGASSERT(filep != NULL && filep->f_inode != NULL);
inode = filep->f_inode;
priv = inode->i_private;
DEBUGASSERT(priv);
/* Get exclusive access to the dsi host driver state structure */
ret = nxmutex_lock(&priv->lock);
if (ret < 0)
{
return ret;
}
/* Process the IOCTL command */
switch (cmd)
{
case MIPIDSI_TRANSFER:
{
/* Get the reference to the mipi_dsi_msg structure */
msg = (FAR struct mipi_dsi_msg *)((uintptr_t)arg);
/* Get the reference to the mipi_dsi_host structure */
host = priv->host;
DEBUGASSERT(host != NULL && msg != NULL);
ret = host->ops->transfer(host, msg);
}
break;
default:
ret = -ENOTTY;
break;
}
nxmutex_unlock(&priv->lock);
return ret;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: mipi_dsi_host_driver_register
*
* Description:
* Create and register the dsi host character driver.
*
* The dsi host character driver is a simple character driver that
* supports dsi transfer.
*
* Input Parameters:
* host - An instance of the struct mipi_dsi_host
*
* Returned Value:
* OK if the driver was successfully register; A negated errno value is
* returned on any failure.
*
****************************************************************************/
int mipi_dsi_host_driver_register(FAR struct mipi_dsi_host *host)
{
FAR struct mipi_dsi_host_driver_s *priv;
char name[MIPI_DSI_HOSTNAME_LEN];
int ret = -ENOMEM;
DEBUGASSERT(host != NULL);
priv = kmm_zalloc(sizeof(struct mipi_dsi_host_driver_s));
if (priv != NULL)
{
priv->host = host;
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
nxmutex_init(&priv->lock);
#endif
snprintf(name, sizeof(name), MIPI_DSI_HOSTNAME_FMT, host->bus);
ret = register_driver(name, &dsi_host_fops, 0666, priv);
if (ret < 0)
{
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
nxmutex_destroy(&priv->lock);
#endif
kmm_free(priv);
}
}
return ret;
}

View File

@ -0,0 +1,220 @@
/****************************************************************************
* drivers/video/mipidsi/mipi_dsi_packet.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <string.h>
#include <nuttx/video/mipi_dsi.h>
#include <nuttx/video/mipi_display.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: mipi_dsi_pixel_format_to_bpp
*
* Description:
* Obtain the number of bits per pixel for any given pixel format defined
* by the MIPI DSI specification
*
* Input Parameters:
* fmt - MIPI DSI pixel format
*
* Returned Value:
* The number of bits per pixel of the given pixel format.
*
****************************************************************************/
int mipi_dsi_pixel_format_to_bpp(uint8_t fmt)
{
switch (fmt)
{
case MIPI_DSI_FMT_RGB888:
case MIPI_DSI_FMT_RGB666:
return 24;
case MIPI_DSI_FMT_RGB666_PACKED:
return 18;
case MIPI_DSI_FMT_RGB565:
return 16;
}
return -EINVAL;
}
/****************************************************************************
* Name: mipi_dsi_packet_format_is_short
*
* Description:
* Check if a packet is of the short format
*
* Input Parameters:
* type - MIPI DSI data type of the packet
*
* Returned Value:
* True if the packet for the given data type is a short packet, false
* otherwise.
*
****************************************************************************/
bool mipi_dsi_packet_format_is_short(uint8_t type)
{
switch (type)
{
case MIPI_DSI_VSYNC_START:
case MIPI_DSI_VSYNC_END:
case MIPI_DSI_HSYNC_START:
case MIPI_DSI_HSYNC_END:
case MIPI_DSI_COMPRESSION_MODE:
case MIPI_DSI_END_OF_TRANSMISSION:
case MIPI_DSI_COLOR_MODE_OFF:
case MIPI_DSI_COLOR_MODE_ON:
case MIPI_DSI_SHUTDOWN_PERIPHERAL:
case MIPI_DSI_TURN_ON_PERIPHERAL:
case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
case MIPI_DSI_GENERIC_READ_0_PARAM:
case MIPI_DSI_GENERIC_READ_1_PARAM:
case MIPI_DSI_GENERIC_READ_2_PARAM:
case MIPI_DSI_DCS_SHORT_WRITE_0_PARAM:
case MIPI_DSI_DCS_SHORT_WRITE_1_PARAM:
case MIPI_DSI_DCS_READ_0_PARAM:
case MIPI_DSI_EXECUTE_QUEUE:
case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
return true;
}
return false;
}
/****************************************************************************
* Name: mipi_dsi_packet_format_is_long
*
* Description:
* Check if a packet is of the long format
*
* Input Parameters:
* type - MIPI DSI data type of the packet
*
* Returned Value:
* True if the packet for the given data type is a long packet, false
* otherwise.
*
****************************************************************************/
bool mipi_dsi_packet_format_is_long(uint8_t type)
{
switch (type)
{
case MIPI_DSI_NULL_PACKET:
case MIPI_DSI_BLANKING_PACKET:
case MIPI_DSI_LONG_GENERIC_WRITE:
case MIPI_DSI_DCS_LONG_WRITE:
case MIPI_DSI_PICTURE_PARAMETER_SET:
case MIPI_DSI_COMPRESSED_PIXEL_STREAM:
case MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20:
case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24:
case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16:
case MIPI_DSI_PACKED_PIXEL_STREAM_RGB30:
case MIPI_DSI_PACKED_PIXEL_STREAM_RGB36:
case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12:
case MIPI_DSI_PACKED_PIXEL_STREAM_RGB16:
case MIPI_DSI_PACKED_PIXEL_STREAM_RGB18:
case MIPI_DSI_PIXEL_STREAM_3BYTE_RGB18:
case MIPI_DSI_PACKED_PIXEL_STREAM_RGB24:
return true;
}
return false;
}
/****************************************************************************
* Name: mipi_dsi_create_packet
*
* Description:
* Create a packet from a message according to the DSI protocol
*
* Input Parameters:
* packet - Pointer to a DSI packet structure
* msg - Message to translate into a packet
*
* Returned Value:
* Return: 0 on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_create_packet(FAR struct mipi_dsi_packet *packet,
FAR const struct mipi_dsi_msg *msg)
{
DEBUGASSERT(packet != NULL);
DEBUGASSERT(msg != NULL);
/* do some minimum sanity checking */
if (!mipi_dsi_packet_format_is_short(msg->type) &&
!mipi_dsi_packet_format_is_long(msg->type))
{
return -EINVAL;
}
if (msg->channel > 3)
{
return -EINVAL;
}
memset(packet, 0, sizeof(*packet));
packet->header[0] = (msg->channel << 6) | (msg->type & 0x3f);
/* TODO: compute ECC if hardware support is not available */
/* Long write packets contain the word count in header bytes 1 and 2.
* The payload follows the header and is word count bytes long.
*
* Short write packets encode up to two parameters in header bytes 1
* and 2.
*/
if (mipi_dsi_packet_format_is_long(msg->type))
{
packet->header[1] = (msg->tx_len >> 0) & 0xff;
packet->header[2] = (msg->tx_len >> 8) & 0xff;
packet->payload_length = msg->tx_len;
packet->payload = msg->tx_buf;
}
else
{
FAR const uint8_t *tx = msg->tx_buf;
packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0;
packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0;
}
packet->size = sizeof(packet->header) + packet->payload_length;
return OK;
}

View File

@ -94,6 +94,7 @@
#define _LTEBASE (0x3600) /* LTE device ioctl commands */ #define _LTEBASE (0x3600) /* LTE device ioctl commands */
#define _VIDIOCBASE (0x3700) /* Video device ioctl commands */ #define _VIDIOCBASE (0x3700) /* Video device ioctl commands */
#define _CELLIOCBASE (0x3800) /* Cellular device ioctl commands */ #define _CELLIOCBASE (0x3800) /* Cellular device ioctl commands */
#define _MIPIDSIBASE (0x3900) /* Mipidsi device ioctl commands */
#define _WLIOCBASE (0x8b00) /* Wireless modules ioctl network commands */ #define _WLIOCBASE (0x8b00) /* Wireless modules ioctl network commands */
/* boardctl() commands share the same number space */ /* boardctl() commands share the same number space */
@ -621,6 +622,11 @@
#define _CELLIOCVALID(c) (_IOC_TYPE(c)==_CELLIOCBASE) #define _CELLIOCVALID(c) (_IOC_TYPE(c)==_CELLIOCBASE)
#define _CELLIOC(nr) _IOC(_CELLIOCBASE,nr) #define _CELLIOC(nr) _IOC(_CELLIOCBASE,nr)
/* mipidsi driver ioctl definitions *****************************************/
#define _MIPIDSIIOCVALID(c) (_IOC_TYPE(c)==_MIPIDSIBASE)
#define _MIPIDSIIOC(nr) _IOC(_MIPIDSIBASE,nr)
/* Wireless driver network ioctl definitions ********************************/ /* Wireless driver network ioctl definitions ********************************/
/* (see nuttx/include/wireless/wireless.h */ /* (see nuttx/include/wireless/wireless.h */

View File

@ -0,0 +1,153 @@
/****************************************************************************
* include/nuttx/video/mipi_display.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing software
* distributed under the License is distributed on an "AS IS" BASIS WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_VIDEO_MIPI_DISPLAY_H
#define __INCLUDE_NUTTX_VIDEO_MIPI_DISPLAY_H
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* DSI Processor-to-Peripheral transaction types */
#define MIPI_DSI_VSYNC_START 0x01
#define MIPI_DSI_VSYNC_END 0x11
#define MIPI_DSI_HSYNC_START 0x21
#define MIPI_DSI_HSYNC_END 0x31
#define MIPI_DSI_COMPRESSION_MODE 0x07
#define MIPI_DSI_END_OF_TRANSMISSION 0x08
#define MIPI_DSI_COLOR_MODE_OFF 0x02
#define MIPI_DSI_COLOR_MODE_ON 0x12
#define MIPI_DSI_SHUTDOWN_PERIPHERAL 0x22
#define MIPI_DSI_TURN_ON_PERIPHERAL 0x32
#define MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM 0x03
#define MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM 0x13
#define MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM 0x23
#define MIPI_DSI_GENERIC_READ_0_PARAM 0x04
#define MIPI_DSI_GENERIC_READ_1_PARAM 0x14
#define MIPI_DSI_GENERIC_READ_2_PARAM 0x24
#define MIPI_DSI_DCS_SHORT_WRITE_0_PARAM 0x05
#define MIPI_DSI_DCS_SHORT_WRITE_1_PARAM 0x15
#define MIPI_DSI_DCS_READ_0_PARAM 0x06
#define MIPI_DSI_EXECUTE_QUEUE 0x16
#define MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE 0x37
#define MIPI_DSI_NULL_PACKET 0x09
#define MIPI_DSI_BLANKING_PACKET 0x19
#define MIPI_DSI_LONG_GENERIC_WRITE 0x29
#define MIPI_DSI_DCS_LONG_WRITE 0x39
#define MIPI_DSI_PICTURE_PARAMETER_SET 0x0a
#define MIPI_DSI_COMPRESSED_PIXEL_STREAM 0x0b
#define MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20 0x0c
#define MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24 0x1c
#define MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16 0x2c
#define MIPI_DSI_PACKED_PIXEL_STREAM_RGB30 0x0d
#define MIPI_DSI_PACKED_PIXEL_STREAM_RGB36 0x1d
#define MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12 0x3d
#define MIPI_DSI_PACKED_PIXEL_STREAM_RGB16 0x0e
#define MIPI_DSI_PACKED_PIXEL_STREAM_RGB18 0x1e
#define MIPI_DSI_PIXEL_STREAM_3BYTE_RGB18 0x2e
#define MIPI_DSI_PACKED_PIXEL_STREAM_RGB24 0x3e
/* DSI Peripheral-to-Processor transaction data type */
#define MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT 0x02
#define MIPI_DSI_RX_END_OF_TRANSMISSION 0x08
#define MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE 0x11
#define MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_2BYTE 0x12
#define MIPI_DSI_RX_GENERIC_LONG_READ_RESPONSE 0x1a
#define MIPI_DSI_RX_DCS_LONG_READ_RESPONSE 0x1c
#define MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE 0x21
#define MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE 0x22
/* DCS commands */
#define MIPI_DCS_NOP 0x00
#define MIPI_DCS_SOFT_RESET 0x01
#define MIPI_DCS_GET_COMPRESSION_MODE 0x03
#define MIPI_DCS_GET_DISPLAY_ID 0x04
#define MIPI_DCS_GET_ERROR_COUNT_ON_DSI 0x05
#define MIPI_DCS_GET_RED_CHANNEL 0x06
#define MIPI_DCS_GET_GREEN_CHANNEL 0x07
#define MIPI_DCS_GET_BLUE_CHANNEL 0x08
#define MIPI_DCS_GET_DISPLAY_STATUS 0x09
#define MIPI_DCS_GET_POWER_MODE 0x0a
#define MIPI_DCS_GET_ADDRESS_MODE 0x0b
#define MIPI_DCS_GET_PIXEL_FORMAT 0x0c
#define MIPI_DCS_GET_DISPLAY_MODE 0x0d
#define MIPI_DCS_GET_SIGNAL_MODE 0x0e
#define MIPI_DCS_GET_DIAGNOSTIC_RESULT 0x0f
#define MIPI_DCS_ENTER_SLEEP_MODE 0x10
#define MIPI_DCS_EXIT_SLEEP_MODE 0x11
#define MIPI_DCS_ENTER_PARTIAL_MODE 0x12
#define MIPI_DCS_ENTER_NORMAL_MODE 0x13
#define MIPI_DCS_GET_IMAGE_CHECKSUM_RGB 0x14
#define MIPI_DCS_GET_IMAGE_CHECKSUM_CT 0x15
#define MIPI_DCS_EXIT_INVERT_MODE 0x20
#define MIPI_DCS_ENTER_INVERT_MODE 0x21
#define MIPI_DCS_SET_GAMMA_CURVE 0x26
#define MIPI_DCS_SET_DISPLAY_OFF 0x28
#define MIPI_DCS_SET_DISPLAY_ON 0x29
#define MIPI_DCS_SET_COLUMN_ADDRESS 0x2a
#define MIPI_DCS_SET_PAGE_ADDRESS 0x2b
#define MIPI_DCS_WRITE_MEMORY_START 0x2c
#define MIPI_DCS_WRITE_LUT 0x2d
#define MIPI_DCS_READ_MEMORY_START 0x2e
#define MIPI_DCS_SET_PARTIAL_ROWS 0x30 /* MIPI DCS 1.02 -
* MIPI_DCS_SET_PARTIAL_AREA
* before that */
#define MIPI_DCS_SET_PARTIAL_COLUMNS 0x31
#define MIPI_DCS_SET_SCROLL_AREA 0x33
#define MIPI_DCS_SET_TEAR_OFF 0x34
#define MIPI_DCS_SET_TEAR_ON 0x35
#define MIPI_DCS_SET_ADDRESS_MODE 0x36
#define MIPI_DCS_SET_SCROLL_START 0x37
#define MIPI_DCS_EXIT_IDLE_MODE 0x38
#define MIPI_DCS_ENTER_IDLE_MODE 0x39
#define MIPI_DCS_SET_PIXEL_FORMAT 0x3a
#define MIPI_DCS_WRITE_MEMORY_CONTINUE 0x3c
#define MIPI_DCS_SET_3D_CONTROL 0x3d
#define MIPI_DCS_READ_MEMORY_CONTINUE 0x3e
#define MIPI_DCS_GET_3D_CONTROL 0x3f
#define MIPI_DCS_SET_VSYNC_TIMING 0x40
#define MIPI_DCS_SET_TEAR_SCANLINE 0x44
#define MIPI_DCS_GET_SCANLINE 0x45
#define MIPI_DCS_SET_DISPLAY_BRIGHTNESS 0x51 /* MIPI DCS 1.3 */
#define MIPI_DCS_GET_DISPLAY_BRIGHTNESS 0x52 /* MIPI DCS 1.3 */
#define MIPI_DCS_WRITE_CONTROL_DISPLAY 0x53 /* MIPI DCS 1.3 */
#define MIPI_DCS_GET_CONTROL_DISPLAY 0x54 /* MIPI DCS 1.3 */
#define MIPI_DCS_WRITE_POWER_SAVE 0x55 /* MIPI DCS 1.3 */
#define MIPI_DCS_GET_POWER_SAVE 0x56 /* MIPI DCS 1.3 */
#define MIPI_DCS_SET_CABC_MIN_BRIGHTNESS 0x5e /* MIPI DCS 1.3 */
#define MIPI_DCS_GET_CABC_MIN_BRIGHTNESS 0x5f /* MIPI DCS 1.3 */
#define MIPI_DCS_READ_DDB_START 0xa1
#define MIPI_DCS_READ_PPS_START 0xa2
#define MIPI_DCS_READ_DDB_CONTINUE 0xa8
#define MIPI_DCS_READ_PPS_CONTINUE 0xa9
/* DCS pixel formats */
#define MIPI_DCS_PIXEL_FMT_24BIT 7
#define MIPI_DCS_PIXEL_FMT_18BIT 6
#define MIPI_DCS_PIXEL_FMT_16BIT 5
#define MIPI_DCS_PIXEL_FMT_12BIT 3
#define MIPI_DCS_PIXEL_FMT_8BIT 2
#define MIPI_DCS_PIXEL_FMT_3BIT 1
#endif /* __INCLUDE_NUTTX_VIDEO_MIPI_DISPLAY_H */

View File

@ -0,0 +1,865 @@
/****************************************************************************
* include/nuttx/video/mipi_dsi.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_VIDEO_MIPI_DSI_H
#define __INCLUDE_NUTTX_VIDEO_MIPI_DSI_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/fs/ioctl.h>
#include <stdbool.h>
#include <stddef.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Define cmd for dsi device */
#define MIPIDSI_GETDEVLANES _MIPIDSIIOC(1)
#define MIPIDSI_GETDEVFMT _MIPIDSIIOC(2)
#define MIPIDSI_GETDEVMODE _MIPIDSIIOC(3)
#define MIPIDSI_GETDEVHSRATE _MIPIDSIIOC(4)
#define MIPIDSI_GETDEVLPRATE _MIPIDSIIOC(5)
/* Define cmd for dsi host */
#define MIPIDSI_TRANSFER _MIPIDSIIOC(6)
/* Define msg flags */
#define MIPI_DSI_MSG_REQ_ACK (1 << 0) /* Request ACK from peripheral */
#define MIPI_DSI_MSG_USE_LPM (1 << 1) /* Use Low Power Mode to
* transmit message */
#define MIPI_DSI_MSG_AFTER_FRAME (1 << 2) /* Transmit message after frame */
/* Tearing Effect Output Line mode */
#define MIPI_DSI_DCS_TEAR_MODE_VBLANK 0 /* The TE output line consists of
* V-Blanking information only */
#define MIPI_DSI_DCS_TEAR_MODE_VHBLANK 1 /* The TE output line consists of
* both V-Blanking and H-Blanking
* information */
/* Define pixel color format */
#define MIPI_DSI_FMT_RGB888 0
#define MIPI_DSI_FMT_RGB666 1
#define MIPI_DSI_FMT_RGB666_PACKED 2
#define MIPI_DSI_FMT_RGB565 3
/* Indicates the status of register 0Ah */
#define MIPI_DSI_DCS_POWER_MODE_DISPLAY (1 << 2)
#define MIPI_DSI_DCS_POWER_MODE_NORMAL (1 << 3)
#define MIPI_DSI_DCS_POWER_MODE_SLEEP (1 << 4)
#define MIPI_DSI_DCS_POWER_MODE_PARTIAL (1 << 5)
#define MIPI_DSI_DCS_POWER_MODE_IDLE (1 << 6)
/* DSI mode flags define */
#define MIPI_DSI_MODE_VIDEO (1 << 0) /* Video mode */
#define MIPI_DSI_MODE_VIDEO_BURST (1 << 1) /* Video burst mode */
#define MIPI_DSI_MODE_VIDEO_SYNC_PULSE (1 << 2) /* Video pulse mode */
#define MIPI_DSI_MODE_VIDEO_AUTO_VERT (1 << 3) /* Enable auto vertical
* count mode */
#define MIPI_DSI_MODE_VIDEO_HSE (1 << 4) /* Enable hsync-end packets
* in vsync-pulse and
* v-porch area */
#define MIPI_DSI_MODE_VIDEO_NO_HFP (1 << 5) /* Disable hfront-porch area */
#define MIPI_DSI_MODE_VIDEO_NO_HBP (1 << 6) /* Disable hback-porch area */
#define MIPI_DSI_MODE_VIDEO_NO_HSA (1 << 7) /* Disable hsync-active area */
#define MIPI_DSI_MODE_VSYNC_FLUSH (1 << 8) /* Flush display FIFO on vsync
* pulse */
#define MIPI_DSI_MODE_NO_EOT_PACKET (1 << 9) /* Disable EoT packets in HS
* mode */
#define MIPI_DSI_CLOCK_NON_CONTINUOUS (1 << 10) /* Device supports
* non-continuous clock
* behavior (DSI spec 5.6.1) */
#define MIPI_DSI_MODE_LPM (1 << 11) /* Transmit data in low
* power */
#define MIPI_DSI_MODE_AFTER_FRAME (1 << 12) /* Transmit data after frame
* transfer done */
#define MIPI_DSI_HS_PKT_END_ALIGNED (1 << 13) /* Transmit data ending at
* the same time for all
* lanes within one hsync */
/****************************************************************************
* Public Types
****************************************************************************/
struct mipi_dsi_host;
struct mipi_dsi_device;
/* Read/write DSI buffer */
struct mipi_dsi_msg
{
uint8_t channel; /* Virtual channel id */
uint8_t type; /* Payload data type */
uint8_t flags; /* Flags controlling this message transmission */
size_t tx_len; /* Length of tx_buf */
FAR const void *tx_buf; /* Data to be written */
size_t rx_len; /* Lenght of rx_buf */
FAR void *rx_buf; /* Data to be read, or NULL */
};
/* Represents a MIPI DSI packet in protocol format */
struct mipi_dsi_packet
{
size_t size; /* Size (in bytes) of the packet */
uint8_t header[4]; /* The four bytes that make up the header
* (Data ID, Word Count or Packet Data,
* and ECC) */
size_t payload_length; /* Number of bytes in the payload */
FAR const uint8_t *payload; /* A pointer to a buffer containing
* the payload */
};
/* DSI bus operations
*
* DSI packets transmitted by .transfer() are passed in as mipi_dsi_msg
* structures. This structure contains information about the type of packet
* being transmitted as well as the transmit and receive buffers. When an
* error is encountered during transmission, this function will return a
* negative error code. On success it shall return the number of bytes
* transmitted for write packets or the number of bytes received for read
* packets.
*
* Note that typically DSI packet transmission is atomic, so the .transfer()
* function will seldomly return anything other than the number of bytes
* contained in the transmit buffer on success.
*
* Also note that those callbacks can be called no matter the state the
* host is in. Drivers that need the underlying device to be powered to
* perform these operations will first need to make sure it's been
* properly enabled.
*/
struct mipi_dsi_host_ops
{
/* Attach DSI device to DSI host */
CODE int (*attach)(FAR struct mipi_dsi_host *host,
FAR struct mipi_dsi_device *device);
/* Detach DSI device from DSI host */
CODE int (*detach)(FAR struct mipi_dsi_host *host,
FAR struct mipi_dsi_device *device);
/* Transmit a DSI packet */
CODE ssize_t (*transfer)(FAR struct mipi_dsi_host *host,
FAR const struct mipi_dsi_msg *msg);
};
/* Dsi host structure */
struct mipi_dsi_host
{
int bus;
FAR const struct mipi_dsi_host_ops *ops;
};
/* Dsi peripheral device structure panel dsi device */
struct mipi_dsi_device
{
FAR struct mipi_dsi_host *host; /* DSI host for this peripheral,
* almost on the panel */
char name[32]; /* DSI peripheral chip type */
uint16_t channel; /* Vitural channel assigned to this */
uint16_t lanes; /* Number of active data lanes */
uint8_t format; /* Pixel formal */
uint32_t mode_flags; /* Dsi operate mode flag */
uint32_t hs_rate; /* Maximum lane frequency for high speed
* mode in hertz, this shoud be set
* to the real limits of the hardware. */
uint32_t lp_rate; /* Maximum lane frequency for low power
* mode in hertz, this shoud be set
* to the real limits of the hardware. */
};
/****************************************************************************
* Public Functions Definitions
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: mipi_dsi_packet_format_is_short
*
* Description:
* Check if a packet is of the short format
*
* Input Parameters:
* type - MIPI DSI data type of the packet
*
* Returned Value:
* True if the packet for the given data type is a short packet, false
* otherwise.
*
****************************************************************************/
bool mipi_dsi_packet_format_is_short(uint8_t type);
/****************************************************************************
* Name: mipi_dsi_packet_format_is_long
*
* Description:
* Check if a packet is of the long format
*
* Input Parameters:
* type - MIPI DSI data type of the packet
*
* Returned Value:
* True if the packet for the given data type is a long packet, false
* otherwise.
*
****************************************************************************/
bool mipi_dsi_packet_format_is_long(uint8_t type);
/****************************************************************************
* Name: mipi_dsi_create_packet
*
* Description:
* Create a packet from a message according to the DSI protocol
*
* Input Parameters:
* packet - Pointer to a DSI packet structure
* msg - Message to translate into a packet
*
* Returned Value:
* Return: 0 on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_create_packet(FAR struct mipi_dsi_packet *packet,
FAR const struct mipi_dsi_msg *msg);
/****************************************************************************
* Name: mipi_dsi_host_register
*
* Description:
* Register mipi dsi host, if defined CONFIG_MIPI_DSI_DRIVER, will create
* character device at /dev.
*
* Input Parameters:
* host - An instance of the dsi host
*
* Returned Value:
* OK if the driver was successfully register; A negated errno value is
* returned on any failure.
*
****************************************************************************/
int mipi_dsi_host_register(FAR struct mipi_dsi_host *host);
/****************************************************************************
* Name: mipi_dsi_host_get
*
* Description:
* Find host in list by bus number. Lcd driver can get host by this
* interface to register dsi device.
*
* Input Parameters:
* bus - The dsi host bus number.
*
* Returned Value:
* struct mipi_dsi_host pointer if the host was successfully registered;
* NULL pointer is returned on any failure.
*
****************************************************************************/
FAR struct mipi_dsi_host *mipi_dsi_host_get(int bus);
/****************************************************************************
* Name: mipi_dsi_pixel_format_to_bpp
*
* Description:
* Obtain the number of bits per pixel for any given pixel format defined
* by the MIPI DSI specification
*
* Input Parameters:
* fmt - MIPI DSI pixel format
*
* Returned Value:
* The number of bits per pixel of the given pixel format.
*
****************************************************************************/
int mipi_dsi_pixel_format_to_bpp(uint8_t fmt);
/****************************************************************************
* Name: mipi_dsi_device_register_full
*
* Description:
* Register mipi dsi device, if defined CONFIG_MIPI_DSI_DRIVER, will create
* character device at /dev/dsiN/dev-xxx.
*
* Input Parameters:
* host - An instance of the dsi host
* name - The name of the dsi device
* channel - The channel used by dsi device
*
* Returned Value:
* struct mipi_dsi_device* if the driver was successfully register; NULL is
* returned on any failure.
*
****************************************************************************/
FAR struct mipi_dsi_device *
mipi_dsi_device_register(FAR struct mipi_dsi_host *host,
FAR const char *name, int channel);
/****************************************************************************
* Name: mipi_dsi_attach
*
* Description:
* Attach a DSI device to its DSI host
*
* Input Parameters:
* device - DSI peripheral
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_attach(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_detach
*
* Description:
* Detach a DSI device from its DSI host
*
* Input Parameters:
* device - DSI peripheral device
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_detach(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_transfer
*
* Description:
* Transfer message to display modules
*
* Input Parameters:
* device - DSI peripheral
* msg - Message to transfer
*
* Returned Value:
* The number of bytes successfully transfered or a negative error code on
* failure.
*
****************************************************************************/
ssize_t mipi_dsi_transfer(FAR struct mipi_dsi_device *device,
FAR struct mipi_dsi_msg *msg);
/****************************************************************************
* Name: mipi_dsi_shutdown_peripheral
*
* Description:
* Send a Shutdown Peripheral command to the dsi device
*
* Input Parameters:
* device - DSI peripheral device
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_shutdown_peripheral(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_turn_on_peripheral
*
* Description:
* Send a Turn On Peripheral command to the dsi device
*
* Input Parameters:
* device - DSI peripheral device
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_turn_on_peripheral(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_set_maximum_return_packet_size
*
* Description:
* Specify the maximum size of the payload in a long packet transmitted
* from the peripheral back to the device host processor
*
* Input Parameters:
* device - DSI peripheral device
* value - The maximum size of the payload
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_set_maximum_return_packet_size(
FAR struct mipi_dsi_device *device, uint16_t value);
/****************************************************************************
* Name: mipi_dsi_compression_mode
*
* Description:
* Enable / disable DSC on the peripheral. Enable or disable Display Stream
* Compression on the peripheral using the default Picture Parameter Set
* and VESA DSC 1.1 algorithm.
*
* Input Parameters:
* device - DSI peripheral device
* enable - Whether to enable or disable the DSC
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_compression_mode(FAR struct mipi_dsi_device *device,
bool enable);
/****************************************************************************
* Name: mipi_dsi_generic_write
*
* Description:
* Transmit data using a generic write packet
*
* Input Parameters:
* device - DSI peripheral device
* payload - buffer containing the payload
* size - size of the payload
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_generic_write(FAR struct mipi_dsi_device *device,
FAR const void *payload, size_t size);
/****************************************************************************
* Name: mipi_dsi_generic_read
*
* Description:
* Receive data using a generic read packet.
* This function will automatically choose the right data type depending on
* the number of parameters passed in.
*
* Input Parameters:
* device - DSI peripheral device
* params - buffer containing the request parameters
* num_params - number of request parameters
* data - buffer in which to return the received data
* size - size of receive buffer
*
* Returned Value:
* The number of bytes successfully read or a negative error code on
* failure.
*
****************************************************************************/
ssize_t mipi_dsi_generic_read(FAR struct mipi_dsi_device *device,
FAR const void *params, size_t num_params,
FAR void *data, size_t size);
/****************************************************************************
* Name: mipi_dsi_dcs_write_buffer
*
* Description:
* Transmit a DCS command with payload.
* This function will automatically choose the right data type depending on
* the command payload length.
*
* Input Parameters:
* device - DSI peripheral device
* data - buffer containing data to be transmitted
* len - size of transmission buffer
*
* Returned Value:
* The number of bytes successfully transmitted or a negative error
* code on failure.
*
****************************************************************************/
ssize_t mipi_dsi_dcs_write_buffer(FAR struct mipi_dsi_device *device,
FAR const void *data, size_t len);
/****************************************************************************
* Name: mipi_dsi_dcs_write
*
* Description:
* Send DCS write command.
* This function will automatically choose the right data type depending on
* the command payload length.
*
* Input Parameters:
* device - DSI peripheral device
* cmd - DCS command
* data - buffer containing the command payload
* len - command payload length
*
* Returned Value:
* The number of bytes successfully transmitted or a negative error
* code on failure.
*
****************************************************************************/
ssize_t mipi_dsi_dcs_write(FAR struct mipi_dsi_device *device, uint8_t cmd,
FAR const void *data, size_t len);
/****************************************************************************
* Name: mipi_dsi_dcs_read
*
* Description:
* Send DCS read request command.
*
* Input Parameters:
* device - DSI peripheral device
* cmd - DCS command
* data - buffer in which to receive data
* len - size of receive buffer
*
* Returned Value:
* The number of bytes read or a negative error code on failure.
*
****************************************************************************/
ssize_t mipi_dsi_dcs_read(FAR struct mipi_dsi_device *device, uint8_t cmd,
FAR void *data, size_t len);
/****************************************************************************
* Name: mipi_dsi_dcs_nop
*
* Description:
* Send DCS nop packet
*
* Input Parameters:
* device - DSI peripheral device
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_nop(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_dcs_soft_reset
*
* Description:
* Send a software reset of the display module
*
* Input Parameters:
* device - DSI peripheral device
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_soft_reset(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_dcs_get_power_mode
*
* Description:
* Query the display module's current power mode
*
* Input Parameters:
* device - DSI peripheral device
* mode - return location of the current power mode
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_get_power_mode(FAR struct mipi_dsi_device *device,
FAR uint8_t *mode);
/****************************************************************************
* Name: mipi_dsi_dcs_get_pixel_format
*
* Description:
* Gets the pixel format for the RGB image data used by the display module.
*
* Input Parameters:
* device - DSI peripheral device
* format - return location of the pixel format
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_get_pixel_format(FAR struct mipi_dsi_device *device,
FAR uint8_t *format);
/****************************************************************************
* Name: mipi_dsi_dcs_enter_sleep_mode
*
* Description:
* Send a Enter Sleep Mode command to display module.
*
* Input Parameters:
* device - DSI peripheral device
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_enter_sleep_mode(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_dcs_exit_sleep_mode
*
* Description:
* Send a Exit Sleep Mode command to display module.
*
* Input Parameters:
* device - DSI peripheral device
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_exit_sleep_mode(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_dcs_set_display_off
*
* Description:
* Send a Display OFF command to display module. Stop displaying the image
* data on the display device.
*
* Input Parameters:
* device - DSI peripheral device
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_set_display_off(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_dcs_set_display_on
*
* Description:
* Send a Display On command to display module. Start displaying the image
* data on the display device.
*
* Input Parameters:
* device - DSI peripheral device
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_set_display_on(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_dcs_set_column_address
*
* Description:
* Define the column extent of the frame memory accessed by the host
* processor
*
* Input Parameters:
* device - DSI peripheral device
* start - first column address of frame memory
* end - last column address of frame memory
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_set_column_address(FAR struct mipi_dsi_device *device,
uint16_t start, uint16_t end);
/****************************************************************************
* Name: mipi_dsi_dcs_set_page_address
*
* Description:
* Define the page extent of the frame memory accessed by the host
* processor
*
* Input Parameters:
* device - DSI peripheral device
* start - first page address of frame memory
* end - last page address of frame memory
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_set_page_address(FAR struct mipi_dsi_device *device,
uint16_t start, uint16_t end);
/****************************************************************************
* Name: mipi_dsi_dcs_set_tear_off
*
* Description:
* Turn off the display module's Tearing Effect output signal on the TE
* signal line
*
* Input Parameters:
* device - DSI peripheral device
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_set_tear_off(FAR struct mipi_dsi_device *device);
/****************************************************************************
* Name: mipi_dsi_dcs_set_tear_on
*
* Description:
* Turn on the display module's Tearing Effect output signal on the TE
* signal line.
*
* Input Parameters:
* device - DSI peripheral device
* mode - Tearing Mode, MIPI_DSI_DCS_TEAR_MODE_VBLANK or
* MIPI_DSI_DCS_TEAR_MODE_VHBLANK
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_set_tear_on(FAR struct mipi_dsi_device *device,
uint8_t mode);
/****************************************************************************
* Name: mipi_dsi_dcs_set_pixel_format
*
* Description:
* Sets the pixel format for the RGB image data used by the display module.
*
* Input Parameters:
* device - DSI peripheral device
* format - pixel format
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_set_pixel_format(FAR struct mipi_dsi_device *device,
uint8_t format);
/****************************************************************************
* Name: mipi_dsi_dcs_set_tear_scanline
*
* Description:
* Set the scanline to use as trigger for the Tearing Effect output signal
* of the display module.
*
* Input Parameters:
* device - DSI peripheral device
* scanline - scanline to use as trigger
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_set_tear_scanline(FAR struct mipi_dsi_device *device,
uint16_t scanline);
/****************************************************************************
* Name: mipi_dsi_dcs_set_display_brightness
*
* Description:
* Sets the brightness value of the display.
*
* Input Parameters:
* device - DSI peripheral device
* brightness - brightness value
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_set_display_brightness(FAR struct mipi_dsi_device *device,
uint16_t brightness);
/****************************************************************************
* Name: mipi_dsi_dcs_get_display_brightness
*
* Description:
* Gets the current brightness value of the display.
*
* Input Parameters:
* device - DSI peripheral device
* brightness - brightness value
*
* Returned Value:
* OK on success or a negative error code on failure.
*
****************************************************************************/
int mipi_dsi_dcs_get_display_brightness(FAR struct mipi_dsi_device *device,
FAR uint16_t *brightness);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_VIDEO_MIPI_DSI_H */