clean up, wrap up bulk command supported

This commit is contained in:
hathach
2025-09-25 18:58:25 +07:00
parent 879f02f69c
commit 34be38db19
3 changed files with 0 additions and 153 deletions

View File

@ -513,96 +513,6 @@ int32_t tud_mtp_response_complete_cb(tud_mtp_cb_data_t* cb_data) {
return 0; // nothing to do
}
//--------------------------------------------------------------------+
// API
//--------------------------------------------------------------------+
#if 0
mtp_response_t tud_mtp_storage_format(uint32_t storage_id) {
if (_fs_operation.session_id == 0) {
TU_LOG1("ERR: Session not open\r\n");
return MTP_RESP_SESSION_NOT_OPEN;
}
if (storage_id != SUPPORTED_STORAGE_ID) {
TU_LOG1("ERR: Unexpected storage id %ld\r\n", storage_id);
return MTP_RESP_INVALID_STORAGE_ID;
}
// Simply deallocate all entries
for (unsigned int i = 0; i < FS_MAX_NODES; i++)
fs_objects[i].allocated = false;
TU_LOG1("Format completed\r\n");
return MTP_RESP_OK;
}
mtp_response_t tud_mtp_storage_object_move(uint32_t object_handle, uint32_t new_parent_object_handle) {
fs_file_t* obj;
if (new_parent_object_handle == 0xFFFFFFFF)
new_parent_object_handle = 0;
// Ensure we are not moving to an nonexisting parent
if (new_parent_object_handle != 0) {
obj = fs_get_file(new_parent_object_handle);
if (obj == NULL) {
TU_LOG1("Parent %ld does not exist\r\n", new_parent_object_handle);
return MTP_RESP_INVALID_PARENT_OBJECT;
}
if (!obj->association_type) {
TU_LOG1("Parent %ld is not an association\r\n", new_parent_object_handle);
return MTP_RESP_INVALID_PARENT_OBJECT;
}
}
obj = fs_get_file(object_handle);
if (obj == NULL) {
TU_LOG1("ERR: Object with handle %ld does not exist\r\n", object_handle);
return MTP_RESP_INVALID_OBJECT_HANDLE;
}
TU_LOG1("Move object %ld to new parent %ld\r\n", object_handle, new_parent_object_handle);
obj->parent = new_parent_object_handle;
return MTP_RESP_OK;
}
mtp_response_t tud_mtp_storage_object_delete(uint32_t object_handle) {
fs_file_t* obj;
if (_fs_operation.session_id == 0) {
TU_LOG1("ERR: Session not open\r\n");
return MTP_RESP_SESSION_NOT_OPEN;
}
if (object_handle == 0xFFFFFFFF)
object_handle = 0;
if (object_handle != 0) {
obj = fs_get_file(object_handle);
if (obj == NULL) {
TU_LOG1("ERR: Object with handle %ld does not exist\r\n", object_handle);
return MTP_RESP_INVALID_OBJECT_HANDLE;
}
obj->allocated = false;
TU_LOG1("Delete object with handle %ld\r\n", object_handle);
}
if (object_handle == 0 || obj->association_type) {
// Delete also children
for (unsigned int i = 0; i < FS_MAX_NODES; i++) {
obj = &fs_objects[i];
if (obj->allocated && obj->parent == object_handle) {
tud_mtp_storage_object_delete(obj->handle);
}
}
}
return MTP_RESP_OK;
}
void tud_mtp_storage_object_done(void) {
}
#endif
void tud_mtp_storage_cancel(void) {
}

View File

@ -102,14 +102,12 @@
MTP_OP_CLOSE_SESSION, \
MTP_OP_GET_STORAGE_IDS, \
MTP_OP_GET_STORAGE_INFO, \
MTP_OP_GET_NUM_OBJECTS, \
MTP_OP_GET_OBJECT_HANDLES, \
MTP_OP_GET_OBJECT_INFO, \
MTP_OP_GET_OBJECT, \
MTP_OP_DELETE_OBJECT, \
MTP_OP_SEND_OBJECT_INFO, \
MTP_OP_SEND_OBJECT, \
MTP_OP_FORMAT_STORE, \
MTP_OP_RESET_DEVICE, \
MTP_OP_GET_DEVICE_PROP_DESC, \
MTP_OP_GET_DEVICE_PROP_VALUE, \

View File

@ -76,13 +76,6 @@ typedef struct {
// INTERNAL FUNCTION DECLARATION
//--------------------------------------------------------------------+
static void process_cmd(mtpd_interface_t* p_mtp, tud_mtp_cb_data_t* cb_data);
static mtp_phase_type_t mtpd_handle_data(void);
static mtp_phase_type_t mtpd_handle_cmd_delete_object(void);
static mtp_phase_type_t mtpd_handle_cmd_send_object_info(void);
static mtp_phase_type_t mtpd_handle_dto_send_object_info(void);
static mtp_phase_type_t mtpd_handle_cmd_send_object(void);
static mtp_phase_type_t mtpd_handle_dto_send_object(void);
static mtp_phase_type_t mtpd_handle_cmd_format_store(void);
//--------------------------------------------------------------------+
// MTP variable declaration
@ -474,59 +467,5 @@ void process_cmd(mtpd_interface_t* p_mtp, tud_mtp_cb_data_t* cb_data) {
break;
}
}
#if 0
mtp_phase_type_t mtpd_handle_data(void)
{
mtp_generic_container_t* p_container = &_mtpd_epbuf.buf;
TU_ASSERT(p_container->type == MTP_CONTAINER_TYPE_DATA_BLOCK);
switch(p_container->code)
{
case MTP_OP_SEND_OBJECT_INFO:
TU_LOG_DRV(" MTP command: MTP_OP_SEND_OBJECT_INFO-DATA_OUT\n");
return mtpd_handle_dto_send_object_info();
case MTP_OP_SEND_OBJECT:
TU_LOG_DRV(" MTP command: MTP_OP_SEND_OBJECT-DATA_OUT\n");
return mtpd_handle_dto_send_object();
default:
TU_LOG_DRV(" MTP command: MTP_OP_UNKNOWN_COMMAND %x!!!!\n", p_container->code);
return false;
}
return true;
}
mtp_phase_type_t mtpd_handle_cmd_delete_object(void)
{
mtp_generic_container_t* p_container = &_mtpd_epbuf.buf;
uint32_t object_handle = p_container->data[0];
uint32_t object_code_format = p_container->data[1]; // not used
(void) object_code_format;
mtp_response_t res = tud_mtp_storage_object_delete(object_handle);
mtp_phase_type_t phase;
if ((phase = mtpd_chk_generic(__func__, (res != MTP_RESP_OK), res, "")) != MTP_PHASE_NONE) return phase;
p_container->type = MTP_CONTAINER_TYPE_RESPONSE_BLOCK;
p_container->code = MTP_RESP_OK;
p_container->len = MTP_CONTAINER_HEADER_LENGTH;
return MTP_PHASE_RESPONSE;
}
mtp_phase_type_t mtpd_handle_cmd_format_store(void)
{
mtp_generic_container_t* p_container = &_mtpd_epbuf.buf;
uint32_t storage_id = p_container->data[0];
uint32_t file_system_format = p_container->data[1]; // not used
(void) file_system_format;
mtp_response_t res = tud_mtp_storage_format(storage_id);
p_container->type = MTP_CONTAINER_TYPE_RESPONSE_BLOCK;
p_container->code = res;
p_container->len = MTP_CONTAINER_HEADER_LENGTH;
return MTP_PHASE_RESPONSE;
}
#endif
#endif