Removed more byteorder stuff. Removed driver product/venodr models.
(Class detection should provide proper endpoints -- NOT TESTED yet) git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@3701 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -2,22 +2,4 @@ This is libptp2!
|
||||
|
||||
This library is under developement yet.
|
||||
|
||||
Attached example program allows downloading pictures from camera.
|
||||
To build download and instal libusb (libusb.sf.net), then type:
|
||||
make
|
||||
|
||||
After proper building you can use example program as follows:
|
||||
./dx3500 vendorID ProductID
|
||||
|
||||
To obtain vendorID and ProductID read your dmesg.
|
||||
For example:
|
||||
|
||||
# dmesg
|
||||
(...)
|
||||
Product: KODAK DX3500 Digital Camera
|
||||
usb.c: unhandled interfaces on device
|
||||
usb.c: USB device 65 (vend/prod 0x40a/0x500) is not claimed by any active driver
|
||||
|
||||
vendorID=0x40a, productID=0x500;
|
||||
|
||||
Enjoy!
|
||||
|
||||
@@ -167,8 +167,8 @@ static struct {
|
||||
unsigned short usb_vendor;
|
||||
unsigned short usb_product;
|
||||
} models[] = {
|
||||
{"Kodak DC-240 (PTP)", 0x040a, 0x0121}, /* Special firmware */
|
||||
{"Kodak DC-4800", 0x040a, 0x0160},
|
||||
// {"Kodak DC-240 (PTP)", 0x040a, 0x0121}, /* Special firmware */
|
||||
/* {"Kodak DC-4800", 0x040a, 0x0160},
|
||||
{"Kodak DC-3215", 0x040a, 0x0525},
|
||||
{"Kodak DX-3500", 0x040a, 0x0500},
|
||||
{"Kodak DX-3600", 0x040a, 0x0510},
|
||||
@@ -178,7 +178,7 @@ static struct {
|
||||
{"Sony DSC-P5", 0, 0},
|
||||
{"Sony DSC-F707", 0x054c, 0x004e},
|
||||
{"HP PhotoSmart 318", 0x03f0, 0x6302},
|
||||
{NULL, 0, 0}
|
||||
*/ {NULL, 0, 0}
|
||||
};
|
||||
|
||||
static struct {
|
||||
@@ -258,7 +258,6 @@ ptp_read_func (unsigned char *bytes, unsigned int size, void *data)
|
||||
* read. libptp doesn't need that.
|
||||
*/
|
||||
result = gp_port_read (camera->port, bytes, size);
|
||||
// returned value is little endian
|
||||
if (result==0) result = gp_port_read (camera->port, bytes, size);
|
||||
if (result >= 0)
|
||||
return (PTP_RC_OK);
|
||||
@@ -277,7 +276,6 @@ ptp_write_func (unsigned char *bytes, unsigned int size, void *data)
|
||||
* write. libptp doesn't need that.
|
||||
*/
|
||||
result = gp_port_write (camera->port, bytes, size);
|
||||
// returned value is little endian
|
||||
if (result >= 0)
|
||||
return (PTP_RC_OK);
|
||||
else
|
||||
@@ -415,7 +413,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
|
||||
if ((ptp_objectinfo.ObjectFormat & 0x0800) == 0) return (GP_OK);
|
||||
switch (type) {
|
||||
case GP_FILE_TYPE_NORMAL:
|
||||
size=le32toh(ptp_objectinfo.ObjectCompressedSize);
|
||||
size=ptp_objectinfo.ObjectCompressedSize;
|
||||
fdata=malloc(size+PTP_REQ_HDR_LEN);
|
||||
CPR_free (camera, ptp_getobject(&camera->pl->params,
|
||||
camera->pl->params.handles.handler[image_id],
|
||||
@@ -429,7 +427,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
|
||||
break;
|
||||
|
||||
case GP_FILE_TYPE_PREVIEW:
|
||||
size=le32toh(ptp_objectinfo.ThumbCompressedSize);
|
||||
size=ptp_objectinfo.ThumbCompressedSize;
|
||||
fdata=malloc(size+PTP_REQ_HDR_LEN);
|
||||
CPR_free (camera, ptp_getthumb(&camera->pl->params,
|
||||
camera->pl->params.handles.handler[image_id],
|
||||
@@ -501,22 +499,22 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
|
||||
*/
|
||||
info->file.fields = GP_FILE_INFO_SIZE|GP_FILE_INFO_TYPE;
|
||||
|
||||
info->file.size = le32toh(oi.ObjectCompressedSize);
|
||||
info->file.size = oi.ObjectCompressedSize;
|
||||
strcpy_mime (info->file.type, oi.ObjectFormat);
|
||||
|
||||
if ((le16toh(oi.ObjectFormat) & 0x0800) != 0) {
|
||||
if ((oi.ObjectFormat & 0x0800) != 0) {
|
||||
info->preview.fields = GP_FILE_INFO_SIZE|GP_FILE_INFO_WIDTH
|
||||
|GP_FILE_INFO_HEIGHT|GP_FILE_INFO_TIME|GP_FILE_INFO_TYPE;
|
||||
strcpy_mime(info->preview.type, oi.ThumbFormat);
|
||||
info->preview.size = le32toh(oi.ThumbCompressedSize);
|
||||
info->preview.width = le32toh(oi.ThumbPixWidth);
|
||||
info->preview.height = le32toh(oi.ThumbPixHeight);
|
||||
info->preview.size = oi.ThumbCompressedSize;
|
||||
info->preview.width = oi.ThumbPixWidth;
|
||||
info->preview.height = oi.ThumbPixHeight;
|
||||
|
||||
info->file.fields = info->file.fields|GP_FILE_INFO_WIDTH|GP_FILE_INFO_HEIGHT|
|
||||
GP_FILE_INFO_TIME;
|
||||
|
||||
info->file.width = le32toh(oi.ImagePixWidth);
|
||||
info->file.height = le32toh(oi.ImagePixHeight);
|
||||
info->file.width = oi.ImagePixWidth;
|
||||
info->file.height = oi.ImagePixHeight;
|
||||
info->file.time = ptp_getobjectcapturedate (&oi);
|
||||
}
|
||||
|
||||
@@ -537,10 +535,10 @@ make_dir_func (CameraFilesystem *fs, const char *folder, const char *foldername,
|
||||
|
||||
// blackmagic, obtain ObjectHandle of upper folder
|
||||
// XXX 0xffffffff=root filesystem
|
||||
parent=htole32(0x00000000);
|
||||
parent=0x00000000;
|
||||
|
||||
// any store (responder decides)
|
||||
store=htole32(0xffffffff);
|
||||
store=0xffffffff;
|
||||
|
||||
ptp_setobjectfilename(&oi, foldername);
|
||||
|
||||
@@ -594,10 +592,10 @@ camera_init (Camera *camera)
|
||||
CR (gp_port_set_settings (camera->port, settings));
|
||||
|
||||
/* Establish a connection to the camera */
|
||||
ret=ptp_opensession (&camera->pl->params, htole32(1));
|
||||
ret=ptp_opensession (&camera->pl->params, 1);
|
||||
while (ret==PTP_RC_InvalidTransactionID) {
|
||||
camera->pl->params.transaction_id+=10;
|
||||
ret=ptp_opensession (&camera->pl->params, htole32(1));
|
||||
ret=ptp_opensession (&camera->pl->params, 1);
|
||||
}
|
||||
if (ret!=PTP_RC_SessionAlreadyOpened && ret!=PTP_RC_OK) {
|
||||
report_result(camera, ret);
|
||||
|
||||
@@ -96,7 +96,6 @@ ptp_sendreq (PTPParams* params, PTPReq* databuf, uint16_t code)
|
||||
ptp_error (params,
|
||||
"request code 0x%4x sending req error", le16toh(code));
|
||||
}
|
||||
// returned value is little endian
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -119,7 +118,6 @@ ptp_senddata (PTPParams* params, PTPReq* req, uint16_t code,
|
||||
ptp_error (params,
|
||||
"request code 0x%4x sending data error", le16toh(code));
|
||||
}
|
||||
// returned value is little endian
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -145,7 +143,6 @@ ptp_getdata (PTPParams* params, PTPReq* req, uint16_t code,
|
||||
if (ret!=PTP_RC_OK)
|
||||
ptp_error (params,
|
||||
"request code 0x%4.4x getting data error 0x%4.4x", le16toh(code), le16toh(ret));
|
||||
// returned value is in little endian
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -172,7 +169,6 @@ ptp_getresp (PTPParams* params, PTPReq* databuf, uint16_t code)
|
||||
ptp_error (params,
|
||||
"request code 0x%4x getting resp error 0x%4x", le16toh(code), le16toh(ret));
|
||||
if (databuf==NULL) free (req);
|
||||
// returned value is little endian
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -235,8 +231,8 @@ ptp_getdevinfo (PTPParams* params, PTPDedviceInfo* devinfo)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* WARNING all ptp_ functions take integer parameters
|
||||
* in little endian byte order!
|
||||
* all ptp_ functions should take integer parameters
|
||||
* in host byte order!
|
||||
**/
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user