1
/* Copyright (C) 2001-2012 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied,
8
modified or distributed except as expressly authorized under the terms
9
of the license contained in the file LICENSE in this distribution.
11
Refer to licensing information at http://www.artifex.com or contact
12
Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael,
13
CA 94903, U.S.A., +1(415)492-9861, for further information.
17
/* Sony News frame buffer driver for GhostScript */
19
#define prn_dev ((gx_device_printer *)dev) /* needed in 5.31 et seq */
20
/*#include <sys/types.h> problems with ushort! */
21
typedef char * caddr_t;
24
#include <newsiop/framebuf.h>
26
/* The device descriptor */
27
static dev_proc_open_device(sonyfb_open);
28
static dev_proc_output_page(sonyfb_output_page);
29
static dev_proc_close_device(sonyfb_close);
30
static gx_device_procs sonyfb_procs =
31
prn_procs(sonyfb_open, sonyfb_output_page, sonyfb_close);
32
const gx_device_printer far_data gs_sonyfb_device =
33
prn_device(sonyfb_procs, "sonyfb",
34
102.4, /* width_10ths */
35
103.2, /* height_10ths */
38
0,0,0,0, /* margins */
41
static int fb_file = -1;
45
sonyfb_open(gx_device *dev)
50
if((fb_file = open("/dev/fb", 2)) < 0)
51
perror("open failed");
53
if(ioctl(fb_file, FBIOCGETSCRTYPE, &stype) < 0)
54
perror("ioctl failed");
56
prect.rect = stype.visiblerect;
58
return gdev_prn_open(dev);
62
sonyfb_close(gx_device *dev)
69
return gdev_prn_close(dev);
72
#define FRAME_WIDTH 1024
74
/* Send the page to the printer. */
76
sonyfb_output_page(gx_device *dev, int num_copies, int flush)
78
int l, i, byte_width, height;
79
unsigned char *bm, *fbs, *fb;
81
byte_width = (dev->width + 7) / 8;
83
bm = (typeof(bm))prn_dev->mem.base;
87
prect.ptnRect = prect.rect;
89
prect.ptnBM.type = BM_MEM;
90
prect.ptnBM.depth = 1;
91
prect.ptnBM.width = (byte_width + 1) / 2;
92
prect.ptnBM.rect.origin.x = 0;
93
prect.ptnBM.rect.origin.y = 0;
94
prect.ptnBM.rect.extent.x = byte_width * 8; /* width in 16bit words */
95
prect.ptnBM.rect.extent.y = height;
96
prect.ptnBM.base = (typeof(prect.ptnBM.base))bm;
100
prect.planemask = FB_PLANEALL;
103
prect.clip = prect.rect;
104
prect.drawBM.type = BM_FB;
105
prect.drawBM.depth = 1;
106
prect.drawBM.width = (prect.rect.extent.x + 15) / 16;
107
prect.drawBM.rect = prect.rect;
108
prect.drawBM.base = 0;
110
if(ioctl(fb_file, FBIOCRECTANGLE, &prect) < 0)
111
perror("rect ioctl failed");
113
return gx_finish_output_page(dev, num_copies, flush);