2008-11-27 23:56:45 +01:00
|
|
|
/****************************************************************************
|
2010-04-17 05:08:30 +02:00
|
|
|
* graphics/nxbe/nxbe_configure.c
|
2008-11-27 23:56:45 +01:00
|
|
|
*
|
2021-02-05 11:12:53 +01: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
|
2008-11-27 23:56:45 +01:00
|
|
|
*
|
2021-02-05 11:12:53 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-11-27 23:56:45 +01:00
|
|
|
*
|
2021-02-05 11:12:53 +01: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.
|
2008-11-27 23:56:45 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2009-12-17 20:24:18 +01:00
|
|
|
#include <stddef.h>
|
2008-11-27 23:56:45 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2019-04-09 01:14:41 +02:00
|
|
|
#include "nxglib.h"
|
2008-11-27 23:56:45 +01:00
|
|
|
#include "nxbe.h"
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-04-08 16:32:05 +02:00
|
|
|
* Pre-processor Definitions
|
2008-11-27 23:56:45 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
2014-07-12 04:47:12 +02:00
|
|
|
#ifndef CONFIG_NX_BGCOLOR
|
|
|
|
# define CONFIG_NX_BGCOLOR 0
|
|
|
|
#endif
|
|
|
|
|
2008-11-27 23:56:45 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-07-12 04:47:12 +02:00
|
|
|
static const nxgl_mxpixel_t g_bgcolor[CONFIG_NX_NPLANES] =
|
|
|
|
{
|
|
|
|
CONFIG_NX_BGCOLOR
|
|
|
|
|
|
|
|
#if CONFIG_NX_NPLANES > 1
|
|
|
|
# warning Missing logic for multiple color planes
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2008-11-27 23:56:45 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2010-04-17 05:08:30 +02:00
|
|
|
* Name: nxbe_configure
|
2008-11-27 23:56:45 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Configure the back end state structure based on information from the
|
|
|
|
* framebuffer driver
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-04-18 04:56:15 +02:00
|
|
|
int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
|
2008-11-27 23:56:45 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Get the video controller configuration */
|
|
|
|
|
2010-04-18 04:56:15 +02:00
|
|
|
ret = dev->getvideoinfo(dev, &be->vinfo);
|
2008-11-27 23:56:45 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-12 19:11:57 +02:00
|
|
|
gerr("ERROR: Failed to get vinfo\n");
|
2008-11-27 23:56:45 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-07-12 04:47:12 +02:00
|
|
|
/* Set the initial background color */
|
|
|
|
|
|
|
|
nxgl_colorcopy(be->bgcolor, g_bgcolor);
|
|
|
|
|
2008-11-27 23:56:45 +01:00
|
|
|
/* Check the number of color planes */
|
|
|
|
|
2019-03-17 18:34:45 +01:00
|
|
|
#ifdef CONFIG_DEBUG_GRAPHICS
|
2008-11-27 23:56:45 +01:00
|
|
|
if (be->vinfo.nplanes > CONFIG_NX_NPLANES)
|
|
|
|
{
|
2016-06-12 19:11:57 +02:00
|
|
|
gerr("ERROR: NX configured for only %d planes, controller wants %d\n",
|
2008-11-27 23:56:45 +01:00
|
|
|
CONFIG_NX_NPLANES, be->vinfo.nplanes);
|
|
|
|
return -E2BIG;
|
|
|
|
}
|
2010-04-17 18:00:58 +02:00
|
|
|
#endif
|
2008-11-27 23:56:45 +01:00
|
|
|
|
|
|
|
/* Then get information about each color plane */
|
|
|
|
|
|
|
|
for (i = 0; i < be->vinfo.nplanes; i++)
|
|
|
|
{
|
2010-04-18 04:56:15 +02:00
|
|
|
ret = dev->getplaneinfo(dev, i, &be->plane[i].pinfo);
|
2008-11-27 23:56:45 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-12 19:11:57 +02:00
|
|
|
gerr("ERROR: Failed to get pinfo[%d]\n", i);
|
2008-11-27 23:56:45 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-06-04 04:35:50 +02:00
|
|
|
be->plane[i].driver = dev;
|
|
|
|
|
2008-11-27 23:56:45 +01:00
|
|
|
/* Select rasterizers to match the BPP reported for this plane.
|
|
|
|
* NOTE that there are configuration options to eliminate support
|
|
|
|
* for unused BPP values. If the unused BPP values are not suppressed
|
|
|
|
* in this way, then ALL rasterizers will be drawn into the link and
|
|
|
|
* will signicantly increase the size
|
|
|
|
*/
|
|
|
|
|
2008-12-05 15:04:37 +01:00
|
|
|
#ifndef CONFIG_NX_DISABLE_1BPP
|
2008-11-27 23:56:45 +01:00
|
|
|
if (be->plane[i].pinfo.bpp == 1)
|
|
|
|
{
|
2019-03-14 21:38:56 +01:00
|
|
|
be->plane[i].dev.setpixel = nxgl_setpixel_1bpp;
|
|
|
|
be->plane[i].dev.fillrectangle = nxgl_fillrectangle_1bpp;
|
|
|
|
be->plane[i].dev.getrectangle = nxgl_getrectangle_1bpp;
|
|
|
|
be->plane[i].dev.filltrapezoid = nxgl_filltrapezoid_1bpp;
|
|
|
|
be->plane[i].dev.moverectangle = nxgl_moverectangle_1bpp;
|
|
|
|
be->plane[i].dev.copyrectangle = nxgl_copyrectangle_1bpp;
|
|
|
|
|
|
|
|
#ifdef CONFIG_NX_RAMBACKED
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].pwfb.setpixel = pwfb_setpixel_1bpp;
|
|
|
|
be->plane[i].pwfb.fillrectangle = pwfb_fillrectangle_1bpp;
|
|
|
|
be->plane[i].pwfb.getrectangle = pwfb_getrectangle_1bpp;
|
|
|
|
be->plane[i].pwfb.filltrapezoid = pwfb_filltrapezoid_1bpp;
|
|
|
|
be->plane[i].pwfb.moverectangle = pwfb_moverectangle_1bpp;
|
|
|
|
be->plane[i].pwfb.copyrectangle = pwfb_copyrectangle_1bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
#endif
|
2008-11-27 23:56:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2008-12-05 15:04:37 +01:00
|
|
|
#ifndef CONFIG_NX_DISABLE_2BPP
|
2008-11-27 23:56:45 +01:00
|
|
|
if (be->plane[i].pinfo.bpp == 2)
|
|
|
|
{
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].dev.setpixel = nxgl_setpixel_2bpp;
|
|
|
|
be->plane[i].dev.fillrectangle = nxgl_fillrectangle_2bpp;
|
|
|
|
be->plane[i].dev.getrectangle = nxgl_getrectangle_2bpp;
|
|
|
|
be->plane[i].dev.filltrapezoid = nxgl_filltrapezoid_2bpp;
|
|
|
|
be->plane[i].dev.moverectangle = nxgl_moverectangle_2bpp;
|
|
|
|
be->plane[i].dev.copyrectangle = nxgl_copyrectangle_2bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_RAMBACKED
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].pwfb.setpixel = pwfb_setpixel_2bpp;
|
|
|
|
be->plane[i].pwfb.fillrectangle = pwfb_fillrectangle_2bpp;
|
|
|
|
be->plane[i].pwfb.getrectangle = pwfb_getrectangle_2bpp;
|
|
|
|
be->plane[i].pwfb.filltrapezoid = pwfb_filltrapezoid_2bpp;
|
|
|
|
be->plane[i].pwfb.moverectangle = pwfb_moverectangle_2bpp;
|
|
|
|
be->plane[i].pwfb.copyrectangle = pwfb_copyrectangle_2bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
#endif
|
2008-11-27 23:56:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2008-12-05 15:04:37 +01:00
|
|
|
#ifndef CONFIG_NX_DISABLE_4BPP
|
2008-11-27 23:56:45 +01:00
|
|
|
if (be->plane[i].pinfo.bpp == 4)
|
|
|
|
{
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].dev.setpixel = nxgl_setpixel_4bpp;
|
|
|
|
be->plane[i].dev.fillrectangle = nxgl_fillrectangle_4bpp;
|
|
|
|
be->plane[i].dev.getrectangle = nxgl_getrectangle_4bpp;
|
|
|
|
be->plane[i].dev.filltrapezoid = nxgl_filltrapezoid_4bpp;
|
|
|
|
be->plane[i].dev.moverectangle = nxgl_moverectangle_4bpp;
|
|
|
|
be->plane[i].dev.copyrectangle = nxgl_copyrectangle_4bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_RAMBACKED
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].pwfb.setpixel = pwfb_setpixel_4bpp;
|
|
|
|
be->plane[i].pwfb.fillrectangle = pwfb_fillrectangle_4bpp;
|
|
|
|
be->plane[i].pwfb.getrectangle = pwfb_getrectangle_4bpp;
|
|
|
|
be->plane[i].pwfb.filltrapezoid = pwfb_filltrapezoid_4bpp;
|
|
|
|
be->plane[i].pwfb.moverectangle = pwfb_moverectangle_4bpp;
|
|
|
|
be->plane[i].pwfb.copyrectangle = pwfb_copyrectangle_4bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
#endif
|
2008-11-27 23:56:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2008-12-05 15:04:37 +01:00
|
|
|
#ifndef CONFIG_NX_DISABLE_8BPP
|
2008-11-27 23:56:45 +01:00
|
|
|
if (be->plane[i].pinfo.bpp == 8)
|
|
|
|
{
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].dev.setpixel = nxgl_setpixel_8bpp;
|
|
|
|
be->plane[i].dev.fillrectangle = nxgl_fillrectangle_8bpp;
|
|
|
|
be->plane[i].dev.getrectangle = nxgl_getrectangle_8bpp;
|
|
|
|
be->plane[i].dev.filltrapezoid = nxgl_filltrapezoid_8bpp;
|
|
|
|
be->plane[i].dev.moverectangle = nxgl_moverectangle_8bpp;
|
|
|
|
be->plane[i].dev.copyrectangle = nxgl_copyrectangle_8bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_RAMBACKED
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].pwfb.setpixel = pwfb_setpixel_8bpp;
|
|
|
|
be->plane[i].pwfb.fillrectangle = pwfb_fillrectangle_8bpp;
|
|
|
|
be->plane[i].pwfb.getrectangle = pwfb_getrectangle_8bpp;
|
|
|
|
be->plane[i].pwfb.filltrapezoid = pwfb_filltrapezoid_8bpp;
|
|
|
|
be->plane[i].pwfb.moverectangle = pwfb_moverectangle_8bpp;
|
|
|
|
be->plane[i].pwfb.copyrectangle = pwfb_copyrectangle_8bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
#endif
|
2019-04-09 19:32:42 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_SWCURSOR
|
|
|
|
be->plane[i].cursor.draw = nxglib_cursor_draw_8bpp;
|
|
|
|
be->plane[i].cursor.erase = nxglib_cursor_erase_8bpp;
|
|
|
|
be->plane[i].cursor.backup = nxglib_cursor_backup_8bpp;
|
|
|
|
#endif
|
2008-11-27 23:56:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2008-12-05 15:04:37 +01:00
|
|
|
#ifndef CONFIG_NX_DISABLE_16BPP
|
2008-11-27 23:56:45 +01:00
|
|
|
if (be->plane[i].pinfo.bpp == 16)
|
|
|
|
{
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].dev.setpixel = nxgl_setpixel_16bpp;
|
|
|
|
be->plane[i].dev.fillrectangle = nxgl_fillrectangle_16bpp;
|
|
|
|
be->plane[i].dev.getrectangle = nxgl_getrectangle_16bpp;
|
|
|
|
be->plane[i].dev.filltrapezoid = nxgl_filltrapezoid_16bpp;
|
|
|
|
be->plane[i].dev.moverectangle = nxgl_moverectangle_16bpp;
|
|
|
|
be->plane[i].dev.copyrectangle = nxgl_copyrectangle_16bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_RAMBACKED
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].pwfb.setpixel = pwfb_setpixel_16bpp;
|
|
|
|
be->plane[i].pwfb.fillrectangle = pwfb_fillrectangle_16bpp;
|
|
|
|
be->plane[i].pwfb.getrectangle = pwfb_getrectangle_16bpp;
|
|
|
|
be->plane[i].pwfb.filltrapezoid = pwfb_filltrapezoid_16bpp;
|
|
|
|
be->plane[i].pwfb.moverectangle = pwfb_moverectangle_16bpp;
|
|
|
|
be->plane[i].pwfb.copyrectangle = pwfb_copyrectangle_16bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
#endif
|
2019-04-09 19:32:42 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_SWCURSOR
|
|
|
|
be->plane[i].cursor.draw = nxglib_cursor_draw_16bpp;
|
|
|
|
be->plane[i].cursor.erase = nxglib_cursor_erase_16bpp;
|
|
|
|
be->plane[i].cursor.backup = nxglib_cursor_backup_16bpp;
|
|
|
|
#endif
|
2008-11-27 23:56:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2008-12-05 15:04:37 +01:00
|
|
|
#ifndef CONFIG_NX_DISABLE_24BPP
|
2008-11-27 23:56:45 +01:00
|
|
|
if (be->plane[i].pinfo.bpp == 24)
|
|
|
|
{
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].dev.setpixel = nxgl_setpixel_24bpp;
|
|
|
|
be->plane[i].dev.fillrectangle = nxgl_fillrectangle_24bpp;
|
|
|
|
be->plane[i].dev.getrectangle = nxgl_getrectangle_24bpp;
|
|
|
|
be->plane[i].dev.filltrapezoid = nxgl_filltrapezoid_24bpp;
|
|
|
|
be->plane[i].dev.moverectangle = nxgl_moverectangle_24bpp;
|
|
|
|
be->plane[i].dev.copyrectangle = nxgl_copyrectangle_24bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_RAMBACKED
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].pwfb.setpixel = pwfb_setpixel_24bpp;
|
|
|
|
be->plane[i].pwfb.fillrectangle = pwfb_fillrectangle_24bpp;
|
|
|
|
be->plane[i].pwfb.getrectangle = pwfb_getrectangle_24bpp;
|
|
|
|
be->plane[i].pwfb.filltrapezoid = pwfb_filltrapezoid_24bpp;
|
|
|
|
be->plane[i].pwfb.moverectangle = pwfb_moverectangle_24bpp;
|
|
|
|
be->plane[i].pwfb.copyrectangle = pwfb_copyrectangle_24bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
#endif
|
2019-04-09 19:32:42 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_SWCURSOR
|
|
|
|
be->plane[i].cursor.draw = nxglib_cursor_draw_24bpp;
|
|
|
|
be->plane[i].cursor.erase = nxglib_cursor_erase_24bpp;
|
|
|
|
be->plane[i].cursor.backup = nxglib_cursor_backup_24bpp;
|
|
|
|
#endif
|
2008-11-27 23:56:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2008-12-05 15:04:37 +01:00
|
|
|
#ifndef CONFIG_NX_DISABLE_32BPP
|
2008-11-27 23:56:45 +01:00
|
|
|
if (be->plane[i].pinfo.bpp == 32)
|
|
|
|
{
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].dev.setpixel = nxgl_setpixel_32bpp;
|
|
|
|
be->plane[i].dev.fillrectangle = nxgl_fillrectangle_32bpp;
|
|
|
|
be->plane[i].dev.getrectangle = nxgl_getrectangle_32bpp;
|
|
|
|
be->plane[i].dev.filltrapezoid = nxgl_filltrapezoid_32bpp;
|
|
|
|
be->plane[i].dev.moverectangle = nxgl_moverectangle_32bpp;
|
|
|
|
be->plane[i].dev.copyrectangle = nxgl_copyrectangle_32bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_RAMBACKED
|
2019-03-15 19:15:33 +01:00
|
|
|
be->plane[i].pwfb.setpixel = pwfb_setpixel_1bpp;
|
|
|
|
be->plane[i].pwfb.fillrectangle = pwfb_fillrectangle_32bpp;
|
|
|
|
be->plane[i].pwfb.getrectangle = pwfb_getrectangle_32bpp;
|
|
|
|
be->plane[i].pwfb.filltrapezoid = pwfb_filltrapezoid_32bpp;
|
|
|
|
be->plane[i].pwfb.moverectangle = pwfb_moverectangle_32bpp;
|
|
|
|
be->plane[i].pwfb.copyrectangle = pwfb_copyrectangle_32bpp;
|
2019-03-14 21:38:56 +01:00
|
|
|
#endif
|
2019-04-09 19:32:42 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NX_SWCURSOR
|
|
|
|
be->plane[i].cursor.draw = nxglib_cursor_draw_32bpp;
|
|
|
|
be->plane[i].cursor.erase = nxglib_cursor_erase_32bpp;
|
|
|
|
be->plane[i].cursor.backup = nxglib_cursor_backup_32bpp;
|
|
|
|
#endif
|
2008-11-27 23:56:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2019-03-14 21:38:56 +01:00
|
|
|
gerr("ERROR: Unsupported pinfo[%d] BPP: %d\n",
|
|
|
|
i, be->plane[i].pinfo.bpp);
|
2008-11-27 23:56:45 +01:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
}
|
2020-06-04 04:35:50 +02:00
|
|
|
|
2008-11-27 23:56:45 +01:00
|
|
|
return OK;
|
|
|
|
}
|