Re: [RFC v2 1/5] video: Add generic display entity core
Hi, On 2012-11-22 23:45, Laurent Pinchart wrote: +/** + * display_entity_get_modes - Get video modes supported by the display entity + * @entity The display entity + * @modes: Pointer to an array of modes + * + * Fill the modes argument with a pointer to an array of video modes. The array + * is owned by the display entity. + * + * Return the number of supported modes on success (including 0 if no mode is + * supported) or a negative error code otherwise. + */ +int display_entity_get_modes(struct display_entity *entity, + const struct videomode **modes) +{ + if (!entity-ops.ctrl || !entity-ops.ctrl-get_modes) + return 0; + + return entity-ops.ctrl-get_modes(entity, modes); +} +EXPORT_SYMBOL_GPL(display_entity_get_modes); + +/** + * display_entity_get_size - Get display entity physical size + * @entity: The display entity + * @width: Physical width in millimeters + * @height: Physical height in millimeters + * + * When applicable, for instance for display panels, retrieve the display + * physical size in millimeters. + * + * Return 0 on success or a negative error code otherwise. + */ +int display_entity_get_size(struct display_entity *entity, + unsigned int *width, unsigned int *height) +{ + if (!entity-ops.ctrl || !entity-ops.ctrl-get_size) + return -EOPNOTSUPP; + + return entity-ops.ctrl-get_size(entity, width, height); +} +EXPORT_SYMBOL_GPL(display_entity_get_size); How do you envision these to be used with, say, DVI monitors with EDID data? Should each panel driver, that manages a device with EDID, read and parse the EDID itself? I guess that shouldn't be too difficult with a common EDID lib, but that will only expose some of the information found from EDID. Should the upper levels also have a way to get the raw EDID data, in addition to funcs like above? Tomi signature.asc Description: OpenPGP digital signature
[RFC v2 1/5] video: Add generic display entity core
From: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- drivers/video/Kconfig|1 + drivers/video/Makefile |1 + drivers/video/display/Kconfig|4 + drivers/video/display/Makefile |1 + drivers/video/display/display-core.c | 362 ++ include/video/display.h | 150 ++ 6 files changed, 519 insertions(+), 0 deletions(-) create mode 100644 drivers/video/display/Kconfig create mode 100644 drivers/video/display/Makefile create mode 100644 drivers/video/display/display-core.c create mode 100644 include/video/display.h diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index c5b7bcf..e91f03e 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -2442,6 +2442,7 @@ source drivers/video/omap/Kconfig source drivers/video/omap2/Kconfig source drivers/video/exynos/Kconfig source drivers/video/backlight/Kconfig +source drivers/video/display/Kconfig if VT source drivers/video/console/Kconfig diff --git a/drivers/video/Makefile b/drivers/video/Makefile index b936b00..0a4cfea 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -14,6 +14,7 @@ fb-objs := $(fb-y) obj-$(CONFIG_VT) += console/ obj-$(CONFIG_LOGO) += logo/ obj-y+= backlight/ +obj-y+= display/ obj-$(CONFIG_EXYNOS_VIDEO) += exynos/ diff --git a/drivers/video/display/Kconfig b/drivers/video/display/Kconfig new file mode 100644 index 000..1d533e7 --- /dev/null +++ b/drivers/video/display/Kconfig @@ -0,0 +1,4 @@ +menuconfig DISPLAY_CORE + tristate Display Core + ---help--- + Support common display framework for graphics devices. diff --git a/drivers/video/display/Makefile b/drivers/video/display/Makefile new file mode 100644 index 000..bd93496 --- /dev/null +++ b/drivers/video/display/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_DISPLAY_CORE) += display-core.o diff --git a/drivers/video/display/display-core.c b/drivers/video/display/display-core.c new file mode 100644 index 000..358c089 --- /dev/null +++ b/drivers/video/display/display-core.c @@ -0,0 +1,362 @@ +/* + * Display Core + * + * Copyright (C) 2012 Renesas Solutions Corp. + * + * Contacts: Laurent Pinchart laurent.pinch...@ideasonboard.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/export.h +#include linux/kernel.h +#include linux/list.h +#include linux/module.h +#include linux/mutex.h +#include linux/videomode.h + +#include video/display.h + +static LIST_HEAD(display_entity_list); +static LIST_HEAD(display_entity_notifiers); +static DEFINE_MUTEX(display_entity_mutex); + +/* - + * Control operations + */ + +/** + * display_entity_set_state - Set the display entity operation state + * @entity: The display entity + * @state: Display entity operation state + * + * See enum display_entity_state for information regarding the entity states. + * + * Return 0 on success or a negative error code otherwise. + */ +int display_entity_set_state(struct display_entity *entity, +enum display_entity_state state) +{ + int ret; + + if (entity-state == state) + return 0; + + if (!entity-ops.ctrl || !entity-ops.ctrl-set_state) + return 0; + + ret = entity-ops.ctrl-set_state(entity, state); + if (ret 0) + return ret; + + entity-state = state; + return 0; +} +EXPORT_SYMBOL_GPL(display_entity_set_state); + +/** + * display_entity_update - Update the display + * @entity: The display entity + * + * Make the display entity ready to receive pixel data and start frame transfer. + * This operation can only be called if the display entity is in STANDBY or ON + * state. + * + * The display entity will call the upstream entity in the video chain to start + * the video stream. + * + * Return 0 on success or a negative error code otherwise. + */ +int display_entity_update(struct display_entity *entity) +{ + if (!entity-ops.ctrl || !entity-ops.ctrl-update) + return 0; + + return entity-ops.ctrl-update(entity); +} +EXPORT_SYMBOL_GPL(display_entity_update); + +/** + * display_entity_get_modes - Get video modes supported by the display entity + * @entity The display entity + * @modes: Pointer to an array of modes + * + * Fill the modes argument with a pointer to an array of video modes. The array + * is owned by the display entity. + * + * Return the number of supported modes on success (including 0 if no mode is + * supported) or a negative error code otherwise. + */