aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorChe-Liang Chiou2011-10-20 18:04:22 -0500
committerAnatolij Gustschin2011-11-15 16:58:27 -0600
commita2a5729fc1247bb45d794e9d731c0b03bf58096f (patch)
treea89f1b03ebc2e3987b8068aefe0f0a30c1c357c4 /api
parentd3983ee85325d2be730830ebcf82585ee7cd2ecb (diff)
downloadu-boot-a2a5729fc1247bb45d794e9d731c0b03bf58096f.tar.gz
u-boot-a2a5729fc1247bb45d794e9d731c0b03bf58096f.tar.xz
u-boot-a2a5729fc1247bb45d794e9d731c0b03bf58096f.zip
api: export LCD device to external apps
This patch exports LCD info-query and bitmap-rendering functions to external apps. This patch is tested on a Seaboard. Because the LCD driver is not yet upstreamed, the test was done in a local downstream repo. Signed-off-by: Che-Liang Chiou <clchiou@chromium.org>
Diffstat (limited to 'api')
-rw-r--r--api/Makefile3
-rw-r--r--api/api.c47
-rw-r--r--api/api_display.c74
-rw-r--r--api/api_private.h4
4 files changed, 127 insertions, 1 deletions
diff --git a/api/Makefile b/api/Makefile
index 2a64c4ddf6..0e99f741b7 100644
--- a/api/Makefile
+++ b/api/Makefile
@@ -24,7 +24,8 @@ include $(TOPDIR)/config.mk
24 24
25LIB = $(obj)libapi.o 25LIB = $(obj)libapi.o
26 26
27COBJS-$(CONFIG_API) += api.o api_net.o api_storage.o api_platform-$(ARCH).o 27COBJS-$(CONFIG_API) += api.o api_display.o api_net.o api_storage.o \
28 api_platform-$(ARCH).o
28 29
29COBJS := $(COBJS-y) 30COBJS := $(COBJS-y)
30SRCS := $(COBJS:.o=.c) 31SRCS := $(COBJS:.o=.c)
diff --git a/api/api.c b/api/api.c
index 853f010fee..a3bf60ad62 100644
--- a/api/api.c
+++ b/api/api.c
@@ -553,6 +553,50 @@ static int API_env_enum(va_list ap)
553 return 0; 553 return 0;
554} 554}
555 555
556/*
557 * pseudo signature:
558 *
559 * int API_display_get_info(int type, struct display_info *di)
560 */
561static int API_display_get_info(va_list ap)
562{
563 int type;
564 struct display_info *di;
565
566 type = va_arg(ap, int);
567 di = va_arg(ap, struct display_info *);
568
569 return display_get_info(type, di);
570}
571
572/*
573 * pseudo signature:
574 *
575 * int API_display_draw_bitmap(ulong bitmap, int x, int y)
576 */
577static int API_display_draw_bitmap(va_list ap)
578{
579 ulong bitmap;
580 int x, y;
581
582 bitmap = va_arg(ap, ulong);
583 x = va_arg(ap, int);
584 y = va_arg(ap, int);
585
586 return display_draw_bitmap(bitmap, x, y);
587}
588
589/*
590 * pseudo signature:
591 *
592 * void API_display_clear(void)
593 */
594static int API_display_clear(va_list ap)
595{
596 display_clear();
597 return 0;
598}
599
556static cfp_t calls_table[API_MAXCALL] = { NULL, }; 600static cfp_t calls_table[API_MAXCALL] = { NULL, };
557 601
558/* 602/*
@@ -616,6 +660,9 @@ void api_init(void)
616 calls_table[API_ENV_GET] = &API_env_get; 660 calls_table[API_ENV_GET] = &API_env_get;
617 calls_table[API_ENV_SET] = &API_env_set; 661 calls_table[API_ENV_SET] = &API_env_set;
618 calls_table[API_ENV_ENUM] = &API_env_enum; 662 calls_table[API_ENV_ENUM] = &API_env_enum;
663 calls_table[API_DISPLAY_GET_INFO] = &API_display_get_info;
664 calls_table[API_DISPLAY_DRAW_BITMAP] = &API_display_draw_bitmap;
665 calls_table[API_DISPLAY_CLEAR] = &API_display_clear;
619 calls_no = API_MAXCALL; 666 calls_no = API_MAXCALL;
620 667
621 debugf("API initialized with %d calls\n", calls_no); 668 debugf("API initialized with %d calls\n", calls_no);
diff --git a/api/api_display.c b/api/api_display.c
new file mode 100644
index 0000000000..643917088f
--- /dev/null
+++ b/api/api_display.c
@@ -0,0 +1,74 @@
1/*
2 * Copyright (c) 2011 The Chromium OS Authors.
3 * See file CREDITS for list of people who contributed to this
4 * project.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19 * MA 02111-1307 USA
20 */
21
22#include <common.h>
23#include <api_public.h>
24#include <lcd.h>
25#include <video_font.h> /* Get font width and height */
26
27/* lcd.h needs BMP_LOGO_HEIGHT to calculate CONSOLE_ROWS */
28#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
29#include <bmp_logo.h>
30#endif
31
32/* TODO(clchiou): add support of video device */
33
34int display_get_info(int type, struct display_info *di)
35{
36 if (!di)
37 return API_EINVAL;
38
39 switch (type) {
40 default:
41 debug("%s: unsupport display device type: %d\n",
42 __FILE__, type);
43 return API_ENODEV;
44#ifdef CONFIG_LCD
45 case DISPLAY_TYPE_LCD:
46 di->pixel_width = panel_info.vl_col;
47 di->pixel_height = panel_info.vl_row;
48 di->screen_rows = CONSOLE_ROWS;
49 di->screen_cols = CONSOLE_COLS;
50 break;
51#endif
52 }
53
54 di->type = type;
55 return 0;
56}
57
58int display_draw_bitmap(ulong bitmap, int x, int y)
59{
60 if (!bitmap)
61 return API_EINVAL;
62#ifdef CONFIG_LCD
63 return lcd_display_bitmap(bitmap, x, y);
64#else
65 return API_ENODEV;
66#endif
67}
68
69void display_clear(void)
70{
71#ifdef CONFIG_LCD
72 lcd_clear();
73#endif
74}
diff --git a/api/api_private.h b/api/api_private.h
index 94a7fc509c..988f702356 100644
--- a/api/api_private.h
+++ b/api/api_private.h
@@ -45,4 +45,8 @@ int dev_write_net(void *, void *, int);
45 45
46void dev_stor_init(void); 46void dev_stor_init(void);
47 47
48int display_get_info(int type, struct display_info *di);
49int display_draw_bitmap(ulong bitmap, int x, int y);
50void display_clear(void);
51
48#endif /* _API_PRIVATE_H_ */ 52#endif /* _API_PRIVATE_H_ */