boards/arm/stm32/stm3210e-eval/src/stm32_lcd.c: Appease nxstyle
This commit is contained in:
parent
56803db5e8
commit
5631b7f464
@ -43,15 +43,17 @@
|
||||
* 2. Orise Tech SPFD5408B
|
||||
* 3. RenesasSP R61580
|
||||
*
|
||||
* The driver dynamically selects the LCD based on the reported LCD ID value. However,
|
||||
* code size can be reduced by suppressing support for individual LCDs using:
|
||||
* The driver dynamically selects the LCD based on the reported LCD ID value.
|
||||
* However, code size can be reduced by suppressing support for individual
|
||||
* LCDs using:
|
||||
*
|
||||
* CONFIG_STM3210E_AM240320_DISABLE
|
||||
* CONFIG_STM3210E_SPFD5408B_DISABLE
|
||||
* CONFIG_STM3210E_R61580_DISABLE
|
||||
*
|
||||
* Omitting the above (or setting them to "n") enables support for the LCD. Setting
|
||||
* any of the above to "y" will disable support for the corresponding LCD.
|
||||
* Omitting the above (or setting them to "n") enables support for the LCD.
|
||||
* Setting any of the above to "y" will disable support for the
|
||||
* corresponding LCD.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
@ -83,7 +85,8 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration **********************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* Check contrast selection */
|
||||
|
||||
#if !defined(CONFIG_LCD_MAXCONTRAST)
|
||||
@ -159,7 +162,8 @@
|
||||
|
||||
#define SPFD5408B_RDSHIFT 5
|
||||
|
||||
/* Display/Color Properties ***********************************************************/
|
||||
/* Display/Color Properties *************************************************/
|
||||
|
||||
/* Display Resolution */
|
||||
|
||||
#ifdef CONFIG_LCD_LANDSCAPE
|
||||
@ -175,7 +179,8 @@
|
||||
#define STM3210E_BPP 16
|
||||
#define STM3210E_COLORFMT FB_FMT_RGB16_565
|
||||
|
||||
/* STM3210E-EVAL LCD Hardware Definitions *********************************************/
|
||||
/* STM3210E-EVAL LCD Hardware Definitions ***********************************/
|
||||
|
||||
/* LCD /CS is CE4, Bank 4 of NOR/SRAM Bank 1~4 */
|
||||
|
||||
#define STM3210E_LCDBASE ((uint32_t)(0x60000000 | 0x0c000000))
|
||||
@ -340,6 +345,7 @@ struct stm3210e_dev_s
|
||||
/****************************************************************************
|
||||
* Private Function Protototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* Low Level LCD access */
|
||||
|
||||
static void stm3210e_writereg(uint8_t regaddr, uint16_t regval);
|
||||
@ -356,16 +362,19 @@ static void stm3210e_setcursor(uint16_t col, uint16_t row);
|
||||
|
||||
/* LCD Data Transfer Methods */
|
||||
|
||||
static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer,
|
||||
static int stm3210e_putrun(fb_coord_t row, fb_coord_t col,
|
||||
FAR const uint8_t *buffer,
|
||||
size_t npixels);
|
||||
static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
static int stm3210e_getrun(fb_coord_t row, fb_coord_t col,
|
||||
FAR uint8_t *buffer,
|
||||
size_t npixels);
|
||||
|
||||
/* LCD Configuration */
|
||||
|
||||
static int stm3210e_getvideoinfo(FAR struct lcd_dev_s *dev,
|
||||
FAR struct fb_videoinfo_s *vinfo);
|
||||
static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno,
|
||||
static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev,
|
||||
unsigned int planeno,
|
||||
FAR struct lcd_planeinfo_s *pinfo);
|
||||
|
||||
/* LCD RGB Mapping */
|
||||
@ -385,7 +394,8 @@ static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno
|
||||
static int stm3210e_getpower(struct lcd_dev_s *dev);
|
||||
static int stm3210e_setpower(struct lcd_dev_s *dev, int power);
|
||||
static int stm3210e_getcontrast(struct lcd_dev_s *dev);
|
||||
static int stm3210e_setcontrast(struct lcd_dev_s *dev, unsigned int contrast);
|
||||
static int stm3210e_setcontrast(struct lcd_dev_s *dev,
|
||||
unsigned int contrast);
|
||||
|
||||
/* LCD Power Management */
|
||||
|
||||
@ -454,6 +464,7 @@ static struct stm3210e_dev_s g_lcddev =
|
||||
.getplaneinfo = stm3210e_getplaneinfo,
|
||||
|
||||
/* LCD RGB Mapping -- Not supported */
|
||||
|
||||
/* Cursor Controls -- Not supported */
|
||||
|
||||
/* LCD Specific Controls */
|
||||
@ -473,7 +484,6 @@ static struct pm_callback_s g_lcdcb =
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@ -542,9 +552,9 @@ static inline void stm3210e_writegram(uint16_t rgbval)
|
||||
* Name: stm3210e_readsetup / stm3210e_readnosetup
|
||||
*
|
||||
* Description:
|
||||
* 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
|
||||
* returned data:
|
||||
* 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 returned data:
|
||||
*
|
||||
* - SPFD5408B: There appears to be a 5-bit shift in the returned data.
|
||||
* - R61580: There is a 16-bit (1 pixel) shift in the returned data.
|
||||
@ -575,8 +585,8 @@ static void stm3210e_readnosetup(FAR uint16_t *accum)
|
||||
* Name: stm3210e_readshift / stm3210e_readnoshift
|
||||
*
|
||||
* Description:
|
||||
* Read one correctly aligned pixel from the GRAM memory. Possibly shifting the
|
||||
* data and possibly swapping red and green components.
|
||||
* Read one correctly aligned pixel from the GRAM memory. Possibly
|
||||
* shifting the data and possibly swapping red and green components.
|
||||
*
|
||||
* - SPFD5408B: There appears to be a 5-bit shift in the returned data.
|
||||
* Red and green appear to be swapped on read-back as well
|
||||
@ -586,8 +596,8 @@ static void stm3210e_readnosetup(FAR uint16_t *accum)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* This version is used only for the SPFD5408B. It shifts the data by 5-bits and swaps
|
||||
* red and green
|
||||
/* This version is used only for the SPFD5408B. It shifts the data by
|
||||
* 5-bits and swaps red and green
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_STM3210E_SPFD5408B_DISABLE
|
||||
@ -601,7 +611,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
|
||||
|
||||
uint16_t next = LCD->value;
|
||||
|
||||
/* Return previous bits 0-10 as bits 6-15 and next data bits 11-15 as bits 0-5
|
||||
/* Return previous bits 0-10 as bits 6-15 and next data bits 11-15 as
|
||||
* bits 0-5
|
||||
*
|
||||
* xxxx xPPP PPPP PPPP
|
||||
* NNNN Nxxx xxxx xxxx
|
||||
@ -609,7 +620,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
|
||||
* Assuming that SPFD5408B_RDSHIFT == 5
|
||||
*/
|
||||
|
||||
uint16_t value = *accum << SPFD5408B_RDSHIFT | next >> (16-SPFD5408B_RDSHIFT);
|
||||
uint16_t value = *accum << SPFD5408B_RDSHIFT |
|
||||
next >> (16 - SPFD5408B_RDSHIFT);
|
||||
|
||||
/* Save the value for the next time we are called */
|
||||
|
||||
@ -627,7 +639,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
|
||||
|
||||
/* This is weird... If blue is zero, then red+green values are off by 0x20.
|
||||
* Except that both 0x0000 and 0x0020 can map to 0x0000. Need to revisit
|
||||
* this!!!!!!!!!!! I might be misinterpreting some of the data that I have.
|
||||
* this!!!!!!!!!!! I might be misinterpreting some of the data that I
|
||||
* have.
|
||||
*/
|
||||
|
||||
#if 0 /* REVISIT */
|
||||
@ -641,8 +654,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This version is used for the R61580 and for the AM240320. It neither shifts nor
|
||||
* swaps colors.
|
||||
/* This version is used for the R61580 and for the AM240320. It neither
|
||||
* shifts nor swaps colors.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_STM3210E_R61580_DISABLE) || !defined(CONFIG_STM3210E_AM240320_DISABLE)
|
||||
@ -658,8 +671,8 @@ static uint16_t stm3210e_readnoshift(FAR uint16_t *accum)
|
||||
* Name: stm3210e_setcursor
|
||||
*
|
||||
* Description:
|
||||
* Set the cursor position. In landscape mode, the "column" is actually the physical
|
||||
* Y position and the "row" is the physical X position.
|
||||
* Set the cursor position. In landscape mode, the "column" is actually
|
||||
* the physical Y position and the "row" is the physical X position.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -681,9 +694,11 @@ static void stm3210e_setcursor(uint16_t col, uint16_t row)
|
||||
****************************************************************************/
|
||||
|
||||
#if 0 /* Sometimes useful */
|
||||
static void stm3210e_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels)
|
||||
static void stm3210e_dumprun(FAR const char *msg, FAR uint16_t *run,
|
||||
size_t npixels)
|
||||
{
|
||||
int i, j;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
syslog(LOG_DEBUG, "\n%s:\n", msg);
|
||||
for (i = 0; i < npixels; i += 16)
|
||||
@ -714,7 +729,8 @@ static void stm3210e_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npix
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer,
|
||||
static int stm3210e_putrun(fb_coord_t row, fb_coord_t col,
|
||||
FAR const uint8_t *buffer,
|
||||
size_t npixels)
|
||||
{
|
||||
FAR const uint16_t *src = (FAR const uint16_t *)buffer;
|
||||
@ -728,8 +744,8 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
|
||||
/* Write the run to GRAM. */
|
||||
|
||||
#ifdef CONFIG_LCD_LANDSCAPE
|
||||
/* Convert coordinates -- Which edge of the display is the "top?" Here the edge
|
||||
* with the simplest conversion is used.
|
||||
/* Convert coordinates -- Which edge of the display is the "top?" Here the
|
||||
* edge with the simplest conversion is used.
|
||||
*/
|
||||
|
||||
col = (STM3210E_XRES - 1) - col;
|
||||
@ -743,7 +759,9 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
|
||||
stm3210e_gramselect();
|
||||
for (i = 0; i < npixels; i++)
|
||||
{
|
||||
/* Write the next pixel to this position (auto-decrements to the next column) */
|
||||
/* Write the next pixel to this position (auto-decrements to the next
|
||||
* column)
|
||||
*/
|
||||
|
||||
stm3210e_writegram(*src++);
|
||||
}
|
||||
@ -787,6 +805,7 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
|
||||
col--;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -804,7 +823,8 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
static int stm3210e_getrun(fb_coord_t row, fb_coord_t col,
|
||||
FAR uint8_t *buffer,
|
||||
size_t npixels)
|
||||
{
|
||||
FAR uint16_t *dest = (FAR uint16_t *)buffer;
|
||||
@ -850,8 +870,8 @@ static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
/* Read the run from GRAM. */
|
||||
|
||||
#ifdef CONFIG_LCD_LANDSCAPE
|
||||
/* Convert coordinates -- Which edge of the display is the "top?" Here the edge
|
||||
* with the simplest conversion is used.
|
||||
/* Convert coordinates -- Which edge of the display is the "top?" Here the
|
||||
* edge with the simplest conversion is used.
|
||||
*/
|
||||
|
||||
col = (STM3210E_XRES - 1) - col;
|
||||
@ -870,7 +890,9 @@ static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
|
||||
for (i = 0; i < npixels; i++)
|
||||
{
|
||||
/* Read the next pixel from this position (autoincrements to the next row) */
|
||||
/* Read the next pixel from this position (autoincrements to the next
|
||||
* row)
|
||||
*/
|
||||
|
||||
*dest++ = readgram(&accum);
|
||||
}
|
||||
@ -933,7 +955,8 @@ static int stm3210e_getvideoinfo(FAR struct lcd_dev_s *dev,
|
||||
{
|
||||
DEBUGASSERT(dev && vinfo);
|
||||
ginfo("fmt: %d xres: %d yres: %d nplanes: %d\n",
|
||||
g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes);
|
||||
g_videoinfo.fmt, g_videoinfo.xres,
|
||||
g_videoinfo.yres, g_videoinfo.nplanes);
|
||||
memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s));
|
||||
return OK;
|
||||
}
|
||||
@ -946,7 +969,8 @@ static int stm3210e_getvideoinfo(FAR struct lcd_dev_s *dev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno,
|
||||
static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev,
|
||||
unsigned int planeno,
|
||||
FAR struct lcd_planeinfo_s *pinfo)
|
||||
{
|
||||
DEBUGASSERT(dev && pinfo && planeno == 0);
|
||||
@ -959,8 +983,9 @@ static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno
|
||||
* Name: stm3210e_getpower
|
||||
*
|
||||
* Description:
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -974,8 +999,9 @@ static int stm3210e_getpower(struct lcd_dev_s *dev)
|
||||
* Name: stm3210e_poweroff
|
||||
*
|
||||
* Description:
|
||||
* Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On
|
||||
* backlit LCDs, this setting may correspond to the backlight setting.
|
||||
* Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER:
|
||||
* full on). On backlit LCDs, this setting may correspond to the backlight
|
||||
* setting.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -1011,8 +1037,9 @@ static int stm3210e_poweroff(void)
|
||||
* Name: stm3210e_setpower
|
||||
*
|
||||
* Description:
|
||||
* Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On
|
||||
* backlit LCDs, this setting may correspond to the backlight setting.
|
||||
* Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER:
|
||||
* full on). On backlit LCDs, this setting may correspond to the backlight
|
||||
* setting.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -1029,7 +1056,9 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
|
||||
uint32_t frac;
|
||||
uint32_t duty;
|
||||
|
||||
/* If we are coming up from the power off state, then re-configure the timer */
|
||||
/* If we are coming up from the power off state, then re-configure
|
||||
* the timer
|
||||
*/
|
||||
|
||||
if (g_lcddev.power == 0)
|
||||
{
|
||||
@ -1065,7 +1094,9 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
|
||||
|
||||
#ifndef CONFIG_STM3210E_AM240320_DISABLE
|
||||
# if !defined (CONFIG_STM3210E_SPFD5408B_DISABLE) || !defined(CONFIG_STM3210E_R61580_DISABLE)
|
||||
stm3210e_writereg(LCD_REG_7, g_lcddev.type == LCD_TYPE_AM240320 ? 0x0173 : 0x0112);
|
||||
stm3210e_writereg(LCD_REG_7,
|
||||
g_lcddev.type == LCD_TYPE_AM240320 ?
|
||||
0x0173 : 0x0112);
|
||||
# else
|
||||
stm3210e_writereg(LCD_REG_7, 0x0173);
|
||||
# endif
|
||||
@ -1231,7 +1262,6 @@ static void stm3210e_pm_notify(struct pm_callback_s *cb, int domain,
|
||||
default:
|
||||
{
|
||||
/* Should not get here */
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1276,8 +1306,8 @@ static void stm3210e_pm_notify(struct pm_callback_s *cb, int domain,
|
||||
static int stm3210e_pm_prepare(struct pm_callback_s *cb, int domain,
|
||||
enum pm_state_e pmstate)
|
||||
{
|
||||
/* No preparation to change power modes is required by the LCD driver. We always
|
||||
* accept the state change by returning OK.
|
||||
/* No preparation to change power modes is required by the LCD driver.
|
||||
* We always accept the state change by returning OK.
|
||||
*/
|
||||
|
||||
return OK;
|
||||
@ -1296,8 +1326,8 @@ static inline void stm3210e_lcdinitialize(void)
|
||||
{
|
||||
uint16_t id;
|
||||
|
||||
/* Check if the LCD is Orise Tech SPFD5408B Controller (or the compatible RenesasSP
|
||||
* R61580).
|
||||
/* Check if the LCD is Orise Tech SPFD5408B Controller (or the compatible
|
||||
* RenesasSP R61580).
|
||||
*/
|
||||
|
||||
id = stm3210e_readreg(LCD_REG_0);
|
||||
@ -1337,7 +1367,7 @@ static inline void stm3210e_lcdinitialize(void)
|
||||
stm3210e_writereg(LCD_REG_17, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
up_mdelay(50);
|
||||
|
||||
stm3210e_writereg(LCD_REG_16, 0x12B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
stm3210e_writereg(LCD_REG_16, 0x12b0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
up_mdelay(50);
|
||||
|
||||
stm3210e_writereg(LCD_REG_18, 0x01bd); /* External reference voltage= Vci */
|
||||
@ -1604,7 +1634,8 @@ static void stm3210e_backlight(void)
|
||||
|
||||
/* Calculate the TIM1 prescaler value */
|
||||
|
||||
prescaler = (STM32_PCLK2_FREQUENCY / CONFIG_STM3210E_LCD_PWMFREQUENCY + 65534) / 65535;
|
||||
prescaler = (STM32_PCLK2_FREQUENCY / CONFIG_STM3210E_LCD_PWMFREQUENCY +
|
||||
65534) / 65535;
|
||||
if (prescaler < 1)
|
||||
{
|
||||
prescaler = 1;
|
||||
@ -1754,9 +1785,9 @@ static void stm3210e_backlight(void)
|
||||
* Name: board_lcd_initialize
|
||||
*
|
||||
* Description:
|
||||
* 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).
|
||||
* 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).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -1801,8 +1832,8 @@ int board_lcd_initialize(void)
|
||||
* Name: board_lcd_getdev
|
||||
*
|
||||
* Description:
|
||||
* Return a a reference to the LCD object for the specified LCD. This allows support
|
||||
* for multiple LCD devices.
|
||||
* Return a a reference to the LCD object for the specified LCD. This
|
||||
* allows support for multiple LCD devices.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -1830,10 +1861,11 @@ void board_lcd_uninitialize(void)
|
||||
* Name: stm3210e_lcdclear
|
||||
*
|
||||
* Description:
|
||||
* This is a non-standard LCD interface just for the STM3210E-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.
|
||||
* This is a non-standard LCD interface just for the STM3210E-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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user