Add HDMI input and chip queries to GVFG SDK 3.1

- Expose HDMI input and chip information through the capture API and rename the full-frame OSD rendering entry point.
- Update the bundled Gigabyte library and add opt-in internal diagnostics with a user LED control.
- Update the customer API reference, generated PDF, and build guidance.

Validation: git diff --cached --check passed. Build and runtime tests were not run for this commit.
This commit is contained in:
Mark.lin
2026-11-17 17:40:25 +08:00
parent 47a5f041ee
commit 7a7027391e
20 changed files with 568 additions and 47 deletions
@@ -133,6 +133,43 @@ def extract_banner(template_docx: Path) -> bytes:
raise RuntimeError("Branding template does not contain word/media/image1.jpeg") from error
def add_pdf_bookmarks(body: str, source_pdf: Path, output_pdf: Path) -> None:
"""Reuse Edge's named destinations so bookmarks land at heading positions."""
from pypdf import PdfReader, PdfWriter
from pypdf.generic import Fit
reader = PdfReader(source_pdf)
writer = PdfWriter()
writer.clone_document_from_reader(reader)
destinations = reader.named_destinations
parent = None
count = 0
for match in re.finditer(r'<h([23])\s+id="(section-\d+)">(.*?)</h\1>', body, re.DOTALL):
level, section_id, inner = match.groups()
title = html.unescape(re.sub(r"<[^>]+>", "", inner)).strip()
destination = destinations.get('/' + section_id)
if destination is None:
destination = destinations.get(section_id)
if destination is None:
raise RuntimeError(f"PDF heading destination not found: {section_id}")
page = reader.get_destination_page_number(destination)
if page is None:
raise RuntimeError(f"PDF heading page not found: {section_id}")
bookmark = writer.add_outline_item(
title, page, parent=parent if level == '3' else None,
fit=Fit.xyz(destination.left, destination.top, destination.zoom),
)
if level == '2':
parent = bookmark
count += 1
if not count:
raise RuntimeError("No chapter headings found for PDF bookmarks.")
writer.page_mode = '/UseOutlines'
with output_pdf.open('wb') as stream:
writer.write(stream)
print(f"PDF bookmarks created: {count}")
def build_pdf(input_markdown: Path, output_pdf: Path, template_docx: Path) -> None:
for required in (input_markdown, template_docx):
if not required.is_file():
@@ -187,7 +224,7 @@ def build_pdf(input_markdown: Path, output_pdf: Path, template_docx: Path) -> No
details = completed.stderr.decode(errors="replace").strip()
raise RuntimeError(f"Microsoft Edge did not create a valid PDF. {details}")
shutil.copyfile(plain_pdf, output_pdf)
add_pdf_bookmarks(body, plain_pdf, output_pdf)
if not output_pdf.is_file() or output_pdf.stat().st_size < 10_000:
raise RuntimeError("The generated PDF is missing or unexpectedly small.")
@@ -195,11 +232,18 @@ def build_pdf(input_markdown: Path, output_pdf: Path, template_docx: Path) -> No
def main() -> None:
script_dir = Path(__file__).resolve().parent
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--add-bookmarks', action='store_true', help='Add bookmarks using HTML, input PDF, and output PDF positional arguments.')
parser.add_argument("input_markdown", nargs="?", type=Path, default=script_dir / "GVFG_CUSTOMER_API_REFERENCE.md")
parser.add_argument("output_pdf", nargs="?", type=Path)
parser.add_argument("template_docx", nargs="?", type=Path, default=script_dir / "GVFG_CUSTOMER_API_REFERENCE.docx")
args = parser.parse_args()
if args.add_bookmarks:
if args.output_pdf is None:
parser.error('--add-bookmarks requires HTML, input PDF, and output PDF paths')
add_pdf_bookmarks(args.input_markdown.read_text(encoding='utf-8'), args.output_pdf, args.template_docx)
return
input_markdown = args.input_markdown.resolve()
output_pdf = (args.output_pdf or input_markdown.with_suffix(".pdf")).resolve()
build_pdf(input_markdown, output_pdf, args.template_docx.resolve())