int camera_init (Camera *camera, GPContext *context) { char *curloc; /* First, set up all the function pointers */ camera->functions->get_config = camera_config_get; camera->functions->set_config = camera_config_set; camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->exit = camera_exit; /* Now, tell the filesystem where to get lists, files and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_port_set_timeout (camera->port, TF_PROTOCOL_TIMEOUT); gp_port_usb_clear_halt (camera->port, GP_PORT_USB_ENDPOINT_IN); camera->pl = calloc (sizeof (CameraPrivateLibrary),1); if (!camera->pl) return GP_ERROR_NO_MEMORY; #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H) curloc = nl_langinfo (CODESET); if (!curloc) curloc="UTF-8"; cd_latin1_to_locale = iconv_open(curloc, "iso-8859-1"); if (!cd_latin1_to_locale) return GP_ERROR_NO_MEMORY; cd_locale_to_latin1 = iconv_open("iso-8859-1", curloc); if (!cd_locale_to_latin1) return GP_ERROR_NO_MEMORY; #endif do_cmd_ready (camera, context); return GP_OK; }
/* * OK, lets get serious ! */ int camera_init(Camera *camera,GPContext *context) { GPPortSettings settings; CameraAbilities abilities; /* try to contact the camera ...*/ /*CR(gp_port_get_settings(camera->port,&settings));*/ camera->functions->about=camera_about; camera->functions->exit=camera_exit; gp_port_get_settings(camera->port,&settings); if (camera->port->type!=GP_PORT_USB) { gp_context_error(context,_("sx330z is USB only")); return(GP_ERROR_UNKNOWN_PORT); } /* GP_DEBUG("camera_init : in = %x",camera->port->settings.usb.inep);*/ CR(gp_port_set_settings(camera->port,settings)); CR(gp_port_set_timeout(camera->port,TIMEOUT)); CR(gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera)); camera->pl=malloc(sizeof(CameraPrivateLibrary)); if (!camera->pl) return(GP_ERROR_NO_MEMORY); CR(gp_camera_get_abilities(camera, &abilities)); camera->pl->usb_product=abilities.usb_product; /* some models differ in Thumbnail size */ /* GP_DEBUG("sx330z Camera_init : sx init %04x",camera->pl->usb_product); */ return(sx330z_init(camera,context)); } /* camera init */
int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; /* First, set up all the function pointers */ camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->capture_preview = camera_capture_preview; camera->functions->capture = camera_capture; gp_port_get_settings(camera->port, &settings); switch(camera->port->type) { case GP_PORT_SERIAL: gp_port_set_timeout(camera->port, 1000); settings.serial.speed = 115200; settings.serial.bits = 8; settings.serial.parity = 0; settings.serial.stopbits = 1; break; case GP_PORT_USB: /* Use the defaults the core parsed */ break; default: return (GP_ERROR_UNKNOWN_PORT); break; } gp_port_set_settings(camera->port, settings); /* Set up the filesystem */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); /* test camera */ return stv0680_ping(camera->port); }
int camera_init(Camera *camera, GPContext *context){ GPPortSettings settings; int ret = 0; camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->about = camera_about; gp_log (GP_LOG_DEBUG, "pccam", "Initializing the camera\n"); switch (camera->port->type) { case GP_PORT_USB: ret = gp_port_get_settings(camera->port,&settings); if (ret < 0) return ret; settings.usb.inep = 0x82; settings.usb.outep = 0x03; settings.usb.config = 1; settings.usb.interface = 1; settings.usb.altsetting = 0; ret=gp_port_set_settings(camera->port,settings); if (ret<0) return ret; break; case GP_PORT_SERIAL: return GP_ERROR_IO_SUPPORTED_SERIAL; default: return GP_ERROR_NOT_SUPPORTED; } ret = pccam600_init(camera->port, context); if (ret < 0) return ret; return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); }
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; }
/** * Initialises camera */ int camera_init(Camera * camera, GPContext *context) { int rc; SonyModel model; rc = get_camera_model(camera, &model); if (rc != GP_OK) return rc; camera->functions->exit = camera_exit; camera->functions->about = camera_about; gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return (GP_ERROR_NO_MEMORY); rc = sony_init (camera, model); if (rc < 0) { free (camera->pl); camera->pl = NULL; return (rc); } return (GP_OK); }
int camera_init (Camera *camera, GPContext *context) { /* First, set up all the function pointers */ /* camera->functions->exit = camera_exit; */ camera->functions->get_config = camera_config_get; camera->functions->set_config = camera_config_set; camera->functions->capture = camera_capture; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists, files and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); /* Configure port */ gp_port_set_timeout(camera->port,MDC800_DEFAULT_COMMAND_RETRY_DELAY); if (camera->port->type == GP_PORT_SERIAL) { GPPortSettings settings; gp_port_get_settings(camera->port, &settings); settings.serial.speed = 57600; settings.serial.bits = 8; settings.serial.parity = 0; settings.serial.stopbits= 1; gp_port_set_settings(camera->port, settings); } return mdc800_openCamera(camera); }
int camera_init (Camera *camera, GPContext *context) { int ret; camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return (GP_ERROR_NO_MEMORY); /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->manual = camera_manual; camera->functions->about = camera_about; /* Set up the CameraFilesystem */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); /* initialize the camera */ ret = init (camera); if (ret < 0) { free (camera->pl); camera->pl = NULL; return (ret); } ret = dc3200_keep_alive (camera); if (ret < 0) { free (camera->pl); camera->pl = NULL; return (ret); } camera->pl->context = NULL; return (GP_OK); }
int camera_init (Camera *camera, GPContext *context) { /* First, set up all the function pointers */ camera->functions->manual = camera_manual; camera->functions->about = camera_about; return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); }
int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; int speeds[] = { 115200, 9600, 19200, 38400, 57600, 115200 }; int ret, i; char cmd[3], buf[1]; /* First, set up all the function pointers. */ camera->functions->capture = camera_capture; camera->functions->about = camera_about; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; /* Now, tell the filesystem where to get lists, files and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); /* * The port is already provided with camera->port (and * already open). You just have to use functions like * gp_port_timeout_set, gp_port_settings_get, gp_port_settings_set. */ gp_port_get_settings (camera->port, &settings); settings.serial.speed = 115200; settings.serial.bits = 8; settings.serial.stopbits= 1; settings.serial.parity = 0; gp_port_set_settings (camera->port, settings); /* * Once you have configured the port, you should check if a * connection to the camera can be established. */ for (i=0;i<sizeof(speeds)/sizeof(speeds[0]);i++) { gp_port_get_settings (camera->port, &settings); settings.serial.speed = speeds[i]; gp_port_set_settings (camera->port, settings); if (GP_OK<=k_ping (camera->port)) break; } if (i == sizeof(speeds)/sizeof(speeds[0])) return GP_ERROR; cmd[0] = ESC; cmd[1] = SETSPEED; cmd[2] = 0x30 + 4; /* speed nr 4:(9600, 19200, 38400, 57600, 115200) */ ret = gp_port_write (camera->port, cmd, 3); if (ret<GP_OK) return ret; ret = gp_port_read (camera->port, buf, 1); if (ret<GP_OK) return ret; if (buf[0] != ACK) return GP_ERROR; gp_port_get_settings (camera->port, &settings); settings.serial.speed = 115200; gp_port_set_settings (camera->port, settings); return GP_OK; }
int camera_init (Camera *camera, GPContext *context) { CameraAbilities a; int ret; char *dump, buf[256]; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = calloc (1, sizeof(CameraPrivateLibrary)); if (!camera->pl) return GP_ERROR_NO_MEMORY; ret = gp_setting_get("tp6801", "syncdatetime", buf); if (ret == GP_OK) camera->pl->syncdatetime = buf[0] == '1'; else camera->pl->syncdatetime = 1; CHECK (gp_camera_get_abilities(camera, &a)) dump = getenv("GP_TP6801_DUMP"); if (dump) ret = tp6801_open_dump (camera, dump); else ret = tp6801_open_device (camera); if (ret != GP_OK) { camera_exit (camera, context); return ret; } if (camera->pl->syncdatetime) { struct tm tm; time_t t; t = time (NULL); if (localtime_r (&t , &tm)) { ret = tp6801_set_time_and_date (camera, &tm); if (ret != GP_OK) { camera_exit (camera, context); return ret; } } } return GP_OK; }
int camera_init (Camera *camera, GPContext *context) { /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists, files and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); return pdrm11_init(camera->port); }
int camera_init (Camera *camera, GPContext *context) { CameraAbilities cab; up_badge_type badge; camera->functions->exit = camera_exit; camera->functions->about = camera_about; gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); badge = BADGE_UNKNOWN; gp_camera_get_abilities(camera, &cab); switch (cab.usb_vendor) { case USB_VENDOR_ID_SMAL: case USB_VENDOR_ID_CREATIVE: switch (cab.usb_product) { case USB_DEVICE_ID_ULTRAPOCKET: /* could be an axia eyeplate or a slimshot * figure it out later, when we get the image * catalogue. */ badge = BADGE_GENERIC; break; case USB_DEVICE_ID_FLATFOTO: badge = BADGE_FLATFOTO; break; case USB_DEVICE_ID_CARDCAM: badge = BADGE_CARDCAM; break; default: break; } break; case USB_VENDOR_ID_LOGITECH: switch (cab.usb_product) { case USB_DEVICE_ID_POCKETDIGITAL: badge = BADGE_LOGITECH_PD; break; default: break; } break; default: break; } if (badge == BADGE_UNKNOWN) { /* can't happen. Otherwise, how'd we get to camera_init, neh? */ return GP_ERROR; } camera->pl = malloc (sizeof (CameraPrivateLibrary)); camera->pl->up_type = badge; /* don't need to do any exciting init stuff until we get pic numbers */ return GP_OK; }
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; }
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); }
int camera_init (Camera *camera, GPContext *context) { int ret; GPPortSettings settings; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->about = camera_about; CHECK (gp_port_get_settings (camera->port, &settings)); switch (camera->port->type) { case GP_PORT_USB: settings.usb.inep = 0x82; settings.usb.outep = 0x03; settings.usb.config = 1; settings.usb.interface = 0; settings.usb.altsetting = 0; CHECK (gp_port_set_settings (camera->port, settings)); CHECK (gp_port_set_timeout (camera->port, TIMEOUT)); break; default: gp_context_error (context, _("Unsupported port type: %d. " "This driver only works with USB " "cameras.\n"), camera->port->type); return (GP_ERROR); break; } camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return (GP_ERROR_NO_MEMORY); memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); camera->pl->gpdev = camera->port; camera->pl->dirty = 1; ret = gsmart300_reset (camera->pl); if (ret < 0) { gp_context_error (context, _("Could not reset camera.\n")); free (camera->pl); camera->pl = NULL; return (ret); } /* Set up the CameraFilesystem */ return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); }
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; }
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->manual = camera_manual; 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.inep = 0x82; settings.usb.outep =0x03; break; default: return ( GP_ERROR ); } ret = gp_port_set_settings(camera->port,settings); if (ret < 0) return ret; /* 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; camera->pl->catalog = NULL; camera->pl->num_pics = 0; /* Connect to the camera */ ret = clicksmart_init (camera->port, camera->pl); if (ret != GP_OK) { free(camera->pl); return ret; }; return GP_OK; }
int camera_init (Camera *camera, GPContext *context) { int count; GPPortSettings settings; GP_DEBUG ("* camera_init"); GP_DEBUG (" * jamcam library for Gphoto2 by Chris Pinkham <*****@*****.**>"); GP_DEBUG (" * jamcam library v%s, %s", JAMCAM_VERSION, JAMCAM_LAST_MOD ); /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->about = camera_about; CHECK (gp_port_get_settings (camera->port, &settings)); switch( camera->port->type ) { case GP_PORT_SERIAL: settings.serial.speed = 57600; settings.serial.bits = 8; settings.serial.parity = 0; settings.serial.stopbits = 1; break; case GP_PORT_USB: /* Use the defaults the core parsed */ break; default: fprintf( stderr, "Unknown port type: %d\n", camera->port->type ); return ( GP_ERROR ); break; } CHECK (gp_port_set_settings (camera->port, settings)); CHECK (gp_port_set_timeout (camera->port, TIMEOUT)); /* check to see if camera is really there */ CHECK (jamcam_enq (camera)); /* get number of images */ CHECK (count = jamcam_file_count (camera)); /* Set up the CameraFilesystem */ return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); }
int camera_init (Camera *camera, GPContext *context) { DC210_DEBUG("Initialising camera.\n"); /* First, set up all the function pointers */ camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; camera->functions->capture = camera_capture; camera->functions->capture_preview = camera_capture_preview; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); if (dc210_init_port (camera) == GP_ERROR) return GP_ERROR; if (dc210_open_card (camera) == GP_ERROR) return GP_ERROR; return (GP_OK); }
int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; camera->functions->about = enigma13_about; CHECK(gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); CHECK(gp_port_get_settings( camera->port, &settings)); settings.usb.inep = 0x82; settings.usb.outep = 0x03; settings.usb.config = 1; settings.usb.interface = 0; settings.usb.altsetting = 0; CHECK(gp_port_set_timeout (camera->port, ENIGMA13_USB_TIMEOUT_MS)); CHECK(gp_port_set_settings( camera->port, settings)); 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->manual = camera_manual; camera->functions->about = camera_about; camera->functions->capture_preview = camera_capture_preview; 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_port_set_settings(camera->port,settings); if (ret < 0) return ret; /* 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; camera->pl->model = 0; camera->pl->catalog = NULL; camera->pl->nb_entries = 0; camera->pl->last_fetched_entry = -1; camera->pl->last_fetched_data = NULL; /* Connect to the camera */ ret = sq_init (camera->port, camera->pl); if (ret != GP_OK) { free(camera->pl); return ret; }; return GP_OK; }
int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; int speed; /* First, set up all the function pointers */ camera->functions->capture = camera_capture; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); /* Configure the port (remember the speed) */ gp_port_get_settings (camera->port, &settings); speed = settings.serial.speed; settings.serial.speed = 9600; settings.serial.bits = 8; settings.serial.parity = 0; settings.serial.stopbits = 1; gp_port_set_settings (camera->port, settings); gp_port_set_timeout (camera->port, TIMEOUT); /* Reset the camera to 9600 */ gp_port_send_break (camera->port, 2); /* Wait for it to update */ GP_SYSTEM_SLEEP(1500); if (dc120_set_speed (camera, speed) == GP_ERROR) { return (GP_ERROR); } /* Try to talk after speed change */ if (dc120_get_status(camera, NULL, context) == GP_ERROR) { return (GP_ERROR); } return (GP_OK); }
int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; /* First, set up all the function pointers */ camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); /* Some settings */ CHECK_RESULT (gp_port_get_settings (camera->port, &settings)); settings.serial.speed = 115200; settings.serial.bits = 8; settings.serial.parity = 0; settings.serial.stopbits= 1; CHECK_RESULT (gp_port_set_settings (camera->port, settings)); CHECK_RESULT (gp_port_set_timeout (camera->port, SDSC_TIMEOUT)); /* Open the port and check if the camera is there */ CHECK_RESULT (SDSC_initialize (camera->port)); return (GP_OK); }
int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; int ret; /* First, set up all the function pointers */ camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->capture_preview = camera_capture_preview; camera->functions->capture = camera_capture; gp_port_get_settings(camera->port, &settings); switch(camera->port->type) { case GP_PORT_USB: /* Modify the default settings the core parsed */ settings.usb.altsetting=1;/* we need to use interface 0 setting 1 */ settings.usb.inep=2; settings.usb.intep=3; settings.usb.outep=5; /* Use the defaults the core parsed */ break; default: return (GP_ERROR_UNKNOWN_PORT); break; } ret = gp_port_set_settings (camera->port, settings); if (ret != GP_OK) { gp_context_error (context, _("Could not apply USB settings")); return ret; } /* Set up the filesystem */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); /* test camera */ return stv0674_ping(camera->port); }
int camera_init (Camera *camera, GPContext *context) { int ret; GPPortSettings settings; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; /* Allocate memory for a read/write buffer */ camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return (GP_ERROR_NO_MEMORY); gp_port_set_timeout (camera->port, 2000); gp_port_get_settings(camera->port, &settings); camera->pl->speed = settings.serial.speed; settings.serial.speed = 9600; /* hand shake speed */ settings.serial.bits = 8; settings.serial.parity = 0; settings.serial.stopbits = 1; gp_port_set_settings(camera->port, settings); /* Set up the filesystem */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); ret = l859_connect (camera); if (ret < 0) { free (camera->pl); camera->pl = NULL; } return (ret); }
int camera_init (Camera *camera, GPContext *context) { int ret = 0; int x = 0; char *model; GPPortSettings settings; CameraAbilities abilities; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->capture = camera_capture; CHECK (gp_port_get_settings (camera->port, &settings)); switch (camera->port->type) { case GP_PORT_USB: settings.usb.inep = 0x82; settings.usb.outep = 0x03; settings.usb.config = 1; settings.usb.interface = 0; settings.usb.altsetting = 0; CHECK (gp_port_set_settings (camera->port, settings)); CHECK (gp_port_set_timeout (camera->port, TIMEOUT)); break; default: gp_context_error (context, _("Unsupported port type: %d. " "This driver only works with USB " "cameras.\n"), camera->port->type); return (GP_ERROR); break; } camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return (GP_ERROR_NO_MEMORY); memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); camera->pl->gpdev = camera->port; camera->pl->dirty_sdram = 1; camera->pl->dirty_flash = 1; /* What bridge chip is inside the camera? The gsmart mini is spca500 * based, while the others have a spca50xa */ gp_camera_get_abilities (camera, &abilities); model = models[x].model; while (model) { if (abilities.usb_vendor == models[x].usb_vendor && abilities.usb_product == models[x].usb_product) { int same; char *m = strdup( models[x].model ); char *p = strchr (m, ':' ); if (p) *p = ' '; same = !strcmp (m, abilities.model); free (m); if (same) { camera->pl->bridge = models[x].bridge; camera->pl->storage_media_mask = models[x].storage_media_mask; break; } } model = models[++x].model; } CHECK (spca50x_get_firmware_revision (camera->pl)); if (camera->pl->fw_rev > 1) { CHECK (spca50x_detect_storage_type (camera->pl)); } if (cam_has_flash(camera->pl) || cam_has_card(camera->pl) ) { if ((camera->pl->bridge == BRIDGE_SPCA504) || (camera->pl->bridge == BRIDGE_SPCA504B_PD)) CHECK (spca50x_flash_init (camera->pl, context)); } if ((camera->pl->bridge == BRIDGE_SPCA504) || (camera->pl->bridge == BRIDGE_SPCA504B_PD)) { /* if (abilities.usb_vendor != 0x04fc && abilities.usb_product != 0x504a ) */ if (!(abilities.usb_vendor == 0x04fc && abilities.usb_product == 0x504a )) ret = spca50x_reset (camera->pl); } if (ret < 0) { gp_context_error (context, _("Could not reset camera.\n")); free (camera->pl); camera->pl = NULL; return (ret); } /* Set up the CameraFilesystem */ return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); }
int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; int ret, selected_speed; char buf[1024]; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->capture = camera_capture; camera->functions->capture_preview = camera_capture_preview; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; /* Get the settings and remember the selected speed */ gp_port_get_settings (camera->port, &settings); selected_speed = settings.serial.speed; /* TODO: camera->pl can probably be allocated at the end to simplify */ camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) { gp_context_error (context, _("Out of memory")); return (GP_ERROR_NO_MEMORY); } /* Set the default exposure */ if (gp_setting_get ("dimera3500", "exposure", buf) == GP_OK) camera->pl->exposure = atoi(buf); else camera->pl->exposure = DEFAULT_EXPOSURE; /* Set automatic exposure enable setting for capture preview mode */ if (gp_setting_get ("dimera3500", "auto_exposure", buf) == GP_OK) camera->pl->auto_exposure = atoi(buf); else camera->pl->auto_exposure = 1; /* Set flag to use flash, if necessary, when capturing picture */ if (gp_setting_get ("dimera3500", "auto_flash", buf) == GP_OK) camera->pl->auto_flash = atoi(buf); else camera->pl->auto_flash = 1; GP_DEBUG("Opening port"); if ( (ret = mesa_port_open(camera->port)) != GP_OK) { ERROR("Camera Open Failed"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Problem opening port")); return ret; } GP_DEBUG("Resetting camera"); if ( (ret = mesa_reset(camera->port)) != GP_OK ) { ERROR("Camera Reset Failed"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Problem resetting camera")); return ret; } GP_DEBUG("Setting speed"); if ( (ret = mesa_set_speed(camera->port, selected_speed)) != GP_OK ) { ERROR("Camera Speed Setting Failed"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Problem setting camera communication speed")); return ret; } GP_DEBUG("Checking for modem"); switch ( ret = mesa_modem_check(camera->port) ) { case GP_ERROR_IO: case GP_ERROR_TIMEOUT: ERROR("No or Unknown Response"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("No response from camera")); return GP_ERROR_TIMEOUT; case GP_ERROR_MODEL_NOT_FOUND: ERROR("Probably a modem"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Looks like a modem, not a camera")); return GP_ERROR_MODEL_NOT_FOUND; case GP_OK: break; default: /* Hopefully, gp_camera_set_error was called for this error */ return ret; } /* Tell the filesystem where to get listings and info from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); return (GP_OK); }
int main () { CameraFilesystem *fs; CameraFileInfo info; CameraList *list; int x, count; const char *name; char *foldername; GPContext *context; #ifdef HAVE_MCHECK_H mtrace(); #endif CHECK (gp_list_new(&list)); gp_log_add_func (GP_LOG_DEBUG, log_func, NULL); context = gp_context_new (); gp_context_set_error_func (context, error_func, NULL); printf ("*** Creating file system...\n"); CHECK (gp_filesystem_new (&fs)); printf ("*** Setting the callbacks...\n"); CHECK (gp_filesystem_set_funcs (fs, &fsfuncs, NULL)); printf ("*** Adding a file...\n"); CHECK (gp_filesystem_append (fs, "/", "my.file", context)); gp_filesystem_dump (fs); printf ("*** Removing this file...\n"); CHECK (gp_filesystem_delete_file (fs, "/", "my.file", context)); gp_filesystem_dump (fs); printf ("*** Resetting...\n"); CHECK (gp_filesystem_reset (fs)); gp_filesystem_dump (fs); printf ("*** Adding /...\n"); CHECK (gp_filesystem_append (fs, "/", NULL, context)); printf ("*** Adding /whatever ...\n"); CHECK (gp_filesystem_append (fs, "/whatever", NULL, context)); printf ("*** Adding /whatever/dir...\n"); CHECK (gp_filesystem_append (fs, "/whatever/dir", NULL, context)); printf ("*** Adding /whatever/dir/file1...\n"); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file1", context)); gp_filesystem_dump (fs); printf ("*** Adding /whatever/dir/file2...\n"); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file2", context)); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file3", context)); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file4", context)); CHECK (gp_filesystem_append (fs, "/whatever/dir", "file5", context)); gp_filesystem_dump (fs); printf ("*** Deleting everything below root...\n"); CHECK (gp_filesystem_delete_all (fs, "/", context)); gp_filesystem_dump (fs); printf ("*** Appending root directory...\n"); CHECK (gp_filesystem_append (fs, "/", NULL, context)); printf ("*** Appending some directories...\n"); CHECK (gp_filesystem_append (fs, "/whatever", NULL, context)); CHECK (gp_filesystem_append (fs, "/whatever/directory", NULL, context)); printf ("*** Adding some files...\n"); CHECK (gp_filesystem_append (fs, "/whatever/directory", "some.file", context)); CHECK (gp_filesystem_append (fs, "/whatever/directory", "some.file2", context)); CHECK (gp_filesystem_append (fs, "/another/directory", "another.file", context)); gp_filesystem_dump (fs); printf ("*** Getting info about a file...\n"); CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file", &info, context)); printf ("*** Getting info again (cache!)...\n"); CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file", &info, context)); printf ("*** Set info about another file...\n"); CHECK (gp_filesystem_set_info (fs, "/whatever/directory", "some.file2", info, context)); printf ("*** Getting info about this file (cache!)...\n"); CHECK (gp_filesystem_get_info (fs, "/whatever/directory", "some.file2", &info, context)); printf ("*** Deleting a file...\n"); CHECK (gp_filesystem_delete_file (fs, "/whatever/directory", "some.file2", context)); gp_filesystem_dump (fs); printf ("*** Resetting the filesystem...\n"); CHECK (gp_filesystem_reset (fs)); gp_filesystem_dump (fs); printf ("*** Getting file list for folder '/whatever/directory'...\n"); CHECK (gp_filesystem_list_folders (fs, "/whatever/directory", list, context)); printf ("*** Getting file list for folder '/whatever/directory' " "again (cached!)...\n"); CHECK (gp_filesystem_list_folders (fs, "/whatever/directory", list, context)); printf ("*** Counting the contents...\n"); CHECK (count = gp_list_count (list)); printf ("*** Listing the contents...\n"); for (x = 0; x < count; x++) { CHECK (gp_list_get_name (list, x, &name)); printf (" %i: '%s'\n", x, name); } printf ("*** Getting folder of 'file1'...\n"); CHECK (gp_filesystem_get_folder (fs, "file1", &foldername, context)); printf ("... found in '%s'.\n", foldername); free(foldername); printf ("*** Deleting a couple of files...\n"); CHECK (gp_filesystem_delete_file (fs, "/whatever", "file5", context)); CHECK (gp_filesystem_delete_file (fs, "/whatever", "file4", context)); CHECK (gp_filesystem_delete_file (fs, "/whatever", "file3", context)); gp_filesystem_dump (fs); printf ("*** Freeing file system...\n"); CHECK (gp_filesystem_free (fs)); gp_context_unref (context); CHECK (gp_list_free(list)); #ifdef HAVE_MCHECK_H muntrace(); #endif return (0); }
int camera_init (Camera *camera, GPContext *context) { int i, j, ret; #ifdef HAVE_ICONV char *curloc; #endif char buf[256]; st2205_filename clean_name; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; camera->functions->summary = camera_summary; camera->functions->manual = camera_manual; camera->functions->about = camera_about; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; /* FIXME add gp_camera_get_storageinfo support */ /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = calloc (1, sizeof(CameraPrivateLibrary)); if (!camera->pl) return GP_ERROR_NO_MEMORY; ret = gp_setting_get("st2205", "syncdatetime", buf); if (ret == GP_OK) camera->pl->syncdatetime = buf[0] == '1'; else camera->pl->syncdatetime = 1; ret = gp_setting_get("st2205", "orientation", buf); if (ret == GP_OK) { ret = string_to_orientation (buf); if (ret >= 0) camera->pl->orientation = ret; } #ifdef HAVE_ICONV curloc = nl_langinfo (CODESET); if (!curloc) curloc="UTF-8"; camera->pl->cd = iconv_open("ASCII", curloc); if (camera->pl->cd == (iconv_t) -1) { gp_log (GP_LOG_ERROR, "iconv", "Failed to create iconv converter"); camera_exit (camera, context); return GP_ERROR_OS_FAILURE; } #endif #if 1 ret = st2205_open_device (camera); #else ret = st2205_open_dump (camera, "/home/hans/st2205tool/memdump.bin", 128, 128); #endif if (ret != GP_OK) { camera_exit (camera, context); return ret; } GP_DEBUG ("st2205 memory size: %d, free: %d", st2205_get_mem_size (camera), st2205_get_free_mem_size (camera)); /* Get the filenames from the picframe */ ret = st2205_get_filenames (camera, camera->pl->filenames); if (ret != GP_OK) { camera_exit (camera, context); return ret; } /* And clean them up and make them unique */ for (i = 0; i < ST2205_MAX_NO_FILES; i++) { if (!camera->pl->filenames[i][0]) continue; /* Filter out non ASCII chars (some frames ship with sample photo's with garbage in the names) */ for (j = 0; camera->pl->filenames[i][j]; j++) { if ((uint8_t)camera->pl->filenames[i][j] < 0x20 || (uint8_t)camera->pl->filenames[i][j] > 0x7E) clean_name[j] = '?'; else clean_name[j] = camera->pl->filenames[i][j]; } clean_name[j] = 0; ST2205_SET_FILENAME(camera->pl->filenames[i], clean_name, i); } /* Sync time if requested */ if (camera->pl->syncdatetime) { struct tm tm; time_t t; t = time (NULL); if (localtime_r (&t , &tm)) { ret = st2205_set_time_and_date (camera, &tm); if (ret != GP_OK) { camera_exit (camera, context); return ret; } } } return GP_OK; }