mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 17:48:54 +08:00
video/videomode/videomode_lookup.c: At some additional lookups from FreeBSD. Not currently used in NuttX so ifdef'ed out for now.
This commit is contained in:
@@ -380,7 +380,7 @@ void am335x_lcd_edid(FAR const uint8_t *edid, size_t edid_len,
|
|||||||
|
|
||||||
if (videomode == NULL)
|
if (videomode == NULL)
|
||||||
{
|
{
|
||||||
videomode = videomode_lookup("640x480x60");
|
videomode = videomode_lookup_by_name("640x480x60");
|
||||||
DEBUGASSERT(videomode != NULL);
|
DEBUGASSERT(videomode != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ int up_fbinitialize(int display)
|
|||||||
#else
|
#else
|
||||||
/* Lookup the video mode corresponding to the default video mode */
|
/* Lookup the video mode corresponding to the default video mode */
|
||||||
|
|
||||||
videomode = videomode_lookup(CONFIG_BEAGLEBONE_VIDEOMODE);
|
videomode = videomode_lookup_by_name(CONFIG_BEAGLEBONE_VIDEOMODE);
|
||||||
if (videomode == NULL)
|
if (videomode == NULL)
|
||||||
{
|
{
|
||||||
lcderr("ERROR: Videomode \"%s\" is not supported.\n",
|
lcderr("ERROR: Videomode \"%s\" is not supported.\n",
|
||||||
|
|||||||
@@ -133,7 +133,39 @@ void sort_videomodes(FAR struct videomode_s *modes,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR const struct videomode_s *videomode_lookup(FAR const char *name);
|
FAR const struct videomode_s *videomode_lookup_by_name(FAR const char *name);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: videomode_lookup_by_dotclock
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Find the video mode in a look-up table with the matching width and
|
||||||
|
* height and the closest dot clock that does not exceed the requested
|
||||||
|
* dot clock.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if 0 /* Not used */
|
||||||
|
FAR const struct videomode_s *
|
||||||
|
videomode_lookup_by_dotclock(uint16_t width, uint16_t height,
|
||||||
|
uint32_t dotclock);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: videomode_lookup_by_refresh
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Find the video mode in a look-up table with the matching width and
|
||||||
|
* height and the closest refresh rate that does not exceed the requested
|
||||||
|
* rate.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if 0 /* Not used */
|
||||||
|
FAR const struct videomode_s *
|
||||||
|
videomode_lookup_by_refresh(uint16_t width, uint16_t height,
|
||||||
|
uint16_t refresh);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: videomode_dump
|
* Name: videomode_dump
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/video/videomode.h>
|
#include <nuttx/video/videomode.h>
|
||||||
|
#include <nuttx/video/vesagtf.h>
|
||||||
#include <nuttx/video/edid.h>
|
#include <nuttx/video/edid.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -174,7 +175,7 @@ static bool edid_std_timing(FAR const uint8_t *stdtim,
|
|||||||
/* First try to lookup the mode as a DMT timing */
|
/* First try to lookup the mode as a DMT timing */
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%dx%dx%d", x, y, f);
|
snprintf(name, sizeof(name), "%dx%dx%d", x, y, f);
|
||||||
if ((lookup = videomode_lookup(name)) != NULL)
|
if ((lookup = videomode_lookup_by_name(name)) != NULL)
|
||||||
{
|
{
|
||||||
*mode = *lookup;
|
*mode = *lookup;
|
||||||
}
|
}
|
||||||
@@ -532,7 +533,7 @@ int edid_parse(FAR const uint8_t *data, FAR struct edid_info_s *edid)
|
|||||||
{
|
{
|
||||||
if (estmodes & (1 << i))
|
if (estmodes & (1 << i))
|
||||||
{
|
{
|
||||||
mode = videomode_lookup(g_edid_modes[i]);
|
mode = videomode_lookup_by_name(g_edid_modes[i]);
|
||||||
if (mode != NULL)
|
if (mode != NULL)
|
||||||
{
|
{
|
||||||
edid->edid_modes[edid->edid_nmodes] = *mode;
|
edid->edid_modes[edid->edid_nmodes] = *mode;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/video/videomode.h>
|
#include <nuttx/video/videomode.h>
|
||||||
|
|
||||||
@@ -176,14 +177,15 @@ static const int g_nvideomodes = 46;
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: edid_mode_lookup
|
* Name: videomode_lookup_by_name
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Find the video mode in a look-up table
|
* Find the video mode in a look-up table by the name assigned to the
|
||||||
|
* video mode.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR const struct videomode_s *edid_mode_lookup(FAR const char *name)
|
FAR const struct videomode_s *videomode_lookup_by_name(FAR const char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -197,3 +199,122 @@ FAR const struct videomode_s *edid_mode_lookup(FAR const char *name)
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: videomode_lookup_by_dotclock
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Find the video mode in a look-up table with the matching width and
|
||||||
|
* height and the closest dot clock that does not exceed the requested
|
||||||
|
* dot clock.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if 0 /* Not used */
|
||||||
|
FAR const struct videomode_s *
|
||||||
|
videomode_lookup_by_dotclock(uint16_t width, uint16_t height,
|
||||||
|
uint32_t dotclock)
|
||||||
|
{
|
||||||
|
FAR const struct videomode_s *curr;
|
||||||
|
FAR const struct videomode_s *best = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
lcdinfo("Looking for %u x %u at up to %lu kHz\n",
|
||||||
|
width, height, (unsigned long)dotclock);
|
||||||
|
|
||||||
|
for (i = 0; i < g_nvideomodes; i++)
|
||||||
|
{
|
||||||
|
curr = &g_videomodes[i];
|
||||||
|
|
||||||
|
if (curr->hdisplay == width && curr->vdisplay == height &&
|
||||||
|
curr->dotclock <= dotclock)
|
||||||
|
{
|
||||||
|
if (best != NULL)
|
||||||
|
{
|
||||||
|
if (curr->dotclock > best->dotclock)
|
||||||
|
{
|
||||||
|
best = curr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
best = curr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (best != NULL)
|
||||||
|
{
|
||||||
|
lcdinfo("Found %s\n", best->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: videomode_lookup_by_refresh
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Find the video mode in a look-up table with the matching width and
|
||||||
|
* height and the closest refrsh rate that does not exceed the requested
|
||||||
|
* rate.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if 0 /* Not used */
|
||||||
|
FAR const struct videomode_s *
|
||||||
|
videomode_lookup_by_refresh(uint16_t width, uint16_t height,
|
||||||
|
uint16_t refresh)
|
||||||
|
{
|
||||||
|
FAR const struct videomode_s *curr;
|
||||||
|
FAR const struct videomode_s *best = NULL;
|
||||||
|
uint32_t mref;
|
||||||
|
int closest = 1000;
|
||||||
|
int diff;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
lcdinfo("Looking for %u x %u at up to %u Hz\n",
|
||||||
|
width, height, refresh);
|
||||||
|
|
||||||
|
for (i = 0; i < g_nvideomodes; i++)
|
||||||
|
{
|
||||||
|
curr = &g_videomodes[i];
|
||||||
|
|
||||||
|
if (curr->hdisplay == width && curr->vdisplay == height)
|
||||||
|
{
|
||||||
|
mref = curr->dotclock * 1000 / (curr->htotal * curr->vtotal);
|
||||||
|
diff = mref - (uint32_t)refresh;
|
||||||
|
if (diff < 0)
|
||||||
|
{
|
||||||
|
diff = -diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
lcdinfo("%s in %lu Hz, diff %d\n",
|
||||||
|
curr->name, (unsigned long)mref, diff);
|
||||||
|
|
||||||
|
if (best != NULL)
|
||||||
|
{
|
||||||
|
if (diff < closest)
|
||||||
|
{
|
||||||
|
best = curr;
|
||||||
|
closest = diff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
best = curr;
|
||||||
|
closest = diff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (best != NULL)
|
||||||
|
{
|
||||||
|
lcdinfo("Found %s %lu\n",
|
||||||
|
best->name, (unsigned long)best->dotclock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user