View | Details | Raw Unified | Return to bug 122673
Collapse All | Expand All

(-)w3m/Makefile (-1 / +2 lines)
Lines 7-12 Link Here
7
7
8
PORTNAME=	w3m
8
PORTNAME=	w3m
9
PORTVERSION=	${W3M_VERSION}
9
PORTVERSION=	${W3M_VERSION}
10
PORTREVISION=	1
10
CATEGORIES+=	www ipv6
11
CATEGORIES+=	www ipv6
11
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
12
MASTER_SITE_SUBDIR=	${PORTNAME}
13
MASTER_SITE_SUBDIR=	${PORTNAME}
Lines 64-70 Link Here
64
65
65
.if defined(INLINE_IMAGE)
66
.if defined(INLINE_IMAGE)
66
USE_GNOME=	gtk20
67
USE_GNOME=	gtk20
67
CONFIGURE_ARGS+=	--with-imagelib=gtk2
68
CONFIGURE_ARGS+=	--with-imagelib=gtk2 --enable-image=fb,x11
68
69
69
DOCS+=		README.img
70
DOCS+=		README.img
70
DOCS_JP+=	README.img
71
DOCS_JP+=	README.img
(-)w3m/files/patch-configure (+11 lines)
Line 0 Link Here
1
--- configure.orig	2007-11-23 02:39:52.000000000 +0900
2
+++ configure	2007-11-23 02:43:22.000000000 +0900
3
@@ -5532,7 +5532,7 @@
4
   if test x"$enable_image" = xyes; then
5
     enable_image=x11
6
     case "`uname -s`" in
7
-    Linux|linux|LINUX)
8
+    Linux|linux|LINUX|FreeBSD|freebsd|FREEBSD)
9
 	if test -c /dev/fb0; then
10
 	  enable_image=x11,fb
11
         fi;;
(-)w3m/files/patch-w3mimg_fb_fb.c (+751 lines)
Line 0 Link Here
1
--- w3mimg/fb/fb.c.orig	2003-07-14 01:19:10.000000000 +0900
2
+++ w3mimg/fb/fb.c	2007-11-23 08:59:36.000000000 +0900
3
@@ -12,12 +12,24 @@
4
 #include <errno.h>
5
 #include <sys/ioctl.h>
6
 #include <sys/mman.h>
7
+#if defined(__linux__)
8
 #include <linux/fb.h>
9
+#elif defined(__FreeBSD__)
10
+#include <sys/fbio.h> 
11
+#endif
12
+#if defined(__FreeBSD__)
13
+#include <sys/types.h>
14
+#include <machine/param.h>
15
+#endif
16
 
17
 #include "fb.h"
18
 
19
 #define FB_ENV		"FRAMEBUFFER"
20
+#if defined(__linux__)
21
 #define	FB_DEFDEV	"/dev/fb0"
22
+#elif defined(__FreeBSD__)
23
+#define	FB_DEFDEV	"/dev/ttyv0"
24
+#endif
25
 
26
 #define MONO_OFFSET_8BIT  0x40
27
 #define COLORS_MONO_8BIT  0x40
28
@@ -38,22 +50,65 @@
29
 
30
 #define IMAGE_SIZE_MAX 10000
31
 
32
+#if defined(__linux__)
33
 static struct fb_cmap *fb_cmap_create(struct fb_fix_screeninfo *,
34
 				      struct fb_var_screeninfo *);
35
+#elif defined(__FreeBSD__)
36
+static video_color_palette_t *fb_cmap_create(video_info_t *video_info,
37
+				video_adapter_info_t *video_adapter_info);
38
+#endif
39
+#if defined(__linux__)
40
 static void fb_cmap_destroy(struct fb_cmap *cmap);
41
+#elif defined(__FreeBSD__)
42
+static void fb_cmap_destroy(video_color_palette_t *cmap);
43
+#endif
44
+#if defined(__linux__)
45
 static int fb_fscrn_get(int fbfp, struct fb_fix_screeninfo *scinfo);
46
+#endif
47
+#if defined(__linux__)
48
 static void *fb_mmap(int fbfp, struct fb_fix_screeninfo *scinfo);
49
+#elif defined(__FreeBSD__)
50
+static void *fb_mmap(int fbfp, video_adapter_info_t *video_adapter_info);
51
+#endif
52
+#if defined(__linux__)
53
 static int fb_munmap(void *buf, struct fb_fix_screeninfo *scinfo);
54
+#elif defined(__FreeBSD__)
55
+static int fb_munmap(void *buf, video_adapter_info_t *video_adapter_info);
56
+#endif
57
+#if defined(__linux__)
58
 static int fb_vscrn_get(int fbfp, struct fb_var_screeninfo *scinfo);
59
+#endif
60
+#if defined(__linux__)
61
 static int fb_cmap_set(int fbfp, struct fb_cmap *cmap);
62
+#elif defined(__FreeBSD__)
63
+static int fb_cmap_set(int fbfp, video_color_palette_t *cmap);
64
+#endif
65
+#if defined(__linux__)
66
 static int fb_cmap_get(int fbfp, struct fb_cmap *cmap);
67
+#elif defined(__FreeBSD__)
68
+static int fb_cmap_get(int fbfp, video_color_palette_t *cmap);
69
+#endif
70
 static int fb_cmap_init(void);
71
 static int fb_get_cmap_index(int r, int g, int b);
72
 static unsigned long fb_get_packed_color(int r, int g, int b);
73
+#if defined(__FreeBSD__)
74
+static int fb_video_mode_get(int fbfp, int *video_mode);
75
+static int fb_video_info_get(int fbfp, video_info_t *video_info);
76
+static int fb_video_adapter_info_get(int fbfp, video_adapter_info_t *video_adapter_info);
77
+#endif
78
 
79
+#if defined(__linux__)
80
 static struct fb_fix_screeninfo fscinfo;
81
 static struct fb_var_screeninfo vscinfo;
82
+#elif defined(__FreeBSD__)
83
+static video_info_t video_info;
84
+static video_adapter_info_t video_adapter_info;
85
+#endif
86
+#if defined(__linux__)
87
 static struct fb_cmap *cmap = NULL, *cmap_org = NULL;
88
+#elif defined(__FreeBSD__)
89
+static video_color_palette_t *cmap = NULL, *cmap_org = NULL;
90
+#endif
91
 static int is_open = FALSE;
92
 static int fbfp = -1;
93
 static size_t pixel_size = 0;
94
@@ -63,6 +118,9 @@
95
 fb_open(void)
96
 {
97
     char *fbdev = { FB_DEFDEV };
98
+#if defined(__FreeBSD__)
99
+    int video_mode;
100
+#endif
101
 
102
     if (is_open == TRUE)
103
 	return 1;
104
@@ -76,6 +134,7 @@
105
 	goto ERR_END;
106
     }
107
 
108
+#if defined(__linux__)
109
     if (fb_fscrn_get(fbfp, &fscinfo)) {
110
 	goto ERR_END;
111
     }
112
@@ -83,22 +142,67 @@
113
     if (fb_vscrn_get(fbfp, &vscinfo)) {
114
 	goto ERR_END;
115
     }
116
+#elif defined(__FreeBSD__)
117
+    if (fb_video_mode_get(fbfp, &video_mode)) {
118
+	goto ERR_END;
119
+    }
120
+    video_info.vi_mode = video_mode;
121
+
122
+    if (fb_video_info_get(fbfp, &video_info)) {
123
+	goto ERR_END;
124
+    }
125
+
126
+    if (fb_video_adapter_info_get(fbfp, &video_adapter_info)) {
127
+	goto ERR_END;
128
+    }
129
+    if (!(video_info.vi_flags & V_INFO_GRAPHICS) ||
130
+	!(video_info.vi_flags & V_INFO_LINEAR)) {
131
+	goto ERR_END;
132
+    }
133
+#endif
134
 
135
+#if defined(__linux__)
136
     if ((cmap = fb_cmap_create(&fscinfo, &vscinfo)) == (struct fb_cmap *)-1) {
137
 	goto ERR_END;
138
     }
139
+#elif defined(__FreeBSD__)
140
+    if ((cmap = fb_cmap_create(&video_info, &video_adapter_info)) == (video_color_palette_t *)-1) {
141
+	goto ERR_END;
142
+    }
143
+#endif
144
 
145
+#if defined(__linux__)
146
     if (!(buf = fb_mmap(fbfp, &fscinfo))) {
147
 	fprintf(stderr, "Can't allocate memory.\n");
148
 	goto ERR_END;
149
     }
150
+#elif defined(__FreeBSD__)
151
+    if (!(buf = fb_mmap(fbfp, &video_adapter_info))) {
152
+	fprintf(stderr, "Can't allocate memory.\n");
153
+	goto ERR_END;
154
+    }
155
+#endif
156
 
157
+#if defined(__linux__)
158
     if (fscinfo.type != FB_TYPE_PACKED_PIXELS) {
159
 	fprintf(stderr, "This type of framebuffer is not supported.\n");
160
 	goto ERR_END;
161
     }
162
+#elif defined(__FreeBSD__)
163
+    if (!(video_info.vi_mem_model == V_INFO_MM_PACKED || 
164
+	  video_info.vi_mem_model == V_INFO_MM_DIRECT)) {
165
+	fprintf(stderr, "This type of framebuffer is not supported.\n");
166
+	goto ERR_END;
167
+    }
168
+#endif
169
 
170
+#if defined(__linux__)
171
     if (fscinfo.visual == FB_VISUAL_PSEUDOCOLOR && vscinfo.bits_per_pixel == 8) {
172
+#elif defined(__FreeBSD__)
173
+    if (video_adapter_info.va_flags & V_ADP_PALETTE &&
174
+	video_info.vi_mem_model == V_INFO_MM_PACKED &&
175
+	video_info.vi_depth == 8) {
176
+#endif
177
 	if (fb_cmap_get(fbfp, cmap)) {
178
 	    fprintf(stderr, "Can't get color map.\n");
179
 	    fb_cmap_destroy(cmap);
180
@@ -111,12 +215,20 @@
181
 
182
 	pixel_size = 1;
183
     }
184
+#if defined(__linux__)
185
     else if ((fscinfo.visual == FB_VISUAL_TRUECOLOR ||
186
 	      fscinfo.visual == FB_VISUAL_DIRECTCOLOR) &&
187
 	     (vscinfo.bits_per_pixel == 15 ||
188
 	      vscinfo.bits_per_pixel == 16 ||
189
 	      vscinfo.bits_per_pixel == 24 || vscinfo.bits_per_pixel == 32)) {
190
 	pixel_size = (vscinfo.bits_per_pixel + 7) / CHAR_BIT;
191
+#elif defined(__FreeBSD__)
192
+    else if (video_info.vi_mem_model == V_INFO_MM_DIRECT &&
193
+	     (video_info.vi_depth == 15 ||
194
+	      video_info.vi_depth == 16 ||
195
+	      video_info.vi_depth == 24 || video_info.vi_depth == 32)) {
196
+	pixel_size = (video_info.vi_depth + 7) / CHAR_BIT;
197
+#endif
198
     }
199
     else {
200
 	fprintf(stderr, "This type of framebuffer is not supported.\n");
201
@@ -147,7 +259,11 @@
202
 	cmap = NULL;
203
     }
204
     if (buf != NULL) {
205
+#if defined(__linux__)
206
 	fb_munmap(buf, &fscinfo);
207
+#elif defined(__FreeBSD__)
208
+	fb_munmap(buf, &video_adapter_info);
209
+#endif
210
 	buf = NULL;
211
     }
212
 
213
@@ -259,11 +375,19 @@
214
     if (y + height > fb_height())
215
 	height = fb_height() - y;
216
 
217
+#if defined(__linux__)
218
     offset_fb = fscinfo.line_length * y + pixel_size * x;
219
+#elif defined(__FreeBSD__)
220
+    offset_fb = video_adapter_info.va_line_width * y + pixel_size * x;
221
+#endif
222
     offset_img = image->rowstride * sy + pixel_size * sx;
223
     for (i = 0; i < height; i++) {
224
 	memcpy(buf + offset_fb, image->data + offset_img, pixel_size * width);
225
+#if defined(__linux__)
226
 	offset_fb += fscinfo.line_length;
227
+#elif defined(__FreeBSD__)
228
+	offset_fb += video_adapter_info.va_line_width;
229
+#endif
230
 	offset_img += image->rowstride;
231
     }
232
 
233
@@ -336,7 +460,11 @@
234
     if (is_open != TRUE)
235
 	return 0;
236
 
237
+#if defined(__linux__)
238
     return vscinfo.xres;
239
+#elif defined(__FreeBSD__)
240
+    return video_info.vi_width;
241
+#endif
242
 }
243
 
244
 int
245
@@ -345,7 +473,11 @@
246
     if (is_open != TRUE)
247
 	return 0;
248
 
249
+#if defined(__linux__)
250
     return vscinfo.yres;
251
+#elif defined(__FreeBSD__)
252
+    return video_info.vi_height;
253
+#endif
254
 }
255
 
256
 int
257
@@ -369,7 +501,11 @@
258
 	h = fb_height() - y;
259
 
260
     if (tmp == NULL) {
261
+#if defined(__linux__)
262
 	tmp = malloc(fscinfo.line_length);
263
+#elif defined(__FreeBSD__)
264
+	tmp = malloc(video_adapter_info.va_line_width);
265
+#endif
266
 	if (tmp == NULL)
267
 	    return 1;
268
     }
269
@@ -384,10 +520,18 @@
270
 	gg = g;
271
 	bb = b;
272
     }
273
+#if defined(__linux__)
274
     offset_fb = fscinfo.line_length * y + pixel_size * x;
275
+#elif defined(__FreeBSD__)
276
+    offset_fb = video_adapter_info.va_line_width * y + pixel_size * x;
277
+#endif
278
     for (i = 0; i < h; i++) {
279
 	memcpy(buf + offset_fb, tmp, pixel_size * w);
280
+#if defined(__linux__)
281
 	offset_fb += fscinfo.line_length;
282
+#elif defined(__FreeBSD__)
283
+	offset_fb += video_adapter_info.va_line_width;
284
+#endif
285
     }
286
     return 0;
287
 }
288
@@ -400,11 +544,21 @@
289
 	return fb_get_cmap_index(r, g, b);
290
     }
291
     else {
292
+#if defined(__linux__)
293
 	return
294
 	    ((r >> (CHAR_BIT - vscinfo.red.length)) << vscinfo.red.offset) +
295
 	    ((g >> (CHAR_BIT - vscinfo.green.length)) << vscinfo.green.
296
 	     offset) +
297
 	    ((b >> (CHAR_BIT - vscinfo.blue.length)) << vscinfo.blue.offset);
298
+#elif defined(__FreeBSD__)
299
+	return
300
+	    ((r >> (CHAR_BIT - video_info.vi_pixel_fsizes[0])) <<
301
+	     video_info.vi_pixel_fields[0]) +
302
+	    ((g >> (CHAR_BIT - video_info.vi_pixel_fsizes[1])) <<
303
+	     video_info.vi_pixel_fields[1]) +
304
+	    ((b >> (CHAR_BIT - video_info.vi_pixel_fsizes[2])) <<
305
+	     video_info.vi_pixel_fields[2]);
306
+#endif
307
     }
308
 }
309
 
310
@@ -433,16 +587,31 @@
311
     if (cmap == NULL)
312
 	return 1;
313
 
314
+#if defined(__linux__)
315
     if (cmap->len < COLOR_OFFSET_8BIT + COLORS_8BIT) {
316
 	fprintf(stderr, "Can't allocate enough color.\n");
317
 	return 1;
318
     }
319
+#elif defined(__FreeBSD__)
320
+    if (cmap->count < COLOR_OFFSET_8BIT + COLORS_8BIT) {
321
+	fprintf(stderr, "Can't allocate enough color.\n");
322
+	return 1;
323
+    }
324
+#endif
325
 
326
     if (cmap_org == NULL) {
327
+#if defined(__linux__)
328
 	if ((cmap_org =
329
 	     fb_cmap_create(&fscinfo, &vscinfo)) == (struct fb_cmap *)-1) {
330
 	    return 1;
331
 	}
332
+#elif defined(__FreeBSD__)
333
+	if ((cmap_org =
334
+	     fb_cmap_create(&video_info, &video_adapter_info)) ==
335
+	     (video_color_palette_t *)-1) {
336
+	    return 1;
337
+	}
338
+#endif
339
 
340
 	if (fb_cmap_get(fbfp, cmap_org)) {
341
 	    fprintf(stderr, "Can't get color map.\n");
342
@@ -452,8 +621,13 @@
343
 	}
344
     }
345
 
346
+#if defined(__linux__)
347
     cmap->start = MONO_OFFSET_8BIT;
348
     cmap->len = COLORS_8BIT + COLORS_MONO_8BIT;
349
+#elif defined(__FreeBSD__)
350
+    cmap->index = MONO_OFFSET_8BIT;
351
+    cmap->count = COLORS_8BIT + COLORS_MONO_8BIT;
352
+#endif
353
 
354
     for (lp = 0; lp < COLORS_MONO_8BIT; lp++) {
355
 	int c;
356
@@ -506,73 +680,213 @@
357
 
358
 #define	LUT_MAX		(256)
359
 
360
+#if defined(__linux__)
361
 static struct fb_cmap *
362
 fb_cmap_create(struct fb_fix_screeninfo *fscinfo,
363
 	       struct fb_var_screeninfo *vscinfo)
364
+#elif defined(__FreeBSD__)
365
+static video_color_palette_t *
366
+fb_cmap_create(video_info_t *video_info,
367
+	       video_adapter_info_t *video_adapter_info)
368
+#endif
369
 {
370
+#if defined(__linux__)
371
     struct fb_cmap *cmap;
372
+#elif defined(__FreeBSD__)
373
+    video_color_palette_t *cmap;
374
+#endif
375
     int cmaplen = LUT_MAX;
376
 
377
     /* check the existence of colormap */
378
+#if defined(__linux__)
379
     if (fscinfo->visual == FB_VISUAL_MONO01 ||
380
 	fscinfo->visual == FB_VISUAL_MONO10 ||
381
 	fscinfo->visual == FB_VISUAL_TRUECOLOR)
382
 	return NULL;
383
+#elif defined(__FreeBSD__)
384
+    if (!(video_adapter_info->va_flags & V_ADP_PALETTE))
385
+	return NULL;
386
+#endif
387
 
388
+#if defined(__linux__)
389
     cmap = (struct fb_cmap *)malloc(sizeof(struct fb_cmap));
390
+#elif defined(__FreeBSD__)
391
+    cmap = (video_color_palette_t *)malloc(sizeof(video_color_palette_t));
392
+#endif
393
     if (!cmap) {
394
 	perror("cmap malloc error\n");
395
+#if defined(__linux__)
396
 	return (struct fb_cmap *)-1;
397
+#elif defined(__FreeBSD__)
398
+	return (video_color_palette_t *)-1;
399
+#endif
400
     }
401
+#if defined(__linux__)
402
     memset(cmap, 0, sizeof(struct fb_cmap));
403
+#elif defined(__FreeBSD__)
404
+    memset(cmap, 0, sizeof(video_color_palette_t));
405
+#endif
406
+
407
+#if defined(__FreeBSD__)
408
+    if (video_info->vi_mem_model == V_INFO_MM_PACKED) {
409
+	cmap->red = (u_char *) malloc(sizeof(u_char) * cmaplen);
410
+	if (!cmap->red) {
411
+	    perror("red lut malloc error\n");
412
+	    return (video_color_palette_t *)-1;
413
+	}
414
+	cmap->green = (u_char *) malloc(sizeof(u_char) * cmaplen);
415
+	if (!cmap->green) {
416
+	    perror("green lut malloc error\n");
417
+	    free(cmap->red);
418
+	    return (video_color_palette_t *)-1;
419
+	}
420
+	cmap->blue = (u_char *) malloc(sizeof(u_char) * cmaplen);
421
+	if (!cmap->blue) {
422
+	    perror("blue lut malloc error\n");
423
+	    free(cmap->red);
424
+	    free(cmap->green);
425
+	    return (video_color_palette_t *)-1;
426
+	}
427
+	cmap->transparent = (u_char *) malloc(sizeof(u_char) * cmaplen);
428
+	if (!cmap->transparent) {
429
+	    perror("transparent lut malloc error\n");
430
+	    free(cmap->red);
431
+	    free(cmap->green);
432
+	    free(cmap->blue);
433
+	    return (video_color_palette_t *)-1;
434
+	}
435
+	cmap->count = cmaplen;
436
+	return cmap;
437
+    }
438
+#endif
439
 
440
     /* Allocates memory for a colormap */
441
+#if defined(__linux__)
442
     if (vscinfo->red.length) {
443
 	cmap->red = (__u16 *) malloc(sizeof(__u16) * cmaplen);
444
+#elif defined(__FreeBSD__)
445
+    if (video_info->vi_pixel_fsizes[0]) {
446
+	cmap->red = (u_char *) malloc(sizeof(u_char) * cmaplen);
447
+#endif
448
 	if (!cmap->red) {
449
 	    perror("red lut malloc error\n");
450
+#if defined(__linux__)
451
 	    return (struct fb_cmap *)-1;
452
+#elif defined(__FreeBSD__)
453
+	    return (video_color_palette_t *)-1;
454
+#endif
455
 	}
456
     }
457
+#if defined(__linux__)
458
     if (vscinfo->green.length) {
459
 	cmap->green = (__u16 *) malloc(sizeof(__u16) * cmaplen);
460
+#elif defined(__FreeBSD__)
461
+    if (video_info->vi_pixel_fsizes[1]) {
462
+	cmap->green = (u_char *) malloc(sizeof(u_char) * cmaplen);
463
+#endif
464
 	if (!cmap->green) {
465
+#if defined(__linux__)
466
 	    if (vscinfo->red.length)
467
 		free(cmap->red);
468
+#elif defined(__FreeBSD__)
469
+	    if (video_info->vi_pixel_fsizes[0])
470
+		free(cmap->red);
471
+#endif
472
 	    perror("green lut malloc error\n");
473
+#if defined(__linux__)
474
 	    return (struct fb_cmap *)-1;
475
+#elif defined(__FreeBSD__)
476
+	    return (video_color_palette_t *)-1;
477
+#endif
478
 	}
479
     }
480
+#if defined(__linux__)
481
     if (vscinfo->blue.length) {
482
 	cmap->blue = (__u16 *) malloc(sizeof(__u16) * cmaplen);
483
+#elif defined(__FreeBSD__)
484
+    if (video_info->vi_pixel_fsizes[2]) {
485
+	cmap->blue = (u_char *) malloc(sizeof(u_char) * cmaplen);
486
+#endif
487
 	if (!cmap->blue) {
488
+#if defined(__linux__)
489
 	    if (vscinfo->red.length)
490
 		free(cmap->red);
491
+#elif defined(__FreeBSD__)
492
+	    if (video_info->vi_pixel_fsizes[0])
493
+		free(cmap->red);
494
+#endif
495
+#if defined(__linux__)
496
 	    if (vscinfo->green.length)
497
 		free(cmap->green);
498
+#elif defined(__FreeBSD__)
499
+	    if (video_info->vi_pixel_fsizes[1])
500
+		free(cmap->green);
501
+#endif
502
 	    perror("blue lut malloc error\n");
503
+#if defined(__linux__)
504
 	    return (struct fb_cmap *)-1;
505
+#elif defined(__FreeBSD__)
506
+	    return (video_color_palette_t *)-1;
507
+#endif
508
 	}
509
     }
510
+#if defined(__linux__)
511
     if (vscinfo->transp.length) {
512
 	cmap->transp = (__u16 *) malloc(sizeof(__u16) * cmaplen);
513
+#elif defined(__FreeBSD__)
514
+    if (video_info->vi_pixel_fsizes[3]) {
515
+	cmap->transparent = (u_char *) malloc(sizeof(u_char) * cmaplen);
516
+#endif
517
+#if defined(__linux__)
518
 	if (!cmap->transp) {
519
+#elif defined(__FreeBSD__)
520
+	if (!cmap->transparent) {
521
+#endif
522
+#if defined(__linux__)
523
 	    if (vscinfo->red.length)
524
 		free(cmap->red);
525
+#elif defined(__FreeBSD__)
526
+	    if (video_info->vi_pixel_fsizes[0])
527
+		free(cmap->red);
528
+#endif
529
+#if defined(__linux__)
530
 	    if (vscinfo->green.length)
531
 		free(cmap->green);
532
+#elif defined(__FreeBSD__)
533
+	    if (video_info->vi_pixel_fsizes[1])
534
+		free(cmap->green);
535
+#endif
536
+#if defined(__linux__)
537
 	    if (vscinfo->blue.length)
538
 		free(cmap->blue);
539
 	    perror("transp lut malloc error\n");
540
+#elif defined(__FreeBSD__)
541
+	    if (video_info->vi_pixel_fsizes[2])
542
+		free(cmap->blue);
543
+	    perror("transparent lut malloc error\n");
544
+#endif
545
+#if defined(__linux__)
546
 	    return (struct fb_cmap *)-1;
547
+#elif defined(__FreeBSD__)
548
+	    return (video_color_palette_t *)-1;
549
+#endif
550
 	}
551
     }
552
+#if defined(__linux__)
553
     cmap->len = cmaplen;
554
+#elif defined(__FreeBSD__)
555
+    cmap->count = cmaplen;
556
+#endif
557
     return cmap;
558
 }
559
 
560
+#if defined(__linux__)
561
 static void
562
 fb_cmap_destroy(struct fb_cmap *cmap)
563
+#elif defined(__FreeBSD__)
564
+static void
565
+fb_cmap_destroy(video_color_palette_t *cmap)
566
+#endif
567
 {
568
     if (cmap->red)
569
 	free(cmap->red);
570
@@ -580,28 +894,57 @@
571
 	free(cmap->green);
572
     if (cmap->blue)
573
 	free(cmap->blue);
574
+#if defined(__linux__)
575
     if (cmap->transp)
576
 	free(cmap->transp);
577
+#elif defined(__FreeBSD__)
578
+    if (cmap->transparent)
579
+	free(cmap->transparent);
580
+#endif
581
     free(cmap);
582
 }
583
 
584
+#if defined(__linux__)
585
 static int
586
 fb_cmap_get(int fbfp, struct fb_cmap *cmap)
587
+#elif defined(__FreeBSD__)
588
+static int
589
+fb_cmap_get(int fbfp, video_color_palette_t *cmap)
590
+#endif
591
 {
592
+#if defined(__linux__)
593
     if (ioctl(fbfp, FBIOGETCMAP, cmap)) {
594
 	perror("ioctl FBIOGETCMAP error\n");
595
 	return -1;
596
     }
597
+#elif defined(__FreeBSD__)
598
+    if (ioctl(fbfp, FBIO_GETPALETTE, cmap) == -1) {
599
+	perror("ioctl FBIO_GETPALETTE error\n");
600
+	return -1;
601
+    }
602
+#endif
603
     return 0;
604
 }
605
 
606
+#if defined(__linux__)
607
 static int
608
 fb_cmap_set(int fbfp, struct fb_cmap *cmap)
609
+#elif defined(__FreeBSD__)
610
+static int
611
+fb_cmap_set(int fbfp, video_color_palette_t *cmap)
612
+#endif
613
 {
614
+#if defined(__linux__)
615
     if (ioctl(fbfp, FBIOPUTCMAP, cmap)) {
616
 	perror("ioctl FBIOPUTCMAP error\n");
617
 	return -1;
618
     }
619
+#elif defined(__FreeBSD__)
620
+    if (ioctl(fbfp, FBIO_SETPALETTE, cmap) == -1) {
621
+	perror("ioctl FBIO_SETPALETTE error\n");
622
+	return -1;
623
+    }
624
+#endif
625
     return 0;
626
 }
627
 
628
@@ -612,10 +955,16 @@
629
  * fb_munmap()          deletes the mappings
630
  */
631
 
632
+#if defined(__linux__)
633
 static void *
634
 fb_mmap(int fbfp, struct fb_fix_screeninfo *scinfo)
635
+#elif defined(__FreeBSD__)
636
+static void *
637
+fb_mmap(int fbfp, video_adapter_info_t *video_adapter_info)
638
+#endif
639
 {
640
     void *buf;
641
+#if defined(__linux__)
642
     if ((buf = (unsigned char *)
643
 	 mmap(NULL, scinfo->smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fbfp,
644
 	      (off_t) 0))
645
@@ -623,13 +972,41 @@
646
 	perror("mmap error");
647
 	return NULL;
648
     }
649
+#elif defined(__FreeBSD__)
650
+    size_t mmap_offset;
651
+    size_t mmap_length;
652
+    mmap_offset = (size_t)(video_adapter_info->va_window) & (PAGE_MASK);
653
+    mmap_length = (size_t)(video_adapter_info->va_window_size +
654
+			   mmap_offset + PAGE_MASK) & (~PAGE_MASK);
655
+    if ((buf = (unsigned char *)
656
+	 mmap(NULL, mmap_length, PROT_READ | PROT_WRITE, MAP_SHARED, fbfp,
657
+	      (off_t) 0))
658
+	== MAP_FAILED) {
659
+	perror("mmap error");
660
+	return NULL;
661
+    }
662
+#endif
663
     return buf;
664
 }
665
 
666
+#if defined(__linux__)
667
 static int
668
 fb_munmap(void *buf, struct fb_fix_screeninfo *scinfo)
669
+#elif defined(__FreeBSD__)
670
+static int
671
+fb_munmap(void *buf, video_adapter_info_t *video_adapter_info)
672
+#endif
673
 {
674
+#if defined(__linux__)
675
     return munmap(buf, scinfo->smem_len);
676
+#elif defined(__FreeBSD__)
677
+    size_t mmap_offset;
678
+    size_t mmap_length;
679
+    mmap_offset = (size_t)(video_adapter_info->va_window) & (PAGE_MASK);
680
+    mmap_length = (size_t)(video_adapter_info->va_window_size +
681
+			   mmap_offset + PAGE_MASK) & (~PAGE_MASK);
682
+    return munmap((void *)((u_long)buf & (~PAGE_MASK)), mmap_length);
683
+#endif
684
 }
685
 
686
 /*
687
@@ -637,6 +1014,7 @@
688
  * 
689
  * fb_fscrn_get()               get information
690
  */
691
+#if defined(__linux__)
692
 static int
693
 fb_fscrn_get(int fbfp, struct fb_fix_screeninfo *scinfo)
694
 {
695
@@ -646,12 +1024,14 @@
696
     }
697
     return 0;
698
 }
699
+#endif
700
 
701
 /*
702
  * (struct fb_var_screeninfo) device independent variable information
703
  * 
704
  * fb_vscrn_get()               get information
705
  */
706
+#if defined(__linux__)
707
 static int
708
 fb_vscrn_get(int fbfp, struct fb_var_screeninfo *scinfo)
709
 {
710
@@ -661,3 +1041,41 @@
711
     }
712
     return 0;
713
 }
714
+#endif
715
+
716
+#if defined(__FreeBSD__)
717
+static int
718
+fb_video_mode_get(int fbfp, int *video_mode)
719
+{
720
+    if (ioctl(fbfp, FBIO_GETMODE, video_mode) == -1) {
721
+	perror("ioctl FBIO_GETMODE error\n");
722
+	return -1;
723
+    }
724
+    return 0;
725
+}
726
+#endif
727
+
728
+#if defined(__FreeBSD__)
729
+static int
730
+fb_video_info_get(int fbfp, video_info_t *video_info)
731
+{
732
+    if (ioctl(fbfp, FBIO_MODEINFO, video_info) == -1) {
733
+	perror("ioctl FBIO_MODEINFO error\n");
734
+	return -1;
735
+    }
736
+    return 0;
737
+}
738
+#endif
739
+
740
+#if defined(__FreeBSD__)
741
+static int
742
+fb_video_adapter_info_get(int fbfp, video_adapter_info_t *video_adapter_info)
743
+{
744
+    if (ioctl(fbfp, FBIO_ADPINFO, video_adapter_info) == -1) {
745
+	perror("ioctl FBIO_ADPINFO error\n");
746
+	return -1;
747
+    }
748
+    return 0;
749
+}
750
+#endif
751
+
(-)w3m/files/patch-w3mimg_fb_fb.h (+14 lines)
Line 0 Link Here
1
--- w3mimg/fb/fb.h.orig	2003-07-08 00:48:17.000000000 +0900
2
+++ w3mimg/fb/fb.h	2007-11-23 02:43:22.000000000 +0900
3
@@ -1,7 +1,11 @@
4
 /* $Id: fb.h,v 1.7 2003/07/07 15:48:17 ukai Exp $ */
5
 #ifndef fb_header
6
 #define fb_header
7
+#if defined(__linux__)
8
 #include <linux/fb.h>
9
+#elif defined(__FreeBSD__)
10
+#include <sys/fbio.h> 
11
+#endif
12
 
13
 typedef struct {
14
     int num;
(-)w3m/files/patch-w3mimg_fb_fb_w3mimg.c (+29 lines)
Line 0 Link Here
1
--- w3mimg/fb/fb_w3mimg.c.orig	Wed Aug  4 17:32:28 2004
2
+++ w3mimg/fb/fb_w3mimg.c	Mon Dec  3 10:42:23 2007
3
@@ -153,10 +153,15 @@
4
 	return 0;
5
     if (strncmp(tty, "/dev/", 5) == 0)
6
 	tty += 5;
7
+#if defined(__linux__)
8
     if (strncmp(tty, "tty", 3) == 0 && isdigit(*(tty + 3)))
9
 	return 1;
10
     if (strncmp(tty, "vc/", 3) == 0 && isdigit(*(tty + 3)))
11
 	return 1;
12
+#elif defined(__FreeBSD__)
13
+    if (strncmp(tty, "ttyv", 4) == 0 && isxdigit(*(tty + 4)))
14
+	return 1;
15
+#endif
16
     return 0;
17
 }
18
 #else
19
@@ -172,7 +177,9 @@
20
 	return NULL;
21
     memset(wop, 0, sizeof(w3mimg_op));
22
 
23
-    if (!check_tty_console(getenv("W3M_TTY")) && strcmp("jfbterm", getenv("TERM")) != 0) {
24
+    if (!check_tty_console(getenv("W3M_TTY")) &&
25
+	strcmp("jfbterm", getenv("TERM")) != 0 &&
26
+	strncmp("jfbterm-", getenv("TERM"), 8) != 0) {
27
 	fprintf(stderr, "w3mimgdisplay/fb: tty is not console\n");
28
 	goto error;
29
     }

Return to bug 122673