summaryrefslogtreecommitdiff
path: root/camlibs/konica
diff options
context:
space:
mode:
authorScott Fritzinger <scottf@unr.edu>2000-08-31 18:42:15 +0000
committerScott Fritzinger <scottf@unr.edu>2000-08-31 18:42:15 +0000
commit53b04594e6a75373336d18f11cec09130c593a6f (patch)
tree638403e7ca1d4ecec1829cbf8cab1477c9e5152d /camlibs/konica
parent03ee7a60c1866f9f102a46010d7296a370e11ef8 (diff)
downloadlibgphoto2-53b04594e6a75373336d18f11cec09130c593a6f.tar.gz
appplied localization patches
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@1001 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/konica')
-rw-r--r--camlibs/konica/konica.c262
-rw-r--r--camlibs/konica/konica.h26
-rw-r--r--camlibs/konica/library.c176
3 files changed, 278 insertions, 186 deletions
diff --git a/camlibs/konica/konica.c b/camlibs/konica/konica.c
index d434c5999..556c5ed13 100644
--- a/camlibs/konica/konica.c
+++ b/camlibs/konica/konica.c
@@ -158,6 +158,7 @@ k_return_status_t k_erase_image (konica_data_t *konica_data, gulong image_id)
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
if (!konica_data->image_id_long) {
sb[6] = image_id;
sb[7] = image_id >> 8;
@@ -256,6 +257,7 @@ k_return_status_t k_erase_all (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (
number_of_images_not_erased != NULL,
K_PROGRAM_ERROR);
@@ -312,6 +314,7 @@ k_return_status_t k_set_protect_status (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
if (!konica_data->image_id_long) {
if (protected) sb[8] = 0x01;
sb[6] = image_id;
@@ -387,6 +390,7 @@ k_return_status_t k_get_image (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (image_buffer != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (*image_buffer == NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (image_buffer_size != NULL, K_PROGRAM_ERROR);
@@ -483,6 +487,7 @@ k_return_status_t k_get_image_information (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (image_id != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (exif_size != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (protected != NULL, K_PROGRAM_ERROR);
@@ -562,6 +567,7 @@ k_return_status_t k_get_preview (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (image_buffer != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (*image_buffer == NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (image_buffer_size != NULL, K_PROGRAM_ERROR);
@@ -626,6 +632,7 @@ k_return_status_t k_get_io_capability (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (bit_rate_300 != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (bit_rate_600 != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (bit_rate_1200 != NULL, K_PROGRAM_ERROR);
@@ -786,7 +793,7 @@ k_return_status_t k_get_information (
guchar *rb = NULL;
guint rbs;
- g_return_val_if_fail (model != NULL, K_PROGRAM_ERROR);
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR); g_return_val_if_fail (model != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (*model == NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (serial_number != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (*serial_number == NULL, K_PROGRAM_ERROR);
@@ -939,6 +946,7 @@ k_return_status_t k_get_status (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (self_test_result != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (power_level != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (power_source != NULL, K_PROGRAM_ERROR);
@@ -1077,6 +1085,7 @@ k_return_status_t k_get_date_and_time (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (year != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (month != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (day != NULL, K_PROGRAM_ERROR);
@@ -1140,7 +1149,8 @@ k_return_status_t k_get_preferences (
guchar *rb = NULL;
guint rbs;
- g_return_val_if_fail (shutoff_time != NULL, K_PROGRAM_ERROR);
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
+ g_return_val_if_fail (shutoff_time != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (self_timer_time != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (beep != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (slide_show_interval != NULL, K_PROGRAM_ERROR);
@@ -1196,6 +1206,7 @@ k_return_status_t k_set_io_capability (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
switch (bit_rate) {
case 300:
sb[4] = (1 << 0);
@@ -1325,6 +1336,7 @@ k_return_status_t k_set_preference (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
switch (preference) {
case K_PREFERENCE_RESOLUTION:
sb[4] = 0x00;
@@ -1395,6 +1407,7 @@ k_return_status_t k_reset_preferences (konica_data_t *konica_data)
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
l_return_status = l_send_receive (konica_data, sb, 4, &rb, &rbs);
if (l_return_status != L_SUCCESS) {
g_free (rb);
@@ -1451,16 +1464,14 @@ k_return_status_t k_take_picture (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (image_id != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (exif_size != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (protected != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (information_buffer != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (*information_buffer == NULL, K_PROGRAM_ERROR);
- g_return_val_if_fail (information_buffer_size != NULL, K_PROGRAM_ERROR); l_return_status = l_send_receive_receive (
- konica_data,
- sb, 6,
- information_buffer, information_buffer_size,
- &rb, &rbs, 60000);
+ g_return_val_if_fail (information_buffer_size != NULL, K_PROGRAM_ERROR);
+ l_return_status = l_send_receive_receive (konica_data, sb, 6, information_buffer, information_buffer_size, &rb, &rbs, 60000);
if (l_return_status != L_SUCCESS) {
g_free (rb);
return K_RETURN_STATUS (l_return_status);
@@ -1483,32 +1494,145 @@ k_return_status_t k_take_picture (
}
-k_return_status_t k_put_localization_data (
- konica_data_t *konica_data,
- guchar *data,
- gulong data_size)
+k_return_status_t k_localization_tv_output_format_set (konica_data_t *konica_data, k_tv_output_format tv_output_format)
+{
+ /************************************************/
+ /* Command for various localization issues. */
+ /* Here: Setting of tv output format. */
+ /* */
+ /* 0x00: Byte 0 of command identifier */
+ /* 0x92: Byte 1 of command identifier */
+ /* 0x00: Reserved */
+ /* 0x00: Reserved */
+ /* 0x01: Byte 0 of localization type identifier */
+ /* 0x00: transmission of */
+ /* localization data */
+ /* 0x01: setting of tv output */
+ /* format */
+ /* 0x02: setting of date format */
+ /* 0x00: Byte 1 of localization type identifier */
+ /* 0xXX: Byte 0 of tv output format */
+ /* 0x00: NTSC */
+ /* 0x01: PAL */
+ /* 0x02: None */
+ /* 0x00: Byte 1 of tv output format */
+ /* */
+ /* Return values: */
+ /* 0x00: Byte 0 of command identifier */
+ /* 0x92: Byte 1 of command identifier */
+ /* 0xXX: Byte 0 of return status */
+ /* 0xXX: Byte 1 of return status */
+ /************************************************/
+ guchar sb[] = {0x00, 0x92, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};
+ l_return_status_t l_return_status;
+ k_return_status_t k_return_status;
+ guchar *rb = NULL;
+ guint rbs;
+
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
+ switch (tv_output_format) {
+ case K_TV_OUTPUT_FORMAT_NTSC:
+ sb[6] = 0x00;
+ break;
+ case K_TV_OUTPUT_FORMAT_PAL:
+ sb[6] = 0x01;
+ break;
+ case K_TV_OUTPUT_FORMAT_HIDE:
+ sb[6] = 0x02;
+ break;
+ default:
+ return (K_PROGRAM_ERROR);
+ }
+ l_return_status = l_send_receive (konica_data, sb, 8, &rb, &rbs);
+ if (l_return_status != L_SUCCESS) {
+ g_free (rb);
+ return K_RETURN_STATUS (l_return_status);
+ }
+ k_return_status = return_status_translation (rb[2], rb[3]);
+ g_free (rb);
+ return (k_return_status);
+}
+
+
+k_return_status_t k_localization_date_format_set (konica_data_t *konica_data, k_date_format_t date_format)
+{
+ /************************************************/
+ /* Command for various localization issues. */
+ /* Here: Setting of date format. */
+ /* */
+ /* 0x00: Byte 0 of command identifier */
+ /* 0x92: Byte 1 of command identifier */
+ /* 0x00: Reserved */
+ /* 0x00: Reserved */
+ /* 0x02: Byte 0 of localization type identifier */
+ /* 0x00: transmission of */
+ /* localization data */
+ /* 0x01: setting of tv output */
+ /* format */
+ /* 0x02: setting of date format */
+ /* 0x00: Byte 1 of localization type identifier */
+ /* 0xXX: Byte 0 of date format */
+ /* 0x00: month/day/year */
+ /* 0x01: day/month/year */
+ /* 0x02: year/month/day */
+ /* 0x00: Byte 1 of date format */
+ /* */
+ /* Return values: */
+ /* 0x00: Byte 0 of command identifier */
+ /* 0x92: Byte 1 of command identifier */
+ /* 0xXX: Byte 0 of return status */
+ /* 0xXX: Byte 1 of return status */
+ /************************************************/
+ guchar sb[] = {0x00, 0x92, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00};
+ l_return_status_t l_return_status;
+ k_return_status_t k_return_status;
+ guchar *rb = NULL;
+ guint rbs;
+
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
+ switch (date_format) {
+ case K_DATE_FORMAT_MONTH_DAY_YEAR:
+ sb[6] = 0x00;
+ break;
+ case K_DATE_FORMAT_DAY_MONTH_YEAR:
+ sb[6] = 0x01;
+ break;
+ case K_DATE_FORMAT_YEAR_MONTH_DAY:
+ sb[6] = 0x02;
+ break;
+ default:
+ return (K_PROGRAM_ERROR);
+ }
+ l_return_status = l_send_receive (konica_data, sb, 8, &rb, &rbs);
+ if (l_return_status != L_SUCCESS) {
+ g_free (rb);
+ return K_RETURN_STATUS (l_return_status);
+ }
+ k_return_status = return_status_translation (rb[2], rb[3]);
+ g_free (rb);
+ return (k_return_status);
+}
+
+
+k_return_status_t k_localization_data_put (konica_data_t *konica_data, guchar *data, gulong data_size)
{
/************************************************/
- /* Command to send a localization file to the */
- /* camera. */
+ /* Command for various localization issues. */
+ /* Here: Transmission of localization data. */
/* */
/* 0x00: Byte 0 of command identifier */
/* 0x92: Byte 1 of command identifier */
/* 0x00: Reserved */
/* 0x00: Reserved */
- /* 0xXX: Byte 0 of transmission status */
- /* 0x00: packet attached */
- /* 0x01: all packets transmitted */
- /* 0x02: end of transmission */
- /* 0x00: Byte 1 of transmission status */
- /* 0xXX: Byte 0 of language */
- /* 0x00: English */
- /* 0x01: French */
- /* 0x00: Byte 1 of language */
- /* */
- /* In case of transmission status 0x00 0x00, */
- /* the following bytes are attached. */
- /* */
+ /* 0x00: Byte 0 of localization type identifier */
+ /* 0x00: transmission of */
+ /* localization data */
+ /* 0x01: setting of tv output */
+ /* format */
+ /* 0x02: setting of date format */
+ /* 0x00: Byte 1 of localization type identifier */
+ /* 0x00: Byte 0 of ? */
+ /* 0x00: Byte 1 of ? */
/* 0xXX: Byte 0 of number of bytes of packet */
/* 0xXX: Byte 1 of number of bytes of packet */
/* 0xXX: Byte 3 of memory address where to */
@@ -1532,41 +1656,52 @@ k_return_status_t k_put_localization_data (
/************************************************/
l_return_status_t l_return_status;
k_return_status_t k_return_status;
- guchar sb[1040];
guchar *rb = NULL;
guint rbs;
gulong i, j;
guint packet_size = 1024;
+ guchar sb[16 + packet_size];
g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
+ g_return_val_if_fail (data_size >= 512, K_PROGRAM_ERROR);
g_return_val_if_fail (data != NULL, K_PROGRAM_ERROR);
- g_return_val_if_fail (data_size >= 112, K_PROGRAM_ERROR);
- /****************************************/
- /* Write data to the camera's memory. */
- /****************************************/
- for (i = 0; i < packet_size + 16; i++) sb[i] = 0;
sb[0] = 0x00;
sb[1] = 0x92;
sb[2] = 0x00;
sb[3] = 0x00;
sb[4] = 0x00;
sb[5] = 0x00;
- sb[6] = data[52];
+ sb[6] = 0x00;
sb[7] = 0x00;
sb[8] = packet_size;
sb[9] = packet_size >> 8;
- for (i = 0; i <= 65536; i+= packet_size) {
+ sb[10] = 0x00;
+ sb[11] = 0x00;
+ sb[12] = 0x00;
+ sb[13] = 0x00;
+ sb[14] = 0x00;
+ sb[15] = 0x00;
+ i = 0;
+ while (TRUE) {
+ /* Set up the packet. */
sb[10] = i >> 16;
sb[11] = i >> 24;
sb[12] = i;
sb[13] = i >> 8;
- sb[14] = 0x00;
- sb[15] = 0x00;
- if (i + packet_size > 65536) sb[14] = 1;
- for (j = 0; j < packet_size; j++) {
- if ((i + j) < data_size) sb[16 + j] = data[i + j];
- else sb[16 + j] = 0xFF;
- }
+ for (j = 0; j < packet_size; j++) {
+ if ((i + j) < data_size) sb[16 + j] = data[i + j];
+ else sb[16 + j] = 0xFF;
+ }
+ /********************************************************/
+ /* We could wait until the camera sends us */
+ /* K_ERROR_LOCALIZATION_DATA_EXCESS, but it does that */
+ /* not until the 70000th byte or so. However, as we can */
+ /* provoke the message with sb[14] = 0x01, we do so as */
+ /* soon as we exceed the 65535th byte to shorten the */
+ /* transmission time. We can't do that before or the */
+ /* camera reports K_ERROR_LOCALIZATION_DATA_CORRUPT. */
+ /********************************************************/
+ if (i + packet_size > 65536) sb[14] = 0x01;
if (konica_data->debug_flag)
printf ("-> Sending packet starting at "
"memory address %i.\n", (gint) i);
@@ -1580,38 +1715,20 @@ k_return_status_t k_put_localization_data (
}
k_return_status = return_status_translation (rb[2], rb[3]);
g_free (rb);
- if (k_return_status != K_SUCCESS)
- if (k_return_status != K_ERROR_LOCALIZATION_DATA_EXCESS)
- return (k_return_status);
- }
- /****************************************/
- /* Send the information that all */
- /* packets have been transmitted. */
- /****************************************/
- if (konica_data->debug_flag) printf ("-> Sending 1.\n");
- sb[4] = 1;
- l_return_status = l_send_receive (konica_data, sb, 8, &rb, &rbs);
- if (l_return_status != L_SUCCESS) {
- g_free (rb);
- return K_RETURN_STATUS (l_return_status);
- }
- k_return_status = return_status_translation (rb[2], rb[3]);
- g_free (rb);
- if (k_return_status != K_SUCCESS) return (k_return_status);
- /****************************************/
- /* Send the information that the */
- /* localization is done. */
- /****************************************/
- if (konica_data->debug_flag) printf ("-> Sending 2.\n");
- sb[4] = 2;
- l_return_status = l_send_receive (konica_data, sb, 8, &rb, &rbs);
- if (l_return_status != L_SUCCESS) {
- g_free (rb);
- return K_RETURN_STATUS (l_return_status);
+ switch (k_return_status) {
+ case K_SUCCESS:
+ /* Everything is fine. Continue sending packets. However, make sure we don't loop forever. */
+ if (i > 131072) return (K_PROGRAM_ERROR);
+ break;
+ case K_ERROR_LOCALIZATION_DATA_EXCESS:
+ /* The camera does no longer want to receive localization data. We are done. */
+ return (K_SUCCESS);
+ default:
+ /* Something went wrong. */
+ return (k_return_status);
+ }
+ i += packet_size;
}
- k_return_status = return_status_translation (rb[2], rb[3]);
- g_free (rb);
- return (k_return_status);
}
@@ -1642,6 +1759,7 @@ k_return_status_t k_cancel (
guchar *rb = NULL;
guint rbs;
+ g_return_val_if_fail (konica_data != NULL, K_PROGRAM_ERROR);
g_return_val_if_fail (command != NULL, K_PROGRAM_ERROR);
l_return_status = l_send_receive (
konica_data,
diff --git a/camlibs/konica/konica.h b/camlibs/konica/konica.h
index ad22c5903..631c34304 100644
--- a/camlibs/konica/konica.h
+++ b/camlibs/konica/konica.h
@@ -272,6 +272,20 @@ typedef enum {
} k_card_status_t;
+typedef enum {
+ K_DATE_FORMAT_MONTH_DAY_YEAR,
+ K_DATE_FORMAT_DAY_MONTH_YEAR,
+ K_DATE_FORMAT_YEAR_MONTH_DAY
+} k_date_format_t;
+
+
+typedef enum {
+ K_TV_OUTPUT_FORMAT_NTSC,
+ K_TV_OUTPUT_FORMAT_PAL,
+ K_TV_OUTPUT_FORMAT_HIDE
+} k_tv_output_format;
+
+
/****************************************************************/
/* Functions */
/****************************************************************/
@@ -453,7 +467,17 @@ k_return_status_t k_set_protect_status (
gboolean protected);
-k_return_status_t k_put_localization_data (
+k_return_status_t k_localization_tv_output_format_set (
+ konica_data_t *konica_data,
+ k_tv_output_format tv_output_format);
+
+
+k_return_status_t k_localization_date_format_set (
+ konica_data_t *konica_data,
+ k_date_format_t date_format);
+
+
+k_return_status_t k_localization_data_put (
konica_data_t *konica_data,
guchar *data,
gulong data_size);
diff --git a/camlibs/konica/library.c b/camlibs/konica/library.c
index 7eba6dd4a..39d72132a 100644
--- a/camlibs/konica/library.c
+++ b/camlibs/konica/library.c
@@ -865,9 +865,26 @@ int camera_config_get (Camera *camera, CameraWidget *window)
gp_widget_value_set (widget, "Medium (1152 x 872)");
break;
}
+ /****************/
+ /* Localization */
+ /****************/
+ section = gp_widget_new (GP_WIDGET_SECTION, "Localization");
+ gp_widget_append (window, section);
/* Language */
widget = gp_widget_new (GP_WIDGET_TEXT, "Localization File");
gp_widget_append (section, widget);
+ /* TV output format */
+ widget = gp_widget_new (GP_WIDGET_RADIO, "TV Output Format");
+ gp_widget_append (section, widget);
+ gp_widget_choice_add (widget, "NTSC");
+ gp_widget_choice_add (widget, "PAL");
+ gp_widget_choice_add (widget, "Do not display TV menu");
+ /* Date format */
+ widget = gp_widget_new (GP_WIDGET_RADIO, "Date Format");
+ gp_widget_append (section, widget);
+ gp_widget_choice_add (widget, "Month/Day/Year");
+ gp_widget_choice_add (widget, "Day/Month/Year");
+ gp_widget_choice_add (widget, "Year/Month/Day");
/********************************/
/* Session-persistent Settings */
/********************************/
@@ -947,86 +964,69 @@ int camera_config_set (Camera *camera, CameraSetting *setting, int count)
konica_data_t *konica_data;
guchar *data;
gulong data_size;
+ k_date_format_t date_format;
+ k_tv_output_format tv_output_format;
g_return_val_if_fail (camera != NULL, GP_ERROR);
g_return_val_if_fail (setting != NULL, GP_ERROR);
focus = 0;
self_timer = 0;
konica_data = (konica_data_t *) camera->camlib_data;
- if (konica_data->debug_flag)
- printf ("*** Entering camera_config_set.\n");
+ if (konica_data->debug_flag) printf ("*** Entering camera_config_set.\n");
for (i = 0; i < count; i++) {
- if (konica_data->debug_flag)
- printf ("-> Setting \"%s\" to \"%s\".\n",
- setting[i].name,
- setting[i].value);
+ if (konica_data->debug_flag) printf ("-> Setting \"%s\" to \"%s\".\n", setting[i].name, setting[i].value);
if (strcmp (setting[i].name, "Beep") == 0) {
if (strcmp (setting[i].value, "Off") == 0) j = 0;
else j = 1;
- if (error_happened (camera, k_set_preference (
- konica_data,
- K_PREFERENCE_BEEP,
- j))) return (GP_ERROR);
+ if (error_happened (camera, k_set_preference (konica_data, K_PREFERENCE_BEEP, j))) return (GP_ERROR);
continue;
}
if (strcmp (setting[i].name, "Self Timer Time") == 0) {
- if (error_happened (camera, k_set_preference (
- konica_data,
- K_PREFERENCE_SELF_TIMER_TIME,
- (guint) atoi (setting[i].value))))
- return (GP_ERROR);
+ if (error_happened (camera, k_set_preference (konica_data, K_PREFERENCE_SELF_TIMER_TIME, (guint) atoi (setting[i].value)))) return (GP_ERROR);
continue;
}
if (strcmp (setting[i].name, "Auto Off Time") == 0) {
- if (error_happened (camera, k_set_preference (
- konica_data,
- K_PREFERENCE_AUTO_OFF_TIME,
- (guint) atoi (setting[i].value))))
- return (GP_ERROR);
+ if (error_happened (camera, k_set_preference (konica_data, K_PREFERENCE_AUTO_OFF_TIME, (guint) atoi (setting[i].value)))) return (GP_ERROR);
continue;
}
if (strcmp (setting[i].name, "Slide Show Interval") == 0) {
- if (error_happened (camera, k_set_preference (
- konica_data,
- K_PREFERENCE_SLIDE_SHOW_INTERVAL,
- (guint) atoi (setting[i].value))))
- return (GP_ERROR);
+ if (error_happened (camera, k_set_preference (konica_data, K_PREFERENCE_SLIDE_SHOW_INTERVAL, (guint) atoi (setting[i].value)))) return (GP_ERROR);
continue;
}
if (strcmp (setting[i].name, "Resolution") == 0) {
- if (strcmp (
- setting[i].value,
- "High (1152 x 872)") == 0) j = 1;
- if (strcmp (
- setting[i].value,
- "Low (576 x 436)") == 0) j = 3;
+ if (strcmp (setting[i].value, "High (1152 x 872)") == 0) j = 1;
+ if (strcmp (setting[i].value, "Low (576 x 436)") == 0) j = 3;
else j = 0;
- if (error_happened (camera, k_set_preference (
- konica_data,
- K_PREFERENCE_RESOLUTION,
- j))) return (GP_ERROR);
+ if (error_happened (camera, k_set_preference (konica_data, K_PREFERENCE_RESOLUTION, j))) return (GP_ERROR);
continue;
}
+ if (strcmp (setting[i].name, "TV Output Format") == 0) {
+ if (strcmp (setting[i].value, "NTSC") == 0) tv_output_format = K_TV_OUTPUT_FORMAT_NTSC;
+ else if (strcmp (setting[i].value, "PAL") == 0) tv_output_format = K_TV_OUTPUT_FORMAT_PAL;
+ else if (strcmp (setting[i].value, "Do not display TV menu") == 0) tv_output_format = K_TV_OUTPUT_FORMAT_HIDE;
+ else continue;
+ if (error_happened (camera, k_localization_tv_output_format_set (konica_data, tv_output_format))) return (GP_ERROR);
+ continue;
+ }
+ if (strcmp (setting[i].name, "Date Format") == 0) {
+ if (strcmp (setting[i].value, "Month/Day/Year") == 0) date_format = K_DATE_FORMAT_MONTH_DAY_YEAR;
+ else if (strcmp (setting[i].value, "Day/Month/Year") == 0) date_format = K_DATE_FORMAT_DAY_MONTH_YEAR;
+ else if (strcmp (setting[i].value, "Year/Month/Day") == 0) date_format = K_DATE_FORMAT_YEAR_MONTH_DAY;
+ else continue;
+ if (error_happened (camera, k_localization_date_format_set (konica_data, date_format))) return (GP_ERROR);
+ continue;
+ }
if (strcmp (setting[i].name, "Localization File") == 0) {
if (strcmp (setting[i].value, "") != 0) {
data = NULL;
data_size = 0;
/* Read localization file */
- if (!localization_file_read (
- camera,
- setting[i].value,
- &data,
- &data_size)) {
+ if (!localization_file_read (camera, setting[i].value, &data, &data_size)) {
g_free (data);
return (GP_ERROR);
}
/* Go! */
- if (error_happened (
- camera,
- k_put_localization_data (
- konica_data,
- data,
- data_size))) {
+ if (error_happened (camera, k_localization_data_put (konica_data, data, data_size))) {
g_free (data);
return (GP_ERROR);
}
@@ -1037,49 +1037,28 @@ int camera_config_set (Camera *camera, CameraSetting *setting, int count)
if (strcmp (setting[i].name, "Flash") == 0) {
if (strcmp (setting[i].value, "Off") == 0) j = 0;
else if (strcmp (setting[i].value, "On") == 0) j = 1;
- else if (strcmp (
- setting[i].value,
- "On, red-eye reduction") == 0) j = 5;
- else if (strcmp (
- setting[i].value,
- "Auto, red-eye reduction") == 0) j = 6;
+ else if (strcmp (setting[i].value, "On, red-eye reduction") == 0) j = 5;
+ else if (strcmp (setting[i].value, "Auto, red-eye reduction") == 0) j = 6;
else j = 2;
- if (error_happened (camera, k_set_preference (
- konica_data,
- K_PREFERENCE_FLASH,
- j))) return (GP_ERROR);
+ if (error_happened (camera, k_set_preference (konica_data, K_PREFERENCE_FLASH, j))) return (GP_ERROR);
continue;
}
if (strcmp (setting[i].name, "Exposure") == 0) {
- if (error_happened (camera, k_set_preference (
- konica_data,
- K_PREFERENCE_EXPOSURE,
- (guint) atoi (setting[i].value))))
- return (GP_ERROR);
+ if (error_happened (camera, k_set_preference (konica_data, K_PREFERENCE_EXPOSURE, (guint) atoi (setting[i].value)))) return (GP_ERROR);
continue;
}
if (strcmp (setting[i].name, "Focus") == 0) {
if (strcmp (setting[i].value, "Auto") == 0) focus = 2;
- if (error_happened (camera, k_set_preference (
- konica_data,
- K_PREFERENCE_FOCUS_SELF_TIMER,
- focus + self_timer))) return (GP_ERROR);
+ if (error_happened (camera, k_set_preference (konica_data, K_PREFERENCE_FOCUS_SELF_TIMER, focus + self_timer))) return (GP_ERROR);
continue;
}
if (strcmp (setting[i].name, "Self Timer") == 0) {
- if (strcmp (
- setting[i].value,
- "Self Timer (only next picture)") == 0)
- self_timer = 1;
- if (error_happened (camera, k_set_preference (
- konica_data,
- K_PREFERENCE_FOCUS_SELF_TIMER,
- focus + self_timer))) return (GP_ERROR);
+ if (strcmp (setting[i].value, "Self Timer (only next picture)") == 0) self_timer = 1;
+ if (error_happened (camera, k_set_preference (konica_data, K_PREFERENCE_FOCUS_SELF_TIMER, focus + self_timer))) return (GP_ERROR);
continue;
}
}
- if (konica_data->debug_flag)
- printf ("*** Leaving camera_config_set.\n");
+ if (konica_data->debug_flag) printf ("*** Leaving camera_config_set.\n");
return (GP_OK);
}
@@ -1094,12 +1073,12 @@ gboolean localization_file_read (
gulong j;
gchar f;
guchar c[] = "\0\0";
- gchar buffer[1024];
gulong line_number;
konica_data_t *konica_data;
guchar checksum;
gulong fcs;
guint d;
+ gchar *message;
g_return_val_if_fail (camera != NULL, FALSE);
g_return_val_if_fail (file_name != NULL, FALSE);
@@ -1108,9 +1087,7 @@ gboolean localization_file_read (
g_return_val_if_fail (data_size != NULL, FALSE);
konica_data = (konica_data_t *) camera->camlib_data;
if ((file = fopen (file_name, "r")) == NULL) {
- gp_camera_message (
- camera,
- "Could not open requested localization file!");
+ gp_camera_message (camera, "Could not open requested localization file!");
return (FALSE);
}
*data_size = 0;
@@ -1150,15 +1127,13 @@ gboolean localization_file_read (
(f != '9') && (f != 'A') && (f != 'B') &&
(f != 'C') && (f != 'D') && (f != 'E') &&
(f != 'F')) {
- sprintf (
- buffer,
+ message = g_strdup_printf (
"Error in localization file!\n"
"\"%c\" in line %i is not allowed.",
f,
(gint) line_number);
- gp_camera_message (
- camera,
- buffer);
+ gp_camera_message (camera, message);
+ g_free (message);
fclose (file);
return (FALSE);
}
@@ -1191,39 +1166,14 @@ gboolean localization_file_read (
/* Calculate and check checksum. */
/*********************************/
checksum = 0;
- for (j = 112; j < *data_size; j++) checksum += (*data)[j];
- if ((*data)[100] != checksum) {
- sprintf (
- buffer,
- "Checksum not right:\n"
- " - File: %i\n"
- " - Calculated: %i\n"
- "Continuing nevertheless as the\n"
- "camera won't check the checksum.",
- (*data)[100],
- checksum);
- gp_camera_message (camera, buffer);
- }
+ g_warning ("Checksum not implemented!");
+ //FIXME: There's a checksum at (*data)[100]. I could not figure out how it is calculated.
/*********************************************/
/* Calculate and check frame check sequence. */
/*********************************************/
-//FIXME: How do I calculate a fcs?
fcs = 0;
- if ((((*data)[108] << 8) | (*data)[109]) != fcs) {
- sprintf (
- buffer,
- "Frame check sequence not right:\n"
- " - File: %i\n"
- " - Calculated: %i\n"
- "I can't check the frame check sequence, as\n"
- "I don't know how to calculate it. If you\n"
- "know more, please contact the maintainer\n"
- "of this driver.\n"
- "Sending data nevertheless.",
- ((*data)[108] << 8) | (*data)[109],
- (gint) fcs);
- gp_camera_message (camera, buffer);
- }
+ g_warning ("Frame check sequence not implemented!");
+ //FIXME: There's a frame check sequence at (*data)[108] and (*data)[109]. I could not figure out how it is calculated.
if (konica_data->debug_flag)
printf ("-> %i bytes read.\n", (gint) *data_size);
return (TRUE);