summaryrefslogtreecommitdiff
path: root/quantum/painter/qp.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/painter/qp.c')
-rw-r--r--quantum/painter/qp.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/quantum/painter/qp.c b/quantum/painter/qp.c
index aea9381b60..f27bb7892a 100644
--- a/quantum/painter/qp.c
+++ b/quantum/painter/qp.c
@@ -30,6 +30,11 @@ bool qp_init(painter_device_t device, painter_rotation_t rotation) {
qp_dprintf("qp_init: entry\n");
painter_driver_t *driver = (painter_driver_t *)device;
+ if (!driver) {
+ qp_dprintf("qp_init: fail (pointer to NULL)\n");
+ return false;
+ }
+
driver->validate_ok = false;
if (!validate_driver_integrity(driver)) {
qp_dprintf("Failed to validate driver integrity in qp_init\n");
@@ -65,7 +70,7 @@ bool qp_init(painter_device_t device, painter_rotation_t rotation) {
bool qp_power(painter_device_t device, bool power_on) {
qp_dprintf("qp_power: entry\n");
painter_driver_t *driver = (painter_driver_t *)device;
- if (!driver->validate_ok) {
+ if (!driver || !driver->validate_ok) {
qp_dprintf("qp_power: fail (validation_ok == false)\n");
return false;
}
@@ -87,7 +92,7 @@ bool qp_power(painter_device_t device, bool power_on) {
bool qp_clear(painter_device_t device) {
qp_dprintf("qp_clear: entry\n");
painter_driver_t *driver = (painter_driver_t *)device;
- if (!driver->validate_ok) {
+ if (!driver || !driver->validate_ok) {
qp_dprintf("qp_clear: fail (validation_ok == false)\n");
return false;
}
@@ -109,7 +114,7 @@ bool qp_clear(painter_device_t device) {
bool qp_flush(painter_device_t device) {
qp_dprintf("qp_flush: entry\n");
painter_driver_t *driver = (painter_driver_t *)device;
- if (!driver->validate_ok) {
+ if (!driver || !driver->validate_ok) {
qp_dprintf("qp_flush: fail (validation_ok == false)\n");
return false;
}
@@ -129,9 +134,14 @@ bool qp_flush(painter_device_t device) {
// Quantum Painter External API: qp_get_geometry
void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height, painter_rotation_t *rotation, uint16_t *offset_x, uint16_t *offset_y) {
- qp_dprintf("qp_geometry: entry\n");
+ qp_dprintf("qp_get_geometry: entry\n");
painter_driver_t *driver = (painter_driver_t *)device;
+ if (!driver) {
+ qp_dprintf("qp_get_geometry: fail (pointer to NULL)\n");
+ return;
+ }
+
switch (driver->rotation) {
default:
case QP_ROTATION_0:
@@ -166,7 +176,7 @@ void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height,
*offset_y = driver->offset_y;
}
- qp_dprintf("qp_geometry: ok\n");
+ qp_dprintf("qp_get_geometry: ok\n");
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -176,6 +186,11 @@ void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_
qp_dprintf("qp_set_viewport_offsets: entry\n");
painter_driver_t *driver = (painter_driver_t *)device;
+ if (!driver) {
+ qp_dprintf("qp_set_viewport_offsets: fail (pointer to NULL)\n");
+ return;
+ }
+
driver->offset_x = offset_x;
driver->offset_y = offset_y;
@@ -188,7 +203,7 @@ void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_
bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) {
qp_dprintf("qp_viewport: entry\n");
painter_driver_t *driver = (painter_driver_t *)device;
- if (!driver->validate_ok) {
+ if (!driver || !driver->validate_ok) {
qp_dprintf("qp_viewport: fail (validation_ok == false)\n");
return false;
}
@@ -211,7 +226,7 @@ bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t
bool qp_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) {
qp_dprintf("qp_pixdata: entry\n");
painter_driver_t *driver = (painter_driver_t *)device;
- if (!driver->validate_ok) {
+ if (!driver || !driver->validate_ok) {
qp_dprintf("qp_pixdata: fail (validation_ok == false)\n");
return false;
}