glcd driver: Add direct support for framebuffer with paged memory layout.
'struct glcd_framebuf' now contains a layout type which can either be FB_TYPE_LINEAR (this is the default) or FB_TYPE_VPAGED. This actually affects the drawing function and the frame-buffer memory calculation. A new 'size' field is added to store the pre-calculated length. Adopt existing driver to make use of the new feature (currently only glcd2usb driver).
This commit is contained in:
@@ -130,8 +130,10 @@ glcd_init(Driver *drvthis)
|
||||
}
|
||||
p->framebuf.px_width = w;
|
||||
p->framebuf.px_height = h;
|
||||
p->framebuf.layout = FB_TYPE_LINEAR;
|
||||
p->framebuf.bytesPerLine = (p->framebuf.px_width + 7) / 8;
|
||||
debug(RPT_INFO, "%s: bytesPerLine (first) = %d", drvthis->name, BYTES_PER_LINE);
|
||||
p->framebuf.size = p->framebuf.bytesPerLine * p->framebuf.px_height;
|
||||
debug(RPT_INFO, "%s: size (first) = %d", drvthis->name, p->framebuf.size);
|
||||
|
||||
/* Set contrast */
|
||||
tmp = drvthis->config_get_int(drvthis->name, "Contrast", 0, GLCD_DEFAULT_CONTRAST);
|
||||
@@ -185,15 +187,23 @@ glcd_init(Driver *drvthis)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Allocate framebuffer (re-calculate bytesPerLine before) */
|
||||
p->framebuf.bytesPerLine = (p->framebuf.px_width + 7) / 8;
|
||||
debug(RPT_INFO, "%s: bytesPerLine (final) = %d", drvthis->name, BYTES_PER_LINE);
|
||||
p->framebuf.data = malloc(FB_BYTES_TOTAL);
|
||||
/* Allocate framebuffer (re-calculate size before) */
|
||||
if (p->framebuf.layout == FB_TYPE_LINEAR) {
|
||||
p->framebuf.bytesPerLine = (p->framebuf.px_width + 7) / 8;
|
||||
p->framebuf.size = p->framebuf.bytesPerLine * p->framebuf.px_height;
|
||||
}
|
||||
else {
|
||||
p->framebuf.bytesPerLine = 0;
|
||||
p->framebuf.size = (p->framebuf.px_height + 7) / 8 * p->framebuf.px_width;
|
||||
}
|
||||
debug(RPT_INFO, "%s: size (final) = %d", drvthis->name, p->framebuf.size);
|
||||
|
||||
p->framebuf.data = malloc(p->framebuf.size);
|
||||
if (p->framebuf.data == NULL) {
|
||||
report(RPT_ERR, "%s: unable to allocate framebuffer", drvthis->name);
|
||||
return -1;
|
||||
}
|
||||
memset(p->framebuf.data, 0x00, FB_BYTES_TOTAL);
|
||||
memset(p->framebuf.data, 0x00, p->framebuf.size);
|
||||
|
||||
/* Initialize renderer */
|
||||
if (glcd_render_init(drvthis) != 0)
|
||||
@@ -356,7 +366,7 @@ glcd_clear(Driver *drvthis)
|
||||
|
||||
debug(RPT_DEBUG, "%s()", __FUNCTION__);
|
||||
|
||||
memset(p->framebuf.data, 0x00, FB_BYTES_TOTAL);
|
||||
memset(p->framebuf.data, 0x00, p->framebuf.size);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user