diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index 8a7a3ba3d..06bde93a5 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -8897,6 +8897,383 @@ struct { { N_("Automatic Warm"), 0x8015 }, }; +static int +_put_Panasonic_AdjustGM(CONFIG_PUT_ARGS) +{ + PTPParams *params = &(camera->pl->params); + char *xval; + uint32_t val; + + CR (gp_widget_get_value(widget, &xval)); + int16_t adj; + sscanf (xval, "%hd", &adj); + if (adj < 0) { + adj = abs(adj) + 0x8000; + } + val = adj; + + return translate_ptp_result (ptp_panasonic_setdeviceproperty(params, PTP_DPC_PANASONIC_WhiteBalance_ADJ_GM, (unsigned char*)&val, 2)); +} + +static int +_get_Panasonic_AdjustGM(CONFIG_GET_ARGS) { + uint32_t currentVal = 0; + char buf[32]; + PTPParams *params = &(camera->pl->params); + GPContext *context = ((PTPData *) params->data)->context; + + uint16_t valsize; + C_PTP_REP (ptp_panasonic_getdeviceproperty(params, PTP_DPC_PANASONIC_WhiteBalance_ADJ_GM, &valsize, ¤tVal)); + + //printf("retrieved %x with size %x\n", currentVal, valsize); + if (currentVal & 0x8000) { + currentVal = (currentVal & 0x7FFF) * -1; + } + sprintf(buf, "%d\n", currentVal); + + gp_widget_new (GP_WIDGET_RADIO, _(menu->label), widget); + gp_widget_set_name (*widget, menu->name); + + gp_widget_set_value(*widget, &buf); + return GP_OK; +} + +static int +_put_Panasonic_AdjustAB(CONFIG_PUT_ARGS) +{ + PTPParams *params = &(camera->pl->params); + char *xval; + uint32_t val; + + CR (gp_widget_get_value(widget, &xval)); + int16_t adj; + sscanf (xval, "%hd", &adj); + if (adj < 0) { + adj = abs(adj) + 0x8000; + } + val = adj; + + return translate_ptp_result (ptp_panasonic_setdeviceproperty(params, PTP_DPC_PANASONIC_WhiteBalance_ADJ_AB, (unsigned char*)&val, 2)); +} + +static int +_get_Panasonic_AdjustAB(CONFIG_GET_ARGS) { + uint32_t currentVal = 0; + char buf[32]; + PTPParams *params = &(camera->pl->params); + GPContext *context = ((PTPData *) params->data)->context; + + uint16_t valsize; + C_PTP_REP (ptp_panasonic_getdeviceproperty(params, PTP_DPC_PANASONIC_WhiteBalance_ADJ_AB, &valsize, ¤tVal)); + + //printf("retrieved %x with size %x\n", currentVal, valsize); + if (currentVal & 0x8000) { + currentVal = (currentVal & 0x7FFF) * -1; + } + sprintf(buf, "%d\n", currentVal); + + gp_widget_new (GP_WIDGET_RADIO, _(menu->label), widget); + gp_widget_set_name (*widget, menu->name); + + gp_widget_set_value(*widget, &buf); + return GP_OK; +} + +static int +_put_Panasonic_ColorTemp(CONFIG_PUT_ARGS) +{ + PTPParams *params = &(camera->pl->params); + char *xval; + uint32_t val; + + CR (gp_widget_get_value(widget, &xval)); + uint16_t KSet;; + sscanf (xval, "%hd", &KSet); + val = KSet; + + return translate_ptp_result (ptp_panasonic_setdeviceproperty(params, PTP_DPC_PANASONIC_WhiteBalance_KSet, (unsigned char*)&val, 2)); +} + +static int +_get_Panasonic_ColorTemp(CONFIG_GET_ARGS) { + uint32_t currentVal; + uint32_t listCount; + uint32_t *list; + uint32_t i; + int valset = 0; + char buf[32]; + PTPParams *params = &(camera->pl->params); + GPContext *context = ((PTPData *) params->data)->context; + + C_PTP_REP (ptp_panasonic_getdevicepropertydesc(params, PTP_DPC_PANASONIC_WhiteBalance_KSet, 2, ¤tVal, &list, &listCount)); + + //printf("retrieved %lu property values\n", listCount); + + gp_widget_new (GP_WIDGET_RADIO, _(menu->label), widget); + gp_widget_set_name (*widget, menu->name); + + for (i = 0; i < listCount; i++) { + sprintf(buf,_("%d"), list[i]); + if (list[i] == currentVal) { + gp_widget_set_value (*widget, buf); + valset = 1; + } + + gp_widget_add_choice (*widget, buf); + } + free(list); + if (!valset) { + sprintf(buf,_("Unknown 0x%04x"), currentVal); + gp_widget_set_value (*widget, buf); + } + return GP_OK; +} + +static +struct { + char* str; + uint16_t val; +} panasonic_aftable[] = { + { N_("AF"), 0x0000 }, + { N_("AF macro"), 0x0001 }, + { N_("AF macro (D)"), 0x0002 }, + { N_("MF"), 0x0003 }, + { N_("AF_S"), 0x0004 }, + { N_("AF_C"), 0x0005 }, + { N_("AF_F"), 0x0006 }, +}; + +static int +_put_Panasonic_AFMode(CONFIG_PUT_ARGS) +{ + PTPParams *params = &(camera->pl->params); + char *xval; + uint32_t val; + uint32_t i; + + CR (gp_widget_get_value(widget, &xval)); + + for (i=0;ipl->params); + GPContext *context = ((PTPData *) params->data)->context; + + C_PTP_REP (ptp_panasonic_getdevicepropertydesc(params, PTP_DPC_PANASONIC_AFArea_AFModeParam, 2, ¤tVal, &list, &listCount)); + + //printf("retrieved %lu property values\n", listCount); + + gp_widget_new (GP_WIDGET_RADIO, _(menu->label), widget); + gp_widget_set_name (*widget, menu->name); + + for (i = 0; i < listCount; i++) { + for (j=0;jpl->params); + char *xval; + uint32_t val = 0; + uint32_t i; + + CR (gp_widget_get_value(widget, &xval)); + for (i=0;ilabel), widget); + gp_widget_set_name (*widget,menu->name); + + for (i=0;ipl->params); + GPContext *context = ((PTPData *) params->data)->context; + + C_PTP_REP (ptp_panasonic_getdevicepropertydesc(params, 0x06000011, 2, ¤tVal, &list, &listCount)); + + //printf("retrieved %lu property values\n", listCount); + + gp_widget_new (GP_WIDGET_RADIO, _(menu->label), widget); + gp_widget_set_name (*widget, menu->name); + + for (j=0;jpl->params); + char *xval; + uint32_t val = 0; + uint32_t i; + + CR (gp_widget_get_value(widget, &xval)); + for (i=0;ipl->params); + GPContext *context = ((PTPData *) params->data)->context; + + uint16_t valsize; + C_PTP_REP (ptp_panasonic_getrecordingstatus(params, 0x12000013, &valsize, ¤tVal)); + + gp_widget_new (GP_WIDGET_RADIO, _(menu->label), widget); + gp_widget_set_name (*widget, menu->name); + + for(i = 0; i < sizeof(panasonic_recordtable) / sizeof(panasonic_recordtable[0]); i++) { + if (currentVal == panasonic_recordtable[i].val) { + strcpy(buf, panasonic_recordtable[i].str); + } + } + + gp_widget_set_value(*widget, &buf); + return GP_OK; +} + + static int +_put_Panasonic_Recording(CONFIG_PUT_ARGS) +{ + PTPParams *params = &(camera->pl->params); + char *xval; + uint32_t val = 0; + uint32_t i; + + CR (gp_widget_get_value(widget, &xval)); + if (!strcmp(xval, "start")) { + return translate_ptp_result (ptp_panasonic_startrecording(params)); + } else if (!strcmp(xval, "stop")) { + return translate_ptp_result (ptp_panasonic_stoprecording(params)); + } else { + return GP_ERROR; + } +} + static int _put_Panasonic_Whitebalance(CONFIG_PUT_ARGS) { @@ -8925,7 +9302,7 @@ _put_Panasonic_Whitebalance(CONFIG_PUT_ARGS) } /* free(list); */ GP_LOG_D("setting whitebalance to 0x%04x", val); - return translate_ptp_result (ptp_panasonic_setdeviceproperty(params, PTP_DPC_PANASONIC_WhiteBalance, (unsigned char*)&val, 2)); + return translate_ptp_result (ptp_panasonic_setdeviceproperty(params, PTP_DPC_PANASONIC_WhiteBalance_Param, (unsigned char*)&val, 2)); } static int @@ -8939,7 +9316,7 @@ _get_Panasonic_Whitebalance(CONFIG_GET_ARGS) { PTPParams *params = &(camera->pl->params); GPContext *context = ((PTPData *) params->data)->context; - C_PTP_REP (ptp_panasonic_getdevicepropertydesc(params, PTP_DPC_PANASONIC_WhiteBalance, 2, ¤tVal, &list, &listCount)); + C_PTP_REP (ptp_panasonic_getdevicepropertydesc(params, PTP_DPC_PANASONIC_WhiteBalance_Param, 2, ¤tVal, &list, &listCount)); //printf("retrieved %lu property values\n", listCount); @@ -8984,7 +9361,7 @@ _put_Panasonic_Exposure(CONFIG_PUT_ARGS) val = (uint32_t)(0x8000 | (int)(((-f)*3))); else val = (uint32_t) (f*3); - return translate_ptp_result (ptp_panasonic_setdeviceproperty(params, PTP_DPC_PANASONIC_Exposure, (unsigned char*)&val, 2)); + return translate_ptp_result (ptp_panasonic_setdeviceproperty(params, PTP_DPC_PANASONIC_Exposure_Param, (unsigned char*)&val, 2)); } static int @@ -9011,11 +9388,13 @@ _get_Panasonic_Exposure(CONFIG_GET_ARGS) { val = -(val & 0x7fff); sprintf (buf, "%f", val/3.0); gp_widget_add_choice (*widget, buf); + if ((int)list[i] == (int)currentVal) { + sprintf (buf, "%f", val/3.0); + gp_widget_set_value (*widget, &buf); + } } free(list); - sprintf (buf, "%f", (float)currentVal); - gp_widget_set_value (*widget, &buf); return GP_OK; } @@ -10259,6 +10638,13 @@ static struct submenu capture_settings_menu[] = { { N_("Exposure Compensation"), "exposurecompensation", PTP_DPC_CANON_EOS_ExpCompensation, PTP_VENDOR_CANON, PTP_DTC_UINT8, _get_Canon_ExpCompensation2, _put_Canon_ExpCompensation2 }, { N_("Exposure Compensation"), "exposurecompensation", 0, PTP_VENDOR_PANASONIC, PTP_DTC_INT32, _get_Panasonic_Exposure, _put_Panasonic_Exposure }, { N_("White Balance"), "whitebalance", 0, PTP_VENDOR_PANASONIC, PTP_DTC_INT32, _get_Panasonic_Whitebalance, _put_Panasonic_Whitebalance }, + { N_("Color temperature"), "colortemperature", 0, PTP_VENDOR_PANASONIC, PTP_DTC_INT32, _get_Panasonic_ColorTemp, _put_Panasonic_ColorTemp }, + { N_("Adjust A/B"), "whitebalanceadjustab", 0, PTP_VENDOR_PANASONIC, PTP_DTC_INT32, _get_Panasonic_AdjustAB, _put_Panasonic_AdjustAB }, + { N_("Adjust G/M"), "whitebalanceadjustgm", 0, PTP_VENDOR_PANASONIC, PTP_DTC_INT32, _get_Panasonic_AdjustGM, _put_Panasonic_AdjustGM }, + { N_("AF Mode"), "afmode", 0, PTP_VENDOR_PANASONIC, PTP_DTC_INT32, _get_Panasonic_AFMode, _put_Panasonic_AFMode }, + { N_("MF Adjust"), "mfadjust", 0, PTP_VENDOR_PANASONIC, PTP_DTC_INT32, _get_Panasonic_MFAdjust, _put_Panasonic_MFAdjust }, + { N_("Exp mode"), "expmode", 0, PTP_VENDOR_PANASONIC, PTP_DTC_INT32, _get_Panasonic_ExpMode, _put_Panasonic_ExpMode }, + { N_("Start/Stop recording"), "recording", 0, PTP_VENDOR_PANASONIC, PTP_DTC_INT32, _get_Panasonic_Recording, _put_Panasonic_Recording }, /* these cameras also have PTP_DPC_ExposureBiasCompensation, avoid overlap */ { N_("Exposure Compensation"), "exposurecompensation2", PTP_DPC_NIKON_ExposureCompensation, PTP_VENDOR_NIKON, PTP_DTC_UINT8, _get_Nikon_OnOff_UINT8, _put_Nikon_OnOff_UINT8 }, { N_("Flash Compensation"), "flashcompensation", PTP_DPC_CANON_FlashCompensation, PTP_VENDOR_CANON, PTP_DTC_UINT8, _get_Canon_ExpCompensation, _put_Canon_ExpCompensation }, diff --git a/camlibs/ptp2/ptp.c b/camlibs/ptp2/ptp.c index 85f8470fc..09b55c1b0 100644 --- a/camlibs/ptp2/ptp.c +++ b/camlibs/ptp2/ptp.c @@ -1604,6 +1604,55 @@ ptp_panasonic_manualfocusdrive (PTPParams* params, uint16_t mode) return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, sizeof(data), &xdata, NULL); } +uint16_t +ptp_panasonic_recordmode (PTPParams* params, uint16_t mode) +{ + PTPContainer ptp; + unsigned char data[10]; + unsigned char *xdata = data; + uint32_t propcode = 0x06000011; + uint32_t type = 2; + + htod32a(data, propcode); /* memcpy(data, &propcode, 4); */ + htod32a(&data[4], type); /* memcpy(&data[4], &type, 4); */ + htod16a(&data[8], mode); /* memcpy(&data[8], &mode, 2); */ + + PTP_CNT_INIT(ptp, PTP_OC_PANASONIC_9409, propcode); + return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, sizeof(data), &xdata, NULL); +} + +uint16_t +ptp_panasonic_startrecording (PTPParams* params) +{ + PTPContainer ptp; + unsigned char data[8]; + unsigned char *xdata = data; + uint32_t propcode = 0x07000011; + uint32_t type = 0; + + htod32a(data, propcode); /* memcpy(data, &propcode, 4); */ + htod32a(&data[4], type); /* memcpy(&data[4], &type, 4); */ + + PTP_CNT_INIT(ptp, PTP_OC_PANASONIC_MovieRecControl, propcode); + return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, sizeof(data), &xdata, NULL); +} + +uint16_t +ptp_panasonic_stoprecording (PTPParams* params) +{ + PTPContainer ptp; + unsigned char data[8]; + unsigned char *xdata = data; + uint32_t propcode = 0x07000012; + uint32_t type = 0; + + htod32a(data, propcode); /* memcpy(data, &propcode, 4); */ + htod32a(&data[4], type); /* memcpy(&data[4], &type, 4); */ + + PTP_CNT_INIT(ptp, PTP_OC_PANASONIC_MovieRecControl, propcode); + return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, sizeof(data), &xdata, NULL); +} + uint16_t ptp_panasonic_getcapturetarget (PTPParams* params, uint16_t *target) { @@ -1706,6 +1755,34 @@ ptp_panasonic_getdevicepropertydesc (PTPParams *params, uint32_t propcode, uint1 return ret; } + uint16_t +ptp_panasonic_getrecordingstatus (PTPParams *params, uint32_t propcode, uint16_t *valuesize, uint32_t *currentValue) +{ + PTPContainer ptp; + unsigned char *data = NULL; + unsigned int size = 0; + uint16_t ret = PTP_RC_OK; + + PTP_CNT_INIT(ptp, PTP_OC_PANASONIC_PollEvents, propcode); + CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size)); + if (!data) return PTP_RC_GeneralError; + + if(size < 8) return PTP_RC_GeneralError; + *valuesize = dtoh32a( (data + 4) ); + + if(size < 8u + (*valuesize)) return PTP_RC_GeneralError; + if(*valuesize == 4) { + *currentValue = dtoh32a( (data + 8) ); + } else if(*valuesize == 2) { + *currentValue = (uint32_t) dtoh16a( (data + 8) ); + } else { + return PTP_RC_GeneralError; + } + //printf("ptp_panasonic_getdeviceproperty: size: %lu, valuesize: %d, currentValue: %lu\n", size, *valuesize, *currentValue); + + free (data); + return ret; +} uint16_t ptp_panasonic_getdeviceproperty (PTPParams *params, uint32_t propcode, uint16_t *valuesize, uint32_t *currentValue) diff --git a/camlibs/ptp2/ptp.h b/camlibs/ptp2/ptp.h index c4f90ef64..8f0e03529 100644 --- a/camlibs/ptp2/ptp.h +++ b/camlibs/ptp2/ptp.h @@ -4792,11 +4792,15 @@ uint16_t ptp_panasonic_liveview_image (PTPParams* params, unsigned char **data, uint16_t ptp_panasonic_setdeviceproperty (PTPParams* params, uint32_t propcode, unsigned char *value, uint16_t valuesize); uint16_t ptp_panasonic_getdeviceproperty (PTPParams *params, uint32_t propcode, uint16_t *valuesize, uint32_t *currentValue); +uint16_t ptp_panasonic_getrecordingstatus (PTPParams *params, uint32_t propcode, uint16_t *valuesize, uint32_t *currentValue); uint16_t ptp_panasonic_getdevicepropertydesc (PTPParams *params, uint32_t propcode, uint16_t valuesize, uint32_t *currentValue, uint32_t **propertyValueList, uint32_t *propertyValueListLength); uint16_t ptp_panasonic_getdevicepropertysize (PTPParams *params, uint32_t propcode); uint16_t ptp_panasonic_getcapturetarget (PTPParams *params, uint16_t *target); uint16_t ptp_panasonic_setcapturetarget (PTPParams *params, uint16_t target); uint16_t ptp_panasonic_manualfocusdrive (PTPParams* params, uint16_t mode); +uint16_t ptp_panasonic_recordmode (PTPParams* params, uint16_t mode); +uint16_t ptp_panasonic_startrecording (PTPParams* params); +uint16_t ptp_panasonic_stoprecording (PTPParams* params); uint16_t ptp_panasonic_9401 (PTPParams* params, uint32_t x); uint16_t ptp_panasonic_9414_0d800012 (PTPParams* params, PanasonicLiveViewSize **liveviewsizes, unsigned int *nrofliveviewsizes);