Make re-usuable to userland. The vesagtf standalone build is #if'd out for now.

This commit is contained in:
mlelstv 2021-12-25 13:51:31 +00:00
parent 630a5cc129
commit 08b20cda6b
2 changed files with 24 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: edid.c,v 1.15 2020/01/25 15:59:11 maxv Exp $ */
/* $NetBSD: edid.c,v 1.16 2021/12/25 13:51:31 mlelstv Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@ -32,13 +32,22 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: edid.c,v 1.15 2020/01/25 15:59:11 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: edid.c,v 1.16 2021/12/25 13:51:31 mlelstv Exp $");
#ifdef _KERNEL
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#else
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#endif
#include <dev/videomode/videomode.h>
#include <dev/videomode/ediddevs.h>
#include <dev/videomode/edidreg.h>
@ -132,7 +141,7 @@ edid_is_valid(uint8_t *d)
{
int sum = 0, i;
uint8_t sig[8] = EDID_SIGNATURE;
if (memcmp(d, sig, 8) != 0)
return EINVAL;
@ -430,7 +439,7 @@ static void bump_preferred_mode(struct edid_info *edid, struct videomode *m)
*/
if (edid->edid_preferred_mode == NULL) {
edid->edid_preferred_mode = m;
} else if ((strncmp(edid->edid_vendor, "IVM", 3) == 0) &&
} else if ((strncmp((char*)edid->edid_vendor, "IVM", 3) == 0) &&
(edid->edid_product == 0x4800) &&
(edid->edid_preferred_mode->dot_clock < m->dot_clock))
edid->edid_preferred_mode = m;
@ -546,14 +555,14 @@ edid_parse(uint8_t *data, struct edid_info *edid)
edid->edid_product = data[EDID_OFFSET_PRODUCT_ID] +
(data[EDID_OFFSET_PRODUCT_ID + 1] << 8);
name = edid_findvendor(edid->edid_vendor);
name = edid_findvendor((char *)edid->edid_vendor);
if (name != NULL)
strlcpy(edid->edid_vendorname, name,
sizeof(edid->edid_vendorname));
else
edid->edid_vendorname[0] = '\0';
name = edid_findproduct(edid->edid_vendor, edid->edid_product);
name = edid_findproduct((char *)edid->edid_vendor, edid->edid_product);
if (name != NULL)
strlcpy(edid->edid_productname, name,
sizeof(edid->edid_productname));
@ -647,8 +656,10 @@ edid_parse(uint8_t *data, struct edid_info *edid)
if (edid->edid_modes[i].dot_clock > max_dotclock)
max_dotclock = edid->edid_modes[i].dot_clock;
#ifdef _KERNEL
aprint_debug("max_dotclock according to supported modes: %d\n",
max_dotclock);
#endif
mhz = (max_dotclock + 999) / 1000;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vesagtf.c,v 1.3 2014/03/21 22:00:00 dholland Exp $ */
/* $NetBSD: vesagtf.c,v 1.4 2021/12/25 13:51:31 mlelstv Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@ -153,21 +153,17 @@
#ifdef _KERNEL
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vesagtf.c,v 1.3 2014/03/21 22:00:00 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: vesagtf.c,v 1.4 2021/12/25 13:51:31 mlelstv Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <dev/videomode/videomode.h>
#include <dev/videomode/vesagtf.h>
#else
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include "videomode.h"
#include "vesagtf.h"
void print_xf86_mode(struct videomode *m);
#include <inttypes.h>
#endif
#include <dev/videomode/videomode.h>
#include <dev/videomode/vesagtf.h>
#define CELL_GRAN 8 /* assumed character cell granularity */
@ -660,6 +656,7 @@ vesagtf_mode(unsigned x, unsigned y, unsigned refresh, struct videomode *vmp)
/* print_xf86_mode() - print the XFree86 modeline, given mode timings. */
#if 0
#ifndef _KERNEL
void
print_xf86_mode (struct videomode *vmp)
@ -700,3 +697,4 @@ main (int argc, char *argv[])
}
#endif
#endif