driver: display: Added dummy display driver
Added dummy display driver. fixes: #12001 Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
parent
65f79cdc21
commit
848b0844dd
|
@ -13,3 +13,5 @@ zephyr_sources_ifdef(CONFIG_SSD1673 ssd1673.c)
|
|||
|
||||
zephyr_sources_ifdef(CONFIG_SDL_DISPLAY display_sdl.c)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_DUMMY_DISPLAY display_dummy.c)
|
||||
|
||||
|
|
|
@ -27,4 +27,6 @@ source "drivers/display/Kconfig.ssd1306"
|
|||
|
||||
source "drivers/display/Kconfig.ssd1673"
|
||||
|
||||
source "drivers/display/Kconfig.dummy"
|
||||
|
||||
endif # DISPLAY
|
||||
|
|
28
drivers/display/Kconfig.dummy
Normal file
28
drivers/display/Kconfig.dummy
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Kconfig - Configuration options for dummy display
|
||||
|
||||
#
|
||||
# Copyright (c) 2018 Jan Van Winkel <jan.van_winkel@dxplore.eu>
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
menuconfig DUMMY_DISPLAY
|
||||
bool "Dummy display driver"
|
||||
help
|
||||
Enable dummy display driver compliant with display driver API.
|
||||
|
||||
if DUMMY_DISPLAY
|
||||
|
||||
config DUMMY_DISPLAY_DEV_NAME
|
||||
string "Dummy display device name"
|
||||
default "DUMMY_DISPLAY"
|
||||
|
||||
config DUMMY_DISPLAY_X_RES
|
||||
int "X resolution for dummy display"
|
||||
default 320
|
||||
|
||||
config DUMMY_DISPLAY_Y_RES
|
||||
int "Y resolution for dummy display"
|
||||
default 240
|
||||
|
||||
endif #DUMMY_DISPLAY
|
114
drivers/display/display_dummy.c
Normal file
114
drivers/display/display_dummy.c
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Jan Van Winkel <jan.van_winkel@dxplore.eu>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <display.h>
|
||||
|
||||
struct dummy_display_data {
|
||||
enum display_pixel_format current_pixel_format;
|
||||
};
|
||||
|
||||
static struct dummy_display_data dummy_display_data;
|
||||
|
||||
static int dummy_display_init(struct device *dev)
|
||||
{
|
||||
struct dummy_display_data *disp_data =
|
||||
(struct dummy_display_data *)dev->driver_data;
|
||||
|
||||
disp_data->current_pixel_format = PIXEL_FORMAT_ARGB_8888;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_display_write(const struct device *dev, const u16_t x,
|
||||
const u16_t y,
|
||||
const struct display_buffer_descriptor *desc,
|
||||
const void *buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_display_read(const struct device *dev, const u16_t x,
|
||||
const u16_t y,
|
||||
const struct display_buffer_descriptor *desc,
|
||||
void *buf)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static void *dummy_display_get_framebuffer(const struct device *dev)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int dummy_display_blanking_off(const struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_display_blanking_on(const struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_display_set_brightness(const struct device *dev,
|
||||
const u8_t brightness)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_display_set_contrast(const struct device *dev,
|
||||
const u8_t contrast)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dummy_display_get_capabilities(const struct device *dev,
|
||||
struct display_capabilities *capabilities)
|
||||
{
|
||||
struct dummy_display_data *disp_data =
|
||||
(struct dummy_display_data *)dev->driver_data;
|
||||
|
||||
memset(capabilities, 0, sizeof(struct display_capabilities));
|
||||
capabilities->x_resolution = CONFIG_DUMMY_DISPLAY_X_RES;
|
||||
capabilities->y_resolution = CONFIG_DUMMY_DISPLAY_Y_RES;
|
||||
capabilities->supported_pixel_formats = PIXEL_FORMAT_ARGB_8888 |
|
||||
PIXEL_FORMAT_RGB_888 |
|
||||
PIXEL_FORMAT_MONO01 |
|
||||
PIXEL_FORMAT_MONO10;
|
||||
capabilities->current_pixel_format = disp_data->current_pixel_format;
|
||||
capabilities->screen_info = SCREEN_INFO_MONO_VTILED |
|
||||
SCREEN_INFO_MONO_MSB_FIRST;
|
||||
}
|
||||
|
||||
static int dummy_display_set_pixel_format(const struct device *dev,
|
||||
const enum display_pixel_format pixel_format)
|
||||
{
|
||||
struct dummy_display_data *disp_data =
|
||||
(struct dummy_display_data *)dev->driver_data;
|
||||
|
||||
disp_data->current_pixel_format = pixel_format;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct display_driver_api dummy_display_api = {
|
||||
.blanking_on = dummy_display_blanking_on,
|
||||
.blanking_off = dummy_display_blanking_off,
|
||||
.write = dummy_display_write,
|
||||
.read = dummy_display_read,
|
||||
.get_framebuffer = dummy_display_get_framebuffer,
|
||||
.set_brightness = dummy_display_set_brightness,
|
||||
.set_contrast = dummy_display_set_contrast,
|
||||
.get_capabilities = dummy_display_get_capabilities,
|
||||
.set_pixel_format = dummy_display_set_pixel_format,
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(dummy_display, CONFIG_DUMMY_DISPLAY_DEV_NAME,
|
||||
&dummy_display_init, &dummy_display_data, NULL,
|
||||
APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY,
|
||||
&dummy_display_api);
|
||||
|
Loading…
Reference in a new issue