Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Macros | Functions | Variables
qcr.c File Reference
#include "qcr.h"
Include dependency graph for qcr.c:

Go to the source code of this file.

Macros

#define IS_ONE(resp_num, msg1, msg2)
 

Functions

 qcr_wait_srq ()
 
 write_qcr_cmd (int cmd)
 
 write_data (char *buff, int len)
 
int init_qcr (short verbose)
 
 print_qcr_status ()
 
int set_resolution (int fourK)
 
 set_up_qcr (int x_size, int y_size, int nslice, int offset)
 
 set_up_qcr_nc (xstart, ystart, xsize, ysize, fourK)
 
 send_pixel_image (int color, char *buff, int len)
 
 send_rle_image (int color, char *buff, int len)
 
int send_3pass_rle (unsigned char *buff, int len)
 
 close_qcr ()
 
int reset_qcr ()
 
 qcr_rd_brt_tbl (buf)
 
 qcr_rd_brt_lvl (buf)
 
 qcr_ld_lut12 (buf)
 
 qcr_rd_lut12 (buf)
 
 qcr_load_i_luts (int lut)
 

Variables

int qcr_cmd
 
int qcr_data
 
int qcr_raw
 
short verbose_flag
 
unsigned char response [ 8192 ]
 

Macro Definition Documentation

#define IS_ONE (   resp_num,
  msg1,
  msg2 
)
Value:
if (((int)response[resp_num + 1]) == 1) \
printf(msg1); else printf(msg2);
unsigned char response[ 8192 ]
Definition: qcr.c:19

Definition at line 162 of file qcr.c.

Function Documentation

close_qcr ( )

Definition at line 517 of file qcr.c.

References qcr_cmd, qcr_data, and qcr_raw.

518 {
519  close(qcr_cmd);
520  close(qcr_data);
521  close(qcr_raw);
522  }
int qcr_raw
Definition: qcr.c:16
int qcr_data
Definition: qcr.c:16
int qcr_cmd
Definition: qcr.c:16
int init_qcr ( short  verbose)

Definition at line 104 of file qcr.c.

107 {
108  int len;
109  char ch, *command;
110 
111  verbose_flag = verbose; /* Some control of output */
112 
113  if ((qcr_cmd = open ("/dev/qcrc", O_RDWR)) < 0)
114  {
115  fprintf(stderr,"Recorder command dev not opened: error = %d\n",errno);
116  return(-1);
117  }
118  if ((qcr_data = open ("/dev/qcrd", O_RDWR)) < 0)
119  {
120  fprintf(stderr,"Recorder data dev not opened: error = %d\n",errno);
121  return(-1);
122  }
123 
124  if ((qcr_raw = open ("/dev/rhpib", O_RDWR)) < 0)
125  {
126  fprintf(stderr,"/dev/rhpib not opened: error = %d\n",errno);
127  return(-1);
128  }
129  /* Check for response from the Matrix */
130 
132 
133  if (read(qcr_data,response,BUFSIZ) != IDLENGTH )
134  {
135  fprintf(stderr,"Error reading response from QCR, errno = %d\n",errno);
136  return(-1);
137  }
138 
139  if (verbose_flag)
140  {
141  fprintf(stderr,"\n\n Matrix Camera Control, Version 0.1\n\n");
142  fprintf(stderr," matrix rev %s\n",response);
144  len = read(qcr_data,response,BUFSIZ);
145  switch (response[0])
146  {
147  case 0x10: command = "M35"; break;
148  case 0x20: command = "M120"; break;
149  case 0x40: command = "M240"; break;
150  case 0xf0: command = "Empty"; break;
151  default: sprintf(command,"Unknown (%x) ",response[0]); break;
152  }
153  fprintf(stderr, "Camera back: %s\n", command);
154  }
155 }
#define MODULE_ID
Definition: qcr.h:88
write_qcr_cmd(int cmd)
Definition: qcr.c:55
unsigned char response[ 8192 ]
Definition: qcr.c:19
#define GET_VERSION_ID
Definition: qcr.h:51
short verbose_flag
Definition: qcr.c:17
int verbose
Definition: aliastorle.c:96
int qcr_raw
Definition: qcr.c:16
int qcr_data
Definition: qcr.c:16
#define IDLENGTH
Definition: qcr.h:52
int qcr_cmd
Definition: qcr.c:16
print_qcr_status ( )

Definition at line 164 of file qcr.c.

References qcr_data, response, verbose_flag, and write_qcr_cmd().

165 {
166  int len, i, j;
167  unsigned char * rp;
168 
170  len = read( qcr_data, response, BUFSIZ );
171  printf("Got back %d status bytes\n", len);
172 
173  if (verbose_flag)
174  {
175  printf("Status data (in hex):\n");
176  rp = response;
177  for (j = 0; j < 2; j++)
178  {
179  for (i = 0; i < 16; i++)
180  printf("%2X ", (int) *rp++);
181  printf("\n");
182  }
183  }
184 
185  rp = response;
186  rp++; /* Output appears to have one junk byte... */
187 
188  IS_ONE(0, "External LUTs have been loaded for RGB\n",
189  "External LUTs have not been loaded for RGB\n");
190  IS_ONE(1, "External LUTs have been loaded for monochrome\n",
191  "External LUTs have not been loaded for monochrome\n");
192  printf("End of line time delay: %d\n", (int) rp[2]);
193  IS_ONE(4, "Automatic filter wheel operation is disabled\n",
194  "Automatic filter wheel operation is enabled\n");
195  IS_ONE(5, "Automatic camera operation is disabled\n",
196  "Automatic camera operation is enabled\n");
197 
198  printf("Start address (horiz, vert): %d, %d\n",
199  (int)(short)(((short)rp[12]) << 8) | rp[13],
200  (int)(short)(((short)rp[8]) << 8) | rp[9]);
201 
202  printf("Image dimensions (horiz, vert): %d, %d\n",
203  (((int) rp[10]) << 8) | rp[11],
204  (((int) rp[6]) << 8) | rp[7] );
205 
206  IS_ONE(15, "Automatic calibration enabled\n",
207  "Automatic calibration disabled\n");
208  IS_ONE(16, "End of image warble is disabled\n",
209  "End of image warble is enabled\n");
210  IS_ONE(17, "Black jumping is disabled\n",
211  "Black jumping is enabled\n");
212 
213  switch ((int)rp[18])
214  {
215  case 2:
216  printf("Resolution 2K\n");
217  break;
218  case 4:
219  printf("Resolution 4K\n");
220  break;
221  default:
222  printf("Weird resolution: %d\n", (int) rp[18]);
223  break;
224  }
225 
226  IS_ONE(19, "Mode externally selected\n",
227  "Mode is not externally selected\n");
228  IS_ONE(20, "90 degree rotation enabled\n",
229  "90 degree rotation disabled\n");
230  IS_ONE(21, "Mirror image enabled\n",
231  "Mirror image disabled\n");
232  IS_ONE(22, "Unbuffered raster mode enabled\n",
233  "Unbuffered raster mode disabled\n");
234  IS_ONE(23, "Return to no filter mode is disabled\n",
235  "Return to no filter mode is enabled\n");
236  IS_ONE(24, "Exchange of coords is selected\n",
237  "Exchange of coords is not selected\n");
238  IS_ONE(25, "Red-repeat is enabled\n",
239  "Red-repeat is disabled\n");
240  printf("Frame number: %d\n", (((int) rp[26]) << 8) | rp[27]);
241  IS_ONE(28, "Film is in camera\n",
242  "Film is not in camera\n");
243  IS_ONE(29, "Half frame mode enabled\n",
244  "Half frame mode disabled\n");
245  IS_ONE(30, "Bulk back in use\n", "" );
246  IS_ONE(31, "180 degree rotation enabled\n",
247  "180 degree rotation not enabled\n");
248 }
write_qcr_cmd(int cmd)
Definition: qcr.c:55
unsigned char response[ 8192 ]
Definition: qcr.c:19
#define IS_ONE(resp_num, msg1, msg2)
Definition: qcr.c:162
short verbose_flag
Definition: qcr.c:17
#define RETURN_STATUS
Definition: qcr.h:116
int qcr_data
Definition: qcr.c:16
int i
Definition: rletorla.c:82

Here is the call graph for this function:

qcr_ld_lut12 ( buf  )

Definition at line 565 of file qcr.c.

567 {
569  write_data( buf, 3*256*2 );
570 }
write_qcr_cmd(int cmd)
Definition: qcr.c:55
write_data(char *buff, int len)
Definition: qcr.c:74
#define LOAD_12_LUT
Definition: qcr.h:22
static char buf[4096 +1]
Definition: into.c:46
qcr_load_i_luts ( int  lut)

Definition at line 584 of file qcr.c.

586 {
587  char select_lut = lut;
589  write_data( &select_lut, 1 );
590  sleep( 2 );
591 }
write_qcr_cmd(int cmd)
Definition: qcr.c:55
write_data(char *buff, int len)
Definition: qcr.c:74
#define LOAD_INTERN_LUT
Definition: qcr.h:78
qcr_rd_brt_lvl ( buf  )

Definition at line 553 of file qcr.c.

555 {
557  if ( read( qcr_data, buf, BUFSIZ ) <= 0 )
558  {
559  perror( "Error reading brightness levels\n" );
560  return 0;
561  }
562  return 1;
563 }
write_qcr_cmd(int cmd)
Definition: qcr.c:55
#define RETURN_BRIGHT_LEVELS
Definition: qcr.h:108
int qcr_data
Definition: qcr.c:16
static char buf[4096 +1]
Definition: into.c:46
qcr_rd_brt_tbl ( buf  )

Definition at line 540 of file qcr.c.

542 {
544  if ( read( qcr_data, buf, BUFSIZ ) <= 0 )
545  {
546  perror( "Error reading brightness table\n" );
547  return 0;
548  }
549  return buf[0];
550 }
write_qcr_cmd(int cmd)
Definition: qcr.c:55
#define RETURN_BRIGHT_TABLE
Definition: qcr.h:111
int qcr_data
Definition: qcr.c:16
static char buf[4096 +1]
Definition: into.c:46
qcr_rd_lut12 ( buf  )

Definition at line 572 of file qcr.c.

574 {
576  if ( read( qcr_data, buf, 1536 ) != 1536 )
577  {
578  perror( "Error reading 12 bit LUTs\n" );
579  return 0;
580  }
581  return 1;
582 }
write_qcr_cmd(int cmd)
Definition: qcr.c:55
#define VERIFY_12
Definition: qcr.h:23
int qcr_data
Definition: qcr.c:16
static char buf[4096 +1]
Definition: into.c:46
qcr_wait_srq ( )

Definition at line 26 of file qcr.c.

References qcr_raw.

27 {
28  int i, status;
29 
30  io_timeout_ctl( qcr_raw, 90000000 ); /* 1.5 minutes */
31 
32  if (hpib_status_wait( qcr_raw, 1 ) == 0)
33  {
34  /* Clear the assertion. Assumes the default HPIB address. */
35  if ((status = hpib_spoll( qcr_raw, 2 )) == -1)
36  {
37  fprintf(stderr, "qcr.c: error during HPIB s-poll\n");
38  }
39  if ((status = hpib_spoll( qcr_raw, 3 )) == -1)
40  {
41  fprintf(stderr, "qcr.c: error during HPIB s-poll\n");
42  }
43  return(1);
44  }
45  else
46  fprintf(stderr, "qcr.c: HPIB timeout or error (no SRQ)\n");
47 }
status_ $t status
Definition: getap.c:99
int qcr_raw
Definition: qcr.c:16
int i
Definition: rletorla.c:82
int reset_qcr ( )

Definition at line 531 of file qcr.c.

References qcr_raw.

532 {
533  fprintf(stderr," ** Reset QCR ** \n\n");
534  hpib_spoll(qcr_raw,3);
535  hpib_spoll(qcr_raw,2);
536  exit(-1);
537 }
int qcr_raw
Definition: qcr.c:16
int send_3pass_rle ( unsigned char *  buff,
int  len 
)

Definition at line 489 of file qcr.c.

492 {
493  int stat;
494 
496  if (verbose_flag)
497  fprintf(stderr,"send_3passrle_: %d bytes ... ",len);
498  write_data(buff,len);
499  /* stat = write(qcr_data,buff,len); */
500  if (verbose_flag)
501  {
502  if (stat > 0)
503  fprintf(stderr,"%d bytes sent.\n",stat);
504  else
505  fprintf(stderr," Error sending data, errno = %d.\n",errno);
506  }
507  return (stat == len);
508 }
write_qcr_cmd(int cmd)
Definition: qcr.c:55
#define THREE_PASS_RLE
Definition: qcr.h:32
write_data(char *buff, int len)
Definition: qcr.c:74
short verbose_flag
Definition: qcr.c:17
send_pixel_image ( int  color,
char *  buff,
int  len 
)

Definition at line 403 of file qcr.c.

406 {
407  char *cl;
408  int stat;
409 
410  switch(color) {
411  case RED:
412  cl = "Red";
414  break;
415  case GREEN:
416  cl = "Green";
418  break;
419  case BLUE:
420  cl = "Blue";
422  break;
423  default:
424  fprintf(stderr,"send_pixel_image: unknown color %d\n",color); break;
425  }
426 
427  if (verbose_flag)
428  fprintf(stderr,"send_pixel_image: %d bytes of %s... ",len,cl);
429  /* stat = write(qcr_data,buff,len); */
430  stat = write_data(buff,len);
431  qcr_wait_srq();
432  if (verbose_flag)
433  {
434  if (stat > 0)
435  fprintf(stderr,"%d bytes sent.\n",stat);
436  else
437  fprintf(stderr," Error sending %s, errno = %d.\n",cl,errno);
438  }
439 
440  return (stat == len);
441 }
qcr_wait_srq()
Definition: qcr.c:26
write_qcr_cmd(int cmd)
Definition: qcr.c:55
write_data(char *buff, int len)
Definition: qcr.c:74
#define GREEN_PIXEL
Definition: qcr.h:38
short verbose_flag
Definition: qcr.c:17
#define RED_PIXEL
Definition: qcr.h:37
#define GREEN(x)
Definition: getami.c:50
#define BLUE(x)
Definition: getami.c:51
#define RED(x)
Definition: getami.c:49
#define BLUE_PIXEL
Definition: qcr.h:39
send_rle_image ( int  color,
char *  buff,
int  len 
)

Definition at line 443 of file qcr.c.

446 {
447  char *cl;
448  int stat;
449 
450  switch(color) {
451  case RED:
452  cl = "Red";
454  break;
455  case GREEN:
456  cl = "Green";
458  break;
459  case BLUE:
460  cl = "Blue";
462  break;
463  default:
464  fprintf(stderr,"send_rle_image: unknown color %d\n",color); break;
465  }
466 
467  if (verbose_flag)
468  fprintf(stderr,"send_rle_image: %d bytes of %s... ",len,cl);
469  stat = write(qcr_data,buff,len);
470  qcr_wait_srq();
471  if (verbose_flag)
472  {
473  if (stat > 0)
474  fprintf(stderr,"%d bytes sent.\n",stat);
475  else
476  fprintf(stderr," Error sending %s, errno = %d.\n",cl,errno);
477  }
478  return (stat == len);
479 }
qcr_wait_srq()
Definition: qcr.c:26
write_qcr_cmd(int cmd)
Definition: qcr.c:55
#define RED_RLE
Definition: qcr.h:43
short verbose_flag
Definition: qcr.c:17
int qcr_data
Definition: qcr.c:16
#define GREEN_RLE
Definition: qcr.h:44
#define GREEN(x)
Definition: getami.c:50
#define BLUE(x)
Definition: getami.c:51
#define BLUE_RLE
Definition: qcr.h:45
#define RED(x)
Definition: getami.c:49
int set_resolution ( int  fourK)

Definition at line 255 of file qcr.c.

Referenced by set_up_qcr_nc().

257 {
258  int len;
259  char ch, *command;
260 
262  len = read(qcr_data,response,BUFSIZ);
263  fprintf(stderr," Current resolution mode: %x\n",response[18+1]);
264  if (len > 0)
265  { /* Use high-res (4K) (assume 4x5 back) */
266  if (fourK)
267  {
268  if ( response[18+1] != 4 ) /* +1 for extra junk byte */
269  {
271  if (verbose_flag)
272  printf("Resetting resolution to 4k, be patient.\n");
273  sleep(10); /* Yow! */
274  }
275  }
276  else /* We only need 2k */
277  if ( response[18+1] != 2 )
278  {
280  if (verbose_flag)
281  printf("Resetting resolution to 2k, be patient.\n");
282  sleep(10); /* Yow! */
283  }
284  }
285 }
write_qcr_cmd(int cmd)
Definition: qcr.c:55
unsigned char response[ 8192 ]
Definition: qcr.c:19
short verbose_flag
Definition: qcr.c:17
#define RETURN_STATUS
Definition: qcr.h:116
int qcr_data
Definition: qcr.c:16
#define RESOLUTION_2K
Definition: qcr.h:99
#define RESOLUTION_4K
Definition: qcr.h:100

Here is the caller graph for this function:

set_up_qcr ( int  x_size,
int  y_size,
int  nslice,
int  offset 
)

Definition at line 303 of file qcr.c.

305 {
306  int len;
307  char ch, *command;
308  short scan_start, row_start;
309  unsigned char sizes[8];
310  int res;
311 
312  if ((x_size > 2048) || (y_size > 1536))
313  set_resolution( 1 );
314  else
315  set_resolution( 0 );
316 
319  write_qcr_cmd(RED_REPEAT_ON); /* Let's see what happens */
320 
321  /* Now that the resolution is settled, center image on film */
322 
323  scan_start = (y_size >> 1 ) - offset;
324  row_start = 0 - (x_size >> 1 );
325 
326  if (verbose_flag)
327  fprintf(stderr,"-- centering %d x %d image, at (%d,%d)\n",
328  x_size,y_size,row_start,scan_start);
329 
330  sizes[0] = (char) (row_start >> 8) & 0xff;
331  sizes[1] = (char) row_start;
332 
333  sizes[2] = (char) (x_size >> 8) & 0xff;
334  sizes[3] = (char) x_size;
335 
336  sizes[4] = (char) (scan_start >> 8) & 0xff;
337  sizes[5] = (char) scan_start;
338 
339  sizes[6] = (char) (nslice >> 8) & 0xff;
340  sizes[7] = (char) nslice;
341 
343  write(qcr_data,sizes,8);
344 
345 }
write_qcr_cmd(int cmd)
Definition: qcr.c:55
int y_size
Definition: get4d.c:28
short verbose_flag
Definition: qcr.c:17
#define SET_DIMENSIONS
Definition: qcr.h:53
int qcr_data
Definition: qcr.c:16
int x_size
Definition: get4d.c:28
#define RED_REPEAT_ON
Definition: qcr.h:61
#define END_WARBLE_OFF
Definition: qcr.h:75
#define MIRROR_ENABLE
Definition: qcr.h:56
int set_resolution(int fourK)
Definition: qcr.c:255
set_up_qcr_nc ( xstart  ,
ystart  ,
xsize  ,
ysize  ,
fourK   
)

Definition at line 354 of file qcr.c.

References qcr_data, set_resolution(), and write_qcr_cmd().

355 {
356  unsigned char sizes[8];
357 
358  set_resolution( fourK );
359 
362  write_qcr_cmd(RED_REPEAT_ON); /* Let's see what happens */
363 
364  if (fourK)
365  {
366  xstart = xstart - (4096/2);
367  ystart = -ystart + (3072/2);
368  }
369  else
370  {
371  xstart = xstart - (2048/2);
372  ystart = -ystart + (1536/2);
373  }
374 
375  sizes[0] = (char) (xstart >> 8) & 0xff;
376  sizes[1] = (char) xstart & 0xff;
377 
378  sizes[2] = (char) (xsize >> 8) & 0xff;
379  sizes[3] = (char) xsize;
380 
381  sizes[4] = (char) (ystart >> 8) & 0xff;
382  sizes[5] = (char) ystart;
383 
384  sizes[6] = (char) (ysize >> 8) & 0xff;
385  sizes[7] = (char) ysize;
386 
388  write(qcr_data,sizes,8);
389 }
write_qcr_cmd(int cmd)
Definition: qcr.c:55
int xsize
Definition: read98721.c:58
int ystart
Definition: read98721.c:51
int xstart
Definition: read98721.c:50
#define SET_DIMENSIONS
Definition: qcr.h:53
int qcr_data
Definition: qcr.c:16
#define RED_REPEAT_ON
Definition: qcr.h:61
int ysize
Definition: read98721.c:59
#define END_WARBLE_OFF
Definition: qcr.h:75
#define MIRROR_ENABLE
Definition: qcr.h:56
int set_resolution(int fourK)
Definition: qcr.c:255

Here is the call graph for this function:

write_data ( char *  buff,
int  len 
)

Definition at line 74 of file qcr.c.

77 {
78  int stat;
79 
80  if (io_burst(qcr_data,1) != 0) /* Enable burst mode */
81  fprintf(stderr," write_data: burst mode on failed %d\n");
82 
83  stat = write(qcr_data,buff,len);
84  if (stat != len) fprintf(stderr," write_data: stat %d != %d (len)\n",
85  stat, len);
86 
87  /* if (hpib_bus_status(qcr_raw,1) == 1) return(reset_qcr()); */
88 
89  if (io_burst(qcr_data,0) != 0) /* Disable burst mode */
90  fprintf(stderr," write_data: burst mode off failed %d\n");
91 
92  return(stat); /* Assume success */
93 }
int qcr_data
Definition: qcr.c:16
write_qcr_cmd ( int  cmd)

Definition at line 55 of file qcr.c.

Referenced by print_qcr_status(), and set_up_qcr_nc().

57 {
58  char ch[1];
59 
60  ch[0] = cmd & 0xff;
61  write(qcr_cmd,ch,1);
62  /* if (hpib_bus_status(qcr_raw,1) == 1) return(reset_qcr()); */
63  return(1); /* Assume success */
64 }
int qcr_cmd
Definition: qcr.c:16

Here is the caller graph for this function:

Variable Documentation

int qcr_cmd

Definition at line 16 of file qcr.c.

Referenced by close_qcr().

int qcr_data

Definition at line 16 of file qcr.c.

Referenced by close_qcr(), print_qcr_status(), and set_up_qcr_nc().

int qcr_raw

Definition at line 16 of file qcr.c.

Referenced by close_qcr(), qcr_wait_srq(), and reset_qcr().

unsigned char response[ 8192 ]

Definition at line 19 of file qcr.c.

Referenced by print_qcr_status().

short verbose_flag

Definition at line 17 of file qcr.c.

Referenced by print_qcr_status().