Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic allow to have a per-product init function
details: https://anonhg.NetBSD.org/src/rev/91dff7cae29b
branches: trunk
changeset: 464783:91dff7cae29b
user: tnn <tnn%NetBSD.org@localhost>
date: Tue Oct 22 22:03:27 2019 +0000
description:
allow to have a per-product init function
diffstat:
sys/dev/ic/ssdfb.c | 25 +++++++++++++++----------
sys/dev/ic/ssdfbvar.h | 5 ++++-
2 files changed, 19 insertions(+), 11 deletions(-)
diffs (121 lines):
diff -r 92baed0bbde3 -r 91dff7cae29b sys/dev/ic/ssdfb.c
--- a/sys/dev/ic/ssdfb.c Tue Oct 22 21:41:01 2019 +0000
+++ b/sys/dev/ic/ssdfb.c Tue Oct 22 22:03:27 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb.c,v 1.7 2019/10/22 21:41:01 tnn Exp $ */
+/* $NetBSD: ssdfb.c,v 1.8 2019/10/22 22:03:27 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.7 2019/10/22 21:41:01 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.8 2019/10/22 22:03:27 tnn Exp $");
#include "opt_ddb.h"
@@ -72,7 +72,7 @@
static void ssdfb_cursor(void *, int, int, int);
/* hardware interface */
-static int ssdfb_init(struct ssdfb_softc *);
+static int ssdfb_init_ssd1306(struct ssdfb_softc *);
static int ssdfb_set_contrast(struct ssdfb_softc *, uint8_t, bool);
static int ssdfb_set_display_on(struct ssdfb_softc *, bool, bool);
static int ssdfb_set_mode(struct ssdfb_softc *, u_int);
@@ -100,7 +100,8 @@
static const char *ssdfb_controller_names[] = {
[SSDFB_CONTROLLER_UNKNOWN] = "unknown",
[SSDFB_CONTROLLER_SSD1306] = "Solomon Systech SSD1306",
- [SSDFB_CONTROLLER_SH1106] = "Sino Wealth SH1106"
+ [SSDFB_CONTROLLER_SH1106] = "Sino Wealth SH1106",
+ [SSDFB_CONTROLLER_SSD1322] = "Solomon Systech SSD1322"
};
/*
@@ -124,7 +125,8 @@
.p_default_contrast = 0x7f,
.p_multiplex_ratio = 0x3f,
.p_chargepump_cmd = SSD1306_CMD_SET_CHARGE_PUMP,
- .p_chargepump_arg = SSD1306_CHARGE_PUMP_ENABLE
+ .p_chargepump_arg = SSD1306_CHARGE_PUMP_ENABLE,
+ .p_init = ssdfb_init_ssd1306
},
{
.p_product_id = SSDFB_PRODUCT_SH1106_GENERIC,
@@ -143,7 +145,8 @@
.p_default_contrast = 0x80,
.p_multiplex_ratio = 0x3f,
.p_chargepump_cmd = SH1106_CMD_SET_CHARGE_PUMP_7V4,
- .p_chargepump_arg = SSDFB_CMD_NOP
+ .p_chargepump_arg = SSDFB_CMD_NOP,
+ .p_init = ssdfb_init_ssd1306
},
{
.p_product_id = SSDFB_PRODUCT_ADAFRUIT_938,
@@ -161,7 +164,8 @@
.p_default_contrast = 0x8f,
.p_multiplex_ratio = 0x3f,
.p_chargepump_cmd = SSD1306_CMD_SET_CHARGE_PUMP,
- .p_chargepump_arg = SSD1306_CHARGE_PUMP_ENABLE
+ .p_chargepump_arg = SSD1306_CHARGE_PUMP_ENABLE,
+ .p_init = ssdfb_init_ssd1306
},
{
.p_product_id = SSDFB_PRODUCT_ADAFRUIT_931,
@@ -179,7 +183,8 @@
.p_default_contrast = 0x8f,
.p_multiplex_ratio = 0x1f,
.p_chargepump_cmd = SSD1306_CMD_SET_CHARGE_PUMP,
- .p_chargepump_arg = SSD1306_CHARGE_PUMP_ENABLE
+ .p_chargepump_arg = SSD1306_CHARGE_PUMP_ENABLE,
+ .p_init = ssdfb_init_ssd1306
}
};
@@ -294,7 +299,7 @@
/*
* Initialize hardware.
*/
- error = ssdfb_init(sc);
+ error = p->p_init(sc);
if (error)
goto out;
@@ -581,7 +586,7 @@
}
static int
-ssdfb_init(struct ssdfb_softc *sc)
+ssdfb_init_ssd1306(struct ssdfb_softc *sc)
{
int error;
uint8_t cmd[2];
diff -r 92baed0bbde3 -r 91dff7cae29b sys/dev/ic/ssdfbvar.h
--- a/sys/dev/ic/ssdfbvar.h Tue Oct 22 21:41:01 2019 +0000
+++ b/sys/dev/ic/ssdfbvar.h Tue Oct 22 22:03:27 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfbvar.h,v 1.3 2019/10/22 21:40:10 tnn Exp $ */
+/* $NetBSD: ssdfbvar.h,v 1.4 2019/10/22 22:03:27 tnn Exp $ */
/*
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -209,6 +209,8 @@
#define SSD1322_COMMAND_UNLOCK_MAGIC 0x12
#define SSD1322_COMMAND_LOCK_MAGIC 0x16
+struct ssdfb_softc;
+
typedef enum {
SSDFB_CONTROLLER_UNKNOWN=0,
SSDFB_CONTROLLER_SSD1306=1,
@@ -254,6 +256,7 @@
uint8_t p_multiplex_ratio;
uint8_t p_chargepump_cmd;
uint8_t p_chargepump_arg;
+ int (*p_init)(struct ssdfb_softc *);
};
struct ssdfb_softc {
Home |
Main Index |
Thread Index |
Old Index