Article View: fj.lang.postscript
Article #982Re: Can't compile gdevn533.c in gs23.
From: LAO Shihong
Date: Tue, 31 Mar 1992 05:59
Date: Tue, 31 Mar 1992 05:59
527 lines
16913 bytes
16913 bytes
In article <IKAI.92Mar31084816@ecip00.cc.kurume-it.ac.jp> ikai@cc.kurume-it.ac.jp (Hidetaka Ikai) writes:
>Sony $@$N(J LBP $@$G$"$k(J NWP533 $@$G(J Gostscript 2.3 $@$rF0$+$=$&$H$7$^$7$?$,!$(J
>gdevn533.c $@$O<!$N%(%i!<$G%3%s%Q%$%k$G$-$^$;$s!%(J
>
>cc $@$G$N%a%C%;!<%8(J
>"gdevn533.c", line 147: mem undefined
>"gdevn533.c", line 147: member of structure or union required
$@$3$l$N(Jpatch$@$,(Jgnu.ghostscript.bug$@$K(Jpost$@$5$l$^$7$?!%$=$s$J$KD9$/$J$$$7!$(J
$@:G6aNI$/$3$N<ALd$,8+$+$1$^$9$N$G!$$3$3$K(Jpost$@$7$^$9!%(J
------- $@$3$3$+$i(J---------
>From: Hannu.ARonsson@cs.hut.fi (haa)
Newsgroups: gnu.ghostscript.bug
Subject: Sony nwp533 and frame buffer diffs for 2.2 (Re: sony nwp533 driver)
Message-ID: <HAA.91Aug8175552@zen.hut.fi>
Date: 8 Aug 91 21:55:52 GMT
References: Hannu.ARonsson@cs.hut.fi (haa)
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: Helsinki University of Technology, Finland
Lines: 496
Approved: bug-ghostscript@prep.ai.mit.edu
In article <Z6GTF2R@math.fu-berlin.de> hecht@sonne.zedat.fu-berlin.de
(Wolfgang Hecht) writes:
>
> I have problems with the nwp533 printer driver on our sony
> workstation [...]
The internal format of the bitmap has changed between version 2.1 and
2.2, so the printer driver requires updating accordingly.
Acknowledgements: The major changes needed for 2.2 and nwp533 were
posted in the fj.sys.news (Japanese) newsgroup by Kaneko
Yutaka <kaneko@rcais.tohoku.ac.jp>, I only made a few little
minor finishing touches. The frame buffer code was updated by
Tero Kivinen <kivinen@niksula.hut.fi>.
I did not have enought time now to do things really *right*, so please
complain to me first, as the kludges and bugs are probably mine.
I could not get the clist method work for printing, it died (overwrote
clist structures) at scan line 1008 (the boundary between clist #2 and
#3), so I "fixed" it by increasing the amount of memory allowed for
the bitmap in gdevprn.h, so gs would use a full-page bitmap, which
seems to work -- I know, this is a dirty fix.
In our setting, we regularly use gs to print Postscript on our nwp533
printer. I have included a sample script you can put to /etc/printcap.
The script uses a grand kludge for the printer output, as gs itself
may output something to stdout (See #ifdef NIKSULA in the source
patches).
We also use a different dithering algorithm with the printer, which
looks better on a 400dpi device than the original dithering algorithm
(this is in the gs_init.ps file patch).
In the appended shar file, please find the patch files and a sample
shell-script front end for printing and returning status/error
information via e-mail.
Study the patches and apply appropriately.
As usual, it works well for us, but your mileage may vary.
rgds//haa
--
Hannu Aronsson <Hannu.Aronsson@cs.hut.fi>
Laboratory of Computer Science
Helsinki University of Technology, Tel. +358 0 451 3233 (GMT+2)
Otakaari 1, 02150 Espoo, Finland. Fax. +358 0 451 3293
---clip-here------clip-here------clip-here------clip-here------clip-here---
#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 08/08/1991 14:15 UTC by haa@hutcs.cs.hut.fi
# Source directory /m/hutcs/users/haa
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1500 -rw-r--r-- PATCH.gs_init
# 3017 -rw-r--r-- PATCH.newsfb
# 4099 -rw-r--r-- PATCH.nwp533
# 1100 -rwxr-xr-x lpf_gs533
#
# ============= PATCH.gs_init ==============
if test -f 'PATCH.gs_init' -a X"$1" != X"-c"; then
echo 'x - skipping PATCH.gs_init (File already exists)'
else
echo 'x - extracting PATCH.gs_init (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'PATCH.gs_init' &&
*** gs_init.ps.orig Wed May 29 22:42:30 1991
--- gs_init.ps Fri Aug 2 10:57:01 1991
*** 606,611 ****
--- 611,639 ----
X ifelse
X 1 setflat % initgraphics doesn't set this
X { } settransfer % ditto
+
+ %%NIKSULA
+ %
+ % NOTE: copied straight from GS2.1.1 init file modifications, thus
+ % the kludge may not really be necessary, if the bug does not exist
+ % any more...
+ %
+ % The Niksula dither has a part of a circle in the middle of each side
+ % of the dithering square. GS has a bug in this, as the angle argument
+ % to setscreen works differently than in real PS. Gs rotates the dither
+ % matrix itself, PS rotates the whole dither pattern as a whole.
+ %
+ % For DITHERPPI, 32.5 works best on our 400dpi Sony NWP533 printer.
+
+ systemdict /DITHERPPI known
+ {
+ DITHERPPI 0 { abs /y exch def abs /x exch def
+ x y le { x y /x exch def /y exch def } if
+ x 1 sub dup mul y dup mul add 1 exch sub } setscreen
+ } % else
+ {
+ %%NIKSULAEND
+
X % The following 'ordered dither' spot function was contributed by
X % Gregg Townsend. Thanks, Gregg!
X 72 72 dtransform abs exch abs min % min(|dpi x|,|dpi y|)
***************
*** 628,633 ****
--- 656,664 ----
X 32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98
X F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58
X > exch get 256 div } bind setscreen
+ %%NIKSULA
+ } ifelse
+ %%END NIKSULA
X initgraphics
X % The interpreter relies on there being at least 2 entries
X % on the graphics stack. Establish the second one now.
X
SHAR_EOF
chmod 0644 PATCH.gs_init ||
echo 'restore of PATCH.gs_init failed'
Wc_c="`wc -c < 'PATCH.gs_init'`"
test 1500 -eq "$Wc_c" ||
echo 'PATCH.gs_init: original size 1500, current size' "$Wc_c"
fi
# ============= PATCH.newsfb ==============
if test -f 'PATCH.newsfb' -a X"$1" != X"-c"; then
echo 'x - skipping PATCH.newsfb (File already exists)'
else
echo 'x - extracting PATCH.newsfb (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'PATCH.newsfb' &&
*** /p/src2/gs-2.2-j/gdevsnfb.c Wed Apr 10 12:41:46 1991
--- gdevsnfb.c Sun Jun 9 14:01:42 1991
***************
*** 56,62 ****
X if(ioctl(fb_file, FBIOCGETSCRTYPE, &stype) < 0)
X perror("ioctl failed");
X else
! prect.rect = stype.visiblerect;
X
X return gdev_prn_open(dev);
X }
--- 56,84 ----
X if(ioctl(fb_file, FBIOCGETSCRTYPE, &stype) < 0)
X perror("ioctl failed");
X else
! {
! prect.rect = stype.visiblerect;
! prect.drawBM.depth = stype.plane;
! switch (stype.plane)
! {
! case 1:
! prect.fore_color = 1;
! prect.aux_color = 0;
! break;
! case 4:
! prect.fore_color = 0;
! prect.aux_color = 15;
! break;
! case 8:
! prect.fore_color = 255;
! prect.aux_color = 0;
! break;
! default:
! fprintf(stderr, "Unknown screen depth\n");
! break;
! }
!
! }
X
X return gdev_prn_open(dev);
X }
***************
*** 78,86 ****
X private int
X sonyfb_output_page(gx_device *dev)
X {
X int l, i, byte_width, height;
X unsigned char *bm, *fbs, *fb;
-
X byte_width = (dev->width + 7) / 8;
X height = dev->height;
X bm = (typeof(bm))prn_dev->mem.base;
--- 100,144 ----
X private int
X sonyfb_output_page(gx_device *dev)
X {
+ #ifndef OLD_GDEVSNFB
+ int byte_width, lnum;
+ int line_size = gdev_mem_bytes_per_scan_line(dev);
+ byte *in = (byte *) gs_malloc(line_size, 1, "sonyfb_output_page(in)");
+
+ byte_width = (dev->width + 7) / 8;
+
+ prect.refPoint.x = 0;
+ prect.refPoint.y = 0;
+ prect.ptnRect = prect.rect;
+
+ prect.ptnBM.type = BM_MEM;
+ prect.ptnBM.depth = 1;
+ prect.ptnBM.width = (byte_width + 1) / 2;
+ prect.ptnBM.rect.origin.x = 0;
+ prect.ptnBM.rect.origin.y = 0;
+ prect.ptnBM.rect.extent.x = byte_width * 8; /* width in 16bit words */
+ prect.ptnBM.rect.extent.y = 1;
+ prect.ptnBM.base = (typeof(prect.ptnBM.base))in;
+
+ prect.planemask = FB_PLANEALL;
+ prect.transp = 0;
+ prect.func = BF_S;
+ prect.clip = prect.rect;
+ prect.drawBM.type = BM_FB;
+ prect.drawBM.width = (prect.rect.extent.x + 15) / 16;
+ prect.drawBM.rect = prect.rect;
+ prect.drawBM.rect.extent.y = 1;
+ prect.drawBM.base = 0;
+ for ( lnum = 0; lnum < dev->height; lnum++, prect.drawBM.rect.origin.y++ )
+ {
+ gdev_prn_copy_scan_lines(prn_dev, lnum, in, line_size);
+ if(ioctl(fb_file, FBIOCRECTANGLE, &prect) < 0)
+ perror("rect ioctl failed");
+ }
+ gs_free(in, line_size, 1, "sonyfb_output_page(in)");
+ #else
X int l, i, byte_width, height;
X unsigned char *bm, *fbs, *fb;
X byte_width = (dev->width + 7) / 8;
X height = dev->height;
X bm = (typeof(bm))prn_dev->mem.base;
***************
*** 112,117 ****
X
X if(ioctl(fb_file, FBIOCRECTANGLE, &prect) < 0)
X perror("rect ioctl failed");
!
X return 0;
X }
--- 170,177 ----
X
X if(ioctl(fb_file, FBIOCRECTANGLE, &prect) < 0)
X perror("rect ioctl failed");
!
! #endif
!
X return 0;
X }
SHAR_EOF
chmod 0644 PATCH.newsfb ||
echo 'restore of PATCH.newsfb failed'
Wc_c="`wc -c < 'PATCH.newsfb'`"
test 3017 -eq "$Wc_c" ||
echo 'PATCH.newsfb: original size 3017, current size' "$Wc_c"
fi
# ============= PATCH.nwp533 ==============
if test -f 'PATCH.nwp533' -a X"$1" != X"-c"; then
echo 'x - skipping PATCH.nwp533 (File already exists)'
else
echo 'x - extracting PATCH.nwp533 (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'PATCH.nwp533' &&
*** gdevn533.c.orig Wed Apr 10 12:41:36 1991
--- gdevn533.c Thu Aug 8 16:38:20 1991
***************
*** 92,100 ****
X }
X if(waiting)
X {
! ioctl(1, LBIOCRESET, 0);
X sleep(5);
! ioctl(1, LBIOCSTATUS, &status);
X }
X }
X while(waiting);
--- 92,100 ----
X }
X if(waiting)
X {
! ioctl(printer_file, LBIOCRESET, 0); /* fd was 1 --haa */
X sleep(5);
! ioctl(printer_file, LBIOCSTATUS, &status);
X }
X }
X while(waiting);
***************
*** 107,114 ****
X fprintf(stderr, "in nwp533 open\n");
X
X if(printer_file < 0)
! if((printer_file = open("/dev/lbp", O_WRONLY)) < 0)
! return printer_file;
X
X return gdev_prn_open(dev);
X }
--- 107,122 ----
X fprintf(stderr, "in nwp533 open\n");
X
X if(printer_file < 0)
! #ifdef NIKSULA
! /* Use stdout, if we are running as printer filter --haa */
! if (getenv("PRINTERFILTER")) { /* Kludge alert! */
! printer_file = atoi(getenv("PRINTERFILTER"));/* I told you! */
! } else
! #endif
! if((printer_file = open("/dev/lbp", O_WRONLY)) < 0) {
! perror("Nwp533 open failed");
! return printer_file;
! }
X
X return gdev_prn_open(dev);
X }
***************
*** 120,128 ****
X
X if(printer_file >= 0)
X {
X close(printer_file);
X printer_file = -1;
! }
X
X return gdev_prn_close(dev);
X }
--- 128,145 ----
X
X if(printer_file >= 0)
X {
+ /* Wait for the current printing to finish before close --haa*/
+ c_restart:
+ if(ioctl(printer_file, LBIOCSTOP, 0) < 0)
+ {
+ if(analyze_error())
+ goto c_restart;
+ perror("Waiting for device");
+ /* return -1; /* maybe not wise in *_close(?) */
+ }
X close(printer_file);
X printer_file = -1;
! }
X
X return gdev_prn_close(dev);
X }
***************
*** 143,156 ****
X return -1;
X }
X lseek(printer_file, 0, 0);
!
! if(write(printer_file, prn_dev->mem.base,
! (dev->width * dev->height) / 8) !=
! (dev->width * dev->height) / 8)
! {
! perror("Writting to output");
! return -1;
X }
X retry:
X if(ioctl(printer_file, LBIOCSTART, 0) < 0)
X {
--- 160,182 ----
X return -1;
X }
X lseek(printer_file, 0, 0);
! {
! int lnum;
! uint line_size = gdev_mem_bytes_per_scan_line(dev);
! byte *in = (byte *)gs_malloc(line_size, 1, "nwp533_print_page(in)");
! for ( lnum = 0; lnum < prn_dev->height; lnum++ ) {
! gdev_prn_copy_scan_lines(prn_dev, lnum, in, line_size);
! if(write(printer_file, (char *)in, line_size) != line_size) {
! {
! perror("Writing to output"); /* s/tt/t/ --haa */
! gs_free((char *)in, line_size, 1, "nwp533_print_page(in)");
! return -1;
! }
! };
X }
+ gs_free((char *)in, line_size, 1, "nwp533_print_page(in)");
+ }
+
X retry:
X if(ioctl(printer_file, LBIOCSTART, 0) < 0)
X {
*** gdevprn.h.orig Tue May 28 02:47:04 1991
--- gdevprn.h Fri Aug 2 12:51:20 1991
***************
*** 38,46 ****
--- 38,53 ----
X # define PRN_BUFFER_SPACE 20000
X #else
X /* Unix and VMS machines have great big hulking RAMs.... */
+ #ifdef sony_news
+ /* We have even greater big hulking RAMs, the clist code dies */
+ /* with the nwp533 printer output code (scrambled structures) --haa */
+ # define PRN_MAX_BITMAP 1800000L /* nwp533 is approx 1.8 megs */
+ # define PRN_BUFFER_SPACE 250000L
+ #else
X # define PRN_MAX_BITMAP 300000L
X # define PRN_BUFFER_SPACE 250000L
X #endif
+ #endif
X
X /****** ENABLE OR DISABLE DIRECT WRITING TO PRINTER ******/
X #ifdef __MSDOS__
***************
*** 127,134 ****
X sizeof(gx_device_printer),\
X &procs,\
X dev_name,\
! (int)((long)width_10ths * x_dpi / 10), /* width */\
! (int)((long)height_10ths * y_dpi / 10), /* height */\
X x_dpi,\
X y_dpi,\
X l_margin, b_margin, r_margin, t_margin,\
--- 134,141 ----
X sizeof(gx_device_printer),\
X &procs,\
X dev_name,\
! (int)((double)width_10ths * x_dpi / 10), /* width */\
! (int)((double)height_10ths * y_dpi / 10), /* height */\
X x_dpi,\
X y_dpi,\
X l_margin, b_margin, r_margin, t_margin,\
SHAR_EOF
chmod 0644 PATCH.nwp533 ||
echo 'restore of PATCH.nwp533 failed'
Wc_c="`wc -c < 'PATCH.nwp533'`"
test 4099 -eq "$Wc_c" ||
echo 'PATCH.nwp533: original size 4099, current size' "$Wc_c"
fi
# ============= lpf_gs533 ==============
if test -f 'lpf_gs533' -a X"$1" != X"-c"; then
echo 'x - skipping lpf_gs533 (File already exists)'
else
echo 'x - extracting lpf_gs533 (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'lpf_gs533' &&
#!/bin/sh
#
# Ghostscript front end for hessu
#
# Authors: haa, kivinen
#
X
NAME="unknown"
HOST="unknown"
X
while test $# -gt 0 >/dev/null 2>&1
do
X case "$1" in
X -n) NAME=$2; shift; shift;;
X -h) HOST=$2; shift; shift;;
X *) shift;;
X esac
done
X
rm -f /tmp/gsout$$
# Gs writes to fd3, stdin goes to stderr.
(PRINTERFILTER=3 /p/src2/gs-2.2-j/gs -dQUIET -sDEVICE=nwp533 \
X -dNOPAUSE -dDITHERPPI=32.5 - 3>&1 1>&2) 2>/tmp/gsout$$
(echo "Your GhostScript job has finished. [version gs-2.2-j]"
X awk ' /^in nwp533 open/ { next; }
X /^in nwp533 output page / { pages++; next; }
X /^in nwp533 close/ { next; }
X { if (errors==0)
X print "*****Errors detected, output from Ghostscript follows*****";
X print; errors++;
X }
X END {if (pages) printf "Printed %d page(s). ", pages
X else printf "No pages printed. ";
X if (!errors) printf "No errors detected.";
X printf "\n";
X }' /tmp/gsout$$) |
Mail -s "Ghostscript status output" $NAME@$HOST
#/p/bin/rmsg $NAME@$HOST >/dev/null 2>&1
X
rm -f core /tmp/gsout$$
Xexit 0
X
SHAR_EOF
chmod 0755 lpf_gs533 ||
echo 'restore of lpf_gs533 failed'
Wc_c="`wc -c < 'lpf_gs533'`"
test 1100 -eq "$Wc_c" ||
echo 'lpf_gs533: original size 1100, current size' "$Wc_c"
fi
exit 0
---clip-here------clip-here------clip-here------clip-here------clip-here---
rgds//haa
--
Hannu Aronsson <Hannu.Aronsson@cs.hut.fi>
Laboratory of Computer Science
Helsinki University of Technology, Tel. +358 0 451 3233 (GMT+2)
Otakaari 1, 02150 Espoo, Finland. Fax. +358 0 451 3293
|~|~~~|~~~| lao@kuee.kyoto-u.ac.jp
| | 1 | | | LAO Shihong (Rock Stone)
| |_!_|___| Elec. Eng. Dept. Kyoto Univ. JAPAN 606.
|_________| Tel:075-753-5286(Lab)
Technical Details
Message-ID:
<5247@kuee.kuee.kyoto-u.ac.jp>Path:
arc1-ca.pugleaf.net!sparky!uunet!ccut!sh.wide!astemgw!kuis!kuee!rotary!laoReferences:
<IKAI.92Mar31084816@ecip00.cc.kurume-it.ac.jp>Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS X-Google-Thread: fa2ca,37548dce40f83b09 X-Google-Attributes: gidfa2ca,public X-Google-ArrivalTime: 1992-03-30 21:59:06 PST Path: arc1-ca.pugleaf.net!sparky!uunet!ccut!sh.wide!astemgw!kuis!kuee!rotary!lao From: lao@rotary.kuee.kyoto-u.ac.jp (LAO Shihong) Newsgroups: fj.lang.postscript Subject: Re: Can't compile gdevn533.c in gs23. Message-ID: <5247@kuee.kuee.kyoto-u.ac.jp> Date: 31 Mar 92 05:59:06 GMT References: <IKAI.92Mar31084816@ecip00.cc.kurume-it.ac.jp> Sender: news@kuee.kuee.kyoto-u.ac.jp Reply-To: lao@rotary.kuee.kyoto-u.ac.jp (LAO Shihong) Distribution: fj Organization: Electrical Engineering Dept. Kyoto Univ. Lines: 527