1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
25 #include <sys/types.h>
33 #include "screenhack.h"
38 * Specific implementations for X11, using the generic LCD API and data.
42 #include "lcd-playersim.h"
46 #define ANDBIT 3 /* AND with this to get the color number */
52 extern void screen_resized(int width
, int height
);
53 extern bool lcd_display_redraw
;
55 #ifdef HAVE_LCD_BITMAP
57 fb_data lcd_framebuffer_copy
[LCD_HEIGHT
][LCD_WIDTH
*2];
59 fb_data lcd_framebuffer_copy
[LCD_HEIGHT
/YBLOCK
][LCD_WIDTH
];
62 void lcd_update (void)
64 /* update a full screen rect */
65 lcd_update_rect(0, 0, LCD_WIDTH
, LCD_HEIGHT
);
68 void lcd_update_rect(int x_start
, int y_start
,
69 int width
, int height
)
78 int colors
[LCD_WIDTH
* LCD_HEIGHT
];
79 struct coordinate points
[LCD_WIDTH
* LCD_HEIGHT
];
80 unsigned force_mask
= lcd_display_redraw
? 0xFF : 0;
83 fprintf(stderr
, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
84 counter
++, x_start
, y_start
, width
, height
);
86 /* The Y coordinates have to work on even YBLOCK pixel rows */
87 ymax
= (yline
+ height
)/YBLOCK
;
90 xmax
= x_start
+ width
;
94 if(ymax
>= LCD_HEIGHT
/YBLOCK
)
95 ymax
= LCD_HEIGHT
/YBLOCK
-1;
97 for(; yline
<= ymax
; yline
++) {
99 for(x
= x_start
; x
< xmax
; x
++) {
100 unsigned char diff
= (lcd_framebuffer
[yline
][x
]
101 ^ lcd_framebuffer_copy
[yline
][x
])
104 /* one or more bits/pixels are changed */
105 unsigned char mask
= ANDBIT
;
106 for(bit
= 0; bit
< YBLOCK
; bit
++) {
108 /* pixel has changed */
109 unsigned int col
= lcd_framebuffer
[yline
][x
] & mask
;
111 colors
[p
] = col
>> (bit
* LCD_DEPTH
);
113 colors
[p
] = col
? 3 : 0;
115 points
[p
].x
= x
+ MARGIN_X
;
116 points
[p
].y
= y
+ bit
+ MARGIN_Y
;
117 p
++; /* increase the point counter */
122 /* update the copy */
123 lcd_framebuffer_copy
[yline
][x
] = lcd_framebuffer
[yline
][x
];
128 dots(colors
, &points
[0], p
);
129 /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/
133 lcd_display_redraw
=false;
136 #ifdef LCD_REMOTE_HEIGHT
137 extern unsigned char lcd_remote_framebuffer
[LCD_REMOTE_HEIGHT
/8][LCD_REMOTE_WIDTH
];
138 unsigned char lcd_remote_framebuffer_copy
[LCD_REMOTE_HEIGHT
/8][LCD_REMOTE_WIDTH
];
140 #define REMOTE_START_Y (LCD_HEIGHT + 2*MARGIN_Y)
142 void lcd_remote_update (void)
144 lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH
, LCD_REMOTE_HEIGHT
);
147 void lcd_remote_update_rect(int x_start
, int y_start
,
148 int width
, int height
)
157 struct coordinate points
[LCD_REMOTE_WIDTH
* LCD_REMOTE_HEIGHT
];
158 int colors
[LCD_REMOTE_WIDTH
* LCD_REMOTE_HEIGHT
];
159 unsigned force_mask
= lcd_display_redraw
? 0xFF : 0;
162 fprintf(stderr
, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
163 counter
++, x_start
, y_start
, width
, height
);
165 /* The Y coordinates have to work on even 8 pixel rows */
166 ymax
= (yline
+ height
)/8;
169 xmax
= x_start
+ width
;
171 if(xmax
> LCD_REMOTE_WIDTH
)
172 xmax
= LCD_REMOTE_WIDTH
;
173 if(ymax
>= LCD_REMOTE_HEIGHT
/8)
174 ymax
= LCD_REMOTE_HEIGHT
/8-1;
176 for(; yline
<= ymax
; yline
++) {
178 for(x
= x_start
; x
< xmax
; x
++) {
179 unsigned char diff
= (lcd_remote_framebuffer
[yline
][x
]
180 ^ lcd_remote_framebuffer_copy
[yline
][x
])
183 unsigned char mask
= 1;
184 for(bit
= 0; bit
< 8; bit
++) {
186 unsigned int col
= lcd_remote_framebuffer
[yline
][x
] & mask
;
187 colors
[p
] = col
? 3 : 0;
188 points
[p
].x
= x
+ MARGIN_X
;
189 points
[p
].y
= y
+ bit
+ (REMOTE_START_Y
+ MARGIN_Y
);
190 p
++; /* increase the point counter */
195 /* update the copy */
196 lcd_remote_framebuffer_copy
[yline
][x
] =
197 lcd_remote_framebuffer
[yline
][x
];
202 dots(colors
, &points
[0], p
);
203 /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/
207 lcd_display_redraw
=false;
214 #ifdef HAVE_LCD_CHARCELLS
216 /* Defined in lcd-playersim.c */
217 extern void lcd_print_char(int x
, int y
);
218 extern unsigned char lcd_buffer
[2][11];
219 extern void drawrect(int color
, int x1
, int y1
, int x2
, int y2
);
221 extern unsigned char hardware_buffer_lcd
[11][2];
222 static unsigned char lcd_buffer_copy
[11][2];
224 void lcd_update (void)
228 for (y
=0; y
<2; y
++) {
229 for (x
=0; x
<11; x
++) {
230 if (lcd_display_redraw
||
231 lcd_buffer_copy
[x
][y
] != hardware_buffer_lcd
[x
][y
]) {
232 lcd_buffer_copy
[x
][y
] = hardware_buffer_lcd
[x
][y
];
233 lcd_print_char(x
, y
);
244 lcd_display_redraw
=false;
249 #ifdef CONFIG_BACKLIGHT
250 void sim_backlight(int value
)
252 DEBUGF("backlight: %s\n", (value
> 0) ? "on" : "off");
256 #ifdef HAVE_REMOTE_LCD
257 void sim_remote_backlight(int value
)
259 DEBUGF("remote backlight: %s\n", (value
> 0) ? "on" : "off");