[common] lgmp: separate transport configuration

Move LGMP queue tunables into LGMPConfig.h and keep compatibility
aliases in KVMFR.h. Promote color-transform, SDR white-level, and
damage-limit definitions to transport-neutral common types so non-LGMP
transports do not depend on the KVMFR wire format.
This commit is contained in:
Geoffrey McRae
2026-07-20 05:09:43 +00:00
parent 5196c5503a
commit d4b3506e6c
11 changed files with 81 additions and 22 deletions

View File

@@ -26,22 +26,16 @@
#include <stdint.h>
#include <stdbool.h>
#include "types.h"
#include "LGMPConfig.h"
#define KVMFR_MAGIC "KVMFR---"
#define KVMFR_VERSION 23
// Fallback used by producers that cannot report the source display's SDR
// white level. IDD frames override this with IDDCX_METADATA2::SdrWhiteLevel.
#define KVMFR_SDR_WHITE_LEVEL_DEFAULT 203
#define KVMFR_MAX_DAMAGE_RECTS 64
#define LGMP_Q_POINTER 1
#define LGMP_Q_FRAME 2
#define LGMP_Q_FRAME_LEN 2
#define LGMP_Q_POINTER_LEN 32
#define KVMFR_SDR_WHITE_LEVEL_DEFAULT LG_SDR_WHITE_LEVEL_DEFAULT
#define KVMFR_MAX_DAMAGE_RECTS LG_MAX_FRAME_DAMAGE_RECTS
#ifdef _MSC_VER
// don't warn on zero length arrays
@@ -144,25 +138,18 @@ KVMFRCursor;
enum
{
KVMFR_COLOR_TRANSFORM_MATRIX = 0x1,
KVMFR_COLOR_TRANSFORM_LUT = 0x2,
KVMFR_COLOR_TRANSFORM_MATRIX = LG_COLOR_TRANSFORM_MATRIX,
KVMFR_COLOR_TRANSFORM_LUT = LG_COLOR_TRANSFORM_LUT,
};
typedef uint32_t KVMFRColorTransformFlags;
typedef LGColorTransformFlags KVMFRColorTransformFlags;
// Optional payload appended to KVMFRCursor when
// CURSOR_FLAG_COLOR_TRANSFORM is present. The matrix is an XYZ-to-XYZ
// adjustment; the LUT is applied after encoding to the active wire transfer
// function. Four LUT components keep the payload directly uploadable as an
// RGBA32F texture, with alpha reserved and set to 1.0.
typedef struct KVMFRColorTransform
{
KVMFRColorTransformFlags flags;
float matrix[3][4];
float scalar;
float lut[4096][4];
}
KVMFRColorTransform;
typedef LGColorTransform KVMFRColorTransform;
enum
{

View File

@@ -0,0 +1,30 @@
/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _H_LG_COMMON_LGMP_CONFIG_
#define _H_LG_COMMON_LGMP_CONFIG_
#define LGMP_Q_POINTER 1
#define LGMP_Q_FRAME 2
#define LGMP_Q_FRAME_LEN 2
#define LGMP_Q_POINTER_LEN 32
#endif

View File

@@ -22,6 +22,7 @@
#define _H_LG_COMMON_STRINGUTILS
#include <stdbool.h>
#include <stddef.h>
// vsprintf but with buffer allocation
int valloc_sprintf(char ** str, const char * format, va_list ap)
@@ -37,6 +38,9 @@ bool str_containsValue(const char * list, char delimiter, const char * value);
// Local implementation of strdup
char * lg_strdup(const char *s);
// copy a potentially unterminated string into a null-terminated buffer
void str_copy(char * dst, size_t dstSize, const char * src, size_t srcSize);
// search a non null terminated buffer for a value
const char * memsearch(
const char * haystack, size_t haystackSize,

View File

@@ -89,6 +89,26 @@ typedef enum CursorType
}
CursorType;
enum
{
LG_COLOR_TRANSFORM_MATRIX = 0x1,
LG_COLOR_TRANSFORM_LUT = 0x2,
};
typedef uint32_t LGColorTransformFlags;
#define LG_SDR_WHITE_LEVEL_DEFAULT 203
#define LG_MAX_FRAME_DAMAGE_RECTS 64
typedef struct LGColorTransform
{
LGColorTransformFlags flags;
float matrix[3][4];
float scalar;
float lut[4096][4];
}
LGColorTransform;
typedef struct StringPair
{
const char * name;

View File

@@ -112,6 +112,20 @@ char * lg_strdup(const char *s)
return out;
}
void str_copy(char * dst, size_t dstSize, const char * src, size_t srcSize)
{
if (!dstSize)
return;
const char * end = memchr(src, 0, srcSize);
const size_t srcLength = end ? (size_t)(end - src) : srcSize;
const size_t copySize = srcLength < dstSize - 1 ?
srcLength : dstSize - 1;
memcpy(dst, src, copySize);
dst[copySize] = 0;
}
const char * memsearch(
const char * haystack, size_t haystackSize,
const char * needle , size_t needleSize ,