lib2245: Implement ip_getMemorySize() for the KA6900.

ip_imageProc() now intentionally aborts.
This commit is contained in:
Solomon Peachy 2024-11-11 18:48:34 -05:00
parent 718c505ba5
commit 9348003199

View file

@ -39,7 +39,7 @@
*/
#define LIB_VERSION "0.1.4"
#define LIB_VERSION "0.1.5"
#include <stdbool.h>
#include <stdio.h>
@ -126,8 +126,9 @@ struct ippHeader {
char model[16];
char ipp[4];
uint16_t version;
uint8_t serial[10]; /* null terminated */
uint8_t pad_0x15[32];
uint8_t serial[34]; /* null terminated */
int8_t unk_0x38;
uint8_t pad_0x39[7];
} __attribute__((packed));
STATIC_ASSERT(sizeof(struct ippHeader) == 64);
@ -174,15 +175,15 @@ struct ippConfKA {
uint8_t planeOrder[16];
/*@30*/ uint8_t num_panels; /* 0x01-0x03 */
uint8_t unk_0x31; /* 0x06 in IPP, 0x00 or 0x01 in cmd */
uint16_t unk_0x32; /* 0x0032 */
uint16_t unk_0x32; /* 0x0032 == 50d */
uint16_t max_panel_overlap; /* 0x0258 == 600d */
uint16_t panel_rows[3]; /* panel size, or 0 if not used */
uint16_t lam_rows[3]; /* panel size, or 0 if not used */
uint8_t unk_0x42; // 0x00
uint8_t unk_0x43; // 0x01 for "extended" ?
uint8_t unk_0x43; // 0x01 for an additional 1920 bytes in header? ?
uint16_t unk_0x44; // 0x01 for "extended enable" ?
uint8_t extraRows; // ?
uint8_t unk_0x45[57];
uint8_t unk_0x47[57];
} __attribute__((packed));
STATIC_ASSERT(sizeof(struct ippConfKA) == 128); /* KA6900 */
@ -399,17 +400,17 @@ static bool CIppMng_SetConf(struct CIppMng *this, void *ippData,
#if (__BYTE_ORDER != __LITTLE_ENDIAN)
this->conf.headWidth = le16_to_cpu(this->conf.headWidth);
#endif
if (this->ka6900) {
this->conf.max_panel_overlap = le16_to_cpu(this->conf.max_panel_overlap);
this->conf.unk_0x32 = le16_to_cpu(this->conf.unk_0x32); // XXX
this->conf.unk_0x44 = le16_to_cpu(this->conf.unk_0x44); // XXX
for (int i = 0 ; i < 3 ; i++) {
this->conf.panel_rows[i] = le16_to_cpu(this->conf.panel_rows[i]);
this->conf.lam_rows[i] = le16_to_cpu(this->conf.lam_rows[i]);
}
// XXX additional fields.
// XXX byteswap additional fields as needed
}
#endif
return 1;
}
@ -542,6 +543,34 @@ static bool CIppMng_GetIppData(struct CIppMng *this, struct SIppData *destPtr, u
return 1;
}
static uint16_t CIppMng_KAComputePanelRows(uint16_t *panelRows,
uint8_t *padRows,
struct ippConfKA *ippConf,
uint16_t height)
{
*panelRows = height;
*padRows = 1;
if ((ippConf->unk_0x43 != 0) && (ippConf->unk_0x44 > 1)) {
uint16_t uVar5 = 0;
int16_t incr = height + 12;
int i = 0;
do {
uVar5 = height + incr;
if (uVar5 > 2492)
break;
(*padRows)++;
height = uVar5;
i++;
} while (i < ippConf->unk_0x44);
*panelRows = height;
if (height < 2492)
height = 2492;
}
return height;
}
/*** CMidDataGen ***/
static void CMidDataGen_Init(struct CMidDataGen *this)
@ -1762,6 +1791,12 @@ bool ip_imageProc(uint16_t *destData, uint8_t *srcInRgb,
goto done;
rval = CIppMng_SetIPP(&ippMng, srcIpp, width, height);
if (ippMng.ka6900) {
fprintf(stderr, "ERROR: KA6900 not supported yet, aborting\n");
goto done;
}
if (rval)
rval = CImageProc_PulseGen(&imageProc, destData, srcInRgb);
@ -1815,16 +1850,37 @@ bool ip_getMemorySize(uint32_t *szMemory,
return 0;
}
// XXX KA6900 needs this to be rewritten heavily.
if (ippMng.ka6900) {
int rows;
if (height <= 2492) {
uint16_t panelRows;
uint8_t padRows;
rows = CIppMng_KAComputePanelRows(&panelRows,
&padRows,
&ippMng.conf,
height);
} else {
rows = 7302;
}
pixels = (rows * width);
pixels += ippMng.conf.extraRows * width;
if ((ippMng.conf.borderCapable == 0x02) &&
(width == 1548) && (height == 2140)) {
pixels = 2434*1844; /* ie 8x6 */
pixels *= 2 * ippMng.conf.planes;
if (ippMng.conf.unk_0x43)
*szMemory = pixels + 9856;
else
*szMemory = pixels + 7936;
} else {
pixels = height * width;
}
if ((ippMng.conf.borderCapable == 0x02) &&
(width == 1548) && (height == 2140)) {
pixels = 2434*1844; /* ie 8x6 */
} else {
pixels = height * width;
}
*szMemory = pixels * 2 * ippMng.conf.planes;
*szMemory = pixels * 2 * ippMng.conf.planes;
}
CIppMng_Cleanup(&ippMng);