30 io_timeout_ctl(
qcr_raw, 90000000 );
32 if (hpib_status_wait(
qcr_raw, 1 ) == 0)
35 if ((status = hpib_spoll(
qcr_raw, 2 )) == -1)
37 fprintf(stderr,
"qcr.c: error during HPIB s-poll\n");
39 if ((status = hpib_spoll(
qcr_raw, 3 )) == -1)
41 fprintf(stderr,
"qcr.c: error during HPIB s-poll\n");
46 fprintf(stderr,
"qcr.c: HPIB timeout or error (no SRQ)\n");
81 fprintf(stderr,
" write_data: burst mode on failed %d\n");
84 if (stat != len) fprintf(stderr,
" write_data: stat %d != %d (len)\n",
90 fprintf(stderr,
" write_data: burst mode off failed %d\n");
113 if ((
qcr_cmd = open (
"/dev/qcrc", O_RDWR)) < 0)
115 fprintf(stderr,
"Recorder command dev not opened: error = %d\n",errno);
118 if ((
qcr_data = open (
"/dev/qcrd", O_RDWR)) < 0)
120 fprintf(stderr,
"Recorder data dev not opened: error = %d\n",errno);
124 if ((
qcr_raw = open (
"/dev/rhpib", O_RDWR)) < 0)
126 fprintf(stderr,
"/dev/rhpib not opened: error = %d\n",errno);
135 fprintf(stderr,
"Error reading response from QCR, errno = %d\n",errno);
141 fprintf(stderr,
"\n\n Matrix Camera Control, Version 0.1\n\n");
142 fprintf(stderr,
" matrix rev %s\n",
response);
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;
153 fprintf(stderr,
"Camera back: %s\n", command);
162 #define IS_ONE(resp_num, msg1, msg2) if (((int)response[resp_num + 1
]) == 1
)
163 printf(msg1); else printf(msg2);
171 printf(
"Got back %d status bytes\n", len);
175 printf(
"Status data (in hex):\n");
177 for (j = 0; j < 2; j++)
179 for (i = 0; i < 16; i++)
180 printf(
"%2X ", (
int) *rp++);
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");
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]);
202 printf(
"Image dimensions (horiz, vert): %d, %d\n",
203 (((
int) rp[10]) << 8) | rp[11],
204 (((
int) rp[6]) << 8) | rp[7] );
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");
216 printf(
"Resolution 2K\n");
219 printf(
"Resolution 4K\n");
222 printf(
"Weird resolution: %d\n", (
int) rp[18]);
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");
263 fprintf(stderr,
" Current resolution mode: %x\n",
response[18+1]);
272 printf(
"Resetting resolution to 4k, be patient.\n");
281 printf(
"Resetting resolution to 2k, be patient.\n");
304 int x_size, y_size, nslice, offset;
308 short scan_start, row_start;
309 unsigned char sizes[8];
312 if ((x_size > 2048) || (y_size > 1536))
323 scan_start = (y_size >> 1 ) - offset;
324 row_start = 0 - (x_size >> 1 );
327 fprintf(stderr,
"-- centering %d x %d image, at (%d,%d)\n",
328 x_size,y_size,row_start,scan_start);
330 sizes[0] = (
char) (row_start >> 8) & 0xff;
331 sizes[1] = (
char) row_start;
333 sizes[2] = (
char) (x_size >> 8) & 0xff;
334 sizes[3] = (
char) x_size;
336 sizes[4] = (
char) (scan_start >> 8) & 0xff;
337 sizes[5] = (
char) scan_start;
339 sizes[6] = (
char) (nslice >> 8) & 0xff;
340 sizes[7] = (
char) nslice;
356 unsigned char sizes[8];
366 xstart = xstart - (4096/2);
367 ystart = -ystart + (3072/2);
371 xstart = xstart - (2048/2);
372 ystart = -ystart + (1536/2);
375 sizes[0] = (
char) (xstart >> 8) & 0xff;
376 sizes[1] = (
char) xstart & 0xff;
378 sizes[2] = (
char) (xsize >> 8) & 0xff;
379 sizes[3] = (
char) xsize;
381 sizes[4] = (
char) (ystart >> 8) & 0xff;
382 sizes[5] = (
char) ystart;
384 sizes[6] = (
char) (ysize >> 8) & 0xff;
385 sizes[7] = (
char) ysize;
424 fprintf(stderr,
"send_pixel_image: unknown color %d\n",color);
break;
428 fprintf(stderr,
"send_pixel_image: %d bytes of %s... ",len,cl);
435 fprintf(stderr,
"%d bytes sent.\n",stat);
437 fprintf(stderr,
" Error sending %s, errno = %d.\n",cl,errno);
440 return (stat == len);
464 fprintf(stderr,
"send_rle_image: unknown color %d\n",color);
break;
468 fprintf(stderr,
"send_rle_image: %d bytes of %s... ",len,cl);
474 fprintf(stderr,
"%d bytes sent.\n",stat);
476 fprintf(stderr,
" Error sending %s, errno = %d.\n",cl,errno);
478 return (stat == len);
497 fprintf(stderr,
"send_3passrle_: %d bytes ... ",len);
503 fprintf(stderr,
"%d bytes sent.\n",stat);
505 fprintf(stderr,
" Error sending data, errno = %d.\n",errno);
507 return (stat == len);
533 fprintf(stderr,
" ** Reset QCR ** \n\n");
544 if ( read(
qcr_data, buf, BUFSIZ ) <= 0 )
546 perror(
"Error reading brightness table\n" );
557 if ( read(
qcr_data, buf, BUFSIZ ) <= 0 )
559 perror(
"Error reading brightness levels\n" );
566 unsigned char buf[1536];
576 if ( read(
qcr_data, buf, 1536 ) != 1536 )
578 perror(
"Error reading 12 bit LUTs\n" );
587 char select_lut = lut;
int init_qcr(short verbose)
unsigned char response[ 8192 ]
write_data(char *buff, int len)
#define IS_ONE(resp_num, msg1, msg2)
send_pixel_image(int color, char *buff, int len)
#define RETURN_BRIGHT_LEVELS
#define RETURN_BRIGHT_TABLE
int send_3pass_rle(unsigned char *buff, int len)
send_rle_image(int color, char *buff, int len)
set_up_qcr_nc(xstart, ystart, xsize, ysize, fourK)
set_up_qcr(int x_size, int y_size, int nslice, int offset)
int set_resolution(int fourK)