nuttx/video/videomode/videomode_dump.c
Lwazi Dube bd2081aeec video/videomode: Fix EDID parsing and formatting of video mode dumps
Fixes several bugs in EDID parsing and consolidates syslog output in
videomode_dump to prevent broken lines.

Specific changes include:
  - Corrected bitwise masking for _HACT_HI (0xf0) and _HBLK_HI (0x0f)
    to properly extract the upper bits of horizontal active and blanking
    timings.
  - Multiplied raw EDID pixel clock by 10 to convert it into kHz, matching
    the expectation of the videomode struct dotclock field.
  - Combined fragmented syslog calls in videomode_dump into a single line
    to prevent unwanted newlines from splitting the output across multiple logs.

Signed-off-by: Lwazi Dube <lwazeh@gmail.com>
2026-08-29 11:09:11 -03:00

114 lines
4 KiB
C

/****************************************************************************
* video/videomode/videomode_dump.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <sys/types.h>
#include <syslog.h>
#include <nuttx/video/videomode.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define DIVIDE(x,y) (((x) + ((y) / 2)) / (y))
/****************************************************************************
* Name: videomode_refresh
*
* Description:
* Calculate the refresh rate.
*
* Input Parameters:
* videomode - The videomode to be dumped
*
* Returned Value:
* None
*
****************************************************************************/
static uint32_t videomode_refresh(FAR const struct videomode_s *videomode)
{
return DIVIDE(DIVIDE(videomode->dotclock * 1000, videomode->htotal),
videomode->vtotal);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: videomode_dump
*
* Description:
* Dump the content of a video mode one one line to the SYSLOG.
*
* Input Parameters:
* prefix - A string to print at the beginning of the line. May be
* NULL
* videomode - The videomode to be dumped
* terse - True: Print only a minimal amount of data, sufficient to
* identify the video mode.
*
* Returned Value:
* None
*
****************************************************************************/
void videomode_dump(FAR const char *prefix,
FAR const struct videomode_s *videomode, bool terse)
{
if (videomode != NULL)
{
if (terse)
{
syslog(LOG_INFO, "%s%ux%u @ %luHz",
prefix ? prefix : "",
videomode->hdisplay, videomode->vdisplay,
(unsigned long)videomode_refresh(videomode));
}
else
{
syslog(LOG_INFO,
"%s%ux%u @ %luHz (%lu %u %u %u %u %u %u %s%sH %s%sV)\n",
prefix ? prefix : "",
videomode->hdisplay, videomode->vdisplay,
(unsigned long)videomode_refresh(videomode),
(unsigned long)videomode->dotclock,
videomode->hsync_start,
videomode->hsync_end,
videomode->htotal,
videomode->vsync_start,
videomode->vsync_end,
videomode->vtotal,
videomode->flags & VID_PHSYNC ? "+" : "",
videomode->flags & VID_NHSYNC ? "-" : "",
videomode->flags & VID_PVSYNC ? "+" : "",
videomode->flags & VID_NVSYNC ? "-" : "");
}
}
}