]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/arm_drivers/lcd/src/lcd-tegra2.c
update
[l4.git] / l4 / pkg / arm_drivers / lcd / src / lcd-tegra2.c
1 /*
2  * Tegra2 FB driver (just pass-through, must be init'ed by boot-loader)
3  */
4
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include <string.h>
8
9 #include <l4/arm_drivers/lcd.h>
10 #include <l4/io/io.h>
11 #include <l4/util/util.h>
12
13 static inline int width(void) { return 1280; }
14 static inline int height(void) { return 900; }
15 static inline int bytes_per_pixel(void) { return 2; }
16
17 static unsigned int fbmem_size(void)
18 { return height() * width() * bytes_per_pixel(); }
19
20 static void *fb_vaddr;
21
22 static void setup_memory(void)
23 {
24   l4_addr_t fb_paddr;
25   l4_addr_t a = 0;
26   int ret;
27
28   if (fb_vaddr)
29     return;
30
31   fb_paddr = 0x1c012000;
32   ret = l4io_request_iomem(fb_paddr, 0x500000, 0, &a);
33   if (ret)
34     {
35       printf("[LCD] Error: Could not map device memory\n");
36       return;
37     }
38
39   fb_vaddr = (void *)a;
40
41   printf("[LCD] Info: Video memory is at virtual %p (size: 0x%x Bytes)\n",
42          fb_vaddr, fbmem_size());
43   printf("[LCD] Info: Physical video memory is at %p\n", (void *)fb_paddr);
44 }
45
46
47 static int lcd_probe(const char *configstr)
48 {
49   (void)configstr;
50   return !l4io_lookup_device("FBMEM", NULL, 0, 0);
51 }
52
53 static void *lcd_get_fb(void)
54 {
55   if (!fb_vaddr)
56     setup_memory();
57
58   return fb_vaddr;
59 }
60
61 static unsigned int lcd_fbmem_size(void) { return fbmem_size(); }
62
63 static const char *lcd_get_info(void)
64 {
65   return "TEGRA2 FASTBOOT init'ed FB";
66 }
67
68 static int get_fbinfo(l4re_video_view_info_t *vinfo)
69 {
70   vinfo->width               = width();
71   vinfo->height              = height();
72   vinfo->bytes_per_line      = bytes_per_pixel() * vinfo->width;
73
74   vinfo->pixel_info.bytes_per_pixel = bytes_per_pixel();
75   vinfo->pixel_info.r.shift         = 11;
76   vinfo->pixel_info.r.size          = 5;
77   vinfo->pixel_info.g.shift         = 5;
78   vinfo->pixel_info.g.size          = 6;
79   vinfo->pixel_info.b.shift         = 0;
80   vinfo->pixel_info.b.size          = 5;
81   vinfo->pixel_info.a.shift         = 0;
82   vinfo->pixel_info.a.size          = 0;
83   return 0;
84 }
85
86 static void lcd_enable(void)
87 {
88   setup_memory();
89 }
90
91 static void lcd_disable(void)
92 {
93   printf("%s unimplemented.\n", __func__);
94 }
95
96 static struct arm_lcd_ops arm_lcd_ops_omap3 = {
97   .probe              = lcd_probe,
98   .get_fb             = lcd_get_fb,
99   .get_fbinfo         = get_fbinfo,
100   .get_video_mem_size = lcd_fbmem_size,
101   .get_info           = lcd_get_info,
102   .enable             = lcd_enable,
103   .disable            = lcd_disable,
104 };
105
106 arm_lcd_register(&arm_lcd_ops_omap3);