static int put_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *data, GPContext *context) { Camera *camera=data; const char *data_file; long unsigned int data_size; /* * Upload the file to the camera. Use gp_file_get_data_and_size, etc. */ GP_DEBUG ("*** put_file_func"); GP_DEBUG ("*** folder: %s", folder); GP_DEBUG ("*** filename: %s", filename); gp_file_get_data_and_size (file, &data_file, &data_size); if ( data_size == 0) { gp_context_error (context, _("The file to be uploaded has a null length")); return GP_ERROR_BAD_PARAMETERS; } /* Should check memory here */ /* if (available_memory < data_size) { gp_context_error (context, _("Not enough memory available on the memory card")); return GP_ERROR_NO_MEMORY; } */ tiger_upload_file (camera->pl, filename,data_file,data_size); return GP_OK; }
static int get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, void *data, GPContext *context) { Camera *camera = data; int n; struct jamcam_file *jc_file; GP_DEBUG ("* get_info_func"); GP_DEBUG ("*** folder: %s", folder); GP_DEBUG ("*** filename: %s",filename); /* Get the file number from the CameraFileSystem */ CHECK (n = gp_filesystem_number (camera->fs, folder, filename, context)); jc_file = jamcam_file_info( camera, n ); /* fixme, get file size also */ info->file.fields = GP_FILE_INFO_TYPE; strcpy (info->file.type, GP_MIME_PPM); info->file.width = jc_file->width; info->file.height = jc_file->height; info->preview.fields = GP_FILE_INFO_TYPE; strcpy (info->preview.type, GP_MIME_PPM); info->preview.width = 80; info->preview.height = 60; return (GP_OK); }
int lg_gsm_init (GPPort *port, Model *model, Info *info) { char firmware[54]; char oknok[6]; memset (oknok,0,6); memset (firmware,0,54); GP_DEBUG("Running lg_gsm_init\n"); port->timeout=20000; /* syncstart */ MSGWRITE(port, 0x13, 0x6, 0x0, "", 0); WRITE(port, sync_start, 6); READ(port, oknok, 6); /* getfirmware : write 0x010000000000 */ MSGWRITE(port, 0x13, 0x6, 0x0, "", 0); WRITE(port, get_firmware, 0x6); READ(port, firmware, 54); /* syncstop */ MSGWRITE(port, 0x13, 0x6, 0x0, "", 0); WRITE(port, sync_stop, 6); READ(port, oknok, 6); /* This information, too. */ memcpy (info, &firmware[6], 40); GP_DEBUG("info = %s\n", info); /*GP_DEBUG("info[20] = 0x%x\n", firmware[26]);*/ GP_DEBUG("Leaving lg_gsm_init\n"); return GP_OK; }
int camera_init(Camera *camera, GPContext *context) { GPPortSettings settings; CameraAbilities abilities; int ret = 0; /* First, set up all the function pointers */ camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->exit = camera_exit; GP_DEBUG ("Initializing the camera\n"); ret = gp_port_get_settings(camera->port,&settings); if (ret < 0) return ret; ret = gp_camera_get_abilities(camera,&abilities); if (ret < 0) return ret; GP_DEBUG("product number is 0x%x\n", abilities.usb_product); switch (camera->port->type) { case GP_PORT_SERIAL: return ( GP_ERROR ); case GP_PORT_USB: settings.usb.config = 1; settings.usb.altsetting = 0; settings.usb.interface = 1; settings.usb.inep = 0x84; settings.usb.outep =0x05; break; default: return ( GP_ERROR ); } ret = gp_port_set_settings(camera->port,settings); if (ret < 0) return ret; GP_DEBUG("interface = %i\n", settings.usb.interface); GP_DEBUG("inep = %x\n", settings.usb.inep); GP_DEBUG("outep = %x\n", settings.usb.outep); /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return GP_ERROR_NO_MEMORY; memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); switch(abilities.usb_product) { case 0x2130: camera->pl->model = AOX_MODEL_DMAX; break; default: camera->pl->model = AOX_MODEL_MINI; } /* Connect to the camera */ aox_init (camera->port, &camera->pl->model, camera->pl->info); return GP_OK; }
static int parse_fb_params(char *params, int *flags, const char **fb) { char *param; if (!params) return 0; do { param = params; params = next_param(params); if (!strcasecmp(param, "no_shadow")) { *flags &= ~GP_FB_SHADOW; GP_DEBUG(1, "Shadow framebuffer disabled"); continue; } if (!strcasecmp(param, "new_console")) { *flags |= GP_FB_ALLOC_CON; GP_DEBUG(1, "Console allocation enabled"); continue; } *fb = param; if (strncmp(*fb, "/dev/", 5)) GP_WARN("Console dev set to '%s', are you sure?", *fb); GP_DEBUG(1, "Framebuffer console set to '%s'", *fb); } while (params); return 0; }
static int get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *user_data, GPContext *context) { Camera *camera = user_data; int k; char *data; int len; k = gp_filesystem_number(camera->fs, "/", filename, context); switch (type) { case GP_FILE_TYPE_PREVIEW: return GP_ERROR_NOT_SUPPORTED; case GP_FILE_TYPE_NORMAL: len = lg_gsm_get_picture_size (camera->port, k); GP_DEBUG("len = %i\n", len); data = malloc(len); if (!data) { GP_DEBUG("malloc failed\n"); return GP_ERROR_NO_MEMORY; } lg_gsm_read_picture_data (camera->port, data, len, k); gp_file_append (file, data, len); free (data); break; default: return GP_ERROR_NOT_SUPPORTED; } return GP_OK; }
/* Seek to the current position */ static void seek_cur_pos(struct zip_priv *priv) { unsigned int cur_table = priv->cur_pos / ZIP_CHUNKS_IN_TABLE; unsigned int cur_pos; if (priv->cur_table_pos != cur_table) { unsigned int i; GP_DEBUG(3, "cur_pos %u out of cur table %u", priv->cur_pos, priv->cur_table_pos); priv->cur_table = &priv->table; for (i = 0; i < cur_table; i++) { if (priv->cur_table->next) priv->cur_table = priv->cur_table->next; else GP_WARN("The cur_pos points after last table"); } priv->cur_table_pos = cur_table; } //TODO: Asert that we are not in last table and cur_pos < table_used cur_pos = priv->cur_pos % ZIP_CHUNKS_IN_TABLE; GP_DEBUG(2, "Setting current position to %u (%li)", priv->cur_pos, priv->cur_table->offsets[cur_pos]); gp_io_seek(priv->io, priv->cur_table->offsets[cur_pos], GP_IO_SEEK_SET); }
gp_io *gp_io_mem(void *buf, size_t size, void (*free)(void *)) { gp_io *io; struct mem_io *mem_io; GP_DEBUG(1, "Creating IOMem %p size=%zu", buf, size); io = malloc(sizeof(gp_io) + sizeof(*mem_io)); if (!io) { GP_DEBUG(1, "Malloc failed :("); errno = ENOMEM; return NULL; } io->read = mem_read; io->seek = mem_seek; io->close = mem_close; io->write = NULL; mem_io = GP_IO_PRIV(io); mem_io->free = free; mem_io->buf = buf; mem_io->size = size; mem_io->pos = 0; return io; }
static int read_extensions(GifFileType *gf) { uint8_t *gif_ext_ptr; int gif_ext_type; //TODO: Should we free them? if (DGifGetExtension(gf, &gif_ext_type, &gif_ext_ptr) != GIF_OK) { GP_DEBUG(1, "DGifGetExtension() error %s (%i)", gif_err_name(gif_err(gf)), gif_err(gf)); return EIO; } GP_DEBUG(2, "Have GIF extension type %i (ignoring)", gif_ext_type); do { if (DGifGetExtensionNext(gf, &gif_ext_ptr) != GIF_OK) { GP_DEBUG(1, "DGifGetExtension() error %s (%i)", gif_err_name(gif_err(gf)), gif_err(gf)); return EIO; } } while (gif_ext_ptr != NULL); return 0; }
gp_io *gp_io_sub_io(gp_io *pio, size_t size) { gp_io *io; struct sub_io *sub_io; GP_DEBUG(1, "Creating SubIO (from %p) size=%zu", pio, size); io = malloc(sizeof(gp_io) + sizeof(*sub_io)); if (!io) { GP_DEBUG(1, "Malloc failed :("); errno = ENOMEM; return NULL; } io->read = sub_read; io->seek = sub_seek; io->close = sub_close; io->write = NULL; sub_io = GP_IO_PRIV(io); sub_io->cur = sub_io->start = gp_io_tell(pio); //TODO: Overflow sub_io->end = sub_io->start + size; sub_io->io = pio; return io; }
static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { if (type != GP_CAPTURE_IMAGE) return (GP_ERROR_NOT_SUPPORTED); if ( dimagev_shutter(camera->pl) < GP_OK ) { GP_DEBUG( "camera_capture::unable to open shutter"); return GP_ERROR_IO; } /* Now check how many pictures are taken, and return the last one. */ if ( dimagev_get_camera_status(camera->pl) != 0 ) { GP_DEBUG( "camera_capture::unable to get camera status"); return GP_ERROR_IO; } #if defined HAVE_SNPRINTF snprintf(path->folder, sizeof(path->folder), "/"); snprintf(path->name, sizeof(path->name), DIMAGEV_FILENAME_FMT, camera->pl->status->number_images); #else sprintf(path->folder, "/"); sprintf(path->name, DIMAGEV_FILENAME_FMT, camera->pl->status->number_images); #endif /* Tell the CameraFilesystem about this picture */ gp_filesystem_append (camera->fs, path->folder, path->name, context); return GP_OK; }
int camera_get_config_cam_desc (Camera *camera, CameraWidget **window, GPContext *context) { CameraWidget *section; int indw, indr; const CameraDescType *cam_desc = NULL; GP_DEBUG ("*** camera_get_config_cam_desc"); CHECK (camera_start (camera, context)); gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window); cam_desc = camera->pl->cam_desc; for (indw = 0; indw < 2 /* XXX sizeof () */; indw++) { GP_DEBUG ("%s registers", cam_desc->regset[indw].window_name); gp_widget_new (GP_WIDGET_SECTION, _(cam_desc->regset[indw].window_name), §ion); gp_widget_append (*window, section); for (indr = 0; indr < cam_desc->regset[indw].reg_cnt; indr++) { camera_cam_desc_get_widget (camera, &cam_desc->regset[indw].regs[indr], section, context); } } return (GP_OK); }
/* Download a live image from the camera and return it in a malloced buffer with PGM headers */ static uint8_t * Dimera_Preview( long *size, Camera *camera, GPContext *context ) { uint8_t buffer[VIEWFIND_SZ/2], *p; int i; uint8_t *image; uint32_t exposure_total; unsigned brightness; if ( !(image = (unsigned char *) malloc( VIEWFIND_SZ + sizeof( Dimera_viewhdr ) - 1 )) ) { ERROR( "Get Preview, allocation failed" ); gp_context_error (context, _("Out of memory")); return NULL; } /* set image size */ *size = VIEWFIND_SZ + sizeof( Dimera_viewhdr ) - 1; /* set image header */ memcpy( image, Dimera_viewhdr, sizeof( Dimera_viewhdr ) - 1 ); if ( mesa_snap_view( camera->port, buffer, TRUE, 0, 0, 0, camera->pl->exposure, VIEW_TYPE) < 0 ) { ERROR( "Get Preview, mesa_snap_view failed" ); free (image); gp_context_error (context, _("Problem taking live image")); return NULL; } /* copy the buffer, splitting the pixels up */ exposure_total = 0; for ( p = image + sizeof( Dimera_viewhdr ) - 1, i = 0; i < (VIEWFIND_SZ/2) ; i++ ) { *p++ = buffer[i] >> 4; *p++ = buffer[i] & 0xf; exposure_total += (buffer[i] >> 4) + (buffer[i] & 0xf); } /* Automatic exposure control */ /* Current picture brightness, where 0 is is dark and 255 is bright */ brightness = exposure_total / (VIEWFIND_SZ / 16); GP_DEBUG( "Average pixel brightness %f, Current exposure value: %d", brightness / 16.0, camera->pl->exposure); if (camera->pl->auto_exposure && (brightness < 96 || brightness > 160)) { /* Picture brightness needs to be corrected for next time */ camera->pl->exposure = calc_new_exposure(camera->pl->exposure, brightness); GP_DEBUG( "New exposure value: %d", camera->pl->exposure); } return image; }
gp_io *gp_io_file(const char *path, enum gp_io_file_mode mode) { int err, flags; gp_io *io; struct file_io *file_io; GP_DEBUG(1, "Creating IOFile '%s'", path); io = malloc(sizeof(gp_io) + sizeof(struct file_io)); if (!io) { GP_DEBUG(1, "Malloc failed :("); err = ENOMEM; goto err0; } switch (mode) { case GP_IO_WRONLY: flags = O_CREAT | O_WRONLY; break; case GP_IO_RDONLY: flags = O_RDONLY; break; case GP_IO_RDWR: flags = O_CREAT | O_RDWR; break; } file_io = GP_IO_PRIV(io); file_io->fd = open(path, flags, 0666); if (file_io->fd < 0) { err = errno; GP_DEBUG(1, "Failed to open '%s': %s", path, strerror(errno)); goto err1; } io->mark = 0; io->seek = file_seek; io->read = file_read; io->write = file_write; if (mode == GP_IO_RDONLY) io->write = NULL; if (mode == GP_IO_WRONLY) io->read = NULL; io->close = file_close; return io; err1: free(io); err0: errno = err; return NULL; }
int lg_gsm_list_files (GPPort *port, CameraList *list) { int num_pics; int i; char oknok[6]; char photonumber[22]; char photolist[142000]; /* max_photos * 142 */ char name[44]; char value[88]; memset (oknok,0,6); memset (photonumber,0,22); memset (photolist,0,142000); memset (name,0,44); memset (value,0,88); GP_DEBUG("Running lg_gsm_list_files\n"); /* set timeout to 3s */ /*port->timeout=20000;*/ /* syncstart */ MSGWRITE(port, 0x13, 0x6, 0x0, "", 0); WRITE(port, sync_start, 6); READ(port, oknok, 6); /* lsphoto : write 0x04000800000040000000ffffffff */ MSGWRITE(port, 0x13, 0xe, 0x0, "", 0); WRITE(port, list_all_photo, 0xe); READ(port, photonumber, 0x16); num_pics=photonumber[20]+256*photonumber[21]; /* increase timeout to 20s */ /*port->timeout=20000;*/ /* read 142 * nb_photos */ READ(port, photolist, 142*num_pics); for (i = 0; i < num_pics; i++){ /* sprintf( name, "lg_gsm_pic%03i.jpg", i ); */ memcpy(name,&photolist[6+142*i],44); memcpy(value,&photolist[50+142*i],80); gp_list_append(list, name, value); } /* restore timeout to 5s */ /*port->timeout=5000; */ /* syncstop */ MSGWRITE(port, 0x13, 0x6, 0x0, "", 0); WRITE(port, sync_stop, 6); READ(port, oknok, 6); /*port->timeout=5000;*/ GP_DEBUG("Number of pics : %03i\n", num_pics); GP_DEBUG("Leaving lg_gsm_list_files\n"); return GP_OK; }
/* * l859_connect - try hand shake with camera and establish connection */ static int l859_connect(Camera *camera) { GPPortSettings settings; uint8_t bps; int ret; GP_DEBUG ("Connecting to a camera."); ret = l859_sendcmd(camera, L859_CMD_CONNECT); if (ret < GP_OK) return ret; if (l859_retrcmd(camera) == GP_ERROR) { if (l859_sendcmd(camera, L859_CMD_RESET) != GP_OK) return GP_ERROR; if (l859_sendcmd(camera, L859_CMD_CONNECT)!= GP_OK) return GP_ERROR; if (l859_retrcmd(camera) == GP_ERROR) return GP_ERROR; } switch (camera->pl->speed) { case 19200: bps = L859_CMD_SPEED_19200; break; case 57600: bps = L859_CMD_SPEED_57600; break; case 115200: bps = L859_CMD_SPEED_115200; break; default: bps = L859_CMD_SPEED_DEFAULT; break; } if (bps != L859_CMD_SPEED_DEFAULT) { if (l859_sendcmd(camera, bps) != GP_OK) return GP_ERROR; gp_port_get_settings(camera->port, &settings); settings.serial.speed = camera->pl->speed; gp_port_set_settings(camera->port, settings); if (l859_retrcmd(camera) == GP_ERROR) return GP_ERROR; } if (l859_sendcmd(camera, L859_CMD_INIT) != GP_OK) return GP_ERROR; if (l859_retrcmd(camera) == GP_ERROR) return GP_ERROR; GP_DEBUG ("Camera connected successfully."); return GP_OK; }
static int pre_func (Camera *camera, GPContext *context) { int r; unsigned int i; GPPortSettings settings; GP_DEBUG ("Initializing connection..."); CR (gp_port_get_settings (camera->port, &settings)); CR (fuji_ping (camera, context)); if (!camera->pl->speed) { /* Set to the highest possible speed. */ for (i = 0; Speeds[i].bit_rate; i++) { r = fuji_set_speed (camera, Speeds[i].speed, NULL); if (r >= 0) break; } /* * Change the port's speed and check if the camera is * still there. */ settings.serial.speed = Speeds[i].bit_rate; CR (gp_port_set_settings (camera->port, settings)); GP_DEBUG("Pinging to check new speed %i.", Speeds[i].bit_rate); CR (fuji_ping (camera, context)); } else { /* User specified a speed. Check if the speed is possible */ for (i = 0; Speeds[i].bit_rate; i++) if (Speeds[i].bit_rate == camera->pl->speed) break; if (!Speeds[i].bit_rate) { gp_context_error (context, _("Bit rate %ld is not " "supported."), camera->pl->speed); return (GP_ERROR_NOT_SUPPORTED); } /* Change the speed if necessary. */ if (camera->pl->speed != Speeds[i].bit_rate) { CR (fuji_set_speed (camera, Speeds[i].speed, context)); /* * Change the port's speed and check if the camera is * still there. */ settings.serial.speed = Speeds[i].bit_rate; CR (gp_port_set_settings (camera->port, settings)); CR (fuji_ping (camera, context)); } } return (GP_OK); }
static int zip_load_header(gp_io *io, struct zip_local_header *header) { int ret; uint8_t byte; uint16_t zip_header[] = { 'P', 'K', GP_IO_BYTE, GP_IO_END }; if (gp_io_readf(io, zip_header, &byte) != 3) { GP_DEBUG(1, "Failed to read header"); return EIO; } switch (byte) { /* Central directory -> end of archive */ case 0x01: GP_DEBUG(1, "Reached end of the archive"); return EINVAL; break; /* File header */ case 0x03: break; default: GP_DEBUG(1, "Unexpected header PK%x", byte); return EIO; } uint16_t zip_local_header[] = { 0x04, GP_IO_L2, /* version */ GP_IO_L2, /* bit flags */ GP_IO_L2, /* compression type */ GP_IO_IGN | 4, GP_IO_L4, /* CRC */ GP_IO_L4, /* compressed size */ GP_IO_L4, /* uncompressed size */ GP_IO_L2, /* filename length */ GP_IO_L2, /* extra fields lenght */ GP_IO_END }; ret = gp_io_readf(io, zip_local_header, &header->ver, &header->flags, &header->comp_type, &header->crc, &header->comp_size, &header->uncomp_size, &header->fname_len, &header->extf_len); if (ret != 10) { GP_DEBUG(1, "Failed to read header"); return EIO; } return 0; }
int jl2005c_get_pic_data_size (CameraPrivateLibrary *priv, Info *table, int n) { int size; GP_DEBUG("table[16 * n + 7] = %02X\n", table[16 * n + 7]); size = table[0x10 * n + 6] * 0x100 | table[0x10 * n + 7]; size *= priv->blocksize; GP_DEBUG("size = 0x%x = %d\n", size, size); return (size); }
static int parse_x11_params(char *params, GP_Size *w, GP_Size *h, enum GP_BackendX11Flags *flags) { char *param; if (!params) return 0; do { param = params; params = next_param(params); if (!strcasecmp(param, "use_root")) { *flags |= GP_X11_USE_ROOT_WIN; GP_DEBUG(1, "X11: Using root window"); continue; } if (!strcasecmp(param, "create_root")) { *flags |= GP_X11_CREATE_ROOT_WIN; GP_DEBUG(1, "X11: Creating root window"); continue; } if (!strcasecmp(param, "disable_shm")) { *flags |= GP_X11_DISABLE_SHM; GP_DEBUG(1, "X11: Disabling SHM"); continue; } if (!strcasecmp(param, "fs")) { *flags |= GP_X11_FULLSCREEN; GP_DEBUG(1, "X11: Enabling fullscreen"); continue; } /* * Accepts only string with format "intxint" or "intXint" */ int sw, sh; unsigned int n; if (sscanf(param, "%i%*[xX]%i%n", &sw, &sh, &n) == 2 && n == strlen(param)) { *w = sw; *h = sh; continue; } GP_WARN("X11: Invalid parameters '%s'", param); errno = EINVAL; return 1; } while (params); return 0; }
int camera_init(Camera *camera, GPContext *context) { GPPortSettings settings; int ret = 0; /* First, set up all the function pointers */ camera->functions->manual = camera_manual; camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->exit = camera_exit; GP_DEBUG ("Initializing the camera\n"); ret = gp_port_get_settings(camera->port,&settings); if (ret < 0) return ret; switch (camera->port->type) { case GP_PORT_SERIAL: return ( GP_ERROR ); case GP_PORT_USB: settings.usb.config = 1; settings.usb.altsetting = 0; settings.usb.interface = 0; /* inep 0x84 used to initialize. Then switch to 0x82! */ settings.usb.inep = 0x84; settings.usb.outep = 0x03; break; default: return ( GP_ERROR ); } ret = gp_port_set_settings(camera->port,settings); if (ret < 0) return ret; GP_DEBUG("interface = %i\n", settings.usb.interface); GP_DEBUG("inep = %x\n", settings.usb.inep); GP_DEBUG("outep = %x\n", settings.usb.outep); /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return GP_ERROR_NO_MEMORY; memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); /* Connect to the camera */ camera->pl->total_data_in_camera=0; camera->pl->data_to_read = 0; camera->pl->bytes_put_away = 0; camera->pl->data_reg_opened = 0; camera->pl->data_cache = NULL; camera->pl->init_done = 0; jl2005c_init (camera,camera->port, camera->pl); return GP_OK; }
/* * function added for the D-Link DSC 350F - written by Mark Slemko - [email protected] * This function correctly adjusts the color and orientation of the image */ int dlink_dsc350f_postprocessing_and_flip_both (int width, int height, unsigned char* rgb) { unsigned char *start, *end, c; int whichcolor = 0; int lowred=255, lowgreen=255, lowblue=255; int hired=0, higreen=0, hiblue=0; GP_DEBUG("flipping byte order"); /* flip image left/right and top/bottom (actually reverse byte order) */ start = rgb; end = start + ((width * height) * 3); while (start < end) { c = *start; /* validation - debugging info - collect the color range info * for first half of image. */ switch (whichcolor % 3) { case 0: // blue MINMAX((int)c,lowblue,hiblue); break; case 1: // green MINMAX((int)c,lowgreen,higreen); break; default: // red MINMAX((int)c,lowred,hired); break; } /* adjust color magnitude, since it appears that the 350f only had 7 bits of color info */ *start++ = *--end << 1; *end = c << 1; whichcolor++; } /* // could do more color processing here GP_DEBUG("adjusting color"); // adjust image colours start = rgb; end = start + ((width * height) * 3); while (start < end) { c = *start++; } */ /* show the color range of image in debug mode. */ GP_DEBUG("\nred low = %d high = %d\ngreen low = %d high = %d\nblue low = %d high = %d\n", lowred,hired, lowgreen,higreen, lowblue,hiblue); return GP_OK; }
static void print_flags(struct zip_local_header *header) { if (header->flags & FLAG_ENCRYPTED) GP_DEBUG(2, "File is encrypted"); if (header->flags & FLAG_DATA_DESC_HEADER) GP_DEBUG(2, "File size and CRC are after compressed data"); if (header->flags & FLAG_UTF8) GP_DEBUG(2, "Filename and comment are encoded in UTF-8"); }
void gp_filter_tables_free(gp_filter_tables *self) { GP_DEBUG(1, "Freeing point filter and tables (%p)", self); free_tables(self); if (self->free_table) { GP_DEBUG(2, "Freeing table itself"); free(self); } }
void GP_FilterTablesFree(GP_FilterTables *self) { GP_DEBUG(1, "Freeing point filter and tables (%p)", self); free_tables(self); if (self->free_table) { GP_DEBUG(2, "Freeing table itself"); free(self); } }
static int get_path_for_id_rec (GPParams *p, const char *base_folder, unsigned int id, unsigned int *base_id, char *folder, char *filename) { char subfolder[1024]; int n_folders, n_files, r; unsigned int i; const char *name; CameraList *list; strncpy (folder, base_folder, MAX_FOLDER_LEN); CR (gp_list_new(&list)); CL (gp_camera_folder_list_files (p->camera, base_folder, list, p->context), list); CL (n_files = gp_list_count (list), list); if (id - *base_id < (unsigned int) n_files) { /* ID is in this folder */ GP_DEBUG ("ID %i is in folder '%s'.", id, base_folder); CL (gp_list_get_name (list, id - *base_id, &name), list); strncpy (filename, name, MAX_FILE_LEN); gp_list_free (list); return (GP_OK); } else { /* Look for IDs in subfolders */ GP_DEBUG ("ID %i is not in folder '%s'.", id, base_folder); *base_id += n_files; CL (gp_camera_folder_list_folders (p->camera, base_folder, list, p->context), list); CL (n_folders = gp_list_count (list), list); for (i = 0; i < (unsigned int)n_folders; i++) { CL (gp_list_get_name (list, i, &name), list); strncpy (subfolder, base_folder, sizeof (subfolder)); if (strlen (base_folder) > 1) strncat (subfolder, "/", sizeof (subfolder) - strlen(subfolder) - 1); strncat (subfolder, name, sizeof (subfolder) - strlen(subfolder) - 1); r = get_path_for_id_rec (p, subfolder, id, base_id, folder, filename); switch (r) { case GP_ERROR_FRONTEND_BAD_ID: break; default: gp_list_free (list); return (r); } } gp_list_free (list); return (GP_ERROR_FRONTEND_BAD_ID); } }
int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; unsigned int i; /* Setup all function pointers */ camera->functions->pre_func = pre_func; camera->functions->post_func = post_func; camera->functions->about = camera_about; camera->functions->exit = camera_exit; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; camera->functions->summary = camera_summary; /* We need to store some data */ camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return (GP_ERROR_NO_MEMORY); memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); /* Set up the port, but remember the current speed. */ CR (gp_port_set_timeout (camera->port, 1000)); CR (gp_port_get_settings (camera->port, &settings)); camera->pl->speed = settings.serial.speed; settings.serial.speed = 9600; settings.serial.bits = 8; settings.serial.parity = GP_PORT_SERIAL_PARITY_EVEN; settings.serial.stopbits = 1; CR (gp_port_set_settings (camera->port, settings)); /* Set up the filesystem. */ CR (gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); /* Initialize the connection */ CR (pre_func (camera, context)); /* * What commands does this camera support? The question is not * easy to answer, as "One issue the DS7 has is that the * supported command list command is not supported" * (Matt Martin <*****@*****.**>). */ if (fuji_get_cmds (camera, camera->pl->cmds, context) >= 0) { GP_DEBUG ("Your camera supports the following command(s):"); for (i = 0; i < 0xff; i++) if (camera->pl->cmds[i]) GP_DEBUG (" - 0x%02x: '%s'", i, cmd_get_name (i)); } return (GP_OK); }
/* * l859_disconnect - reset camera, free buffers and close files */ static int l859_disconnect(Camera *camera) { GP_DEBUG ("Disconnecting the camera."); if (l859_sendcmd(camera, L859_CMD_RESET) != GP_OK) return GP_ERROR; if (gp_port_read(camera->port, camera->pl->buf, 1) == GP_ERROR) return GP_ERROR; GP_DEBUG ("Camera disconnected."); return GP_OK; }
int camera_init(Camera *camera, GPContext *context) { GPPortSettings settings; int ret = 0; /* First, set up all the function pointers */ camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->exit = camera_exit; GP_DEBUG ("Initializing the camera\n"); ret = gp_port_get_settings(camera->port,&settings); if (ret < 0) return ret; switch (camera->port->type) { case GP_PORT_SERIAL: return GP_ERROR; case GP_PORT_USB: settings.usb.config = 1; settings.usb.altsetting = 0; settings.usb.interface = 1; settings.usb.inep = 0x81; settings.usb.outep =0x02; break; default: return GP_ERROR; } ret = gp_port_set_settings(camera->port,settings); if (ret < 0) return ret; GP_DEBUG("interface = %i\n", settings.usb.interface); GP_DEBUG("inep = %x\n", settings.usb.inep); GP_DEBUG("outep = %x\n", settings.usb.outep); /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return GP_ERROR_NO_MEMORY; memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); /* Connect to the camera */ lg_gsm_init (camera->port, &camera->pl->model, camera->pl->info); return GP_OK; }
static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { Camera *camera = data; int count; GP_DEBUG ("* file_list_func"); GP_DEBUG ("*** folder: %s", folder); CHECK (count = jamcam_file_count (camera)); CHECK (gp_list_populate (list, "pic_%04i.ppm", count)); return (GP_OK); }