drivers/disp_dev: add display driver registry
This commit is contained in:
parent
40b5359096
commit
f4bc980236
@ -21,9 +21,46 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "disp_dev.h"
|
#include "disp_dev.h"
|
||||||
|
|
||||||
|
disp_dev_reg_t *disp_dev_reg = NULL;
|
||||||
|
|
||||||
|
int disp_dev_reg_add(disp_dev_reg_t *dev)
|
||||||
|
{
|
||||||
|
disp_dev_reg_t *tmp = disp_dev_reg;
|
||||||
|
|
||||||
|
if (dev == NULL) {
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* prepare new entry */
|
||||||
|
dev->next = NULL;
|
||||||
|
/* add to registry */
|
||||||
|
if (disp_dev_reg == NULL) {
|
||||||
|
disp_dev_reg = dev;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
while (tmp->next != NULL) {
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
tmp->next = dev;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
disp_dev_reg_t *disp_dev_reg_find_screen(uint8_t screen_id)
|
||||||
|
{
|
||||||
|
disp_dev_reg_t *tmp = disp_dev_reg;
|
||||||
|
|
||||||
|
while (tmp && tmp->screen_id != screen_id) {
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
void disp_dev_map(const disp_dev_t *dev,
|
void disp_dev_map(const disp_dev_t *dev,
|
||||||
uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
|
uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2,
|
||||||
const uint16_t *color)
|
const uint16_t *color)
|
||||||
|
|||||||
@ -101,6 +101,40 @@ struct disp_dev {
|
|||||||
const disp_dev_driver_t *driver; /**< Pointer to driver of the display device */
|
const disp_dev_driver_t *driver; /**< Pointer to driver of the display device */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disp dev registry entry
|
||||||
|
*/
|
||||||
|
typedef struct disp_dev_reg {
|
||||||
|
struct disp_dev_reg *next; /**< pointer to the next display device in the list */
|
||||||
|
disp_dev_t *dev; /**< pointer to the device descriptor */
|
||||||
|
uint8_t screen_id; /**< id of the screen this display is attached to */
|
||||||
|
} disp_dev_reg_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Export the display device registry as global variable
|
||||||
|
*/
|
||||||
|
extern disp_dev_reg_t *disp_dev_reg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add pointer to a display device item to the list of display items
|
||||||
|
*
|
||||||
|
* @param[in] dev Pointer to the display device
|
||||||
|
*
|
||||||
|
* @return 0 on success
|
||||||
|
* @return -ENODEV on invalid entry
|
||||||
|
*/
|
||||||
|
int disp_dev_reg_add(disp_dev_reg_t *dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Find the display device that is attached to a given screen
|
||||||
|
*
|
||||||
|
* @param[in] screen_id Identifier (number) of the screen
|
||||||
|
*
|
||||||
|
* @return pointer to the display device in the registry
|
||||||
|
* @return NULL if there's no match
|
||||||
|
*/
|
||||||
|
disp_dev_reg_t *disp_dev_reg_find_screen(uint8_t screen_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Map an area to display on the device
|
* @brief Map an area to display on the device
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user