Module Name: src
Committed By: tnn
Date: Thu Aug 5 00:16:36 UTC 2021
Modified Files:
src/sys/dev/ic: ssdfb.c ssdfbvar.h
Log Message:
ssdfb: prepare for supporting rgb color displays
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/ssdfbvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/ssdfb.c
diff -u src/sys/dev/ic/ssdfb.c:1.16 src/sys/dev/ic/ssdfb.c:1.17
--- src/sys/dev/ic/ssdfb.c:1.16 Thu Aug 5 00:02:51 2021
+++ src/sys/dev/ic/ssdfb.c Thu Aug 5 00:16:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb.c,v 1.16 2021/08/05 00:02:51 tnn Exp $ */
+/* $NetBSD: ssdfb.c,v 1.17 2021/08/05 00:16:36 tnn Exp $ */
/*
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.16 2021/08/05 00:02:51 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.17 2021/08/05 00:16:36 tnn Exp $");
#include "opt_ddb.h"
@@ -268,16 +268,35 @@ ssdfb_attach(struct ssdfb_softc *sc, int
goto out;
}
#ifdef SSDFB_USE_NATIVE_DEPTH
- ri->ri_depth = sc->sc_p->p_bits_per_pixel;
+ ri->ri_depth = sc->sc_p->p_bits_per_pixel;
#else
- ri->ri_depth = 8;
+ if (sc->sc_p->p_rgb && sc->sc_p->p_bits_per_pixel == 32) {
+ ri->ri_depth = sc->sc_p->p_bits_per_pixel;
+ ri->ri_rnum = 8;
+ ri->ri_gnum = 8;
+ ri->ri_bnum = 8;
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+ ri->ri_rpos = 0;
+ ri->ri_gpos = 8;
+ ri->ri_bpos = 16;
+#else
+ ri->ri_rpos = 24;
+ ri->ri_gpos = 16;
+ ri->ri_bpos = 8;
+#endif
+ } else {
+ ri->ri_depth = 8;
+ }
#endif
ri->ri_font = sc->sc_font;
ri->ri_width = sc->sc_p->p_width;
ri->ri_height = sc->sc_p->p_height;
ri->ri_stride = ri->ri_width * ri->ri_depth / 8;
ri->ri_hw = sc;
- ri->ri_flg = RI_FULLCLEAR | RI_FORCEMONO;
+ ri->ri_flg = RI_FULLCLEAR;
+ if (!sc->sc_p->p_rgb) {
+ ri->ri_flg |= RI_FORCEMONO;
+ }
sc->sc_ri_bits_len = round_page(ri->ri_stride * ri->ri_height);
ri->ri_bits = (u_char *)uvm_km_alloc(kernel_map, sc->sc_ri_bits_len,
0, UVM_KMF_WIRED);
@@ -290,7 +309,9 @@ ssdfb_attach(struct ssdfb_softc *sc, int
if (error)
goto out;
- ri->ri_caps &= ~WSSCREEN_WSCOLORS;
+ if (!sc->sc_p->p_rgb) {
+ ri->ri_caps &= ~WSSCREEN_WSCOLORS;
+ }
/*
* Save original emul ops & insert our damage notification hooks.
@@ -425,8 +446,10 @@ ssdfb_ioctl(void *v, void *vs, u_long cm
case WSDISPLAYIO_GET_FBINFO:
fbi = (struct wsdisplayio_fbinfo *)data;
error = wsdisplayio_get_fbinfo(&sc->sc_ri, fbi);
- fbi->fbi_subtype.fbi_cmapinfo.cmap_entries = cmaplen;
- /* fbi->fbi_pixeltype = WSFB_GREYSCALE */;
+ if (!sc->sc_p->p_rgb) {
+ fbi->fbi_subtype.fbi_cmapinfo.cmap_entries = cmaplen;
+ /* fbi->fbi_pixeltype = WSFB_GREYSCALE */;
+ }
return error;
case WSDISPLAYIO_LINEBYTES:
*(u_int *)data = sc->sc_ri.ri_stride;
@@ -483,6 +506,8 @@ ssdfb_ioctl(void *v, void *vs, u_long cm
return 0;
#endif
case WSDISPLAYIO_GETCMAP:
+ if (sc->sc_p->p_rgb)
+ return ENOTSUP;
wc = (struct wsdisplay_cmap *)data;
if (wc->index >= cmaplen ||
wc->count > cmaplen - wc->index)
@@ -1117,9 +1142,9 @@ ssdfb_sync_ssd1322(struct ssdfb_softc *s
* Transfer rasops bitmap into gddram shadow buffer while keeping track
* of the bounding box of the dirty region we scribbled over.
*/
- x1 = sc->sc_p->p_width;
+ x1 = width;
x2 = -1;
- y1 = sc->sc_p->p_height;
+ y1 = height;
y2 = -1;
blockp = (uint16_t*)sc->sc_gddram;
for (y = 0; y < height; y++) {
Index: src/sys/dev/ic/ssdfbvar.h
diff -u src/sys/dev/ic/ssdfbvar.h:1.7 src/sys/dev/ic/ssdfbvar.h:1.8
--- src/sys/dev/ic/ssdfbvar.h:1.7 Mon Aug 2 14:00:48 2021
+++ src/sys/dev/ic/ssdfbvar.h Thu Aug 5 00:16:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfbvar.h,v 1.7 2021/08/02 14:00:48 tnn Exp $ */
+/* $NetBSD: ssdfbvar.h,v 1.8 2021/08/05 00:16:36 tnn Exp $ */
/*
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -235,6 +235,13 @@
#define SSD1353_CMD_SET_SECOND_PRECHARGE_SPEED 0x8a
#define SSD1353_DEFAULT_SECOND_PRECHARGE_SPEED 2
#define SSD1353_CMD_REMAP_COLOR_DEPTH 0xa0
+ #define SSD1353_REMAP_NO_INCREMENT __BIT(0)
+ #define SSD1353_REMAP_SEG_DIRECTION __BIT(1)
+ #define SSD1353_REMAP_RGB __BIT(2)
+ #define SSD1353_REMAP_LR __BIT(3)
+ #define SSD1353_REMAP_COM_DIRECTION __BIT(4)
+ #define SSD1353_REMAP_SPLIT_ODD_EVEN __BIT(5)
+ #define SSD1353_REMAP_PIXEL_FORMAT_MASK __BITS(7, 6)
#define SSD1353_CMD_SET_DISPLAY_START_LINE SSD1322_CMD_SET_DISPLAY_START_LINE
#define SSD1353_CMD_SET_DISPLAY_OFFSET SSD1322_CMD_SET_DISPLAY_OFFSET
#define SSD1353_CMD_SET_VERTICAL_SCROLL_AREA SSDFB_CMD_SET_VERTICAL_SCROLL_AREA
@@ -305,6 +312,7 @@ struct ssdfb_product {
int p_width;
int p_height;
int p_bits_per_pixel;
+ bool p_rgb;
int p_panel_shift;
uint8_t p_fosc;
uint8_t p_fosc_div;