diff options
Diffstat (limited to 'utils/hwstub/tools/lua/stmp/lcdif.lua')
-rw-r--r-- | utils/hwstub/tools/lua/stmp/lcdif.lua | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/utils/hwstub/tools/lua/stmp/lcdif.lua b/utils/hwstub/tools/lua/stmp/lcdif.lua index 0878cb1139..a2f085e166 100644 --- a/utils/hwstub/tools/lua/stmp/lcdif.lua +++ b/utils/hwstub/tools/lua/stmp/lcdif.lua | |||
@@ -29,6 +29,18 @@ function STMP.lcdif.set_reset(val) | |||
29 | end | 29 | end |
30 | end | 30 | end |
31 | 31 | ||
32 | function STMP.lcdif.set_databus_width(bus_width) | ||
33 | local v = 0 | ||
34 | if bus_width == 8 then | ||
35 | v = 1 | ||
36 | elseif bus_width == 18 then | ||
37 | v = 2 | ||
38 | elseif bus_width == 24 then | ||
39 | v = 3 | ||
40 | end | ||
41 | HW.LCDIF.CTRL.LCD_DATABUS_WIDTH.write(v) | ||
42 | end | ||
43 | |||
32 | function STMP.lcdif.set_word_length(bus_width) | 44 | function STMP.lcdif.set_word_length(bus_width) |
33 | if STMP.is_stmp3600() or STMP.is_stmp3700() then | 45 | if STMP.is_stmp3600() or STMP.is_stmp3700() then |
34 | if bus_width == 8 then | 46 | if bus_width == 8 then |
@@ -37,7 +49,15 @@ function STMP.lcdif.set_word_length(bus_width) | |||
37 | HW.LCDIF.CTRL.WORD_LENGTH.clr() | 49 | HW.LCDIF.CTRL.WORD_LENGTH.clr() |
38 | end | 50 | end |
39 | else | 51 | else |
40 | error("STMP.lcdif.set_word_length: unimplemented") | 52 | local v = 0 |
53 | if bus_width == 8 then | ||
54 | v = 1 | ||
55 | elseif bus_width == 18 then | ||
56 | v = 2 | ||
57 | elseif bus_width == 24 then | ||
58 | v = 3 | ||
59 | end | ||
60 | HW.LCDIF.CTRL.WORD_LENGTH.write(v) | ||
41 | end | 61 | end |
42 | end | 62 | end |
43 | 63 | ||
@@ -49,7 +69,11 @@ function STMP.lcdif.get_word_length() | |||
49 | return 16 | 69 | return 16 |
50 | end | 70 | end |
51 | else | 71 | else |
52 | error("STMP.lcdif.get_word_length: unimplemented") | 72 | local v = HW.LCDIF.CTRL.WORD_LENGTH.read() |
73 | if v == 0 then return 16 | ||
74 | elseif v == 1 then return 8 | ||
75 | elseif v == 2 then return 18 | ||
76 | else return 24 end | ||
53 | end | 77 | end |
54 | end | 78 | end |
55 | 79 | ||
@@ -62,7 +86,11 @@ function STMP.lcdif.set_data_swizzle(swizzle) | |||
62 | error("unimplemented") | 86 | error("unimplemented") |
63 | end | 87 | end |
64 | end | 88 | end |
65 | HW.LCDIF.CTRL.DATA_SWIZZLE.write(v) | 89 | if STMP.is_stmp3600() or STMP.is_stmp3700() then |
90 | HW.LCDIF.CTRL.DATA_SWIZZLE.write(v) | ||
91 | else | ||
92 | HW.LCDIF.CTRL.INPUT_DATA_SWIZZLE.write(v) | ||
93 | end | ||
66 | end | 94 | end |
67 | 95 | ||
68 | function STMP.lcdif.is_busy() | 96 | function STMP.lcdif.is_busy() |
@@ -73,6 +101,11 @@ function STMP.lcdif.is_busy() | |||
73 | end | 101 | end |
74 | end | 102 | end |
75 | 103 | ||
104 | function STMP.lcdif.wait_ready() | ||
105 | while HW.LCDIF.CTRL.RUN.read() == 1 do | ||
106 | end | ||
107 | end | ||
108 | |||
76 | function STMP.lcdif.send_pio(data_mode, data) | 109 | function STMP.lcdif.send_pio(data_mode, data) |
77 | local wl = STMP.lcdif.get_word_length() | 110 | local wl = STMP.lcdif.get_word_length() |
78 | if data_mode then | 111 | if data_mode then |
@@ -81,8 +114,16 @@ function STMP.lcdif.send_pio(data_mode, data) | |||
81 | HW.LCDIF.CTRL.DATA_SELECT.clr() | 114 | HW.LCDIF.CTRL.DATA_SELECT.clr() |
82 | end | 115 | end |
83 | STMP.debug(string.format("lcdif: count = %d", #data)) | 116 | STMP.debug(string.format("lcdif: count = %d", #data)) |
117 | if STMP.is_imx233() then | ||
118 | HW.LCDIF.CTRL.LCDIF_MASTER.clr() | ||
119 | end | ||
84 | HW.LCDIF.CTRL.RUN.clr() | 120 | HW.LCDIF.CTRL.RUN.clr() |
85 | HW.LCDIF.CTRL.COUNT.write(#data) | 121 | if STMP.is_stmp3600() or STMP.is_stmp3700() then |
122 | HW.LCDIF.CTRL.COUNT.write(#data) | ||
123 | else | ||
124 | HW.LCDIF.TRANSFER_COUNT.V_COUNT.write(1) | ||
125 | HW.LCDIF.TRANSFER_COUNT.H_COUNT.write(#data) | ||
126 | end | ||
86 | HW.LCDIF.CTRL.RUN.set() | 127 | HW.LCDIF.CTRL.RUN.set() |
87 | local i = 1 | 128 | local i = 1 |
88 | while i <= #data do | 129 | while i <= #data do |
@@ -97,4 +138,5 @@ function STMP.lcdif.send_pio(data_mode, data) | |||
97 | while STMP.lcdif.is_busy() do STMP.debug("lcdif: fifo full") end | 138 | while STMP.lcdif.is_busy() do STMP.debug("lcdif: fifo full") end |
98 | HW.LCDIF.DATA.write(v) | 139 | HW.LCDIF.DATA.write(v) |
99 | end | 140 | end |
141 | STMP.lcdif.wait_ready() | ||
100 | end \ No newline at end of file | 142 | end \ No newline at end of file |