Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* Copyright (C) 1989, 1990, 1991, 1996, 1998 Aladdin Enterprises.  All rights reserved.
2
 
3
  This software is provided AS-IS with no warranty, either express or
4
  implied.
5
 
6
  This software is distributed under license and may not be copied,
7
  modified or distributed except as expressly authorized under the terms
8
  of the license contained in the file LICENSE in this distribution.
9
 
10
  For more information about licensing, please refer to
11
  http://www.ghostscript.com/licensing/. For information on
12
  commercial licensing, go to http://www.artifex.com/licensing/ or
13
  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
*/
16
 
17
/* $Id: gdevsnfb.c,v 1.5 2002/02/21 22:24:52 giles Exp $*/
18
/* Sony News frame buffer driver for GhostScript */
19
#include "gdevprn.h"
20
#define prn_dev ((gx_device_printer *)dev) /* needed in 5.31 et seq */
21
/*#include <sys/types.h> problems with ushort! */
22
typedef	char *	caddr_t;
23
typedef	long	off_t;
24
#include <sys/uio.h>
25
#include <newsiop/framebuf.h>
26
 
27
/* The device descriptor */
28
private dev_proc_open_device(sonyfb_open);
29
private dev_proc_output_page(sonyfb_output_page);
30
private dev_proc_close_device(sonyfb_close);
31
private gx_device_procs sonyfb_procs =
32
  prn_procs(sonyfb_open, sonyfb_output_page, sonyfb_close);
33
const gx_device_printer far_data gs_sonyfb_device =
34
  prn_device(sonyfb_procs, "sonyfb",
35
	102.4,				/* width_10ths */
36
	103.2,				/* height_10ths */
37
	100,				/* x_dpi */
38
	100,				/* y_dpi */
39
	0,0,0,0,			/* margins */
40
	1, 0);
41
 
42
private int fb_file = -1;
43
sPrimRect prect;
44
 
45
private int
46
sonyfb_open(gx_device *dev)
47
{
48
  sScrType stype;
49
 
50
  if(fb_file < 0)
51
    if((fb_file = open("/dev/fb", 2)) < 0)
52
      perror("open failed");
53
    else
54
      if(ioctl(fb_file, FBIOCGETSCRTYPE, &stype) < 0)
55
	perror("ioctl failed");
56
      else
57
	prect.rect = stype.visiblerect;
58
 
59
  return gdev_prn_open(dev);
60
}
61
 
62
private int
63
sonyfb_close(gx_device *dev)
64
{
65
  if(fb_file >= 0)
66
    {
67
      close(fb_file);
68
      fb_file = -1;
69
    }
70
  return gdev_prn_close(dev);
71
}
72
 
73
#define FRAME_WIDTH	1024
74
 
75
/* Send the page to the printer. */
76
private int
77
sonyfb_output_page(gx_device *dev, int num_copies, int flush)
78
{
79
  int l, i, byte_width, height;
80
  unsigned char *bm, *fbs, *fb;
81
 
82
  byte_width = (dev->width + 7) / 8;
83
  height = dev->height;
84
  bm	 = (typeof(bm))prn_dev->mem.base;
85
 
86
  prect.refPoint.x = 0;
87
  prect.refPoint.y = 0;
88
  prect.ptnRect = prect.rect;
89
 
90
  prect.ptnBM.type  = BM_MEM;
91
  prect.ptnBM.depth = 1;
92
  prect.ptnBM.width = (byte_width + 1) / 2;
93
  prect.ptnBM.rect.origin.x = 0;
94
  prect.ptnBM.rect.origin.y = 0;
95
  prect.ptnBM.rect.extent.x = byte_width * 8; /* width in 16bit words */
96
  prect.ptnBM.rect.extent.y = height;
97
  prect.ptnBM.base = (typeof(prect.ptnBM.base))bm;
98
 
99
  prect.fore_color = 1;
100
  prect.aux_color = 0;
101
  prect.planemask = FB_PLANEALL;
102
  prect.transp = 0;
103
  prect.func = BF_S;
104
  prect.clip = prect.rect;
105
  prect.drawBM.type  = BM_FB;
106
  prect.drawBM.depth = 1;
107
  prect.drawBM.width = (prect.rect.extent.x + 15) / 16;
108
  prect.drawBM.rect = prect.rect;
109
  prect.drawBM.base = 0;
110
 
111
  if(ioctl(fb_file, FBIOCRECTANGLE, &prect) < 0)
112
    perror("rect ioctl failed");
113
 
114
  return gx_finish_output_page(dev, num_copies, flush);
115
}