2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* drivers/lcd/mio283qt9a.c
|
|
|
|
*
|
2021-05-27 11:12:43 +02:00
|
|
|
* 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
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2021-05-27 11:12:43 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2021-05-27 11:12:43 +02:00
|
|
|
* 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.
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-04-13 22:32:20 +02:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Included Files
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
2021-05-18 08:59:14 +02:00
|
|
|
#include <assert.h>
|
2014-02-10 19:26:08 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include <nuttx/arch.h>
|
|
|
|
#include <nuttx/spi/spi.h>
|
|
|
|
#include <nuttx/lcd/lcd.h>
|
|
|
|
#include <nuttx/lcd/mio283qt9a.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_LCD_MIO283QT9A
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Pre-processor Definitions
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* Configuration ************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
/* Check contrast selection */
|
|
|
|
|
|
|
|
#if !defined(CONFIG_LCD_MAXCONTRAST)
|
|
|
|
# define CONFIG_LCD_MAXCONTRAST 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Check power setting */
|
|
|
|
|
|
|
|
#if !defined(CONFIG_LCD_MAXPOWER) || CONFIG_LCD_MAXPOWER < 1
|
|
|
|
# define CONFIG_LCD_MAXPOWER 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CONFIG_LCD_MAXPOWER > 255
|
|
|
|
# error "CONFIG_LCD_MAXPOWER must be less than 256 to fit in uint8_t"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Check orientation */
|
|
|
|
|
|
|
|
#if defined(CONFIG_LCD_PORTRAIT)
|
|
|
|
# if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) || defined(CONFIG_LCD_RPORTRAIT)
|
|
|
|
# error "Cannot define both portrait and any other orientations"
|
|
|
|
# endif
|
|
|
|
#elif defined(CONFIG_LCD_RPORTRAIT)
|
|
|
|
# if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE)
|
|
|
|
# error "Cannot define both rportrait and any other orientations"
|
|
|
|
# endif
|
|
|
|
#elif defined(CONFIG_LCD_LANDSCAPE)
|
|
|
|
# ifdef CONFIG_LCD_RLANDSCAPE
|
|
|
|
# error "Cannot define both landscape and any other orientations"
|
|
|
|
# endif
|
|
|
|
#elif !defined(CONFIG_LCD_RLANDSCAPE)
|
|
|
|
# define CONFIG_LCD_LANDSCAPE 1
|
|
|
|
#endif
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/* Display/Color Properties *************************************************/
|
|
|
|
|
2014-02-10 19:26:08 +01:00
|
|
|
/* Display Resolution */
|
|
|
|
|
2014-04-13 22:32:20 +02:00
|
|
|
#if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE)
|
2014-02-10 19:26:08 +01:00
|
|
|
# define MIO283QT9A_XRES 320
|
|
|
|
# define MIO283QT9A_YRES 240
|
|
|
|
#else
|
|
|
|
# define MIO283QT9A_XRES 240
|
|
|
|
# define MIO283QT9A_YRES 320
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Color depth and format */
|
|
|
|
|
|
|
|
#define MIO283QT9A_BPP 16
|
|
|
|
#define MIO283QT9A_COLORFMT FB_FMT_RGB16_565
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/* Hardware LCD/LCD controller definitions **********************************/
|
|
|
|
|
|
|
|
/* In this driver, I chose to use all literal constants for register address
|
|
|
|
* and values. Some recent experiences have shown me that during LCD bringup,
|
|
|
|
* it is more important to know the binary values rather than nice, people
|
|
|
|
* friendly names. Sad, but true.
|
2014-02-10 19:26:08 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define ILI9341_ID_1 0x93
|
|
|
|
#define ILI9341_ID_2 0x41
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Private Type Definition
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
/* This structure describes the state of this driver */
|
|
|
|
|
|
|
|
struct mio283qt9a_dev_s
|
|
|
|
{
|
|
|
|
/* Publicly visible device structure */
|
|
|
|
|
|
|
|
struct lcd_dev_s dev;
|
|
|
|
|
|
|
|
/* Private LCD-specific information follows */
|
|
|
|
|
|
|
|
FAR struct mio283qt9a_lcd_s *lcd; /* The contained platform-specific, LCD interface */
|
2021-03-04 08:02:21 +01:00
|
|
|
uint8_t power; /* Current power setting */
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
/* This is working memory allocated by the LCD driver for each LCD device
|
2021-03-04 08:02:21 +01:00
|
|
|
* and for each color plane.
|
|
|
|
* This memory will hold one raster line of data.
|
2014-02-10 19:26:08 +01:00
|
|
|
* The size of the allocated run buffer must therefore be at least
|
|
|
|
* (bpp * xres / 8). Actual alignment of the buffer must conform to the
|
|
|
|
* bitwidth of the underlying pixel type.
|
|
|
|
*
|
|
|
|
* If there are multiple planes, they may share the same working buffer
|
2021-03-04 08:02:21 +01:00
|
|
|
* because different planes will not be operate on concurrently.
|
|
|
|
* However, if there are multiple LCD devices, they must each have unique
|
|
|
|
* run buffers.
|
2014-02-10 19:26:08 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
uint16_t runbuffer[MIO283QT9A_XRES];
|
|
|
|
};
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Private Function Prototypes
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
2014-02-10 19:26:08 +01:00
|
|
|
/* Low Level LCD access */
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
static void mio283qt9a_putreg(FAR struct mio283qt9a_lcd_s *lcd,
|
|
|
|
uint8_t regaddr,
|
|
|
|
uint16_t regval);
|
2014-02-10 19:26:08 +01:00
|
|
|
#ifndef CONFIG_LCD_NOGETRUN
|
2021-03-04 08:02:21 +01:00
|
|
|
static uint16_t mio283qt9a_readreg(FAR struct mio283qt9a_lcd_s *lcd,
|
|
|
|
uint8_t regaddr);
|
2014-02-10 19:26:08 +01:00
|
|
|
#endif
|
|
|
|
static inline void mio283qt9a_gramwrite(FAR struct mio283qt9a_lcd_s *lcd,
|
|
|
|
uint16_t rgbcolor);
|
|
|
|
#ifndef CONFIG_LCD_NOGETRUN
|
|
|
|
static inline void mio283qt9a_readsetup(FAR struct mio283qt9a_lcd_s *lcd,
|
|
|
|
FAR uint16_t *accum);
|
|
|
|
static inline uint16_t mio283qt9a_gramread(FAR struct mio283qt9a_lcd_s *lcd,
|
|
|
|
FAR uint16_t *accum);
|
|
|
|
#endif
|
|
|
|
static void mio283qt9a_setarea(FAR struct mio283qt9a_lcd_s *lcd,
|
|
|
|
uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
|
|
|
|
|
|
|
/* LCD Data Transfer Methods */
|
|
|
|
|
2022-06-17 12:17:18 +02:00
|
|
|
static int mio283qt9a_putrun(FAR struct lcd_dev_s *dev,
|
|
|
|
fb_coord_t row, fb_coord_t col,
|
2021-03-04 08:02:21 +01:00
|
|
|
FAR const uint8_t *buffer,
|
|
|
|
size_t npixels);
|
2022-06-17 12:17:18 +02:00
|
|
|
static int mio283qt9a_getrun(FAR struct lcd_dev_s *dev,
|
|
|
|
fb_coord_t row, fb_coord_t col,
|
2021-03-04 08:02:21 +01:00
|
|
|
FAR uint8_t *buffer,
|
|
|
|
size_t npixels);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
/* LCD Configuration */
|
|
|
|
|
|
|
|
static int mio283qt9a_getvideoinfo(FAR struct lcd_dev_s *dev,
|
|
|
|
FAR struct fb_videoinfo_s *vinfo);
|
2021-03-04 08:02:21 +01:00
|
|
|
static int mio283qt9a_getplaneinfo(FAR struct lcd_dev_s *dev,
|
|
|
|
unsigned int planeno,
|
|
|
|
FAR struct lcd_planeinfo_s *pinfo);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
/* LCD RGB Mapping */
|
|
|
|
|
|
|
|
#ifdef CONFIG_FB_CMAP
|
|
|
|
# error "RGB color mapping not supported by this driver"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Cursor Controls */
|
|
|
|
|
|
|
|
#ifdef CONFIG_FB_HWCURSOR
|
|
|
|
# error "Cursor control not supported by this driver"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* LCD Specific Controls */
|
|
|
|
|
|
|
|
static int mio283qt9a_getpower(FAR struct lcd_dev_s *dev);
|
|
|
|
static int mio283qt9a_setpower(FAR struct lcd_dev_s *dev, int power);
|
|
|
|
static int mio283qt9a_getcontrast(FAR struct lcd_dev_s *dev);
|
2021-03-04 08:02:21 +01:00
|
|
|
static int mio283qt9a_setcontrast(FAR struct lcd_dev_s *dev,
|
|
|
|
unsigned int contrast);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
/* Initialization */
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
static inline int mio283qt9a_hwinitialize(
|
|
|
|
FAR struct mio283qt9a_dev_s *priv);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Private Data
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/* This driver can support only a signal MIO283QT9A device.
|
|
|
|
* The following is the single MIO283QT9A driver state instance:
|
2014-02-10 19:26:08 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
static struct mio283qt9a_dev_s g_lcddev;
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Private Functions
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_putreg
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Write to an LCD register
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
static void mio283qt9a_putreg(FAR struct mio283qt9a_lcd_s *lcd,
|
|
|
|
uint8_t regaddr, uint16_t regval)
|
|
|
|
{
|
2021-03-04 08:02:21 +01:00
|
|
|
/* Set the index register to the register address and write the register
|
|
|
|
* contents
|
|
|
|
*/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
lcd->index(lcd, regaddr);
|
|
|
|
lcd->write(lcd, regval);
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_readreg
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read from an LCD register
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
#ifndef CONFIG_LCD_NOGETRUN
|
2021-03-04 08:02:21 +01:00
|
|
|
static uint16_t mio283qt9a_readreg(FAR struct mio283qt9a_lcd_s *lcd,
|
|
|
|
uint8_t regaddr)
|
2014-02-10 19:26:08 +01:00
|
|
|
{
|
2021-03-04 08:02:21 +01:00
|
|
|
/* Set the index register to the register address and read the register
|
|
|
|
* contents.
|
|
|
|
*/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2014-04-13 22:32:20 +02:00
|
|
|
lcd->index(lcd, regaddr);
|
2014-02-10 19:26:08 +01:00
|
|
|
return lcd->read(lcd);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-04-16 20:17:35 +02:00
|
|
|
* Name: mio283qt9a_gramselect_write
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2014-04-16 20:17:35 +02:00
|
|
|
* Setup to write multiple pixels to the GRAM memory
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
static inline void mio283qt9a_gramselect_write(
|
|
|
|
FAR struct mio283qt9a_lcd_s *lcd)
|
2014-02-10 19:26:08 +01:00
|
|
|
{
|
|
|
|
lcd->index(lcd, 0x2c);
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-04-16 20:17:35 +02:00
|
|
|
* Name: mio283qt9a_gramselect_read
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Setup to read multiple pixels to the GRAM memory
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-04-16 20:17:35 +02:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
static inline void mio283qt9a_gramselect_read(
|
|
|
|
FAR struct mio283qt9a_lcd_s *lcd)
|
2014-04-16 20:17:35 +02:00
|
|
|
{
|
|
|
|
lcd->index(lcd, 0x2e);
|
|
|
|
lcd->readgram(lcd);
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_gramwrite
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Setup to read or write multiple pixels to the GRAM memory
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
static inline void mio283qt9a_gramwrite(
|
|
|
|
FAR struct mio283qt9a_lcd_s *lcd, uint16_t data)
|
2014-02-10 19:26:08 +01:00
|
|
|
{
|
|
|
|
lcd->write(lcd, data);
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_readsetup
|
|
|
|
*
|
|
|
|
* Description:
|
2021-03-04 08:02:21 +01:00
|
|
|
* Prime the operation by reading one pixel from the GRAM memory if
|
|
|
|
* necessary for this LCD type.
|
|
|
|
* When reading 16-bit gram data, there may be some shifts in the
|
2014-02-10 19:26:08 +01:00
|
|
|
* returned data:
|
|
|
|
*
|
|
|
|
* - ILI932x: Discard first dummy read; no shift in the return data
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
#ifndef CONFIG_LCD_NOGETRUN
|
|
|
|
static inline void mio283qt9a_readsetup(FAR struct mio283qt9a_lcd_s *lcd,
|
|
|
|
FAR uint16_t *accum)
|
|
|
|
{
|
|
|
|
#if 0 /* Probably not necessary... untested */
|
|
|
|
/* Read-ahead one pixel */
|
|
|
|
|
|
|
|
*accum = lcd->read(lcd);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_gramread
|
|
|
|
*
|
|
|
|
* Description:
|
2021-03-04 08:02:21 +01:00
|
|
|
* Read one correctly aligned pixel from the GRAM memory.
|
|
|
|
* Possibly shifting the data and possibly swapping red and green
|
|
|
|
* components.
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2014-04-13 22:32:20 +02:00
|
|
|
* - ILI932x: Unknown -- assuming colors are in the color order
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
#ifndef CONFIG_LCD_NOGETRUN
|
|
|
|
static inline uint16_t mio283qt9a_gramread(FAR struct mio283qt9a_lcd_s *lcd,
|
|
|
|
FAR uint16_t *accum)
|
|
|
|
{
|
|
|
|
/* Read the value (GRAM register already selected) */
|
|
|
|
|
2014-04-16 20:17:35 +02:00
|
|
|
return lcd->readgram(lcd);
|
2014-02-10 19:26:08 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_setarea
|
|
|
|
*
|
|
|
|
* Description:
|
2021-03-04 08:02:21 +01:00
|
|
|
* Set the cursor position.
|
|
|
|
* In landscape mode, the "column" is actually the physical
|
2014-02-10 19:26:08 +01:00
|
|
|
* Y position and the "row" is the physical X position.
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
static void mio283qt9a_setarea(FAR struct mio283qt9a_lcd_s *lcd,
|
2021-03-04 08:02:21 +01:00
|
|
|
uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
|
2014-02-10 19:26:08 +01:00
|
|
|
{
|
2015-10-10 18:41:00 +02:00
|
|
|
mio283qt9a_putreg(lcd, 0x2a, (x0 >> 8)); /* Set column address x0 */
|
|
|
|
lcd->write(lcd, (x0 & 0xff)); /* Set x0 */
|
|
|
|
lcd->write(lcd, (x1 >> 8)); /* Set x1 */
|
|
|
|
lcd->write(lcd, (x1 & 0xff)); /* Set x1 */
|
|
|
|
|
|
|
|
mio283qt9a_putreg(lcd, 0x2b, (y0 >> 8)); /* Set page address y0 */
|
|
|
|
lcd->write(lcd, (y0 & 0xff)); /* Set y0 */
|
|
|
|
lcd->write(lcd, (y1 >> 8)); /* Set y1 */
|
|
|
|
lcd->write(lcd, (y1 & 0xff)); /* Set y1 */
|
2014-02-10 19:26:08 +01:00
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_dumprun
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Dump the contexts of the run buffer:
|
|
|
|
*
|
|
|
|
* run - The buffer in containing the run read to be dumped
|
|
|
|
* npixels - The number of pixels to dump
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
#if 0 /* Sometimes useful */
|
2021-03-04 08:02:21 +01:00
|
|
|
static void mio283qt9a_dumprun(FAR const char *msg,
|
|
|
|
FAR uint16_t *run,
|
|
|
|
size_t npixels)
|
2014-02-10 19:26:08 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
|
2014-10-08 18:18:58 +02:00
|
|
|
syslog(LOG_INFO, "\n%s:\n", msg);
|
2014-02-10 19:26:08 +01:00
|
|
|
for (i = 0; i < npixels; i += 16)
|
|
|
|
{
|
|
|
|
up_putc(' ');
|
2014-10-08 18:18:58 +02:00
|
|
|
syslog(LOG_INFO, " ");
|
2014-02-10 19:26:08 +01:00
|
|
|
for (j = 0; j < 16; j++)
|
|
|
|
{
|
2014-10-08 18:18:58 +02:00
|
|
|
syslog(LOG_INFO, " %04x", *run++);
|
2014-02-10 19:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
up_putc('\n');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_putrun
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This method can be used to write a partial raster line to the LCD:
|
|
|
|
*
|
2022-06-17 12:17:18 +02:00
|
|
|
* dev - The lcd device
|
2014-02-10 19:26:08 +01:00
|
|
|
* row - Starting row to write to (range: 0 <= row < yres)
|
|
|
|
* col - Starting column to write to (range: 0 <= col <= xres-npixels)
|
|
|
|
* buffer - The buffer containing the run to be written to the LCD
|
|
|
|
* npixels - The number of pixels to write to the LCD
|
|
|
|
* (range: 0 < npixels <= xres-col)
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2022-06-17 12:17:18 +02:00
|
|
|
static int mio283qt9a_putrun(FAR struct lcd_dev_s *dev,
|
|
|
|
fb_coord_t row, fb_coord_t col,
|
2021-03-04 08:02:21 +01:00
|
|
|
FAR const uint8_t *buffer,
|
|
|
|
size_t npixels)
|
2014-02-10 19:26:08 +01:00
|
|
|
{
|
2022-06-17 12:17:18 +02:00
|
|
|
FAR struct mio283qt9a_dev_s *priv = (FAR struct mio283qt9a_dev_s *)dev;
|
2014-02-10 19:26:08 +01:00
|
|
|
FAR struct mio283qt9a_lcd_s *lcd = priv->lcd;
|
2015-10-10 18:41:00 +02:00
|
|
|
FAR const uint16_t *src = (FAR const uint16_t *)buffer;
|
2014-02-10 19:26:08 +01:00
|
|
|
int i;
|
2014-04-13 22:32:20 +02:00
|
|
|
|
2014-02-10 19:26:08 +01:00
|
|
|
/* Buffer must be provided and aligned to a 16-bit address boundary */
|
|
|
|
|
|
|
|
DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0);
|
|
|
|
|
|
|
|
/* Select the LCD */
|
|
|
|
|
|
|
|
lcd->select(lcd);
|
|
|
|
|
|
|
|
/* Write the run to GRAM. */
|
|
|
|
|
|
|
|
mio283qt9a_setarea(lcd, col, row, col + npixels - 1, row);
|
2014-04-16 20:17:35 +02:00
|
|
|
mio283qt9a_gramselect_write(lcd);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
for (i = 0; i < npixels; i++)
|
|
|
|
{
|
|
|
|
mio283qt9a_gramwrite(lcd, *src);
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* De-select the LCD */
|
|
|
|
|
|
|
|
lcd->deselect(lcd);
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_getrun
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This method can be used to read a partial raster line from the LCD:
|
|
|
|
*
|
2022-06-17 12:17:18 +02:00
|
|
|
* dev - The lcd device
|
2014-02-10 19:26:08 +01:00
|
|
|
* row - Starting row to read from (range: 0 <= row < yres)
|
|
|
|
* col - Starting column to read read (range: 0 <= col <= xres-npixels)
|
|
|
|
* buffer - The buffer in which to return the run read from the LCD
|
|
|
|
* npixels - The number of pixels to read from the LCD
|
|
|
|
* (range: 0 < npixels <= xres-col)
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2022-06-17 12:17:18 +02:00
|
|
|
static int mio283qt9a_getrun(FAR struct lcd_dev_s *dev,
|
|
|
|
fb_coord_t row, fb_coord_t col,
|
2021-03-04 08:02:21 +01:00
|
|
|
FAR uint8_t *buffer,
|
2014-02-10 19:26:08 +01:00
|
|
|
size_t npixels)
|
|
|
|
{
|
|
|
|
#ifndef CONFIG_LCD_NOGETRUN
|
2022-06-17 12:17:18 +02:00
|
|
|
FAR struct mio283qt9a_dev_s *priv = (FAR struct mio283qt9a_dev_s *)dev;
|
2014-02-10 19:26:08 +01:00
|
|
|
FAR struct mio283qt9a_lcd_s *lcd = priv->lcd;
|
2015-10-10 18:41:00 +02:00
|
|
|
FAR uint16_t *dest = (FAR uint16_t *)buffer;
|
2022-06-17 12:17:18 +02:00
|
|
|
uint16_t accum;
|
|
|
|
uint16_t test;
|
2014-02-10 19:26:08 +01:00
|
|
|
int i;
|
2014-04-13 22:32:20 +02:00
|
|
|
|
2014-02-10 19:26:08 +01:00
|
|
|
/* Buffer must be provided and aligned to a 16-bit address boundary */
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
lcdinfo("mio283qt9a_getrun row: %d col: %d npixels: %d\n",
|
|
|
|
row, col, npixels);
|
2014-02-10 19:26:08 +01:00
|
|
|
DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0);
|
|
|
|
|
|
|
|
/* Read the run from GRAM. */
|
|
|
|
|
|
|
|
/* Select the LCD */
|
|
|
|
|
|
|
|
lcd->select(lcd);
|
|
|
|
|
|
|
|
/* Red the run fram GRAM. */
|
|
|
|
|
|
|
|
mio283qt9a_setarea(lcd, col, row, col + npixels - 1, row);
|
2014-04-16 20:17:35 +02:00
|
|
|
mio283qt9a_gramselect_read(lcd);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
/* Prime the pump for unaligned read data */
|
|
|
|
|
|
|
|
mio283qt9a_readsetup(lcd, &accum);
|
|
|
|
|
|
|
|
for (i = 0; i < npixels; i++)
|
|
|
|
{
|
2015-10-10 18:41:00 +02:00
|
|
|
test = mio283qt9a_gramread(lcd, &accum);
|
2014-04-16 20:17:35 +02:00
|
|
|
*dest++ = test;
|
2014-02-10 19:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* De-select the LCD */
|
|
|
|
|
|
|
|
lcd->deselect(lcd);
|
|
|
|
return OK;
|
|
|
|
#else
|
|
|
|
return -ENOSYS;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_getvideoinfo
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Get information about the LCD video controller configuration.
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
static int mio283qt9a_getvideoinfo(FAR struct lcd_dev_s *dev,
|
|
|
|
FAR struct fb_videoinfo_s *vinfo)
|
|
|
|
{
|
|
|
|
DEBUGASSERT(dev && vinfo);
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("fmt: %d xres: %d yres: %d nplanes: 1\n",
|
2014-02-10 19:26:08 +01:00
|
|
|
MIO283QT9A_COLORFMT, MIO283QT9A_XRES, MIO283QT9A_YRES);
|
|
|
|
|
|
|
|
vinfo->fmt = MIO283QT9A_COLORFMT; /* Color format: RGB16-565: RRRR RGGG GGGB BBBB */
|
|
|
|
vinfo->xres = MIO283QT9A_XRES; /* Horizontal resolution in pixel columns */
|
|
|
|
vinfo->yres = MIO283QT9A_YRES; /* Vertical resolution in pixel rows */
|
|
|
|
vinfo->nplanes = 1; /* Number of color planes supported */
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_getplaneinfo
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Get information about the configuration of each LCD color plane.
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
static int mio283qt9a_getplaneinfo(FAR struct lcd_dev_s *dev,
|
|
|
|
unsigned int planeno,
|
|
|
|
FAR struct lcd_planeinfo_s *pinfo)
|
2014-02-10 19:26:08 +01:00
|
|
|
{
|
|
|
|
FAR struct mio283qt9a_dev_s *priv = (FAR struct mio283qt9a_dev_s *)dev;
|
|
|
|
|
|
|
|
DEBUGASSERT(dev && pinfo && planeno == 0);
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("planeno: %d bpp: %d\n", planeno, MIO283QT9A_BPP);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2015-10-10 18:41:00 +02:00
|
|
|
pinfo->putrun = mio283qt9a_putrun; /* Put a run into LCD memory */
|
|
|
|
pinfo->getrun = mio283qt9a_getrun; /* Get a run from LCD memory */
|
|
|
|
pinfo->buffer = (FAR uint8_t *)priv->runbuffer; /* Run scratch buffer */
|
|
|
|
pinfo->bpp = MIO283QT9A_BPP; /* Bits-per-pixel */
|
2022-06-17 12:17:18 +02:00
|
|
|
pinfo->dev = dev; /* The lcd device */
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_getpower
|
|
|
|
*
|
|
|
|
* Description:
|
2021-03-04 08:02:21 +01:00
|
|
|
* Get the LCD panel power status
|
|
|
|
* (0: full off - CONFIG_LCD_MAXPOWER: full on).
|
|
|
|
* On backlit LCDs, this setting may correspond to the backlight setting.
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
static int mio283qt9a_getpower(FAR struct lcd_dev_s *dev)
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("getpower: %d\n", 0);
|
2014-02-10 19:26:08 +01:00
|
|
|
return g_lcddev.power;
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_poweroff
|
|
|
|
*
|
|
|
|
* Description:
|
2021-03-04 08:02:21 +01:00
|
|
|
* Enable/disable LCD panel power
|
|
|
|
* (0: full off - CONFIG_LCD_MAXPOWER: full on).
|
|
|
|
* On backlit LCDs, this setting may correspond to the backlight setting.
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
static int mio283qt9a_poweroff(FAR struct mio283qt9a_lcd_s *lcd)
|
|
|
|
{
|
|
|
|
/* Select the LCD */
|
2021-03-04 08:02:21 +01:00
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("mio283qt9a_poweroff\n");
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
lcd->select(lcd);
|
|
|
|
|
|
|
|
/* Set the backlight off */
|
|
|
|
|
|
|
|
lcd->backlight(lcd, 0);
|
|
|
|
|
|
|
|
/* Turn the display off */
|
|
|
|
|
|
|
|
mio283qt9a_putreg(lcd, 0x28, 0x0000); /* GON=0, DTE=0, D=0 */
|
|
|
|
|
|
|
|
/* Deselect the LCD */
|
|
|
|
|
|
|
|
lcd->deselect(lcd);
|
|
|
|
|
|
|
|
/* Remember the power off state */
|
|
|
|
|
|
|
|
g_lcddev.power = 0;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_setpower
|
|
|
|
*
|
|
|
|
* Description:
|
2021-03-04 08:02:21 +01:00
|
|
|
* Enable/disable LCD panel power
|
|
|
|
* (0: full off - CONFIG_LCD_MAXPOWER: full on).
|
|
|
|
* On backlit LCDs, this setting may correspond to the backlight setting.
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
static int mio283qt9a_setpower(FAR struct lcd_dev_s *dev, int power)
|
|
|
|
{
|
|
|
|
FAR struct mio283qt9a_dev_s *priv = (FAR struct mio283qt9a_dev_s *)dev;
|
|
|
|
FAR struct mio283qt9a_lcd_s *lcd = priv->lcd;
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("setpower: %d\n", power);
|
2014-02-10 19:26:08 +01:00
|
|
|
DEBUGASSERT((unsigned)power <= CONFIG_LCD_MAXPOWER);
|
|
|
|
|
|
|
|
/* Set new power level */
|
|
|
|
|
|
|
|
if (power > 0)
|
|
|
|
{
|
|
|
|
/* Select the LCD */
|
|
|
|
|
|
|
|
lcd->select(lcd);
|
|
|
|
|
|
|
|
/* Set the backlight level */
|
|
|
|
|
|
|
|
lcd->backlight(lcd, power);
|
|
|
|
|
|
|
|
/* Then turn the display on: */
|
|
|
|
|
|
|
|
mio283qt9a_putreg(lcd, 0x29, 0x00); /* GON=1, DTE=1, D=2 */
|
|
|
|
|
|
|
|
/* Deselect the LCD */
|
|
|
|
|
|
|
|
lcd->deselect(lcd);
|
|
|
|
|
|
|
|
/* Remember the power on state */
|
|
|
|
|
|
|
|
g_lcddev.power = power;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Turn the display off */
|
|
|
|
|
|
|
|
mio283qt9a_poweroff(lcd);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_getcontrast
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST).
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
static int mio283qt9a_getcontrast(FAR struct lcd_dev_s *dev)
|
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("Not implemented\n");
|
2014-02-10 19:26:08 +01:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_setcontrast
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST).
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
static int mio283qt9a_setcontrast(FAR struct lcd_dev_s *dev,
|
|
|
|
unsigned int contrast)
|
2014-02-10 19:26:08 +01:00
|
|
|
{
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("contrast: %d\n", contrast);
|
2014-02-10 19:26:08 +01:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_hwinitialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize the LCD hardware.
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
static inline int mio283qt9a_hwinitialize(FAR struct mio283qt9a_dev_s *priv)
|
|
|
|
{
|
|
|
|
FAR struct mio283qt9a_lcd_s *lcd = priv->lcd;
|
2014-11-25 20:15:09 +01:00
|
|
|
#if !defined(CONFIG_LCD_NOGETRUN) || defined(CONFIG_DEBUG_LCD)
|
2014-02-10 19:26:08 +01:00
|
|
|
uint16_t id_a;
|
|
|
|
uint16_t id_b;
|
|
|
|
uint16_t id_c;
|
|
|
|
uint16_t id_d;
|
2014-11-25 20:15:09 +01:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_DEBUG_LCD
|
2014-02-10 19:26:08 +01:00
|
|
|
uint16_t id_e;
|
|
|
|
#endif
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Select the LCD */
|
|
|
|
|
|
|
|
lcd->select(lcd);
|
|
|
|
|
|
|
|
/* Read the HIMAX ID registger (0x00) */
|
|
|
|
|
|
|
|
#ifndef CONFIG_LCD_NOGETRUN
|
|
|
|
id_a = mio283qt9a_readreg(lcd, 0xd3);
|
|
|
|
id_b = lcd->read(lcd);
|
|
|
|
id_c = lcd->read(lcd);
|
|
|
|
id_d = lcd->read(lcd);
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("LCD ID: %04x %04x %04x %04x\n", id_a, id_b, id_c, id_d);
|
2014-11-25 20:15:09 +01:00
|
|
|
UNUSED(id_a);
|
|
|
|
UNUSED(id_b);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
/* Check if the ID is for the ILI9341 */
|
|
|
|
|
|
|
|
if (id_c == ILI9341_ID_1 && id_d == ILI9341_ID_2)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
mio283qt9a_putreg(lcd, 0x29, 0); /* Power on */
|
|
|
|
|
|
|
|
mio283qt9a_putreg(lcd, 0x13, 0); /* Normal display on */
|
|
|
|
mio283qt9a_putreg(lcd, 0xc0, 0x28); /* Power control C1 */
|
|
|
|
mio283qt9a_putreg(lcd, 0xc1, 0x01); /* Power control C2 BT = 1 */
|
|
|
|
mio283qt9a_putreg(lcd, 0xc5, 0x24); /* VCOM control, VMH = 3.6v */
|
|
|
|
lcd->write(lcd, 0x25); /* VML = -1.575v */
|
|
|
|
mio283qt9a_putreg(lcd, 0x26, 0x01); /* Gamma 2.2 */
|
|
|
|
mio283qt9a_putreg(lcd, 0x3a, 0x55); /* Pixel format set command */
|
|
|
|
|
|
|
|
#if defined(CONFIG_LCD_LANDSCAPE)
|
|
|
|
mio283qt9a_putreg(lcd, 0x36, 0x0028); /* MY=1, MX=0, MV=1, ML=0, BGR=1 */
|
|
|
|
#elif defined(CONFIG_LCD_PORTRAIT)
|
|
|
|
mio283qt9a_putreg(lcd, 0x36, 0x0008); /* MY=0, MX=0, MV=0, ML=0, BGR=1 */
|
|
|
|
#elif defined(CONFIG_LCD_RLANDSCAPE)
|
|
|
|
mio283qt9a_putreg(lcd, 0x36, 0x0068); /* MY=0, MX=1, MV=1, ML=0, BGR=1 */
|
|
|
|
#elif defined(CONFIG_LCD_RPORTRAIT)
|
|
|
|
mio283qt9a_putreg(lcd, 0x36, 0x00c8); /* MY=1, MX=0, MV=1, ML=0, BGR=1 */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Window setting */
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
mio283qt9a_setarea(lcd, 0, 0, (MIO283QT9A_XRES - 1),
|
|
|
|
(MIO283QT9A_YRES - 1));
|
2014-02-10 19:26:08 +01:00
|
|
|
mio283qt9a_putreg(lcd, 0x11, 0); /* Sleep out mode */
|
|
|
|
up_mdelay(25);
|
|
|
|
|
2014-11-25 20:15:09 +01:00
|
|
|
#ifdef CONFIG_DEBUG_LCD
|
2014-02-10 19:26:08 +01:00
|
|
|
/* Read back some info from the panel */
|
|
|
|
|
|
|
|
id_a = mio283qt9a_readreg(lcd, 0x04); /* Read display information */
|
|
|
|
id_b = lcd->read(lcd);
|
|
|
|
id_c = lcd->read(lcd);
|
|
|
|
id_d = lcd->read(lcd);
|
2021-03-04 08:02:21 +01:00
|
|
|
lcdinfo("LCD man ID: %02x, version: %02x, driver ID: %02x\n",
|
|
|
|
id_b, id_c, id_d);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
id_a = mio283qt9a_readreg(lcd, 0x09); /* Read display status */
|
|
|
|
id_b = lcd->read(lcd);
|
|
|
|
id_c = lcd->read(lcd);
|
|
|
|
id_d = lcd->read(lcd);
|
|
|
|
id_e = lcd->read(lcd);
|
2021-03-04 08:02:21 +01:00
|
|
|
lcdinfo("Display status %02x, %02x, %02x, %02x, %02x\n",
|
|
|
|
id_a, id_b, id_c, id_d, id_e);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
id_a = mio283qt9a_readreg(lcd, 0x0a); /* Read power status */
|
|
|
|
id_b = lcd->read(lcd);
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("Power status %02x, %02x\n", id_a, id_b);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
id_a = mio283qt9a_readreg(lcd, 0x0b); /* Read MADCTL */
|
|
|
|
id_b = lcd->read(lcd);
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("MADCTL %02x, %02x\n", id_a, id_b);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
id_a = mio283qt9a_readreg(lcd, 0x0c); /* Read pixel format */
|
|
|
|
id_b = lcd->read(lcd);
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("Pixel format %02x, %02x\n", id_a, id_b);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
id_a = mio283qt9a_readreg(lcd, 0x0d); /* Read image format */
|
|
|
|
id_b = lcd->read(lcd);
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("Image format %02x, %02x\n", id_a, id_b);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
id_a = mio283qt9a_readreg(lcd, 0x0e); /* read signal mode */
|
|
|
|
id_b = lcd->read(lcd);
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("Signal mode %02x, %02x\n", id_a, id_b);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
id_a = mio283qt9a_readreg(lcd, 0x0f); /* read self diag */
|
|
|
|
id_b = lcd->read(lcd);
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("Self diag %02x, %02x\n", id_a, id_b);
|
2014-11-25 20:15:09 +01:00
|
|
|
#endif
|
2014-02-10 19:26:08 +01:00
|
|
|
ret = OK;
|
|
|
|
}
|
|
|
|
#ifndef CONFIG_LCD_NOGETRUN
|
|
|
|
else
|
|
|
|
{
|
2016-06-12 17:26:00 +02:00
|
|
|
lcderr("ERROR: Unsupported LCD type\n");
|
2014-02-10 19:26:08 +01:00
|
|
|
ret = -ENODEV;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* De-select the LCD */
|
|
|
|
|
|
|
|
lcd->deselect(lcd);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Public Functions
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-04-13 22:32:20 +02:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_lcdinitialize
|
|
|
|
*
|
|
|
|
* Description:
|
2021-03-04 08:02:21 +01:00
|
|
|
* Initialize the LCD video hardware.
|
|
|
|
* The initial state of the LCD is fully initialized, display memory
|
|
|
|
* cleared, and the LCD ready to use, but with the power setting at 0
|
|
|
|
* (full off).
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
FAR struct lcd_dev_s *mio283qt9a_lcdinitialize(
|
|
|
|
FAR struct mio283qt9a_lcd_s *lcd)
|
2014-02-10 19:26:08 +01:00
|
|
|
{
|
|
|
|
FAR struct mio283qt9a_dev_s *priv;
|
|
|
|
int ret;
|
|
|
|
|
2016-06-11 19:59:51 +02:00
|
|
|
lcdinfo("Initializing\n");
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/* If we could support multiple MIO283QT9A devices, this is where we would
|
2022-06-17 12:17:18 +02:00
|
|
|
* allocate a new driver data structure.
|
2014-02-10 19:26:08 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
priv = &g_lcddev;
|
|
|
|
|
|
|
|
/* Initialize the driver data structure */
|
|
|
|
|
|
|
|
priv->dev.getvideoinfo = mio283qt9a_getvideoinfo;
|
|
|
|
priv->dev.getplaneinfo = mio283qt9a_getplaneinfo;
|
|
|
|
priv->dev.getpower = mio283qt9a_getpower;
|
|
|
|
priv->dev.setpower = mio283qt9a_setpower;
|
|
|
|
priv->dev.getcontrast = mio283qt9a_getcontrast;
|
|
|
|
priv->dev.setcontrast = mio283qt9a_setcontrast;
|
|
|
|
priv->lcd = lcd;
|
|
|
|
|
|
|
|
/* Configure and enable LCD */
|
|
|
|
|
|
|
|
ret = mio283qt9a_hwinitialize(priv);
|
|
|
|
if (ret == OK)
|
|
|
|
{
|
|
|
|
/* Clear the display (setting it to the color 0=black) */
|
|
|
|
|
|
|
|
mio283qt9a_clear(&priv->dev, 0x0000);
|
|
|
|
|
|
|
|
/* Turn the display off */
|
|
|
|
|
|
|
|
mio283qt9a_poweroff(lcd);
|
|
|
|
return &g_lcddev.dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2014-02-10 19:26:08 +01:00
|
|
|
* Name: mio283qt9a_clear
|
|
|
|
*
|
|
|
|
* Description:
|
2021-03-04 08:02:21 +01:00
|
|
|
* This is a non-standard LCD interface just for the stm3240g-EVAL board.
|
|
|
|
* Because of the various rotations, clearing the display in the normal
|
|
|
|
* way by writing a sequences of runs that covers the entire display can
|
|
|
|
* be very slow. Here the display is cleared by simply setting all GRAM
|
|
|
|
* memory to the specified color.
|
2014-02-10 19:26:08 +01:00
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
void mio283qt9a_clear(FAR struct lcd_dev_s *dev, uint16_t color)
|
|
|
|
{
|
|
|
|
FAR struct mio283qt9a_dev_s *priv = (FAR struct mio283qt9a_dev_s *)dev;
|
|
|
|
FAR struct mio283qt9a_lcd_s *lcd = priv->lcd;
|
|
|
|
uint32_t i;
|
|
|
|
|
|
|
|
/* Select the LCD and set the drawring area */
|
|
|
|
|
|
|
|
lcd->select(lcd);
|
2021-03-04 08:02:21 +01:00
|
|
|
mio283qt9a_setarea(lcd, 0, 0, (MIO283QT9A_XRES - 1),
|
|
|
|
(MIO283QT9A_YRES - 1));
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
/* Prepare to write GRAM data */
|
|
|
|
|
2014-04-16 20:17:35 +02:00
|
|
|
mio283qt9a_gramselect_write(lcd);
|
2014-02-10 19:26:08 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/* Copy color into all of GRAM.
|
|
|
|
* Orientation does not matter in this case.
|
|
|
|
*/
|
2014-02-10 19:26:08 +01:00
|
|
|
|
|
|
|
for (i = 0; i < MIO283QT9A_XRES * MIO283QT9A_YRES; i++)
|
|
|
|
{
|
|
|
|
mio283qt9a_gramwrite(lcd, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* De-select the LCD */
|
|
|
|
|
|
|
|
lcd->deselect(lcd);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_LCD_MIO283QT9A */
|