FreeCalypso > hg > fc-magnetite
comparison src/cs/drivers/drv_app/r2d/lcds/BW_D_Sample/R2D_board_bw_dsample_lcd_i.c @ 0:945cf7f506b2
src/cs: chipsetsw import from tcs211-fcmodem
binary blobs and LCD demo files have been excluded,
all line endings are LF only
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 25 Sep 2016 22:50:11 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:945cf7f506b2 |
---|---|
1 static UINT32 r2d_lcd_copy_operator(UINT32 old,UINT32 value) | |
2 { | |
3 return(value); | |
4 } | |
5 static UINT32 r2d_lcd_or_operator(UINT32 old,UINT32 value) | |
6 { | |
7 return(old | value) ; | |
8 } | |
9 static UINT32 r2d_lcd_and_operator(UINT32 old,UINT32 value) | |
10 { | |
11 return(old & value); | |
12 } | |
13 static UINT32 r2d_lcd_xor_operator(UINT32 old,UINT32 value) | |
14 { | |
15 return(old ^ value) ; | |
16 } | |
17 static UINT32 r2d_lcd_not_copy_operator(UINT32 old,UINT32 value) | |
18 { | |
19 return(~value); | |
20 } | |
21 static UINT32 r2d_lcd_not_or_operator(UINT32 old,UINT32 value) | |
22 { | |
23 return(~(old | value)); | |
24 } | |
25 static UINT32 r2d_lcd_not_and_operator(UINT32 old,UINT32 value) | |
26 { | |
27 return(~(old & value)); | |
28 } | |
29 static UINT32 r2d_lcd_not_xor_operator(UINT32 old,UINT32 value) | |
30 { | |
31 return(~(old ^ value)) ; | |
32 } | |
33 | |
34 // Next don't do anything but required for link with asm files | |
35 UINT32 r2d_lcd_alpha_operator(UINT32 old,UINT32 value) | |
36 { | |
37 return(0) ; | |
38 } | |
39 | |
40 const T_R2D_DRAWING_OPERATORS r2d_g_lcd_operators= | |
41 { | |
42 &r2d_lcd_copy_operator, | |
43 &r2d_lcd_or_operator, | |
44 &r2d_lcd_and_operator, | |
45 &r2d_lcd_xor_operator, | |
46 &r2d_lcd_not_copy_operator, | |
47 &r2d_lcd_not_or_operator, | |
48 &r2d_lcd_not_and_operator, | |
49 &r2d_lcd_not_xor_operator, | |
50 NULL | |
51 }; | |
52 | |
53 // Return the pixel value to write on the LCD or the offscreen | |
54 // pixmap | |
55 // LCD DEPENDENT | |
56 void r2d_convert_foreground_color(T_R2D_GC *gc,UINT32 color) | |
57 { | |
58 | |
59 // If one is writing to the LCD framebuffer (the only | |
60 // one which is not 24 bits) then color conversion is required | |
61 UINT16 red,green,blue; | |
62 UINT32 lightness; | |
63 | |
64 | |
65 red=r2d_red(color); | |
66 green=r2d_green(color); | |
67 blue=r2d_blue(color); | |
68 | |
69 // Compute global intensity for monochrome LCD | |
70 lightness=(~((r2d_max_color(red,green,blue) + r2d_min_color(red,green,blue)) >> 1) & 0xFF); | |
71 | |
72 #if (R2D_DITHERING == R2D_ON) | |
73 { | |
74 UINT32 dvalue; | |
75 UINT16 dithering_group; | |
76 | |
77 r2d_dithering_group_and_lightness(); | |
78 | |
79 r2d_dithered_value(0,0) | |
80 r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache, | |
81 dvalue,0,0); | |
82 | |
83 r2d_dithered_value(0,1) | |
84 r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache, | |
85 dvalue,0,1); | |
86 | |
87 r2d_dithered_value(1,1) | |
88 r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache, | |
89 dvalue,1,1); | |
90 | |
91 r2d_dithered_value(1,0) | |
92 r2d_set_dithering_matrix_entry(gc->p_foreground_dithered_cache, | |
93 dvalue,1,0); | |
94 | |
95 | |
96 } | |
97 #else | |
98 lightness=(lightness >> (8 - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK; | |
99 gc->foreground_pixel_value=lightness; | |
100 #endif | |
101 | |
102 | |
103 | |
104 } | |
105 | |
106 // Return the pixel value to write on the LCD or the offscreen | |
107 // pixmap | |
108 // LCD DEPENDENT | |
109 void r2d_convert_background_color(T_R2D_GC *gc,UINT32 color) | |
110 { | |
111 | |
112 // If one is writing to the LCD framebuffer (the only | |
113 // one which is not 24 bits) then color conversion is required | |
114 UINT16 red,green,blue; | |
115 UINT32 lightness; | |
116 | |
117 | |
118 red=r2d_red(color); | |
119 green=r2d_green(color); | |
120 blue=r2d_blue(color); | |
121 | |
122 // Compute global intensity for monochrome LCD | |
123 lightness=(~((r2d_max_color(red,green,blue) + r2d_min_color(red,green,blue)) >> 1) & 0xFF); | |
124 | |
125 #if (R2D_DITHERING == R2D_ON) | |
126 { | |
127 UINT32 dvalue; | |
128 UINT16 dithering_group; | |
129 | |
130 r2d_dithering_group_and_lightness(); | |
131 | |
132 r2d_dithered_value(0,0) | |
133 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache, | |
134 dvalue,0,0); | |
135 | |
136 r2d_dithered_value(0,1) | |
137 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache, | |
138 dvalue,0,1); | |
139 | |
140 r2d_dithered_value(1,1) | |
141 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache, | |
142 dvalue,1,1); | |
143 | |
144 r2d_dithered_value(1,0) | |
145 r2d_set_dithering_matrix_entry(gc->p_background_dithered_cache, | |
146 dvalue,1,0); | |
147 | |
148 | |
149 } | |
150 #else | |
151 lightness=(lightness >> (8 - R2D_PIXEL_DEPTH)) & R2D_PIXEL_MASK; | |
152 gc->background_pixel_value=lightness; | |
153 #endif | |
154 | |
155 | |
156 | |
157 | |
158 | |
159 } | |
160 | |
161 // blit_rect may use the foreground and background color | |
162 // to do the copy. So, one must knows which source pixels | |
163 // are corresponding to the background color, | |
164 // which ones are corresponding to the foreground color | |
165 // and do the conversion of the color selected | |
166 // according to the destination framebuffer | |
167 | |
168 // This files gives routines for: | |
169 // - Selecting a color according to the value in the LCD framebuffer | |
170 // - Converting a color to LCD | |
171 | |
172 | |
173 // Convert a LCD value (not color) to a value | |
174 // to be written into the 24bpp framebuffer | |
175 // In general, the value written is a packed | |
176 // representation of the ARGB color | |
177 // but it may be different according to the framebuffer | |
178 // internal format | |
179 BOOLEAN r2d_lcd_foreground_pixel(UINT32 lcd_value,T_R2D_GC_PTR src_gc) | |
180 { | |
181 if (lcd_value) | |
182 return(TRUE); // Foreground pixel | |
183 else | |
184 return(FALSE); // Background pixel | |
185 } | |
186 | |
187 // Assume than color framebuffer contains ARGB packed values | |
188 // Convert color to LCD with on the fly dithering | |
189 UINT32 r2d_color_to_lcd(UINT32 pixel_value,INT16 x,INT16 y) | |
190 { | |
191 | |
192 INT16 red,green,blue; | |
193 UINT32 lightness; | |
194 UINT32 dvalue; | |
195 UINT16 dithering_group; | |
196 | |
197 pixel_value=(~pixel_value) & 0x00FFFFFF; | |
198 red=r2d_red(pixel_value); | |
199 green=r2d_green(pixel_value); | |
200 blue=r2d_blue(pixel_value); | |
201 | |
202 // Compute global intensity for monochrome LCD | |
203 lightness=(~((r2d_max_color(red,green,blue) + r2d_min_color(red,green,blue)) >> 1) & 0xFF); | |
204 | |
205 | |
206 r2d_dithering_group_and_lightness(); | |
207 | |
208 r2d_dithered_value(x & 1,y & 1); | |
209 | |
210 return(dvalue); | |
211 } | |
212 | |
213 // Lcd to pixel value | |
214 UINT32 r2d_lcd_to_color(UINT32 color) | |
215 { | |
216 | |
217 if (color) | |
218 return(0x00FFFFFF); // 24 bpp framebuffer pixel value for white | |
219 else | |
220 return(0x00000000); | |
221 } | |
222 |