diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2017-04-04 20:18:10 +0200 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2017-04-04 20:18:10 +0200 |
commit | e70acad8e068c9269b1617f7573fccd973008137 (patch) | |
tree | 7bd985f21e050608389db1668201536ce409dcc7 | |
parent | c0ffc6352f7030f637bec325b39406bc3ae079bc (diff) | |
download | libgphoto2-e70acad8e068c9269b1617f7573fccd973008137.tar.gz |
import from pktriggercord on april 4
-rw-r--r-- | camlibs/pentax/pslr.c | 146 | ||||
-rw-r--r-- | camlibs/pentax/pslr.h | 8 | ||||
-rw-r--r-- | camlibs/pentax/pslr_enum.c | 71 | ||||
-rw-r--r-- | camlibs/pentax/pslr_enum.h | 75 | ||||
-rw-r--r-- | camlibs/pentax/pslr_model.c | 39 | ||||
-rw-r--r-- | camlibs/pentax/pslr_model.h | 3 |
6 files changed, 258 insertions, 84 deletions
diff --git a/camlibs/pentax/pslr.c b/camlibs/pentax/pslr.c index 21fbba9cd..8e768bd60 100644 --- a/camlibs/pentax/pslr.c +++ b/camlibs/pentax/pslr.c @@ -188,22 +188,28 @@ typedef enum { /* a different write_args function needs to be done with slightly changed */ /* command sequence. Original function was ipslr_write_args(). */ -/*static int ipslr_write_args_special(ipslr_handle_t *p, int n, ...) { - va_list ap; - int args[n]; - int i; - for( i = 0; i < 4; ++i ) { - args[i] = 0; + +int pslr_get_buffer_status(pslr_handle_t *h, uint32_t *x, uint32_t *y) { + ipslr_handle_t *p = (ipslr_handle_t *) h; + DPRINT("[C]\t\tipslr_get_buffer_status()\n"); + uint8_t buf[800]; + int n; + + CHECK(command(p->fd, 0x02, 0x00, 0)); + n = get_result(p->fd); + DPRINT("[C]\t\tipslr_get_buffer_status() bytes: %d\n",n); + if (n!= 8) { + return PSLR_READ_ERROR; } - va_start(ap, n); - for (i = 0; i < n; i++) { - args[i] = va_arg(ap, int); + CHECK(read_result(p->fd, buf, n)); + int i; + for (i=0; i<n; ++i) { + DPRINT("[C]\t\tbuf[%d]=%02x\n",i,buf[i]); } - va_end(ap); - return _ipslr_write_args(4, p, n, args); - }*/ + return PSLR_OK; +} -/* Commands in form 23 XX YY. I know it si stupid, but ipslr_cmd functions */ +/* Commands in form 23 XX YY. I know it is stupid, but ipslr_cmd functions */ /* are sooooo handy. */ static int ipslr_cmd_23_XX(ipslr_handle_t *p, char XX, char YY, uint32_t mode) { DPRINT("[C]\t\tipslr_cmd_23_XX(%x, %x, mode=%x)\n", XX, YY, mode); @@ -469,6 +475,10 @@ int pslr_get_status(pslr_handle_t h, pslr_status *ps) { memset( ps, 0, sizeof( pslr_status )); CHECK(ipslr_status_full(p, &p->status)); memcpy(ps, &p->status, sizeof (pslr_status)); + +// uint32_t x, y; +// pslr_get_buffer_status(h, &x, &y); + return PSLR_OK; } @@ -532,7 +542,8 @@ char *collect_status_info( pslr_handle_t h, pslr_status status ) { sprintf(strbuffer+strlen(strbuffer),"%-32s: %s\n", "ec", format_rational( status.ec, "%.2f" ) ); sprintf(strbuffer+strlen(strbuffer),"%-32s: %s\n", "custom ev steps", get_pslr_custom_ev_steps_str(status.custom_ev_steps)); sprintf(strbuffer+strlen(strbuffer),"%-32s: %d\n", "custom sensitivity steps", status.custom_sensitivity_steps); - sprintf(strbuffer+strlen(strbuffer),"%-32s: %d (%s)\n", "exposure mode", status.exposure_mode, get_pslr_exposure_submode_str(status.exposure_submode)); + sprintf(strbuffer+strlen(strbuffer),"%-32s: %d\n", "exposure mode", status.exposure_mode); + sprintf(strbuffer+strlen(strbuffer),"%-32s: %s\n", "scene mode", get_pslr_scene_mode_str(status.scene_mode)); sprintf(strbuffer+strlen(strbuffer),"%-32s: %d\n", "user mode flag", status.user_mode_flag); sprintf(strbuffer+strlen(strbuffer),"%-32s: %s\n", "ae metering mode", get_pslr_ae_metering_str(status.ae_metering_mode)); sprintf(strbuffer+strlen(strbuffer),"%-32s: %s\n", "af mode", get_pslr_af_mode_str(status.af_mode)); @@ -552,6 +563,7 @@ char *collect_status_info( pslr_handle_t h, pslr_status status ) { sprintf(strbuffer+strlen(strbuffer),"%-32s: %.2f\n", "manual mode ev", (1.0 * status.manual_mode_ev / 10)); sprintf(strbuffer+strlen(strbuffer),"%-32s: %s\n", "lens", get_lens_name(status.lens_id1, status.lens_id2)); sprintf(strbuffer+strlen(strbuffer),"%-32s: %.2fV %.2fV %.2fV %.2fV\n", "battery", 0.01 * status.battery_1, 0.01 * status.battery_2, 0.01 * status.battery_3, 0.01 * status.battery_4); + sprintf(strbuffer+strlen(strbuffer),"%-32s: %s\n", "buffer mask", int_to_binary(status.bufmask)); return strbuffer; } @@ -1351,6 +1363,104 @@ static int ipslr_identify(ipslr_handle_t *p) { return PSLR_OK; } +int pslr_read_datetime(pslr_handle_t *h, int *year, int *month, int *day, int *hour, int *min, int *sec) { + ipslr_handle_t *p = (ipslr_handle_t *) h; + DPRINT("[C]\t\tipslr_read_datetime()\n"); + uint8_t idbuf[800]; + int n; + + CHECK(command(p->fd, 0x20, 0x06, 0)); + n = get_result(p->fd); + DPRINT("[C]\t\tipslr_read_datetime() bytes: %d\n",n); + if (n!= 24) { + return PSLR_READ_ERROR; + } + CHECK(read_result(p->fd, idbuf, n)); + get_uint32_func get_uint32_func_ptr; + + if (p->model->is_little_endian) { + get_uint32_func_ptr = get_uint32_le; + } else { + get_uint32_func_ptr = get_uint32_be; + } + *year = (*get_uint32_func_ptr)(idbuf); + *month = (*get_uint32_func_ptr)(idbuf+4); + *day = (*get_uint32_func_ptr)(idbuf+8); + *hour = (*get_uint32_func_ptr)(idbuf+12); + *min = (*get_uint32_func_ptr)(idbuf+16); + *sec = (*get_uint32_func_ptr)(idbuf+20); + return PSLR_OK; +} + +int pslr_read_dspinfo(pslr_handle_t *h, char* firmware) { + ipslr_handle_t *p = (ipslr_handle_t *) h; + DPRINT("[C]\t\tipslr_read_dspinfo()\n"); + uint8_t buf[4]; + int n; + + CHECK(command(p->fd, 0x01, 0x01, 0)); + n = get_result(p->fd); + DPRINT("[C]\t\tipslr_read_dspinfo() bytes: %d\n",n); + if (n!= 4) { + return PSLR_READ_ERROR; + } + CHECK(read_result(p->fd, buf, n)); + if (p->model->is_little_endian) { + snprintf( firmware, 16, "%d.%02d.%02d.%02d", buf[3], buf[2], buf[1], buf[0]); + } else { + snprintf( firmware, 16, "%d.%02d.%02d.%02d", buf[0], buf[1], buf[2], buf[3]); + } + return PSLR_OK; +} + +int pslr_read_setting(pslr_handle_t *h, int offset, uint32_t *value) { + ipslr_handle_t *p = (ipslr_handle_t *) h; + DPRINT("[C]\t\tipslr_read_setting(%d)\n", offset); + uint8_t buf[4]; + int n; + + CHECK(ipslr_write_args(p, 1, offset)); + CHECK(command(p->fd, 0x20, 0x09, 4)); + n = get_result(p->fd); + DPRINT("[C]\t\tipslr_read_setting() bytes: %d\n",n); + if (n!= 4) { + return PSLR_READ_ERROR; + } + CHECK(read_result(p->fd, buf, n)); + get_uint32_func get_uint32_func_ptr; + if (p->model->is_little_endian) { + get_uint32_func_ptr = get_uint32_le; + } else { + get_uint32_func_ptr = get_uint32_be; + } + *value = (*get_uint32_func_ptr)(buf); + return PSLR_OK; +} + +int pslr_write_setting(pslr_handle_t *h, int offset, uint32_t value) { + ipslr_handle_t *p = (ipslr_handle_t *) h; + DPRINT("[C]\t\tipslr_write_setting(%d)=%d\n", offset, value); + CHECK(ipslr_cmd_00_09(p, 1)); + CHECK(ipslr_write_args(p, 2, offset, value)); + CHECK(command(p->fd, 0x20, 0x08, 8)); + CHECK(ipslr_cmd_00_09(p, 2)); + return PSLR_OK; +} + +int pslr_read_settings(pslr_handle_t *h, int offset, int length, uint8_t *buf) { + int index=offset; + uint32_t value; + int ret; + while (index<offset+length) { + if ( (ret = pslr_read_setting(h, index, &value)) != PSLR_OK ) { + return ret; + } + buf[index] = value; + ++index; + } + return PSLR_OK; +} + static int _ipslr_write_args(uint8_t cmd_2, ipslr_handle_t *p, int n, ...) { va_list ap; uint8_t cmd[8] = {0xf0, 0x4f, cmd_2, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -1450,16 +1560,14 @@ static int get_status(FDTYPE fd) { memset(statusbuf,0,8); while (1) { - //usleep(POLL_INTERVAL); CHECK(read_status(fd, statusbuf)); - if ((statusbuf[7] & 0x01) == 0) { + DPRINT("[R]\t\t\t\t => ERROR: 0x%02X\n", statusbuf[7]); + if (statusbuf[7] != 0x01) { break; } - //DPRINT("Waiting for ready - "); - DPRINT("[R]\t\t\t\t => ERROR: 0x%02X\n", statusbuf[7]); usleep(POLL_INTERVAL); } - if ((statusbuf[7] & 0xff) != 0) { + if (statusbuf[7] != 0) { DPRINT("\tERROR: 0x%x\n", statusbuf[7]); } return statusbuf[7]; diff --git a/camlibs/pentax/pslr.h b/camlibs/pentax/pslr.h index bfc704d78..829b7c91c 100644 --- a/camlibs/pentax/pslr.h +++ b/camlibs/pentax/pslr.h @@ -225,6 +225,14 @@ int pslr_get_model_af_point_num(pslr_handle_t h); pslr_buffer_type pslr_get_jpeg_buffer_type(pslr_handle_t h, int quality); int pslr_get_jpeg_resolution(pslr_handle_t h, int hwres); +int pslr_read_datetime(pslr_handle_t *h, int *year, int *month, int *day, int *hour, int *min, int *sec); + +int pslr_read_dspinfo(pslr_handle_t *h, char *firmware); + +int pslr_read_setting(pslr_handle_t *h, int offset, uint32_t *value); +int pslr_write_setting(pslr_handle_t *h, int offset, uint32_t value); +int pslr_read_settings(pslr_handle_t *h, int offset, int length, uint8_t *buf); + pslr_gui_exposure_mode_t exposure_mode_conversion( pslr_exposure_mode_t exp ); char *format_rational( pslr_rational_t rational, char * fmt ); diff --git a/camlibs/pentax/pslr_enum.c b/camlibs/pentax/pslr_enum.c index f3a529fdd..083e0d4ec 100644 --- a/camlibs/pentax/pslr_enum.c +++ b/camlibs/pentax/pslr_enum.c @@ -37,6 +37,7 @@ #include <string.h> #include <ctype.h> #include <stdio.h> +#include <stdlib.h> const char* pslr_color_space_str[PSLR_COLOR_SPACE_MAX] = { "sRGB", @@ -95,7 +96,10 @@ const char* pslr_jpeg_image_tone_str[PSLR_JPEG_IMAGE_TONE_MAX] = { "Muted", "ReversalFilm", "BleachBypass", - "Radiant" + "Radiant", + "CrossProcessing", + "Flat", + "Auto" }; const char* pslr_white_balance_mode_str[PSLR_WHITE_BALANCE_MODE_MAX] = { @@ -108,14 +112,15 @@ const char* pslr_white_balance_mode_str[PSLR_WHITE_BALANCE_MODE_MAX] = { "Fluorescent_W", "Tungsten", "Flash", - "Manual", - "0x0A", // ?? - "0x0B", // ?? - "0x0C", // ?? exif: set color temp1 - "0x0D", // ?? exif: set color temp2 - "0xOE", // ?? exif: set color temp3 + "Manual", // sometimes called Manual1 + "Manual2", + "Manual3", + "Kelvin1", + "Kelvin2", + "Kelvin3", "Fluorescent_L", - "CTE" + "CTE", + "MultiAuto" }; const char* pslr_custom_ev_steps_str[PSLR_CUSTOM_EV_STEPS_MAX] = { @@ -134,7 +139,7 @@ const char* pslr_raw_format_str[PSLR_RAW_FORMAT_MAX] = { "DNG" }; -const char* pslr_exposure_submode_str[PSLR_EXPOSURE_SUBMODE_MAX] = { +const char* pslr_scene_mode_str[PSLR_SCENE_MODE_MAX] = { "NONE", "HISPEED", "DOF", @@ -145,7 +150,7 @@ const char* pslr_exposure_submode_str[PSLR_EXPOSURE_SUBMODE_MAX] = { "MACRO", "SPORT", "NIGHTSCENEPORTRAIT", - "NOFLASH", + "NOFLASH",//10 "NIGHTSCENE", "SURFANDSNOW", "TEXT", @@ -154,10 +159,17 @@ const char* pslr_exposure_submode_str[PSLR_EXPOSURE_SUBMODE_MAX] = { "PET", "CANDLELIGHT", "MUSEUM", + "19", // ? "FOOD", "STAGE", "NIGHTSNAP", - "SWALLOWDOF" + "SWALLOWDOF", + "24", // ? + "NIGHTSCENEHDR", + "BLUESKY", + "FOREST", + "28", // ? + "BLACKLIGHTSILHOUETTE" }; @@ -199,12 +211,23 @@ int find_in_array( const char** array, int length, char* str ) { return found_index; } +const char *get_pslr_str( const char** array, int length, int value ) { + if (value >=0 && value < length) { + return array[value]; + } else { + char *ret = malloc(128); + sprintf (ret, "Unknown value: %d", value); + return ret; + } +} + + pslr_color_space_t get_pslr_color_space( char *str ) { return find_in_array( pslr_color_space_str, sizeof(pslr_color_space_str)/sizeof(pslr_color_space_str[0]),str); } const char *get_pslr_color_space_str( pslr_color_space_t value ) { - return pslr_color_space_str[value]; + return get_pslr_str( pslr_color_space_str, sizeof(pslr_color_space_str)/sizeof(pslr_color_space_str[0]),value); } pslr_af_mode_t get_pslr_af_mode( char *str ) { @@ -212,7 +235,7 @@ pslr_af_mode_t get_pslr_af_mode( char *str ) { } const char *get_pslr_af_mode_str( pslr_af_mode_t value ) { - return pslr_af_mode_str[value]; + return get_pslr_str( pslr_af_mode_str, sizeof(pslr_af_mode_str)/sizeof(pslr_af_mode_str[0]),value); } pslr_ae_metering_t get_pslr_ae_metering( char *str ) { @@ -220,7 +243,7 @@ pslr_ae_metering_t get_pslr_ae_metering( char *str ) { } const char *get_pslr_ae_metering_str( pslr_ae_metering_t value ) { - return pslr_ae_metering_str[value]; + return get_pslr_str( pslr_ae_metering_str, sizeof(pslr_ae_metering_str)/sizeof(pslr_ae_metering_str[0]),value); } pslr_flash_mode_t get_pslr_flash_mode( char *str ) { @@ -228,7 +251,7 @@ pslr_flash_mode_t get_pslr_flash_mode( char *str ) { } const char *get_pslr_flash_mode_str( pslr_flash_mode_t value ) { - return pslr_flash_mode_str[value]; + return get_pslr_str( pslr_flash_mode_str, sizeof(pslr_flash_mode_str)/sizeof(pslr_flash_mode_str[0]),value); } pslr_drive_mode_t get_pslr_drive_mode( char *str ) { @@ -236,7 +259,7 @@ pslr_drive_mode_t get_pslr_drive_mode( char *str ) { } const char *get_pslr_drive_mode_str( pslr_drive_mode_t value ) { - return pslr_drive_mode_str[value]; + return get_pslr_str( pslr_drive_mode_str, sizeof(pslr_drive_mode_str)/sizeof(pslr_drive_mode_str[0]),value); } pslr_af_point_sel_t get_pslr_af_point_sel( char *str ) { @@ -244,7 +267,7 @@ pslr_af_point_sel_t get_pslr_af_point_sel( char *str ) { } const char *get_pslr_af_point_sel_str( pslr_af_point_sel_t value ) { - return pslr_af_point_sel_str[value]; + return get_pslr_str( pslr_af_point_sel_str, sizeof(pslr_af_point_sel_str)/sizeof(pslr_af_point_sel_str[0]),value); } pslr_jpeg_image_tone_t get_pslr_jpeg_image_tone( char *str ) { @@ -252,7 +275,7 @@ pslr_jpeg_image_tone_t get_pslr_jpeg_image_tone( char *str ) { } const char *get_pslr_jpeg_image_tone_str( pslr_jpeg_image_tone_t value ) { - return pslr_jpeg_image_tone_str[value]; + return get_pslr_str( pslr_jpeg_image_tone_str, sizeof(pslr_jpeg_image_tone_str)/sizeof(pslr_jpeg_image_tone_str[0]),value); } pslr_white_balance_mode_t get_pslr_white_balance_mode( char *str ) { @@ -260,21 +283,21 @@ pslr_white_balance_mode_t get_pslr_white_balance_mode( char *str ) { } const char *get_pslr_white_balance_mode_str( pslr_white_balance_mode_t value ) { - return pslr_white_balance_mode_str[value]; + return get_pslr_str( pslr_white_balance_mode_str, sizeof(pslr_white_balance_mode_str)/sizeof(pslr_white_balance_mode_str[0]),value); } const char *get_pslr_custom_ev_steps_str( pslr_custom_ev_steps_t value ) { - return pslr_custom_ev_steps_str[value]; + return get_pslr_str( pslr_custom_ev_steps_str, sizeof(pslr_custom_ev_steps_str)/sizeof(pslr_custom_ev_steps_str[0]),value); } const char *get_pslr_image_format_str( pslr_image_format_t value ) { - return pslr_image_format_str[value]; + return get_pslr_str( pslr_image_format_str, sizeof(pslr_image_format_str)/sizeof(pslr_image_format_str[0]),value); } const char *get_pslr_raw_format_str( pslr_raw_format_t value ) { - return pslr_raw_format_str[value]; + return get_pslr_str( pslr_raw_format_str, sizeof(pslr_raw_format_str)/sizeof(pslr_raw_format_str[0]),value); } -const char *get_pslr_exposure_submode_str( pslr_exposure_submode_t value ) { - return pslr_exposure_submode_str[value]; +const char *get_pslr_scene_mode_str( pslr_scene_mode_t value ) { + return get_pslr_str( pslr_scene_mode_str, sizeof(pslr_scene_mode_str)/sizeof(pslr_scene_mode_str[0]),value); } diff --git a/camlibs/pentax/pslr_enum.h b/camlibs/pentax/pslr_enum.h index bce84894d..9d8c5eb87 100644 --- a/camlibs/pentax/pslr_enum.h +++ b/camlibs/pentax/pslr_enum.h @@ -94,6 +94,9 @@ typedef enum { PSLR_JPEG_IMAGE_TONE_REVERSAL_FILM, PSLR_JPEG_IMAGE_TONE_BLEACH_BYPASS, PSLR_JPEG_IMAGE_TONE_RADIANT, + PSLR_JPEG_IMAGE_TONE_CROSS_PROCESSING, + PSLR_JPEG_IMAGE_TONE_FLAT, + PSLR_JPEG_IMAGE_TONE_AUTO, PSLR_JPEG_IMAGE_TONE_MAX } pslr_jpeg_image_tone_t; @@ -108,10 +111,15 @@ typedef enum { PSLR_WHITE_BALANCE_MODE_TUNGSTEN, PSLR_WHITE_BALANCE_MODE_FLASH, PSLR_WHITE_BALANCE_MODE_MANUAL, - // a few items are missing here - PSLR_WHITE_BALANCE_MODE_FLUORESCENT_WARM_WHITE = 0x0F, - PSLR_WHITE_BALANCE_MODE_CTE = 0x10, - PSLR_WHITE_BALANCE_MODE_MAX = 0x11 + PSLR_WHITE_BALANCE_MODE_MANUAL_2, + PSLR_WHITE_BALANCE_MODE_MANUAL_3, + PSLR_WHITE_BALANCE_MODE_KELVIN_1, + PSLR_WHITE_BALANCE_MODE_KELVIN_2, + PSLR_WHITE_BALANCE_MODE_KELVIN_3, + PSLR_WHITE_BALANCE_MODE_FLUORESCENT_WARM_WHITE, + PSLR_WHITE_BALANCE_MODE_CTE, + PSLR_WHITE_BALANCE_MODE_MULTI_AUTO, + PSLR_WHITE_BALANCE_MODE_MAX } pslr_white_balance_mode_t; typedef enum { @@ -134,31 +142,38 @@ typedef enum { } pslr_raw_format_t; typedef enum { - PSLR_EXPOSURE_SUBMODE_NONE, - PSLR_EXPOSURE_SUBMODE_HISPEED, - PSLR_EXPOSURE_SUBMODE_DOF, - PSLR_EXPOSURE_SUBMODE_MTF, - PSLR_EXPOSURE_SUBMODE_STANDARD, - PSLR_EXPOSURE_SUBMODE_PORTRAIT, - PSLR_EXPOSURE_SUBMODE_LANDSCAPE, - PSLR_EXPOSURE_SUBMODE_MACRO, - PSLR_EXPOSURE_SUBMODE_SPORT, - PSLR_EXPOSURE_SUBMODE_NIGHTSCENEPORTRAIT, - PSLR_EXPOSURE_SUBMODE_NOFLASH, - PSLR_EXPOSURE_SUBMODE_NIGHTSCENE, - PSLR_EXPOSURE_SUBMODE_SURFANDSNOW, - PSLR_EXPOSURE_SUBMODE_TEXT, - PSLR_EXPOSURE_SUBMODE_SUNSET, - PSLR_EXPOSURE_SUBMODE_KIDS, - PSLR_EXPOSURE_SUBMODE_PET, - PSLR_EXPOSURE_SUBMODE_CANDLELIGHT, - PSLR_EXPOSURE_SUBMODE_MUSEUM, - PSLR_EXPOSURE_SUBMODE_FOOD, - PSLR_EXPOSURE_SUBMODE_STAGE, - PSLR_EXPOSURE_SUBMODE_NIGHTSNAP, - PSLR_EXPOSURE_SUBMODE_SWALLOWDOF, - PSLR_EXPOSURE_SUBMODE_MAX -} pslr_exposure_submode_t; + PSLR_SCENE_MODE_NONE, + PSLR_SCENE_MODE_HISPEED, + PSLR_SCENE_MODE_DOF, + PSLR_SCENE_MODE_MTF, + PSLR_SCENE_MODE_STANDARD, + PSLR_SCENE_MODE_PORTRAIT, + PSLR_SCENE_MODE_LANDSCAPE, + PSLR_SCENE_MODE_MACRO, + PSLR_SCENE_MODE_SPORT, + PSLR_SCENE_MODE_NIGHTSCENEPORTRAIT, + PSLR_SCENE_MODE_NOFLASH, + PSLR_SCENE_MODE_NIGHTSCENE, + PSLR_SCENE_MODE_SURFANDSNOW, + PSLR_SCENE_MODE_TEXT, + PSLR_SCENE_MODE_SUNSET, + PSLR_SCENE_MODE_KIDS, + PSLR_SCENE_MODE_PET, + PSLR_SCENE_MODE_CANDLELIGHT, + PSLR_SCENE_MODE_MUSEUM, + PSLR_SCENE_MODE_19, + PSLR_SCENE_MODE_FOOD, + PSLR_SCENE_MODE_STAGE, + PSLR_SCENE_MODE_NIGHTSNAP, + PSLR_SCENE_MODE_SWALLOWDOF, + PSLR_SCENE_MODE_24, + PSLR_SCENE_MODE_NIGHTSCENEHDR, + PSLR_SCENE_MODE_BLUESKY, + PSLR_SCENE_MODE_FOREST, + PSLR_SCENE_MODE_28, + PSLR_SCENE_MODE_BLACKLIGHTSILHOUETTE, + PSLR_SCENE_MODE_MAX +} pslr_scene_mode_t; int str_comparison_i (const char *s1, const char *s2, int n); int find_in_array( const char** array, int length, char* str ); @@ -194,6 +209,6 @@ const char *get_pslr_image_format_str( pslr_image_format_t value ); const char *get_pslr_raw_format_str( pslr_raw_format_t value ); -const char *get_pslr_exposure_submode_str( pslr_exposure_submode_t value ); +const char *get_pslr_scene_mode_str( pslr_scene_mode_t value ); #endif diff --git a/camlibs/pentax/pslr_model.c b/camlibs/pentax/pslr_model.c index c96012978..0c1fabbf5 100644 --- a/camlibs/pentax/pslr_model.c +++ b/camlibs/pentax/pslr_model.c @@ -117,7 +117,7 @@ void set_uint32_be(uint32_t v, uint8_t *buf) { } char *shexdump(uint8_t *buf, uint32_t bufLen) { - char *ret = malloc(2000); + char *ret = malloc(4*bufLen); uint32_t i; sprintf(ret,"%s",""); for (i = 0; i < bufLen; i++) { @@ -150,6 +150,21 @@ void hexdump_debug(uint8_t *buf, uint32_t bufLen) { free(dmp); } + +// based on http://stackoverflow.com/a/657202/21348 + +const char* int_to_binary( uint16_t x ) { + static char b[sizeof(uint16_t)*8+1] = {0}; + int y; + long long z; + for (z=(1LL<<sizeof(uint16_t)*8)-1,y=0; z>0; z>>=1,y++) { + b[y] = ( ((x & z) == z) ? '1' : '0'); + } + b[y] = 0; + return b; +} + + int _get_user_jpeg_stars( ipslr_model_info_t *model, int hwqual ) { if ( model->id == 0x12f71 ) { // K5IIs hack @@ -348,7 +363,7 @@ void ipslr_status_parse_common(ipslr_handle_t *p, pslr_status *status, int shift status->custom_ev_steps = (*get_uint32_func_ptr)(&buf[0xA4 + shift]); status->custom_sensitivity_steps = (*get_uint32_func_ptr)(&buf[0xa8 + shift]); status->exposure_mode = (*get_uint32_func_ptr)(&buf[0xb4 + shift]); - status->exposure_submode = (*get_uint32_func_ptr)(&buf[0xb8 + shift]); + status->scene_mode = (*get_uint32_func_ptr)(&buf[0xb8 + shift]); status->ae_metering_mode = (*get_uint32_func_ptr)(&buf[0xbc + shift]); // same as cc status->af_mode = (*get_uint32_func_ptr)(&buf[0xC0 + shift]); status->af_point_select = (*get_uint32_func_ptr)(&buf[0xc4 + shift]); @@ -616,7 +631,11 @@ void ipslr_status_parse_k70(ipslr_handle_t *p, pslr_status *status) { status->lens_max_aperture.denom = get_uint32_le(&buf[0x154]); status->manual_mode_ev = get_uint32_le(&buf[0x160]); // ? status->focused_af_point = get_uint32_le(&buf[0x16c]); // ? - // battery fields? + + status->battery_1 = get_uint32_le(&buf[0x174]); + status->battery_2 = get_uint32_le(&buf[0x178]); + status->battery_3 = 0; + status->battery_4 = 0; // selected_af_point is invalid status->selected_af_point = 0; @@ -703,7 +722,7 @@ ipslr_model_info_t camera_models[] = { { 0x12fb6, "K-50", 0, 1, 0, 452, 4, {16, 12, 8, 5}, 9, 6000, 100, 51200, 100, 51200, PSLR_JPEG_IMAGE_TONE_BLEACH_BYPASS, 1, 11, ipslr_status_parse_k50 }, { 0x12fc0, "K-3" , 0, 1, 1, 452, 4, {24, 14, 6, 2}, 9, 8000, 100, 51200, 100, 51200, PSLR_JPEG_IMAGE_TONE_BLEACH_BYPASS, 1, 27, ipslr_status_parse_k3 }, { 0x1309c, "K-3II" , 0, 1, 1, 452, 4, {24, 14, 6, 2}, 9, 8000, 100, 51200, 100, 51200, PSLR_JPEG_IMAGE_TONE_BLEACH_BYPASS, 1, 27, ipslr_status_parse_k3 }, - { 0x12fca, "K-500", 0, 1, 0, 452, 3, {16, 12, 8, 5}, 9, 6000, 100, 51200, 100, 51200, PSLR_JPEG_IMAGE_TONE_RADIANT, 1, 11, ipslr_status_parse_k500 }, + { 0x12fca, "K-500", 0, 1, 0, 452, 3, {16, 12, 8, 5}, 9, 6000, 100, 51200, 100, 51200, PSLR_JPEG_IMAGE_TONE_CROSS_PROCESSING, 1, 11, ipslr_status_parse_k500 }, // only limited support from here { 0x12994, "*ist D", 1, 1, 0, 0, 3, {6, 4, 2}, 3, 4000, 200, 3200, 200, 3200, PSLR_JPEG_IMAGE_TONE_NONE , 0, 11, NULL}, // buffersize: 264 { 0x12b60, "*ist DS2", 1, 1, 0, 0, 3, {6, 4, 2}, 5, 4000, 200, 3200, 200, 3200, PSLR_JPEG_IMAGE_TONE_BRIGHT, 0, 11, NULL}, @@ -712,20 +731,20 @@ ipslr_model_info_t camera_models[] = { { 0x12b9d, "K110D", 0, 1, 0, 0, 3, {6, 4, 2}, 5, 4000, 200, 3200, 200, 3200, PSLR_JPEG_IMAGE_TONE_BRIGHT, 0, 11, NULL}, { 0x12b9c, "K100D", 1, 1, 0, 0, 3, {6, 4, 2}, 5, 4000, 200, 3200, 200, 3200, PSLR_JPEG_IMAGE_TONE_BRIGHT, 0, 11, NULL}, { 0x12ba2, "K100D Super", 1, 1, 0, 0, 3, {6, 4, 2}, 5, 4000, 200, 3200, 200, 3200, PSLR_JPEG_IMAGE_TONE_BRIGHT, 0, 11, NULL}, - { 0x1301a, "K-S1", 0, 1, 1, 452, 3, {20, 12, 6, 2}, 9, 6000, 100, 51200, 100, 51200, PSLR_JPEG_IMAGE_TONE_BLEACH_BYPASS, 1, 11, ipslr_status_parse_ks1 }, - { 0x13024, "K-S2", 0, 1, 1, 452, 3, {20, 12, 6, 2}, 9, 6000, 100, 51200, 100, 51200, PSLR_JPEG_IMAGE_TONE_BLEACH_BYPASS, 1, 11, ipslr_status_parse_k3 }, - { 0x13092, "K-1", 0, 1, 1, 456, 3, {36, 22, 12, 2}, 9, 8000, 100, 204800, 100, 204800, PSLR_JPEG_IMAGE_TONE_RADIANT, 1, 33, ipslr_status_parse_k1 }, - { 0x13222, "K-70", 0, 1, 1, 456, 3, {24, 14, 6, 2}, 9, 6000, 100, 102400, 100, 102400, PSLR_JPEG_IMAGE_TONE_RADIANT, 1, 11, ipslr_status_parse_k70 } + { 0x1301a, "K-S1", 0, 1, 1, 452, 3, {20, 12, 6, 2}, 9, 6000, 100, 51200, 100, 51200, PSLR_JPEG_IMAGE_TONE_CROSS_PROCESSING, 1, 11, ipslr_status_parse_ks1 }, + { 0x13024, "K-S2", 0, 1, 1, 452, 3, {20, 12, 6, 2}, 9, 6000, 100, 51200, 100, 51200, PSLR_JPEG_IMAGE_TONE_CROSS_PROCESSING, 1, 11, ipslr_status_parse_k3 }, + { 0x13092, "K-1", 0, 1, 1, 456, 3, {36, 22, 12, 2}, 9, 8000, 100, 204800, 100, 204800, PSLR_JPEG_IMAGE_TONE_FLAT, 1, 33, ipslr_status_parse_k1 }, + { 0x13222, "K-70", 0, 1, 1, 456, 3, {24, 14, 6, 2}, 9, 6000, 100, 102400, 100, 102400, PSLR_JPEG_IMAGE_TONE_AUTO, 1, 11, ipslr_status_parse_k70 } }; ipslr_model_info_t *find_model_by_id( uint32_t id ) { int i; for ( i = 0; i<sizeof (camera_models) / sizeof (camera_models[0]); i++) { if ( camera_models[i].id == id ) { - DPRINT("found %d\n",i); + // DPRINT("found %d\n",i); return &camera_models[i]; } } - DPRINT("not found\n"); + // DPRINT("not found\n"); return NULL; } diff --git a/camlibs/pentax/pslr_model.h b/camlibs/pentax/pslr_model.h index 4f14f499f..1524d7303 100644 --- a/camlibs/pentax/pslr_model.h +++ b/camlibs/pentax/pslr_model.h @@ -80,7 +80,7 @@ typedef struct { uint32_t custom_ev_steps; uint32_t custom_sensitivity_steps; uint32_t exposure_mode; - uint32_t exposure_submode; + uint32_t scene_mode; uint32_t user_mode_flag; uint32_t ae_metering_mode; uint32_t af_mode; @@ -162,5 +162,6 @@ typedef int32_t (*get_int32_func)(uint8_t *buf); char *shexdump(uint8_t *buf, uint32_t bufLen); void hexdump(uint8_t *buf, uint32_t bufLen); void hexdump_debug(uint8_t *buf, uint32_t bufLen); +const char* int_to_binary( uint16_t x ); #endif |